@tonconnect/ui 2.2.0 → 2.3.0-beta.1

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/lib/index.cjs CHANGED
@@ -18,6 +18,18 @@ var __spreadValues = (a2, b) => {
18
18
  return a2;
19
19
  };
20
20
  var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
21
+ var __objRest = (source, exclude) => {
22
+ var target = {};
23
+ for (var prop in source)
24
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
+ target[prop] = source[prop];
26
+ if (source != null && __getOwnPropSymbols)
27
+ for (var prop of __getOwnPropSymbols(source)) {
28
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
+ target[prop] = source[prop];
30
+ }
31
+ return target;
32
+ };
21
33
  var __publicField = (obj, key, value) => {
22
34
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
23
35
  return value;
@@ -83,7 +95,7 @@ function createRoot(fn, detachedOwner) {
83
95
  owned: null,
84
96
  cleanups: null,
85
97
  context: null,
86
- owner: detachedOwner === void 0 ? owner : detachedOwner
98
+ owner: detachedOwner || owner
87
99
  }, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
88
100
  Owner = root;
89
101
  Listener = null;
@@ -173,9 +185,9 @@ function createResource(pSource, pFetcher, pOptions) {
173
185
  }
174
186
  function completeLoad(v, err) {
175
187
  runUpdates(() => {
176
- if (err === void 0)
188
+ if (!err)
177
189
  setValue(() => v);
178
- setState(err !== void 0 ? "errored" : "ready");
190
+ setState(err ? "errored" : "ready");
179
191
  setError(err);
180
192
  for (const c2 of contexts.keys())
181
193
  c2.decrement();
@@ -184,7 +196,7 @@ function createResource(pSource, pFetcher, pOptions) {
184
196
  }
185
197
  function read() {
186
198
  const c2 = SuspenseContext, v = value(), err = error();
187
- if (err !== void 0 && !pr)
199
+ if (err && !pr)
188
200
  throw err;
189
201
  if (Listener && !Listener.user && c2) {
190
202
  createComputed(() => {
@@ -264,8 +276,6 @@ function batch(fn) {
264
276
  return runUpdates(fn, false);
265
277
  }
266
278
  function untrack(fn) {
267
- if (Listener === null)
268
- return fn();
269
279
  const listener = Listener;
270
280
  Listener = null;
271
281
  try {
@@ -500,9 +510,8 @@ function runUpdates(fn, init) {
500
510
  completeUpdates(wait);
501
511
  return res;
502
512
  } catch (err) {
503
- if (!wait)
513
+ if (!Updates)
504
514
  Effects = null;
505
- Updates = null;
506
515
  handleError(err);
507
516
  }
508
517
  }
@@ -1825,8 +1834,10 @@ function fixMobileSafariActiveTransition() {
1825
1834
  }
1826
1835
  }
1827
1836
  function defineStylesRoot() {
1828
- customElements.define(globalStylesTag, class TcRootElement extends HTMLElement {
1829
- });
1837
+ if (!customElements.get("tc-root")) {
1838
+ customElements.define(globalStylesTag, class TcRootElement extends HTMLElement {
1839
+ });
1840
+ }
1830
1841
  }
1831
1842
  function createMacrotask(callback) {
1832
1843
  return __async(this, null, function* () {
@@ -3034,6 +3045,7 @@ function useDataAttributes(props) {
3034
3045
  const Button = (props) => {
3035
3046
  const dataAttrs = useDataAttributes(props);
3036
3047
  return createComponent(ButtonStyled$1, mergeProps({
3048
+ type: "button",
3037
3049
  get appearance() {
3038
3050
  return props.appearance || "primary";
3039
3051
  },
@@ -4915,16 +4927,16 @@ var qrcode$1 = { exports: {} };
4915
4927
  };
4916
4928
  return _this;
4917
4929
  }();
4918
- function qrPolynomial(num, shift) {
4930
+ function qrPolynomial(num, shift2) {
4919
4931
  if (typeof num.length == "undefined") {
4920
- throw num.length + "/" + shift;
4932
+ throw num.length + "/" + shift2;
4921
4933
  }
4922
4934
  var _num = function() {
4923
4935
  var offset = 0;
4924
4936
  while (offset < num.length && num[offset] == 0) {
4925
4937
  offset += 1;
4926
4938
  }
4927
- var _num2 = new Array(num.length - offset + shift);
4939
+ var _num2 = new Array(num.length - offset + shift2);
4928
4940
  for (var i2 = 0; i2 < num.length - offset; i2 += 1) {
4929
4941
  _num2[i2] = num[i2 + offset];
4930
4942
  }
@@ -7298,18 +7310,18 @@ const NotificationsStyled = styled(Notifications)`
7298
7310
  margin-top: 20px;
7299
7311
  }
7300
7312
  `;
7301
- function getSide(placement) {
7302
- return placement.split("-")[0];
7303
- }
7304
7313
  function getAlignment(placement) {
7305
7314
  return placement.split("-")[1];
7306
7315
  }
7307
- function getMainAxisFromPlacement(placement) {
7308
- return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
7309
- }
7310
7316
  function getLengthFromAxis(axis) {
7311
7317
  return axis === "y" ? "height" : "width";
7312
7318
  }
7319
+ function getSide(placement) {
7320
+ return placement.split("-")[0];
7321
+ }
7322
+ function getMainAxisFromPlacement(placement) {
7323
+ return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
7324
+ }
7313
7325
  function computeCoordsFromPlacement(_ref, placement, rtl) {
7314
7326
  let {
7315
7327
  reference,
@@ -7465,6 +7477,22 @@ const computePosition$1 = (reference, floating, config) => __async(exports, null
7465
7477
  middlewareData
7466
7478
  };
7467
7479
  });
7480
+ function expandPaddingObject(padding) {
7481
+ return __spreadValues({
7482
+ top: 0,
7483
+ right: 0,
7484
+ bottom: 0,
7485
+ left: 0
7486
+ }, padding);
7487
+ }
7488
+ function getSideObjectFromPadding(padding) {
7489
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
7490
+ top: padding,
7491
+ right: padding,
7492
+ bottom: padding,
7493
+ left: padding
7494
+ };
7495
+ }
7468
7496
  function rectToClientRect(rect) {
7469
7497
  return __spreadProps(__spreadValues({}, rect), {
7470
7498
  top: rect.y,
@@ -7473,6 +7501,305 @@ function rectToClientRect(rect) {
7473
7501
  bottom: rect.y + rect.height
7474
7502
  });
7475
7503
  }
7504
+ function detectOverflow(middlewareArguments, options) {
7505
+ return __async(this, null, function* () {
7506
+ var _await$platform$isEle;
7507
+ if (options === void 0) {
7508
+ options = {};
7509
+ }
7510
+ const {
7511
+ x,
7512
+ y,
7513
+ platform: platform2,
7514
+ rects,
7515
+ elements,
7516
+ strategy
7517
+ } = middlewareArguments;
7518
+ const {
7519
+ boundary = "clippingAncestors",
7520
+ rootBoundary = "viewport",
7521
+ elementContext = "floating",
7522
+ altBoundary = false,
7523
+ padding = 0
7524
+ } = options;
7525
+ const paddingObject = getSideObjectFromPadding(padding);
7526
+ const altContext = elementContext === "floating" ? "reference" : "floating";
7527
+ const element = elements[altBoundary ? altContext : elementContext];
7528
+ const clippingClientRect = rectToClientRect(yield platform2.getClippingRect({
7529
+ element: ((_await$platform$isEle = yield platform2.isElement == null ? void 0 : platform2.isElement(element)) != null ? _await$platform$isEle : true) ? element : element.contextElement || (yield platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
7530
+ boundary,
7531
+ rootBoundary,
7532
+ strategy
7533
+ }));
7534
+ const rect = elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
7535
+ x,
7536
+ y
7537
+ }) : rects.reference;
7538
+ const offsetParent = yield platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating);
7539
+ const offsetScale = (yield platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? (yield platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
7540
+ x: 1,
7541
+ y: 1
7542
+ } : {
7543
+ x: 1,
7544
+ y: 1
7545
+ };
7546
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? yield platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
7547
+ rect,
7548
+ offsetParent,
7549
+ strategy
7550
+ }) : rect);
7551
+ return {
7552
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
7553
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
7554
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
7555
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
7556
+ };
7557
+ });
7558
+ }
7559
+ const min$1 = Math.min;
7560
+ const max$1 = Math.max;
7561
+ function within(min$1$1, value, max$1$1) {
7562
+ return max$1(min$1$1, min$1(value, max$1$1));
7563
+ }
7564
+ const oppositeSideMap = {
7565
+ left: "right",
7566
+ right: "left",
7567
+ bottom: "top",
7568
+ top: "bottom"
7569
+ };
7570
+ function getOppositePlacement(placement) {
7571
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
7572
+ }
7573
+ function getAlignmentSides(placement, rects, rtl) {
7574
+ if (rtl === void 0) {
7575
+ rtl = false;
7576
+ }
7577
+ const alignment = getAlignment(placement);
7578
+ const mainAxis = getMainAxisFromPlacement(placement);
7579
+ const length = getLengthFromAxis(mainAxis);
7580
+ let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
7581
+ if (rects.reference[length] > rects.floating[length]) {
7582
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
7583
+ }
7584
+ return {
7585
+ main: mainAlignmentSide,
7586
+ cross: getOppositePlacement(mainAlignmentSide)
7587
+ };
7588
+ }
7589
+ const oppositeAlignmentMap = {
7590
+ start: "end",
7591
+ end: "start"
7592
+ };
7593
+ function getOppositeAlignmentPlacement(placement) {
7594
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
7595
+ }
7596
+ function getExpandedPlacements(placement) {
7597
+ const oppositePlacement = getOppositePlacement(placement);
7598
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
7599
+ }
7600
+ function getSideList(side, isStart, rtl) {
7601
+ const lr = ["left", "right"];
7602
+ const rl = ["right", "left"];
7603
+ const tb = ["top", "bottom"];
7604
+ const bt = ["bottom", "top"];
7605
+ switch (side) {
7606
+ case "top":
7607
+ case "bottom":
7608
+ if (rtl)
7609
+ return isStart ? rl : lr;
7610
+ return isStart ? lr : rl;
7611
+ case "left":
7612
+ case "right":
7613
+ return isStart ? tb : bt;
7614
+ default:
7615
+ return [];
7616
+ }
7617
+ }
7618
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
7619
+ const alignment = getAlignment(placement);
7620
+ let list = getSideList(getSide(placement), direction === "start", rtl);
7621
+ if (alignment) {
7622
+ list = list.map((side) => side + "-" + alignment);
7623
+ if (flipAlignment) {
7624
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
7625
+ }
7626
+ }
7627
+ return list;
7628
+ }
7629
+ const flip = function(options) {
7630
+ if (options === void 0) {
7631
+ options = {};
7632
+ }
7633
+ return {
7634
+ name: "flip",
7635
+ options,
7636
+ fn(middlewareArguments) {
7637
+ return __async(this, null, function* () {
7638
+ var _middlewareData$flip;
7639
+ const {
7640
+ placement,
7641
+ middlewareData,
7642
+ rects,
7643
+ initialPlacement,
7644
+ platform: platform2,
7645
+ elements
7646
+ } = middlewareArguments;
7647
+ const _a3 = options, {
7648
+ mainAxis: checkMainAxis = true,
7649
+ crossAxis: checkCrossAxis = true,
7650
+ fallbackPlacements: specifiedFallbackPlacements,
7651
+ fallbackStrategy = "bestFit",
7652
+ fallbackAxisSideDirection = "none",
7653
+ flipAlignment = true
7654
+ } = _a3, detectOverflowOptions = __objRest(_a3, [
7655
+ "mainAxis",
7656
+ "crossAxis",
7657
+ "fallbackPlacements",
7658
+ "fallbackStrategy",
7659
+ "fallbackAxisSideDirection",
7660
+ "flipAlignment"
7661
+ ]);
7662
+ const side = getSide(placement);
7663
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
7664
+ const rtl = yield platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating);
7665
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
7666
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
7667
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
7668
+ }
7669
+ const placements = [initialPlacement, ...fallbackPlacements];
7670
+ const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
7671
+ const overflows = [];
7672
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
7673
+ if (checkMainAxis) {
7674
+ overflows.push(overflow[side]);
7675
+ }
7676
+ if (checkCrossAxis) {
7677
+ const {
7678
+ main,
7679
+ cross
7680
+ } = getAlignmentSides(placement, rects, rtl);
7681
+ overflows.push(overflow[main], overflow[cross]);
7682
+ }
7683
+ overflowsData = [...overflowsData, {
7684
+ placement,
7685
+ overflows
7686
+ }];
7687
+ if (!overflows.every((side2) => side2 <= 0)) {
7688
+ var _middlewareData$flip2;
7689
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
7690
+ const nextPlacement = placements[nextIndex];
7691
+ if (nextPlacement) {
7692
+ return {
7693
+ data: {
7694
+ index: nextIndex,
7695
+ overflows: overflowsData
7696
+ },
7697
+ reset: {
7698
+ placement: nextPlacement
7699
+ }
7700
+ };
7701
+ }
7702
+ let resetPlacement = "bottom";
7703
+ switch (fallbackStrategy) {
7704
+ case "bestFit": {
7705
+ var _overflowsData$map$so;
7706
+ const placement2 = (_overflowsData$map$so = overflowsData.map((d) => [d, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b) => a2[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
7707
+ if (placement2) {
7708
+ resetPlacement = placement2;
7709
+ }
7710
+ break;
7711
+ }
7712
+ case "initialPlacement":
7713
+ resetPlacement = initialPlacement;
7714
+ break;
7715
+ }
7716
+ if (placement !== resetPlacement) {
7717
+ return {
7718
+ reset: {
7719
+ placement: resetPlacement
7720
+ }
7721
+ };
7722
+ }
7723
+ }
7724
+ return {};
7725
+ });
7726
+ }
7727
+ };
7728
+ };
7729
+ function getCrossAxis(axis) {
7730
+ return axis === "x" ? "y" : "x";
7731
+ }
7732
+ const shift = function(options) {
7733
+ if (options === void 0) {
7734
+ options = {};
7735
+ }
7736
+ return {
7737
+ name: "shift",
7738
+ options,
7739
+ fn(middlewareArguments) {
7740
+ return __async(this, null, function* () {
7741
+ const {
7742
+ x,
7743
+ y,
7744
+ placement
7745
+ } = middlewareArguments;
7746
+ const _a3 = options, {
7747
+ mainAxis: checkMainAxis = true,
7748
+ crossAxis: checkCrossAxis = false,
7749
+ limiter = {
7750
+ fn: (_ref) => {
7751
+ let {
7752
+ x: x2,
7753
+ y: y2
7754
+ } = _ref;
7755
+ return {
7756
+ x: x2,
7757
+ y: y2
7758
+ };
7759
+ }
7760
+ }
7761
+ } = _a3, detectOverflowOptions = __objRest(_a3, [
7762
+ "mainAxis",
7763
+ "crossAxis",
7764
+ "limiter"
7765
+ ]);
7766
+ const coords = {
7767
+ x,
7768
+ y
7769
+ };
7770
+ const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
7771
+ const mainAxis = getMainAxisFromPlacement(getSide(placement));
7772
+ const crossAxis = getCrossAxis(mainAxis);
7773
+ let mainAxisCoord = coords[mainAxis];
7774
+ let crossAxisCoord = coords[crossAxis];
7775
+ if (checkMainAxis) {
7776
+ const minSide = mainAxis === "y" ? "top" : "left";
7777
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
7778
+ const min2 = mainAxisCoord + overflow[minSide];
7779
+ const max2 = mainAxisCoord - overflow[maxSide];
7780
+ mainAxisCoord = within(min2, mainAxisCoord, max2);
7781
+ }
7782
+ if (checkCrossAxis) {
7783
+ const minSide = crossAxis === "y" ? "top" : "left";
7784
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
7785
+ const min2 = crossAxisCoord + overflow[minSide];
7786
+ const max2 = crossAxisCoord - overflow[maxSide];
7787
+ crossAxisCoord = within(min2, crossAxisCoord, max2);
7788
+ }
7789
+ const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, middlewareArguments), {
7790
+ [mainAxis]: mainAxisCoord,
7791
+ [crossAxis]: crossAxisCoord
7792
+ }));
7793
+ return __spreadProps(__spreadValues({}, limitedCoords), {
7794
+ data: {
7795
+ x: limitedCoords.x - x,
7796
+ y: limitedCoords.y - y
7797
+ }
7798
+ });
7799
+ });
7800
+ }
7801
+ };
7802
+ };
7476
7803
  function getWindow(node) {
7477
7804
  var _node$ownerDocument;
7478
7805
  return ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
@@ -7518,7 +7845,7 @@ function isOverflowElement(element) {
7518
7845
  overflowY,
7519
7846
  display
7520
7847
  } = getComputedStyle$1(element);
7521
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
7848
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
7522
7849
  }
7523
7850
  function isTableElement(element) {
7524
7851
  return ["table", "td", "th"].includes(getNodeName(element));
@@ -7543,28 +7870,43 @@ function isLastTraversableNode(node) {
7543
7870
  const min = Math.min;
7544
7871
  const max = Math.max;
7545
7872
  const round = Math.round;
7873
+ function getCssDimensions(element) {
7874
+ const css = getComputedStyle$1(element);
7875
+ let width = parseFloat(css.width);
7876
+ let height = parseFloat(css.height);
7877
+ const offsetWidth = element.offsetWidth;
7878
+ const offsetHeight = element.offsetHeight;
7879
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
7880
+ if (shouldFallback) {
7881
+ width = offsetWidth;
7882
+ height = offsetHeight;
7883
+ }
7884
+ return {
7885
+ width,
7886
+ height,
7887
+ fallback: shouldFallback
7888
+ };
7889
+ }
7890
+ function unwrapElement(element) {
7891
+ return !isElement(element) ? element.contextElement : element;
7892
+ }
7546
7893
  const FALLBACK_SCALE = {
7547
7894
  x: 1,
7548
7895
  y: 1
7549
7896
  };
7550
7897
  function getScale(element) {
7551
- const domElement = !isElement(element) && element.contextElement ? element.contextElement : isElement(element) ? element : null;
7552
- if (!domElement) {
7898
+ const domElement = unwrapElement(element);
7899
+ if (!isHTMLElement(domElement)) {
7553
7900
  return FALLBACK_SCALE;
7554
7901
  }
7555
7902
  const rect = domElement.getBoundingClientRect();
7556
- const css = getComputedStyle$1(domElement);
7557
- if (css.boxSizing !== "border-box") {
7558
- if (!isHTMLElement(domElement)) {
7559
- return FALLBACK_SCALE;
7560
- }
7561
- return {
7562
- x: domElement.offsetWidth > 0 ? round(rect.width) / domElement.offsetWidth || 1 : 1,
7563
- y: domElement.offsetHeight > 0 ? round(rect.height) / domElement.offsetHeight || 1 : 1
7564
- };
7565
- }
7566
- let x = rect.width / parseFloat(css.width);
7567
- let y = rect.height / parseFloat(css.height);
7903
+ const {
7904
+ width,
7905
+ height,
7906
+ fallback
7907
+ } = getCssDimensions(domElement);
7908
+ let x = (fallback ? round(rect.width) : rect.width) / width;
7909
+ let y = (fallback ? round(rect.height) : rect.height) / height;
7568
7910
  if (!x || !Number.isFinite(x)) {
7569
7911
  x = 1;
7570
7912
  }
@@ -7577,7 +7919,7 @@ function getScale(element) {
7577
7919
  };
7578
7920
  }
7579
7921
  function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
7580
- var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
7922
+ var _win$visualViewport, _win$visualViewport2;
7581
7923
  if (includeScale === void 0) {
7582
7924
  includeScale = false;
7583
7925
  }
@@ -7585,6 +7927,7 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
7585
7927
  isFixedStrategy = false;
7586
7928
  }
7587
7929
  const clientRect = element.getBoundingClientRect();
7930
+ const domElement = unwrapElement(element);
7588
7931
  let scale = FALLBACK_SCALE;
7589
7932
  if (includeScale) {
7590
7933
  if (offsetParent) {
@@ -7595,12 +7938,31 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
7595
7938
  scale = getScale(element);
7596
7939
  }
7597
7940
  }
7598
- const win = isElement(element) ? getWindow(element) : window;
7941
+ const win = domElement ? getWindow(domElement) : window;
7599
7942
  const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
7600
- const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scale.x;
7601
- const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scale.y;
7602
- const width = clientRect.width / scale.x;
7603
- const height = clientRect.height / scale.y;
7943
+ let x = (clientRect.left + (addVisualOffsets ? ((_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) || 0 : 0)) / scale.x;
7944
+ let y = (clientRect.top + (addVisualOffsets ? ((_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) || 0 : 0)) / scale.y;
7945
+ let width = clientRect.width / scale.x;
7946
+ let height = clientRect.height / scale.y;
7947
+ if (domElement) {
7948
+ const win2 = getWindow(domElement);
7949
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
7950
+ let currentIFrame = win2.frameElement;
7951
+ while (currentIFrame && offsetParent && offsetWin !== win2) {
7952
+ const iframeScale = getScale(currentIFrame);
7953
+ const iframeRect = currentIFrame.getBoundingClientRect();
7954
+ const css = getComputedStyle(currentIFrame);
7955
+ iframeRect.x += (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
7956
+ iframeRect.y += (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
7957
+ x *= iframeScale.x;
7958
+ y *= iframeScale.y;
7959
+ width *= iframeScale.x;
7960
+ height *= iframeScale.y;
7961
+ x += iframeRect.x;
7962
+ y += iframeRect.y;
7963
+ currentIFrame = getWindow(currentIFrame).frameElement;
7964
+ }
7965
+ }
7604
7966
  return {
7605
7967
  width,
7606
7968
  height,
@@ -7697,17 +8059,7 @@ function getOffsetParent(element) {
7697
8059
  return offsetParent || getContainingBlock(element) || window2;
7698
8060
  }
7699
8061
  function getDimensions(element) {
7700
- if (isHTMLElement(element)) {
7701
- return {
7702
- width: element.offsetWidth,
7703
- height: element.offsetHeight
7704
- };
7705
- }
7706
- const rect = getBoundingClientRect(element);
7707
- return {
7708
- width: rect.width,
7709
- height: rect.height
7710
- };
8062
+ return getCssDimensions(element);
7711
8063
  }
7712
8064
  function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
7713
8065
  let {
@@ -8055,7 +8407,8 @@ const AccountButton = () => {
8055
8407
  const [anchor, setAnchor] = createSignal();
8056
8408
  const position = P(anchor, floating, {
8057
8409
  whileElementsMounted: autoUpdate,
8058
- placement: "bottom-end"
8410
+ placement: "bottom-end",
8411
+ middleware: [flip(), shift()]
8059
8412
  });
8060
8413
  const normalizedAddress = () => {
8061
8414
  const acc = account();
@@ -12157,7 +12510,7 @@ class TonConnectUITracker {
12157
12510
  }
12158
12511
  }
12159
12512
  }
12160
- const tonConnectUiVersion = "2.2.0";
12513
+ const tonConnectUiVersion = "2.3.0-beta.1";
12161
12514
  class TonConnectUI {
12162
12515
  constructor(options) {
12163
12516
  __publicField(this, "walletInfoStorage", new WalletInfoStorage());
@@ -12393,6 +12746,7 @@ class TonConnectUI {
12393
12746
  });
12394
12747
  const abortController = new AbortController();
12395
12748
  const onRequestSent = () => {
12749
+ var _a2;
12396
12750
  if (abortController.signal.aborted) {
12397
12751
  return;
12398
12752
  }
@@ -12406,6 +12760,20 @@ class TonConnectUI {
12406
12760
  returnStrategy,
12407
12761
  twaReturnUrl
12408
12762
  });
12763
+ let firstClick = true;
12764
+ const redirectToWallet2 = () => {
12765
+ if (abortController.signal.aborted) {
12766
+ return;
12767
+ }
12768
+ const forceRedirect = !firstClick;
12769
+ firstClick = false;
12770
+ this.redirectAfterRequestSent({
12771
+ returnStrategy,
12772
+ twaReturnUrl,
12773
+ forceRedirect
12774
+ });
12775
+ };
12776
+ (_a2 = options == null ? void 0 : options.onRequestSent) == null ? void 0 : _a2.call(options, redirectToWallet2);
12409
12777
  };
12410
12778
  const unsubscribe = this.onTransactionModalStateChange((action2) => {
12411
12779
  if (action2 == null ? void 0 : action2.openModal) {
@@ -12453,7 +12821,7 @@ class TonConnectUI {
12453
12821
  }
12454
12822
  });
12455
12823
  }
12456
- signData(data) {
12824
+ signData(data, options) {
12457
12825
  return __async(this, null, function* () {
12458
12826
  this.tracker.trackDataSentForSignature(this.wallet, data);
12459
12827
  if (!this.connected) {
@@ -12472,6 +12840,7 @@ class TonConnectUI {
12472
12840
  });
12473
12841
  const abortController = new AbortController();
12474
12842
  const onRequestSent = () => {
12843
+ var _a2;
12475
12844
  if (abortController.signal.aborted) {
12476
12845
  return;
12477
12846
  }
@@ -12485,6 +12854,20 @@ class TonConnectUI {
12485
12854
  returnStrategy,
12486
12855
  twaReturnUrl
12487
12856
  });
12857
+ let firstClick = true;
12858
+ const redirectToWallet2 = () => {
12859
+ if (abortController.signal.aborted) {
12860
+ return;
12861
+ }
12862
+ const forceRedirect = !firstClick;
12863
+ firstClick = false;
12864
+ this.redirectAfterRequestSent({
12865
+ returnStrategy,
12866
+ twaReturnUrl,
12867
+ forceRedirect
12868
+ });
12869
+ };
12870
+ (_a2 = options == null ? void 0 : options.onRequestSent) == null ? void 0 : _a2.call(options, redirectToWallet2);
12488
12871
  };
12489
12872
  const unsubscribe = this.onTransactionModalStateChange((action2) => {
12490
12873
  if (action2 == null ? void 0 : action2.openModal) {
@@ -12534,14 +12917,15 @@ class TonConnectUI {
12534
12917
  }
12535
12918
  redirectAfterRequestSent({
12536
12919
  returnStrategy,
12537
- twaReturnUrl
12920
+ twaReturnUrl,
12921
+ forceRedirect
12538
12922
  }) {
12539
12923
  if (this.walletInfo && "universalLink" in this.walletInfo && (this.walletInfo.openMethod === "universal-link" || this.walletInfo.openMethod === "custom-deeplink")) {
12540
12924
  if (sdk.isTelegramUrl(this.walletInfo.universalLink)) {
12541
12925
  redirectToTelegram(this.walletInfo.universalLink, {
12542
12926
  returnStrategy,
12543
12927
  twaReturnUrl: twaReturnUrl || appState.twaReturnUrl,
12544
- forceRedirect: false
12928
+ forceRedirect: forceRedirect || false
12545
12929
  });
12546
12930
  } else {
12547
12931
  redirectToWallet(
@@ -12549,7 +12933,7 @@ class TonConnectUI {
12549
12933
  this.walletInfo.deepLink,
12550
12934
  {
12551
12935
  returnStrategy,
12552
- forceRedirect: false
12936
+ forceRedirect: forceRedirect || false
12553
12937
  },
12554
12938
  () => {
12555
12939
  }