tamagui 2.3.3 → 2.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.
package/dist/native.cjs CHANGED
@@ -12171,6 +12171,43 @@ function updateMediaListeners() {
12171
12171
  return cb(getMedia());
12172
12172
  });
12173
12173
  }
12174
+ function buildTouchTrackerProto() {
12175
+ var proto = {};
12176
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
12177
+ try {
12178
+ var _loop = function() {
12179
+ var fullKey = _step.value;
12180
+ var key = fullKey[0] === "$" ? fullKey.slice(1) : fullKey;
12181
+ proto[key] = {
12182
+ enumerable: true,
12183
+ configurable: true,
12184
+ get() {
12185
+ var slot = this[refSlot];
12186
+ if (!disableMediaTouch) slot.keys.add(key);
12187
+ return slot.proxyTarget[key];
12188
+ }
12189
+ };
12190
+ };
12191
+ for (var _iterator = mediaKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) _loop();
12192
+ } catch (err) {
12193
+ _didIteratorError = true;
12194
+ _iteratorError = err;
12195
+ } finally {
12196
+ try {
12197
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
12198
+ } finally {
12199
+ if (_didIteratorError) throw _iteratorError;
12200
+ }
12201
+ }
12202
+ return Object.create(null, proto);
12203
+ }
12204
+ function getTouchTrackerProto() {
12205
+ if (!touchTrackerProto) touchTrackerProto = buildTouchTrackerProto();
12206
+ return touchTrackerProto;
12207
+ }
12208
+ function resetMediaTouchTracker() {
12209
+ touchTrackerProto = null;
12210
+ }
12174
12211
  function setMediaShouldUpdate(ref, enabled, keys) {
12175
12212
  var cur = States.get(ref);
12176
12213
  if (!cur || cur.enabled !== enabled || keys) States.set(ref, _objectSpread2(_objectSpread2({}, cur), {}, {
@@ -12186,53 +12223,99 @@ function subscribe$1(subscriber) {
12186
12223
  }
12187
12224
  function useMedia(componentContext, debug) {
12188
12225
  "use no memo";
12189
- var componentState = componentContext ? States.get(componentContext) : null;
12190
12226
  var internalRef = (0, react$1.useRef)(null);
12191
- if (!internalRef.current) internalRef.current = {
12192
- keys: /* @__PURE__ */ new Set(),
12193
- lastState: getMedia()
12194
- };
12195
- if (internalRef.current.pendingState) {
12196
- internalRef.current.lastState = internalRef.current.pendingState;
12197
- internalRef.current.pendingState = void 0;
12198
- }
12199
- var { keys } = internalRef.current;
12200
- if (keys.size) keys.clear();
12201
- var state = (0, react$1.useSyncExternalStore)(subscribe$1, function() {
12202
- var curKeys = (componentState === null || componentState === void 0 ? void 0 : componentState.keys) || keys;
12203
- var { lastState, pendingState } = internalRef.current;
12204
- if (!curKeys.size) return lastState;
12205
- var ms = getMedia();
12206
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
12207
- try {
12208
- for (var _iterator = curKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
12209
- var key = _step.value;
12210
- if (ms[key] !== (pendingState || lastState)[key]) {
12211
- if (componentContext === null || componentContext === void 0 ? void 0 : componentContext.mediaEmit) {
12212
- componentContext.mediaEmit(ms);
12213
- internalRef.current.pendingState = ms;
12214
- return lastState;
12227
+ if (!internalRef.current) {
12228
+ var initial = getMedia();
12229
+ var r = {
12230
+ keys: /* @__PURE__ */ new Set(),
12231
+ lastState: initial,
12232
+ renderVersion: 0,
12233
+ proxyTarget: initial,
12234
+ proxy: void 0,
12235
+ getSnapshot: void 0,
12236
+ componentContext,
12237
+ debug
12238
+ };
12239
+ var tracker = Object.create(getTouchTrackerProto());
12240
+ tracker[refSlot] = {
12241
+ proxyTarget: initial,
12242
+ keys: r.keys
12243
+ };
12244
+ r.proxy = tracker;
12245
+ r.getSnapshot = function() {
12246
+ var _States_get;
12247
+ var curKeys = r.componentContext ? ((_States_get = States.get(r.componentContext)) === null || _States_get === void 0 ? void 0 : _States_get.keys) || r.keys : r.keys;
12248
+ var { lastState, pendingState } = r;
12249
+ if (!curKeys.size) return lastState;
12250
+ var ms = getMedia();
12251
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
12252
+ try {
12253
+ for (var _iterator = curKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
12254
+ var key = _step.value;
12255
+ if (ms[key] !== (pendingState || lastState)[key]) {
12256
+ var _r_componentContext;
12257
+ if ((_r_componentContext = r.componentContext) === null || _r_componentContext === void 0 ? void 0 : _r_componentContext.mediaEmit) {
12258
+ r.componentContext.mediaEmit(ms);
12259
+ r.pendingState = ms;
12260
+ return lastState;
12261
+ }
12262
+ r.lastState = ms;
12263
+ return ms;
12215
12264
  }
12216
- internalRef.current.lastState = ms;
12217
- return ms;
12218
12265
  }
12219
- }
12220
- } catch (err) {
12221
- _didIteratorError = true;
12222
- _iteratorError = err;
12223
- } finally {
12224
- try {
12225
- if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
12266
+ } catch (err) {
12267
+ _didIteratorError = true;
12268
+ _iteratorError = err;
12226
12269
  } finally {
12227
- if (_didIteratorError) throw _iteratorError;
12270
+ try {
12271
+ if (!_iteratorNormalCompletion && _iterator.return != null) _iterator.return();
12272
+ } finally {
12273
+ if (_didIteratorError) throw _iteratorError;
12274
+ }
12228
12275
  }
12276
+ return lastState;
12277
+ };
12278
+ internalRef.current = r;
12279
+ } else {
12280
+ internalRef.current.componentContext = componentContext;
12281
+ internalRef.current.debug = debug;
12282
+ }
12283
+ var ref = internalRef.current;
12284
+ ref.renderVersion++;
12285
+ if (ref.pendingState) {
12286
+ ref.lastState = ref.pendingState;
12287
+ ref.pendingState = void 0;
12288
+ }
12289
+ if (ref.keys.size) ref.keys.clear();
12290
+ var [, forceUpdate] = (0, react$1.useReducer)(incReducer$1, 0);
12291
+ var state = ref.getSnapshot();
12292
+ ref.proxyTarget = state;
12293
+ ref.proxy[refSlot].proxyTarget = state;
12294
+ (0, react$1.useEffect)(function() {
12295
+ var _States_get;
12296
+ var renderVersion = ref.renderVersion;
12297
+ if (!ref.componentContext || !!((_States_get = States.get(ref.componentContext)) === null || _States_get === void 0 ? void 0 : _States_get.enabled)) {
12298
+ if (!ref.unsubscribe) ref.unsubscribe = subscribe$1(function() {
12299
+ var next = ref.getSnapshot();
12300
+ if (next !== ref.proxyTarget) {
12301
+ ref.proxyTarget = next;
12302
+ ref.proxy[refSlot].proxyTarget = next;
12303
+ forceUpdate();
12304
+ }
12305
+ });
12306
+ } else if (ref.unsubscribe) {
12307
+ ref.unsubscribe();
12308
+ ref.unsubscribe = void 0;
12229
12309
  }
12230
- return lastState;
12231
- }, getServerSnapshot);
12232
- return new Proxy(state, { get(_, key) {
12233
- if (!disableMediaTouch && typeof key === "string") keys.add(key);
12234
- return Reflect.get(state, key);
12235
- } });
12310
+ return function() {
12311
+ if (ref.renderVersion === renderVersion) {
12312
+ var _ref_unsubscribe;
12313
+ (_ref_unsubscribe = ref.unsubscribe) === null || _ref_unsubscribe === void 0 || _ref_unsubscribe.call(ref);
12314
+ ref.unsubscribe = void 0;
12315
+ }
12316
+ };
12317
+ });
12318
+ return ref.proxy;
12236
12319
  }
12237
12320
  function getMediaState(mediaGroups, layout) {
12238
12321
  disableMediaTouch = true;
@@ -12255,7 +12338,7 @@ function mediaKeyMatch(key, dimensions) {
12255
12338
  return isMax ? givenVal < expectedVal : givenVal > expectedVal;
12256
12339
  });
12257
12340
  }
12258
- var mediaKeyRegex, getMediaKey, initState, mediaKeysOrdered, getMediaKeyImportance, dispose, mediaVersion, configureMedia, setupVersion, listeners, States, getServerSnapshot, disableMediaTouch, getMediaImportanceIfMoreImportant;
12341
+ var mediaKeyRegex, getMediaKey, mediaKeysOrdered, getMediaKeyImportance, dispose, mediaVersion, configureMedia, setupVersion, listeners, States, touchTrackerProto, refSlot, incReducer$1, disableMediaTouch, getMediaImportanceIfMoreImportant;
12259
12342
  var init_useMedia_native = __esmMin((() => {
12260
12343
  init_index_native$7();
12261
12344
  init_config_native();
@@ -12284,20 +12367,23 @@ var init_useMedia_native = __esmMin((() => {
12284
12367
  if (!media) return;
12285
12368
  mediaVersion++;
12286
12369
  resetMediaStyleCache();
12370
+ resetMediaTouchTracker();
12287
12371
  for (var key in media) {
12288
12372
  getMedia()[key] = (mediaQueryDefaultActive === null || mediaQueryDefaultActive === void 0 ? void 0 : mediaQueryDefaultActive[key]) || false;
12289
12373
  mediaKeys.add(`$${key}`);
12290
12374
  }
12291
12375
  Object.assign(mediaQueryConfig, media);
12292
- initState = _objectSpread2({}, getMedia());
12376
+ _objectSpread2({}, getMedia());
12293
12377
  mediaKeysOrdered = Object.keys(media);
12294
12378
  setupMediaListeners();
12295
12379
  };
12296
12380
  setupVersion = -1;
12297
12381
  listeners = /* @__PURE__ */ new Set();
12298
12382
  States = /* @__PURE__ */ new WeakMap();
12299
- getServerSnapshot = function() {
12300
- return initState;
12383
+ touchTrackerProto = null;
12384
+ refSlot = /* @__PURE__ */ Symbol("mediaRefSlot");
12385
+ incReducer$1 = function(c) {
12386
+ return c + 1;
12301
12387
  };
12302
12388
  disableMediaTouch = false;
12303
12389
  getMediaImportanceIfMoreImportant = function(mediaKey, key, styleState, isSizeMedia) {
@@ -12922,6 +13008,18 @@ var init_getDynamicVal_native = __esmMin((() => {
12922
13008
  }));
12923
13009
  //#endregion
12924
13010
  //#region ../../core/web/dist/esm/hooks/useThemeState.native.js
13011
+ function cleanupThemeSubscription(r) {
13012
+ var _r_unsubscribe;
13013
+ (_r_unsubscribe = r.unsubscribe) === null || _r_unsubscribe === void 0 || _r_unsubscribe.call(r);
13014
+ }
13015
+ function cleanupThemeState(r) {
13016
+ if (r.unsubscribe) cleanupThemeSubscription(r);
13017
+ else {
13018
+ localStates.delete(r.id);
13019
+ states.delete(r.id);
13020
+ PendingUpdate.delete(r.id);
13021
+ }
13022
+ }
12925
13023
  function scheduleUpdate(id) {
12926
13024
  var queue = [id];
12927
13025
  var visited = /* @__PURE__ */ new Set();
@@ -13095,7 +13193,7 @@ function getNewThemeName() {
13095
13193
  themeNameCache.set(cacheKey, found);
13096
13194
  return found;
13097
13195
  }
13098
- var ThemeStateContext, allListeners, listenersByParent, HasRenderedOnce, HadTheme, PendingUpdate, states, localStates, shouldForce, forceUpdateThemes, getThemeState, cacheVersion, themeNameCache, themeNameCacheVer, themes, rootThemeState, getRootThemeState, getThemeBaseName, useThemeState, getNextState, validSchemes, getPropsKey, hasThemeUpdatingProps;
13196
+ var ThemeStateContext, allListeners, listenersByParent, HasRenderedOnce, HadTheme, PendingUpdate, states, localStates, shouldForce, forceUpdateThemes, getThemeState, cacheVersion, themeNameCache, themeNameCacheVer, themes, rootThemeState, getRootThemeState, getThemeBaseName, incReducer, useThemeState, shouldSubscribeToTheme, getSnapshotImpl, getNextState, validSchemes, getPropsKey, hasThemeUpdatingProps;
13099
13197
  var init_useThemeState_native = __esmMin((() => {
13100
13198
  init_index_native$7();
13101
13199
  init_config_native();
@@ -13132,9 +13230,12 @@ var init_useThemeState_native = __esmMin((() => {
13132
13230
  getThemeBaseName = function(name) {
13133
13231
  return name.replace(/^(light|dark)_/, "");
13134
13232
  };
13233
+ incReducer = function(c) {
13234
+ return c + 1;
13235
+ };
13135
13236
  useThemeState = function(props) {
13136
13237
  "use no memo";
13137
- var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0;
13238
+ var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, keys = arguments.length > 2 ? arguments[2] : void 0, schemeKeys = arguments.length > 3 ? arguments[3] : void 0, cascadeOnChange = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
13138
13239
  var { disable } = props;
13139
13240
  var parentId = (0, react$1.useContext)(ThemeStateContext);
13140
13241
  if (!parentId && !isRoot) throw new Error(MISSING_THEME_MESSAGE);
@@ -13144,53 +13245,69 @@ var init_useThemeState_native = __esmMin((() => {
13144
13245
  theme: getConfig().themes.light
13145
13246
  };
13146
13247
  var id = (0, react$1.useId)();
13147
- var subscribe = (0, react$1.useCallback)(function(cb) {
13148
- listenersByParent[parentId] = listenersByParent[parentId] || /* @__PURE__ */ new Set();
13149
- listenersByParent[parentId].add(id);
13150
- allListeners.set(id, function() {
13151
- PendingUpdate.set(id, shouldForce ? "force" : true);
13152
- cb();
13153
- });
13154
- return function() {
13155
- allListeners.delete(id);
13156
- listenersByParent[parentId].delete(id);
13157
- localStates.delete(id);
13158
- states.delete(id);
13159
- PendingUpdate.delete(id);
13160
- };
13161
- }, [id, parentId]);
13162
13248
  var propsKey = getPropsKey(props);
13163
- var getSnapshot = function() {
13164
- var _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;
13165
- var local = localStates.get(id);
13166
- var parentState = states.get(parentId);
13167
- if (local && !PendingUpdate.has(id)) {
13168
- if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
13169
- }
13170
- var isSchemeOnlyChange = supportsDynamicColorIOS && getSetting("fastSchemeChange") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);
13171
- var _keys_current_size;
13172
- var keysSize = (_keys_current_size = keys === null || keys === void 0 ? void 0 : (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) !== null && _keys_current_size !== void 0 ? _keys_current_size : 0;
13173
- var _schemeKeys_current_size;
13174
- var allKeysSchemeOptimized = ((_schemeKeys_current_size = schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) !== null && _schemeKeys_current_size !== void 0 ? _schemeKeys_current_size : 0) === keysSize && keysSize > 0;
13175
- var canSkipForSchemeChange = isSchemeOnlyChange && allKeysSchemeOptimized;
13176
- var needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);
13177
- var [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
13178
- PendingUpdate.delete(id);
13179
- if (!local || rerender) {
13180
- local = _objectSpread2({}, next);
13181
- localStates.set(id, local);
13182
- }
13183
- if (next !== local) {
13184
- Object.assign(local, next);
13185
- local.id = id;
13186
- }
13187
- local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
13188
- local._propsKey = propsKey;
13189
- states.set(id, next);
13190
- return local;
13249
+ var ref = (0, react$1.useRef)(null);
13250
+ if (!ref.current) ref.current = {
13251
+ id,
13252
+ parentId,
13253
+ props,
13254
+ propsKey,
13255
+ isRoot,
13256
+ keys,
13257
+ schemeKeys,
13258
+ renderVersion: 0
13191
13259
  };
13192
- var state = (0, react$1.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
13193
- useIsomorphicLayoutEffect(function() {
13260
+ else {
13261
+ ref.current.props = props;
13262
+ ref.current.propsKey = propsKey;
13263
+ ref.current.isRoot = isRoot;
13264
+ ref.current.keys = keys;
13265
+ ref.current.schemeKeys = schemeKeys;
13266
+ ref.current.parentId = parentId;
13267
+ }
13268
+ ref.current.renderVersion++;
13269
+ var [, forceUpdate] = (0, react$1.useReducer)(incReducer, 0);
13270
+ var state = getSnapshotImpl(ref.current);
13271
+ ref.current.lastSnap = state;
13272
+ (0, react$1.useEffect)(function() {
13273
+ var r = ref.current;
13274
+ var renderVersion = r.renderVersion;
13275
+ if (r.unsubscribe && r.subscribedParentId !== r.parentId) cleanupThemeSubscription(r);
13276
+ if (shouldSubscribeToTheme(r, cascadeOnChange)) {
13277
+ if (!r.unsubscribe) {
13278
+ var pid = r.parentId;
13279
+ var sid = r.id;
13280
+ var cb = function() {
13281
+ var next = getSnapshotImpl(r);
13282
+ if (next !== r.lastSnap) {
13283
+ r.lastSnap = next;
13284
+ forceUpdate();
13285
+ }
13286
+ };
13287
+ listenersByParent[pid] = listenersByParent[pid] || /* @__PURE__ */ new Set();
13288
+ listenersByParent[pid].add(sid);
13289
+ allListeners.set(sid, function() {
13290
+ PendingUpdate.set(sid, shouldForce ? "force" : true);
13291
+ cb();
13292
+ });
13293
+ r.subscribedParentId = pid;
13294
+ r.unsubscribe = function() {
13295
+ var _listenersByParent_pid;
13296
+ allListeners.delete(sid);
13297
+ (_listenersByParent_pid = listenersByParent[pid]) === null || _listenersByParent_pid === void 0 || _listenersByParent_pid.delete(sid);
13298
+ localStates.delete(sid);
13299
+ states.delete(sid);
13300
+ PendingUpdate.delete(sid);
13301
+ r.unsubscribe = void 0;
13302
+ r.subscribedParentId = void 0;
13303
+ };
13304
+ }
13305
+ } else if (r.unsubscribe) cleanupThemeSubscription(r);
13306
+ return function() {
13307
+ if (r.renderVersion === renderVersion) cleanupThemeState(r);
13308
+ };
13309
+ });
13310
+ if (cascadeOnChange) useIsomorphicLayoutEffect(function() {
13194
13311
  if (!HasRenderedOnce.get(keys)) {
13195
13312
  HasRenderedOnce.set(keys, true);
13196
13313
  return;
@@ -13205,6 +13322,40 @@ var init_useThemeState_native = __esmMin((() => {
13205
13322
  }, [keys, propsKey]);
13206
13323
  return state;
13207
13324
  };
13325
+ shouldSubscribeToTheme = function(r, cascadeOnChange) {
13326
+ var _r_keys_current, _r_props_needsUpdate, _r_props;
13327
+ return r.isRoot || cascadeOnChange || hasThemeUpdatingProps(r.props) || !!((_r_keys_current = r.keys.current) === null || _r_keys_current === void 0 ? void 0 : _r_keys_current.size) || !!((_r_props_needsUpdate = (_r_props = r.props).needsUpdate) === null || _r_props_needsUpdate === void 0 ? void 0 : _r_props_needsUpdate.call(_r_props));
13328
+ };
13329
+ getSnapshotImpl = function(r) {
13330
+ var _keys_current, _schemeKeys_current, _keys_current1, _props_needsUpdate;
13331
+ var { id, parentId, props, propsKey, isRoot, keys, schemeKeys } = r;
13332
+ var local = localStates.get(id);
13333
+ var parentState = states.get(parentId);
13334
+ if (local && !PendingUpdate.has(id)) {
13335
+ if (parentState && local._parentName === parentState.name && local._propsKey === propsKey) return local;
13336
+ }
13337
+ var isSchemeOnlyChange = supportsDynamicColorIOS && getSetting("fastSchemeChange") && local && parentState && local.scheme !== parentState.scheme && getThemeBaseName(local.name) === getThemeBaseName(parentState.name);
13338
+ var _keys_current_size;
13339
+ var keysSize = (_keys_current_size = keys === null || keys === void 0 ? void 0 : (_keys_current = keys.current) === null || _keys_current === void 0 ? void 0 : _keys_current.size) !== null && _keys_current_size !== void 0 ? _keys_current_size : 0;
13340
+ var _schemeKeys_current_size;
13341
+ var allKeysSchemeOptimized = ((_schemeKeys_current_size = schemeKeys === null || schemeKeys === void 0 ? void 0 : (_schemeKeys_current = schemeKeys.current) === null || _schemeKeys_current === void 0 ? void 0 : _schemeKeys_current.size) !== null && _schemeKeys_current_size !== void 0 ? _schemeKeys_current_size : 0) === keysSize && keysSize > 0;
13342
+ var canSkipForSchemeChange = isSchemeOnlyChange && allKeysSchemeOptimized;
13343
+ var needsUpdate = props.passThrough ? false : isRoot || props.name === "light" || props.name === "dark" || props.name === null ? true : !HasRenderedOnce.get(keys) ? true : canSkipForSchemeChange ? false : (keys === null || keys === void 0 ? void 0 : (_keys_current1 = keys.current) === null || _keys_current1 === void 0 ? void 0 : _keys_current1.size) ? true : (_props_needsUpdate = props.needsUpdate) === null || _props_needsUpdate === void 0 ? void 0 : _props_needsUpdate.call(props);
13344
+ var [rerender, next] = getNextState(local, props, propsKey, isRoot, id, parentId, needsUpdate, PendingUpdate.get(id));
13345
+ PendingUpdate.delete(id);
13346
+ if (!local || rerender) {
13347
+ local = _objectSpread2({}, next);
13348
+ localStates.set(id, local);
13349
+ }
13350
+ if (next !== local) {
13351
+ Object.assign(local, next);
13352
+ local.id = id;
13353
+ }
13354
+ local._parentName = parentState === null || parentState === void 0 ? void 0 : parentState.name;
13355
+ local._propsKey = propsKey;
13356
+ states.set(id, next);
13357
+ return local;
13358
+ };
13208
13359
  getNextState = function(lastState, props, propsKey) {
13209
13360
  var isRoot = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : false, id = arguments.length > 4 ? arguments[4] : void 0, parentId = arguments.length > 5 ? arguments[5] : void 0, needsUpdate = arguments.length > 6 ? arguments[6] : void 0, pendingUpdate = arguments.length > 7 ? arguments[7] : void 0;
13210
13361
  var { debug } = props;
@@ -13219,9 +13370,13 @@ var init_useThemeState_native = __esmMin((() => {
13219
13370
  return [shouldRerender, _objectSpread2(_objectSpread2({}, parentState), {}, { isNew: false })];
13220
13371
  }
13221
13372
  if (!name) {
13222
- var next = lastState !== null && lastState !== void 0 ? lastState : parentState;
13223
- if (!next) throw new Error(MISSING_THEME_MESSAGE);
13224
- if (shouldRerender) return [true, _objectSpread2({}, parentState || lastState)];
13373
+ var _ref, _ref1;
13374
+ var next = (_ref1 = (_ref = lastState !== null && lastState !== void 0 ? lastState : parentState) !== null && _ref !== void 0 ? _ref : rootThemeState) !== null && _ref1 !== void 0 ? _ref1 : {
13375
+ id,
13376
+ name: "light",
13377
+ theme: getConfig().themes.light
13378
+ };
13379
+ if (shouldRerender) return [true, _objectSpread2({}, parentState || lastState || next)];
13225
13380
  return [false, next];
13226
13381
  }
13227
13382
  var scheme = getScheme(name);
@@ -13342,10 +13497,14 @@ var init_useTheme_native = __esmMin((() => {
13342
13497
  };
13343
13498
  useThemeWithState = function(props) {
13344
13499
  "use no memo";
13345
- var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
13346
- var keys = (0, react$1.useRef)(null);
13347
- var schemeKeys = (0, react$1.useRef)(null);
13348
- var themeState = useThemeState(props, isRoot, keys, schemeKeys);
13500
+ var isRoot = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false, forThemeView = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
13501
+ var bag = (0, react$1.useRef)(null);
13502
+ if (!bag.current) bag.current = {
13503
+ keys: { current: null },
13504
+ schemeKeys: { current: null }
13505
+ };
13506
+ var { keys, schemeKeys } = bag.current;
13507
+ var themeState = useThemeState(props, isRoot, keys, schemeKeys, forThemeView);
13349
13508
  return [props.passThrough ? {} : getThemeProxied(props, themeState, keys, schemeKeys), themeState];
13350
13509
  };
13351
13510
  }));
@@ -15423,6 +15582,11 @@ function normalizeGroupKey(key, groupContext) {
15423
15582
  function isValidStyleKey(key, validStyles, accept) {
15424
15583
  return key in validStyles ? true : accept && key in accept;
15425
15584
  }
15585
+ function shouldSkipNativeHoverProp(key, isMedia) {
15586
+ if (key === "hoverStyle") return true;
15587
+ if (isMedia === "group") return getGroupPropParts(key.slice(1)).pseudo === "hover";
15588
+ return false;
15589
+ }
15426
15590
  function mergeFlatTransforms(target, flatTransforms) {
15427
15591
  Object.entries(flatTransforms).sort(function(param, param1) {
15428
15592
  var [a] = param, [b] = param1;
@@ -15532,6 +15696,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15532
15696
  viewProps[keyInit] = valInit;
15533
15697
  return "continue";
15534
15698
  }
15699
+ if (keyInit[0] === "d" && keyInit.startsWith("data-")) return "continue";
15535
15700
  if (accept) {
15536
15701
  var accepted = accept[keyInit];
15537
15702
  if ((accepted === "style" || accepted === "textStyle") && valInit && (typeof valInit === "undefined" ? "undefined" : _type_of$9(valInit)) === "object") {
@@ -15573,6 +15738,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15573
15738
  var isMediaOrPseudo = Boolean(isMedia || isPseudo);
15574
15739
  if (isMediaOrPseudo && isMedia === "group") keyInit = normalizeGroupKey(keyInit, groupContext);
15575
15740
  var isStyleProp = isValidStyleKeyInit || isMediaOrPseudo || isVariant && !noExpand;
15741
+ if (shouldSkipNativeHoverProp(keyInit, isMedia)) return "continue";
15576
15742
  if (isStyleProp && (asChild === "except-style" || asChild === "except-style-web")) return "continue";
15577
15743
  var shouldPassProp = !isStyleProp && isHOC || isHOC && parentVariants && keyInit in parentVariants || (inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(keyInit));
15578
15744
  var parentVariant = parentVariants === null || parentVariants === void 0 ? void 0 : parentVariants[keyInit];
@@ -15610,6 +15776,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15610
15776
  isMediaOrPseudo = Boolean(isMedia || isPseudo);
15611
15777
  isVariant = variants && key5 in variants;
15612
15778
  if (isMedia === "group") key5 = normalizeGroupKey(key5, groupContext);
15779
+ if (shouldSkipNativeHoverProp(key5, isMedia)) return;
15613
15780
  if ((inlineProps === null || inlineProps === void 0 ? void 0 : inlineProps.has(key5)) || process.env.IS_STATIC === "is_static" && (inlineWhenUnflattened === null || inlineWhenUnflattened === void 0 ? void 0 : inlineWhenUnflattened.has(key5))) {
15614
15781
  var _props_key;
15615
15782
  viewProps[key5] = (_props_key = props[key5]) !== null && _props_key !== void 0 ? _props_key : val2;
@@ -15774,6 +15941,7 @@ var init_getSplitStyles_native = __esmMin((() => {
15774
15941
  var groupState = groupContext === null || groupContext === void 0 ? void 0 : (_groupContext_groupName = groupContext[groupName]) === null || _groupContext_groupName === void 0 ? void 0 : _groupContext_groupName.state;
15775
15942
  var groupPseudoKey = groupInfo.pseudo;
15776
15943
  var groupMediaKey = groupInfo.media;
15944
+ if (groupPseudoKey === "hover") return;
15777
15945
  if (!groupState) {
15778
15946
  pseudoGroups || (pseudoGroups = /* @__PURE__ */ new Set());
15779
15947
  return;
@@ -16127,13 +16295,17 @@ var init_mergeRenderElementProps_native = __esmMin((() => {
16127
16295
  function usePointerEvents(props, viewProps) {
16128
16296
  var { onPointerDown, onPointerUp, onPointerMove, onPointerCancel, onPointerEnter, onPointerLeave } = props;
16129
16297
  var hasPointerEvents = onPointerDown || onPointerUp || onPointerMove || onPointerCancel || onPointerEnter || onPointerLeave;
16130
- var isInsideRef = (0, react$1.useRef)(false);
16131
- var layoutRef = (0, react$1.useRef)({
16132
- width: 0,
16133
- height: 0
16134
- });
16135
- var isCapturedRef = (0, react$1.useRef)(false);
16298
+ var ref = (0, react$1.useRef)(null);
16299
+ if (!ref.current) ref.current = {
16300
+ isInside: false,
16301
+ layout: {
16302
+ width: 0,
16303
+ height: 0
16304
+ },
16305
+ isCaptured: false
16306
+ };
16136
16307
  if (!hasPointerEvents) return;
16308
+ var bag = ref.current;
16137
16309
  var createNormalizedEvent = function(e) {
16138
16310
  var touch = e.nativeEvent;
16139
16311
  var _touch_identifier;
@@ -16149,10 +16321,10 @@ function usePointerEvents(props, viewProps) {
16149
16321
  nativeEvent: touch,
16150
16322
  target: {
16151
16323
  setPointerCapture: function(_pointerId) {
16152
- isCapturedRef.current = true;
16324
+ bag.isCaptured = true;
16153
16325
  },
16154
16326
  releasePointerCapture: function(_pointerId) {
16155
- isCapturedRef.current = false;
16327
+ bag.isCaptured = false;
16156
16328
  }
16157
16329
  }
16158
16330
  });
@@ -16161,46 +16333,46 @@ function usePointerEvents(props, viewProps) {
16161
16333
  onPointerDown(createNormalizedEvent(e));
16162
16334
  });
16163
16335
  if (onPointerUp) viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
16164
- isCapturedRef.current = false;
16336
+ bag.isCaptured = false;
16165
16337
  onPointerUp(createNormalizedEvent(e));
16166
16338
  });
16167
16339
  if (onPointerMove) viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
16168
16340
  var { locationX, locationY } = e.nativeEvent;
16169
- var { width, height } = layoutRef.current;
16341
+ var { width, height } = bag.layout;
16170
16342
  var isInBounds = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
16171
- if (isCapturedRef.current || isInBounds) onPointerMove(createNormalizedEvent(e));
16343
+ if (bag.isCaptured || isInBounds) onPointerMove(createNormalizedEvent(e));
16172
16344
  });
16173
16345
  if (onPointerCancel) viewProps.onTouchCancel = composeEventHandlers(viewProps.onTouchCancel, function(e) {
16174
- isCapturedRef.current = false;
16346
+ bag.isCaptured = false;
16175
16347
  onPointerCancel(createNormalizedEvent(e));
16176
16348
  });
16177
16349
  if (onPointerEnter || onPointerLeave || onPointerMove) viewProps.onLayout = composeEventHandlers(viewProps.onLayout, function(e) {
16178
- layoutRef.current = {
16350
+ bag.layout = {
16179
16351
  width: e.nativeEvent.layout.width,
16180
16352
  height: e.nativeEvent.layout.height
16181
16353
  };
16182
16354
  });
16183
16355
  if (onPointerEnter) viewProps.onTouchStart = composeEventHandlers(viewProps.onTouchStart, function(e) {
16184
16356
  var { locationX, locationY } = e.nativeEvent;
16185
- var { width, height } = layoutRef.current;
16357
+ var { width, height } = bag.layout;
16186
16358
  if (locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height) {
16187
- isInsideRef.current = true;
16359
+ bag.isInside = true;
16188
16360
  onPointerEnter(createNormalizedEvent(e));
16189
16361
  }
16190
16362
  });
16191
16363
  if (onPointerLeave) {
16192
16364
  viewProps.onTouchMove = composeEventHandlers(viewProps.onTouchMove, function(e) {
16193
16365
  var { locationX, locationY } = e.nativeEvent;
16194
- var { width, height } = layoutRef.current;
16366
+ var { width, height } = bag.layout;
16195
16367
  var isInside = locationX >= 0 && locationX <= width && locationY >= 0 && locationY <= height;
16196
- if (isInsideRef.current && !isInside) {
16197
- isInsideRef.current = false;
16368
+ if (bag.isInside && !isInside) {
16369
+ bag.isInside = false;
16198
16370
  onPointerLeave(createNormalizedEvent(e));
16199
16371
  }
16200
16372
  });
16201
16373
  viewProps.onTouchEnd = composeEventHandlers(viewProps.onTouchEnd, function(e) {
16202
- if (isInsideRef.current) {
16203
- isInsideRef.current = false;
16374
+ if (bag.isInside) {
16375
+ bag.isInside = false;
16204
16376
  onPointerLeave(createNormalizedEvent(e));
16205
16377
  }
16206
16378
  });
@@ -16396,7 +16568,7 @@ var init_Theme_native = __esmMin((() => {
16396
16568
  if (props.disable) return props.children;
16397
16569
  var { passThrough } = props;
16398
16570
  var isRoot = !!props["_isRoot"];
16399
- var [_, themeState] = useThemeWithState(props, isRoot);
16571
+ var [_, themeState] = useThemeWithState(props, isRoot, true);
16400
16572
  var finalChildren = props["disable-child-theme"] ? react$1.Children.map(props.children, function(child) {
16401
16573
  return passThrough || !/* @__PURE__ */ (0, react$1.isValidElement)(child) ? child : /* @__PURE__ */ (0, react$1.cloneElement)(child, { ["data-disable-theme"]: true });
16402
16574
  }) : props.children;
@@ -16565,7 +16737,15 @@ var init_useComponentState_native = __esmMin((() => {
16565
16737
  });
16566
16738
  }
16567
16739
  var groupName = props.group;
16568
- var setStateShallow = useCreateShallowSetState(setState, props.debug);
16740
+ if (!stateRef.current.baseSetStateShallow) {
16741
+ var r = stateRef.current;
16742
+ r.baseSetStateShallow = function(stateOrGetState) {
16743
+ setState(function(prev) {
16744
+ return mergeIfNotShallowEqual(prev, typeof stateOrGetState === "function" ? stateOrGetState(prev) : stateOrGetState);
16745
+ });
16746
+ };
16747
+ }
16748
+ var setStateShallow = stateRef.current.baseSetStateShallow;
16569
16749
  if (presenceState && isAnimated && isHydrated && staticConfig.variants) {
16570
16750
  var { enterVariant, exitVariant, enterExitVariant, custom } = presenceState;
16571
16751
  if (isObj(custom)) Object.assign(props, custom);
@@ -16685,7 +16865,7 @@ function createComponent(staticConfig) {
16685
16865
  var overriddenContextProps = null;
16686
16866
  var componentContext = react$1.default.useContext(ComponentContext);
16687
16867
  var hasTextAncestor = false;
16688
- var isInsideNativeMenu = react$1.default.useContext(NativeMenuContext);
16868
+ var isInsideNativeMenu = isAndroid$1 ? react$1.default.useContext(NativeMenuContext) : false;
16689
16869
  var props = propsIn;
16690
16870
  var componentName = props.componentName || staticConfig.componentName;
16691
16871
  var [nextProps, overrides] = mergeComponentProps(getDefaultProps(staticConfig, props.componentName), styledContextValue, propsIn);
@@ -20559,6 +20739,7 @@ function PortalHostNonNative(props) {
20559
20739
  //#region ../portal/dist/esm/GorhomPortalItem.native.js
20560
20740
  init_index_native$7();
20561
20741
  init_index_native$3();
20742
+ init_index_native();
20562
20743
  var GorhomPortalItem = function(props) {
20563
20744
  var { name: _providedName, hostName = "root", handleOnMount: _providedHandleOnMount, handleOnUnmount: _providedHandleOnUnmount, handleOnUpdate: _providedHandleOnUpdate, children, passThrough } = props;
20564
20745
  if (getPortal().state.type === "teleport") {
@@ -20583,11 +20764,16 @@ var GorhomPortalItemFallback = function(props) {
20583
20764
  var { addPortal: addUpdatePortal, removePortal } = usePortal(hostName);
20584
20765
  var id = (0, react$1.useId)();
20585
20766
  var name = _providedName || id;
20767
+ var themeName = useThemeName();
20768
+ var themedChildren = passThrough ? children : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Theme, {
20769
+ name: themeName,
20770
+ children
20771
+ });
20586
20772
  var handleOnMount = useEvent(function() {
20587
20773
  if (_providedHandleOnMount) _providedHandleOnMount(function() {
20588
- return addUpdatePortal(name, children);
20774
+ return addUpdatePortal(name, themedChildren);
20589
20775
  });
20590
- else addUpdatePortal(name, children);
20776
+ else addUpdatePortal(name, themedChildren);
20591
20777
  });
20592
20778
  var handleOnUnmount = useEvent(function() {
20593
20779
  if (_providedHandleOnUnmount) _providedHandleOnUnmount(function() {
@@ -20597,9 +20783,9 @@ var GorhomPortalItemFallback = function(props) {
20597
20783
  });
20598
20784
  var handleOnUpdate = useEvent(function() {
20599
20785
  if (_providedHandleOnUpdate) _providedHandleOnUpdate(function() {
20600
- return addUpdatePortal(name, children);
20786
+ return addUpdatePortal(name, themedChildren);
20601
20787
  });
20602
- else addUpdatePortal(name, children);
20788
+ else addUpdatePortal(name, themedChildren);
20603
20789
  });
20604
20790
  useIsomorphicLayoutEffect(function() {
20605
20791
  if (passThrough) return;
@@ -20611,7 +20797,7 @@ var GorhomPortalItemFallback = function(props) {
20611
20797
  (0, react$1.useEffect)(function() {
20612
20798
  if (passThrough) return;
20613
20799
  handleOnUpdate();
20614
- }, [children]);
20800
+ }, [children, themeName]);
20615
20801
  return passThrough ? children : null;
20616
20802
  };
20617
20803
  //#endregion
@@ -28585,6 +28771,7 @@ function getKeyboardOccludedHeight(param) {
28585
28771
  //#region ../sheet/dist/esm/useGestureHandlerPan.native.js
28586
28772
  init_index_native$7();
28587
28773
  var AT_TOP_THRESHOLD = 5;
28774
+ var SCROLL_HANDOFF_THRESHOLD = 160;
28588
28775
  function useGestureHandlerPan(config) {
28589
28776
  var { positions, frameSize, setPosition, animateTo, stopSpring, scrollBridge, setIsDragging, getCurrentPosition, resisted, disableDrag, isShowingInnerSheet, setAnimatedPosition, scrollGestureRef } = config;
28590
28777
  var gestureHandlerEnabled = isGestureHandlerEnabled();
@@ -28610,16 +28797,45 @@ function useGestureHandlerPan(config) {
28610
28797
  frozenPositions: [],
28611
28798
  frozenMinY: 0,
28612
28799
  frozenIsKeyboardVisible: false,
28613
- panStarted: false
28800
+ panStarted: false,
28801
+ startedBelowTop: false,
28802
+ upwardDragAfterTop: 0,
28803
+ scrollUnlockedAfterTop: false,
28804
+ keepScrollLockedAfterEnd: false
28614
28805
  });
28806
+ var unlockScrollTimer = (0, react$1.useRef)(null);
28807
+ (0, react$1.useEffect)(function() {
28808
+ return function() {
28809
+ if (unlockScrollTimer.current) {
28810
+ clearTimeout(unlockScrollTimer.current);
28811
+ unlockScrollTimer.current = null;
28812
+ }
28813
+ };
28814
+ }, []);
28615
28815
  var onStart = (0, react$1.useCallback)(function() {
28616
28816
  stopSpring();
28617
28817
  }, [stopSpring]);
28618
28818
  var onEnd = (0, react$1.useCallback)(function(closestPoint, animationOverride) {
28619
- var _scrollBridge_setScrollEnabled;
28819
+ var keepScrollLocked = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
28820
+ if (unlockScrollTimer.current) {
28821
+ clearTimeout(unlockScrollTimer.current);
28822
+ unlockScrollTimer.current = null;
28823
+ }
28620
28824
  setIsDragging(false);
28621
28825
  scrollBridge.setParentDragging(false);
28622
- (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, true);
28826
+ scrollBridge.lockScrollAtTop = false;
28827
+ if (keepScrollLocked) {
28828
+ var _scrollBridge_setScrollEnabled;
28829
+ (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, false, 0);
28830
+ unlockScrollTimer.current = setTimeout(function() {
28831
+ var _scrollBridge_setScrollEnabled2;
28832
+ unlockScrollTimer.current = null;
28833
+ (_scrollBridge_setScrollEnabled2 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled2 === void 0 || _scrollBridge_setScrollEnabled2.call(scrollBridge, true);
28834
+ }, 160);
28835
+ } else {
28836
+ var _scrollBridge_setScrollEnabled1;
28837
+ (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, true);
28838
+ }
28623
28839
  setPosition(closestPoint);
28624
28840
  animateTo(closestPoint, animationOverride);
28625
28841
  }, [
@@ -28649,6 +28865,15 @@ function useGestureHandlerPan(config) {
28649
28865
  gs.frozenPositions = [...positions];
28650
28866
  gs.frozenMinY = minY;
28651
28867
  gs.frozenIsKeyboardVisible = releaseConfigRef.current.isKeyboardVisible;
28868
+ gs.startedBelowTop = !atTop;
28869
+ gs.upwardDragAfterTop = 0;
28870
+ gs.scrollUnlockedAfterTop = false;
28871
+ gs.keepScrollLockedAfterEnd = false;
28872
+ scrollBridge.lockScrollAtTop = false;
28873
+ if (unlockScrollTimer.current) {
28874
+ clearTimeout(unlockScrollTimer.current);
28875
+ unlockScrollTimer.current = null;
28876
+ }
28652
28877
  if (!atTop) {
28653
28878
  var _scrollBridge_setScrollEnabled;
28654
28879
  (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, false, 0);
@@ -28674,10 +28899,17 @@ function useGestureHandlerPan(config) {
28674
28899
  else if (isSwipingDown) if (nodeIsScrolling && hasScrollableContent) panHandles = false;
28675
28900
  else if (gs.scrollEngaged && hasScrollableContent) panHandles = true;
28676
28901
  else panHandles = true;
28677
- else if (hasScrollableContent) panHandles = false;
28902
+ else if (hasScrollableContent) if (gs.startedBelowTop && !gs.scrollUnlockedAfterTop) {
28903
+ gs.upwardDragAfterTop += Math.max(0, -deltaY);
28904
+ if (gs.upwardDragAfterTop >= SCROLL_HANDOFF_THRESHOLD) {
28905
+ gs.scrollUnlockedAfterTop = true;
28906
+ panHandles = false;
28907
+ } else panHandles = true;
28908
+ } else panHandles = false;
28678
28909
  else panHandles = true;
28679
28910
  if (panHandles) {
28680
28911
  var _scrollBridge_setScrollEnabled;
28912
+ scrollBridge.lockScrollAtTop = gs.startedBelowTop && !gs.scrollUnlockedAfterTop;
28681
28913
  var lockTo = isCurrentlyAtTop && isSwipingDown && gs.scrollEngaged ? void 0 : 0;
28682
28914
  (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, false, lockTo);
28683
28915
  gs.accumulatedOffset += deltaY;
@@ -28687,15 +28919,20 @@ function useGestureHandlerPan(config) {
28687
28919
  scrollBridge.setParentDragging(newPosition > minY);
28688
28920
  } else {
28689
28921
  var _scrollBridge_setScrollEnabled1;
28922
+ scrollBridge.lockScrollAtTop = false;
28690
28923
  (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, true);
28924
+ scrollBridge.setParentDragging(false);
28691
28925
  }
28692
28926
  }).onEnd(function(event) {
28693
28927
  var { velocityY } = event;
28694
28928
  var currentPos = gs.startY + gs.accumulatedOffset;
28695
- scrollBridge.scrollLockY = void 0;
28929
+ var keepScrollLockedAfterEnd = gs.startedBelowTop && !gs.scrollUnlockedAfterTop;
28930
+ scrollBridge.lockScrollAtTop = false;
28931
+ scrollBridge.scrollLockY = keepScrollLockedAfterEnd ? 0 : void 0;
28932
+ gs.keepScrollLockedAfterEnd = keepScrollLockedAfterEnd;
28696
28933
  var snapPositions = gs.frozenPositions.length > 0 ? gs.frozenPositions : positions;
28697
28934
  if (currentPos <= (gs.frozenPositions.length > 0 ? gs.frozenMinY : minY) + AT_TOP_THRESHOLD && scrollBridge.y > 0) {
28698
- onEnd(0);
28935
+ onEnd(0, void 0, keepScrollLockedAfterEnd);
28699
28936
  return;
28700
28937
  }
28701
28938
  var projectedEnd = currentPos + frameSize * (velocityY / 1e3) * .2;
@@ -28709,9 +28946,10 @@ function useGestureHandlerPan(config) {
28709
28946
  snapPointsMode: releaseConfig.snapPointsMode,
28710
28947
  isKeyboardVisible: gs.frozenIsKeyboardVisible,
28711
28948
  isWeb: false
28712
- }));
28949
+ }), void 0, keepScrollLockedAfterEnd);
28713
28950
  }).onFinalize(function() {
28714
- scrollBridge.scrollLockY = void 0;
28951
+ scrollBridge.lockScrollAtTop = false;
28952
+ scrollBridge.scrollLockY = gs.keepScrollLockedAfterEnd ? 0 : void 0;
28715
28953
  if (gs.panStarted) setIsDragging(false);
28716
28954
  else if (config.pauseKeyboardHandler) config.pauseKeyboardHandler.current = false;
28717
28955
  }).runOnJS(true);
@@ -28864,8 +29102,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
28864
29102
  var { open, controller, isHidden } = state;
28865
29103
  var openRef = react$1.default.useRef(open);
28866
29104
  openRef.current = open;
28867
- var sheetRef = react$1.default.useRef(void 0);
28868
- var ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef);
29105
+ var ref = useComposedRefs(forwardedRef, react$1.default.useRef(void 0), providerProps.contentRef);
28869
29106
  var { animationDriver } = useConfiguration();
28870
29107
  if (!animationDriver) throw new Error(`Sheet requires an animation driver to be set`);
28871
29108
  var transitionConfig = function() {
@@ -28887,6 +29124,16 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
28887
29124
  if (open && frameSize) stableFrameSize.current = frameSize;
28888
29125
  }, [open, frameSize]);
28889
29126
  var isWebKbSheet = false;
29127
+ var isNativeKbFitSheet = hasFit && Boolean(moveOnKeyboardChange);
29128
+ var preKeyboardFrameSize = react$1.default.useRef(0);
29129
+ react$1.default.useEffect(function() {
29130
+ if (isNativeKbFitSheet && open && !isKeyboardVisible && frameSize > 0) preKeyboardFrameSize.current = frameSize;
29131
+ }, [
29132
+ isNativeKbFitSheet,
29133
+ open,
29134
+ isKeyboardVisible,
29135
+ frameSize
29136
+ ]);
28890
29137
  var effScreenSize = isWebKbSheet ? getStableViewportHeight() : screenSize;
28891
29138
  var effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
28892
29139
  var positions = react$1.default.useMemo(function() {
@@ -28939,8 +29186,8 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
28939
29186
  screenSize: effScreenSize,
28940
29187
  sheetY: position >= 0 ? activePositions[position] : void 0
28941
29188
  });
28942
- var keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0 ? frameSize : 0;
28943
- var { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } = animationDriver;
29189
+ var keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0 ? frameSize : isNativeKbFitSheet && isKeyboardVisible && preKeyboardFrameSize.current > 0 ? preKeyboardFrameSize.current : 0;
29190
+ var { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver;
28944
29191
  var _animationDriver_View;
28945
29192
  var AnimatedView = (_animationDriver_View = animationDriver.View) !== null && _animationDriver_View !== void 0 ? _animationDriver_View : View;
28946
29193
  useIsomorphicLayoutEffect(function() {
@@ -28962,33 +29209,49 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
28962
29209
  if (controller === null || controller === void 0 ? void 0 : controller.skipNextAnimation) skipAdaptAnimation.current = true;
28963
29210
  var hasScrollView = react$1.default.useRef(false);
28964
29211
  var opacityFallbackTimer = react$1.default.useRef(null);
28965
- useAnimatedNumberReaction({
28966
- value: animatedNumber,
28967
- hostRef: sheetRef
28968
- }, react$1.default.useCallback(function(value) {
29212
+ var syncAnimatedPosition = useEvent(function(value) {
28969
29213
  at.current = value;
28970
29214
  scrollBridge.paneY = value;
28971
29215
  var minY = activePositions[0];
28972
29216
  var wasAtTop = scrollBridge.isAtTop;
28973
29217
  var nowAtTop = value <= minY + 5;
28974
- if (wasAtTop !== nowAtTop) {
28975
- scrollBridge.isAtTop = nowAtTop;
28976
- if (nowAtTop) {
28977
- var _scrollBridge_setScrollEnabled;
29218
+ if (wasAtTop === nowAtTop) return;
29219
+ scrollBridge.isAtTop = nowAtTop;
29220
+ if (nowAtTop) {
29221
+ var _scrollBridge_setScrollEnabled;
29222
+ if (scrollBridge.lockScrollAtTop) {
29223
+ var _scrollBridge_setScrollEnabled1;
28978
29224
  if (scrollBridge.y > 0) {
28979
29225
  var _scrollBridge_forceScrollTo;
28980
29226
  (_scrollBridge_forceScrollTo = scrollBridge.forceScrollTo) === null || _scrollBridge_forceScrollTo === void 0 || _scrollBridge_forceScrollTo.call(scrollBridge, 0);
28981
29227
  scrollBridge.y = 0;
28982
29228
  }
28983
- scrollBridge.scrollLockY = void 0;
28984
- (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, true);
28985
- } else {
28986
- var _scrollBridge_setScrollEnabled1;
28987
29229
  scrollBridge.scrollLockY = 0;
28988
- (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, false);
29230
+ (_scrollBridge_setScrollEnabled1 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled1 === void 0 || _scrollBridge_setScrollEnabled1.call(scrollBridge, false, 0);
29231
+ return;
28989
29232
  }
29233
+ if (scrollBridge.y > 0) {
29234
+ var _scrollBridge_forceScrollTo1;
29235
+ (_scrollBridge_forceScrollTo1 = scrollBridge.forceScrollTo) === null || _scrollBridge_forceScrollTo1 === void 0 || _scrollBridge_forceScrollTo1.call(scrollBridge, 0);
29236
+ scrollBridge.y = 0;
29237
+ }
29238
+ scrollBridge.scrollLockY = void 0;
29239
+ (_scrollBridge_setScrollEnabled = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled === void 0 || _scrollBridge_setScrollEnabled.call(scrollBridge, true);
29240
+ } else {
29241
+ var _scrollBridge_setScrollEnabled2;
29242
+ scrollBridge.scrollLockY = 0;
29243
+ (_scrollBridge_setScrollEnabled2 = scrollBridge.setScrollEnabled) === null || _scrollBridge_setScrollEnabled2 === void 0 || _scrollBridge_setScrollEnabled2.call(scrollBridge, false);
28990
29244
  }
28991
- }, [animationDriver, activePositions]));
29245
+ });
29246
+ var setAnimatedPositionDirect = useEvent(function(value) {
29247
+ syncAnimatedPosition(value);
29248
+ animatedNumber.setValue(value, { type: "direct" });
29249
+ });
29250
+ var getAnimatedPosition = useEvent(function() {
29251
+ var value = animatedNumber.getValue();
29252
+ syncAnimatedPosition(value);
29253
+ return value;
29254
+ });
28992
29255
  function stopSpring() {
28993
29256
  animatedNumber.stop();
28994
29257
  if (scrollBridge.onFinishAnimate) {
@@ -29009,6 +29272,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29009
29272
  }
29010
29273
  var animationCompleteCallback = function() {
29011
29274
  var _controller_onAnimationComplete;
29275
+ syncAnimatedPosition(toValue);
29012
29276
  if (opacityFallbackTimer.current) {
29013
29277
  clearTimeout(opacityFallbackTimer.current);
29014
29278
  opacityFallbackTimer.current = null;
@@ -29038,6 +29302,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29038
29302
  type: "timing",
29039
29303
  duration: 0
29040
29304
  }, function() {
29305
+ syncAnimatedPosition(screenSize);
29041
29306
  setTimeout(function() {
29042
29307
  setDisableAnimation(false);
29043
29308
  }, 10);
@@ -29140,7 +29405,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29140
29405
  var grant = function() {
29141
29406
  setPanning(true);
29142
29407
  stopSpring();
29143
- startY = at.current;
29408
+ startY = getAnimatedPosition();
29144
29409
  };
29145
29410
  var isExternalDrag = false;
29146
29411
  scrollBridge.startPanDrag = function() {
@@ -29152,8 +29417,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29152
29417
  isExternalDrag = true;
29153
29418
  grant();
29154
29419
  }
29155
- var to = dy + startY;
29156
- animatedNumber.setValue(resisted(to, minY), { type: "direct" });
29420
+ setAnimatedPositionDirect(resisted(dy + startY, minY));
29157
29421
  };
29158
29422
  scrollBridge.release = release;
29159
29423
  scrollBridge.snapToPosition = function(positionIndex) {
@@ -29173,7 +29437,7 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29173
29437
  var to = resisted(dy + startY, minY);
29174
29438
  if (to <= minY) scrollBridge.setParentDragging(false);
29175
29439
  else scrollBridge.setParentDragging(true);
29176
- animatedNumber.setValue(to, { type: "direct" });
29440
+ setAnimatedPositionDirect(to);
29177
29441
  },
29178
29442
  onPanResponderEnd: finish,
29179
29443
  onPanResponderTerminate: finish,
@@ -29223,16 +29487,11 @@ var SheetImplementationCustom = /* @__PURE__ */ react$1.default.forwardRef(funct
29223
29487
  stopSpring,
29224
29488
  scrollBridge,
29225
29489
  setIsDragging,
29226
- getCurrentPosition: function() {
29227
- return at.current;
29228
- },
29490
+ getCurrentPosition: getAnimatedPosition,
29229
29491
  resisted,
29230
29492
  disableDrag,
29231
29493
  isShowingInnerSheet,
29232
- setAnimatedPosition: function(val) {
29233
- at.current = val;
29234
- animatedNumber.setValue(val, { type: "direct" });
29235
- },
29494
+ setAnimatedPosition: setAnimatedPositionDirect,
29236
29495
  dismissOnSnapToBottom,
29237
29496
  snapPointsMode,
29238
29497
  isKeyboardVisible,
@@ -29533,6 +29792,7 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29533
29792
  height: void 0,
29534
29793
  maxHeight: screenSize || void 0
29535
29794
  } : { flex: 1 };
29795
+ var contentContainerStyle = hasFit ? void 0 : { minHeight: "100%" };
29536
29796
  var keyboardFrozenOverride = hasFit && isKeyboardVisible && frozenFrameHeight > 0 ? {
29537
29797
  height: frozenFrameHeight,
29538
29798
  maxHeight: frozenFrameHeight
@@ -29541,20 +29801,29 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29541
29801
  var { ScrollView: RNGHScrollView } = getGestureHandlerState();
29542
29802
  var useRNGHScrollView = isGestureHandlerEnabled() && RNGHScrollView && panGestureRef;
29543
29803
  var currentScrollOffset = (0, react$1.useRef)(0);
29804
+ var lastEmittedScrollOffset = (0, react$1.useRef)(0);
29544
29805
  var lockedScrollY = (0, react$1.useRef)(0);
29545
29806
  (0, react$1.useRef)(0);
29546
29807
  var setScrollEnabled = function(next, lockTo) {
29547
29808
  if (!next) {
29548
- var _scrollRef_current_scrollTo, _scrollRef_current;
29549
- var lockY = lockTo !== null && lockTo !== void 0 ? lockTo : currentScrollOffset.current;
29809
+ var _ref;
29810
+ var lockY = (_ref = lockTo !== null && lockTo !== void 0 ? lockTo : scrollBridge.scrollLockY) !== null && _ref !== void 0 ? _ref : currentScrollOffset.current;
29811
+ if (scrollBridge.enabled === false && scrollBridge.scrollLockY === lockY) return;
29812
+ scrollBridge.enabled = false;
29550
29813
  lockedScrollY.current = lockY;
29551
29814
  scrollBridge.scrollLockY = lockY;
29552
- (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 || (_scrollRef_current_scrollTo = _scrollRef_current.scrollTo) == null || _scrollRef_current_scrollTo.call(_scrollRef_current, {
29553
- x: 0,
29554
- y: lockY,
29555
- animated: false
29556
- });
29815
+ if (currentScrollOffset.current !== lockY) {
29816
+ var _scrollRef_current_scrollTo, _scrollRef_current;
29817
+ (_scrollRef_current = scrollRef.current) === null || _scrollRef_current === void 0 || (_scrollRef_current_scrollTo = _scrollRef_current.scrollTo) == null || _scrollRef_current_scrollTo.call(_scrollRef_current, {
29818
+ x: 0,
29819
+ y: lockY,
29820
+ animated: false
29821
+ });
29822
+ currentScrollOffset.current = lockY;
29823
+ }
29557
29824
  } else {
29825
+ if (scrollBridge.enabled === true && scrollBridge.scrollLockY === void 0) return;
29826
+ scrollBridge.enabled = true;
29558
29827
  lockedScrollY.current = currentScrollOffset.current;
29559
29828
  scrollBridge.scrollLockY = void 0;
29560
29829
  }
@@ -29566,7 +29835,31 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29566
29835
  y,
29567
29836
  animated: false
29568
29837
  });
29569
- };
29838
+ currentScrollOffset.current = y;
29839
+ };
29840
+ var emitManualScroll = react$1.default.useCallback(function(node, y) {
29841
+ currentScrollOffset.current = y;
29842
+ scrollBridge.y = y;
29843
+ if (y > 0) scrollBridge.scrollStartY = -1;
29844
+ lastEmittedScrollOffset.current = y;
29845
+ onScroll === null || onScroll === void 0 || onScroll({
29846
+ nativeEvent: {
29847
+ contentOffset: {
29848
+ x: node.scrollLeft,
29849
+ y
29850
+ },
29851
+ contentSize: {
29852
+ height: node.scrollHeight,
29853
+ width: node.scrollWidth
29854
+ },
29855
+ layoutMeasurement: {
29856
+ height: node.offsetHeight,
29857
+ width: node.offsetWidth
29858
+ }
29859
+ },
29860
+ timeStamp: Date.now()
29861
+ });
29862
+ }, [onScroll, scrollBridge]);
29570
29863
  var scrollFocusedInputClearOfKeyboard = react$1.default.useCallback(function() {}, [
29571
29864
  hasFit,
29572
29865
  isKeyboardVisible,
@@ -29601,7 +29894,8 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29601
29894
  scrollBridge,
29602
29895
  hasScrollableContent,
29603
29896
  scrollEnabled,
29604
- setScrollEnabled
29897
+ setScrollEnabled,
29898
+ onManualScroll: emitManualScroll
29605
29899
  });
29606
29900
  var contentWrapper = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(View, {
29607
29901
  onLayout: function(e) {
@@ -29640,15 +29934,20 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29640
29934
  animated: false
29641
29935
  });
29642
29936
  }
29937
+ currentScrollOffset.current = scrollBridge.scrollLockY;
29643
29938
  scrollBridge.y = scrollBridge.scrollLockY;
29644
- onScroll === null || onScroll === void 0 || onScroll(_objectSpread2(_objectSpread2({}, e), {}, { nativeEvent: _objectSpread2(_objectSpread2({}, e.nativeEvent), {}, { contentOffset: _objectSpread2(_objectSpread2({}, e.nativeEvent.contentOffset), {}, { y: scrollBridge.scrollLockY }) }) }));
29939
+ if (lastEmittedScrollOffset.current !== scrollBridge.scrollLockY) {
29940
+ lastEmittedScrollOffset.current = scrollBridge.scrollLockY;
29941
+ onScroll === null || onScroll === void 0 || onScroll(_objectSpread2(_objectSpread2({}, e), {}, { nativeEvent: _objectSpread2(_objectSpread2({}, e.nativeEvent), {}, { contentOffset: _objectSpread2(_objectSpread2({}, e.nativeEvent.contentOffset), {}, { y: scrollBridge.scrollLockY }) }) }));
29942
+ }
29645
29943
  return;
29646
29944
  }
29647
29945
  scrollBridge.y = y;
29648
29946
  if (y > 0) scrollBridge.scrollStartY = -1;
29947
+ lastEmittedScrollOffset.current = y;
29649
29948
  onScroll === null || onScroll === void 0 || onScroll(e);
29650
29949
  },
29651
- contentContainerStyle: { minHeight: "100%" },
29950
+ contentContainerStyle,
29652
29951
  bounces: false,
29653
29952
  keyboardShouldPersistTaps: "always",
29654
29953
  keyboardDismissMode: "none"
@@ -29668,9 +29967,10 @@ var SheetScrollView = /* @__PURE__ */ react$1.default.forwardRef(function(param,
29668
29967
  currentScrollOffset.current = y;
29669
29968
  scrollBridge.y = y;
29670
29969
  if (y > 0) scrollBridge.scrollStartY = -1;
29970
+ lastEmittedScrollOffset.current = y;
29671
29971
  onScroll === null || onScroll === void 0 || onScroll(e);
29672
29972
  },
29673
- contentContainerStyle: { minHeight: "100%" }
29973
+ contentContainerStyle
29674
29974
  }, gestureProps), props), keyboardFrozenOverride), {}, { children: contentWrapper }));
29675
29975
  });
29676
29976
  //#endregion
@@ -32210,13 +32510,19 @@ function getWindowSize() {
32210
32510
  return Dimensions.get("window");
32211
32511
  }
32212
32512
  var cbs = /* @__PURE__ */ new Set();
32213
- Dimensions.addEventListener("change", function(param) {
32214
- var { window } = param;
32215
- cbs.forEach(function(cb) {
32216
- return cb(window);
32513
+ var isListening = false;
32514
+ var ensureListening = function() {
32515
+ if (isListening) return;
32516
+ isListening = true;
32517
+ Dimensions.addEventListener("change", function(param) {
32518
+ var { window } = param;
32519
+ cbs.forEach(function(cb) {
32520
+ return cb(window);
32521
+ });
32217
32522
  });
32218
- });
32523
+ };
32219
32524
  function subscribe(cb) {
32525
+ ensureListening();
32220
32526
  cbs.add(cb);
32221
32527
  return function() {
32222
32528
  return cbs.delete(cb);