stream-chat-react 9.3.0 → 9.4.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.
@@ -13555,346 +13555,681 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
13555
13555
  var linkifyjs = linkify;
13556
13556
  var linkifyjs_1 = linkifyjs.find;
13557
13557
 
13558
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
13559
- var convert_1 = convert;
13560
-
13561
- function convert(test) {
13562
- if (test == null) {
13563
- return ok
13564
- }
13558
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};function escapeStringRegexp(string) {
13559
+ if (typeof string !== 'string') {
13560
+ throw new TypeError('Expected a string');
13561
+ }
13565
13562
 
13566
- if (typeof test === 'string') {
13567
- return typeFactory(test)
13568
- }
13563
+ // Escape characters with special meaning either inside or outside character sets.
13564
+ // Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
13565
+ return string
13566
+ .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
13567
+ .replace(/-/g, '\\x2d');
13568
+ }
13569
13569
 
13570
- if (typeof test === 'object') {
13571
- return 'length' in test ? anyFactory(test) : allFactory(test)
13572
- }
13570
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
13571
+ * @typedef {import('unist').Node} Node
13572
+ * @typedef {import('unist').Parent} Parent
13573
+ *
13574
+ * @typedef {string} Type
13575
+ * @typedef {Object<string, unknown>} Props
13576
+ *
13577
+ * @typedef {null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>} Test
13578
+ */
13573
13579
 
13574
- if (typeof test === 'function') {
13575
- return test
13576
- }
13580
+ const convert$2 =
13581
+ /**
13582
+ * @type {(
13583
+ * (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
13584
+ * ((test?: Test) => AssertAnything)
13585
+ * )}
13586
+ */
13587
+ (
13588
+ /**
13589
+ * Generate an assertion from a check.
13590
+ * @param {Test} [test]
13591
+ * When nullish, checks if `node` is a `Node`.
13592
+ * When `string`, works like passing `function (node) {return node.type === test}`.
13593
+ * When `function` checks if function passed the node is true.
13594
+ * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
13595
+ * When `array`, checks any one of the subtests pass.
13596
+ * @returns {AssertAnything}
13597
+ */
13598
+ function (test) {
13599
+ if (test === undefined || test === null) {
13600
+ return ok$2
13601
+ }
13577
13602
 
13578
- throw new Error('Expected function, string, or object as test')
13579
- }
13603
+ if (typeof test === 'string') {
13604
+ return typeFactory$2(test)
13605
+ }
13580
13606
 
13581
- // Utility assert each property in `test` is represented in `node`, and each
13582
- // values are strictly equal.
13583
- function allFactory(test) {
13584
- return all
13607
+ if (typeof test === 'object') {
13608
+ return Array.isArray(test) ? anyFactory$2(test) : propsFactory$1(test)
13609
+ }
13585
13610
 
13586
- function all(node) {
13587
- var key;
13611
+ if (typeof test === 'function') {
13612
+ return castFactory$1(test)
13613
+ }
13588
13614
 
13589
- for (key in test) {
13590
- if (node[key] !== test[key]) return false
13615
+ throw new Error('Expected function, string, or object as test')
13591
13616
  }
13592
-
13593
- return true
13594
- }
13595
- }
13596
-
13597
- function anyFactory(tests) {
13598
- var checks = [];
13599
- var index = -1;
13617
+ );
13618
+ /**
13619
+ * @param {Array.<Type|Props|TestFunctionAnything>} tests
13620
+ * @returns {AssertAnything}
13621
+ */
13622
+ function anyFactory$2(tests) {
13623
+ /** @type {Array.<AssertAnything>} */
13624
+ const checks = [];
13625
+ let index = -1;
13600
13626
 
13601
13627
  while (++index < tests.length) {
13602
- checks[index] = convert(tests[index]);
13628
+ checks[index] = convert$2(tests[index]);
13603
13629
  }
13604
13630
 
13605
- return any
13631
+ return castFactory$1(any)
13606
13632
 
13607
- function any() {
13608
- var index = -1;
13633
+ /**
13634
+ * @this {unknown}
13635
+ * @param {unknown[]} parameters
13636
+ * @returns {boolean}
13637
+ */
13638
+ function any(...parameters) {
13639
+ let index = -1;
13609
13640
 
13610
13641
  while (++index < checks.length) {
13611
- if (checks[index].apply(this, arguments)) {
13612
- return true
13613
- }
13642
+ if (checks[index].call(this, ...parameters)) return true
13614
13643
  }
13615
13644
 
13616
13645
  return false
13617
13646
  }
13618
13647
  }
13619
13648
 
13620
- // Utility to convert a string into a function which checks a given node’s type
13621
- // for said string.
13622
- function typeFactory(test) {
13623
- return type
13649
+ /**
13650
+ * Utility to assert each property in `test` is represented in `node`, and each
13651
+ * values are strictly equal.
13652
+ *
13653
+ * @param {Props} check
13654
+ * @returns {AssertAnything}
13655
+ */
13656
+ function propsFactory$1(check) {
13657
+ return castFactory$1(all)
13624
13658
 
13625
- function type(node) {
13626
- return Boolean(node && node.type === test)
13627
- }
13628
- }
13659
+ /**
13660
+ * @param {Node} node
13661
+ * @returns {boolean}
13662
+ */
13663
+ function all(node) {
13664
+ /** @type {string} */
13665
+ let key;
13629
13666
 
13630
- // Utility to return true.
13631
- function ok() {
13632
- return true
13633
- }
13667
+ for (key in check) {
13668
+ // @ts-expect-error: hush, it sure works as an index.
13669
+ if (node[key] !== check[key]) return false
13670
+ }
13634
13671
 
13635
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var color_1 = color;
13636
- function color(d) {
13637
- return '\u001B[33m' + d + '\u001B[39m'
13672
+ return true
13673
+ }
13638
13674
  }
13639
13675
 
13640
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
13641
- var unistUtilVisitParents$1 = visitParents$1;
13676
+ /**
13677
+ * Utility to convert a string into a function which checks a given node’s type
13678
+ * for said string.
13679
+ *
13680
+ * @param {Type} check
13681
+ * @returns {AssertAnything}
13682
+ */
13683
+ function typeFactory$2(check) {
13684
+ return castFactory$1(type)
13642
13685
 
13686
+ /**
13687
+ * @param {Node} node
13688
+ */
13689
+ function type(node) {
13690
+ return node && node.type === check
13691
+ }
13692
+ }
13643
13693
 
13694
+ /**
13695
+ * Utility to convert a string into a function which checks a given node’s type
13696
+ * for said string.
13697
+ * @param {TestFunctionAnything} check
13698
+ * @returns {AssertAnything}
13699
+ */
13700
+ function castFactory$1(check) {
13701
+ return assertion
13644
13702
 
13703
+ /**
13704
+ * @this {unknown}
13705
+ * @param {Array.<unknown>} parameters
13706
+ * @returns {boolean}
13707
+ */
13708
+ function assertion(...parameters) {
13709
+ // @ts-expect-error: spreading is fine.
13710
+ return Boolean(check.call(this, ...parameters))
13711
+ }
13712
+ }
13645
13713
 
13646
- var CONTINUE$1 = true;
13647
- var SKIP$1 = 'skip';
13648
- var EXIT$1 = false;
13714
+ // Utility to return true.
13715
+ function ok$2() {
13716
+ return true
13717
+ }
13649
13718
 
13650
- visitParents$1.CONTINUE = CONTINUE$1;
13651
- visitParents$1.SKIP = SKIP$1;
13652
- visitParents$1.EXIT = EXIT$1;
13719
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
13720
+ * @param {string} d
13721
+ * @returns {string}
13722
+ */
13723
+ function color$1(d) {
13724
+ return d
13725
+ }
13653
13726
 
13654
- function visitParents$1(tree, test, visitor, reverse) {
13655
- var step;
13656
- var is;
13727
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
13728
+ * @typedef {import('unist').Node} Node
13729
+ * @typedef {import('unist').Parent} Parent
13730
+ * @typedef {import('unist-util-is').Test} Test
13731
+ * @typedef {import('./complex-types').Action} Action
13732
+ * @typedef {import('./complex-types').Index} Index
13733
+ * @typedef {import('./complex-types').ActionTuple} ActionTuple
13734
+ * @typedef {import('./complex-types').VisitorResult} VisitorResult
13735
+ * @typedef {import('./complex-types').Visitor} Visitor
13736
+ */
13657
13737
 
13658
- if (typeof test === 'function' && typeof visitor !== 'function') {
13659
- reverse = visitor;
13660
- visitor = test;
13661
- test = null;
13662
- }
13738
+ /**
13739
+ * Continue traversing as normal
13740
+ */
13741
+ const CONTINUE$2 = true;
13742
+ /**
13743
+ * Do not traverse this node’s children
13744
+ */
13745
+ const SKIP$2 = 'skip';
13746
+ /**
13747
+ * Stop traversing immediately
13748
+ */
13749
+ const EXIT$2 = false;
13663
13750
 
13664
- is = convert_1(test);
13665
- step = reverse ? -1 : 1;
13751
+ /**
13752
+ * Visit children of tree which pass a test
13753
+ *
13754
+ * @param tree Abstract syntax tree to walk
13755
+ * @param test Test node, optional
13756
+ * @param visitor Function to run for each node
13757
+ * @param reverse Visit the tree in reverse order, defaults to false
13758
+ */
13759
+ const visitParents$2 =
13760
+ /**
13761
+ * @type {(
13762
+ * (<Tree extends Node, Check extends Test>(tree: Tree, test: Check, visitor: import('./complex-types').BuildVisitor<Tree, Check>, reverse?: boolean) => void) &
13763
+ * (<Tree extends Node>(tree: Tree, visitor: import('./complex-types').BuildVisitor<Tree>, reverse?: boolean) => void)
13764
+ * )}
13765
+ */
13766
+ (
13767
+ /**
13768
+ * @param {Node} tree
13769
+ * @param {Test} test
13770
+ * @param {import('./complex-types').Visitor<Node>} visitor
13771
+ * @param {boolean} [reverse]
13772
+ */
13773
+ function (tree, test, visitor, reverse) {
13774
+ if (typeof test === 'function' && typeof visitor !== 'function') {
13775
+ reverse = visitor;
13776
+ // @ts-expect-error no visitor given, so `visitor` is test.
13777
+ visitor = test;
13778
+ test = null;
13779
+ }
13666
13780
 
13667
- factory(tree, null, [])();
13781
+ const is = convert$2(test);
13782
+ const step = reverse ? -1 : 1;
13668
13783
 
13669
- function factory(node, index, parents) {
13670
- var value = typeof node === 'object' && node !== null ? node : {};
13671
- var name;
13784
+ factory(tree, null, [])();
13672
13785
 
13673
- if (typeof value.type === 'string') {
13674
- name =
13675
- typeof value.tagName === 'string'
13676
- ? value.tagName
13677
- : typeof value.name === 'string'
13678
- ? value.name
13679
- : undefined;
13786
+ /**
13787
+ * @param {Node} node
13788
+ * @param {number?} index
13789
+ * @param {Array.<Parent>} parents
13790
+ */
13791
+ function factory(node, index, parents) {
13792
+ /** @type {Object.<string, unknown>} */
13793
+ // @ts-expect-error: hush
13794
+ const value = typeof node === 'object' && node !== null ? node : {};
13795
+ /** @type {string|undefined} */
13796
+ let name;
13797
+
13798
+ if (typeof value.type === 'string') {
13799
+ name =
13800
+ typeof value.tagName === 'string'
13801
+ ? value.tagName
13802
+ : typeof value.name === 'string'
13803
+ ? value.name
13804
+ : undefined;
13805
+
13806
+ Object.defineProperty(visit, 'name', {
13807
+ value:
13808
+ 'node (' +
13809
+ color$1(value.type + (name ? '<' + name + '>' : '')) +
13810
+ ')'
13811
+ });
13812
+ }
13680
13813
 
13681
- visit.displayName =
13682
- 'node (' + color_1(value.type + (name ? '<' + name + '>' : '')) + ')';
13683
- }
13814
+ return visit
13684
13815
 
13685
- return visit
13816
+ function visit() {
13817
+ /** @type {ActionTuple} */
13818
+ let result = [];
13819
+ /** @type {ActionTuple} */
13820
+ let subresult;
13821
+ /** @type {number} */
13822
+ let offset;
13823
+ /** @type {Array.<Parent>} */
13824
+ let grandparents;
13686
13825
 
13687
- function visit() {
13688
- var grandparents = parents.concat(node);
13689
- var result = [];
13690
- var subresult;
13691
- var offset;
13826
+ if (!test || is(node, index, parents[parents.length - 1] || null)) {
13827
+ result = toResult$1(visitor(node, parents));
13692
13828
 
13693
- if (!test || is(node, index, parents[parents.length - 1] || null)) {
13694
- result = toResult(visitor(node, parents));
13829
+ if (result[0] === EXIT$2) {
13830
+ return result
13831
+ }
13832
+ }
13695
13833
 
13696
- if (result[0] === EXIT$1) {
13697
- return result
13698
- }
13699
- }
13834
+ // @ts-expect-error looks like a parent.
13835
+ if (node.children && result[0] !== SKIP$2) {
13836
+ // @ts-expect-error looks like a parent.
13837
+ offset = (reverse ? node.children.length : -1) + step;
13838
+ // @ts-expect-error looks like a parent.
13839
+ grandparents = parents.concat(node);
13700
13840
 
13701
- if (node.children && result[0] !== SKIP$1) {
13702
- offset = (reverse ? node.children.length : -1) + step;
13841
+ // @ts-expect-error looks like a parent.
13842
+ while (offset > -1 && offset < node.children.length) {
13843
+ // @ts-expect-error looks like a parent.
13844
+ subresult = factory(node.children[offset], offset, grandparents)();
13703
13845
 
13704
- while (offset > -1 && offset < node.children.length) {
13705
- subresult = factory(node.children[offset], offset, grandparents)();
13846
+ if (subresult[0] === EXIT$2) {
13847
+ return subresult
13848
+ }
13706
13849
 
13707
- if (subresult[0] === EXIT$1) {
13708
- return subresult
13850
+ offset =
13851
+ typeof subresult[1] === 'number' ? subresult[1] : offset + step;
13852
+ }
13709
13853
  }
13710
13854
 
13711
- offset =
13712
- typeof subresult[1] === 'number' ? subresult[1] : offset + step;
13855
+ return result
13713
13856
  }
13714
13857
  }
13715
-
13716
- return result
13717
13858
  }
13718
- }
13719
- }
13859
+ );
13720
13860
 
13721
- function toResult(value) {
13722
- if (value !== null && typeof value === 'object' && 'length' in value) {
13861
+ /**
13862
+ * @param {VisitorResult} value
13863
+ * @returns {ActionTuple}
13864
+ */
13865
+ function toResult$1(value) {
13866
+ if (Array.isArray(value)) {
13723
13867
  return value
13724
13868
  }
13725
13869
 
13726
13870
  if (typeof value === 'number') {
13727
- return [CONTINUE$1, value]
13871
+ return [CONTINUE$2, value]
13728
13872
  }
13729
13873
 
13730
13874
  return [value]
13731
13875
  }
13732
13876
 
13733
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
13734
- var escapeStringRegexp = string => {
13735
- if (typeof string !== 'string') {
13736
- throw new TypeError('Expected a string');
13737
- }
13877
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
13878
+ * @typedef {import('unist').Node} Node
13879
+ * @typedef {import('unist').Parent} Parent
13880
+ *
13881
+ * @typedef {string} Type
13882
+ * @typedef {Object<string, unknown>} Props
13883
+ *
13884
+ * @typedef {null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>} Test
13885
+ */
13738
13886
 
13739
- // Escape characters with special meaning either inside or outside character sets.
13740
- // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
13741
- return string
13742
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
13743
- .replace(/-/g, '\\x2d');
13744
- };
13887
+ const convert$1 =
13888
+ /**
13889
+ * @type {(
13890
+ * (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
13891
+ * ((test?: Test) => AssertAnything)
13892
+ * )}
13893
+ */
13894
+ (
13895
+ /**
13896
+ * Generate an assertion from a check.
13897
+ * @param {Test} [test]
13898
+ * When nullish, checks if `node` is a `Node`.
13899
+ * When `string`, works like passing `function (node) {return node.type === test}`.
13900
+ * When `function` checks if function passed the node is true.
13901
+ * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
13902
+ * When `array`, checks any one of the subtests pass.
13903
+ * @returns {AssertAnything}
13904
+ */
13905
+ function (test) {
13906
+ if (test === undefined || test === null) {
13907
+ return ok$1
13908
+ }
13745
13909
 
13746
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
13747
- var mdastUtilFindAndReplace = findAndReplace;
13910
+ if (typeof test === 'string') {
13911
+ return typeFactory$1(test)
13912
+ }
13748
13913
 
13914
+ if (typeof test === 'object') {
13915
+ return Array.isArray(test) ? anyFactory$1(test) : propsFactory(test)
13916
+ }
13749
13917
 
13918
+ if (typeof test === 'function') {
13919
+ return castFactory(test)
13920
+ }
13750
13921
 
13922
+ throw new Error('Expected function, string, or object as test')
13923
+ }
13924
+ );
13925
+ /**
13926
+ * @param {Array.<Type|Props|TestFunctionAnything>} tests
13927
+ * @returns {AssertAnything}
13928
+ */
13929
+ function anyFactory$1(tests) {
13930
+ /** @type {Array.<AssertAnything>} */
13931
+ const checks = [];
13932
+ let index = -1;
13933
+
13934
+ while (++index < tests.length) {
13935
+ checks[index] = convert$1(tests[index]);
13936
+ }
13937
+
13938
+ return castFactory(any)
13751
13939
 
13940
+ /**
13941
+ * @this {unknown}
13942
+ * @param {unknown[]} parameters
13943
+ * @returns {boolean}
13944
+ */
13945
+ function any(...parameters) {
13946
+ let index = -1;
13752
13947
 
13753
- var splice$2 = [].splice;
13948
+ while (++index < checks.length) {
13949
+ if (checks[index].call(this, ...parameters)) return true
13950
+ }
13754
13951
 
13755
- function findAndReplace(tree, find, replace, options) {
13756
- var settings;
13757
- var schema;
13952
+ return false
13953
+ }
13954
+ }
13758
13955
 
13759
- if (typeof find === 'string' || (find && typeof find.exec === 'function')) {
13760
- schema = [[find, replace]];
13761
- } else {
13762
- schema = find;
13763
- options = replace;
13956
+ /**
13957
+ * Utility to assert each property in `test` is represented in `node`, and each
13958
+ * values are strictly equal.
13959
+ *
13960
+ * @param {Props} check
13961
+ * @returns {AssertAnything}
13962
+ */
13963
+ function propsFactory(check) {
13964
+ return castFactory(all)
13965
+
13966
+ /**
13967
+ * @param {Node} node
13968
+ * @returns {boolean}
13969
+ */
13970
+ function all(node) {
13971
+ /** @type {string} */
13972
+ let key;
13973
+
13974
+ for (key in check) {
13975
+ // @ts-expect-error: hush, it sure works as an index.
13976
+ if (node[key] !== check[key]) return false
13977
+ }
13978
+
13979
+ return true
13764
13980
  }
13981
+ }
13765
13982
 
13766
- settings = options || {};
13983
+ /**
13984
+ * Utility to convert a string into a function which checks a given node’s type
13985
+ * for said string.
13986
+ *
13987
+ * @param {Type} check
13988
+ * @returns {AssertAnything}
13989
+ */
13990
+ function typeFactory$1(check) {
13991
+ return castFactory(type)
13767
13992
 
13768
- search$2(tree, settings, handlerFactory(toPairs$1(schema)));
13993
+ /**
13994
+ * @param {Node} node
13995
+ */
13996
+ function type(node) {
13997
+ return node && node.type === check
13998
+ }
13999
+ }
14000
+
14001
+ /**
14002
+ * Utility to convert a string into a function which checks a given node’s type
14003
+ * for said string.
14004
+ * @param {TestFunctionAnything} check
14005
+ * @returns {AssertAnything}
14006
+ */
14007
+ function castFactory(check) {
14008
+ return assertion
14009
+
14010
+ /**
14011
+ * @this {unknown}
14012
+ * @param {Array.<unknown>} parameters
14013
+ * @returns {boolean}
14014
+ */
14015
+ function assertion(...parameters) {
14016
+ // @ts-expect-error: spreading is fine.
14017
+ return Boolean(check.call(this, ...parameters))
14018
+ }
14019
+ }
14020
+
14021
+ // Utility to return true.
14022
+ function ok$1() {
14023
+ return true
14024
+ }
13769
14025
 
13770
- return tree
14026
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};/**
14027
+ * @typedef Options
14028
+ * Configuration (optional).
14029
+ * @property {Test} [ignore]
14030
+ * `unist-util-is` test used to assert parents
14031
+ *
14032
+ * @typedef {import('mdast').Root} Root
14033
+ * @typedef {import('mdast').Content} Content
14034
+ * @typedef {import('mdast').PhrasingContent} PhrasingContent
14035
+ * @typedef {import('mdast').Text} Text
14036
+ * @typedef {Content|Root} Node
14037
+ * @typedef {Exclude<Extract<Node, import('mdast').Parent>, Root>} Parent
14038
+ *
14039
+ * @typedef {import('unist-util-visit-parents').Test} Test
14040
+ * @typedef {import('unist-util-visit-parents').VisitorResult} VisitorResult
14041
+ *
14042
+ * @typedef RegExpMatchObject
14043
+ * @property {number} index
14044
+ * @property {string} input
14045
+ * @property {[Root, ...Array<Parent>, Text]} stack
14046
+ *
14047
+ * @typedef {string|RegExp} Find
14048
+ * @typedef {string|ReplaceFunction} Replace
14049
+ *
14050
+ * @typedef {[Find, Replace]} FindAndReplaceTuple
14051
+ * @typedef {Record<string, Replace>} FindAndReplaceSchema
14052
+ * @typedef {Array<FindAndReplaceTuple>} FindAndReplaceList
14053
+ *
14054
+ * @typedef {[RegExp, ReplaceFunction]} Pair
14055
+ * @typedef {Array<Pair>} Pairs
14056
+ */
13771
14057
 
13772
- function handlerFactory(pairs) {
13773
- var pair = pairs[0];
14058
+ const own$5 = {}.hasOwnProperty;
13774
14059
 
13775
- return handler
14060
+ /**
14061
+ * @param tree mdast tree
14062
+ * @param find Value to find and remove. When `string`, escaped and made into a global `RegExp`
14063
+ * @param [replace] Value to insert.
14064
+ * * When `string`, turned into a Text node.
14065
+ * * When `Function`, called with the results of calling `RegExp.exec` as
14066
+ * arguments, in which case it can return a single or a list of `Node`,
14067
+ * a `string` (which is wrapped in a `Text` node), or `false` to not replace
14068
+ * @param [options] Configuration.
14069
+ */
14070
+ const findAndReplace =
14071
+ /**
14072
+ * @type {(
14073
+ * ((tree: Node, find: Find, replace?: Replace, options?: Options) => Node) &
14074
+ * ((tree: Node, schema: FindAndReplaceSchema|FindAndReplaceList, options?: Options) => Node)
14075
+ * )}
14076
+ **/
14077
+ (
14078
+ /**
14079
+ * @param {Node} tree
14080
+ * @param {Find|FindAndReplaceSchema|FindAndReplaceList} find
14081
+ * @param {Replace|Options} [replace]
14082
+ * @param {Options} [options]
14083
+ */
14084
+ function (tree, find, replace, options) {
14085
+ /** @type {Options|undefined} */
14086
+ let settings;
14087
+ /** @type {FindAndReplaceSchema|FindAndReplaceList} */
14088
+ let schema;
14089
+
14090
+ if (typeof find === 'string' || find instanceof RegExp) {
14091
+ // @ts-expect-error don’t expect options twice.
14092
+ schema = [[find, replace]];
14093
+ settings = options;
14094
+ } else {
14095
+ schema = find;
14096
+ // @ts-expect-error don’t expect replace twice.
14097
+ settings = replace;
14098
+ }
13776
14099
 
13777
- function handler(node, parent) {
13778
- var find = pair[0];
13779
- var replace = pair[1];
13780
- var nodes = [];
13781
- var start = 0;
13782
- var index = parent.children.indexOf(node);
13783
- var position;
13784
- var match;
13785
- var subhandler;
13786
- var value;
14100
+ if (!settings) {
14101
+ settings = {};
14102
+ }
13787
14103
 
13788
- find.lastIndex = 0;
14104
+ const ignored = convert$1(settings.ignore || []);
14105
+ const pairs = toPairs$1(schema);
14106
+ let pairIndex = -1;
13789
14107
 
13790
- match = find.exec(node.value);
14108
+ while (++pairIndex < pairs.length) {
14109
+ visitParents$2(tree, 'text', visitor);
14110
+ }
13791
14111
 
13792
- while (match) {
13793
- position = match.index;
13794
- value = replace.apply(
13795
- null,
13796
- [].concat(match, {index: match.index, input: match.input})
13797
- );
14112
+ return tree
13798
14113
 
13799
- if (value !== false) {
13800
- if (start !== position) {
13801
- nodes.push({type: 'text', value: node.value.slice(start, position)});
13802
- }
14114
+ /** @type {import('unist-util-visit-parents/complex-types').BuildVisitor<Root, 'text'>} */
14115
+ function visitor(node, parents) {
14116
+ let index = -1;
14117
+ /** @type {Parent|undefined} */
14118
+ let grandparent;
13803
14119
 
13804
- if (typeof value === 'string' && value.length > 0) {
13805
- value = {type: 'text', value: value};
13806
- }
14120
+ while (++index < parents.length) {
14121
+ const parent = /** @type {Parent} */ (parents[index]);
13807
14122
 
13808
- if (value) {
13809
- nodes = [].concat(nodes, value);
14123
+ if (
14124
+ ignored(
14125
+ parent,
14126
+ // @ts-expect-error mdast vs. unist parent.
14127
+ grandparent ? grandparent.children.indexOf(parent) : undefined,
14128
+ grandparent
14129
+ )
14130
+ ) {
14131
+ return
13810
14132
  }
13811
14133
 
13812
- start = position + match[0].length;
14134
+ grandparent = parent;
13813
14135
  }
13814
14136
 
13815
- if (!find.global) {
13816
- break
14137
+ if (grandparent) {
14138
+ // @ts-expect-error: stack is fine.
14139
+ return handler(node, parents)
13817
14140
  }
13818
-
13819
- match = find.exec(node.value);
13820
14141
  }
13821
14142
 
13822
- if (position === undefined) {
13823
- nodes = [node];
13824
- index--;
13825
- } else {
13826
- if (start < node.value.length) {
13827
- nodes.push({type: 'text', value: node.value.slice(start)});
13828
- }
14143
+ /**
14144
+ * @param {Text} node
14145
+ * @param {[Root, ...Array<Parent>]} parents
14146
+ * @returns {VisitorResult}
14147
+ */
14148
+ function handler(node, parents) {
14149
+ const parent = parents[parents.length - 1];
14150
+ const find = pairs[pairIndex][0];
14151
+ const replace = pairs[pairIndex][1];
14152
+ let start = 0;
14153
+ // @ts-expect-error: TS is wrong, some of these children can be text.
14154
+ const index = parent.children.indexOf(node);
14155
+ let change = false;
14156
+ /** @type {Array<PhrasingContent>} */
14157
+ let nodes = [];
14158
+ /** @type {number|undefined} */
14159
+ let position;
14160
+
14161
+ find.lastIndex = 0;
14162
+
14163
+ let match = find.exec(node.value);
14164
+
14165
+ while (match) {
14166
+ position = match.index;
14167
+ /** @type {RegExpMatchObject} */
14168
+ const matchObject = {
14169
+ index: match.index,
14170
+ input: match.input,
14171
+ stack: [...parents, node]
14172
+ };
14173
+ let value = replace(...match, matchObject);
13829
14174
 
13830
- nodes.unshift(index, 1);
13831
- splice$2.apply(parent.children, nodes);
13832
- }
14175
+ if (typeof value === 'string') {
14176
+ value = value.length > 0 ? {type: 'text', value} : undefined;
14177
+ }
13833
14178
 
13834
- if (pairs.length > 1) {
13835
- subhandler = handlerFactory(pairs.slice(1));
13836
- position = -1;
14179
+ if (value !== false) {
14180
+ if (start !== position) {
14181
+ nodes.push({
14182
+ type: 'text',
14183
+ value: node.value.slice(start, position)
14184
+ });
14185
+ }
13837
14186
 
13838
- while (++position < nodes.length) {
13839
- node = nodes[position];
14187
+ if (Array.isArray(value)) {
14188
+ nodes.push(...value);
14189
+ } else if (value) {
14190
+ nodes.push(value);
14191
+ }
13840
14192
 
13841
- if (node.type === 'text') {
13842
- subhandler(node, parent);
13843
- } else {
13844
- search$2(node, settings, subhandler);
14193
+ start = position + match[0].length;
14194
+ change = true;
13845
14195
  }
13846
- }
13847
- }
13848
-
13849
- return index + nodes.length + 1
13850
- }
13851
- }
13852
- }
13853
-
13854
- function search$2(tree, settings, handler) {
13855
- var ignored = convert_1(settings.ignore || []);
13856
- var result = [];
13857
14196
 
13858
- unistUtilVisitParents$1(tree, 'text', visitor);
14197
+ if (!find.global) {
14198
+ break
14199
+ }
13859
14200
 
13860
- return result
14201
+ match = find.exec(node.value);
14202
+ }
13861
14203
 
13862
- function visitor(node, parents) {
13863
- var index = -1;
13864
- var parent;
13865
- var grandparent;
14204
+ if (change) {
14205
+ if (start < node.value.length) {
14206
+ nodes.push({type: 'text', value: node.value.slice(start)});
14207
+ }
13866
14208
 
13867
- while (++index < parents.length) {
13868
- parent = parents[index];
14209
+ parent.children.splice(index, 1, ...nodes);
14210
+ } else {
14211
+ nodes = [node];
14212
+ }
13869
14213
 
13870
- if (
13871
- ignored(
13872
- parent,
13873
- grandparent ? grandparent.children.indexOf(parent) : undefined,
13874
- grandparent
13875
- )
13876
- ) {
13877
- return
14214
+ return index + nodes.length
13878
14215
  }
13879
-
13880
- grandparent = parent;
13881
14216
  }
14217
+ );
13882
14218
 
13883
- return handler(node, grandparent)
13884
- }
13885
- }
13886
-
14219
+ /**
14220
+ * @param {FindAndReplaceSchema|FindAndReplaceList} schema
14221
+ * @returns {Pairs}
14222
+ */
13887
14223
  function toPairs$1(schema) {
13888
- var result = [];
13889
- var key;
13890
- var index;
14224
+ /** @type {Pairs} */
14225
+ const result = [];
13891
14226
 
13892
14227
  if (typeof schema !== 'object') {
13893
- throw new Error('Expected array or object as schema')
14228
+ throw new TypeError('Expected array or object as schema')
13894
14229
  }
13895
14230
 
13896
- if ('length' in schema) {
13897
- index = -1;
14231
+ if (Array.isArray(schema)) {
14232
+ let index = -1;
13898
14233
 
13899
14234
  while (++index < schema.length) {
13900
14235
  result.push([
@@ -13903,24 +14238,33 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
13903
14238
  ]);
13904
14239
  }
13905
14240
  } else {
14241
+ /** @type {string} */
14242
+ let key;
14243
+
13906
14244
  for (key in schema) {
13907
- result.push([toExpression(key), toFunction(schema[key])]);
14245
+ if (own$5.call(schema, key)) {
14246
+ result.push([toExpression(key), toFunction(schema[key])]);
14247
+ }
13908
14248
  }
13909
14249
  }
13910
14250
 
13911
14251
  return result
13912
14252
  }
13913
14253
 
14254
+ /**
14255
+ * @param {Find} find
14256
+ * @returns {RegExp}
14257
+ */
13914
14258
  function toExpression(find) {
13915
14259
  return typeof find === 'string' ? new RegExp(escapeStringRegexp(find), 'g') : find
13916
14260
  }
13917
14261
 
14262
+ /**
14263
+ * @param {Replace} replace
14264
+ * @returns {ReplaceFunction}
14265
+ */
13918
14266
  function toFunction(replace) {
13919
- return typeof replace === 'function' ? replace : returner
13920
-
13921
- function returner() {
13922
- return replace
13923
- }
14267
+ return typeof replace === 'function' ? replace : () => replace
13924
14268
  }
13925
14269
 
13926
14270
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var immutable = extend$1;
@@ -23943,10 +24287,10 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
23943
24287
 
23944
24288
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
23945
24289
  /* Expose. */
23946
- var unistUtilVisitParents = visitParents;
24290
+ var unistUtilVisitParents$1 = visitParents$1;
23947
24291
 
23948
24292
  /* Visit. */
23949
- function visitParents(tree, type, visitor) {
24293
+ function visitParents$1(tree, type, visitor) {
23950
24294
  var stack = [];
23951
24295
 
23952
24296
  if (typeof type === 'function') {
@@ -23996,7 +24340,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
23996
24340
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
23997
24341
  function addListMetadata() {
23998
24342
  return function (ast) {
23999
- unistUtilVisitParents(ast, 'list', function (listNode, parents) {
24343
+ unistUtilVisitParents$1(ast, 'list', function (listNode, parents) {
24000
24344
  var depth = 0, i, n;
24001
24345
  for (i = 0, n = parents.length; i < n; i++) {
24002
24346
  if (parents[i].type === 'list') depth += 1;
@@ -24014,14 +24358,189 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
24014
24358
 
24015
24359
  var mdastAddListMetadata = addListMetadata;
24016
24360
 
24361
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
24362
+ var convert_1 = convert;
24363
+
24364
+ function convert(test) {
24365
+ if (test == null) {
24366
+ return ok
24367
+ }
24368
+
24369
+ if (typeof test === 'string') {
24370
+ return typeFactory(test)
24371
+ }
24372
+
24373
+ if (typeof test === 'object') {
24374
+ return 'length' in test ? anyFactory(test) : allFactory(test)
24375
+ }
24376
+
24377
+ if (typeof test === 'function') {
24378
+ return test
24379
+ }
24380
+
24381
+ throw new Error('Expected function, string, or object as test')
24382
+ }
24383
+
24384
+ // Utility assert each property in `test` is represented in `node`, and each
24385
+ // values are strictly equal.
24386
+ function allFactory(test) {
24387
+ return all
24388
+
24389
+ function all(node) {
24390
+ var key;
24391
+
24392
+ for (key in test) {
24393
+ if (node[key] !== test[key]) return false
24394
+ }
24395
+
24396
+ return true
24397
+ }
24398
+ }
24399
+
24400
+ function anyFactory(tests) {
24401
+ var checks = [];
24402
+ var index = -1;
24403
+
24404
+ while (++index < tests.length) {
24405
+ checks[index] = convert(tests[index]);
24406
+ }
24407
+
24408
+ return any
24409
+
24410
+ function any() {
24411
+ var index = -1;
24412
+
24413
+ while (++index < checks.length) {
24414
+ if (checks[index].apply(this, arguments)) {
24415
+ return true
24416
+ }
24417
+ }
24418
+
24419
+ return false
24420
+ }
24421
+ }
24422
+
24423
+ // Utility to convert a string into a function which checks a given node’s type
24424
+ // for said string.
24425
+ function typeFactory(test) {
24426
+ return type
24427
+
24428
+ function type(node) {
24429
+ return Boolean(node && node.type === test)
24430
+ }
24431
+ }
24432
+
24433
+ // Utility to return true.
24434
+ function ok() {
24435
+ return true
24436
+ }
24437
+
24438
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var color_1 = color;
24439
+ function color(d) {
24440
+ return '\u001B[33m' + d + '\u001B[39m'
24441
+ }
24442
+
24443
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
24444
+ var unistUtilVisitParents = visitParents;
24445
+
24446
+
24447
+
24448
+
24449
+ var CONTINUE$1 = true;
24450
+ var SKIP$1 = 'skip';
24451
+ var EXIT$1 = false;
24452
+
24453
+ visitParents.CONTINUE = CONTINUE$1;
24454
+ visitParents.SKIP = SKIP$1;
24455
+ visitParents.EXIT = EXIT$1;
24456
+
24457
+ function visitParents(tree, test, visitor, reverse) {
24458
+ var step;
24459
+ var is;
24460
+
24461
+ if (typeof test === 'function' && typeof visitor !== 'function') {
24462
+ reverse = visitor;
24463
+ visitor = test;
24464
+ test = null;
24465
+ }
24466
+
24467
+ is = convert_1(test);
24468
+ step = reverse ? -1 : 1;
24469
+
24470
+ factory(tree, null, [])();
24471
+
24472
+ function factory(node, index, parents) {
24473
+ var value = typeof node === 'object' && node !== null ? node : {};
24474
+ var name;
24475
+
24476
+ if (typeof value.type === 'string') {
24477
+ name =
24478
+ typeof value.tagName === 'string'
24479
+ ? value.tagName
24480
+ : typeof value.name === 'string'
24481
+ ? value.name
24482
+ : undefined;
24483
+
24484
+ visit.displayName =
24485
+ 'node (' + color_1(value.type + (name ? '<' + name + '>' : '')) + ')';
24486
+ }
24487
+
24488
+ return visit
24489
+
24490
+ function visit() {
24491
+ var grandparents = parents.concat(node);
24492
+ var result = [];
24493
+ var subresult;
24494
+ var offset;
24495
+
24496
+ if (!test || is(node, index, parents[parents.length - 1] || null)) {
24497
+ result = toResult(visitor(node, parents));
24498
+
24499
+ if (result[0] === EXIT$1) {
24500
+ return result
24501
+ }
24502
+ }
24503
+
24504
+ if (node.children && result[0] !== SKIP$1) {
24505
+ offset = (reverse ? node.children.length : -1) + step;
24506
+
24507
+ while (offset > -1 && offset < node.children.length) {
24508
+ subresult = factory(node.children[offset], offset, grandparents)();
24509
+
24510
+ if (subresult[0] === EXIT$1) {
24511
+ return subresult
24512
+ }
24513
+
24514
+ offset =
24515
+ typeof subresult[1] === 'number' ? subresult[1] : offset + step;
24516
+ }
24517
+ }
24518
+
24519
+ return result
24520
+ }
24521
+ }
24522
+ }
24523
+
24524
+ function toResult(value) {
24525
+ if (value !== null && typeof value === 'object' && 'length' in value) {
24526
+ return value
24527
+ }
24528
+
24529
+ if (typeof value === 'number') {
24530
+ return [CONTINUE$1, value]
24531
+ }
24532
+
24533
+ return [value]
24534
+ }
24535
+
24017
24536
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
24018
24537
  var unistUtilVisit = visit;
24019
24538
 
24020
24539
 
24021
24540
 
24022
- var CONTINUE = unistUtilVisitParents$1.CONTINUE;
24023
- var SKIP = unistUtilVisitParents$1.SKIP;
24024
- var EXIT = unistUtilVisitParents$1.EXIT;
24541
+ var CONTINUE = unistUtilVisitParents.CONTINUE;
24542
+ var SKIP = unistUtilVisitParents.SKIP;
24543
+ var EXIT = unistUtilVisitParents.EXIT;
24025
24544
 
24026
24545
  visit.CONTINUE = CONTINUE;
24027
24546
  visit.SKIP = SKIP;
@@ -24034,7 +24553,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
24034
24553
  test = null;
24035
24554
  }
24036
24555
 
24037
- unistUtilVisitParents$1(tree, test, overload, reverse);
24556
+ unistUtilVisitParents(tree, test, overload, reverse);
24038
24557
 
24039
24558
  function overload(node, parents) {
24040
24559
  var parent = parents[parents.length - 1];
@@ -36573,7 +37092,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
36573
37092
  };
36574
37093
  }
36575
37094
  var transform = function (markdownAST) {
36576
- mdastUtilFindAndReplace(markdownAST, emojiRegex(), replace);
37095
+ findAndReplace(markdownAST, emojiRegex(), replace);
36577
37096
  return markdownAST;
36578
37097
  };
36579
37098
  return transform;
@@ -36600,7 +37119,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
36600
37119
  return markdownAST;
36601
37120
  }
36602
37121
  var mentionedUsersRegex = new RegExp(mentioned_usernames.map(function (username) { return "@" + username; }).join('|'), 'g');
36603
- mdastUtilFindAndReplace(markdownAST, mentionedUsersRegex, replace);
37122
+ findAndReplace(markdownAST, mentionedUsersRegex, replace);
36604
37123
  return markdownAST;
36605
37124
  };
36606
37125
  return transform;
@@ -36631,6 +37150,22 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
36631
37150
  if (noParsingNeeded.length > 0 || linkIsInBlock)
36632
37151
  return;
36633
37152
  try {
37153
+ // special case for mentions:
37154
+ // it could happen that a user's name matches with an e-mail format pattern.
37155
+ // in that case, we check whether the found e-mail is actually a mention
37156
+ // by naively checking for an existence of @ sign in front of it.
37157
+ if (type === 'email' && mentioned_users) {
37158
+ var emailMatchesWithName = mentioned_users.some(function (u) { return u.name === value; });
37159
+ if (emailMatchesWithName) {
37160
+ newText = newText.replace(new RegExp(escapeRegExp(value), 'g'), function (match, position) {
37161
+ var isMention = newText.charAt(position - 1) === '@';
37162
+ // in case of mention, we leave the match in its original form,
37163
+ // and we let `mentionsMarkdownPlugin` to do its job
37164
+ return isMention ? match : "[" + match + "](" + encodeDecode(href) + ")";
37165
+ });
37166
+ return;
37167
+ }
37168
+ }
36634
37169
  var displayLink = type === 'email' ? value : formatUrlForDisplay(href);
36635
37170
  newText = newText.replace(new RegExp(escapeRegExp(value), 'g'), "[" + displayLink + "](" + encodeDecode(href) + ")");
36636
37171
  }
@@ -42774,7 +43309,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
42774
43309
  _a.label = 1;
42775
43310
  case 1:
42776
43311
  _a.trys.push([1, 3, , 4]);
42777
- return [4 /*yield*/, editMessage(__assign$2(__assign$2({}, message), updatedMessage))];
43312
+ return [4 /*yield*/, editMessage(__assign$2(__assign$2(__assign$2({}, message), updatedMessage), customMessageData))];
42778
43313
  case 2:
42779
43314
  _a.sent();
42780
43315
  clearEditingState === null || clearEditingState === void 0 ? void 0 : clearEditingState();
@@ -45150,7 +45685,7 @@ var StreamChatReact = (function (exports, React, streamChat, reactDom) {
45150
45685
 
45151
45686
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};
45152
45687
 
45153
- window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version = '9.3.0';
45688
+ window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var version = '9.4.0';
45154
45689
 
45155
45690
  window.StreamChat.StreamChat=StreamChat;window.StreamChat.logChatPromiseExecution=logChatPromiseExecution;window.StreamChat.Channel=Channel;window.ICAL=window.ICAL||{};var useChat = function (_a) {
45156
45691
  var _b, _c;