@shellui/core 0.0.18 → 0.0.19

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.
@@ -0,0 +1,4414 @@
1
+ // modules are defined as an array
2
+ // [ module function, map of requires ]
3
+ //
4
+ // map of requires is short require name -> numeric require
5
+ //
6
+ // anything defined in a previous bundle is accessed via the
7
+ // orig method which is the require for previous bundles
8
+
9
+ (function (
10
+ modules,
11
+ entry,
12
+ mainEntry,
13
+ parcelRequireName,
14
+ externals,
15
+ distDir,
16
+ publicUrl,
17
+ devServer
18
+ ) {
19
+ /* eslint-disable no-undef */
20
+ var globalObject =
21
+ typeof globalThis !== 'undefined'
22
+ ? globalThis
23
+ : typeof self !== 'undefined'
24
+ ? self
25
+ : typeof window !== 'undefined'
26
+ ? window
27
+ : typeof global !== 'undefined'
28
+ ? global
29
+ : {};
30
+ /* eslint-enable no-undef */
31
+
32
+ // Save the require from previous bundle to this closure if any
33
+ var previousRequire =
34
+ typeof globalObject[parcelRequireName] === 'function' &&
35
+ globalObject[parcelRequireName];
36
+
37
+ var importMap = previousRequire.i || {};
38
+ var cache = previousRequire.cache || {};
39
+ // Do not use `require` to prevent Webpack from trying to bundle this call
40
+ var nodeRequire =
41
+ typeof module !== 'undefined' &&
42
+ typeof module.require === 'function' &&
43
+ module.require.bind(module);
44
+
45
+ function newRequire(name, jumped) {
46
+ if (!cache[name]) {
47
+ if (!modules[name]) {
48
+ if (externals[name]) {
49
+ return externals[name];
50
+ }
51
+ // if we cannot find the module within our internal map or
52
+ // cache jump to the current global require ie. the last bundle
53
+ // that was added to the page.
54
+ var currentRequire =
55
+ typeof globalObject[parcelRequireName] === 'function' &&
56
+ globalObject[parcelRequireName];
57
+ if (!jumped && currentRequire) {
58
+ return currentRequire(name, true);
59
+ }
60
+
61
+ // If there are other bundles on this page the require from the
62
+ // previous one is saved to 'previousRequire'. Repeat this as
63
+ // many times as there are bundles until the module is found or
64
+ // we exhaust the require chain.
65
+ if (previousRequire) {
66
+ return previousRequire(name, true);
67
+ }
68
+
69
+ // Try the node require function if it exists.
70
+ if (nodeRequire && typeof name === 'string') {
71
+ return nodeRequire(name);
72
+ }
73
+
74
+ var err = new Error("Cannot find module '" + name + "'");
75
+ err.code = 'MODULE_NOT_FOUND';
76
+ throw err;
77
+ }
78
+
79
+ localRequire.resolve = resolve;
80
+ localRequire.cache = {};
81
+
82
+ var module = (cache[name] = new newRequire.Module(name));
83
+
84
+ modules[name][0].call(
85
+ module.exports,
86
+ localRequire,
87
+ module,
88
+ module.exports,
89
+ globalObject
90
+ );
91
+ }
92
+
93
+ return cache[name].exports;
94
+
95
+ function localRequire(x) {
96
+ var res = localRequire.resolve(x);
97
+ if (res === false) {
98
+ return {};
99
+ }
100
+ // Synthesize a module to follow re-exports.
101
+ if (Array.isArray(res)) {
102
+ var m = {__esModule: true};
103
+ res.forEach(function (v) {
104
+ var key = v[0];
105
+ var id = v[1];
106
+ var exp = v[2] || v[0];
107
+ var x = newRequire(id);
108
+ if (key === '*') {
109
+ Object.keys(x).forEach(function (key) {
110
+ if (
111
+ key === 'default' ||
112
+ key === '__esModule' ||
113
+ Object.prototype.hasOwnProperty.call(m, key)
114
+ ) {
115
+ return;
116
+ }
117
+
118
+ Object.defineProperty(m, key, {
119
+ enumerable: true,
120
+ get: function () {
121
+ return x[key];
122
+ },
123
+ });
124
+ });
125
+ } else if (exp === '*') {
126
+ Object.defineProperty(m, key, {
127
+ enumerable: true,
128
+ value: x,
129
+ });
130
+ } else {
131
+ Object.defineProperty(m, key, {
132
+ enumerable: true,
133
+ get: function () {
134
+ if (exp === 'default') {
135
+ return x.__esModule ? x.default : x;
136
+ }
137
+ return x[exp];
138
+ },
139
+ });
140
+ }
141
+ });
142
+ return m;
143
+ }
144
+ return newRequire(res);
145
+ }
146
+
147
+ function resolve(x) {
148
+ var id = modules[name][1][x];
149
+ return id != null ? id : x;
150
+ }
151
+ }
152
+
153
+ function Module(moduleName) {
154
+ this.id = moduleName;
155
+ this.bundle = newRequire;
156
+ this.require = nodeRequire;
157
+ this.exports = {};
158
+ }
159
+
160
+ newRequire.isParcelRequire = true;
161
+ newRequire.Module = Module;
162
+ newRequire.modules = modules;
163
+ newRequire.cache = cache;
164
+ newRequire.parent = previousRequire;
165
+ newRequire.distDir = distDir;
166
+ newRequire.publicUrl = publicUrl;
167
+ newRequire.devServer = devServer;
168
+ newRequire.i = importMap;
169
+ newRequire.register = function (id, exports) {
170
+ modules[id] = [
171
+ function (require, module) {
172
+ module.exports = exports;
173
+ },
174
+ {},
175
+ ];
176
+ };
177
+
178
+ // Only insert newRequire.load when it is actually used.
179
+ // The code in this file is linted against ES5, so dynamic import is not allowed.
180
+ // INSERT_LOAD_HERE
181
+
182
+ Object.defineProperty(newRequire, 'root', {
183
+ get: function () {
184
+ return globalObject[parcelRequireName];
185
+ },
186
+ });
187
+
188
+ globalObject[parcelRequireName] = newRequire;
189
+
190
+ for (var i = 0; i < entry.length; i++) {
191
+ newRequire(entry[i]);
192
+ }
193
+
194
+ if (mainEntry) {
195
+ // Expose entry point to Node, AMD or browser globals
196
+ // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
197
+ var mainExports = newRequire(mainEntry);
198
+
199
+ // CommonJS
200
+ if (typeof exports === 'object' && typeof module !== 'undefined') {
201
+ module.exports = mainExports;
202
+
203
+ // RequireJS
204
+ } else if (typeof define === 'function' && define.amd) {
205
+ define(function () {
206
+ return mainExports;
207
+ });
208
+ }
209
+ }
210
+ })({"aEqQu":[function(require,module,exports,__globalThis) {
211
+ var global = arguments[3];
212
+ var HMR_HOST = "localhost";
213
+ var HMR_PORT = null;
214
+ var HMR_SERVER_PORT = 4000;
215
+ var HMR_SECURE = false;
216
+ var HMR_ENV_HASH = "439701173a9199ea";
217
+ var HMR_USE_SSE = false;
218
+ module.bundle.HMR_BUNDLE_ID = "c525d1fd4454f259";
219
+ "use strict";
220
+ /* global HMR_HOST, HMR_PORT, HMR_SERVER_PORT, HMR_ENV_HASH, HMR_SECURE, HMR_USE_SSE, chrome, browser, __parcel__import__, __parcel__importScripts__, ServiceWorkerGlobalScope */ /*::
221
+ import type {
222
+ HMRAsset,
223
+ HMRMessage,
224
+ } from '@parcel/reporter-dev-server/src/HMRServer.js';
225
+ interface ParcelRequire {
226
+ (string): mixed;
227
+ cache: {|[string]: ParcelModule|};
228
+ hotData: {|[string]: mixed|};
229
+ Module: any;
230
+ parent: ?ParcelRequire;
231
+ isParcelRequire: true;
232
+ modules: {|[string]: [Function, {|[string]: string|}]|};
233
+ HMR_BUNDLE_ID: string;
234
+ root: ParcelRequire;
235
+ }
236
+ interface ParcelModule {
237
+ hot: {|
238
+ data: mixed,
239
+ accept(cb: (Function) => void): void,
240
+ dispose(cb: (mixed) => void): void,
241
+ // accept(deps: Array<string> | string, cb: (Function) => void): void,
242
+ // decline(): void,
243
+ _acceptCallbacks: Array<(Function) => void>,
244
+ _disposeCallbacks: Array<(mixed) => void>,
245
+ |};
246
+ }
247
+ interface ExtensionContext {
248
+ runtime: {|
249
+ reload(): void,
250
+ getURL(url: string): string;
251
+ getManifest(): {manifest_version: number, ...};
252
+ |};
253
+ }
254
+ declare var module: {bundle: ParcelRequire, ...};
255
+ declare var HMR_HOST: string;
256
+ declare var HMR_PORT: string;
257
+ declare var HMR_SERVER_PORT: string;
258
+ declare var HMR_ENV_HASH: string;
259
+ declare var HMR_SECURE: boolean;
260
+ declare var HMR_USE_SSE: boolean;
261
+ declare var chrome: ExtensionContext;
262
+ declare var browser: ExtensionContext;
263
+ declare var __parcel__import__: (string) => Promise<void>;
264
+ declare var __parcel__importScripts__: (string) => Promise<void>;
265
+ declare var globalThis: typeof self;
266
+ declare var ServiceWorkerGlobalScope: Object;
267
+ */ var OVERLAY_ID = '__parcel__error__overlay__';
268
+ var OldModule = module.bundle.Module;
269
+ function Module(moduleName) {
270
+ OldModule.call(this, moduleName);
271
+ this.hot = {
272
+ data: module.bundle.hotData[moduleName],
273
+ _acceptCallbacks: [],
274
+ _disposeCallbacks: [],
275
+ accept: function(fn) {
276
+ this._acceptCallbacks.push(fn || function() {});
277
+ },
278
+ dispose: function(fn) {
279
+ this._disposeCallbacks.push(fn);
280
+ }
281
+ };
282
+ module.bundle.hotData[moduleName] = undefined;
283
+ }
284
+ module.bundle.Module = Module;
285
+ module.bundle.hotData = {};
286
+ var checkedAssets /*: {|[string]: boolean|} */ , disposedAssets /*: {|[string]: boolean|} */ , assetsToDispose /*: Array<[ParcelRequire, string]> */ , assetsToAccept /*: Array<[ParcelRequire, string]> */ , bundleNotFound = false;
287
+ function getHostname() {
288
+ return HMR_HOST || (typeof location !== 'undefined' && location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost');
289
+ }
290
+ function getPort() {
291
+ return HMR_PORT || (typeof location !== 'undefined' ? location.port : HMR_SERVER_PORT);
292
+ }
293
+ // eslint-disable-next-line no-redeclare
294
+ let WebSocket = globalThis.WebSocket;
295
+ if (!WebSocket && typeof module.bundle.root === 'function') try {
296
+ // eslint-disable-next-line no-global-assign
297
+ WebSocket = module.bundle.root('ws');
298
+ } catch {
299
+ // ignore.
300
+ }
301
+ var hostname = getHostname();
302
+ var port = getPort();
303
+ var protocol = HMR_SECURE || typeof location !== 'undefined' && location.protocol === 'https:' && ![
304
+ 'localhost',
305
+ '127.0.0.1',
306
+ '0.0.0.0'
307
+ ].includes(hostname) ? 'wss' : 'ws';
308
+ // eslint-disable-next-line no-redeclare
309
+ var parent = module.bundle.parent;
310
+ if (!parent || !parent.isParcelRequire) {
311
+ // Web extension context
312
+ var extCtx = typeof browser === 'undefined' ? typeof chrome === 'undefined' ? null : chrome : browser;
313
+ // Safari doesn't support sourceURL in error stacks.
314
+ // eval may also be disabled via CSP, so do a quick check.
315
+ var supportsSourceURL = false;
316
+ try {
317
+ (0, eval)('throw new Error("test"); //# sourceURL=test.js');
318
+ } catch (err) {
319
+ supportsSourceURL = err.stack.includes('test.js');
320
+ }
321
+ var ws;
322
+ if (HMR_USE_SSE) ws = new EventSource('/__parcel_hmr');
323
+ else try {
324
+ // If we're running in the dev server's node runner, listen for messages on the parent port.
325
+ let { workerData, parentPort } = module.bundle.root('node:worker_threads') /*: any*/ ;
326
+ if (workerData !== null && workerData !== void 0 && workerData.__parcel) {
327
+ parentPort.on('message', async (message)=>{
328
+ try {
329
+ await handleMessage(message);
330
+ parentPort.postMessage('updated');
331
+ } catch {
332
+ parentPort.postMessage('restart');
333
+ }
334
+ });
335
+ // After the bundle has finished running, notify the dev server that the HMR update is complete.
336
+ queueMicrotask(()=>parentPort.postMessage('ready'));
337
+ }
338
+ } catch {
339
+ if (typeof WebSocket !== 'undefined') try {
340
+ ws = new WebSocket(protocol + '://' + hostname + (port ? ':' + port : '') + '/');
341
+ } catch (err) {
342
+ // Ignore cloudflare workers error.
343
+ if (err.message && !err.message.includes('Disallowed operation called within global scope')) console.error(err.message);
344
+ }
345
+ }
346
+ if (ws) {
347
+ // $FlowFixMe
348
+ ws.onmessage = async function(event /*: {data: string, ...} */ ) {
349
+ var data /*: HMRMessage */ = JSON.parse(event.data);
350
+ await handleMessage(data);
351
+ };
352
+ if (ws instanceof WebSocket) {
353
+ ws.onerror = function(e) {
354
+ if (e.message) console.error(e.message);
355
+ };
356
+ ws.onclose = function() {
357
+ console.warn("[parcel] \uD83D\uDEA8 Connection to the HMR server was lost");
358
+ };
359
+ }
360
+ }
361
+ }
362
+ async function handleMessage(data /*: HMRMessage */ ) {
363
+ checkedAssets = {} /*: {|[string]: boolean|} */ ;
364
+ disposedAssets = {} /*: {|[string]: boolean|} */ ;
365
+ assetsToAccept = [];
366
+ assetsToDispose = [];
367
+ bundleNotFound = false;
368
+ if (data.type === 'reload') fullReload();
369
+ else if (data.type === 'update') {
370
+ // Remove error overlay if there is one
371
+ if (typeof document !== 'undefined') removeErrorOverlay();
372
+ let assets = data.assets;
373
+ // Handle HMR Update
374
+ let handled = assets.every((asset)=>{
375
+ return asset.type === 'css' || asset.type === 'js' && hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle);
376
+ });
377
+ // Dispatch a custom event in case a bundle was not found. This might mean
378
+ // an asset on the server changed and we should reload the page. This event
379
+ // gives the client an opportunity to refresh without losing state
380
+ // (e.g. via React Server Components). If e.preventDefault() is not called,
381
+ // we will trigger a full page reload.
382
+ if (handled && bundleNotFound && assets.some((a)=>a.envHash !== HMR_ENV_HASH) && typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') handled = !window.dispatchEvent(new CustomEvent('parcelhmrreload', {
383
+ cancelable: true
384
+ }));
385
+ if (handled) {
386
+ console.clear();
387
+ // Dispatch custom event so other runtimes (e.g React Refresh) are aware.
388
+ if (typeof window !== 'undefined' && typeof CustomEvent !== 'undefined') window.dispatchEvent(new CustomEvent('parcelhmraccept'));
389
+ await hmrApplyUpdates(assets);
390
+ hmrDisposeQueue();
391
+ // Run accept callbacks. This will also re-execute other disposed assets in topological order.
392
+ let processedAssets = {};
393
+ for(let i = 0; i < assetsToAccept.length; i++){
394
+ let id = assetsToAccept[i][1];
395
+ if (!processedAssets[id]) {
396
+ hmrAccept(assetsToAccept[i][0], id);
397
+ processedAssets[id] = true;
398
+ }
399
+ }
400
+ } else fullReload();
401
+ }
402
+ if (data.type === 'error') {
403
+ // Log parcel errors to console
404
+ for (let ansiDiagnostic of data.diagnostics.ansi){
405
+ let stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack;
406
+ console.error("\uD83D\uDEA8 [parcel]: " + ansiDiagnostic.message + '\n' + stack + '\n\n' + ansiDiagnostic.hints.join('\n'));
407
+ }
408
+ if (typeof document !== 'undefined') {
409
+ // Render the fancy html overlay
410
+ removeErrorOverlay();
411
+ var overlay = createErrorOverlay(data.diagnostics.html);
412
+ // $FlowFixMe
413
+ document.body.appendChild(overlay);
414
+ }
415
+ }
416
+ }
417
+ function removeErrorOverlay() {
418
+ var overlay = document.getElementById(OVERLAY_ID);
419
+ if (overlay) {
420
+ overlay.remove();
421
+ console.log("[parcel] \u2728 Error resolved");
422
+ }
423
+ }
424
+ function createErrorOverlay(diagnostics) {
425
+ var overlay = document.createElement('div');
426
+ overlay.id = OVERLAY_ID;
427
+ let errorHTML = '<div style="background: black; opacity: 0.85; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; font-family: Menlo, Consolas, monospace; z-index: 9999;">';
428
+ for (let diagnostic of diagnostics){
429
+ let stack = diagnostic.frames.length ? diagnostic.frames.reduce((p, frame)=>{
430
+ return `${p}
431
+ <a href="${protocol === 'wss' ? 'https' : 'http'}://${hostname}:${port}/__parcel_launch_editor?file=${encodeURIComponent(frame.location)}" style="text-decoration: underline; color: #888" onclick="fetch(this.href); return false">${frame.location}</a>
432
+ ${frame.code}`;
433
+ }, '') : diagnostic.stack;
434
+ errorHTML += `
435
+ <div>
436
+ <div style="font-size: 18px; font-weight: bold; margin-top: 20px;">
437
+ \u{1F6A8} ${diagnostic.message}
438
+ </div>
439
+ <pre>${stack}</pre>
440
+ <div>
441
+ ${diagnostic.hints.map((hint)=>"<div>\uD83D\uDCA1 " + hint + '</div>').join('')}
442
+ </div>
443
+ ${diagnostic.documentation ? `<div>\u{1F4DD} <a style="color: violet" href="${diagnostic.documentation}" target="_blank">Learn more</a></div>` : ''}
444
+ </div>
445
+ `;
446
+ }
447
+ errorHTML += '</div>';
448
+ overlay.innerHTML = errorHTML;
449
+ return overlay;
450
+ }
451
+ function fullReload() {
452
+ if (typeof location !== 'undefined' && 'reload' in location) location.reload();
453
+ else if (typeof extCtx !== 'undefined' && extCtx && extCtx.runtime && extCtx.runtime.reload) extCtx.runtime.reload();
454
+ else try {
455
+ let { workerData, parentPort } = module.bundle.root('node:worker_threads') /*: any*/ ;
456
+ if (workerData !== null && workerData !== void 0 && workerData.__parcel) parentPort.postMessage('restart');
457
+ } catch (err) {
458
+ console.error("[parcel] \u26A0\uFE0F An HMR update was not accepted. Please restart the process.");
459
+ }
460
+ }
461
+ function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ {
462
+ var modules = bundle.modules;
463
+ if (!modules) return [];
464
+ var parents = [];
465
+ var k, d, dep;
466
+ for(k in modules)for(d in modules[k][1]){
467
+ dep = modules[k][1][d];
468
+ if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) parents.push([
469
+ bundle,
470
+ k
471
+ ]);
472
+ }
473
+ if (bundle.parent) parents = parents.concat(getParents(bundle.parent, id));
474
+ return parents;
475
+ }
476
+ function updateLink(link) {
477
+ var href = link.getAttribute('href');
478
+ if (!href) return;
479
+ var newLink = link.cloneNode();
480
+ newLink.onload = function() {
481
+ if (link.parentNode !== null) // $FlowFixMe
482
+ link.parentNode.removeChild(link);
483
+ };
484
+ newLink.setAttribute('href', // $FlowFixMe
485
+ href.split('?')[0] + '?' + Date.now());
486
+ // $FlowFixMe
487
+ link.parentNode.insertBefore(newLink, link.nextSibling);
488
+ }
489
+ var cssTimeout = null;
490
+ function reloadCSS() {
491
+ if (cssTimeout || typeof document === 'undefined') return;
492
+ cssTimeout = setTimeout(function() {
493
+ var links = document.querySelectorAll('link[rel="stylesheet"]');
494
+ for(var i = 0; i < links.length; i++){
495
+ // $FlowFixMe[incompatible-type]
496
+ var href /*: string */ = links[i].getAttribute('href');
497
+ var hostname = getHostname();
498
+ var servedFromHMRServer = hostname === 'localhost' ? new RegExp('^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):' + getPort()).test(href) : href.indexOf(hostname + ':' + getPort());
499
+ var absolute = /^https?:\/\//i.test(href) && href.indexOf(location.origin) !== 0 && !servedFromHMRServer;
500
+ if (!absolute) updateLink(links[i]);
501
+ }
502
+ cssTimeout = null;
503
+ }, 50);
504
+ }
505
+ function hmrDownload(asset) {
506
+ if (asset.type === 'js') {
507
+ if (typeof document !== 'undefined') {
508
+ let script = document.createElement('script');
509
+ script.src = asset.url + '?t=' + Date.now();
510
+ if (asset.outputFormat === 'esmodule') script.type = 'module';
511
+ return new Promise((resolve, reject)=>{
512
+ var _document$head;
513
+ script.onload = ()=>resolve(script);
514
+ script.onerror = reject;
515
+ (_document$head = document.head) === null || _document$head === void 0 || _document$head.appendChild(script);
516
+ });
517
+ } else if (typeof importScripts === 'function') {
518
+ // Worker scripts
519
+ if (asset.outputFormat === 'esmodule') return import(asset.url + '?t=' + Date.now());
520
+ else return new Promise((resolve, reject)=>{
521
+ try {
522
+ importScripts(asset.url + '?t=' + Date.now());
523
+ resolve();
524
+ } catch (err) {
525
+ reject(err);
526
+ }
527
+ });
528
+ }
529
+ }
530
+ }
531
+ async function hmrApplyUpdates(assets) {
532
+ global.parcelHotUpdate = Object.create(null);
533
+ let scriptsToRemove;
534
+ try {
535
+ // If sourceURL comments aren't supported in eval, we need to load
536
+ // the update from the dev server over HTTP so that stack traces
537
+ // are correct in errors/logs. This is much slower than eval, so
538
+ // we only do it if needed (currently just Safari).
539
+ // https://bugs.webkit.org/show_bug.cgi?id=137297
540
+ // This path is also taken if a CSP disallows eval.
541
+ if (!supportsSourceURL) {
542
+ let promises = assets.map((asset)=>{
543
+ var _hmrDownload;
544
+ return (_hmrDownload = hmrDownload(asset)) === null || _hmrDownload === void 0 ? void 0 : _hmrDownload.catch((err)=>{
545
+ // Web extension fix
546
+ if (extCtx && extCtx.runtime && extCtx.runtime.getManifest().manifest_version == 3 && typeof ServiceWorkerGlobalScope != 'undefined' && global instanceof ServiceWorkerGlobalScope) {
547
+ extCtx.runtime.reload();
548
+ return;
549
+ }
550
+ throw err;
551
+ });
552
+ });
553
+ scriptsToRemove = await Promise.all(promises);
554
+ }
555
+ assets.forEach(function(asset) {
556
+ hmrApply(module.bundle.root, asset);
557
+ });
558
+ } finally{
559
+ delete global.parcelHotUpdate;
560
+ if (scriptsToRemove) scriptsToRemove.forEach((script)=>{
561
+ if (script) {
562
+ var _document$head2;
563
+ (_document$head2 = document.head) === null || _document$head2 === void 0 || _document$head2.removeChild(script);
564
+ }
565
+ });
566
+ }
567
+ }
568
+ function hmrApply(bundle /*: ParcelRequire */ , asset /*: HMRAsset */ ) {
569
+ var modules = bundle.modules;
570
+ if (!modules) return;
571
+ if (asset.type === 'css') reloadCSS();
572
+ else if (asset.type === 'js') {
573
+ let deps = asset.depsByBundle[bundle.HMR_BUNDLE_ID];
574
+ if (deps) {
575
+ if (modules[asset.id]) {
576
+ // Remove dependencies that are removed and will become orphaned.
577
+ // This is necessary so that if the asset is added back again, the cache is gone, and we prevent a full page reload.
578
+ let oldDeps = modules[asset.id][1];
579
+ for(let dep in oldDeps)if (!deps[dep] || deps[dep] !== oldDeps[dep]) {
580
+ let id = oldDeps[dep];
581
+ let parents = getParents(module.bundle.root, id);
582
+ if (parents.length === 1) hmrDelete(module.bundle.root, id);
583
+ }
584
+ }
585
+ if (supportsSourceURL) // Global eval. We would use `new Function` here but browser
586
+ // support for source maps is better with eval.
587
+ (0, eval)(asset.output);
588
+ // $FlowFixMe
589
+ let fn = global.parcelHotUpdate[asset.id];
590
+ modules[asset.id] = [
591
+ fn,
592
+ deps
593
+ ];
594
+ }
595
+ // Always traverse to the parent bundle, even if we already replaced the asset in this bundle.
596
+ // This is required in case modules are duplicated. We need to ensure all instances have the updated code.
597
+ if (bundle.parent) hmrApply(bundle.parent, asset);
598
+ }
599
+ }
600
+ function hmrDelete(bundle, id) {
601
+ let modules = bundle.modules;
602
+ if (!modules) return;
603
+ if (modules[id]) {
604
+ // Collect dependencies that will become orphaned when this module is deleted.
605
+ let deps = modules[id][1];
606
+ let orphans = [];
607
+ for(let dep in deps){
608
+ let parents = getParents(module.bundle.root, deps[dep]);
609
+ if (parents.length === 1) orphans.push(deps[dep]);
610
+ }
611
+ // Delete the module. This must be done before deleting dependencies in case of circular dependencies.
612
+ delete modules[id];
613
+ delete bundle.cache[id];
614
+ // Now delete the orphans.
615
+ orphans.forEach((id)=>{
616
+ hmrDelete(module.bundle.root, id);
617
+ });
618
+ } else if (bundle.parent) hmrDelete(bundle.parent, id);
619
+ }
620
+ function hmrAcceptCheck(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) {
621
+ checkedAssets = {};
622
+ if (hmrAcceptCheckOne(bundle, id, depsByBundle)) return true;
623
+ // Traverse parents breadth first. All possible ancestries must accept the HMR update, or we'll reload.
624
+ let parents = getParents(module.bundle.root, id);
625
+ let accepted = false;
626
+ while(parents.length > 0){
627
+ let v = parents.shift();
628
+ let a = hmrAcceptCheckOne(v[0], v[1], null);
629
+ if (a) // If this parent accepts, stop traversing upward, but still consider siblings.
630
+ accepted = true;
631
+ else if (a !== null) {
632
+ // Otherwise, queue the parents in the next level upward.
633
+ let p = getParents(module.bundle.root, v[1]);
634
+ if (p.length === 0) {
635
+ // If there are no parents, then we've reached an entry without accepting. Reload.
636
+ accepted = false;
637
+ break;
638
+ }
639
+ parents.push(...p);
640
+ }
641
+ }
642
+ return accepted;
643
+ }
644
+ function hmrAcceptCheckOne(bundle /*: ParcelRequire */ , id /*: string */ , depsByBundle /*: ?{ [string]: { [string]: string } }*/ ) {
645
+ var modules = bundle.modules;
646
+ if (!modules) return;
647
+ if (depsByBundle && !depsByBundle[bundle.HMR_BUNDLE_ID]) {
648
+ // If we reached the root bundle without finding where the asset should go,
649
+ // there's nothing to do. Mark as "accepted" so we don't reload the page.
650
+ if (!bundle.parent) {
651
+ bundleNotFound = true;
652
+ return true;
653
+ }
654
+ return hmrAcceptCheckOne(bundle.parent, id, depsByBundle);
655
+ }
656
+ if (checkedAssets[id]) return null;
657
+ checkedAssets[id] = true;
658
+ var cached = bundle.cache[id];
659
+ if (!cached) return true;
660
+ assetsToDispose.push([
661
+ bundle,
662
+ id
663
+ ]);
664
+ if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
665
+ assetsToAccept.push([
666
+ bundle,
667
+ id
668
+ ]);
669
+ return true;
670
+ }
671
+ return false;
672
+ }
673
+ function hmrDisposeQueue() {
674
+ // Dispose all old assets.
675
+ for(let i = 0; i < assetsToDispose.length; i++){
676
+ let id = assetsToDispose[i][1];
677
+ if (!disposedAssets[id]) {
678
+ hmrDispose(assetsToDispose[i][0], id);
679
+ disposedAssets[id] = true;
680
+ }
681
+ }
682
+ assetsToDispose = [];
683
+ }
684
+ function hmrDispose(bundle /*: ParcelRequire */ , id /*: string */ ) {
685
+ var cached = bundle.cache[id];
686
+ bundle.hotData[id] = {};
687
+ if (cached && cached.hot) cached.hot.data = bundle.hotData[id];
688
+ if (cached && cached.hot && cached.hot._disposeCallbacks.length) cached.hot._disposeCallbacks.forEach(function(cb) {
689
+ cb(bundle.hotData[id]);
690
+ });
691
+ delete bundle.cache[id];
692
+ }
693
+ function hmrAccept(bundle /*: ParcelRequire */ , id /*: string */ ) {
694
+ // Execute the module.
695
+ bundle(id);
696
+ // Run the accept callbacks in the new version of the module.
697
+ var cached = bundle.cache[id];
698
+ if (cached && cached.hot && cached.hot._acceptCallbacks.length) {
699
+ let assetsToAlsoAccept = [];
700
+ cached.hot._acceptCallbacks.forEach(function(cb) {
701
+ let additionalAssets = cb(function() {
702
+ return getParents(module.bundle.root, id);
703
+ });
704
+ if (Array.isArray(additionalAssets) && additionalAssets.length) assetsToAlsoAccept.push(...additionalAssets);
705
+ });
706
+ if (assetsToAlsoAccept.length) {
707
+ let handled = assetsToAlsoAccept.every(function(a) {
708
+ return hmrAcceptCheck(a[0], a[1]);
709
+ });
710
+ if (!handled) return fullReload();
711
+ hmrDisposeQueue();
712
+ }
713
+ }
714
+ }
715
+
716
+ },{}],"go6VO":[function(require,module,exports,__globalThis) {
717
+ var $parcel$ReactRefreshHelpers$2591 = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
718
+ $parcel$ReactRefreshHelpers$2591.init();
719
+ var prevRefreshReg = globalThis.$RefreshReg$;
720
+ var prevRefreshSig = globalThis.$RefreshSig$;
721
+ $parcel$ReactRefreshHelpers$2591.prelude(module);
722
+
723
+ try {
724
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
725
+ parcelHelpers.defineInteropFlag(exports);
726
+ /** Wraps layout content with Modal, Drawer and Sonner providers.
727
+ * Note: DialogProvider is now at the app level in app.tsx */ parcelHelpers.export(exports, "LayoutProviders", ()=>LayoutProviders);
728
+ var _jsxRuntime = require("react/jsx-runtime");
729
+ var _modalContext = require("../modal/ModalContext");
730
+ var _drawerContext = require("../drawer/DrawerContext");
731
+ var _sonnerContext = require("../sonner/SonnerContext");
732
+ function LayoutProviders({ children }) {
733
+ return (0, _jsxRuntime.jsx)((0, _modalContext.ModalProvider), {
734
+ children: (0, _jsxRuntime.jsx)((0, _drawerContext.DrawerProvider), {
735
+ children: (0, _jsxRuntime.jsx)((0, _sonnerContext.SonnerProvider), {
736
+ children: children
737
+ })
738
+ })
739
+ });
740
+ }
741
+ _c = LayoutProviders;
742
+ var _c;
743
+ $RefreshReg$(_c, "LayoutProviders");
744
+
745
+ $parcel$ReactRefreshHelpers$2591.postlude(module);
746
+ } finally {
747
+ globalThis.$RefreshReg$ = prevRefreshReg;
748
+ globalThis.$RefreshSig$ = prevRefreshSig;
749
+ }
750
+ },{"react/jsx-runtime":"05iiF","../modal/ModalContext":"3yXXZ","../drawer/DrawerContext":"7mOI7","../sonner/SonnerContext":"jskfT","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"3yXXZ":[function(require,module,exports,__globalThis) {
751
+ var $parcel$ReactRefreshHelpers$197e = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
752
+ $parcel$ReactRefreshHelpers$197e.init();
753
+ var prevRefreshReg = globalThis.$RefreshReg$;
754
+ var prevRefreshSig = globalThis.$RefreshSig$;
755
+ $parcel$ReactRefreshHelpers$197e.prelude(module);
756
+
757
+ try {
758
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
759
+ parcelHelpers.defineInteropFlag(exports);
760
+ parcelHelpers.export(exports, "validateAndNormalizeUrl", ()=>validateAndNormalizeUrl);
761
+ parcelHelpers.export(exports, "useModal", ()=>useModal);
762
+ parcelHelpers.export(exports, "ModalProvider", ()=>ModalProvider);
763
+ var _jsxRuntime = require("react/jsx-runtime");
764
+ var _sdk = require("@shellui/sdk");
765
+ var _react = require("react");
766
+ var _s = $RefreshSig$(), _s1 = $RefreshSig$();
767
+ const validateAndNormalizeUrl = (url)=>{
768
+ if (!url || typeof url !== 'string') return null;
769
+ try {
770
+ // If it's already an absolute URL, check if it's same origin or localhost
771
+ if (url.startsWith('http://') || url.startsWith('https://')) {
772
+ const urlObj = new URL(url);
773
+ const currentOrigin = typeof window !== 'undefined' ? window.location.origin : '';
774
+ // Allow same origin
775
+ if (urlObj.origin === currentOrigin) return url;
776
+ // Allow localhost URLs (for development)
777
+ if (urlObj.hostname === 'localhost' || urlObj.hostname === '127.0.0.1') return url;
778
+ return null; // Different origin, reject for security
779
+ }
780
+ // If it's a relative URL, make it absolute using current origin
781
+ if (url.startsWith('/') || url.startsWith('./') || !url.startsWith('//')) {
782
+ const currentOrigin = typeof window !== 'undefined' ? window.location.origin : '';
783
+ // Ensure relative paths start with /
784
+ const normalizedPath = url.startsWith('/') ? url : `/${url}`;
785
+ return `${currentOrigin}${normalizedPath}`;
786
+ }
787
+ // Reject protocol-relative URLs (//example.com) for security
788
+ return null;
789
+ } catch (error) {
790
+ // eslint-disable-next-line no-console
791
+ console.error('Invalid URL:', url, error);
792
+ return null;
793
+ }
794
+ };
795
+ const ModalContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
796
+ const useModal = ()=>{
797
+ _s();
798
+ const context = (0, _react.useContext)(ModalContext);
799
+ if (!context) throw new Error('useModal must be used within a ModalProvider');
800
+ return context;
801
+ };
802
+ _s(useModal, "b9L3QQ+jgeyIrH0NfHrJ8nn7VMU=");
803
+ const ModalProvider = ({ children })=>{
804
+ _s1();
805
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
806
+ const [modalUrl, setModalUrl] = (0, _react.useState)(null);
807
+ const openModal = (0, _react.useCallback)((url)=>{
808
+ const validatedUrl = url ? validateAndNormalizeUrl(url) : null;
809
+ setModalUrl(validatedUrl);
810
+ setIsOpen(true);
811
+ }, []);
812
+ const closeModal = (0, _react.useCallback)(()=>{
813
+ setIsOpen(false);
814
+ // Clear URL after a short delay to allow animation to complete
815
+ setTimeout(()=>setModalUrl(null), 200);
816
+ }, []);
817
+ // Listen for postMessage events from nested iframes
818
+ (0, _react.useEffect)(()=>{
819
+ const cleanupOpenModal = (0, _sdk.shellui).addMessageListener('SHELLUI_OPEN_MODAL', (data)=>{
820
+ const payload = data.payload;
821
+ openModal(payload.url);
822
+ });
823
+ const cleanupCloseModal = (0, _sdk.shellui).addMessageListener('SHELLUI_CLOSE_MODAL', ()=>{
824
+ closeModal();
825
+ });
826
+ return ()=>{
827
+ cleanupOpenModal();
828
+ cleanupCloseModal();
829
+ };
830
+ }, [
831
+ openModal,
832
+ closeModal
833
+ ]);
834
+ return (0, _jsxRuntime.jsx)(ModalContext.Provider, {
835
+ value: {
836
+ isOpen,
837
+ modalUrl,
838
+ openModal,
839
+ closeModal
840
+ },
841
+ children: children
842
+ });
843
+ };
844
+ _s1(ModalProvider, "iFTcdmeBOCDabLoQi6fdUSQwzBU=");
845
+ _c = ModalProvider;
846
+ var _c;
847
+ $RefreshReg$(_c, "ModalProvider");
848
+
849
+ $parcel$ReactRefreshHelpers$197e.postlude(module);
850
+ } finally {
851
+ globalThis.$RefreshReg$ = prevRefreshReg;
852
+ globalThis.$RefreshSig$ = prevRefreshSig;
853
+ }
854
+ },{"react/jsx-runtime":"05iiF","@shellui/sdk":"dS2fb","react":"jMk1U","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"7mOI7":[function(require,module,exports,__globalThis) {
855
+ var $parcel$ReactRefreshHelpers$1530 = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
856
+ $parcel$ReactRefreshHelpers$1530.init();
857
+ var prevRefreshReg = globalThis.$RefreshReg$;
858
+ var prevRefreshSig = globalThis.$RefreshSig$;
859
+ $parcel$ReactRefreshHelpers$1530.prelude(module);
860
+
861
+ try {
862
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
863
+ parcelHelpers.defineInteropFlag(exports);
864
+ parcelHelpers.export(exports, "DEFAULT_DRAWER_POSITION", ()=>DEFAULT_DRAWER_POSITION);
865
+ parcelHelpers.export(exports, "useDrawer", ()=>useDrawer);
866
+ parcelHelpers.export(exports, "DrawerProvider", ()=>DrawerProvider);
867
+ var _jsxRuntime = require("react/jsx-runtime");
868
+ var _sdk = require("@shellui/sdk");
869
+ var _react = require("react");
870
+ var _modalContext = require("../modal/ModalContext");
871
+ var _s = $RefreshSig$(), _s1 = $RefreshSig$();
872
+ /**
873
+ * Validates and normalizes a URL for the drawer iframe.
874
+ * Allows same-origin, localhost, and external http(s) URLs (e.g. from nav config).
875
+ */ const validateAndNormalizeUrl = (url)=>{
876
+ if (!url || typeof url !== 'string') return null;
877
+ try {
878
+ if (url.startsWith('http://') || url.startsWith('https://')) {
879
+ new URL(url); // validate
880
+ return url;
881
+ }
882
+ if (url.startsWith('/') || url.startsWith('./') || !url.startsWith('//')) {
883
+ const currentOrigin = typeof window !== 'undefined' ? window.location.origin : '';
884
+ const normalizedPath = url.startsWith('/') ? url : `/${url}`;
885
+ return `${currentOrigin}${normalizedPath}`;
886
+ }
887
+ return null;
888
+ } catch {
889
+ return null;
890
+ }
891
+ };
892
+ const DEFAULT_DRAWER_POSITION = 'right';
893
+ const DrawerContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
894
+ const useDrawer = ()=>{
895
+ _s();
896
+ const context = (0, _react.useContext)(DrawerContext);
897
+ if (!context) throw new Error('useDrawer must be used within a DrawerProvider');
898
+ return context;
899
+ };
900
+ _s(useDrawer, "b9L3QQ+jgeyIrH0NfHrJ8nn7VMU=");
901
+ const DrawerProvider = ({ children })=>{
902
+ _s1();
903
+ const { closeModal } = (0, _modalContext.useModal)();
904
+ const [isOpen, setIsOpen] = (0, _react.useState)(false);
905
+ const [drawerUrl, setDrawerUrl] = (0, _react.useState)(null);
906
+ const [position, setPosition] = (0, _react.useState)(DEFAULT_DRAWER_POSITION);
907
+ const [size, setSize] = (0, _react.useState)(null);
908
+ const openDrawer = (0, _react.useCallback)((options)=>{
909
+ closeModal();
910
+ const url = options?.url;
911
+ const validatedUrl = url ? validateAndNormalizeUrl(url) : null;
912
+ setDrawerUrl(validatedUrl);
913
+ setPosition(options?.position ?? DEFAULT_DRAWER_POSITION);
914
+ setSize(options?.size ?? null);
915
+ setIsOpen(true);
916
+ }, [
917
+ closeModal
918
+ ]);
919
+ const closeDrawer = (0, _react.useCallback)(()=>{
920
+ setIsOpen(false);
921
+ // Do not reset drawerUrl/position here — Vaul's close animation uses the current
922
+ // direction. Resetting position (e.g. to 'right') mid-animation would make
923
+ // non-right drawers jump. State is set on next openDrawer().
924
+ }, []);
925
+ (0, _react.useEffect)(()=>{
926
+ const cleanupOpen = (0, _sdk.shellui).addMessageListener('SHELLUI_OPEN_DRAWER', (data)=>{
927
+ const payload = data.payload;
928
+ openDrawer({
929
+ url: payload.url,
930
+ position: payload.position,
931
+ size: payload.size
932
+ });
933
+ });
934
+ const cleanupClose = (0, _sdk.shellui).addMessageListener('SHELLUI_CLOSE_DRAWER', ()=>{
935
+ closeDrawer();
936
+ });
937
+ return ()=>{
938
+ cleanupOpen();
939
+ cleanupClose();
940
+ };
941
+ }, [
942
+ openDrawer,
943
+ closeDrawer
944
+ ]);
945
+ return (0, _jsxRuntime.jsx)(DrawerContext.Provider, {
946
+ value: {
947
+ isOpen,
948
+ drawerUrl,
949
+ position,
950
+ size,
951
+ openDrawer,
952
+ closeDrawer
953
+ },
954
+ children: children
955
+ });
956
+ };
957
+ _s1(DrawerProvider, "+OfsKjKZAXrYNPfgZi5T4AIM790=", false, function() {
958
+ return [
959
+ (0, _modalContext.useModal)
960
+ ];
961
+ });
962
+ _c = DrawerProvider;
963
+ var _c;
964
+ $RefreshReg$(_c, "DrawerProvider");
965
+
966
+ $parcel$ReactRefreshHelpers$1530.postlude(module);
967
+ } finally {
968
+ globalThis.$RefreshReg$ = prevRefreshReg;
969
+ globalThis.$RefreshSig$ = prevRefreshSig;
970
+ }
971
+ },{"react/jsx-runtime":"05iiF","@shellui/sdk":"dS2fb","react":"jMk1U","../modal/ModalContext":"3yXXZ","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"jskfT":[function(require,module,exports,__globalThis) {
972
+ var $parcel$ReactRefreshHelpers$53a3 = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
973
+ $parcel$ReactRefreshHelpers$53a3.init();
974
+ var prevRefreshReg = globalThis.$RefreshReg$;
975
+ var prevRefreshSig = globalThis.$RefreshSig$;
976
+ $parcel$ReactRefreshHelpers$53a3.prelude(module);
977
+
978
+ try {
979
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
980
+ parcelHelpers.defineInteropFlag(exports);
981
+ parcelHelpers.export(exports, "useSonner", ()=>useSonner);
982
+ parcelHelpers.export(exports, "SonnerProvider", ()=>SonnerProvider);
983
+ var _jsxRuntime = require("react/jsx-runtime");
984
+ var _sdk = require("@shellui/sdk");
985
+ var _react = require("react");
986
+ var _sonner = require("sonner");
987
+ var _s = $RefreshSig$(), _s1 = $RefreshSig$();
988
+ const SonnerContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
989
+ function useSonner() {
990
+ _s();
991
+ const context = (0, _react.useContext)(SonnerContext);
992
+ if (!context) throw new Error('useSonner must be used within a SonnerProvider');
993
+ return context;
994
+ }
995
+ _s(useSonner, "b9L3QQ+jgeyIrH0NfHrJ8nn7VMU=");
996
+ const SonnerProvider = ({ children })=>{
997
+ _s1();
998
+ const toast = (0, _react.useCallback)((options)=>{
999
+ const { id, title, description, type = 'default', duration, position, action, cancel, onDismiss, onAutoClose } = options;
1000
+ const toastOptions = {
1001
+ id,
1002
+ duration,
1003
+ position,
1004
+ action: action ? {
1005
+ label: action.label,
1006
+ onClick: action.onClick
1007
+ } : undefined,
1008
+ cancel: cancel ? {
1009
+ label: cancel.label,
1010
+ onClick: cancel.onClick
1011
+ } : undefined,
1012
+ onDismiss: onDismiss,
1013
+ onAutoClose: onAutoClose
1014
+ };
1015
+ // If ID is provided, this is an update operation
1016
+ if (id) {
1017
+ switch(type){
1018
+ case 'success':
1019
+ (0, _sonner.toast).success(title || 'Success', {
1020
+ id,
1021
+ description,
1022
+ ...toastOptions
1023
+ });
1024
+ break;
1025
+ case 'error':
1026
+ (0, _sonner.toast).error(title || 'Error', {
1027
+ id,
1028
+ description,
1029
+ ...toastOptions
1030
+ });
1031
+ break;
1032
+ case 'warning':
1033
+ (0, _sonner.toast).warning(title || 'Warning', {
1034
+ id,
1035
+ description,
1036
+ ...toastOptions
1037
+ });
1038
+ break;
1039
+ case 'info':
1040
+ (0, _sonner.toast).info(title || 'Info', {
1041
+ id,
1042
+ description,
1043
+ ...toastOptions
1044
+ });
1045
+ break;
1046
+ case 'loading':
1047
+ (0, _sonner.toast).loading(title || 'Loading...', {
1048
+ id,
1049
+ description,
1050
+ ...toastOptions
1051
+ });
1052
+ break;
1053
+ default:
1054
+ (0, _sonner.toast)(title || 'Notification', {
1055
+ id,
1056
+ description,
1057
+ ...toastOptions
1058
+ });
1059
+ break;
1060
+ }
1061
+ return;
1062
+ }
1063
+ // Create new toast
1064
+ switch(type){
1065
+ case 'success':
1066
+ (0, _sonner.toast).success(title || 'Success', {
1067
+ description,
1068
+ ...toastOptions
1069
+ });
1070
+ break;
1071
+ case 'error':
1072
+ (0, _sonner.toast).error(title || 'Error', {
1073
+ description,
1074
+ ...toastOptions
1075
+ });
1076
+ break;
1077
+ case 'warning':
1078
+ (0, _sonner.toast).warning(title || 'Warning', {
1079
+ description,
1080
+ ...toastOptions
1081
+ });
1082
+ break;
1083
+ case 'info':
1084
+ (0, _sonner.toast).info(title || 'Info', {
1085
+ description,
1086
+ ...toastOptions
1087
+ });
1088
+ break;
1089
+ case 'loading':
1090
+ (0, _sonner.toast).loading(title || 'Loading...', {
1091
+ description,
1092
+ ...toastOptions
1093
+ });
1094
+ break;
1095
+ default:
1096
+ (0, _sonner.toast)(title || 'Notification', {
1097
+ description,
1098
+ ...toastOptions
1099
+ });
1100
+ break;
1101
+ }
1102
+ }, []);
1103
+ // Listen for postMessage events from nested iframes
1104
+ (0, _react.useEffect)(()=>{
1105
+ const cleanupToast = (0, _sdk.shellui).addMessageListener('SHELLUI_TOAST', (data)=>{
1106
+ const payload = data.payload;
1107
+ toast({
1108
+ ...payload,
1109
+ onDismiss: ()=>{
1110
+ (0, _sdk.shellui).sendMessage({
1111
+ type: 'SHELLUI_TOAST_CLEAR',
1112
+ payload: {
1113
+ id: payload.id
1114
+ },
1115
+ to: data.from
1116
+ });
1117
+ },
1118
+ onAutoClose: ()=>{
1119
+ (0, _sdk.shellui).sendMessage({
1120
+ type: 'SHELLUI_TOAST_CLEAR',
1121
+ payload: {
1122
+ id: payload.id
1123
+ },
1124
+ to: data.from
1125
+ });
1126
+ },
1127
+ action: payload.action && (()=>{
1128
+ let actionSent = false;
1129
+ return {
1130
+ label: payload.action?.label ?? undefined,
1131
+ onClick: ()=>{
1132
+ if (actionSent) return;
1133
+ actionSent = true;
1134
+ (0, _sdk.shellui).sendMessage({
1135
+ type: 'SHELLUI_TOAST_ACTION',
1136
+ payload: {
1137
+ id: payload.id
1138
+ },
1139
+ to: data.from
1140
+ });
1141
+ }
1142
+ };
1143
+ })(),
1144
+ cancel: payload.cancel && (()=>{
1145
+ let cancelSent = false;
1146
+ return {
1147
+ label: payload.cancel?.label ?? undefined,
1148
+ onClick: ()=>{
1149
+ if (cancelSent) return;
1150
+ cancelSent = true;
1151
+ (0, _sdk.shellui).sendMessage({
1152
+ type: 'SHELLUI_TOAST_CANCEL',
1153
+ payload: {
1154
+ id: payload.id
1155
+ },
1156
+ to: data.from
1157
+ });
1158
+ }
1159
+ };
1160
+ })()
1161
+ });
1162
+ });
1163
+ const cleanupToastUpdate = (0, _sdk.shellui).addMessageListener('SHELLUI_TOAST_UPDATE', (data)=>{
1164
+ const payload = data.payload;
1165
+ // CRITICAL: When updating a toast, we MUST re-register action handlers
1166
+ // The callbackRegistry still has the callbacks, but the toast button needs onClick handlers
1167
+ // that trigger the callbackRegistry via SHELLUI_TOAST_ACTION messages
1168
+ toast({
1169
+ ...payload,
1170
+ // Re-register action handlers so the button works after update
1171
+ // These handlers send messages that trigger the callbackRegistry
1172
+ action: payload.action && (()=>{
1173
+ let actionSent = false;
1174
+ return {
1175
+ label: payload.action?.label ?? undefined,
1176
+ onClick: ()=>{
1177
+ if (actionSent) return;
1178
+ actionSent = true;
1179
+ (0, _sdk.shellui).sendMessage({
1180
+ type: 'SHELLUI_TOAST_ACTION',
1181
+ payload: {
1182
+ id: payload.id
1183
+ },
1184
+ to: data.from
1185
+ });
1186
+ }
1187
+ };
1188
+ })(),
1189
+ cancel: payload.cancel && (()=>{
1190
+ let cancelSent = false;
1191
+ return {
1192
+ label: payload.cancel?.label ?? undefined,
1193
+ onClick: ()=>{
1194
+ if (cancelSent) return;
1195
+ cancelSent = true;
1196
+ (0, _sdk.shellui).sendMessage({
1197
+ type: 'SHELLUI_TOAST_CANCEL',
1198
+ payload: {
1199
+ id: payload.id
1200
+ },
1201
+ to: data.from
1202
+ });
1203
+ }
1204
+ };
1205
+ })()
1206
+ });
1207
+ });
1208
+ return ()=>{
1209
+ cleanupToast();
1210
+ cleanupToastUpdate();
1211
+ };
1212
+ }, [
1213
+ toast
1214
+ ]);
1215
+ return (0, _jsxRuntime.jsx)(SonnerContext.Provider, {
1216
+ value: {
1217
+ toast
1218
+ },
1219
+ children: children
1220
+ });
1221
+ };
1222
+ _s1(SonnerProvider, "ZVjub9HLFiQySUX6LxkDJI5pS/k=");
1223
+ _c = SonnerProvider;
1224
+ var _c;
1225
+ $RefreshReg$(_c, "SonnerProvider");
1226
+
1227
+ $parcel$ReactRefreshHelpers$53a3.postlude(module);
1228
+ } finally {
1229
+ globalThis.$RefreshReg$ = prevRefreshReg;
1230
+ globalThis.$RefreshSig$ = prevRefreshSig;
1231
+ }
1232
+ },{"react/jsx-runtime":"05iiF","@shellui/sdk":"dS2fb","react":"jMk1U","sonner":"kK7Kb","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"kK7Kb":[function(require,module,exports,__globalThis) {
1233
+ 'use client';
1234
+ function __insertCSS(code) {
1235
+ if (!code || typeof document == 'undefined') return;
1236
+ let head = document.head || document.getElementsByTagName('head')[0];
1237
+ let style = document.createElement('style');
1238
+ style.type = 'text/css';
1239
+ head.appendChild(style);
1240
+ style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
1241
+ }
1242
+ Object.defineProperty(exports, '__esModule', {
1243
+ value: true
1244
+ });
1245
+ var React = require("3f174e72235a2879");
1246
+ var ReactDOM = require("8b51ad213197056a");
1247
+ function _interopDefault(e) {
1248
+ return e && e.__esModule ? e : {
1249
+ default: e
1250
+ };
1251
+ }
1252
+ var React__default = /*#__PURE__*/ _interopDefault(React);
1253
+ var ReactDOM__default = /*#__PURE__*/ _interopDefault(ReactDOM);
1254
+ const getAsset = (type)=>{
1255
+ switch(type){
1256
+ case 'success':
1257
+ return SuccessIcon;
1258
+ case 'info':
1259
+ return InfoIcon;
1260
+ case 'warning':
1261
+ return WarningIcon;
1262
+ case 'error':
1263
+ return ErrorIcon;
1264
+ default:
1265
+ return null;
1266
+ }
1267
+ };
1268
+ const bars = Array(12).fill(0);
1269
+ const Loader = ({ visible, className })=>{
1270
+ return /*#__PURE__*/ React__default.default.createElement("div", {
1271
+ className: [
1272
+ 'sonner-loading-wrapper',
1273
+ className
1274
+ ].filter(Boolean).join(' '),
1275
+ "data-visible": visible
1276
+ }, /*#__PURE__*/ React__default.default.createElement("div", {
1277
+ className: "sonner-spinner"
1278
+ }, bars.map((_, i)=>/*#__PURE__*/ React__default.default.createElement("div", {
1279
+ className: "sonner-loading-bar",
1280
+ key: `spinner-bar-${i}`
1281
+ }))));
1282
+ };
1283
+ const SuccessIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
1284
+ xmlns: "http://www.w3.org/2000/svg",
1285
+ viewBox: "0 0 20 20",
1286
+ fill: "currentColor",
1287
+ height: "20",
1288
+ width: "20"
1289
+ }, /*#__PURE__*/ React__default.default.createElement("path", {
1290
+ fillRule: "evenodd",
1291
+ d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
1292
+ clipRule: "evenodd"
1293
+ }));
1294
+ const WarningIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
1295
+ xmlns: "http://www.w3.org/2000/svg",
1296
+ viewBox: "0 0 24 24",
1297
+ fill: "currentColor",
1298
+ height: "20",
1299
+ width: "20"
1300
+ }, /*#__PURE__*/ React__default.default.createElement("path", {
1301
+ fillRule: "evenodd",
1302
+ d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
1303
+ clipRule: "evenodd"
1304
+ }));
1305
+ const InfoIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
1306
+ xmlns: "http://www.w3.org/2000/svg",
1307
+ viewBox: "0 0 20 20",
1308
+ fill: "currentColor",
1309
+ height: "20",
1310
+ width: "20"
1311
+ }, /*#__PURE__*/ React__default.default.createElement("path", {
1312
+ fillRule: "evenodd",
1313
+ d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
1314
+ clipRule: "evenodd"
1315
+ }));
1316
+ const ErrorIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
1317
+ xmlns: "http://www.w3.org/2000/svg",
1318
+ viewBox: "0 0 20 20",
1319
+ fill: "currentColor",
1320
+ height: "20",
1321
+ width: "20"
1322
+ }, /*#__PURE__*/ React__default.default.createElement("path", {
1323
+ fillRule: "evenodd",
1324
+ d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
1325
+ clipRule: "evenodd"
1326
+ }));
1327
+ const CloseIcon = /*#__PURE__*/ React__default.default.createElement("svg", {
1328
+ xmlns: "http://www.w3.org/2000/svg",
1329
+ width: "12",
1330
+ height: "12",
1331
+ viewBox: "0 0 24 24",
1332
+ fill: "none",
1333
+ stroke: "currentColor",
1334
+ strokeWidth: "1.5",
1335
+ strokeLinecap: "round",
1336
+ strokeLinejoin: "round"
1337
+ }, /*#__PURE__*/ React__default.default.createElement("line", {
1338
+ x1: "18",
1339
+ y1: "6",
1340
+ x2: "6",
1341
+ y2: "18"
1342
+ }), /*#__PURE__*/ React__default.default.createElement("line", {
1343
+ x1: "6",
1344
+ y1: "6",
1345
+ x2: "18",
1346
+ y2: "18"
1347
+ }));
1348
+ const useIsDocumentHidden = ()=>{
1349
+ const [isDocumentHidden, setIsDocumentHidden] = React__default.default.useState(document.hidden);
1350
+ React__default.default.useEffect(()=>{
1351
+ const callback = ()=>{
1352
+ setIsDocumentHidden(document.hidden);
1353
+ };
1354
+ document.addEventListener('visibilitychange', callback);
1355
+ return ()=>window.removeEventListener('visibilitychange', callback);
1356
+ }, []);
1357
+ return isDocumentHidden;
1358
+ };
1359
+ let toastsCounter = 1;
1360
+ class Observer {
1361
+ constructor(){
1362
+ // We use arrow functions to maintain the correct `this` reference
1363
+ this.subscribe = (subscriber)=>{
1364
+ this.subscribers.push(subscriber);
1365
+ return ()=>{
1366
+ const index = this.subscribers.indexOf(subscriber);
1367
+ this.subscribers.splice(index, 1);
1368
+ };
1369
+ };
1370
+ this.publish = (data)=>{
1371
+ this.subscribers.forEach((subscriber)=>subscriber(data));
1372
+ };
1373
+ this.addToast = (data)=>{
1374
+ this.publish(data);
1375
+ this.toasts = [
1376
+ ...this.toasts,
1377
+ data
1378
+ ];
1379
+ };
1380
+ this.create = (data)=>{
1381
+ var _data_id;
1382
+ const { message, ...rest } = data;
1383
+ const id = typeof (data == null ? void 0 : data.id) === 'number' || ((_data_id = data.id) == null ? void 0 : _data_id.length) > 0 ? data.id : toastsCounter++;
1384
+ const alreadyExists = this.toasts.find((toast)=>{
1385
+ return toast.id === id;
1386
+ });
1387
+ const dismissible = data.dismissible === undefined ? true : data.dismissible;
1388
+ if (this.dismissedToasts.has(id)) this.dismissedToasts.delete(id);
1389
+ if (alreadyExists) this.toasts = this.toasts.map((toast)=>{
1390
+ if (toast.id === id) {
1391
+ this.publish({
1392
+ ...toast,
1393
+ ...data,
1394
+ id,
1395
+ title: message
1396
+ });
1397
+ return {
1398
+ ...toast,
1399
+ ...data,
1400
+ id,
1401
+ dismissible,
1402
+ title: message
1403
+ };
1404
+ }
1405
+ return toast;
1406
+ });
1407
+ else this.addToast({
1408
+ title: message,
1409
+ ...rest,
1410
+ dismissible,
1411
+ id
1412
+ });
1413
+ return id;
1414
+ };
1415
+ this.dismiss = (id)=>{
1416
+ if (id) {
1417
+ this.dismissedToasts.add(id);
1418
+ requestAnimationFrame(()=>this.subscribers.forEach((subscriber)=>subscriber({
1419
+ id,
1420
+ dismiss: true
1421
+ })));
1422
+ } else this.toasts.forEach((toast)=>{
1423
+ this.subscribers.forEach((subscriber)=>subscriber({
1424
+ id: toast.id,
1425
+ dismiss: true
1426
+ }));
1427
+ });
1428
+ return id;
1429
+ };
1430
+ this.message = (message, data)=>{
1431
+ return this.create({
1432
+ ...data,
1433
+ message
1434
+ });
1435
+ };
1436
+ this.error = (message, data)=>{
1437
+ return this.create({
1438
+ ...data,
1439
+ message,
1440
+ type: 'error'
1441
+ });
1442
+ };
1443
+ this.success = (message, data)=>{
1444
+ return this.create({
1445
+ ...data,
1446
+ type: 'success',
1447
+ message
1448
+ });
1449
+ };
1450
+ this.info = (message, data)=>{
1451
+ return this.create({
1452
+ ...data,
1453
+ type: 'info',
1454
+ message
1455
+ });
1456
+ };
1457
+ this.warning = (message, data)=>{
1458
+ return this.create({
1459
+ ...data,
1460
+ type: 'warning',
1461
+ message
1462
+ });
1463
+ };
1464
+ this.loading = (message, data)=>{
1465
+ return this.create({
1466
+ ...data,
1467
+ type: 'loading',
1468
+ message
1469
+ });
1470
+ };
1471
+ this.promise = (promise, data)=>{
1472
+ if (!data) // Nothing to show
1473
+ return;
1474
+ let id = undefined;
1475
+ if (data.loading !== undefined) id = this.create({
1476
+ ...data,
1477
+ promise,
1478
+ type: 'loading',
1479
+ message: data.loading,
1480
+ description: typeof data.description !== 'function' ? data.description : undefined
1481
+ });
1482
+ const p = Promise.resolve(promise instanceof Function ? promise() : promise);
1483
+ let shouldDismiss = id !== undefined;
1484
+ let result;
1485
+ const originalPromise = p.then(async (response)=>{
1486
+ result = [
1487
+ 'resolve',
1488
+ response
1489
+ ];
1490
+ const isReactElementResponse = React__default.default.isValidElement(response);
1491
+ if (isReactElementResponse) {
1492
+ shouldDismiss = false;
1493
+ this.create({
1494
+ id,
1495
+ type: 'default',
1496
+ message: response
1497
+ });
1498
+ } else if (isHttpResponse(response) && !response.ok) {
1499
+ shouldDismiss = false;
1500
+ const promiseData = typeof data.error === 'function' ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
1501
+ const description = typeof data.description === 'function' ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
1502
+ const isExtendedResult = typeof promiseData === 'object' && !React__default.default.isValidElement(promiseData);
1503
+ const toastSettings = isExtendedResult ? promiseData : {
1504
+ message: promiseData
1505
+ };
1506
+ this.create({
1507
+ id,
1508
+ type: 'error',
1509
+ description,
1510
+ ...toastSettings
1511
+ });
1512
+ } else if (response instanceof Error) {
1513
+ shouldDismiss = false;
1514
+ const promiseData = typeof data.error === 'function' ? await data.error(response) : data.error;
1515
+ const description = typeof data.description === 'function' ? await data.description(response) : data.description;
1516
+ const isExtendedResult = typeof promiseData === 'object' && !React__default.default.isValidElement(promiseData);
1517
+ const toastSettings = isExtendedResult ? promiseData : {
1518
+ message: promiseData
1519
+ };
1520
+ this.create({
1521
+ id,
1522
+ type: 'error',
1523
+ description,
1524
+ ...toastSettings
1525
+ });
1526
+ } else if (data.success !== undefined) {
1527
+ shouldDismiss = false;
1528
+ const promiseData = typeof data.success === 'function' ? await data.success(response) : data.success;
1529
+ const description = typeof data.description === 'function' ? await data.description(response) : data.description;
1530
+ const isExtendedResult = typeof promiseData === 'object' && !React__default.default.isValidElement(promiseData);
1531
+ const toastSettings = isExtendedResult ? promiseData : {
1532
+ message: promiseData
1533
+ };
1534
+ this.create({
1535
+ id,
1536
+ type: 'success',
1537
+ description,
1538
+ ...toastSettings
1539
+ });
1540
+ }
1541
+ }).catch(async (error)=>{
1542
+ result = [
1543
+ 'reject',
1544
+ error
1545
+ ];
1546
+ if (data.error !== undefined) {
1547
+ shouldDismiss = false;
1548
+ const promiseData = typeof data.error === 'function' ? await data.error(error) : data.error;
1549
+ const description = typeof data.description === 'function' ? await data.description(error) : data.description;
1550
+ const isExtendedResult = typeof promiseData === 'object' && !React__default.default.isValidElement(promiseData);
1551
+ const toastSettings = isExtendedResult ? promiseData : {
1552
+ message: promiseData
1553
+ };
1554
+ this.create({
1555
+ id,
1556
+ type: 'error',
1557
+ description,
1558
+ ...toastSettings
1559
+ });
1560
+ }
1561
+ }).finally(()=>{
1562
+ if (shouldDismiss) {
1563
+ // Toast is still in load state (and will be indefinitely — dismiss it)
1564
+ this.dismiss(id);
1565
+ id = undefined;
1566
+ }
1567
+ data.finally == null || data.finally.call(data);
1568
+ });
1569
+ const unwrap = ()=>new Promise((resolve, reject)=>originalPromise.then(()=>result[0] === 'reject' ? reject(result[1]) : resolve(result[1])).catch(reject));
1570
+ if (typeof id !== 'string' && typeof id !== 'number') // cannot Object.assign on undefined
1571
+ return {
1572
+ unwrap
1573
+ };
1574
+ else return Object.assign(id, {
1575
+ unwrap
1576
+ });
1577
+ };
1578
+ this.custom = (jsx, data)=>{
1579
+ const id = (data == null ? void 0 : data.id) || toastsCounter++;
1580
+ this.create({
1581
+ jsx: jsx(id),
1582
+ id,
1583
+ ...data
1584
+ });
1585
+ return id;
1586
+ };
1587
+ this.getActiveToasts = ()=>{
1588
+ return this.toasts.filter((toast)=>!this.dismissedToasts.has(toast.id));
1589
+ };
1590
+ this.subscribers = [];
1591
+ this.toasts = [];
1592
+ this.dismissedToasts = new Set();
1593
+ }
1594
+ }
1595
+ const ToastState = new Observer();
1596
+ // bind this to the toast function
1597
+ const toastFunction = (message, data)=>{
1598
+ const id = (data == null ? void 0 : data.id) || toastsCounter++;
1599
+ ToastState.addToast({
1600
+ title: message,
1601
+ ...data,
1602
+ id
1603
+ });
1604
+ return id;
1605
+ };
1606
+ const isHttpResponse = (data)=>{
1607
+ return data && typeof data === 'object' && 'ok' in data && typeof data.ok === 'boolean' && 'status' in data && typeof data.status === 'number';
1608
+ };
1609
+ const basicToast = toastFunction;
1610
+ const getHistory = ()=>ToastState.toasts;
1611
+ const getToasts = ()=>ToastState.getActiveToasts();
1612
+ // We use `Object.assign` to maintain the correct types as we would lose them otherwise
1613
+ const toast = Object.assign(basicToast, {
1614
+ success: ToastState.success,
1615
+ info: ToastState.info,
1616
+ warning: ToastState.warning,
1617
+ error: ToastState.error,
1618
+ custom: ToastState.custom,
1619
+ message: ToastState.message,
1620
+ promise: ToastState.promise,
1621
+ dismiss: ToastState.dismiss,
1622
+ loading: ToastState.loading
1623
+ }, {
1624
+ getHistory,
1625
+ getToasts
1626
+ });
1627
+ __insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
1628
+ function isAction(action) {
1629
+ return action.label !== undefined;
1630
+ }
1631
+ // Visible toasts amount
1632
+ const VISIBLE_TOASTS_AMOUNT = 3;
1633
+ // Viewport padding
1634
+ const VIEWPORT_OFFSET = '24px';
1635
+ // Mobile viewport padding
1636
+ const MOBILE_VIEWPORT_OFFSET = '16px';
1637
+ // Default lifetime of a toasts (in ms)
1638
+ const TOAST_LIFETIME = 4000;
1639
+ // Default toast width
1640
+ const TOAST_WIDTH = 356;
1641
+ // Default gap between toasts
1642
+ const GAP = 14;
1643
+ // Threshold to dismiss a toast
1644
+ const SWIPE_THRESHOLD = 45;
1645
+ // Equal to exit animation duration
1646
+ const TIME_BEFORE_UNMOUNT = 200;
1647
+ function cn(...classes) {
1648
+ return classes.filter(Boolean).join(' ');
1649
+ }
1650
+ function getDefaultSwipeDirections(position) {
1651
+ const [y, x] = position.split('-');
1652
+ const directions = [];
1653
+ if (y) directions.push(y);
1654
+ if (x) directions.push(x);
1655
+ return directions;
1656
+ }
1657
+ const Toast = (props)=>{
1658
+ var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
1659
+ const { invert: ToasterInvert, toast, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = '', descriptionClassName = '', duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = 'Close toast' } = props;
1660
+ const [swipeDirection, setSwipeDirection] = React__default.default.useState(null);
1661
+ const [swipeOutDirection, setSwipeOutDirection] = React__default.default.useState(null);
1662
+ const [mounted, setMounted] = React__default.default.useState(false);
1663
+ const [removed, setRemoved] = React__default.default.useState(false);
1664
+ const [swiping, setSwiping] = React__default.default.useState(false);
1665
+ const [swipeOut, setSwipeOut] = React__default.default.useState(false);
1666
+ const [isSwiped, setIsSwiped] = React__default.default.useState(false);
1667
+ const [offsetBeforeRemove, setOffsetBeforeRemove] = React__default.default.useState(0);
1668
+ const [initialHeight, setInitialHeight] = React__default.default.useState(0);
1669
+ const remainingTime = React__default.default.useRef(toast.duration || durationFromToaster || TOAST_LIFETIME);
1670
+ const dragStartTime = React__default.default.useRef(null);
1671
+ const toastRef = React__default.default.useRef(null);
1672
+ const isFront = index === 0;
1673
+ const isVisible = index + 1 <= visibleToasts;
1674
+ const toastType = toast.type;
1675
+ const dismissible = toast.dismissible !== false;
1676
+ const toastClassname = toast.className || '';
1677
+ const toastDescriptionClassname = toast.descriptionClassName || '';
1678
+ // Height index is used to calculate the offset as it gets updated before the toast array, which means we can calculate the new layout faster.
1679
+ const heightIndex = React__default.default.useMemo(()=>heights.findIndex((height)=>height.toastId === toast.id) || 0, [
1680
+ heights,
1681
+ toast.id
1682
+ ]);
1683
+ const closeButton = React__default.default.useMemo(()=>{
1684
+ var _toast_closeButton;
1685
+ return (_toast_closeButton = toast.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
1686
+ }, [
1687
+ toast.closeButton,
1688
+ closeButtonFromToaster
1689
+ ]);
1690
+ const duration = React__default.default.useMemo(()=>toast.duration || durationFromToaster || TOAST_LIFETIME, [
1691
+ toast.duration,
1692
+ durationFromToaster
1693
+ ]);
1694
+ const closeTimerStartTimeRef = React__default.default.useRef(0);
1695
+ const offset = React__default.default.useRef(0);
1696
+ const lastCloseTimerStartTimeRef = React__default.default.useRef(0);
1697
+ const pointerStartRef = React__default.default.useRef(null);
1698
+ const [y, x] = position.split('-');
1699
+ const toastsHeightBefore = React__default.default.useMemo(()=>{
1700
+ return heights.reduce((prev, curr, reducerIndex)=>{
1701
+ // Calculate offset up until current toast
1702
+ if (reducerIndex >= heightIndex) return prev;
1703
+ return prev + curr.height;
1704
+ }, 0);
1705
+ }, [
1706
+ heights,
1707
+ heightIndex
1708
+ ]);
1709
+ const isDocumentHidden = useIsDocumentHidden();
1710
+ const invert = toast.invert || ToasterInvert;
1711
+ const disabled = toastType === 'loading';
1712
+ offset.current = React__default.default.useMemo(()=>heightIndex * gap + toastsHeightBefore, [
1713
+ heightIndex,
1714
+ toastsHeightBefore
1715
+ ]);
1716
+ React__default.default.useEffect(()=>{
1717
+ remainingTime.current = duration;
1718
+ }, [
1719
+ duration
1720
+ ]);
1721
+ React__default.default.useEffect(()=>{
1722
+ // Trigger enter animation without using CSS animation
1723
+ setMounted(true);
1724
+ }, []);
1725
+ React__default.default.useEffect(()=>{
1726
+ const toastNode = toastRef.current;
1727
+ if (toastNode) {
1728
+ const height = toastNode.getBoundingClientRect().height;
1729
+ // Add toast height to heights array after the toast is mounted
1730
+ setInitialHeight(height);
1731
+ setHeights((h)=>[
1732
+ {
1733
+ toastId: toast.id,
1734
+ height,
1735
+ position: toast.position
1736
+ },
1737
+ ...h
1738
+ ]);
1739
+ return ()=>setHeights((h)=>h.filter((height)=>height.toastId !== toast.id));
1740
+ }
1741
+ }, [
1742
+ setHeights,
1743
+ toast.id
1744
+ ]);
1745
+ React__default.default.useLayoutEffect(()=>{
1746
+ // Keep height up to date with the content in case it updates
1747
+ if (!mounted) return;
1748
+ const toastNode = toastRef.current;
1749
+ const originalHeight = toastNode.style.height;
1750
+ toastNode.style.height = 'auto';
1751
+ const newHeight = toastNode.getBoundingClientRect().height;
1752
+ toastNode.style.height = originalHeight;
1753
+ setInitialHeight(newHeight);
1754
+ setHeights((heights)=>{
1755
+ const alreadyExists = heights.find((height)=>height.toastId === toast.id);
1756
+ if (!alreadyExists) return [
1757
+ {
1758
+ toastId: toast.id,
1759
+ height: newHeight,
1760
+ position: toast.position
1761
+ },
1762
+ ...heights
1763
+ ];
1764
+ else return heights.map((height)=>height.toastId === toast.id ? {
1765
+ ...height,
1766
+ height: newHeight
1767
+ } : height);
1768
+ });
1769
+ }, [
1770
+ mounted,
1771
+ toast.title,
1772
+ toast.description,
1773
+ setHeights,
1774
+ toast.id,
1775
+ toast.jsx,
1776
+ toast.action,
1777
+ toast.cancel
1778
+ ]);
1779
+ const deleteToast = React__default.default.useCallback(()=>{
1780
+ // Save the offset for the exit swipe animation
1781
+ setRemoved(true);
1782
+ setOffsetBeforeRemove(offset.current);
1783
+ setHeights((h)=>h.filter((height)=>height.toastId !== toast.id));
1784
+ setTimeout(()=>{
1785
+ removeToast(toast);
1786
+ }, TIME_BEFORE_UNMOUNT);
1787
+ }, [
1788
+ toast,
1789
+ removeToast,
1790
+ setHeights,
1791
+ offset
1792
+ ]);
1793
+ React__default.default.useEffect(()=>{
1794
+ if (toast.promise && toastType === 'loading' || toast.duration === Infinity || toast.type === 'loading') return;
1795
+ let timeoutId;
1796
+ // Pause the timer on each hover
1797
+ const pauseTimer = ()=>{
1798
+ if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
1799
+ // Get the elapsed time since the timer started
1800
+ const elapsedTime = new Date().getTime() - closeTimerStartTimeRef.current;
1801
+ remainingTime.current = remainingTime.current - elapsedTime;
1802
+ }
1803
+ lastCloseTimerStartTimeRef.current = new Date().getTime();
1804
+ };
1805
+ const startTimer = ()=>{
1806
+ // setTimeout(, Infinity) behaves as if the delay is 0.
1807
+ // As a result, the toast would be closed immediately, giving the appearance that it was never rendered.
1808
+ // See: https://github.com/denysdovhan/wtfjs?tab=readme-ov-file#an-infinite-timeout
1809
+ if (remainingTime.current === Infinity) return;
1810
+ closeTimerStartTimeRef.current = new Date().getTime();
1811
+ // Let the toast know it has started
1812
+ timeoutId = setTimeout(()=>{
1813
+ toast.onAutoClose == null || toast.onAutoClose.call(toast, toast);
1814
+ deleteToast();
1815
+ }, remainingTime.current);
1816
+ };
1817
+ if (expanded || interacting || isDocumentHidden) pauseTimer();
1818
+ else startTimer();
1819
+ return ()=>clearTimeout(timeoutId);
1820
+ }, [
1821
+ expanded,
1822
+ interacting,
1823
+ toast,
1824
+ toastType,
1825
+ isDocumentHidden,
1826
+ deleteToast
1827
+ ]);
1828
+ React__default.default.useEffect(()=>{
1829
+ if (toast.delete) {
1830
+ deleteToast();
1831
+ toast.onDismiss == null || toast.onDismiss.call(toast, toast);
1832
+ }
1833
+ }, [
1834
+ deleteToast,
1835
+ toast.delete
1836
+ ]);
1837
+ function getLoadingIcon() {
1838
+ var _toast_classNames;
1839
+ if (icons == null ? void 0 : icons.loading) {
1840
+ var _toast_classNames1;
1841
+ return /*#__PURE__*/ React__default.default.createElement("div", {
1842
+ className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1.loader, 'sonner-loader'),
1843
+ "data-visible": toastType === 'loading'
1844
+ }, icons.loading);
1845
+ }
1846
+ return /*#__PURE__*/ React__default.default.createElement(Loader, {
1847
+ className: cn(classNames == null ? void 0 : classNames.loader, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.loader),
1848
+ visible: toastType === 'loading'
1849
+ });
1850
+ }
1851
+ const icon = toast.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
1852
+ var _toast_richColors, _icons_close;
1853
+ return /*#__PURE__*/ React__default.default.createElement("li", {
1854
+ tabIndex: 0,
1855
+ ref: toastRef,
1856
+ className: cn(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast == null ? void 0 : (_toast_classNames = toast.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast == null ? void 0 : (_toast_classNames1 = toast.classNames) == null ? void 0 : _toast_classNames1[toastType]),
1857
+ "data-sonner-toast": "",
1858
+ "data-rich-colors": (_toast_richColors = toast.richColors) != null ? _toast_richColors : defaultRichColors,
1859
+ "data-styled": !Boolean(toast.jsx || toast.unstyled || unstyled),
1860
+ "data-mounted": mounted,
1861
+ "data-promise": Boolean(toast.promise),
1862
+ "data-swiped": isSwiped,
1863
+ "data-removed": removed,
1864
+ "data-visible": isVisible,
1865
+ "data-y-position": y,
1866
+ "data-x-position": x,
1867
+ "data-index": index,
1868
+ "data-front": isFront,
1869
+ "data-swiping": swiping,
1870
+ "data-dismissible": dismissible,
1871
+ "data-type": toastType,
1872
+ "data-invert": invert,
1873
+ "data-swipe-out": swipeOut,
1874
+ "data-swipe-direction": swipeOutDirection,
1875
+ "data-expanded": Boolean(expanded || expandByDefault && mounted),
1876
+ "data-testid": toast.testId,
1877
+ style: {
1878
+ '--index': index,
1879
+ '--toasts-before': index,
1880
+ '--z-index': toasts.length - index,
1881
+ '--offset': `${removed ? offsetBeforeRemove : offset.current}px`,
1882
+ '--initial-height': expandByDefault ? 'auto' : `${initialHeight}px`,
1883
+ ...style,
1884
+ ...toast.style
1885
+ },
1886
+ onDragEnd: ()=>{
1887
+ setSwiping(false);
1888
+ setSwipeDirection(null);
1889
+ pointerStartRef.current = null;
1890
+ },
1891
+ onPointerDown: (event)=>{
1892
+ if (event.button === 2) return; // Return early on right click
1893
+ if (disabled || !dismissible) return;
1894
+ dragStartTime.current = new Date();
1895
+ setOffsetBeforeRemove(offset.current);
1896
+ // Ensure we maintain correct pointer capture even when going outside of the toast (e.g. when swiping)
1897
+ event.target.setPointerCapture(event.pointerId);
1898
+ if (event.target.tagName === 'BUTTON') return;
1899
+ setSwiping(true);
1900
+ pointerStartRef.current = {
1901
+ x: event.clientX,
1902
+ y: event.clientY
1903
+ };
1904
+ },
1905
+ onPointerUp: ()=>{
1906
+ var _toastRef_current, _toastRef_current1, _dragStartTime_current;
1907
+ if (swipeOut || !dismissible) return;
1908
+ pointerStartRef.current = null;
1909
+ const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue('--swipe-amount-x').replace('px', '')) || 0);
1910
+ const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue('--swipe-amount-y').replace('px', '')) || 0);
1911
+ const timeTaken = new Date().getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime());
1912
+ const swipeAmount = swipeDirection === 'x' ? swipeAmountX : swipeAmountY;
1913
+ const velocity = Math.abs(swipeAmount) / timeTaken;
1914
+ if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
1915
+ setOffsetBeforeRemove(offset.current);
1916
+ toast.onDismiss == null || toast.onDismiss.call(toast, toast);
1917
+ if (swipeDirection === 'x') setSwipeOutDirection(swipeAmountX > 0 ? 'right' : 'left');
1918
+ else setSwipeOutDirection(swipeAmountY > 0 ? 'down' : 'up');
1919
+ deleteToast();
1920
+ setSwipeOut(true);
1921
+ return;
1922
+ } else {
1923
+ var _toastRef_current2, _toastRef_current3;
1924
+ (_toastRef_current2 = toastRef.current) == null || _toastRef_current2.style.setProperty('--swipe-amount-x', `0px`);
1925
+ (_toastRef_current3 = toastRef.current) == null || _toastRef_current3.style.setProperty('--swipe-amount-y', `0px`);
1926
+ }
1927
+ setIsSwiped(false);
1928
+ setSwiping(false);
1929
+ setSwipeDirection(null);
1930
+ },
1931
+ onPointerMove: (event)=>{
1932
+ var _window_getSelection, _toastRef_current, _toastRef_current1;
1933
+ if (!pointerStartRef.current || !dismissible) return;
1934
+ const isHighlighted = ((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0;
1935
+ if (isHighlighted) return;
1936
+ const yDelta = event.clientY - pointerStartRef.current.y;
1937
+ const xDelta = event.clientX - pointerStartRef.current.x;
1938
+ var _props_swipeDirections;
1939
+ const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
1940
+ // Determine swipe direction if not already locked
1941
+ if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? 'x' : 'y');
1942
+ let swipeAmount = {
1943
+ x: 0,
1944
+ y: 0
1945
+ };
1946
+ const getDampening = (delta)=>{
1947
+ const factor = Math.abs(delta) / 20;
1948
+ return 1 / (1.5 + factor);
1949
+ };
1950
+ // Only apply swipe in the locked direction
1951
+ if (swipeDirection === 'y') // Handle vertical swipes
1952
+ {
1953
+ if (swipeDirections.includes('top') || swipeDirections.includes('bottom')) {
1954
+ if (swipeDirections.includes('top') && yDelta < 0 || swipeDirections.includes('bottom') && yDelta > 0) swipeAmount.y = yDelta;
1955
+ else {
1956
+ // Smoothly transition to dampened movement
1957
+ const dampenedDelta = yDelta * getDampening(yDelta);
1958
+ // Ensure we don't jump when transitioning to dampened movement
1959
+ swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
1960
+ }
1961
+ }
1962
+ } else if (swipeDirection === 'x') // Handle horizontal swipes
1963
+ {
1964
+ if (swipeDirections.includes('left') || swipeDirections.includes('right')) {
1965
+ if (swipeDirections.includes('left') && xDelta < 0 || swipeDirections.includes('right') && xDelta > 0) swipeAmount.x = xDelta;
1966
+ else {
1967
+ // Smoothly transition to dampened movement
1968
+ const dampenedDelta = xDelta * getDampening(xDelta);
1969
+ // Ensure we don't jump when transitioning to dampened movement
1970
+ swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
1971
+ }
1972
+ }
1973
+ }
1974
+ if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) setIsSwiped(true);
1975
+ (_toastRef_current = toastRef.current) == null || _toastRef_current.style.setProperty('--swipe-amount-x', `${swipeAmount.x}px`);
1976
+ (_toastRef_current1 = toastRef.current) == null || _toastRef_current1.style.setProperty('--swipe-amount-y', `${swipeAmount.y}px`);
1977
+ }
1978
+ }, closeButton && !toast.jsx && toastType !== 'loading' ? /*#__PURE__*/ React__default.default.createElement("button", {
1979
+ "aria-label": closeButtonAriaLabel,
1980
+ "data-disabled": disabled,
1981
+ "data-close-button": true,
1982
+ onClick: disabled || !dismissible ? ()=>{} : ()=>{
1983
+ deleteToast();
1984
+ toast.onDismiss == null || toast.onDismiss.call(toast, toast);
1985
+ },
1986
+ className: cn(classNames == null ? void 0 : classNames.closeButton, toast == null ? void 0 : (_toast_classNames2 = toast.classNames) == null ? void 0 : _toast_classNames2.closeButton)
1987
+ }, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast.icon || toast.promise) && toast.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast.icon) ? /*#__PURE__*/ React__default.default.createElement("div", {
1988
+ "data-icon": "",
1989
+ className: cn(classNames == null ? void 0 : classNames.icon, toast == null ? void 0 : (_toast_classNames3 = toast.classNames) == null ? void 0 : _toast_classNames3.icon)
1990
+ }, toast.promise || toast.type === 'loading' && !toast.icon ? toast.icon || getLoadingIcon() : null, toast.type !== 'loading' ? icon : null) : null, /*#__PURE__*/ React__default.default.createElement("div", {
1991
+ "data-content": "",
1992
+ className: cn(classNames == null ? void 0 : classNames.content, toast == null ? void 0 : (_toast_classNames4 = toast.classNames) == null ? void 0 : _toast_classNames4.content)
1993
+ }, /*#__PURE__*/ React__default.default.createElement("div", {
1994
+ "data-title": "",
1995
+ className: cn(classNames == null ? void 0 : classNames.title, toast == null ? void 0 : (_toast_classNames5 = toast.classNames) == null ? void 0 : _toast_classNames5.title)
1996
+ }, toast.jsx ? toast.jsx : typeof toast.title === 'function' ? toast.title() : toast.title), toast.description ? /*#__PURE__*/ React__default.default.createElement("div", {
1997
+ "data-description": "",
1998
+ className: cn(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast == null ? void 0 : (_toast_classNames6 = toast.classNames) == null ? void 0 : _toast_classNames6.description)
1999
+ }, typeof toast.description === 'function' ? toast.description() : toast.description) : null), /*#__PURE__*/ React__default.default.isValidElement(toast.cancel) ? toast.cancel : toast.cancel && isAction(toast.cancel) ? /*#__PURE__*/ React__default.default.createElement("button", {
2000
+ "data-button": true,
2001
+ "data-cancel": true,
2002
+ style: toast.cancelButtonStyle || cancelButtonStyle,
2003
+ onClick: (event)=>{
2004
+ // We need to check twice because typescript
2005
+ if (!isAction(toast.cancel)) return;
2006
+ if (!dismissible) return;
2007
+ toast.cancel.onClick == null || toast.cancel.onClick.call(toast.cancel, event);
2008
+ deleteToast();
2009
+ },
2010
+ className: cn(classNames == null ? void 0 : classNames.cancelButton, toast == null ? void 0 : (_toast_classNames7 = toast.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
2011
+ }, toast.cancel.label) : null, /*#__PURE__*/ React__default.default.isValidElement(toast.action) ? toast.action : toast.action && isAction(toast.action) ? /*#__PURE__*/ React__default.default.createElement("button", {
2012
+ "data-button": true,
2013
+ "data-action": true,
2014
+ style: toast.actionButtonStyle || actionButtonStyle,
2015
+ onClick: (event)=>{
2016
+ // We need to check twice because typescript
2017
+ if (!isAction(toast.action)) return;
2018
+ toast.action.onClick == null || toast.action.onClick.call(toast.action, event);
2019
+ if (event.defaultPrevented) return;
2020
+ deleteToast();
2021
+ },
2022
+ className: cn(classNames == null ? void 0 : classNames.actionButton, toast == null ? void 0 : (_toast_classNames8 = toast.classNames) == null ? void 0 : _toast_classNames8.actionButton)
2023
+ }, toast.action.label) : null);
2024
+ };
2025
+ function getDocumentDirection() {
2026
+ if (typeof window === 'undefined') return 'ltr';
2027
+ if (typeof document === 'undefined') return 'ltr'; // For Fresh purpose
2028
+ const dirAttribute = document.documentElement.getAttribute('dir');
2029
+ if (dirAttribute === 'auto' || !dirAttribute) return window.getComputedStyle(document.documentElement).direction;
2030
+ return dirAttribute;
2031
+ }
2032
+ function assignOffset(defaultOffset, mobileOffset) {
2033
+ const styles = {};
2034
+ [
2035
+ defaultOffset,
2036
+ mobileOffset
2037
+ ].forEach((offset, index)=>{
2038
+ const isMobile = index === 1;
2039
+ const prefix = isMobile ? '--mobile-offset' : '--offset';
2040
+ const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
2041
+ function assignAll(offset) {
2042
+ [
2043
+ 'top',
2044
+ 'right',
2045
+ 'bottom',
2046
+ 'left'
2047
+ ].forEach((key)=>{
2048
+ styles[`${prefix}-${key}`] = typeof offset === 'number' ? `${offset}px` : offset;
2049
+ });
2050
+ }
2051
+ if (typeof offset === 'number' || typeof offset === 'string') assignAll(offset);
2052
+ else if (typeof offset === 'object') [
2053
+ 'top',
2054
+ 'right',
2055
+ 'bottom',
2056
+ 'left'
2057
+ ].forEach((key)=>{
2058
+ if (offset[key] === undefined) styles[`${prefix}-${key}`] = defaultValue;
2059
+ else styles[`${prefix}-${key}`] = typeof offset[key] === 'number' ? `${offset[key]}px` : offset[key];
2060
+ });
2061
+ else assignAll(defaultValue);
2062
+ });
2063
+ return styles;
2064
+ }
2065
+ function useSonner() {
2066
+ const [activeToasts, setActiveToasts] = React__default.default.useState([]);
2067
+ React__default.default.useEffect(()=>{
2068
+ return ToastState.subscribe((toast)=>{
2069
+ if (toast.dismiss) {
2070
+ setTimeout(()=>{
2071
+ ReactDOM__default.default.flushSync(()=>{
2072
+ setActiveToasts((toasts)=>toasts.filter((t)=>t.id !== toast.id));
2073
+ });
2074
+ });
2075
+ return;
2076
+ }
2077
+ // Prevent batching, temp solution.
2078
+ setTimeout(()=>{
2079
+ ReactDOM__default.default.flushSync(()=>{
2080
+ setActiveToasts((toasts)=>{
2081
+ const indexOfExistingToast = toasts.findIndex((t)=>t.id === toast.id);
2082
+ // Update the toast if it already exists
2083
+ if (indexOfExistingToast !== -1) return [
2084
+ ...toasts.slice(0, indexOfExistingToast),
2085
+ {
2086
+ ...toasts[indexOfExistingToast],
2087
+ ...toast
2088
+ },
2089
+ ...toasts.slice(indexOfExistingToast + 1)
2090
+ ];
2091
+ return [
2092
+ toast,
2093
+ ...toasts
2094
+ ];
2095
+ });
2096
+ });
2097
+ });
2098
+ });
2099
+ }, []);
2100
+ return {
2101
+ toasts: activeToasts
2102
+ };
2103
+ }
2104
+ const Toaster = /*#__PURE__*/ React__default.default.forwardRef(function Toaster(props, ref) {
2105
+ const { id, invert, position = 'bottom-right', hotkey = [
2106
+ 'altKey',
2107
+ 'KeyT'
2108
+ ], expand, closeButton, className, offset, mobileOffset, theme = 'light', richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = 'Notifications' } = props;
2109
+ const [toasts, setToasts] = React__default.default.useState([]);
2110
+ const filteredToasts = React__default.default.useMemo(()=>{
2111
+ if (id) return toasts.filter((toast)=>toast.toasterId === id);
2112
+ return toasts.filter((toast)=>!toast.toasterId);
2113
+ }, [
2114
+ toasts,
2115
+ id
2116
+ ]);
2117
+ const possiblePositions = React__default.default.useMemo(()=>{
2118
+ return Array.from(new Set([
2119
+ position
2120
+ ].concat(filteredToasts.filter((toast)=>toast.position).map((toast)=>toast.position))));
2121
+ }, [
2122
+ filteredToasts,
2123
+ position
2124
+ ]);
2125
+ const [heights, setHeights] = React__default.default.useState([]);
2126
+ const [expanded, setExpanded] = React__default.default.useState(false);
2127
+ const [interacting, setInteracting] = React__default.default.useState(false);
2128
+ const [actualTheme, setActualTheme] = React__default.default.useState(theme !== 'system' ? theme : typeof window !== 'undefined' ? window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' : 'light');
2129
+ const listRef = React__default.default.useRef(null);
2130
+ const hotkeyLabel = hotkey.join('+').replace(/Key/g, '').replace(/Digit/g, '');
2131
+ const lastFocusedElementRef = React__default.default.useRef(null);
2132
+ const isFocusWithinRef = React__default.default.useRef(false);
2133
+ const removeToast = React__default.default.useCallback((toastToRemove)=>{
2134
+ setToasts((toasts)=>{
2135
+ var _toasts_find;
2136
+ if (!((_toasts_find = toasts.find((toast)=>toast.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) ToastState.dismiss(toastToRemove.id);
2137
+ return toasts.filter(({ id })=>id !== toastToRemove.id);
2138
+ });
2139
+ }, []);
2140
+ React__default.default.useEffect(()=>{
2141
+ return ToastState.subscribe((toast)=>{
2142
+ if (toast.dismiss) {
2143
+ // Prevent batching of other state updates
2144
+ requestAnimationFrame(()=>{
2145
+ setToasts((toasts)=>toasts.map((t)=>t.id === toast.id ? {
2146
+ ...t,
2147
+ delete: true
2148
+ } : t));
2149
+ });
2150
+ return;
2151
+ }
2152
+ // Prevent batching, temp solution.
2153
+ setTimeout(()=>{
2154
+ ReactDOM__default.default.flushSync(()=>{
2155
+ setToasts((toasts)=>{
2156
+ const indexOfExistingToast = toasts.findIndex((t)=>t.id === toast.id);
2157
+ // Update the toast if it already exists
2158
+ if (indexOfExistingToast !== -1) return [
2159
+ ...toasts.slice(0, indexOfExistingToast),
2160
+ {
2161
+ ...toasts[indexOfExistingToast],
2162
+ ...toast
2163
+ },
2164
+ ...toasts.slice(indexOfExistingToast + 1)
2165
+ ];
2166
+ return [
2167
+ toast,
2168
+ ...toasts
2169
+ ];
2170
+ });
2171
+ });
2172
+ });
2173
+ });
2174
+ }, [
2175
+ toasts
2176
+ ]);
2177
+ React__default.default.useEffect(()=>{
2178
+ if (theme !== 'system') {
2179
+ setActualTheme(theme);
2180
+ return;
2181
+ }
2182
+ if (theme === 'system') {
2183
+ // check if current preference is dark
2184
+ if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) // it's currently dark
2185
+ setActualTheme('dark');
2186
+ else // it's not dark
2187
+ setActualTheme('light');
2188
+ }
2189
+ if (typeof window === 'undefined') return;
2190
+ const darkMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
2191
+ try {
2192
+ // Chrome & Firefox
2193
+ darkMediaQuery.addEventListener('change', ({ matches })=>{
2194
+ if (matches) setActualTheme('dark');
2195
+ else setActualTheme('light');
2196
+ });
2197
+ } catch (error) {
2198
+ // Safari < 14
2199
+ darkMediaQuery.addListener(({ matches })=>{
2200
+ try {
2201
+ if (matches) setActualTheme('dark');
2202
+ else setActualTheme('light');
2203
+ } catch (e) {
2204
+ console.error(e);
2205
+ }
2206
+ });
2207
+ }
2208
+ }, [
2209
+ theme
2210
+ ]);
2211
+ React__default.default.useEffect(()=>{
2212
+ // Ensure expanded is always false when no toasts are present / only one left
2213
+ if (toasts.length <= 1) setExpanded(false);
2214
+ }, [
2215
+ toasts
2216
+ ]);
2217
+ React__default.default.useEffect(()=>{
2218
+ const handleKeyDown = (event)=>{
2219
+ var _listRef_current;
2220
+ const isHotkeyPressed = hotkey.every((key)=>event[key] || event.code === key);
2221
+ if (isHotkeyPressed) {
2222
+ var _listRef_current1;
2223
+ setExpanded(true);
2224
+ (_listRef_current1 = listRef.current) == null || _listRef_current1.focus();
2225
+ }
2226
+ if (event.code === 'Escape' && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? void 0 : _listRef_current.contains(document.activeElement)))) setExpanded(false);
2227
+ };
2228
+ document.addEventListener('keydown', handleKeyDown);
2229
+ return ()=>document.removeEventListener('keydown', handleKeyDown);
2230
+ }, [
2231
+ hotkey
2232
+ ]);
2233
+ React__default.default.useEffect(()=>{
2234
+ if (listRef.current) return ()=>{
2235
+ if (lastFocusedElementRef.current) {
2236
+ lastFocusedElementRef.current.focus({
2237
+ preventScroll: true
2238
+ });
2239
+ lastFocusedElementRef.current = null;
2240
+ isFocusWithinRef.current = false;
2241
+ }
2242
+ };
2243
+ }, [
2244
+ listRef.current
2245
+ ]);
2246
+ return /*#__PURE__*/ React__default.default.createElement("section", {
2247
+ ref: ref,
2248
+ "aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
2249
+ tabIndex: -1,
2250
+ "aria-live": "polite",
2251
+ "aria-relevant": "additions text",
2252
+ "aria-atomic": "false",
2253
+ suppressHydrationWarning: true
2254
+ }, possiblePositions.map((position, index)=>{
2255
+ var _heights_;
2256
+ const [y, x] = position.split('-');
2257
+ if (!filteredToasts.length) return null;
2258
+ return /*#__PURE__*/ React__default.default.createElement("ol", {
2259
+ key: position,
2260
+ dir: dir === 'auto' ? getDocumentDirection() : dir,
2261
+ tabIndex: -1,
2262
+ ref: listRef,
2263
+ className: className,
2264
+ "data-sonner-toaster": true,
2265
+ "data-sonner-theme": actualTheme,
2266
+ "data-y-position": y,
2267
+ "data-x-position": x,
2268
+ style: {
2269
+ '--front-toast-height': `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
2270
+ '--width': `${TOAST_WIDTH}px`,
2271
+ '--gap': `${gap}px`,
2272
+ ...style,
2273
+ ...assignOffset(offset, mobileOffset)
2274
+ },
2275
+ onBlur: (event)=>{
2276
+ if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
2277
+ isFocusWithinRef.current = false;
2278
+ if (lastFocusedElementRef.current) {
2279
+ lastFocusedElementRef.current.focus({
2280
+ preventScroll: true
2281
+ });
2282
+ lastFocusedElementRef.current = null;
2283
+ }
2284
+ }
2285
+ },
2286
+ onFocus: (event)=>{
2287
+ const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === 'false';
2288
+ if (isNotDismissible) return;
2289
+ if (!isFocusWithinRef.current) {
2290
+ isFocusWithinRef.current = true;
2291
+ lastFocusedElementRef.current = event.relatedTarget;
2292
+ }
2293
+ },
2294
+ onMouseEnter: ()=>setExpanded(true),
2295
+ onMouseMove: ()=>setExpanded(true),
2296
+ onMouseLeave: ()=>{
2297
+ // Avoid setting expanded to false when interacting with a toast, e.g. swiping
2298
+ if (!interacting) setExpanded(false);
2299
+ },
2300
+ onDragEnd: ()=>setExpanded(false),
2301
+ onPointerDown: (event)=>{
2302
+ const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === 'false';
2303
+ if (isNotDismissible) return;
2304
+ setInteracting(true);
2305
+ },
2306
+ onPointerUp: ()=>setInteracting(false)
2307
+ }, filteredToasts.filter((toast)=>!toast.position && index === 0 || toast.position === position).map((toast, index)=>{
2308
+ var _toastOptions_duration, _toastOptions_closeButton;
2309
+ return /*#__PURE__*/ React__default.default.createElement(Toast, {
2310
+ key: toast.id,
2311
+ icons: icons,
2312
+ index: index,
2313
+ toast: toast,
2314
+ defaultRichColors: richColors,
2315
+ duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
2316
+ className: toastOptions == null ? void 0 : toastOptions.className,
2317
+ descriptionClassName: toastOptions == null ? void 0 : toastOptions.descriptionClassName,
2318
+ invert: invert,
2319
+ visibleToasts: visibleToasts,
2320
+ closeButton: (_toastOptions_closeButton = toastOptions == null ? void 0 : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton,
2321
+ interacting: interacting,
2322
+ position: position,
2323
+ style: toastOptions == null ? void 0 : toastOptions.style,
2324
+ unstyled: toastOptions == null ? void 0 : toastOptions.unstyled,
2325
+ classNames: toastOptions == null ? void 0 : toastOptions.classNames,
2326
+ cancelButtonStyle: toastOptions == null ? void 0 : toastOptions.cancelButtonStyle,
2327
+ actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
2328
+ closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
2329
+ removeToast: removeToast,
2330
+ toasts: filteredToasts.filter((t)=>t.position == toast.position),
2331
+ heights: heights.filter((h)=>h.position == toast.position),
2332
+ setHeights: setHeights,
2333
+ expandByDefault: expand,
2334
+ gap: gap,
2335
+ expanded: expanded,
2336
+ swipeDirections: props.swipeDirections
2337
+ });
2338
+ }));
2339
+ }));
2340
+ });
2341
+ exports.Toaster = Toaster;
2342
+ exports.toast = toast;
2343
+ exports.useSonner = useSonner;
2344
+
2345
+ },{"3f174e72235a2879":"jMk1U","8b51ad213197056a":"i4X7T"}],"2PvVD":[function(require,module,exports,__globalThis) {
2346
+ var $parcel$ReactRefreshHelpers$6210 = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
2347
+ $parcel$ReactRefreshHelpers$6210.init();
2348
+ var prevRefreshReg = globalThis.$RefreshReg$;
2349
+ var prevRefreshSig = globalThis.$RefreshSig$;
2350
+ $parcel$ReactRefreshHelpers$6210.prelude(module);
2351
+
2352
+ try {
2353
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
2354
+ parcelHelpers.defineInteropFlag(exports);
2355
+ /** Renders modal, drawer and toaster overlays and handles SHELLUI_OPEN_MODAL / SHELLUI_NAVIGATE. */ parcelHelpers.export(exports, "OverlayShell", ()=>OverlayShell);
2356
+ var _jsxRuntime = require("react/jsx-runtime");
2357
+ var _react = require("react");
2358
+ var _reactRouter = require("react-router");
2359
+ var _reactI18Next = require("react-i18next");
2360
+ var _sdk = require("@shellui/sdk");
2361
+ var _dialog = require("@/components/ui/dialog");
2362
+ var _drawer = require("@/components/ui/drawer");
2363
+ var _sonner = require("@/components/ui/sonner");
2364
+ var _contentView = require("@/components/ContentView");
2365
+ var _modalContext = require("../modal/ModalContext");
2366
+ var _drawerContext = require("../drawer/DrawerContext");
2367
+ var _utils = require("./utils");
2368
+ var _s = $RefreshSig$();
2369
+ function OverlayShell({ navigationItems, children }) {
2370
+ _s();
2371
+ const navigate = (0, _reactRouter.useNavigate)();
2372
+ const { isOpen, modalUrl, closeModal } = (0, _modalContext.useModal)();
2373
+ const { isOpen: isDrawerOpen, drawerUrl, position: drawerPosition, size: drawerSize, closeDrawer } = (0, _drawerContext.useDrawer)();
2374
+ const { t, i18n } = (0, _reactI18Next.useTranslation)('common');
2375
+ const currentLanguage = i18n.language || 'en';
2376
+ (0, _react.useEffect)(()=>{
2377
+ const cleanup = (0, _sdk.shellui).addMessageListener('SHELLUI_OPEN_MODAL', ()=>{
2378
+ closeDrawer();
2379
+ });
2380
+ return ()=>cleanup();
2381
+ }, [
2382
+ closeDrawer
2383
+ ]);
2384
+ (0, _react.useEffect)(()=>{
2385
+ const cleanup = (0, _sdk.shellui).addMessageListener('SHELLUI_NAVIGATE', (data)=>{
2386
+ const payload = data.payload;
2387
+ const rawUrl = payload?.url;
2388
+ if (typeof rawUrl !== 'string' || !rawUrl.trim()) return;
2389
+ let pathname;
2390
+ if (rawUrl.startsWith('http://') || rawUrl.startsWith('https://')) try {
2391
+ pathname = new URL(rawUrl).pathname;
2392
+ } catch {
2393
+ pathname = rawUrl.startsWith('/') ? rawUrl : `/${rawUrl}`;
2394
+ }
2395
+ else pathname = rawUrl.startsWith('/') ? rawUrl : `/${rawUrl}`;
2396
+ closeModal();
2397
+ closeDrawer();
2398
+ const isHomepage = pathname === '/' || pathname === '';
2399
+ const isAllowed = isHomepage || navigationItems.some((item)=>pathname === `/${item.path}` || pathname.startsWith(`/${item.path}/`));
2400
+ if (isAllowed) navigate(pathname || '/');
2401
+ else (0, _sdk.shellui).toast({
2402
+ type: 'error',
2403
+ title: t('navigationError') ?? 'Navigation error',
2404
+ description: t('navigationNotAllowed') ?? 'This URL is not configured in the app navigation.'
2405
+ });
2406
+ });
2407
+ return ()=>cleanup();
2408
+ }, [
2409
+ navigate,
2410
+ closeModal,
2411
+ closeDrawer,
2412
+ navigationItems,
2413
+ t
2414
+ ]);
2415
+ return (0, _jsxRuntime.jsxs)((0, _jsxRuntime.Fragment), {
2416
+ children: [
2417
+ children,
2418
+ (0, _jsxRuntime.jsx)((0, _dialog.Dialog), {
2419
+ open: isOpen,
2420
+ onOpenChange: closeModal,
2421
+ children: (0, _jsxRuntime.jsx)((0, _dialog.DialogContent), {
2422
+ className: "max-w-4xl w-full h-[80vh] max-h-[680px] flex flex-col p-0 overflow-hidden",
2423
+ children: modalUrl ? (0, _jsxRuntime.jsxs)((0, _jsxRuntime.Fragment), {
2424
+ children: [
2425
+ (0, _jsxRuntime.jsx)((0, _dialog.DialogTitle), {
2426
+ className: "sr-only",
2427
+ children: (0, _utils.resolveLocalizedString)(navigationItems.find((item)=>item.url === modalUrl)?.label, currentLanguage)
2428
+ }),
2429
+ (0, _jsxRuntime.jsx)((0, _dialog.DialogDescription), {
2430
+ className: "sr-only",
2431
+ children: t('modalContent') ?? 'Modal content'
2432
+ }),
2433
+ (0, _jsxRuntime.jsx)("div", {
2434
+ className: "flex-1",
2435
+ style: {
2436
+ minHeight: 0
2437
+ },
2438
+ children: (0, _jsxRuntime.jsx)((0, _contentView.ContentView), {
2439
+ url: modalUrl,
2440
+ pathPrefix: "settings",
2441
+ ignoreMessages: true,
2442
+ navItem: navigationItems.find((item)=>item.url === modalUrl)
2443
+ })
2444
+ })
2445
+ ]
2446
+ }) : (0, _jsxRuntime.jsxs)((0, _jsxRuntime.Fragment), {
2447
+ children: [
2448
+ (0, _jsxRuntime.jsx)((0, _dialog.DialogTitle), {
2449
+ className: "sr-only",
2450
+ children: "Error: Modal URL is undefined"
2451
+ }),
2452
+ (0, _jsxRuntime.jsx)((0, _dialog.DialogDescription), {
2453
+ className: "sr-only",
2454
+ children: "The openModal function was called without a valid URL parameter."
2455
+ }),
2456
+ (0, _jsxRuntime.jsx)("div", {
2457
+ className: "flex-1 p-4",
2458
+ children: (0, _jsxRuntime.jsxs)("div", {
2459
+ className: "rounded-lg border border-destructive/50 bg-destructive/10 p-4",
2460
+ children: [
2461
+ (0, _jsxRuntime.jsx)("h3", {
2462
+ className: "font-semibold text-destructive mb-2",
2463
+ children: "Error: Modal URL is undefined"
2464
+ }),
2465
+ (0, _jsxRuntime.jsxs)("p", {
2466
+ className: "text-sm text-muted-foreground",
2467
+ children: [
2468
+ "The ",
2469
+ (0, _jsxRuntime.jsx)("code", {
2470
+ className: "text-xs bg-background px-1 py-0.5 rounded",
2471
+ children: "openModal"
2472
+ }),
2473
+ ' ',
2474
+ "function was called without a valid URL parameter. Please ensure you provide a URL when opening the modal."
2475
+ ]
2476
+ })
2477
+ ]
2478
+ })
2479
+ })
2480
+ ]
2481
+ })
2482
+ })
2483
+ }),
2484
+ (0, _jsxRuntime.jsx)((0, _drawer.Drawer), {
2485
+ open: isDrawerOpen,
2486
+ onOpenChange: (open)=>!open && closeDrawer(),
2487
+ direction: drawerPosition,
2488
+ children: (0, _jsxRuntime.jsx)((0, _drawer.DrawerContent), {
2489
+ direction: drawerPosition,
2490
+ size: drawerSize,
2491
+ className: "p-0 overflow-hidden flex flex-col",
2492
+ children: drawerUrl ? (0, _jsxRuntime.jsx)("div", {
2493
+ className: "flex-1 min-h-0 flex flex-col",
2494
+ children: (0, _jsxRuntime.jsx)((0, _contentView.ContentView), {
2495
+ url: drawerUrl,
2496
+ pathPrefix: "settings",
2497
+ ignoreMessages: true,
2498
+ navItem: navigationItems.find((item)=>item.url === drawerUrl)
2499
+ })
2500
+ }) : (0, _jsxRuntime.jsx)("div", {
2501
+ className: "flex-1 p-4",
2502
+ children: (0, _jsxRuntime.jsxs)("div", {
2503
+ className: "rounded-lg border border-destructive/50 bg-destructive/10 p-4",
2504
+ children: [
2505
+ (0, _jsxRuntime.jsx)("h3", {
2506
+ className: "font-semibold text-destructive mb-2",
2507
+ children: "Error: Drawer URL is undefined"
2508
+ }),
2509
+ (0, _jsxRuntime.jsxs)("p", {
2510
+ className: "text-sm text-muted-foreground",
2511
+ children: [
2512
+ "The ",
2513
+ (0, _jsxRuntime.jsx)("code", {
2514
+ className: "text-xs bg-background px-1 py-0.5 rounded",
2515
+ children: "openDrawer"
2516
+ }),
2517
+ ' ',
2518
+ "function was called without a valid URL parameter. Please ensure you provide a URL when opening the drawer."
2519
+ ]
2520
+ })
2521
+ ]
2522
+ })
2523
+ })
2524
+ })
2525
+ }),
2526
+ (0, _jsxRuntime.jsx)((0, _sonner.Toaster), {})
2527
+ ]
2528
+ });
2529
+ }
2530
+ _s(OverlayShell, "/sEiQfCpefud5vRGUD2d6RDKq0k=", false, function() {
2531
+ return [
2532
+ (0, _reactRouter.useNavigate),
2533
+ (0, _modalContext.useModal),
2534
+ (0, _drawerContext.useDrawer),
2535
+ (0, _reactI18Next.useTranslation)
2536
+ ];
2537
+ });
2538
+ _c = OverlayShell;
2539
+ var _c;
2540
+ $RefreshReg$(_c, "OverlayShell");
2541
+
2542
+ $parcel$ReactRefreshHelpers$6210.postlude(module);
2543
+ } finally {
2544
+ globalThis.$RefreshReg$ = prevRefreshReg;
2545
+ globalThis.$RefreshSig$ = prevRefreshSig;
2546
+ }
2547
+ },{"react/jsx-runtime":"05iiF","react":"jMk1U","react-router":"kWH5w","react-i18next":"gKfGQ","@shellui/sdk":"dS2fb","@/components/ui/dialog":"fsxN0","@/components/ui/drawer":"ds6aU","@/components/ui/sonner":"8Iiui","@/components/ContentView":"iJhlx","../modal/ModalContext":"3yXXZ","../drawer/DrawerContext":"7mOI7","./utils":"4dqXA","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"fsxN0":[function(require,module,exports,__globalThis) {
2548
+ var $parcel$ReactRefreshHelpers$08a3 = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
2549
+ $parcel$ReactRefreshHelpers$08a3.init();
2550
+ var prevRefreshReg = globalThis.$RefreshReg$;
2551
+ var prevRefreshSig = globalThis.$RefreshSig$;
2552
+ $parcel$ReactRefreshHelpers$08a3.prelude(module);
2553
+
2554
+ try {
2555
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
2556
+ parcelHelpers.defineInteropFlag(exports);
2557
+ parcelHelpers.export(exports, "Dialog", ()=>Dialog);
2558
+ parcelHelpers.export(exports, "DialogPortal", ()=>DialogPortal);
2559
+ parcelHelpers.export(exports, "DialogOverlay", ()=>DialogOverlay);
2560
+ parcelHelpers.export(exports, "DialogClose", ()=>DialogClose);
2561
+ parcelHelpers.export(exports, "DialogTrigger", ()=>DialogTrigger);
2562
+ parcelHelpers.export(exports, "DialogContent", ()=>DialogContent);
2563
+ parcelHelpers.export(exports, "DialogHeader", ()=>DialogHeader);
2564
+ parcelHelpers.export(exports, "DialogFooter", ()=>DialogFooter);
2565
+ parcelHelpers.export(exports, "DialogTitle", ()=>DialogTitle);
2566
+ parcelHelpers.export(exports, "DialogDescription", ()=>DialogDescription);
2567
+ var _jsxRuntime = require("react/jsx-runtime");
2568
+ var _react = require("react");
2569
+ var _reactDialog = require("@radix-ui/react-dialog");
2570
+ var _utils = require("@/lib/utils");
2571
+ var _zIndex = require("@/lib/z-index");
2572
+ var _s = $RefreshSig$();
2573
+ const Dialog = _reactDialog.Root;
2574
+ const DialogTrigger = _reactDialog.Trigger;
2575
+ const DialogPortal = _reactDialog.Portal;
2576
+ const DialogClose = _reactDialog.Close;
2577
+ const DialogOverlay = /*#__PURE__*/ (0, _react.forwardRef)(_c = ({ className, ...props }, ref)=>(0, _jsxRuntime.jsx)(_reactDialog.Overlay, {
2578
+ ref: ref,
2579
+ "data-dialog-overlay": true,
2580
+ className: (0, _utils.cn)('fixed inset-0 bg-[hsl(var(--background)/0.8)] backdrop-blur-[1px]', className),
2581
+ style: {
2582
+ zIndex: (0, _zIndex.Z_INDEX).MODAL_OVERLAY
2583
+ },
2584
+ ...props
2585
+ }));
2586
+ _c1 = DialogOverlay;
2587
+ DialogOverlay.displayName = _reactDialog.Overlay.displayName;
2588
+ const DialogContent = /*#__PURE__*/ _s((0, _react.forwardRef)(_c2 = _s(({ className, children, onPointerDownOutside, hideCloseButton, ...props }, ref)=>{
2589
+ _s();
2590
+ const hasContent = (0, _react.Children).count(children) > 2;
2591
+ const handlePointerDownOutside = (0, _react.useCallback)((event)=>{
2592
+ const target = event?.target;
2593
+ if (target?.closest?.('[data-sonner-toaster]')) event.preventDefault();
2594
+ onPointerDownOutside?.(event);
2595
+ }, [
2596
+ onPointerDownOutside
2597
+ ]);
2598
+ return (0, _jsxRuntime.jsxs)(DialogPortal, {
2599
+ children: [
2600
+ (0, _jsxRuntime.jsx)(DialogOverlay, {}),
2601
+ (0, _jsxRuntime.jsxs)(_reactDialog.Content, {
2602
+ ref: ref,
2603
+ "data-dialog-content": true,
2604
+ "data-has-content": hasContent,
2605
+ className: (0, _utils.cn)('fixed left-[50%] top-[50%] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-6 border bg-background px-6 pt-0 pb-0 shadow-lg sm:rounded-lg', 'data-[has-content=false]:gap-0 data-[has-content=false]:[&>[data-dialog-header]]:border-b-0 data-[has-content=false]:[&>[data-dialog-header]]:pb-0', className),
2606
+ style: {
2607
+ backgroundColor: 'hsl(var(--background))',
2608
+ zIndex: (0, _zIndex.Z_INDEX).MODAL_CONTENT
2609
+ },
2610
+ onPointerDownOutside: handlePointerDownOutside,
2611
+ ...props,
2612
+ children: [
2613
+ children,
2614
+ !hideCloseButton && (0, _jsxRuntime.jsxs)(_reactDialog.Close, {
2615
+ className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground cursor-pointer",
2616
+ children: [
2617
+ (0, _jsxRuntime.jsxs)("svg", {
2618
+ xmlns: "http://www.w3.org/2000/svg",
2619
+ width: "24",
2620
+ height: "24",
2621
+ viewBox: "0 0 24 24",
2622
+ fill: "none",
2623
+ stroke: "currentColor",
2624
+ strokeWidth: "2",
2625
+ strokeLinecap: "round",
2626
+ strokeLinejoin: "round",
2627
+ className: "h-4 w-4",
2628
+ children: [
2629
+ (0, _jsxRuntime.jsx)("path", {
2630
+ d: "M18 6 6 18"
2631
+ }),
2632
+ (0, _jsxRuntime.jsx)("path", {
2633
+ d: "m6 6 12 12"
2634
+ })
2635
+ ]
2636
+ }),
2637
+ (0, _jsxRuntime.jsx)("span", {
2638
+ className: "sr-only",
2639
+ children: "Close"
2640
+ })
2641
+ ]
2642
+ })
2643
+ ]
2644
+ })
2645
+ ]
2646
+ });
2647
+ }, "66ZNp4bV19l/ZslHkNHUXq5vew8=")), "66ZNp4bV19l/ZslHkNHUXq5vew8=");
2648
+ _c3 = DialogContent;
2649
+ DialogContent.displayName = _reactDialog.Content.displayName;
2650
+ const DialogHeader = ({ className, ...props })=>(0, _jsxRuntime.jsx)("div", {
2651
+ "data-dialog-header": true,
2652
+ className: (0, _utils.cn)('-mx-6 flex flex-col space-y-2.5 border-b border-border/60 px-6 pt-5 pb-4 text-left', className),
2653
+ ...props
2654
+ });
2655
+ _c4 = DialogHeader;
2656
+ DialogHeader.displayName = 'DialogHeader';
2657
+ const DialogFooter = ({ className, ...props })=>(0, _jsxRuntime.jsx)("div", {
2658
+ className: (0, _utils.cn)('-mx-6 mt-4 flex flex-col-reverse gap-2 rounded-b-lg border-t border-border bg-sidebar-background px-6 py-2 text-sidebar-foreground sm:flex-row sm:justify-end sm:space-x-2 [&_button]:h-8 [&_button]:px-3 [&_button]:text-xs', className),
2659
+ ...props
2660
+ });
2661
+ _c5 = DialogFooter;
2662
+ DialogFooter.displayName = 'DialogFooter';
2663
+ const DialogTitle = /*#__PURE__*/ (0, _react.forwardRef)(_c6 = ({ className, ...props }, ref)=>(0, _jsxRuntime.jsx)(_reactDialog.Title, {
2664
+ ref: ref,
2665
+ className: (0, _utils.cn)('text-lg font-semibold leading-none tracking-tight', className),
2666
+ ...props
2667
+ }));
2668
+ _c7 = DialogTitle;
2669
+ DialogTitle.displayName = _reactDialog.Title.displayName;
2670
+ const DialogDescription = /*#__PURE__*/ (0, _react.forwardRef)(_c8 = ({ className, ...props }, ref)=>(0, _jsxRuntime.jsx)(_reactDialog.Description, {
2671
+ ref: ref,
2672
+ className: (0, _utils.cn)('text-sm text-muted-foreground', className),
2673
+ ...props
2674
+ }));
2675
+ _c9 = DialogDescription;
2676
+ DialogDescription.displayName = _reactDialog.Description.displayName;
2677
+ var _c, _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8, _c9;
2678
+ $RefreshReg$(_c, "DialogOverlay$forwardRef");
2679
+ $RefreshReg$(_c1, "DialogOverlay");
2680
+ $RefreshReg$(_c2, "DialogContent$forwardRef");
2681
+ $RefreshReg$(_c3, "DialogContent");
2682
+ $RefreshReg$(_c4, "DialogHeader");
2683
+ $RefreshReg$(_c5, "DialogFooter");
2684
+ $RefreshReg$(_c6, "DialogTitle$forwardRef");
2685
+ $RefreshReg$(_c7, "DialogTitle");
2686
+ $RefreshReg$(_c8, "DialogDescription$forwardRef");
2687
+ $RefreshReg$(_c9, "DialogDescription");
2688
+
2689
+ $parcel$ReactRefreshHelpers$08a3.postlude(module);
2690
+ } finally {
2691
+ globalThis.$RefreshReg$ = prevRefreshReg;
2692
+ globalThis.$RefreshSig$ = prevRefreshSig;
2693
+ }
2694
+ },{"react/jsx-runtime":"05iiF","react":"jMk1U","@radix-ui/react-dialog":"5HLWS","@/lib/utils":"58RPa","@/lib/z-index":"eChN4","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"ds6aU":[function(require,module,exports,__globalThis) {
2695
+ var $parcel$ReactRefreshHelpers$b49c = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
2696
+ $parcel$ReactRefreshHelpers$b49c.init();
2697
+ var prevRefreshReg = globalThis.$RefreshReg$;
2698
+ var prevRefreshSig = globalThis.$RefreshSig$;
2699
+ $parcel$ReactRefreshHelpers$b49c.prelude(module);
2700
+
2701
+ try {
2702
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
2703
+ parcelHelpers.defineInteropFlag(exports);
2704
+ parcelHelpers.export(exports, "Drawer", ()=>Drawer);
2705
+ parcelHelpers.export(exports, "DrawerTrigger", ()=>DrawerTrigger);
2706
+ parcelHelpers.export(exports, "DrawerPortal", ()=>DrawerPortal);
2707
+ parcelHelpers.export(exports, "DrawerOverlay", ()=>DrawerOverlay);
2708
+ parcelHelpers.export(exports, "DrawerContent", ()=>DrawerContent);
2709
+ parcelHelpers.export(exports, "DrawerClose", ()=>DrawerClose);
2710
+ parcelHelpers.export(exports, "DrawerHeader", ()=>DrawerHeader);
2711
+ parcelHelpers.export(exports, "DrawerFooter", ()=>DrawerFooter);
2712
+ parcelHelpers.export(exports, "DrawerTitle", ()=>DrawerTitle);
2713
+ parcelHelpers.export(exports, "DrawerDescription", ()=>DrawerDescription);
2714
+ parcelHelpers.export(exports, "DrawerHandle", ()=>DrawerHandle);
2715
+ var _jsxRuntime = require("react/jsx-runtime");
2716
+ var _react = require("react");
2717
+ var _vaul = require("vaul");
2718
+ var _utils = require("@/lib/utils");
2719
+ var _zIndex = require("@/lib/z-index");
2720
+ 'use client';
2721
+ const Drawer = ({ open, onOpenChange, direction = 'right', ...props })=>(0, _jsxRuntime.jsx)((0, _vaul.Drawer).Root, {
2722
+ open: open,
2723
+ onOpenChange: onOpenChange,
2724
+ direction: direction,
2725
+ ...props
2726
+ });
2727
+ _c = Drawer;
2728
+ Drawer.displayName = 'Drawer';
2729
+ const DrawerTrigger = (0, _vaul.Drawer).Trigger;
2730
+ DrawerTrigger.displayName = 'DrawerTrigger';
2731
+ const DrawerPortal = (0, _vaul.Drawer).Portal;
2732
+ DrawerPortal.displayName = 'DrawerPortal';
2733
+ const DrawerOverlay = /*#__PURE__*/ (0, _react.forwardRef)(_c1 = ({ className, ...props }, ref)=>(0, _jsxRuntime.jsx)((0, _vaul.Drawer).Overlay, {
2734
+ ref: ref,
2735
+ "data-drawer-overlay": true,
2736
+ className: (0, _utils.cn)('fixed inset-0 bg-[hsl(var(--background)/0.8)] backdrop-blur-[1px]', className),
2737
+ style: {
2738
+ zIndex: (0, _zIndex.Z_INDEX).DRAWER_OVERLAY
2739
+ },
2740
+ ...props
2741
+ }));
2742
+ _c2 = DrawerOverlay;
2743
+ DrawerOverlay.displayName = (0, _vaul.Drawer).Overlay.displayName;
2744
+ /** Base layout classes per direction — max dimension is applied via style so size prop can override. */ const drawerContentByDirection = {
2745
+ bottom: 'fixed inset-x-0 bottom-0 mt-24 flex h-auto flex-col border border-border bg-background',
2746
+ top: 'fixed inset-x-0 top-0 mb-24 flex h-auto flex-col border border-border bg-background',
2747
+ left: 'fixed inset-y-0 left-0 mr-24 flex h-full w-auto flex-col border border-border bg-background',
2748
+ right: 'fixed inset-y-0 right-0 ml-24 flex h-full w-auto flex-col border border-border bg-background'
2749
+ };
2750
+ const DrawerContent = /*#__PURE__*/ (0, _react.forwardRef)(_c3 = ({ className, direction = 'right', size, children, style, ...props }, ref)=>{
2751
+ const pos = direction;
2752
+ const isVertical = pos === 'top' || pos === 'bottom';
2753
+ // Set dimension via inline style; use both width/height and max so Vaul/defaults don't override.
2754
+ const effectiveSize = size?.trim() || (isVertical ? '80vh' : '80vw');
2755
+ const sizeStyle = isVertical ? {
2756
+ height: effectiveSize,
2757
+ maxHeight: effectiveSize
2758
+ } : {
2759
+ width: effectiveSize,
2760
+ maxWidth: effectiveSize
2761
+ };
2762
+ return (0, _jsxRuntime.jsxs)(DrawerPortal, {
2763
+ children: [
2764
+ (0, _jsxRuntime.jsx)(DrawerOverlay, {}),
2765
+ (0, _jsxRuntime.jsxs)((0, _vaul.Drawer).Content, {
2766
+ ref: ref,
2767
+ "data-drawer-content": true,
2768
+ className: (0, _utils.cn)('outline-none', drawerContentByDirection[pos], className),
2769
+ style: {
2770
+ backgroundColor: 'hsl(var(--background))',
2771
+ zIndex: (0, _zIndex.Z_INDEX).DRAWER_CONTENT,
2772
+ ...sizeStyle,
2773
+ ...style
2774
+ },
2775
+ ...props,
2776
+ children: [
2777
+ children,
2778
+ (0, _jsxRuntime.jsxs)((0, _vaul.Drawer).Close, {
2779
+ className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground cursor-pointer",
2780
+ "aria-label": "Close",
2781
+ children: [
2782
+ (0, _jsxRuntime.jsxs)("svg", {
2783
+ xmlns: "http://www.w3.org/2000/svg",
2784
+ width: "24",
2785
+ height: "24",
2786
+ viewBox: "0 0 24 24",
2787
+ fill: "none",
2788
+ stroke: "currentColor",
2789
+ strokeWidth: "2",
2790
+ strokeLinecap: "round",
2791
+ strokeLinejoin: "round",
2792
+ className: "h-4 w-4",
2793
+ children: [
2794
+ (0, _jsxRuntime.jsx)("path", {
2795
+ d: "M18 6 6 18"
2796
+ }),
2797
+ (0, _jsxRuntime.jsx)("path", {
2798
+ d: "m6 6 12 12"
2799
+ })
2800
+ ]
2801
+ }),
2802
+ (0, _jsxRuntime.jsx)("span", {
2803
+ className: "sr-only",
2804
+ children: "Close"
2805
+ })
2806
+ ]
2807
+ })
2808
+ ]
2809
+ })
2810
+ ]
2811
+ });
2812
+ });
2813
+ _c4 = DrawerContent;
2814
+ DrawerContent.displayName = 'DrawerContent';
2815
+ const DrawerClose = (0, _vaul.Drawer).Close;
2816
+ DrawerClose.displayName = 'DrawerClose';
2817
+ const DrawerHeader = ({ className, ...props })=>(0, _jsxRuntime.jsx)("div", {
2818
+ "data-drawer-header": true,
2819
+ className: (0, _utils.cn)('flex flex-col space-y-2 border-b border-border/60 px-6 pt-5 pb-4 text-left', className),
2820
+ ...props
2821
+ });
2822
+ _c5 = DrawerHeader;
2823
+ DrawerHeader.displayName = 'DrawerHeader';
2824
+ const DrawerFooter = ({ className, ...props })=>(0, _jsxRuntime.jsx)("div", {
2825
+ className: (0, _utils.cn)('mt-auto flex flex-col-reverse gap-2 border-t border-border px-6 py-4 sm:flex-row sm:justify-end', className),
2826
+ ...props
2827
+ });
2828
+ _c6 = DrawerFooter;
2829
+ DrawerFooter.displayName = 'DrawerFooter';
2830
+ const DrawerTitle = /*#__PURE__*/ (0, _react.forwardRef)(_c7 = ({ className, ...props }, ref)=>(0, _jsxRuntime.jsx)((0, _vaul.Drawer).Title, {
2831
+ ref: ref,
2832
+ className: (0, _utils.cn)('text-lg font-semibold leading-none tracking-tight', className),
2833
+ ...props
2834
+ }));
2835
+ _c8 = DrawerTitle;
2836
+ DrawerTitle.displayName = (0, _vaul.Drawer).Title.displayName;
2837
+ const DrawerDescription = /*#__PURE__*/ (0, _react.forwardRef)(_c9 = ({ className, ...props }, ref)=>(0, _jsxRuntime.jsx)((0, _vaul.Drawer).Description, {
2838
+ ref: ref,
2839
+ className: (0, _utils.cn)('text-sm text-muted-foreground', className),
2840
+ ...props
2841
+ }));
2842
+ _c10 = DrawerDescription;
2843
+ DrawerDescription.displayName = (0, _vaul.Drawer).Description.displayName;
2844
+ const DrawerHandle = ({ className, ...props })=>(0, _jsxRuntime.jsx)("div", {
2845
+ "data-drawer-handle": true,
2846
+ className: (0, _utils.cn)('mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted', className),
2847
+ ...props
2848
+ });
2849
+ _c11 = DrawerHandle;
2850
+ DrawerHandle.displayName = 'DrawerHandle';
2851
+ var _c, _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8, _c9, _c10, _c11;
2852
+ $RefreshReg$(_c, "Drawer");
2853
+ $RefreshReg$(_c1, "DrawerOverlay$forwardRef");
2854
+ $RefreshReg$(_c2, "DrawerOverlay");
2855
+ $RefreshReg$(_c3, "DrawerContent$forwardRef");
2856
+ $RefreshReg$(_c4, "DrawerContent");
2857
+ $RefreshReg$(_c5, "DrawerHeader");
2858
+ $RefreshReg$(_c6, "DrawerFooter");
2859
+ $RefreshReg$(_c7, "DrawerTitle$forwardRef");
2860
+ $RefreshReg$(_c8, "DrawerTitle");
2861
+ $RefreshReg$(_c9, "DrawerDescription$forwardRef");
2862
+ $RefreshReg$(_c10, "DrawerDescription");
2863
+ $RefreshReg$(_c11, "DrawerHandle");
2864
+
2865
+ $parcel$ReactRefreshHelpers$b49c.postlude(module);
2866
+ } finally {
2867
+ globalThis.$RefreshReg$ = prevRefreshReg;
2868
+ globalThis.$RefreshSig$ = prevRefreshSig;
2869
+ }
2870
+ },{"react/jsx-runtime":"05iiF","react":"jMk1U","vaul":"eIxhV","@/lib/utils":"58RPa","@/lib/z-index":"eChN4","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}],"eIxhV":[function(require,module,exports,__globalThis) {
2871
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
2872
+ parcelHelpers.defineInteropFlag(exports);
2873
+ parcelHelpers.export(exports, "Content", ()=>Content);
2874
+ parcelHelpers.export(exports, "Drawer", ()=>Drawer);
2875
+ parcelHelpers.export(exports, "Handle", ()=>Handle);
2876
+ parcelHelpers.export(exports, "NestedRoot", ()=>NestedRoot);
2877
+ parcelHelpers.export(exports, "Overlay", ()=>Overlay);
2878
+ parcelHelpers.export(exports, "Portal", ()=>Portal);
2879
+ parcelHelpers.export(exports, "Root", ()=>Root);
2880
+ var _reactDialog = require("@radix-ui/react-dialog");
2881
+ var _react = require("react");
2882
+ var _reactDefault = parcelHelpers.interopDefault(_react);
2883
+ 'use client';
2884
+ function __insertCSS(code) {
2885
+ if (!code || typeof document == 'undefined') return;
2886
+ let head = document.head || document.getElementsByTagName('head')[0];
2887
+ let style = document.createElement('style');
2888
+ style.type = 'text/css';
2889
+ head.appendChild(style);
2890
+ style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
2891
+ }
2892
+ const DrawerContext = (0, _reactDefault.default).createContext({
2893
+ drawerRef: {
2894
+ current: null
2895
+ },
2896
+ overlayRef: {
2897
+ current: null
2898
+ },
2899
+ onPress: ()=>{},
2900
+ onRelease: ()=>{},
2901
+ onDrag: ()=>{},
2902
+ onNestedDrag: ()=>{},
2903
+ onNestedOpenChange: ()=>{},
2904
+ onNestedRelease: ()=>{},
2905
+ openProp: undefined,
2906
+ dismissible: false,
2907
+ isOpen: false,
2908
+ isDragging: false,
2909
+ keyboardIsOpen: {
2910
+ current: false
2911
+ },
2912
+ snapPointsOffset: null,
2913
+ snapPoints: null,
2914
+ handleOnly: false,
2915
+ modal: false,
2916
+ shouldFade: false,
2917
+ activeSnapPoint: null,
2918
+ onOpenChange: ()=>{},
2919
+ setActiveSnapPoint: ()=>{},
2920
+ closeDrawer: ()=>{},
2921
+ direction: 'bottom',
2922
+ shouldAnimate: {
2923
+ current: true
2924
+ },
2925
+ shouldScaleBackground: false,
2926
+ setBackgroundColorOnScale: true,
2927
+ noBodyStyles: false,
2928
+ container: null,
2929
+ autoFocus: false
2930
+ });
2931
+ const useDrawerContext = ()=>{
2932
+ const context = (0, _reactDefault.default).useContext(DrawerContext);
2933
+ if (!context) throw new Error('useDrawerContext must be used within a Drawer.Root');
2934
+ return context;
2935
+ };
2936
+ __insertCSS("[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(\n[data-state=closed]\n){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}");
2937
+ function isMobileFirefox() {
2938
+ const userAgent = navigator.userAgent;
2939
+ return typeof window !== 'undefined' && (/Firefox/.test(userAgent) && /Mobile/.test(userAgent) || // Android Firefox
2940
+ /FxiOS/.test(userAgent) // iOS Firefox
2941
+ );
2942
+ }
2943
+ function isMac() {
2944
+ return testPlatform(/^Mac/);
2945
+ }
2946
+ function isIPhone() {
2947
+ return testPlatform(/^iPhone/);
2948
+ }
2949
+ function isSafari() {
2950
+ return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
2951
+ }
2952
+ function isIPad() {
2953
+ return testPlatform(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
2954
+ isMac() && navigator.maxTouchPoints > 1;
2955
+ }
2956
+ function isIOS() {
2957
+ return isIPhone() || isIPad();
2958
+ }
2959
+ function testPlatform(re) {
2960
+ return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : undefined;
2961
+ }
2962
+ // This code comes from https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/overlays/src/usePreventScroll.ts
2963
+ const KEYBOARD_BUFFER = 24;
2964
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? (0, _react.useLayoutEffect) : (0, _react.useEffect);
2965
+ function chain$1(...callbacks) {
2966
+ return (...args)=>{
2967
+ for (let callback of callbacks)if (typeof callback === 'function') callback(...args);
2968
+ };
2969
+ }
2970
+ // @ts-ignore
2971
+ const visualViewport = typeof document !== 'undefined' && window.visualViewport;
2972
+ function isScrollable(node) {
2973
+ let style = window.getComputedStyle(node);
2974
+ return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
2975
+ }
2976
+ function getScrollParent(node) {
2977
+ if (isScrollable(node)) node = node.parentElement;
2978
+ while(node && !isScrollable(node))node = node.parentElement;
2979
+ return node || document.scrollingElement || document.documentElement;
2980
+ }
2981
+ // HTML input types that do not cause the software keyboard to appear.
2982
+ const nonTextInputTypes = new Set([
2983
+ 'checkbox',
2984
+ 'radio',
2985
+ 'range',
2986
+ 'color',
2987
+ 'file',
2988
+ 'image',
2989
+ 'button',
2990
+ 'submit',
2991
+ 'reset'
2992
+ ]);
2993
+ // The number of active usePreventScroll calls. Used to determine whether to revert back to the original page style/scroll position
2994
+ let preventScrollCount = 0;
2995
+ let restore;
2996
+ /**
2997
+ * Prevents scrolling on the document body on mount, and
2998
+ * restores it on unmount. Also ensures that content does not
2999
+ * shift due to the scrollbars disappearing.
3000
+ */ function usePreventScroll(options = {}) {
3001
+ let { isDisabled } = options;
3002
+ useIsomorphicLayoutEffect(()=>{
3003
+ if (isDisabled) return;
3004
+ preventScrollCount++;
3005
+ if (preventScrollCount === 1) {
3006
+ if (isIOS()) restore = preventScrollMobileSafari();
3007
+ }
3008
+ return ()=>{
3009
+ preventScrollCount--;
3010
+ if (preventScrollCount === 0) restore == null || restore();
3011
+ };
3012
+ }, [
3013
+ isDisabled
3014
+ ]);
3015
+ }
3016
+ // Mobile Safari is a whole different beast. Even with overflow: hidden,
3017
+ // it still scrolls the page in many situations:
3018
+ //
3019
+ // 1. When the bottom toolbar and address bar are collapsed, page scrolling is always allowed.
3020
+ // 2. When the keyboard is visible, the viewport does not resize. Instead, the keyboard covers part of
3021
+ // it, so it becomes scrollable.
3022
+ // 3. When tapping on an input, the page always scrolls so that the input is centered in the visual viewport.
3023
+ // This may cause even fixed position elements to scroll off the screen.
3024
+ // 4. When using the next/previous buttons in the keyboard to navigate between inputs, the whole page always
3025
+ // scrolls, even if the input is inside a nested scrollable element that could be scrolled instead.
3026
+ //
3027
+ // In order to work around these cases, and prevent scrolling without jankiness, we do a few things:
3028
+ //
3029
+ // 1. Prevent default on `touchmove` events that are not in a scrollable element. This prevents touch scrolling
3030
+ // on the window.
3031
+ // 2. Prevent default on `touchmove` events inside a scrollable element when the scroll position is at the
3032
+ // top or bottom. This avoids the whole page scrolling instead, but does prevent overscrolling.
3033
+ // 3. Prevent default on `touchend` events on input elements and handle focusing the element ourselves.
3034
+ // 4. When focusing an input, apply a transform to trick Safari into thinking the input is at the top
3035
+ // of the page, which prevents it from scrolling the page. After the input is focused, scroll the element
3036
+ // into view ourselves, without scrolling the whole page.
3037
+ // 5. Offset the body by the scroll position using a negative margin and scroll to the top. This should appear the
3038
+ // same visually, but makes the actual scroll position always zero. This is required to make all of the
3039
+ // above work or Safari will still try to scroll the page when focusing an input.
3040
+ // 6. As a last resort, handle window scroll events, and scroll back to the top. This can happen when attempting
3041
+ // to navigate to an input with the next/previous buttons that's outside a modal.
3042
+ function preventScrollMobileSafari() {
3043
+ let scrollable;
3044
+ let lastY = 0;
3045
+ let onTouchStart = (e)=>{
3046
+ // Store the nearest scrollable parent element from the element that the user touched.
3047
+ scrollable = getScrollParent(e.target);
3048
+ if (scrollable === document.documentElement && scrollable === document.body) return;
3049
+ lastY = e.changedTouches[0].pageY;
3050
+ };
3051
+ let onTouchMove = (e)=>{
3052
+ // Prevent scrolling the window.
3053
+ if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
3054
+ e.preventDefault();
3055
+ return;
3056
+ }
3057
+ // Prevent scrolling up when at the top and scrolling down when at the bottom
3058
+ // of a nested scrollable area, otherwise mobile Safari will start scrolling
3059
+ // the window instead. Unfortunately, this disables bounce scrolling when at
3060
+ // the top but it's the best we can do.
3061
+ let y = e.changedTouches[0].pageY;
3062
+ let scrollTop = scrollable.scrollTop;
3063
+ let bottom = scrollable.scrollHeight - scrollable.clientHeight;
3064
+ if (bottom === 0) return;
3065
+ if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) e.preventDefault();
3066
+ lastY = y;
3067
+ };
3068
+ let onTouchEnd = (e)=>{
3069
+ let target = e.target;
3070
+ // Apply this change if we're not already focused on the target element
3071
+ if (isInput(target) && target !== document.activeElement) {
3072
+ e.preventDefault();
3073
+ // Apply a transform to trick Safari into thinking the input is at the top of the page
3074
+ // so it doesn't try to scroll it into view. When tapping on an input, this needs to
3075
+ // be done before the "focus" event, so we have to focus the element ourselves.
3076
+ target.style.transform = 'translateY(-2000px)';
3077
+ target.focus();
3078
+ requestAnimationFrame(()=>{
3079
+ target.style.transform = '';
3080
+ });
3081
+ }
3082
+ };
3083
+ let onFocus = (e)=>{
3084
+ let target = e.target;
3085
+ if (isInput(target)) {
3086
+ // Transform also needs to be applied in the focus event in cases where focus moves
3087
+ // other than tapping on an input directly, e.g. the next/previous buttons in the
3088
+ // software keyboard. In these cases, it seems applying the transform in the focus event
3089
+ // is good enough, whereas when tapping an input, it must be done before the focus event. 🤷‍♂️
3090
+ target.style.transform = 'translateY(-2000px)';
3091
+ requestAnimationFrame(()=>{
3092
+ target.style.transform = '';
3093
+ // This will have prevented the browser from scrolling the focused element into view,
3094
+ // so we need to do this ourselves in a way that doesn't cause the whole page to scroll.
3095
+ if (visualViewport) {
3096
+ if (visualViewport.height < window.innerHeight) // If the keyboard is already visible, do this after one additional frame
3097
+ // to wait for the transform to be removed.
3098
+ requestAnimationFrame(()=>{
3099
+ scrollIntoView(target);
3100
+ });
3101
+ else // Otherwise, wait for the visual viewport to resize before scrolling so we can
3102
+ // measure the correct position to scroll to.
3103
+ visualViewport.addEventListener('resize', ()=>scrollIntoView(target), {
3104
+ once: true
3105
+ });
3106
+ }
3107
+ });
3108
+ }
3109
+ };
3110
+ let onWindowScroll = ()=>{
3111
+ // Last resort. If the window scrolled, scroll it back to the top.
3112
+ // It should always be at the top because the body will have a negative margin (see below).
3113
+ window.scrollTo(0, 0);
3114
+ };
3115
+ // Record the original scroll position so we can restore it.
3116
+ // Then apply a negative margin to the body to offset it by the scroll position. This will
3117
+ // enable us to scroll the window to the top, which is required for the rest of this to work.
3118
+ let scrollX = window.pageXOffset;
3119
+ let scrollY = window.pageYOffset;
3120
+ let restoreStyles = chain$1(setStyle(document.documentElement, 'paddingRight', `${window.innerWidth - document.documentElement.clientWidth}px`));
3121
+ // Scroll to the top. The negative margin on the body will make this appear the same.
3122
+ window.scrollTo(0, 0);
3123
+ let removeEvents = chain$1(addEvent(document, 'touchstart', onTouchStart, {
3124
+ passive: false,
3125
+ capture: true
3126
+ }), addEvent(document, 'touchmove', onTouchMove, {
3127
+ passive: false,
3128
+ capture: true
3129
+ }), addEvent(document, 'touchend', onTouchEnd, {
3130
+ passive: false,
3131
+ capture: true
3132
+ }), addEvent(document, 'focus', onFocus, true), addEvent(window, 'scroll', onWindowScroll));
3133
+ return ()=>{
3134
+ // Restore styles and scroll the page back to where it was.
3135
+ restoreStyles();
3136
+ removeEvents();
3137
+ window.scrollTo(scrollX, scrollY);
3138
+ };
3139
+ }
3140
+ // Sets a CSS property on an element, and returns a function to revert it to the previous value.
3141
+ function setStyle(element, style, value) {
3142
+ // https://github.com/microsoft/TypeScript/issues/17827#issuecomment-391663310
3143
+ // @ts-ignore
3144
+ let cur = element.style[style];
3145
+ // @ts-ignore
3146
+ element.style[style] = value;
3147
+ return ()=>{
3148
+ // @ts-ignore
3149
+ element.style[style] = cur;
3150
+ };
3151
+ }
3152
+ // Adds an event listener to an element, and returns a function to remove it.
3153
+ function addEvent(target, event, handler, options) {
3154
+ // @ts-ignore
3155
+ target.addEventListener(event, handler, options);
3156
+ return ()=>{
3157
+ // @ts-ignore
3158
+ target.removeEventListener(event, handler, options);
3159
+ };
3160
+ }
3161
+ function scrollIntoView(target) {
3162
+ let root = document.scrollingElement || document.documentElement;
3163
+ while(target && target !== root){
3164
+ // Find the parent scrollable element and adjust the scroll position if the target is not already in view.
3165
+ let scrollable = getScrollParent(target);
3166
+ if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
3167
+ let scrollableTop = scrollable.getBoundingClientRect().top;
3168
+ let targetTop = target.getBoundingClientRect().top;
3169
+ let targetBottom = target.getBoundingClientRect().bottom;
3170
+ // Buffer is needed for some edge cases
3171
+ const keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
3172
+ if (targetBottom > keyboardHeight) scrollable.scrollTop += targetTop - scrollableTop;
3173
+ }
3174
+ // @ts-ignore
3175
+ target = scrollable.parentElement;
3176
+ }
3177
+ }
3178
+ function isInput(target) {
3179
+ return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
3180
+ }
3181
+ // This code comes from https://github.com/radix-ui/primitives/tree/main/packages/react/compose-refs
3182
+ /**
3183
+ * Set a given ref to a given value
3184
+ * This utility takes care of different types of refs: callback refs and RefObject(s)
3185
+ */ function setRef(ref, value) {
3186
+ if (typeof ref === 'function') ref(value);
3187
+ else if (ref !== null && ref !== undefined) ref.current = value;
3188
+ }
3189
+ /**
3190
+ * A utility to compose multiple refs together
3191
+ * Accepts callback refs and RefObject(s)
3192
+ */ function composeRefs(...refs) {
3193
+ return (node)=>refs.forEach((ref)=>setRef(ref, node));
3194
+ }
3195
+ /**
3196
+ * A custom hook that composes multiple refs
3197
+ * Accepts callback refs and RefObject(s)
3198
+ */ function useComposedRefs(...refs) {
3199
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3200
+ return _react.useCallback(composeRefs(...refs), refs);
3201
+ }
3202
+ const cache = new WeakMap();
3203
+ function set(el, styles, ignoreCache = false) {
3204
+ if (!el || !(el instanceof HTMLElement)) return;
3205
+ let originalStyles = {};
3206
+ Object.entries(styles).forEach(([key, value])=>{
3207
+ if (key.startsWith('--')) {
3208
+ el.style.setProperty(key, value);
3209
+ return;
3210
+ }
3211
+ originalStyles[key] = el.style[key];
3212
+ el.style[key] = value;
3213
+ });
3214
+ if (ignoreCache) return;
3215
+ cache.set(el, originalStyles);
3216
+ }
3217
+ function reset(el, prop) {
3218
+ if (!el || !(el instanceof HTMLElement)) return;
3219
+ let originalStyles = cache.get(el);
3220
+ if (!originalStyles) return;
3221
+ el.style[prop] = originalStyles[prop];
3222
+ }
3223
+ const isVertical = (direction)=>{
3224
+ switch(direction){
3225
+ case 'top':
3226
+ case 'bottom':
3227
+ return true;
3228
+ case 'left':
3229
+ case 'right':
3230
+ return false;
3231
+ default:
3232
+ return direction;
3233
+ }
3234
+ };
3235
+ function getTranslate(element, direction) {
3236
+ if (!element) return null;
3237
+ const style = window.getComputedStyle(element);
3238
+ const transform = style.transform || style.webkitTransform || style.mozTransform;
3239
+ let mat = transform.match(/^matrix3d\((.+)\)$/);
3240
+ if (mat) // https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d
3241
+ return parseFloat(mat[1].split(', ')[isVertical(direction) ? 13 : 12]);
3242
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix
3243
+ mat = transform.match(/^matrix\((.+)\)$/);
3244
+ return mat ? parseFloat(mat[1].split(', ')[isVertical(direction) ? 5 : 4]) : null;
3245
+ }
3246
+ function dampenValue(v) {
3247
+ return 8 * (Math.log(v + 1) - 2);
3248
+ }
3249
+ function assignStyle(element, style) {
3250
+ if (!element) return ()=>{};
3251
+ const prevStyle = element.style.cssText;
3252
+ Object.assign(element.style, style);
3253
+ return ()=>{
3254
+ element.style.cssText = prevStyle;
3255
+ };
3256
+ }
3257
+ /**
3258
+ * Receives functions as arguments and returns a new function that calls all.
3259
+ */ function chain(...fns) {
3260
+ return (...args)=>{
3261
+ for (const fn of fns)if (typeof fn === 'function') // @ts-ignore
3262
+ fn(...args);
3263
+ };
3264
+ }
3265
+ const TRANSITIONS = {
3266
+ DURATION: 0.5,
3267
+ EASE: [
3268
+ 0.32,
3269
+ 0.72,
3270
+ 0,
3271
+ 1
3272
+ ]
3273
+ };
3274
+ const VELOCITY_THRESHOLD = 0.4;
3275
+ const CLOSE_THRESHOLD = 0.25;
3276
+ const SCROLL_LOCK_TIMEOUT = 100;
3277
+ const BORDER_RADIUS = 8;
3278
+ const NESTED_DISPLACEMENT = 16;
3279
+ const WINDOW_TOP_OFFSET = 26;
3280
+ const DRAG_CLASS = 'vaul-dragging';
3281
+ // This code comes from https://github.com/radix-ui/primitives/blob/main/packages/react/use-controllable-state/src/useControllableState.tsx
3282
+ function useCallbackRef(callback) {
3283
+ const callbackRef = (0, _reactDefault.default).useRef(callback);
3284
+ (0, _reactDefault.default).useEffect(()=>{
3285
+ callbackRef.current = callback;
3286
+ });
3287
+ // https://github.com/facebook/react/issues/19240
3288
+ return (0, _reactDefault.default).useMemo(()=>(...args)=>callbackRef.current == null ? void 0 : callbackRef.current.call(callbackRef, ...args), []);
3289
+ }
3290
+ function useUncontrolledState({ defaultProp, onChange }) {
3291
+ const uncontrolledState = (0, _reactDefault.default).useState(defaultProp);
3292
+ const [value] = uncontrolledState;
3293
+ const prevValueRef = (0, _reactDefault.default).useRef(value);
3294
+ const handleChange = useCallbackRef(onChange);
3295
+ (0, _reactDefault.default).useEffect(()=>{
3296
+ if (prevValueRef.current !== value) {
3297
+ handleChange(value);
3298
+ prevValueRef.current = value;
3299
+ }
3300
+ }, [
3301
+ value,
3302
+ prevValueRef,
3303
+ handleChange
3304
+ ]);
3305
+ return uncontrolledState;
3306
+ }
3307
+ function useControllableState({ prop, defaultProp, onChange = ()=>{} }) {
3308
+ const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({
3309
+ defaultProp,
3310
+ onChange
3311
+ });
3312
+ const isControlled = prop !== undefined;
3313
+ const value = isControlled ? prop : uncontrolledProp;
3314
+ const handleChange = useCallbackRef(onChange);
3315
+ const setValue = (0, _reactDefault.default).useCallback((nextValue)=>{
3316
+ if (isControlled) {
3317
+ const setter = nextValue;
3318
+ const value = typeof nextValue === 'function' ? setter(prop) : nextValue;
3319
+ if (value !== prop) handleChange(value);
3320
+ } else setUncontrolledProp(nextValue);
3321
+ }, [
3322
+ isControlled,
3323
+ prop,
3324
+ setUncontrolledProp,
3325
+ handleChange
3326
+ ]);
3327
+ return [
3328
+ value,
3329
+ setValue
3330
+ ];
3331
+ }
3332
+ function useSnapPoints({ activeSnapPointProp, setActiveSnapPointProp, snapPoints, drawerRef, overlayRef, fadeFromIndex, onSnapPointChange, direction = 'bottom', container, snapToSequentialPoint }) {
3333
+ const [activeSnapPoint, setActiveSnapPoint] = useControllableState({
3334
+ prop: activeSnapPointProp,
3335
+ defaultProp: snapPoints == null ? void 0 : snapPoints[0],
3336
+ onChange: setActiveSnapPointProp
3337
+ });
3338
+ const [windowDimensions, setWindowDimensions] = (0, _reactDefault.default).useState(typeof window !== 'undefined' ? {
3339
+ innerWidth: window.innerWidth,
3340
+ innerHeight: window.innerHeight
3341
+ } : undefined);
3342
+ (0, _reactDefault.default).useEffect(()=>{
3343
+ function onResize() {
3344
+ setWindowDimensions({
3345
+ innerWidth: window.innerWidth,
3346
+ innerHeight: window.innerHeight
3347
+ });
3348
+ }
3349
+ window.addEventListener('resize', onResize);
3350
+ return ()=>window.removeEventListener('resize', onResize);
3351
+ }, []);
3352
+ const isLastSnapPoint = (0, _reactDefault.default).useMemo(()=>activeSnapPoint === (snapPoints == null ? void 0 : snapPoints[snapPoints.length - 1]) || null, [
3353
+ snapPoints,
3354
+ activeSnapPoint
3355
+ ]);
3356
+ const activeSnapPointIndex = (0, _reactDefault.default).useMemo(()=>{
3357
+ var _snapPoints_findIndex;
3358
+ return (_snapPoints_findIndex = snapPoints == null ? void 0 : snapPoints.findIndex((snapPoint)=>snapPoint === activeSnapPoint)) != null ? _snapPoints_findIndex : null;
3359
+ }, [
3360
+ snapPoints,
3361
+ activeSnapPoint
3362
+ ]);
3363
+ const shouldFade = snapPoints && snapPoints.length > 0 && (fadeFromIndex || fadeFromIndex === 0) && !Number.isNaN(fadeFromIndex) && snapPoints[fadeFromIndex] === activeSnapPoint || !snapPoints;
3364
+ const snapPointsOffset = (0, _reactDefault.default).useMemo(()=>{
3365
+ const containerSize = container ? {
3366
+ width: container.getBoundingClientRect().width,
3367
+ height: container.getBoundingClientRect().height
3368
+ } : typeof window !== 'undefined' ? {
3369
+ width: window.innerWidth,
3370
+ height: window.innerHeight
3371
+ } : {
3372
+ width: 0,
3373
+ height: 0
3374
+ };
3375
+ var _snapPoints_map;
3376
+ return (_snapPoints_map = snapPoints == null ? void 0 : snapPoints.map((snapPoint)=>{
3377
+ const isPx = typeof snapPoint === 'string';
3378
+ let snapPointAsNumber = 0;
3379
+ if (isPx) snapPointAsNumber = parseInt(snapPoint, 10);
3380
+ if (isVertical(direction)) {
3381
+ const height = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.height : 0;
3382
+ if (windowDimensions) return direction === 'bottom' ? containerSize.height - height : -containerSize.height + height;
3383
+ return height;
3384
+ }
3385
+ const width = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.width : 0;
3386
+ if (windowDimensions) return direction === 'right' ? containerSize.width - width : -containerSize.width + width;
3387
+ return width;
3388
+ })) != null ? _snapPoints_map : [];
3389
+ }, [
3390
+ snapPoints,
3391
+ windowDimensions,
3392
+ container
3393
+ ]);
3394
+ const activeSnapPointOffset = (0, _reactDefault.default).useMemo(()=>activeSnapPointIndex !== null ? snapPointsOffset == null ? void 0 : snapPointsOffset[activeSnapPointIndex] : null, [
3395
+ snapPointsOffset,
3396
+ activeSnapPointIndex
3397
+ ]);
3398
+ const snapToPoint = (0, _reactDefault.default).useCallback((dimension)=>{
3399
+ var _snapPointsOffset_findIndex;
3400
+ const newSnapPointIndex = (_snapPointsOffset_findIndex = snapPointsOffset == null ? void 0 : snapPointsOffset.findIndex((snapPointDim)=>snapPointDim === dimension)) != null ? _snapPointsOffset_findIndex : null;
3401
+ onSnapPointChange(newSnapPointIndex);
3402
+ set(drawerRef.current, {
3403
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
3404
+ transform: isVertical(direction) ? `translate3d(0, ${dimension}px, 0)` : `translate3d(${dimension}px, 0, 0)`
3405
+ });
3406
+ if (snapPointsOffset && newSnapPointIndex !== snapPointsOffset.length - 1 && fadeFromIndex !== undefined && newSnapPointIndex !== fadeFromIndex && newSnapPointIndex < fadeFromIndex) set(overlayRef.current, {
3407
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
3408
+ opacity: '0'
3409
+ });
3410
+ else set(overlayRef.current, {
3411
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
3412
+ opacity: '1'
3413
+ });
3414
+ setActiveSnapPoint(snapPoints == null ? void 0 : snapPoints[Math.max(newSnapPointIndex, 0)]);
3415
+ }, [
3416
+ drawerRef.current,
3417
+ snapPoints,
3418
+ snapPointsOffset,
3419
+ fadeFromIndex,
3420
+ overlayRef,
3421
+ setActiveSnapPoint
3422
+ ]);
3423
+ (0, _reactDefault.default).useEffect(()=>{
3424
+ if (activeSnapPoint || activeSnapPointProp) {
3425
+ var _snapPoints_findIndex;
3426
+ const newIndex = (_snapPoints_findIndex = snapPoints == null ? void 0 : snapPoints.findIndex((snapPoint)=>snapPoint === activeSnapPointProp || snapPoint === activeSnapPoint)) != null ? _snapPoints_findIndex : -1;
3427
+ if (snapPointsOffset && newIndex !== -1 && typeof snapPointsOffset[newIndex] === 'number') snapToPoint(snapPointsOffset[newIndex]);
3428
+ }
3429
+ }, [
3430
+ activeSnapPoint,
3431
+ activeSnapPointProp,
3432
+ snapPoints,
3433
+ snapPointsOffset,
3434
+ snapToPoint
3435
+ ]);
3436
+ function onRelease({ draggedDistance, closeDrawer, velocity, dismissible }) {
3437
+ if (fadeFromIndex === undefined) return;
3438
+ const currentPosition = direction === 'bottom' || direction === 'right' ? (activeSnapPointOffset != null ? activeSnapPointOffset : 0) - draggedDistance : (activeSnapPointOffset != null ? activeSnapPointOffset : 0) + draggedDistance;
3439
+ const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
3440
+ const isFirst = activeSnapPointIndex === 0;
3441
+ const hasDraggedUp = draggedDistance > 0;
3442
+ if (isOverlaySnapPoint) set(overlayRef.current, {
3443
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`
3444
+ });
3445
+ if (!snapToSequentialPoint && velocity > 2 && !hasDraggedUp) {
3446
+ if (dismissible) closeDrawer();
3447
+ else snapToPoint(snapPointsOffset[0]); // snap to initial point
3448
+ return;
3449
+ }
3450
+ if (!snapToSequentialPoint && velocity > 2 && hasDraggedUp && snapPointsOffset && snapPoints) {
3451
+ snapToPoint(snapPointsOffset[snapPoints.length - 1]);
3452
+ return;
3453
+ }
3454
+ // Find the closest snap point to the current position
3455
+ const closestSnapPoint = snapPointsOffset == null ? void 0 : snapPointsOffset.reduce((prev, curr)=>{
3456
+ if (typeof prev !== 'number' || typeof curr !== 'number') return prev;
3457
+ return Math.abs(curr - currentPosition) < Math.abs(prev - currentPosition) ? curr : prev;
3458
+ });
3459
+ const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
3460
+ if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < dim * 0.4) {
3461
+ const dragDirection = hasDraggedUp ? 1 : -1; // 1 = up, -1 = down
3462
+ // Don't do anything if we swipe upwards while being on the last snap point
3463
+ if (dragDirection > 0 && isLastSnapPoint && snapPoints) {
3464
+ snapToPoint(snapPointsOffset[snapPoints.length - 1]);
3465
+ return;
3466
+ }
3467
+ if (isFirst && dragDirection < 0 && dismissible) closeDrawer();
3468
+ if (activeSnapPointIndex === null) return;
3469
+ snapToPoint(snapPointsOffset[activeSnapPointIndex + dragDirection]);
3470
+ return;
3471
+ }
3472
+ snapToPoint(closestSnapPoint);
3473
+ }
3474
+ function onDrag({ draggedDistance }) {
3475
+ if (activeSnapPointOffset === null) return;
3476
+ const newValue = direction === 'bottom' || direction === 'right' ? activeSnapPointOffset - draggedDistance : activeSnapPointOffset + draggedDistance;
3477
+ // Don't do anything if we exceed the last(biggest) snap point
3478
+ if ((direction === 'bottom' || direction === 'right') && newValue < snapPointsOffset[snapPointsOffset.length - 1]) return;
3479
+ if ((direction === 'top' || direction === 'left') && newValue > snapPointsOffset[snapPointsOffset.length - 1]) return;
3480
+ set(drawerRef.current, {
3481
+ transform: isVertical(direction) ? `translate3d(0, ${newValue}px, 0)` : `translate3d(${newValue}px, 0, 0)`
3482
+ });
3483
+ }
3484
+ function getPercentageDragged(absDraggedDistance, isDraggingDown) {
3485
+ if (!snapPoints || typeof activeSnapPointIndex !== 'number' || !snapPointsOffset || fadeFromIndex === undefined) return null;
3486
+ // If this is true we are dragging to a snap point that is supposed to have an overlay
3487
+ const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
3488
+ const isOverlaySnapPointOrHigher = activeSnapPointIndex >= fadeFromIndex;
3489
+ if (isOverlaySnapPointOrHigher && isDraggingDown) return 0;
3490
+ // Don't animate, but still use this one if we are dragging away from the overlaySnapPoint
3491
+ if (isOverlaySnapPoint && !isDraggingDown) return 1;
3492
+ if (!shouldFade && !isOverlaySnapPoint) return null;
3493
+ // Either fadeFrom index or the one before
3494
+ const targetSnapPointIndex = isOverlaySnapPoint ? activeSnapPointIndex + 1 : activeSnapPointIndex - 1;
3495
+ // Get the distance from overlaySnapPoint to the one before or vice-versa to calculate the opacity percentage accordingly
3496
+ const snapPointDistance = isOverlaySnapPoint ? snapPointsOffset[targetSnapPointIndex] - snapPointsOffset[targetSnapPointIndex - 1] : snapPointsOffset[targetSnapPointIndex + 1] - snapPointsOffset[targetSnapPointIndex];
3497
+ const percentageDragged = absDraggedDistance / Math.abs(snapPointDistance);
3498
+ if (isOverlaySnapPoint) return 1 - percentageDragged;
3499
+ else return percentageDragged;
3500
+ }
3501
+ return {
3502
+ isLastSnapPoint,
3503
+ activeSnapPoint,
3504
+ shouldFade,
3505
+ getPercentageDragged,
3506
+ setActiveSnapPoint,
3507
+ activeSnapPointIndex,
3508
+ onRelease,
3509
+ onDrag,
3510
+ snapPointsOffset
3511
+ };
3512
+ }
3513
+ const noop = ()=>()=>{};
3514
+ function useScaleBackground() {
3515
+ const { direction, isOpen, shouldScaleBackground, setBackgroundColorOnScale, noBodyStyles } = useDrawerContext();
3516
+ const timeoutIdRef = (0, _reactDefault.default).useRef(null);
3517
+ const initialBackgroundColor = (0, _react.useMemo)(()=>document.body.style.backgroundColor, []);
3518
+ function getScale() {
3519
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
3520
+ }
3521
+ (0, _reactDefault.default).useEffect(()=>{
3522
+ if (isOpen && shouldScaleBackground) {
3523
+ if (timeoutIdRef.current) clearTimeout(timeoutIdRef.current);
3524
+ const wrapper = document.querySelector('[data-vaul-drawer-wrapper]') || document.querySelector('[vaul-drawer-wrapper]');
3525
+ if (!wrapper) return;
3526
+ chain(setBackgroundColorOnScale && !noBodyStyles ? assignStyle(document.body, {
3527
+ background: 'black'
3528
+ }) : noop, assignStyle(wrapper, {
3529
+ transformOrigin: isVertical(direction) ? 'top' : 'left',
3530
+ transitionProperty: 'transform, border-radius',
3531
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
3532
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`
3533
+ }));
3534
+ const wrapperStylesCleanup = assignStyle(wrapper, {
3535
+ borderRadius: `${BORDER_RADIUS}px`,
3536
+ overflow: 'hidden',
3537
+ ...isVertical(direction) ? {
3538
+ transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`
3539
+ } : {
3540
+ transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
3541
+ }
3542
+ });
3543
+ return ()=>{
3544
+ wrapperStylesCleanup();
3545
+ timeoutIdRef.current = window.setTimeout(()=>{
3546
+ if (initialBackgroundColor) document.body.style.background = initialBackgroundColor;
3547
+ else document.body.style.removeProperty('background');
3548
+ }, TRANSITIONS.DURATION * 1000);
3549
+ };
3550
+ }
3551
+ }, [
3552
+ isOpen,
3553
+ shouldScaleBackground,
3554
+ initialBackgroundColor
3555
+ ]);
3556
+ }
3557
+ let previousBodyPosition = null;
3558
+ /**
3559
+ * This hook is necessary to prevent buggy behavior on iOS devices (need to test on Android).
3560
+ * I won't get into too much detail about what bugs it solves, but so far I've found that setting the body to `position: fixed` is the most reliable way to prevent those bugs.
3561
+ * Issues that this hook solves:
3562
+ * https://github.com/emilkowalski/vaul/issues/435
3563
+ * https://github.com/emilkowalski/vaul/issues/433
3564
+ * And more that I discovered, but were just not reported.
3565
+ */ function usePositionFixed({ isOpen, modal, nested, hasBeenOpened, preventScrollRestoration, noBodyStyles }) {
3566
+ const [activeUrl, setActiveUrl] = (0, _reactDefault.default).useState(()=>typeof window !== 'undefined' ? window.location.href : '');
3567
+ const scrollPos = (0, _reactDefault.default).useRef(0);
3568
+ const setPositionFixed = (0, _reactDefault.default).useCallback(()=>{
3569
+ // All browsers on iOS will return true here.
3570
+ if (!isSafari()) return;
3571
+ // If previousBodyPosition is already set, don't set it again.
3572
+ if (previousBodyPosition === null && isOpen && !noBodyStyles) {
3573
+ previousBodyPosition = {
3574
+ position: document.body.style.position,
3575
+ top: document.body.style.top,
3576
+ left: document.body.style.left,
3577
+ height: document.body.style.height,
3578
+ right: 'unset'
3579
+ };
3580
+ // Update the dom inside an animation frame
3581
+ const { scrollX, innerHeight } = window;
3582
+ document.body.style.setProperty('position', 'fixed', 'important');
3583
+ Object.assign(document.body.style, {
3584
+ top: `${-scrollPos.current}px`,
3585
+ left: `${-scrollX}px`,
3586
+ right: '0px',
3587
+ height: 'auto'
3588
+ });
3589
+ window.setTimeout(()=>window.requestAnimationFrame(()=>{
3590
+ // Attempt to check if the bottom bar appeared due to the position change
3591
+ const bottomBarHeight = innerHeight - window.innerHeight;
3592
+ if (bottomBarHeight && scrollPos.current >= innerHeight) // Move the content further up so that the bottom bar doesn't hide it
3593
+ document.body.style.top = `${-(scrollPos.current + bottomBarHeight)}px`;
3594
+ }), 300);
3595
+ }
3596
+ }, [
3597
+ isOpen
3598
+ ]);
3599
+ const restorePositionSetting = (0, _reactDefault.default).useCallback(()=>{
3600
+ // All browsers on iOS will return true here.
3601
+ if (!isSafari()) return;
3602
+ if (previousBodyPosition !== null && !noBodyStyles) {
3603
+ // Convert the position from "px" to Int
3604
+ const y = -parseInt(document.body.style.top, 10);
3605
+ const x = -parseInt(document.body.style.left, 10);
3606
+ // Restore styles
3607
+ Object.assign(document.body.style, previousBodyPosition);
3608
+ window.requestAnimationFrame(()=>{
3609
+ if (preventScrollRestoration && activeUrl !== window.location.href) {
3610
+ setActiveUrl(window.location.href);
3611
+ return;
3612
+ }
3613
+ window.scrollTo(x, y);
3614
+ });
3615
+ previousBodyPosition = null;
3616
+ }
3617
+ }, [
3618
+ activeUrl
3619
+ ]);
3620
+ (0, _reactDefault.default).useEffect(()=>{
3621
+ function onScroll() {
3622
+ scrollPos.current = window.scrollY;
3623
+ }
3624
+ onScroll();
3625
+ window.addEventListener('scroll', onScroll);
3626
+ return ()=>{
3627
+ window.removeEventListener('scroll', onScroll);
3628
+ };
3629
+ }, []);
3630
+ (0, _reactDefault.default).useEffect(()=>{
3631
+ if (!modal) return;
3632
+ return ()=>{
3633
+ if (typeof document === 'undefined') return;
3634
+ // Another drawer is opened, safe to ignore the execution
3635
+ const hasDrawerOpened = !!document.querySelector('[data-vaul-drawer]');
3636
+ if (hasDrawerOpened) return;
3637
+ restorePositionSetting();
3638
+ };
3639
+ }, [
3640
+ modal,
3641
+ restorePositionSetting
3642
+ ]);
3643
+ (0, _reactDefault.default).useEffect(()=>{
3644
+ if (nested || !hasBeenOpened) return;
3645
+ // This is needed to force Safari toolbar to show **before** the drawer starts animating to prevent a gnarly shift from happening
3646
+ if (isOpen) {
3647
+ // avoid for standalone mode (PWA)
3648
+ const isStandalone = window.matchMedia('(display-mode: standalone)').matches;
3649
+ !isStandalone && setPositionFixed();
3650
+ if (!modal) window.setTimeout(()=>{
3651
+ restorePositionSetting();
3652
+ }, 500);
3653
+ } else restorePositionSetting();
3654
+ }, [
3655
+ isOpen,
3656
+ hasBeenOpened,
3657
+ activeUrl,
3658
+ modal,
3659
+ nested,
3660
+ setPositionFixed,
3661
+ restorePositionSetting
3662
+ ]);
3663
+ return {
3664
+ restorePositionSetting
3665
+ };
3666
+ }
3667
+ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = 'bottom', defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
3668
+ var _drawerRef_current, _drawerRef_current1;
3669
+ const [isOpen = false, setIsOpen] = useControllableState({
3670
+ defaultProp: defaultOpen,
3671
+ prop: openProp,
3672
+ onChange: (o)=>{
3673
+ onOpenChange == null || onOpenChange(o);
3674
+ if (!o && !nested) restorePositionSetting();
3675
+ setTimeout(()=>{
3676
+ onAnimationEnd == null || onAnimationEnd(o);
3677
+ }, TRANSITIONS.DURATION * 1000);
3678
+ if (o && !modal) {
3679
+ if (typeof window !== 'undefined') window.requestAnimationFrame(()=>{
3680
+ document.body.style.pointerEvents = 'auto';
3681
+ });
3682
+ }
3683
+ if (!o) // This will be removed when the exit animation ends (`500ms`)
3684
+ document.body.style.pointerEvents = 'auto';
3685
+ }
3686
+ });
3687
+ const [hasBeenOpened, setHasBeenOpened] = (0, _reactDefault.default).useState(false);
3688
+ const [isDragging, setIsDragging] = (0, _reactDefault.default).useState(false);
3689
+ const [justReleased, setJustReleased] = (0, _reactDefault.default).useState(false);
3690
+ const overlayRef = (0, _reactDefault.default).useRef(null);
3691
+ const openTime = (0, _reactDefault.default).useRef(null);
3692
+ const dragStartTime = (0, _reactDefault.default).useRef(null);
3693
+ const dragEndTime = (0, _reactDefault.default).useRef(null);
3694
+ const lastTimeDragPrevented = (0, _reactDefault.default).useRef(null);
3695
+ const isAllowedToDrag = (0, _reactDefault.default).useRef(false);
3696
+ const nestedOpenChangeTimer = (0, _reactDefault.default).useRef(null);
3697
+ const pointerStart = (0, _reactDefault.default).useRef(0);
3698
+ const keyboardIsOpen = (0, _reactDefault.default).useRef(false);
3699
+ const shouldAnimate = (0, _reactDefault.default).useRef(!defaultOpen);
3700
+ const previousDiffFromInitial = (0, _reactDefault.default).useRef(0);
3701
+ const drawerRef = (0, _reactDefault.default).useRef(null);
3702
+ const drawerHeightRef = (0, _reactDefault.default).useRef(((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.getBoundingClientRect().height) || 0);
3703
+ const drawerWidthRef = (0, _reactDefault.default).useRef(((_drawerRef_current1 = drawerRef.current) == null ? void 0 : _drawerRef_current1.getBoundingClientRect().width) || 0);
3704
+ const initialDrawerHeight = (0, _reactDefault.default).useRef(0);
3705
+ const onSnapPointChange = (0, _reactDefault.default).useCallback((activeSnapPointIndex)=>{
3706
+ // Change openTime ref when we reach the last snap point to prevent dragging for 500ms incase it's scrollable.
3707
+ if (snapPoints && activeSnapPointIndex === snapPointsOffset.length - 1) openTime.current = new Date();
3708
+ }, []);
3709
+ const { activeSnapPoint, activeSnapPointIndex, setActiveSnapPoint, onRelease: onReleaseSnapPoints, snapPointsOffset, onDrag: onDragSnapPoints, shouldFade, getPercentageDragged: getSnapPointsPercentageDragged } = useSnapPoints({
3710
+ snapPoints,
3711
+ activeSnapPointProp,
3712
+ setActiveSnapPointProp,
3713
+ drawerRef,
3714
+ fadeFromIndex,
3715
+ overlayRef,
3716
+ onSnapPointChange,
3717
+ direction,
3718
+ container,
3719
+ snapToSequentialPoint
3720
+ });
3721
+ usePreventScroll({
3722
+ isDisabled: !isOpen || isDragging || !modal || justReleased || !hasBeenOpened || !repositionInputs || !disablePreventScroll
3723
+ });
3724
+ const { restorePositionSetting } = usePositionFixed({
3725
+ isOpen,
3726
+ modal,
3727
+ nested: nested != null ? nested : false,
3728
+ hasBeenOpened,
3729
+ preventScrollRestoration,
3730
+ noBodyStyles
3731
+ });
3732
+ function getScale() {
3733
+ return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
3734
+ }
3735
+ function onPress(event) {
3736
+ var _drawerRef_current, _drawerRef_current1;
3737
+ if (!dismissible && !snapPoints) return;
3738
+ if (drawerRef.current && !drawerRef.current.contains(event.target)) return;
3739
+ drawerHeightRef.current = ((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.getBoundingClientRect().height) || 0;
3740
+ drawerWidthRef.current = ((_drawerRef_current1 = drawerRef.current) == null ? void 0 : _drawerRef_current1.getBoundingClientRect().width) || 0;
3741
+ setIsDragging(true);
3742
+ dragStartTime.current = new Date();
3743
+ // iOS doesn't trigger mouseUp after scrolling so we need to listen to touched in order to disallow dragging
3744
+ if (isIOS()) window.addEventListener('touchend', ()=>isAllowedToDrag.current = false, {
3745
+ once: true
3746
+ });
3747
+ // Ensure we maintain correct pointer capture even when going outside of the drawer
3748
+ event.target.setPointerCapture(event.pointerId);
3749
+ pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
3750
+ }
3751
+ function shouldDrag(el, isDraggingInDirection) {
3752
+ var _window_getSelection;
3753
+ let element = el;
3754
+ const highlightedText = (_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString();
3755
+ const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
3756
+ const date = new Date();
3757
+ // Fixes https://github.com/emilkowalski/vaul/issues/483
3758
+ if (element.tagName === 'SELECT') return false;
3759
+ if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]')) return false;
3760
+ if (direction === 'right' || direction === 'left') return true;
3761
+ // Allow scrolling when animating
3762
+ if (openTime.current && date.getTime() - openTime.current.getTime() < 500) return false;
3763
+ if (swipeAmount !== null) {
3764
+ if (direction === 'bottom' ? swipeAmount > 0 : swipeAmount < 0) return true;
3765
+ }
3766
+ // Don't drag if there's highlighted text
3767
+ if (highlightedText && highlightedText.length > 0) return false;
3768
+ // Disallow dragging if drawer was scrolled within `scrollLockTimeout`
3769
+ if (lastTimeDragPrevented.current && date.getTime() - lastTimeDragPrevented.current.getTime() < scrollLockTimeout && swipeAmount === 0) {
3770
+ lastTimeDragPrevented.current = date;
3771
+ return false;
3772
+ }
3773
+ if (isDraggingInDirection) {
3774
+ lastTimeDragPrevented.current = date;
3775
+ // We are dragging down so we should allow scrolling
3776
+ return false;
3777
+ }
3778
+ // Keep climbing up the DOM tree as long as there's a parent
3779
+ while(element){
3780
+ // Check if the element is scrollable
3781
+ if (element.scrollHeight > element.clientHeight) {
3782
+ if (element.scrollTop !== 0) {
3783
+ lastTimeDragPrevented.current = new Date();
3784
+ // The element is scrollable and not scrolled to the top, so don't drag
3785
+ return false;
3786
+ }
3787
+ if (element.getAttribute('role') === 'dialog') return true;
3788
+ }
3789
+ // Move up to the parent element
3790
+ element = element.parentNode;
3791
+ }
3792
+ // No scrollable parents not scrolled to the top found, so drag
3793
+ return true;
3794
+ }
3795
+ function onDrag(event) {
3796
+ if (!drawerRef.current) return;
3797
+ // We need to know how much of the drawer has been dragged in percentages so that we can transform background accordingly
3798
+ if (isDragging) {
3799
+ const directionMultiplier = direction === 'bottom' || direction === 'right' ? 1 : -1;
3800
+ const draggedDistance = (pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX)) * directionMultiplier;
3801
+ const isDraggingInDirection = draggedDistance > 0;
3802
+ // Pre condition for disallowing dragging in the close direction.
3803
+ const noCloseSnapPointsPreCondition = snapPoints && !dismissible && !isDraggingInDirection;
3804
+ // Disallow dragging down to close when first snap point is the active one and dismissible prop is set to false.
3805
+ if (noCloseSnapPointsPreCondition && activeSnapPointIndex === 0) return;
3806
+ // We need to capture last time when drag with scroll was triggered and have a timeout between
3807
+ const absDraggedDistance = Math.abs(draggedDistance);
3808
+ const wrapper = document.querySelector('[data-vaul-drawer-wrapper]');
3809
+ const drawerDimension = direction === 'bottom' || direction === 'top' ? drawerHeightRef.current : drawerWidthRef.current;
3810
+ // Calculate the percentage dragged, where 1 is the closed position
3811
+ let percentageDragged = absDraggedDistance / drawerDimension;
3812
+ const snapPointPercentageDragged = getSnapPointsPercentageDragged(absDraggedDistance, isDraggingInDirection);
3813
+ if (snapPointPercentageDragged !== null) percentageDragged = snapPointPercentageDragged;
3814
+ // Disallow close dragging beyond the smallest snap point.
3815
+ if (noCloseSnapPointsPreCondition && percentageDragged >= 1) return;
3816
+ if (!isAllowedToDrag.current && !shouldDrag(event.target, isDraggingInDirection)) return;
3817
+ drawerRef.current.classList.add(DRAG_CLASS);
3818
+ // If shouldDrag gave true once after pressing down on the drawer, we set isAllowedToDrag to true and it will remain true until we let go, there's no reason to disable dragging mid way, ever, and that's the solution to it
3819
+ isAllowedToDrag.current = true;
3820
+ set(drawerRef.current, {
3821
+ transition: 'none'
3822
+ });
3823
+ set(overlayRef.current, {
3824
+ transition: 'none'
3825
+ });
3826
+ if (snapPoints) onDragSnapPoints({
3827
+ draggedDistance
3828
+ });
3829
+ // Run this only if snapPoints are not defined or if we are at the last snap point (highest one)
3830
+ if (isDraggingInDirection && !snapPoints) {
3831
+ const dampenedDraggedDistance = dampenValue(draggedDistance);
3832
+ const translateValue = Math.min(dampenedDraggedDistance * -1, 0) * directionMultiplier;
3833
+ set(drawerRef.current, {
3834
+ transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
3835
+ });
3836
+ return;
3837
+ }
3838
+ const opacityValue = 1 - percentageDragged;
3839
+ if (shouldFade || fadeFromIndex && activeSnapPointIndex === fadeFromIndex - 1) {
3840
+ onDragProp == null || onDragProp(event, percentageDragged);
3841
+ set(overlayRef.current, {
3842
+ opacity: `${opacityValue}`,
3843
+ transition: 'none'
3844
+ }, true);
3845
+ }
3846
+ if (wrapper && overlayRef.current && shouldScaleBackground) {
3847
+ // Calculate percentageDragged as a fraction (0 to 1)
3848
+ const scaleValue = Math.min(getScale() + percentageDragged * (1 - getScale()), 1);
3849
+ const borderRadiusValue = 8 - percentageDragged * 8;
3850
+ const translateValue = Math.max(0, 14 - percentageDragged * 14);
3851
+ set(wrapper, {
3852
+ borderRadius: `${borderRadiusValue}px`,
3853
+ transform: isVertical(direction) ? `scale(${scaleValue}) translate3d(0, ${translateValue}px, 0)` : `scale(${scaleValue}) translate3d(${translateValue}px, 0, 0)`,
3854
+ transition: 'none'
3855
+ }, true);
3856
+ }
3857
+ if (!snapPoints) {
3858
+ const translateValue = absDraggedDistance * directionMultiplier;
3859
+ set(drawerRef.current, {
3860
+ transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
3861
+ });
3862
+ }
3863
+ }
3864
+ }
3865
+ (0, _reactDefault.default).useEffect(()=>{
3866
+ window.requestAnimationFrame(()=>{
3867
+ shouldAnimate.current = true;
3868
+ });
3869
+ }, []);
3870
+ (0, _reactDefault.default).useEffect(()=>{
3871
+ var _window_visualViewport;
3872
+ function onVisualViewportChange() {
3873
+ if (!drawerRef.current || !repositionInputs) return;
3874
+ const focusedElement = document.activeElement;
3875
+ if (isInput(focusedElement) || keyboardIsOpen.current) {
3876
+ var _window_visualViewport;
3877
+ const visualViewportHeight = ((_window_visualViewport = window.visualViewport) == null ? void 0 : _window_visualViewport.height) || 0;
3878
+ const totalHeight = window.innerHeight;
3879
+ // This is the height of the keyboard
3880
+ let diffFromInitial = totalHeight - visualViewportHeight;
3881
+ const drawerHeight = drawerRef.current.getBoundingClientRect().height || 0;
3882
+ // Adjust drawer height only if it's tall enough
3883
+ const isTallEnough = drawerHeight > totalHeight * 0.8;
3884
+ if (!initialDrawerHeight.current) initialDrawerHeight.current = drawerHeight;
3885
+ const offsetFromTop = drawerRef.current.getBoundingClientRect().top;
3886
+ // visualViewport height may change due to somq e subtle changes to the keyboard. Checking if the height changed by 60 or more will make sure that they keyboard really changed its open state.
3887
+ if (Math.abs(previousDiffFromInitial.current - diffFromInitial) > 60) keyboardIsOpen.current = !keyboardIsOpen.current;
3888
+ if (snapPoints && snapPoints.length > 0 && snapPointsOffset && activeSnapPointIndex) {
3889
+ const activeSnapPointHeight = snapPointsOffset[activeSnapPointIndex] || 0;
3890
+ diffFromInitial += activeSnapPointHeight;
3891
+ }
3892
+ previousDiffFromInitial.current = diffFromInitial;
3893
+ // We don't have to change the height if the input is in view, when we are here we are in the opened keyboard state so we can correctly check if the input is in view
3894
+ if (drawerHeight > visualViewportHeight || keyboardIsOpen.current) {
3895
+ const height = drawerRef.current.getBoundingClientRect().height;
3896
+ let newDrawerHeight = height;
3897
+ if (height > visualViewportHeight) newDrawerHeight = visualViewportHeight - (isTallEnough ? offsetFromTop : WINDOW_TOP_OFFSET);
3898
+ // When fixed, don't move the drawer upwards if there's space, but rather only change it's height so it's fully scrollable when the keyboard is open
3899
+ if (fixed) drawerRef.current.style.height = `${height - Math.max(diffFromInitial, 0)}px`;
3900
+ else drawerRef.current.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
3901
+ } else if (!isMobileFirefox()) drawerRef.current.style.height = `${initialDrawerHeight.current}px`;
3902
+ if (snapPoints && snapPoints.length > 0 && !keyboardIsOpen.current) drawerRef.current.style.bottom = `0px`;
3903
+ else // Negative bottom value would never make sense
3904
+ drawerRef.current.style.bottom = `${Math.max(diffFromInitial, 0)}px`;
3905
+ }
3906
+ }
3907
+ (_window_visualViewport = window.visualViewport) == null || _window_visualViewport.addEventListener('resize', onVisualViewportChange);
3908
+ return ()=>{
3909
+ var _window_visualViewport;
3910
+ return (_window_visualViewport = window.visualViewport) == null ? void 0 : _window_visualViewport.removeEventListener('resize', onVisualViewportChange);
3911
+ };
3912
+ }, [
3913
+ activeSnapPointIndex,
3914
+ snapPoints,
3915
+ snapPointsOffset
3916
+ ]);
3917
+ function closeDrawer(fromWithin) {
3918
+ cancelDrag();
3919
+ onClose == null || onClose();
3920
+ if (!fromWithin) setIsOpen(false);
3921
+ setTimeout(()=>{
3922
+ if (snapPoints) setActiveSnapPoint(snapPoints[0]);
3923
+ }, TRANSITIONS.DURATION * 1000); // seconds to ms
3924
+ }
3925
+ function resetDrawer() {
3926
+ if (!drawerRef.current) return;
3927
+ const wrapper = document.querySelector('[data-vaul-drawer-wrapper]');
3928
+ const currentSwipeAmount = getTranslate(drawerRef.current, direction);
3929
+ set(drawerRef.current, {
3930
+ transform: 'translate3d(0, 0, 0)',
3931
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`
3932
+ });
3933
+ set(overlayRef.current, {
3934
+ transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
3935
+ opacity: '1'
3936
+ });
3937
+ // Don't reset background if swiped upwards
3938
+ if (shouldScaleBackground && currentSwipeAmount && currentSwipeAmount > 0 && isOpen) set(wrapper, {
3939
+ borderRadius: `${BORDER_RADIUS}px`,
3940
+ overflow: 'hidden',
3941
+ ...isVertical(direction) ? {
3942
+ transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
3943
+ transformOrigin: 'top'
3944
+ } : {
3945
+ transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
3946
+ transformOrigin: 'left'
3947
+ },
3948
+ transitionProperty: 'transform, border-radius',
3949
+ transitionDuration: `${TRANSITIONS.DURATION}s`,
3950
+ transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`
3951
+ }, true);
3952
+ }
3953
+ function cancelDrag() {
3954
+ if (!isDragging || !drawerRef.current) return;
3955
+ drawerRef.current.classList.remove(DRAG_CLASS);
3956
+ isAllowedToDrag.current = false;
3957
+ setIsDragging(false);
3958
+ dragEndTime.current = new Date();
3959
+ }
3960
+ function onRelease(event) {
3961
+ if (!isDragging || !drawerRef.current) return;
3962
+ drawerRef.current.classList.remove(DRAG_CLASS);
3963
+ isAllowedToDrag.current = false;
3964
+ setIsDragging(false);
3965
+ dragEndTime.current = new Date();
3966
+ const swipeAmount = getTranslate(drawerRef.current, direction);
3967
+ if (!event || !shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) return;
3968
+ if (dragStartTime.current === null) return;
3969
+ const timeTaken = dragEndTime.current.getTime() - dragStartTime.current.getTime();
3970
+ const distMoved = pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX);
3971
+ const velocity = Math.abs(distMoved) / timeTaken;
3972
+ if (velocity > 0.05) {
3973
+ // `justReleased` is needed to prevent the drawer from focusing on an input when the drag ends, as it's not the intent most of the time.
3974
+ setJustReleased(true);
3975
+ setTimeout(()=>{
3976
+ setJustReleased(false);
3977
+ }, 200);
3978
+ }
3979
+ if (snapPoints) {
3980
+ const directionMultiplier = direction === 'bottom' || direction === 'right' ? 1 : -1;
3981
+ onReleaseSnapPoints({
3982
+ draggedDistance: distMoved * directionMultiplier,
3983
+ closeDrawer,
3984
+ velocity,
3985
+ dismissible
3986
+ });
3987
+ onReleaseProp == null || onReleaseProp(event, true);
3988
+ return;
3989
+ }
3990
+ // Moved upwards, don't do anything
3991
+ if (direction === 'bottom' || direction === 'right' ? distMoved > 0 : distMoved < 0) {
3992
+ resetDrawer();
3993
+ onReleaseProp == null || onReleaseProp(event, true);
3994
+ return;
3995
+ }
3996
+ if (velocity > VELOCITY_THRESHOLD) {
3997
+ closeDrawer();
3998
+ onReleaseProp == null || onReleaseProp(event, false);
3999
+ return;
4000
+ }
4001
+ var _drawerRef_current_getBoundingClientRect_height;
4002
+ const visibleDrawerHeight = Math.min((_drawerRef_current_getBoundingClientRect_height = drawerRef.current.getBoundingClientRect().height) != null ? _drawerRef_current_getBoundingClientRect_height : 0, window.innerHeight);
4003
+ var _drawerRef_current_getBoundingClientRect_width;
4004
+ const visibleDrawerWidth = Math.min((_drawerRef_current_getBoundingClientRect_width = drawerRef.current.getBoundingClientRect().width) != null ? _drawerRef_current_getBoundingClientRect_width : 0, window.innerWidth);
4005
+ const isHorizontalSwipe = direction === 'left' || direction === 'right';
4006
+ if (Math.abs(swipeAmount) >= (isHorizontalSwipe ? visibleDrawerWidth : visibleDrawerHeight) * closeThreshold) {
4007
+ closeDrawer();
4008
+ onReleaseProp == null || onReleaseProp(event, false);
4009
+ return;
4010
+ }
4011
+ onReleaseProp == null || onReleaseProp(event, true);
4012
+ resetDrawer();
4013
+ }
4014
+ (0, _reactDefault.default).useEffect(()=>{
4015
+ // Trigger enter animation without using CSS animation
4016
+ if (isOpen) {
4017
+ set(document.documentElement, {
4018
+ scrollBehavior: 'auto'
4019
+ });
4020
+ openTime.current = new Date();
4021
+ }
4022
+ return ()=>{
4023
+ reset(document.documentElement, 'scrollBehavior');
4024
+ };
4025
+ }, [
4026
+ isOpen
4027
+ ]);
4028
+ function onNestedOpenChange(o) {
4029
+ const scale = o ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1;
4030
+ const initialTranslate = o ? -NESTED_DISPLACEMENT : 0;
4031
+ if (nestedOpenChangeTimer.current) window.clearTimeout(nestedOpenChangeTimer.current);
4032
+ set(drawerRef.current, {
4033
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
4034
+ transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${initialTranslate}px, 0)` : `scale(${scale}) translate3d(${initialTranslate}px, 0, 0)`
4035
+ });
4036
+ if (!o && drawerRef.current) nestedOpenChangeTimer.current = setTimeout(()=>{
4037
+ const translateValue = getTranslate(drawerRef.current, direction);
4038
+ set(drawerRef.current, {
4039
+ transition: 'none',
4040
+ transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
4041
+ });
4042
+ }, 500);
4043
+ }
4044
+ function onNestedDrag(_event, percentageDragged) {
4045
+ if (percentageDragged < 0) return;
4046
+ const initialScale = (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth;
4047
+ const newScale = initialScale + percentageDragged * (1 - initialScale);
4048
+ const newTranslate = -NESTED_DISPLACEMENT + percentageDragged * NESTED_DISPLACEMENT;
4049
+ set(drawerRef.current, {
4050
+ transform: isVertical(direction) ? `scale(${newScale}) translate3d(0, ${newTranslate}px, 0)` : `scale(${newScale}) translate3d(${newTranslate}px, 0, 0)`,
4051
+ transition: 'none'
4052
+ });
4053
+ }
4054
+ function onNestedRelease(_event, o) {
4055
+ const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
4056
+ const scale = o ? (dim - NESTED_DISPLACEMENT) / dim : 1;
4057
+ const translate = o ? -NESTED_DISPLACEMENT : 0;
4058
+ if (o) set(drawerRef.current, {
4059
+ transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
4060
+ transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${translate}px, 0)` : `scale(${scale}) translate3d(${translate}px, 0, 0)`
4061
+ });
4062
+ }
4063
+ (0, _reactDefault.default).useEffect(()=>{
4064
+ if (!modal) // Need to do this manually unfortunately
4065
+ window.requestAnimationFrame(()=>{
4066
+ document.body.style.pointerEvents = 'auto';
4067
+ });
4068
+ }, [
4069
+ modal
4070
+ ]);
4071
+ return /*#__PURE__*/ (0, _reactDefault.default).createElement(_reactDialog.Root, {
4072
+ defaultOpen: defaultOpen,
4073
+ onOpenChange: (open)=>{
4074
+ if (!dismissible && !open) return;
4075
+ if (open) setHasBeenOpened(true);
4076
+ else closeDrawer(true);
4077
+ setIsOpen(open);
4078
+ },
4079
+ open: isOpen
4080
+ }, /*#__PURE__*/ (0, _reactDefault.default).createElement(DrawerContext.Provider, {
4081
+ value: {
4082
+ activeSnapPoint,
4083
+ snapPoints,
4084
+ setActiveSnapPoint,
4085
+ drawerRef,
4086
+ overlayRef,
4087
+ onOpenChange,
4088
+ onPress,
4089
+ onRelease,
4090
+ onDrag,
4091
+ dismissible,
4092
+ shouldAnimate,
4093
+ handleOnly,
4094
+ isOpen,
4095
+ isDragging,
4096
+ shouldFade,
4097
+ closeDrawer,
4098
+ onNestedDrag,
4099
+ onNestedOpenChange,
4100
+ onNestedRelease,
4101
+ keyboardIsOpen,
4102
+ modal,
4103
+ snapPointsOffset,
4104
+ activeSnapPointIndex,
4105
+ direction,
4106
+ shouldScaleBackground,
4107
+ setBackgroundColorOnScale,
4108
+ noBodyStyles,
4109
+ container,
4110
+ autoFocus
4111
+ }
4112
+ }, children));
4113
+ }
4114
+ const Overlay = /*#__PURE__*/ (0, _reactDefault.default).forwardRef(function({ ...rest }, ref) {
4115
+ const { overlayRef, snapPoints, onRelease, shouldFade, isOpen, modal, shouldAnimate } = useDrawerContext();
4116
+ const composedRef = useComposedRefs(ref, overlayRef);
4117
+ const hasSnapPoints = snapPoints && snapPoints.length > 0;
4118
+ // Overlay is the component that is locking scroll, removing it will unlock the scroll without having to dig into Radix's Dialog library
4119
+ if (!modal) return null;
4120
+ const onMouseUp = (0, _reactDefault.default).useCallback((event)=>onRelease(event), [
4121
+ onRelease
4122
+ ]);
4123
+ return /*#__PURE__*/ (0, _reactDefault.default).createElement(_reactDialog.Overlay, {
4124
+ onMouseUp: onMouseUp,
4125
+ ref: composedRef,
4126
+ "data-vaul-overlay": "",
4127
+ "data-vaul-snap-points": isOpen && hasSnapPoints ? 'true' : 'false',
4128
+ "data-vaul-snap-points-overlay": isOpen && shouldFade ? 'true' : 'false',
4129
+ "data-vaul-animate": (shouldAnimate == null ? void 0 : shouldAnimate.current) ? 'true' : 'false',
4130
+ ...rest
4131
+ });
4132
+ });
4133
+ Overlay.displayName = 'Drawer.Overlay';
4134
+ const Content = /*#__PURE__*/ (0, _reactDefault.default).forwardRef(function({ onPointerDownOutside, style, onOpenAutoFocus, ...rest }, ref) {
4135
+ const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly, shouldAnimate, autoFocus } = useDrawerContext();
4136
+ // Needed to use transition instead of animations
4137
+ const [delayedSnapPoints, setDelayedSnapPoints] = (0, _reactDefault.default).useState(false);
4138
+ const composedRef = useComposedRefs(ref, drawerRef);
4139
+ const pointerStartRef = (0, _reactDefault.default).useRef(null);
4140
+ const lastKnownPointerEventRef = (0, _reactDefault.default).useRef(null);
4141
+ const wasBeyondThePointRef = (0, _reactDefault.default).useRef(false);
4142
+ const hasSnapPoints = snapPoints && snapPoints.length > 0;
4143
+ useScaleBackground();
4144
+ const isDeltaInDirection = (delta, direction, threshold = 0)=>{
4145
+ if (wasBeyondThePointRef.current) return true;
4146
+ const deltaY = Math.abs(delta.y);
4147
+ const deltaX = Math.abs(delta.x);
4148
+ const isDeltaX = deltaX > deltaY;
4149
+ const dFactor = [
4150
+ 'bottom',
4151
+ 'right'
4152
+ ].includes(direction) ? 1 : -1;
4153
+ if (direction === 'left' || direction === 'right') {
4154
+ const isReverseDirection = delta.x * dFactor < 0;
4155
+ if (!isReverseDirection && deltaX >= 0 && deltaX <= threshold) return isDeltaX;
4156
+ } else {
4157
+ const isReverseDirection = delta.y * dFactor < 0;
4158
+ if (!isReverseDirection && deltaY >= 0 && deltaY <= threshold) return !isDeltaX;
4159
+ }
4160
+ wasBeyondThePointRef.current = true;
4161
+ return true;
4162
+ };
4163
+ (0, _reactDefault.default).useEffect(()=>{
4164
+ if (hasSnapPoints) window.requestAnimationFrame(()=>{
4165
+ setDelayedSnapPoints(true);
4166
+ });
4167
+ }, []);
4168
+ function handleOnPointerUp(event) {
4169
+ pointerStartRef.current = null;
4170
+ wasBeyondThePointRef.current = false;
4171
+ onRelease(event);
4172
+ }
4173
+ return /*#__PURE__*/ (0, _reactDefault.default).createElement(_reactDialog.Content, {
4174
+ "data-vaul-drawer-direction": direction,
4175
+ "data-vaul-drawer": "",
4176
+ "data-vaul-delayed-snap-points": delayedSnapPoints ? 'true' : 'false',
4177
+ "data-vaul-snap-points": isOpen && hasSnapPoints ? 'true' : 'false',
4178
+ "data-vaul-custom-container": container ? 'true' : 'false',
4179
+ "data-vaul-animate": (shouldAnimate == null ? void 0 : shouldAnimate.current) ? 'true' : 'false',
4180
+ ...rest,
4181
+ ref: composedRef,
4182
+ style: snapPointsOffset && snapPointsOffset.length > 0 ? {
4183
+ '--snap-point-height': `${snapPointsOffset[activeSnapPointIndex != null ? activeSnapPointIndex : 0]}px`,
4184
+ ...style
4185
+ } : style,
4186
+ onPointerDown: (event)=>{
4187
+ if (handleOnly) return;
4188
+ rest.onPointerDown == null || rest.onPointerDown.call(rest, event);
4189
+ pointerStartRef.current = {
4190
+ x: event.pageX,
4191
+ y: event.pageY
4192
+ };
4193
+ onPress(event);
4194
+ },
4195
+ onOpenAutoFocus: (e)=>{
4196
+ onOpenAutoFocus == null || onOpenAutoFocus(e);
4197
+ if (!autoFocus) e.preventDefault();
4198
+ },
4199
+ onPointerDownOutside: (e)=>{
4200
+ onPointerDownOutside == null || onPointerDownOutside(e);
4201
+ if (!modal || e.defaultPrevented) {
4202
+ e.preventDefault();
4203
+ return;
4204
+ }
4205
+ if (keyboardIsOpen.current) keyboardIsOpen.current = false;
4206
+ },
4207
+ onFocusOutside: (e)=>{
4208
+ if (!modal) {
4209
+ e.preventDefault();
4210
+ return;
4211
+ }
4212
+ },
4213
+ onPointerMove: (event)=>{
4214
+ lastKnownPointerEventRef.current = event;
4215
+ if (handleOnly) return;
4216
+ rest.onPointerMove == null || rest.onPointerMove.call(rest, event);
4217
+ if (!pointerStartRef.current) return;
4218
+ const yPosition = event.pageY - pointerStartRef.current.y;
4219
+ const xPosition = event.pageX - pointerStartRef.current.x;
4220
+ const swipeStartThreshold = event.pointerType === 'touch' ? 10 : 2;
4221
+ const delta = {
4222
+ x: xPosition,
4223
+ y: yPosition
4224
+ };
4225
+ const isAllowedToSwipe = isDeltaInDirection(delta, direction, swipeStartThreshold);
4226
+ if (isAllowedToSwipe) onDrag(event);
4227
+ else if (Math.abs(xPosition) > swipeStartThreshold || Math.abs(yPosition) > swipeStartThreshold) pointerStartRef.current = null;
4228
+ },
4229
+ onPointerUp: (event)=>{
4230
+ rest.onPointerUp == null || rest.onPointerUp.call(rest, event);
4231
+ pointerStartRef.current = null;
4232
+ wasBeyondThePointRef.current = false;
4233
+ onRelease(event);
4234
+ },
4235
+ onPointerOut: (event)=>{
4236
+ rest.onPointerOut == null || rest.onPointerOut.call(rest, event);
4237
+ handleOnPointerUp(lastKnownPointerEventRef.current);
4238
+ },
4239
+ onContextMenu: (event)=>{
4240
+ rest.onContextMenu == null || rest.onContextMenu.call(rest, event);
4241
+ if (lastKnownPointerEventRef.current) handleOnPointerUp(lastKnownPointerEventRef.current);
4242
+ }
4243
+ });
4244
+ });
4245
+ Content.displayName = 'Drawer.Content';
4246
+ const LONG_HANDLE_PRESS_TIMEOUT = 250;
4247
+ const DOUBLE_TAP_TIMEOUT = 120;
4248
+ const Handle = /*#__PURE__*/ (0, _reactDefault.default).forwardRef(function({ preventCycle = false, children, ...rest }, ref) {
4249
+ const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag } = useDrawerContext();
4250
+ const closeTimeoutIdRef = (0, _reactDefault.default).useRef(null);
4251
+ const shouldCancelInteractionRef = (0, _reactDefault.default).useRef(false);
4252
+ function handleStartCycle() {
4253
+ // Stop if this is the second click of a double click
4254
+ if (shouldCancelInteractionRef.current) {
4255
+ handleCancelInteraction();
4256
+ return;
4257
+ }
4258
+ window.setTimeout(()=>{
4259
+ handleCycleSnapPoints();
4260
+ }, DOUBLE_TAP_TIMEOUT);
4261
+ }
4262
+ function handleCycleSnapPoints() {
4263
+ // Prevent accidental taps while resizing drawer
4264
+ if (isDragging || preventCycle || shouldCancelInteractionRef.current) {
4265
+ handleCancelInteraction();
4266
+ return;
4267
+ }
4268
+ // Make sure to clear the timeout id if the user releases the handle before the cancel timeout
4269
+ handleCancelInteraction();
4270
+ if (!snapPoints || snapPoints.length === 0) {
4271
+ if (!dismissible) closeDrawer();
4272
+ return;
4273
+ }
4274
+ const isLastSnapPoint = activeSnapPoint === snapPoints[snapPoints.length - 1];
4275
+ if (isLastSnapPoint && dismissible) {
4276
+ closeDrawer();
4277
+ return;
4278
+ }
4279
+ const currentSnapIndex = snapPoints.findIndex((point)=>point === activeSnapPoint);
4280
+ if (currentSnapIndex === -1) return; // activeSnapPoint not found in snapPoints
4281
+ const nextSnapPoint = snapPoints[currentSnapIndex + 1];
4282
+ setActiveSnapPoint(nextSnapPoint);
4283
+ }
4284
+ function handleStartInteraction() {
4285
+ closeTimeoutIdRef.current = window.setTimeout(()=>{
4286
+ // Cancel click interaction on a long press
4287
+ shouldCancelInteractionRef.current = true;
4288
+ }, LONG_HANDLE_PRESS_TIMEOUT);
4289
+ }
4290
+ function handleCancelInteraction() {
4291
+ if (closeTimeoutIdRef.current) window.clearTimeout(closeTimeoutIdRef.current);
4292
+ shouldCancelInteractionRef.current = false;
4293
+ }
4294
+ return /*#__PURE__*/ (0, _reactDefault.default).createElement("div", {
4295
+ onClick: handleStartCycle,
4296
+ onPointerCancel: handleCancelInteraction,
4297
+ onPointerDown: (e)=>{
4298
+ if (handleOnly) onPress(e);
4299
+ handleStartInteraction();
4300
+ },
4301
+ onPointerMove: (e)=>{
4302
+ if (handleOnly) onDrag(e);
4303
+ },
4304
+ // onPointerUp is already handled by the content component
4305
+ ref: ref,
4306
+ "data-vaul-drawer-visible": isOpen ? 'true' : 'false',
4307
+ "data-vaul-handle": "",
4308
+ "aria-hidden": "true",
4309
+ ...rest
4310
+ }, /*#__PURE__*/ (0, _reactDefault.default).createElement("span", {
4311
+ "data-vaul-handle-hitarea": "",
4312
+ "aria-hidden": "true"
4313
+ }, children));
4314
+ });
4315
+ Handle.displayName = 'Drawer.Handle';
4316
+ function NestedRoot({ onDrag, onOpenChange, open: nestedIsOpen, ...rest }) {
4317
+ const { onNestedDrag, onNestedOpenChange, onNestedRelease } = useDrawerContext();
4318
+ if (!onNestedDrag) throw new Error('Drawer.NestedRoot must be placed in another drawer');
4319
+ return /*#__PURE__*/ (0, _reactDefault.default).createElement(Root, {
4320
+ nested: true,
4321
+ open: nestedIsOpen,
4322
+ onClose: ()=>{
4323
+ onNestedOpenChange(false);
4324
+ },
4325
+ onDrag: (e, p)=>{
4326
+ onNestedDrag(e, p);
4327
+ onDrag == null || onDrag(e, p);
4328
+ },
4329
+ onOpenChange: (o)=>{
4330
+ if (o) onNestedOpenChange(o);
4331
+ onOpenChange == null || onOpenChange(o);
4332
+ },
4333
+ onRelease: onNestedRelease,
4334
+ ...rest
4335
+ });
4336
+ }
4337
+ function Portal(props) {
4338
+ const context = useDrawerContext();
4339
+ const { container = context.container, ...portalProps } = props;
4340
+ return /*#__PURE__*/ (0, _reactDefault.default).createElement(_reactDialog.Portal, {
4341
+ container: container,
4342
+ ...portalProps
4343
+ });
4344
+ }
4345
+ const Drawer = {
4346
+ Root,
4347
+ NestedRoot,
4348
+ Content,
4349
+ Overlay,
4350
+ Trigger: _reactDialog.Trigger,
4351
+ Portal,
4352
+ Handle,
4353
+ Close: _reactDialog.Close,
4354
+ Title: _reactDialog.Title,
4355
+ Description: _reactDialog.Description
4356
+ };
4357
+
4358
+ },{"@radix-ui/react-dialog":"5HLWS","react":"jMk1U","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT"}],"8Iiui":[function(require,module,exports,__globalThis) {
4359
+ var $parcel$ReactRefreshHelpers$fbfc = require("@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js");
4360
+ $parcel$ReactRefreshHelpers$fbfc.init();
4361
+ var prevRefreshReg = globalThis.$RefreshReg$;
4362
+ var prevRefreshSig = globalThis.$RefreshSig$;
4363
+ $parcel$ReactRefreshHelpers$fbfc.prelude(module);
4364
+
4365
+ try {
4366
+ var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
4367
+ parcelHelpers.defineInteropFlag(exports);
4368
+ parcelHelpers.export(exports, "Toaster", ()=>Toaster);
4369
+ var _jsxRuntime = require("react/jsx-runtime");
4370
+ var _useSettings = require("@/features/settings/hooks/useSettings");
4371
+ var _sonner = require("sonner");
4372
+ var _zIndex = require("@/lib/z-index");
4373
+ var _s = $RefreshSig$();
4374
+ const Toaster = ({ ...props })=>{
4375
+ _s();
4376
+ const { settings } = (0, _useSettings.useSettings)();
4377
+ return (0, _jsxRuntime.jsx)((0, _sonner.Toaster), {
4378
+ position: "top-center",
4379
+ theme: settings.appearance.theme,
4380
+ className: "toaster group",
4381
+ style: {
4382
+ zIndex: (0, _zIndex.Z_INDEX).TOAST,
4383
+ // Re-enable pointer events so toasts stay clickable when a Radix modal is open
4384
+ // (Radix sets body.style.pointerEvents = 'none' and only the dialog content gets 'auto')
4385
+ pointerEvents: 'auto'
4386
+ },
4387
+ toastOptions: {
4388
+ classNames: {
4389
+ toast: 'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
4390
+ description: 'group-[.toast]:text-muted-foreground',
4391
+ actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
4392
+ cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground'
4393
+ }
4394
+ },
4395
+ ...props
4396
+ });
4397
+ };
4398
+ _s(Toaster, "gxi4fQ+d98hNJYOxevCQ9ERfZgI=", false, function() {
4399
+ return [
4400
+ (0, _useSettings.useSettings)
4401
+ ];
4402
+ });
4403
+ _c = Toaster;
4404
+ var _c;
4405
+ $RefreshReg$(_c, "Toaster");
4406
+
4407
+ $parcel$ReactRefreshHelpers$fbfc.postlude(module);
4408
+ } finally {
4409
+ globalThis.$RefreshReg$ = prevRefreshReg;
4410
+ globalThis.$RefreshSig$ = prevRefreshSig;
4411
+ }
4412
+ },{"react/jsx-runtime":"05iiF","@/features/settings/hooks/useSettings":"hj85U","sonner":"kK7Kb","@/lib/z-index":"eChN4","@parcel/transformer-js/src/esmodule-helpers.js":"jnFvT","@parcel/transformer-react-refresh-wrap/lib/helpers/helpers.js":"7h6Pi"}]},["aEqQu"], null, "parcelRequire6cf0", {})
4413
+
4414
+ //# sourceMappingURL=DefaultLayout.4454f259.js.map