Socket
Socket
Sign inDemoInstall

jotai

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jotai - npm Package Compare versions

Comparing version 2.7.2 to 2.8.0

esm/experimental.d.mts

7

babel/plugin-debug-label.js
'use strict';
var path = require('path');
var _templateBuilder = require('@babel/template');

@@ -32,6 +31,6 @@

if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';
var displayName = path.basename(filename, path.extname(filename));
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');
var displayName = filename.split('/').pop();
if (displayName === 'index') {
displayName = path.basename(path.dirname(filename));
displayName = filename.slice(0, -'/index'.length).split('/').pop() || 'unknown';
}

@@ -38,0 +37,0 @@ var buildExport = templateBuilder("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ");

'use strict';
var path = require('path');
var _templateBuilder = require('@babel/template');

@@ -32,6 +31,6 @@

if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';
var displayName = path.basename(filename, path.extname(filename));
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');
var displayName = filename.split('/').pop();
if (displayName === 'index') {
displayName = path.basename(path.dirname(filename));
displayName = filename.slice(0, -'/index'.length).split('/').pop() || 'unknown';
}

@@ -38,0 +37,0 @@ var buildExport = templateBuilder$1("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ");

{
"name": "jotai",
"private": false,
"version": "2.7.2",
"version": "2.8.0",
"description": "👻 Primitive and flexible state management for React",

@@ -6,0 +6,0 @@ "main": "./index.js",

@@ -18,2 +18,5 @@ 'use client';

function useReducerAtom(anAtom, reducer, options) {
if (process.env.NODE_ENV !== 'production') {
console.warn('[DEPRECATED] useReducerAtom is deprecated and will be removed in the future. Please create your own version using the recipe. https://github.com/pmndrs/jotai/pull/2467');
}
var _useAtom = react.useAtom(anAtom, options),

@@ -20,0 +23,0 @@ state = _useAtom[0],

import { useAtom } from 'jotai/react';
import type { PrimitiveAtom } from 'jotai/vanilla';
type Options = Parameters<typeof useAtom>[1];
/**
* @deprecated please use a recipe instead
* https://github.com/pmndrs/jotai/pull/2467
*/
export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a?: Action) => Value, options?: Options): [Value, (action?: Action) => void];
/**
* @deprecated please use a recipe instead
* https://github.com/pmndrs/jotai/pull/2467
*/
export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a: Action) => Value, options?: Options): [Value, (action: Action) => void];
export {};

@@ -1,8 +0,6 @@

System.register(['path', '@babel/template'], (function (exports) {
System.register(['@babel/template'], (function (exports) {
'use strict';
var path, _templateBuilder;
var _templateBuilder;
return {
setters: [function (module) {
path = module.default;
}, function (module) {
_templateBuilder = module.default;

@@ -74,6 +72,6 @@ }],

if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = state.filename || "unknown";
let displayName = path.basename(filename, path.extname(filename));
const filename = (state.filename || "unknown").replace(/\.\w+$/, "");
let displayName = filename.split("/").pop();
if (displayName === "index") {
displayName = path.basename(path.dirname(filename));
displayName = filename.slice(0, -"/index".length).split("/").pop() || "unknown";
}

@@ -91,5 +89,5 @@ const buildExport = templateBuilder(`

},
VariableDeclarator(path2) {
if (t.isIdentifier(path2.node.id) && t.isCallExpression(path2.node.init) && isAtom(t, path2.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path2.parentPath.insertAfter(
VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(
t.expressionStatement(

@@ -99,6 +97,6 @@ t.assignmentExpression(

t.memberExpression(
t.identifier(path2.node.id.name),
t.identifier(path.node.id.name),
t.identifier("debugLabel")
),
t.stringLiteral(path2.node.id.name)
t.stringLiteral(path.node.id.name)
)

@@ -105,0 +103,0 @@ )

@@ -1,4 +0,4 @@

System.register(["path","@babel/template"],function(d){"use strict";var o,m;return{setters:[function(a){o=a.default},function(a){m=a.default}],execute:function(){d("default",f);function a(t,i,e=[]){const r=[...u,...e];if(t.isIdentifier(i)&&r.includes(i.name))return!0;if(t.isMemberExpression(i)){const{property:n}=i;if(t.isIdentifier(n)&&r.includes(n.name))return!0}return!1}const u=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],c=m.default||m;function f({types:t},i){return{visitor:{ExportDefaultDeclaration(e,r){const{node:n}=e;if(t.isCallExpression(n.declaration)&&a(t,n.declaration.callee,i==null?void 0:i.customAtomNames)){const s=r.filename||"unknown";let l=o.basename(s,o.extname(s));l==="index"&&(l=o.basename(o.dirname(s)));const h=c(`
System.register(["@babel/template"],function(l){"use strict";var r;return{setters:[function(a){r=a.default}],execute:function(){l("default",u);function a(t,i,e=[]){const n=[...c,...e];if(t.isIdentifier(i)&&n.includes(i.name))return!0;if(t.isMemberExpression(i)){const{property:o}=i;if(t.isIdentifier(o)&&n.includes(o.name))return!0}return!1}const c=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],d=r.default||r;function u({types:t},i){return{visitor:{ExportDefaultDeclaration(e,n){const{node:o}=e;if(t.isCallExpression(o.declaration)&&a(t,o.declaration.callee,i==null?void 0:i.customAtomNames)){const m=(n.filename||"unknown").replace(/\.\w+$/,"");let s=m.split("/").pop();s==="index"&&(s=m.slice(0,-6).split("/").pop()||"unknown");const f=d(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`)({atomIdentifier:t.identifier(l),atom:n.declaration});e.replaceWithMultiple(h)}},VariableDeclarator(e){t.isIdentifier(e.node.id)&&t.isCallExpression(e.node.init)&&a(t,e.node.init.callee,i==null?void 0:i.customAtomNames)&&e.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(e.node.id.name),t.identifier("debugLabel")),t.stringLiteral(e.node.id.name))))}}}}}}});
`)({atomIdentifier:t.identifier(s),atom:o.declaration});e.replaceWithMultiple(f)}},VariableDeclarator(e){t.isIdentifier(e.node.id)&&t.isCallExpression(e.node.init)&&a(t,e.node.init.callee,i==null?void 0:i.customAtomNames)&&e.parentPath.insertAfter(t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(e.node.id.name),t.identifier("debugLabel")),t.stringLiteral(e.node.id.name))))}}}}}}});

@@ -1,8 +0,6 @@

System.register(['path', '@babel/template'], (function (exports) {
System.register(['@babel/template'], (function (exports) {
'use strict';
var path, _templateBuilder;
var _templateBuilder;
return {
setters: [function (module) {
path = module.default;
}, function (module) {
_templateBuilder = module.default;

@@ -74,6 +72,6 @@ }],

if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
const filename = state.filename || "unknown";
let displayName = path.basename(filename, path.extname(filename));
const filename = (state.filename || "unknown").replace(/\.\w+$/, "");
let displayName = filename.split("/").pop();
if (displayName === "index") {
displayName = path.basename(path.dirname(filename));
displayName = filename.slice(0, -"/index".length).split("/").pop() || "unknown";
}

@@ -91,5 +89,5 @@ const buildExport = templateBuilder$1(`

},
VariableDeclarator(path2) {
if (t.isIdentifier(path2.node.id) && t.isCallExpression(path2.node.init) && isAtom(t, path2.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path2.parentPath.insertAfter(
VariableDeclarator(path) {
if (t.isIdentifier(path.node.id) && t.isCallExpression(path.node.init) && isAtom(t, path.node.init.callee, options == null ? void 0 : options.customAtomNames)) {
path.parentPath.insertAfter(
t.expressionStatement(

@@ -99,6 +97,6 @@ t.assignmentExpression(

t.memberExpression(
t.identifier(path2.node.id.name),
t.identifier(path.node.id.name),
t.identifier("debugLabel")
),
t.stringLiteral(path2.node.id.name)
t.stringLiteral(path.node.id.name)
)

@@ -105,0 +103,0 @@ )

@@ -1,5 +0,5 @@

System.register(["path","@babel/template"],function(u){"use strict";var l,m;return{setters:[function(o){l=o.default},function(o){m=o.default}],execute:function(){u("default",W);function o(e,i,t=[]){const n=[...f,...t];if(e.isIdentifier(i)&&n.includes(i.name))return!0;if(e.isMemberExpression(i)){const{property:a}=i;if(e.isIdentifier(a)&&n.includes(a.name))return!0}return!1}const f=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],h=m.default||m;function p({types:e},i){return{visitor:{ExportDefaultDeclaration(t,n){const{node:a}=t;if(e.isCallExpression(a.declaration)&&o(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const r=n.filename||"unknown";let s=l.basename(r,l.extname(r));s==="index"&&(s=l.basename(l.dirname(r)));const d=h(`
System.register(["@babel/template"],function(d){"use strict";var s;return{setters:[function(l){s=l.default}],execute:function(){d("default",b);function l(e,i,t=[]){const o=[...u,...t];if(e.isIdentifier(i)&&o.includes(i.name))return!0;if(e.isMemberExpression(i)){const{property:a}=i;if(e.isIdentifier(a)&&o.includes(a.name))return!0}return!1}const u=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],f=s.default||s;function h({types:e},i){return{visitor:{ExportDefaultDeclaration(t,o){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const n=(o.filename||"unknown").replace(/\.\w+$/,"");let r=n.split("/").pop();r==="index"&&(r=n.slice(0,-6).split("/").pop()||"unknown");const c=f(`
const %%atomIdentifier%% = %%atom%%;
export default %%atomIdentifier%%
`)({atomIdentifier:e.identifier(s),atom:a.declaration});t.replaceWithMultiple(d)}},VariableDeclarator(t){e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&o(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&t.parentPath.insertAfter(e.expressionStatement(e.assignmentExpression("=",e.memberExpression(e.identifier(t.node.id.name),e.identifier("debugLabel")),e.stringLiteral(t.node.id.name))))}}}}const c=m.default||m;function b({types:e},i){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const n=c(`
`)({atomIdentifier:e.identifier(r),atom:a.declaration});t.replaceWithMultiple(c)}},VariableDeclarator(t){e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&t.parentPath.insertAfter(e.expressionStatement(e.assignmentExpression("=",e.memberExpression(e.identifier(t.node.id.name),e.identifier("debugLabel")),e.stringLiteral(t.node.id.name))))}}}}const m=s.default||s;function p({types:e},i){return{pre({opts:t}){if(!t.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(t){const o=m(`
globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {

@@ -14,2 +14,2 @@ cache: new Map(),

},
}`)();t.unshiftContainer("body",n)}},ExportDefaultDeclaration(t,n){const{node:a}=t;if(e.isCallExpression(a.declaration)&&o(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const r=`${n.filename||"unknown"}/defaultExport`,s=c("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:e.stringLiteral(r),atom:a.declaration});t.replaceWith(s)}},VariableDeclarator(t,n){var a,r;if(e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&o(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&((a=t.parentPath.parentPath)!=null&&a.isProgram()||(r=t.parentPath.parentPath)!=null&&r.isExportNamedDeclaration())){const s=`${n.filename||"unknown"}/${t.node.id.name}`,d=c("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:e.identifier(t.node.id.name),atomKey:e.stringLiteral(s),atom:t.node.init});t.parentPath.replaceWith(d)}}}}}function W(e,i){return{plugins:[[p,i],[b,i]]}}}}});
}`)();t.unshiftContainer("body",o)}},ExportDefaultDeclaration(t,o){const{node:a}=t;if(e.isCallExpression(a.declaration)&&l(e,a.declaration.callee,i==null?void 0:i.customAtomNames)){const n=`${o.filename||"unknown"}/defaultExport`,r=m("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:e.stringLiteral(n),atom:a.declaration});t.replaceWith(r)}},VariableDeclarator(t,o){var a,n;if(e.isIdentifier(t.node.id)&&e.isCallExpression(t.node.init)&&l(e,t.node.init.callee,i==null?void 0:i.customAtomNames)&&((a=t.parentPath.parentPath)!=null&&a.isProgram()||(n=t.parentPath.parentPath)!=null&&n.isExportNamedDeclaration())){const r=`${o.filename||"unknown"}/${t.node.id.name}`,c=m("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:e.identifier(t.node.id.name),atomKey:e.stringLiteral(r),atom:t.node.init});t.parentPath.replaceWith(c)}}}}}function b(e,i){return{plugins:[[h,i],[p,i]]}}}}});

@@ -34,2 +34,7 @@ 'use client';

function useReducerAtom(anAtom, reducer, options) {
{
console.warn(
"[DEPRECATED] useReducerAtom is deprecated and will be removed in the future. Please create your own version using the recipe. https://github.com/pmndrs/jotai/pull/2467"
);
}
const [state, setState] = useAtom(anAtom, options);

@@ -36,0 +41,0 @@ const dispatch = useCallback(

'use client';
System.register(["react","jotai/react","jotai/vanilla/utils","jotai/vanilla"],function(k){"use strict";var r,i,c,l,m,f,A;return{setters:[function(e){r=e.useCallback,i=e.useMemo},function(e){c=e.useSetAtom,l=e.useAtom,m=e.useStore},function(e){f=e.RESET},function(e){A=e.atom}],execute:function(){k({useAtomCallback:R,useHydrateAtoms:d,useReducerAtom:y,useResetAtom:e});function e(n,t){const o=c(n,t);return r(()=>o(f),[o])}function y(n,t,o){const[u,s]=l(n,o),a=r(C=>{s(E=>t(E,C))},[s,t]);return[u,a]}function R(n,t){const o=i(()=>A(null,(u,s,...a)=>n(u,s,...a)),[n]);return c(o,t)}const S=new WeakMap;function d(n,t){const o=m(t),u=b(o);for(const[s,a]of n)(!u.has(s)||t!=null&&t.dangerouslyForceHydrate)&&(u.add(s),o.set(s,a))}const b=n=>{let t=S.get(n);return t||(t=new WeakSet,S.set(n,t)),t}}}});
System.register(["react","jotai/react","jotai/vanilla/utils","jotai/vanilla"],function(k){"use strict";var r,i,c,l,m,f,A;return{setters:[function(e){r=e.useCallback,i=e.useMemo},function(e){c=e.useSetAtom,l=e.useAtom,m=e.useStore},function(e){f=e.RESET},function(e){A=e.atom}],execute:function(){k({useAtomCallback:R,useHydrateAtoms:d,useReducerAtom:y,useResetAtom:e});function e(n,t){const s=c(n,t);return r(()=>s(f),[s])}function y(n,t,s){const[u,o]=l(n,s),a=r(C=>{o(E=>t(E,C))},[o,t]);return[u,a]}function R(n,t){const s=i(()=>A(null,(u,o,...a)=>n(u,o,...a)),[n]);return c(s,t)}const S=new WeakMap;function d(n,t){const s=m(t),u=b(s);for(const[o,a]of n)(!u.has(o)||t!=null&&t.dangerouslyForceHydrate)&&(u.add(o),s.set(o,a))}const b=n=>{let t=S.get(n);return t||(t=new WeakSet,S.set(n,t)),t}}}});

@@ -71,3 +71,3 @@ System.register([], (function (exports) {

};
const createStore = exports("createStore", () => {
const createStore$1 = () => {
const atomStateMap = /* @__PURE__ */ new WeakMap();

@@ -77,6 +77,6 @@ const mountedMap = /* @__PURE__ */ new WeakMap();

const pendingMap = /* @__PURE__ */ new WeakMap();
let storeListenersRev2;
let devListenersRev2;
let mountedAtoms;
{
storeListenersRev2 = /* @__PURE__ */ new Set();
devListenersRev2 = /* @__PURE__ */ new Set();
mountedAtoms = /* @__PURE__ */ new Set();

@@ -387,3 +387,3 @@ }

{
storeListenersRev2.forEach(
devListenersRev2.forEach(
(l) => l({ type: "async-write", flushed })

@@ -403,3 +403,3 @@ );

{
storeListenersRev2.forEach((l) => l({ type: "write", flushed }));
devListenersRev2.forEach((l) => l({ type: "write", flushed }));
}

@@ -552,3 +552,3 @@ return result;

{
storeListenersRev2.forEach(
devListenersRev2.forEach(
(l) => l({ type: "sub", flushed })

@@ -561,3 +561,3 @@ );

{
storeListenersRev2.forEach((l) => l({ type: "unsub" }));
devListenersRev2.forEach((l) => l({ type: "unsub" }));
}

@@ -572,9 +572,6 @@ };

// store dev methods (these are tentative and subject to change without notice)
dev_subscribe_store: (l, rev) => {
if (rev !== 2) {
throw new Error("The current StoreListener revision is 2.");
}
storeListenersRev2.add(l);
dev_subscribe_store: (l) => {
devListenersRev2.add(l);
return () => {
storeListenersRev2.delete(l);
devListenersRev2.delete(l);
};

@@ -594,3 +591,3 @@ },

const flushed = flushPending(pendingStack.pop());
storeListenersRev2.forEach(
devListenersRev2.forEach(
(l) => l({ type: "restore", flushed })

@@ -601,7 +598,7 @@ );

}
});
};
let defaultStore;
const getDefaultStore = exports("getDefaultStore", () => {
const getDefaultStore$1 = () => {
if (!defaultStore) {
defaultStore = createStore();
defaultStore = createStore$1();
{

@@ -617,6 +614,9 @@ globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = defaultStore);

return defaultStore;
});
};
const createStore = exports("createStore", createStore$1);
const getDefaultStore = exports("getDefaultStore", getDefaultStore$1);
})
};
}));

@@ -1,1 +0,1 @@

System.register([],function(M){"use strict";return{execute:function(){M("atom",R);let N=0;function R(r,u){const h=`atom${++N}`,v={toString:()=>h};return typeof r=="function"?v.read=r:(v.init=r,v.read=T,v.write=U),u&&(v.write=u),v}function T(r){return r(this)}function U(r,u,h){return u(this,typeof h=="function"?h(r(this)):h)}const b=(r,u)=>r.unstable_is?r.unstable_is(u):u===r,D=r=>"init"in r,O=r=>!!r.write,m=new WeakMap,V=(r,u)=>{m.set(r,u),r.catch(()=>{}).finally(()=>m.delete(r))},_=(r,u)=>{const h=m.get(r);h&&(m.delete(r),h(u))},C=(r,u)=>{r.status="fulfilled",r.value=u},q=(r,u)=>{r.status="rejected",r.reason=u},$=r=>typeof(r==null?void 0:r.then)=="function",E=(r,u)=>!!r&&"v"in r&&"v"in u&&Object.is(r.v,u.v),B=(r,u)=>!!r&&"e"in r&&"e"in u&&Object.is(r.e,u.e),p=r=>!!r&&"v"in r&&r.v instanceof Promise,x=(r,u)=>"v"in r&&"v"in u&&r.v.orig&&r.v.orig===u.v.orig,y=r=>{if("e"in r)throw r.e;return r.v},K=M("createStore",()=>{const r=new WeakMap,u=new WeakMap,h=[],v=new WeakMap,w=t=>r.get(t),F=(t,s)=>{s.d.forEach((a,e)=>{var n;if(!v.has(e)){const c=w(e);(n=h[h.length-1])==null||n.add(e),v.set(e,[c,new Set]),c&&F(e,c)}v.get(e)[1].add(t)})},G=(t,s)=>{var a;const e=w(t);if(r.set(t,s),v.has(t)||((a=h[h.length-1])==null||a.add(t),v.set(t,[e,new Set]),F(t,s)),p(e)){const n="v"in s?s.v instanceof Promise?s.v:Promise.resolve(s.v):Promise.reject(s.e);e.v!==n&&_(e.v,n)}},H=(t,s,a,e)=>{const n=new Map(e?s.d:null);let c=!1;a.forEach((o,i)=>{!o&&b(t,i)&&(o=s),o&&(n.set(i,o),s.d.get(i)!==o&&(c=!0))}),(c||s.d.size!==n.size)&&(s.d=n)},z=(t,s,a,e)=>{const n=w(t),c={d:(n==null?void 0:n.d)||new Map,v:s};if(a&&H(t,c,a,e),E(n,c)&&n.d===c.d)return n;if(p(n)&&p(c)&&x(n,c)){if(n.d===c.d)return n;c.v=n.v}return G(t,c),c},I=(t,s,a,e)=>{if($(s)){let n;const c=()=>{const i=w(t);if(!p(i)||i.v!==o)return;const f=z(t,o,a);u.has(t)&&i.d!==f.d&&L(t,f,i.d)},o=new Promise((i,f)=>{let l=!1;s.then(d=>{l||(l=!0,C(o,d),i(d),c())},d=>{l||(l=!0,q(o,d),f(d),c())}),n=d=>{l||(l=!0,d.then(g=>C(o,g),g=>q(o,g)),i(d))}});return o.orig=s,o.status="pending",V(o,i=>{i&&n(i),e==null||e()}),z(t,o,a,!0)}return z(t,s,a)},Q=(t,s,a)=>{const e=w(t),n={d:(e==null?void 0:e.d)||new Map,e:s};return a&&H(t,n,a),B(e,n)&&e.d===n.d?e:(G(t,n),n)},S=(t,s)=>{const a=w(t);if(!s&&a&&(u.has(t)||Array.from(a.d).every(([l,d])=>{if(l===t)return!0;const g=S(l);return g===d||E(g,d)})))return a;const e=new Map;let n=!0;const c=l=>{if(b(t,l)){const g=w(l);if(g)return e.set(l,g),y(g);if(D(l))return e.set(l,void 0),l.init;throw new Error("no atom init")}const d=S(l);return e.set(l,d),y(d)};let o,i;const f={get signal(){return o||(o=new AbortController),o.signal},get setSelf(){return!i&&O(t)&&(i=(...l)=>{if(!n)return P(t,...l)}),i}};try{const l=t.read(c,f);return I(t,l,e,()=>o==null?void 0:o.abort())}catch(l){return Q(t,l,e)}finally{n=!1}},X=t=>y(S(t)),Y=t=>{const s=o=>{var i,f;const l=new Set((i=u.get(o))==null?void 0:i.t);return(f=v.get(o))==null||f[1].forEach(d=>{l.add(d)}),l},a=new Array,e=new Set,n=o=>{if(!e.has(o)){e.add(o);for(const i of s(o))o!==i&&n(i);a.push(o)}};n(t);const c=new Set([t]);for(let o=a.length-1;o>=0;--o){const i=a[o],f=w(i);if(!f)continue;let l=!1;for(const d of f.d.keys())if(d!==i&&c.has(d)){l=!0;break}if(l){const d=S(i,!0);E(f,d)||c.add(i)}}},J=(t,...s)=>{const a=n=>y(S(n)),e=(n,...c)=>{const o=h.length>0;o||h.push(new Set([n]));let i;if(b(t,n)){if(!D(n))throw new Error("atom not writable");const f=w(n),l=I(n,c[0]);E(f,l)||Y(n)}else i=J(n,...c);return o||A(h.pop()),i};return t.write(a,e,...s)},P=(t,...s)=>{h.push(new Set([t]));const a=J(t,...s);return A(h.pop()),a},j=(t,s,a)=>{var e;const n=u.get(t);if(n)return s&&n.t.add(s),n;const c=a||[];(e=w(t))==null||e.d.forEach((i,f)=>{f!==t&&j(f,t,c)}),S(t);const o={t:new Set(s&&[s]),l:new Set};if(u.set(t,o),O(t)&&t.onMount){const{onMount:i}=t;c.push(()=>{const f=i((...l)=>P(t,...l));f&&(o.u=f)})}return a||c.forEach(i=>i()),o},Z=(t,s)=>!s.l.size&&(!s.t.size||s.t.size===1&&s.t.has(t)),W=(t,s)=>{if(!Z(t,s))return;const a=s.u;a&&a(),u.delete(t);const e=w(t);e&&(p(e)&&_(e.v),e.d.forEach((n,c)=>{if(c!==t){const o=u.get(c);o&&(o.t.delete(t),W(c,o))}}))},L=(t,s,a)=>{const e=new Set(s.d.keys()),n=new Set;a==null||a.forEach((c,o)=>{if(e.has(o)){e.delete(o);return}n.add(o);const i=u.get(o);i&&i.t.delete(t)}),e.forEach(c=>{j(c,t)}),n.forEach(c=>{const o=u.get(c);o&&W(c,o)})},A=t=>{const s=[],a=e=>{var n;if(!v.has(e))return;const[c,o]=v.get(e);v.delete(e),s.push([e,c]),o.forEach(a),(n=w(e))==null||n.d.forEach((i,f)=>a(f))};t.forEach(a),s.forEach(([e,n])=>{const c=w(e);if(c&&c!==n){const o=u.get(e);o&&c.d!==(n==null?void 0:n.d)&&L(e,c,n==null?void 0:n.d),o&&!(!p(n)&&(E(n,c)||B(n,c)))&&o.l.forEach(i=>i())}})};return{get:X,set:P,sub:(t,s)=>{const a=j(t);A([t]);const e=a.l;return e.add(s),()=>{e.delete(s),W(t,a)}}}});let k;const tt=M("getDefaultStore",()=>(k||(k=K()),k))}}});
System.register([],function(W){"use strict";return{execute:function(){W("atom",N);let L=0;function N(r,i){const h=`atom${++L}`,v={toString:()=>h};return typeof r=="function"?v.read=r:(v.init=r,v.read=R,v.write=T),i&&(v.write=i),v}function R(r){return r(this)}function T(r,i,h){return i(this,typeof h=="function"?h(r(this)):h)}const M=(r,i)=>r.unstable_is?r.unstable_is(i):i===r,$=r=>"init"in r,A=r=>!!r.write,m=new WeakMap,U=(r,i)=>{m.set(r,i),r.catch(()=>{}).finally(()=>m.delete(r))},O=(r,i)=>{const h=m.get(r);h&&(m.delete(r),h(i))},_=(r,i)=>{r.status="fulfilled",r.value=i},C=(r,i)=>{r.status="rejected",r.reason=i},V=r=>typeof(r==null?void 0:r.then)=="function",E=(r,i)=>!!r&&"v"in r&&"v"in i&&Object.is(r.v,i.v),q=(r,i)=>!!r&&"e"in r&&"e"in i&&Object.is(r.e,i.e),S=r=>!!r&&"v"in r&&r.v instanceof Promise,K=(r,i)=>"v"in r&&"v"in i&&r.v.orig&&r.v.orig===i.v.orig,y=r=>{if("e"in r)throw r.e;return r.v},x=()=>{const r=new WeakMap,i=new WeakMap,h=[],v=new WeakMap,g=t=>r.get(t),B=(t,s)=>{s.d.forEach((u,n)=>{var e;if(!v.has(n)){const c=g(n);(e=h[h.length-1])==null||e.add(n),v.set(n,[c,new Set]),c&&B(n,c)}v.get(n)[1].add(t)})},F=(t,s)=>{var u;const n=g(t);if(r.set(t,s),v.has(t)||((u=h[h.length-1])==null||u.add(t),v.set(t,[n,new Set]),B(t,s)),S(n)){const e="v"in s?s.v instanceof Promise?s.v:Promise.resolve(s.v):Promise.reject(s.e);n.v!==e&&O(n.v,e)}},G=(t,s,u,n)=>{const e=new Map(n?s.d:null);let c=!1;u.forEach((o,a)=>{!o&&M(t,a)&&(o=s),o&&(e.set(a,o),s.d.get(a)!==o&&(c=!0))}),(c||s.d.size!==e.size)&&(s.d=e)},k=(t,s,u,n)=>{const e=g(t),c={d:(e==null?void 0:e.d)||new Map,v:s};if(u&&G(t,c,u,n),E(e,c)&&e.d===c.d)return e;if(S(e)&&S(c)&&K(e,c)){if(e.d===c.d)return e;c.v=e.v}return F(t,c),c},H=(t,s,u,n)=>{if(V(s)){let e;const c=()=>{const a=g(t);if(!S(a)||a.v!==o)return;const d=k(t,o,u);i.has(t)&&a.d!==d.d&&J(t,d,a.d)},o=new Promise((a,d)=>{let l=!1;s.then(f=>{l||(l=!0,_(o,f),a(f),c())},f=>{l||(l=!0,C(o,f),d(f),c())}),e=f=>{l||(l=!0,f.then(w=>_(o,w),w=>C(o,w)),a(f))}});return o.orig=s,o.status="pending",U(o,a=>{a&&e(a),n==null||n()}),k(t,o,u,!0)}return k(t,s,u)},Q=(t,s,u)=>{const n=g(t),e={d:(n==null?void 0:n.d)||new Map,e:s};return u&&G(t,e,u),q(n,e)&&n.d===e.d?n:(F(t,e),e)},p=(t,s)=>{const u=g(t);if(!s&&u&&(i.has(t)||Array.from(u.d).every(([l,f])=>{if(l===t)return!0;const w=p(l);return w===f||E(w,f)})))return u;const n=new Map;let e=!0;const c=l=>{if(M(t,l)){const w=g(l);if(w)return n.set(l,w),y(w);if($(l))return n.set(l,void 0),l.init;throw new Error("no atom init")}const f=p(l);return n.set(l,f),y(f)};let o,a;const d={get signal(){return o||(o=new AbortController),o.signal},get setSelf(){return!a&&A(t)&&(a=(...l)=>{if(!e)return z(t,...l)}),a}};try{const l=t.read(c,d);return H(t,l,n,()=>o==null?void 0:o.abort())}catch(l){return Q(t,l,n)}finally{e=!1}},X=t=>y(p(t)),Y=t=>{const s=o=>{var a,d;const l=new Set((a=i.get(o))==null?void 0:a.t);return(d=v.get(o))==null||d[1].forEach(f=>{l.add(f)}),l},u=new Array,n=new Set,e=o=>{if(!n.has(o)){n.add(o);for(const a of s(o))o!==a&&e(a);u.push(o)}};e(t);const c=new Set([t]);for(let o=u.length-1;o>=0;--o){const a=u[o],d=g(a);if(!d)continue;let l=!1;for(const f of d.d.keys())if(f!==a&&c.has(f)){l=!0;break}if(l){const f=p(a,!0);E(d,f)||c.add(a)}}},I=(t,...s)=>{const u=e=>y(p(e)),n=(e,...c)=>{const o=h.length>0;o||h.push(new Set([e]));let a;if(M(t,e)){if(!$(e))throw new Error("atom not writable");const d=g(e),l=H(e,c[0]);E(d,l)||Y(e)}else a=I(e,...c);return o||j(h.pop()),a};return t.write(u,n,...s)},z=(t,...s)=>{h.push(new Set([t]));const u=I(t,...s);return j(h.pop()),u},D=(t,s,u)=>{var n;const e=i.get(t);if(e)return s&&e.t.add(s),e;const c=u||[];(n=g(t))==null||n.d.forEach((a,d)=>{d!==t&&D(d,t,c)}),p(t);const o={t:new Set(s&&[s]),l:new Set};if(i.set(t,o),A(t)&&t.onMount){const{onMount:a}=t;c.push(()=>{const d=a((...l)=>z(t,...l));d&&(o.u=d)})}return u||c.forEach(a=>a()),o},Z=(t,s)=>!s.l.size&&(!s.t.size||s.t.size===1&&s.t.has(t)),P=(t,s)=>{if(!Z(t,s))return;const u=s.u;u&&u(),i.delete(t);const n=g(t);n&&(S(n)&&O(n.v),n.d.forEach((e,c)=>{if(c!==t){const o=i.get(c);o&&(o.t.delete(t),P(c,o))}}))},J=(t,s,u)=>{const n=new Set(s.d.keys()),e=new Set;u==null||u.forEach((c,o)=>{if(n.has(o)){n.delete(o);return}e.add(o);const a=i.get(o);a&&a.t.delete(t)}),n.forEach(c=>{D(c,t)}),e.forEach(c=>{const o=i.get(c);o&&P(c,o)})},j=t=>{const s=[],u=n=>{var e;if(!v.has(n))return;const[c,o]=v.get(n);v.delete(n),s.push([n,c]),o.forEach(u),(e=g(n))==null||e.d.forEach((a,d)=>u(d))};t.forEach(u),s.forEach(([n,e])=>{const c=g(n);if(c&&c!==e){const o=i.get(n);o&&c.d!==(e==null?void 0:e.d)&&J(n,c,e==null?void 0:e.d),o&&!(!S(e)&&(E(e,c)||q(e,c)))&&o.l.forEach(a=>a())}})};return{get:X,set:z,sub:(t,s)=>{const u=D(t);j([t]);const n=u.l;return n.add(s),()=>{n.delete(s),P(t,u)}}}};let b;W({createStore:x,getDefaultStore:()=>(b||(b=x()),b)})}}});

@@ -13,2 +13,3 @@ System.register(['jotai/vanilla'], (function (exports) {

atomWithDefault: atomWithDefault,
atomWithLazy: atomWithLazy,
atomWithObservable: atomWithObservable,

@@ -102,5 +103,5 @@ atomWithReducer: atomWithReducer,

const getCached$2 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);
const cache1$4 = /* @__PURE__ */ new WeakMap();
const cache1$3 = /* @__PURE__ */ new WeakMap();
const memo3 = (create, dep1, dep2, dep3) => {
const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$4, dep1);
const cache2 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache1$3, dep1);
const cache3 = getCached$2(() => /* @__PURE__ */ new WeakMap(), cache2, dep2);

@@ -123,5 +124,2 @@ return getCached$2(create, cache3, dep3);

const value = get(anAtom);
if (value instanceof Promise || prev instanceof Promise) {
return Promise.all([value, prev]).then(selectValue);
}
return selectValue([value, prev]);

@@ -138,4 +136,3 @@ });

const cache1$3 = /* @__PURE__ */ new WeakMap();
const memo1$1 = (create, dep1) => (cache1$3.has(dep1) ? cache1$3 : cache1$3.set(dep1, create())).get(dep1);
const frozenAtoms = /* @__PURE__ */ new WeakSet();
const deepFreeze = (obj) => {

@@ -153,20 +150,36 @@ if (typeof obj !== "object" || obj === null)

function freezeAtom(anAtom) {
return memo1$1(() => {
const frozenAtom = atom(
(get) => deepFreeze(get(anAtom)),
(_get, set, arg) => set(anAtom, arg)
);
return frozenAtom;
}, anAtom);
}
function freezeAtomCreator(createAtom) {
return (...params) => {
const anAtom = createAtom(...params);
const origRead = anAtom.read;
anAtom.read = function(get, options) {
return deepFreeze(origRead.call(this, get, options));
};
if (frozenAtoms.has(anAtom)) {
return anAtom;
}
frozenAtoms.add(anAtom);
const origRead = anAtom.read;
anAtom.read = function(get, options) {
return deepFreeze(origRead.call(this, get, options));
};
if ("write" in anAtom) {
const origWrite = anAtom.write;
anAtom.write = function(get, set, ...args) {
return origWrite.call(
this,
get,
(...setArgs) => {
if (setArgs[0] === anAtom) {
setArgs[1] = deepFreeze(setArgs[1]);
}
return set(...setArgs);
},
...args
);
};
}
return anAtom;
}
function freezeAtomCreator(createAtom) {
{
console.warn(
"[DEPRECATED] freezeAtomCreator is deprecated, define it on users end"
);
}
return (...args) => freezeAtom(createAtom(...args));
}

@@ -735,4 +748,15 @@ const getCached$1 = (c, m, k) => (m.has(k) ? m : m.set(k, c())).get(k);

function atomWithLazy(makeInitial) {
const a = atom(void 0);
delete a.init;
Object.defineProperty(a, "init", {
get() {
return makeInitial();
}
});
return a;
}
})
};
}));

@@ -1,1 +0,1 @@

System.register(["jotai/vanilla"],function(P){"use strict";var m;return{setters:[function(W){m=W.atom}],execute:function(){P({atomFamily:J,atomWithDefault:Y,atomWithObservable:nt,atomWithReducer:z,atomWithRefresh:ft,atomWithReset:$,atomWithStorage:et,createJSONStorage:R,freezeAtom:q,freezeAtomCreator:B,loadable:st,selectAtom:F,splitAtom:X,unstable_withStorageValidator:Z,unwrap:lt});const W=P("RESET",Symbol(""));function $(n){const e=m(n,(r,u,a)=>{const o=typeof a=="function"?a(r(e)):a;u(e,o===W?n:o)});return e}function z(n,e){return m(n,function(r,u,a){u(this,e(r(this),a))})}function J(n,e){let r=null;const u=new Map,a=o=>{let t;if(e===void 0)t=u.get(o);else for(const[c,i]of u)if(e(c,o)){t=i;break}if(t!==void 0)if(r!=null&&r(t[1],o))a.remove(o);else return t[0];const s=n(o);return u.set(o,[s,Date.now()]),s};return a.remove=o=>{if(e===void 0)u.delete(o);else for(const[t]of u)if(e(t,o)){u.delete(t);break}},a.setShouldRemove=o=>{if(r=o,!!r)for(const[t,s]of u)r(s[1],t)&&u.delete(t)},a}const I=(n,e,r)=>(e.has(r)?e:e.set(r,n())).get(r),_=new WeakMap,C=(n,e,r,u)=>{const a=I(()=>new WeakMap,_,e),o=I(()=>new WeakMap,a,r);return I(n,o,u)};function F(n,e,r=Object.is){return C(()=>{const u=Symbol(),a=([t,s])=>{if(s===u)return e(t);const c=e(t,s);return r(s,c)?s:c},o=m(t=>{const s=t(o),c=t(n);return c instanceof Promise||s instanceof Promise?Promise.all([c,s]).then(a):a([c,s])});return o.init=u,o},n,e,r)}const L=new WeakMap,K=(n,e)=>(L.has(e)?L:L.set(e,n())).get(e),E=n=>{if(typeof n!="object"||n===null)return;Object.freeze(n);const e=Object.getOwnPropertyNames(n);for(const r of e){const u=n[r];E(u)}return n};function q(n){return K(()=>m(e=>E(e(n)),(e,r,u)=>r(n,u)),n)}function B(n){return(...e)=>{const r=n(...e),u=r.read;return r.read=function(a,o){return E(u.call(this,a,o))},r}}const V=(n,e,r)=>(e.has(r)?e:e.set(r,n())).get(r),G=new WeakMap,H=(n,e,r)=>{const u=V(()=>new WeakMap,G,e);return V(n,u,r)},Q={},j=n=>!!n.write,U=n=>typeof n=="function";function X(n,e){return H(()=>{const r=new WeakMap,u=(t,s)=>{let c=r.get(t);if(c)return c;const i=s&&r.get(s),l=[],f=[];return t.forEach((v,b)=>{const h=e?e(v):b;f[b]=h;const y=i&&i.atomList[i.keyList.indexOf(h)];if(y){l[b]=y;return}const O=g=>{const d=g(a),p=g(n),k=u(p,d==null?void 0:d.arr).keyList.indexOf(h);if(k<0||k>=p.length){const w=t[u(t).keyList.indexOf(h)];if(w)return w;throw new Error("splitAtom: index out of bounds for read")}return p[k]},M=(g,d,p)=>{const k=g(a),w=g(n),S=u(w,k==null?void 0:k.arr).keyList.indexOf(h);if(S<0||S>=w.length)throw new Error("splitAtom: index out of bounds for write");const T=U(p)?p(w[S]):p;Object.is(w[S],T)||d(n,[...w.slice(0,S),T,...w.slice(S+1)])};l[b]=j(n)?m(O,M):m(O)}),i&&i.keyList.length===f.length&&i.keyList.every((v,b)=>v===f[b])?c=i:c={arr:t,atomList:l,keyList:f},r.set(t,c),c},a=m(t=>{const s=t(a),c=t(n);return u(c,s==null?void 0:s.arr)});a.init=void 0;const o=j(n)?m(t=>t(a).atomList,(t,s,c)=>{switch(c.type){case"remove":{const i=t(o).indexOf(c.atom);if(i>=0){const l=t(n);s(n,[...l.slice(0,i),...l.slice(i+1)])}break}case"insert":{const i=c.before?t(o).indexOf(c.before):t(o).length;if(i>=0){const l=t(n);s(n,[...l.slice(0,i),c.value,...l.slice(i)])}break}case"move":{const i=t(o).indexOf(c.atom),l=c.before?t(o).indexOf(c.before):t(o).length;if(i>=0&&l>=0){const f=t(n);i<l?s(n,[...f.slice(0,i),...f.slice(i+1,l),f[i],...f.slice(l)]):s(n,[...f.slice(0,l),f[i],...f.slice(l,i),...f.slice(i+1)])}break}}}):m(t=>t(a).atomList);return o},n,e||Q)}function Y(n){const e=Symbol(),r=m(e),u=m((a,o)=>{const t=a(r);return t!==e?t:n(a,o)},(a,o,t)=>{if(t===W)o(r,e);else if(typeof t=="function"){const s=a(u);o(r,t(s))}else o(r,t)});return u}const A=n=>typeof(n==null?void 0:n.then)=="function";function Z(n){return e=>({...e,getItem:(r,u)=>{const a=t=>n(t)?t:u,o=e.getItem(r,u);return A(o)?o.then(a):a(o)}})}function R(n=()=>{try{return window.localStorage}catch(r){return}},e){let r,u;const a={getItem:(o,t)=>{var s,c;const i=f=>{if(f=f||"",r!==f){try{u=JSON.parse(f,e==null?void 0:e.reviver)}catch(v){return t}r=f}return u},l=(c=(s=n())==null?void 0:s.getItem(o))!=null?c:null;return A(l)?l.then(i):i(l)},setItem:(o,t)=>{var s;return(s=n())==null?void 0:s.setItem(o,JSON.stringify(t,e==null?void 0:e.replacer))},removeItem:o=>{var t;return(t=n())==null?void 0:t.removeItem(o)}};return typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&(a.subscribe=(o,t,s)=>{if(!(n()instanceof window.Storage))return()=>{};const c=i=>{if(i.storageArea===n()&&i.key===o){let l;try{l=JSON.parse(i.newValue||"")}catch(f){l=s}t(l)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}}),a}const tt=R();function et(n,e,r=tt,u){const a=u==null?void 0:u.getOnInit,o=m(a?r.getItem(n,e):e);return o.onMount=t=>{t(r.getItem(n,e));let s;return r.subscribe&&(s=r.subscribe(n,t,e)),s},m(t=>t(o),(t,s,c)=>{const i=typeof c=="function"?c(t(o)):c;return i===W?(s(o,e),r.removeItem(n)):i instanceof Promise?i.then(l=>(s(o,l),r.setItem(n,l))):(s(o,i),r.setItem(n,i))})}function nt(n,e){const r=a=>{if("e"in a)throw a.e;return a.d},u=m(a=>{var o;let t=n(a);const s=(o=t[Symbol.observable])==null?void 0:o.call(t);s&&(t=s);let c;const i=()=>new Promise(d=>{c=d}),l=e&&"initialValue"in e?{d:typeof e.initialValue=="function"?e.initialValue():e.initialValue}:i();let f,v;const b=d=>{v=d,c==null||c(d),f==null||f(d)};let h,y;const O=()=>!f,M=()=>{h&&(clearTimeout(y),h.unsubscribe()),h=t.subscribe({next:d=>b({d}),error:d=>b({e:d}),complete:()=>{}}),O()&&e!=null&&e.unstable_timeout&&(y=setTimeout(()=>{h&&(h.unsubscribe(),h=void 0)},e.unstable_timeout))};M();const g=m(v||l);return g.onMount=d=>(f=d,v&&d(v),h?clearTimeout(y):M(),()=>{f=void 0,h&&(h.unsubscribe(),h=void 0)}),[g,t,i,M,O]});return m(a=>{const[o]=a(u),t=a(o);return t instanceof Promise?t.then(r):r(t)},(a,o,t)=>{const[s,c,i,l,f]=a(u);if("next"in c)f()&&(o(s,i()),l()),c.next(t);else throw new Error("observable is not subject")})}const x=new WeakMap,rt=(n,e)=>(x.has(e)?x:x.set(e,n())).get(e),ot=n=>n instanceof Promise,D={state:"loading"};function st(n){return rt(()=>{const e=new WeakMap,r=m(0),u=m((a,{setSelf:o})=>{a(r);let t;try{t=a(n)}catch(l){return{state:"hasError",error:l}}if(!ot(t))return{state:"hasData",data:t};const s=t,c=e.get(s);return c||(s.status==="fulfilled"?e.set(s,{state:"hasData",data:s.value}):s.status==="rejected"?e.set(s,{state:"hasError",error:s.reason}):s.then(l=>{e.set(s,{state:"hasData",data:l})},l=>{e.set(s,{state:"hasError",error:l})}).finally(o),e.get(s)||(e.set(s,D),D))},(a,o)=>{o(r,t=>t+1)});return m(a=>a(u))},n)}const N=(n,e,r)=>(e.has(r)?e:e.set(r,n())).get(r),it=new WeakMap,at=(n,e,r)=>{const u=N(()=>new WeakMap,it,e);return N(n,u,r)},ut=n=>n instanceof Promise,ct=()=>{};function lt(n,e=ct){return at(()=>{const r=new WeakMap,u=new WeakMap,a=m(0),o=m((t,{setSelf:s})=>{t(a);const c=t(o),i=t(n);if(!ut(i))return{v:i};if(i!==(c==null?void 0:c.p)&&(i.status==="fulfilled"?u.set(i,i.value):i.status==="rejected"?r.set(i,i.reason):i.then(l=>u.set(i,l),l=>r.set(i,l)).finally(s)),r.has(i))throw r.get(i);return u.has(i)?{p:i,v:u.get(i)}:c&&"v"in c?{p:i,f:e(c.v),v:c.v}:{p:i,f:e()}},(t,s)=>{s(a,c=>c+1)});return o.init=void 0,m(t=>{const s=t(o);return"f"in s?s.f:s.v},(t,s,...c)=>s(n,...c))},n,e)}function ft(n,e){const r=m(0);return m((u,a)=>(u(r),n(u,a)),(u,a,...o)=>{if(o.length===0)a(r,t=>t+1);else if(e)return e(u,a,...o)})}}}});
System.register(["jotai/vanilla"],function(x){"use strict";var d;return{setters:[function(S){d=S.atom}],execute:function(){x({atomFamily:_,atomWithDefault:X,atomWithLazy:ft,atomWithObservable:et,atomWithReducer:$,atomWithRefresh:lt,atomWithReset:J,atomWithStorage:tt,createJSONStorage:z,freezeAtom:V,freezeAtomCreator:q,loadable:ot,selectAtom:K,splitAtom:U,unstable_withStorageValidator:Y,unwrap:ct});const S=x("RESET",Symbol(""));function J(e){const n=d(e,(r,u,a)=>{const o=typeof a=="function"?a(r(n)):a;u(n,o===S?e:o)});return n}function $(e,n){return d(e,function(r,u,a){u(this,n(r(this),a))})}function _(e,n){let r=null;const u=new Map,a=o=>{let t;if(n===void 0)t=u.get(o);else for(const[c,i]of u)if(n(c,o)){t=i;break}if(t!==void 0)if(r!=null&&r(t[1],o))a.remove(o);else return t[0];const s=e(o);return u.set(o,[s,Date.now()]),s};return a.remove=o=>{if(n===void 0)u.delete(o);else for(const[t]of u)if(n(t,o)){u.delete(t);break}},a.setShouldRemove=o=>{if(r=o,!!r)for(const[t,s]of u)r(s[1],t)&&u.delete(t)},a}const I=(e,n,r)=>(n.has(r)?n:n.set(r,e())).get(r),C=new WeakMap,F=(e,n,r,u)=>{const a=I(()=>new WeakMap,C,n),o=I(()=>new WeakMap,a,r);return I(e,o,u)};function K(e,n,r=Object.is){return F(()=>{const u=Symbol(),a=([t,s])=>{if(s===u)return n(t);const c=n(t,s);return r(s,c)?s:c},o=d(t=>{const s=t(o),c=t(e);return a([c,s])});return o.init=u,o},e,n,r)}const j=new WeakSet,M=e=>{if(typeof e!="object"||e===null)return;Object.freeze(e);const n=Object.getOwnPropertyNames(e);for(const r of n){const u=e[r];M(u)}return e};function V(e){if(j.has(e))return e;j.add(e);const n=e.read;if(e.read=function(r,u){return M(n.call(this,r,u))},"write"in e){const r=e.write;e.write=function(u,a,...o){return r.call(this,u,(...t)=>(t[0]===e&&(t[1]=M(t[1])),a(...t)),...o)}}return e}function q(e){return(...n)=>V(e(...n))}const A=(e,n,r)=>(n.has(r)?n:n.set(r,e())).get(r),B=new WeakMap,G=(e,n,r)=>{const u=A(()=>new WeakMap,B,n);return A(e,u,r)},H={},R=e=>!!e.write,Q=e=>typeof e=="function";function U(e,n){return G(()=>{const r=new WeakMap,u=(t,s)=>{let c=r.get(t);if(c)return c;const i=s&&r.get(s),l=[],f=[];return t.forEach((v,b)=>{const h=n?n(v):b;f[b]=h;const y=i&&i.atomList[i.keyList.indexOf(h)];if(y){l[b]=y;return}const O=g=>{const m=g(a),p=g(e),W=u(p,m==null?void 0:m.arr).keyList.indexOf(h);if(W<0||W>=p.length){const w=t[u(t).keyList.indexOf(h)];if(w)return w;throw new Error("splitAtom: index out of bounds for read")}return p[W]},L=(g,m,p)=>{const W=g(a),w=g(e),k=u(w,W==null?void 0:W.arr).keyList.indexOf(h);if(k<0||k>=w.length)throw new Error("splitAtom: index out of bounds for write");const T=Q(p)?p(w[k]):p;Object.is(w[k],T)||m(e,[...w.slice(0,k),T,...w.slice(k+1)])};l[b]=R(e)?d(O,L):d(O)}),i&&i.keyList.length===f.length&&i.keyList.every((v,b)=>v===f[b])?c=i:c={arr:t,atomList:l,keyList:f},r.set(t,c),c},a=d(t=>{const s=t(a),c=t(e);return u(c,s==null?void 0:s.arr)});a.init=void 0;const o=R(e)?d(t=>t(a).atomList,(t,s,c)=>{switch(c.type){case"remove":{const i=t(o).indexOf(c.atom);if(i>=0){const l=t(e);s(e,[...l.slice(0,i),...l.slice(i+1)])}break}case"insert":{const i=c.before?t(o).indexOf(c.before):t(o).length;if(i>=0){const l=t(e);s(e,[...l.slice(0,i),c.value,...l.slice(i)])}break}case"move":{const i=t(o).indexOf(c.atom),l=c.before?t(o).indexOf(c.before):t(o).length;if(i>=0&&l>=0){const f=t(e);i<l?s(e,[...f.slice(0,i),...f.slice(i+1,l),f[i],...f.slice(l)]):s(e,[...f.slice(0,l),f[i],...f.slice(l,i),...f.slice(i+1)])}break}}}):d(t=>t(a).atomList);return o},e,n||H)}function X(e){const n=Symbol(),r=d(n),u=d((a,o)=>{const t=a(r);return t!==n?t:e(a,o)},(a,o,t)=>{if(t===S)o(r,n);else if(typeof t=="function"){const s=a(u);o(r,t(s))}else o(r,t)});return u}const P=e=>typeof(e==null?void 0:e.then)=="function";function Y(e){return n=>({...n,getItem:(r,u)=>{const a=t=>e(t)?t:u,o=n.getItem(r,u);return P(o)?o.then(a):a(o)}})}function z(e=()=>{try{return window.localStorage}catch(r){return}},n){let r,u;const a={getItem:(o,t)=>{var s,c;const i=f=>{if(f=f||"",r!==f){try{u=JSON.parse(f,n==null?void 0:n.reviver)}catch(v){return t}r=f}return u},l=(c=(s=e())==null?void 0:s.getItem(o))!=null?c:null;return P(l)?l.then(i):i(l)},setItem:(o,t)=>{var s;return(s=e())==null?void 0:s.setItem(o,JSON.stringify(t,n==null?void 0:n.replacer))},removeItem:o=>{var t;return(t=e())==null?void 0:t.removeItem(o)}};return typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&(a.subscribe=(o,t,s)=>{if(!(e()instanceof window.Storage))return()=>{};const c=i=>{if(i.storageArea===e()&&i.key===o){let l;try{l=JSON.parse(i.newValue||"")}catch(f){l=s}t(l)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}}),a}const Z=z();function tt(e,n,r=Z,u){const a=u==null?void 0:u.getOnInit,o=d(a?r.getItem(e,n):n);return o.onMount=t=>{t(r.getItem(e,n));let s;return r.subscribe&&(s=r.subscribe(e,t,n)),s},d(t=>t(o),(t,s,c)=>{const i=typeof c=="function"?c(t(o)):c;return i===S?(s(o,n),r.removeItem(e)):i instanceof Promise?i.then(l=>(s(o,l),r.setItem(e,l))):(s(o,i),r.setItem(e,i))})}function et(e,n){const r=a=>{if("e"in a)throw a.e;return a.d},u=d(a=>{var o;let t=e(a);const s=(o=t[Symbol.observable])==null?void 0:o.call(t);s&&(t=s);let c;const i=()=>new Promise(m=>{c=m}),l=n&&"initialValue"in n?{d:typeof n.initialValue=="function"?n.initialValue():n.initialValue}:i();let f,v;const b=m=>{v=m,c==null||c(m),f==null||f(m)};let h,y;const O=()=>!f,L=()=>{h&&(clearTimeout(y),h.unsubscribe()),h=t.subscribe({next:m=>b({d:m}),error:m=>b({e:m}),complete:()=>{}}),O()&&n!=null&&n.unstable_timeout&&(y=setTimeout(()=>{h&&(h.unsubscribe(),h=void 0)},n.unstable_timeout))};L();const g=d(v||l);return g.onMount=m=>(f=m,v&&m(v),h?clearTimeout(y):L(),()=>{f=void 0,h&&(h.unsubscribe(),h=void 0)}),[g,t,i,L,O]});return d(a=>{const[o]=a(u),t=a(o);return t instanceof Promise?t.then(r):r(t)},(a,o,t)=>{const[s,c,i,l,f]=a(u);if("next"in c)f()&&(o(s,i()),l()),c.next(t);else throw new Error("observable is not subject")})}const E=new WeakMap,nt=(e,n)=>(E.has(n)?E:E.set(n,e())).get(n),rt=e=>e instanceof Promise,D={state:"loading"};function ot(e){return nt(()=>{const n=new WeakMap,r=d(0),u=d((a,{setSelf:o})=>{a(r);let t;try{t=a(e)}catch(l){return{state:"hasError",error:l}}if(!rt(t))return{state:"hasData",data:t};const s=t,c=n.get(s);return c||(s.status==="fulfilled"?n.set(s,{state:"hasData",data:s.value}):s.status==="rejected"?n.set(s,{state:"hasError",error:s.reason}):s.then(l=>{n.set(s,{state:"hasData",data:l})},l=>{n.set(s,{state:"hasError",error:l})}).finally(o),n.get(s)||(n.set(s,D),D))},(a,o)=>{o(r,t=>t+1)});return d(a=>a(u))},e)}const N=(e,n,r)=>(n.has(r)?n:n.set(r,e())).get(r),st=new WeakMap,it=(e,n,r)=>{const u=N(()=>new WeakMap,st,n);return N(e,u,r)},at=e=>e instanceof Promise,ut=()=>{};function ct(e,n=ut){return it(()=>{const r=new WeakMap,u=new WeakMap,a=d(0),o=d((t,{setSelf:s})=>{t(a);const c=t(o),i=t(e);if(!at(i))return{v:i};if(i!==(c==null?void 0:c.p)&&(i.status==="fulfilled"?u.set(i,i.value):i.status==="rejected"?r.set(i,i.reason):i.then(l=>u.set(i,l),l=>r.set(i,l)).finally(s)),r.has(i))throw r.get(i);return u.has(i)?{p:i,v:u.get(i)}:c&&"v"in c?{p:i,f:n(c.v),v:c.v}:{p:i,f:n()}},(t,s)=>{s(a,c=>c+1)});return o.init=void 0,d(t=>{const s=t(o);return"f"in s?s.f:s.v},(t,s,...c)=>s(e,...c))},e,n)}function lt(e,n){const r=d(0);return d((u,a)=>(u(r),e(u,a)),(u,a,...o)=>{if(o.length===0)a(r,t=>t+1);else if(n)return n(u,a,...o)})}function ft(e){const n=d(void 0);return delete n.init,Object.defineProperty(n,"init",{get(){return e()}}),n}}}});
import { useAtom } from 'jotai/react';
import type { PrimitiveAtom } from 'jotai/vanilla';
type Options = Parameters<typeof useAtom>[1];
/**
* @deprecated please use a recipe instead
* https://github.com/pmndrs/jotai/pull/2467
*/
export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a?: Action) => Value, options?: Options): [

@@ -8,2 +12,6 @@ Value,

];
/**
* @deprecated please use a recipe instead
* https://github.com/pmndrs/jotai/pull/2467
*/
export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a: Action) => Value, options?: Options): [

@@ -10,0 +18,0 @@ Value,

export { atom } from './vanilla/atom';
export type { Atom, WritableAtom, PrimitiveAtom } from './vanilla/atom';
export { createStore, getDefaultStore } from './vanilla/store';
import * as store from './vanilla/store';
type CreateStore = typeof store.createStore;
type GetDefaultStore = typeof store.getDefaultStore;
export declare const createStore: CreateStore;
export declare const getDefaultStore: GetDefaultStore;
export type { Getter, Setter, ExtractAtomValue, ExtractAtomArgs, ExtractAtomResult, SetStateAction, } from './vanilla/typeUtils';
declare type Awaited<T> = T extends Promise<infer V> ? V : T;

@@ -41,3 +41,3 @@ import type { Atom, WritableAtom } from './atom';

};
type StoreListenerRev2 = (action: {
type DevListenerRev2 = (action: {
type: 'write';

@@ -57,11 +57,8 @@ flushed: Set<AnyAtom>;

}) => void;
type Store = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
dev_subscribe_store?: (l: StoreListenerRev2, rev: 2) => () => void;
dev_get_mounted_atoms?: () => IterableIterator<AnyAtom>;
dev_get_atom_state?: (a: AnyAtom) => AtomState | undefined;
dev_get_mounted?: (a: AnyAtom) => Mounted | undefined;
dev_restore_atoms?: (values: Iterable<readonly [
type DevStoreRev2 = {
dev_subscribe_store: (l: DevListenerRev2, rev: 2) => () => void;
dev_get_mounted_atoms: () => IterableIterator<AnyAtom>;
dev_get_atom_state: (a: AnyAtom) => AtomState | undefined;
dev_get_mounted: (a: AnyAtom) => Mounted | undefined;
dev_restore_atoms: (values: Iterable<readonly [
AnyAtom,

@@ -71,2 +68,10 @@ AnyValue

};
type PrdStore = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
};
type Store = PrdStore & Partial<DevStoreRev2>;
export type INTERNAL_DevStoreRev2 = DevStoreRev2;
export type INTERNAL_PrdStore = PrdStore;
/**

@@ -73,0 +78,0 @@ * Create a new store. Each store is an independent, isolated universe of atom

@@ -14,2 +14,3 @@ export { RESET } from './utils/constants';

export { atomWithRefresh } from './utils/atomWithRefresh';
export { atomWithLazy } from './utils/atomWithLazy';
declare type Awaited<T> = T extends Promise<infer V> ? V : T;
import type { Atom } from 'jotai/vanilla';
export declare function freezeAtom<AtomType extends Atom<unknown>>(anAtom: AtomType): AtomType;
export declare function freezeAtomCreator<CreateAtom extends (...params: never[]) => Atom<unknown>>(createAtom: CreateAtom): CreateAtom;
/**
* @deprecated Define it on users end
*/
export declare function freezeAtomCreator<CreateAtom extends (...args: unknown[]) => Atom<unknown>>(createAtom: CreateAtom): CreateAtom;
declare type Awaited<T> = T extends Promise<infer V> ? V : T;
import type { Atom } from 'jotai/vanilla';
export declare function selectAtom<Value, Slice>(anAtom: Atom<Value>, selector: (v: Awaited<Value>, prevSlice?: Slice) => Slice, equalityFn?: (a: Slice, b: Slice) => boolean): Atom<Value extends Promise<unknown> ? Promise<Slice> : Slice>;
export declare function selectAtom<Value, Slice>(anAtom: Atom<Value>, selector: (v: Value, prevSlice?: Slice) => Slice, equalityFn?: (a: Slice, b: Slice) => boolean): Atom<Slice>;
declare type Awaited<T> = T extends Promise<infer V> ? V : T;
import { useAtom } from 'jotai/react';
import type { PrimitiveAtom } from 'jotai/vanilla';
type Options = Parameters<typeof useAtom>[1];
/**
* @deprecated please use a recipe instead
* https://github.com/pmndrs/jotai/pull/2467
*/
export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a?: Action) => Value, options?: Options): [

@@ -8,2 +12,6 @@ Value,

];
/**
* @deprecated please use a recipe instead
* https://github.com/pmndrs/jotai/pull/2467
*/
export declare function useReducerAtom<Value, Action>(anAtom: PrimitiveAtom<Value>, reducer: (v: Value, a: Action) => Value, options?: Options): [

@@ -10,0 +18,0 @@ Value,

export { atom } from './vanilla/atom';
export type { Atom, WritableAtom, PrimitiveAtom } from './vanilla/atom';
export { createStore, getDefaultStore } from './vanilla/store';
import * as store from './vanilla/store';
type CreateStore = typeof store.createStore;
type GetDefaultStore = typeof store.getDefaultStore;
export declare const createStore: CreateStore;
export declare const getDefaultStore: GetDefaultStore;
export type { Getter, Setter, ExtractAtomValue, ExtractAtomArgs, ExtractAtomResult, SetStateAction, } from './vanilla/typeUtils';
declare type Awaited<T> = T extends Promise<infer V> ? V : T;

@@ -41,3 +41,3 @@ import type { Atom, WritableAtom } from './atom';

};
type StoreListenerRev2 = (action: {
type DevListenerRev2 = (action: {
type: 'write';

@@ -57,11 +57,8 @@ flushed: Set<AnyAtom>;

}) => void;
type Store = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
dev_subscribe_store?: (l: StoreListenerRev2, rev: 2) => () => void;
dev_get_mounted_atoms?: () => IterableIterator<AnyAtom>;
dev_get_atom_state?: (a: AnyAtom) => AtomState | undefined;
dev_get_mounted?: (a: AnyAtom) => Mounted | undefined;
dev_restore_atoms?: (values: Iterable<readonly [
type DevStoreRev2 = {
dev_subscribe_store: (l: DevListenerRev2, rev: 2) => () => void;
dev_get_mounted_atoms: () => IterableIterator<AnyAtom>;
dev_get_atom_state: (a: AnyAtom) => AtomState | undefined;
dev_get_mounted: (a: AnyAtom) => Mounted | undefined;
dev_restore_atoms: (values: Iterable<readonly [
AnyAtom,

@@ -71,2 +68,10 @@ AnyValue

};
type PrdStore = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
};
type Store = PrdStore & Partial<DevStoreRev2>;
export type INTERNAL_DevStoreRev2 = DevStoreRev2;
export type INTERNAL_PrdStore = PrdStore;
/**

@@ -73,0 +78,0 @@ * Create a new store. Each store is an independent, isolated universe of atom

@@ -14,2 +14,3 @@ export { RESET } from './utils/constants';

export { atomWithRefresh } from './utils/atomWithRefresh';
export { atomWithLazy } from './utils/atomWithLazy';
declare type Awaited<T> = T extends Promise<infer V> ? V : T;
import type { Atom } from 'jotai/vanilla';
export declare function freezeAtom<AtomType extends Atom<unknown>>(anAtom: AtomType): AtomType;
export declare function freezeAtomCreator<CreateAtom extends (...params: never[]) => Atom<unknown>>(createAtom: CreateAtom): CreateAtom;
/**
* @deprecated Define it on users end
*/
export declare function freezeAtomCreator<CreateAtom extends (...args: unknown[]) => Atom<unknown>>(createAtom: CreateAtom): CreateAtom;
declare type Awaited<T> = T extends Promise<infer V> ? V : T;
import type { Atom } from 'jotai/vanilla';
export declare function selectAtom<Value, Slice>(anAtom: Atom<Value>, selector: (v: Awaited<Value>, prevSlice?: Slice) => Slice, equalityFn?: (a: Slice, b: Slice) => boolean): Atom<Value extends Promise<unknown> ? Promise<Slice> : Slice>;
export declare function selectAtom<Value, Slice>(anAtom: Atom<Value>, selector: (v: Value, prevSlice?: Slice) => Slice, equalityFn?: (a: Slice, b: Slice) => boolean): Atom<Slice>;
declare type Awaited<T> = T extends Promise<infer V> ? V : T;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path'), require('@babel/template')) :
typeof define === 'function' && define.amd ? define(['path', '@babel/template'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jotaiBabelPluginDebugLabel = factory(global.path, global._templateBuilder));
})(this, (function (path, _templateBuilder) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@babel/template')) :
typeof define === 'function' && define.amd ? define(['@babel/template'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jotaiBabelPluginDebugLabel = factory(global._templateBuilder));
})(this, (function (_templateBuilder) { 'use strict';

@@ -33,6 +33,6 @@ function isAtom(t, callee, customAtomNames) {

if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';
var displayName = path.basename(filename, path.extname(filename));
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');
var displayName = filename.split('/').pop();
if (displayName === 'index') {
displayName = path.basename(path.dirname(filename));
displayName = filename.slice(0, -'/index'.length).split('/').pop() || 'unknown';
}

@@ -39,0 +39,0 @@ var buildExport = templateBuilder("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ");

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("path"),require("@babel/template")):"function"==typeof define&&define.amd?define(["path","@babel/template"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).jotaiBabelPluginDebugLabel=t(e.path,e._templateBuilder)}(this,(function(e,t){"use strict";function i(e,t,i){void 0===i&&(i=[]);var o=[].concat(a,i);if(e.isIdentifier(t)&&o.includes(t.name))return!0;if(e.isMemberExpression(t)){var n=t.property;if(e.isIdentifier(n)&&o.includes(n.name))return!0}return!1}var a=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],o=t.default||t;return function(t,a){var n=t.types;return{visitor:{ExportDefaultDeclaration:function(t,r){var m=t.node;if(n.isCallExpression(m.declaration)&&i(n,m.declaration.callee,null==a?void 0:a.customAtomNames)){var l=r.filename||"unknown",s=e.basename(l,e.extname(l));"index"===s&&(s=e.basename(e.dirname(l)));var d=o("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ")({atomIdentifier:n.identifier(s),atom:m.declaration});t.replaceWithMultiple(d)}},VariableDeclarator:function(e){n.isIdentifier(e.node.id)&&n.isCallExpression(e.node.init)&&i(n,e.node.init.callee,null==a?void 0:a.customAtomNames)&&e.parentPath.insertAfter(n.expressionStatement(n.assignmentExpression("=",n.memberExpression(n.identifier(e.node.id.name),n.identifier("debugLabel")),n.stringLiteral(e.node.id.name))))}}}}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@babel/template")):"function"==typeof define&&define.amd?define(["@babel/template"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).jotaiBabelPluginDebugLabel=t(e._templateBuilder)}(this,(function(e){"use strict";function t(e,t,a){void 0===a&&(a=[]);var o=[].concat(i,a);if(e.isIdentifier(t)&&o.includes(t.name))return!0;if(e.isMemberExpression(t)){var n=t.property;if(e.isIdentifier(n)&&o.includes(n.name))return!0}return!1}var i=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],a=e.default||e;return function(e,i){var o=e.types;return{visitor:{ExportDefaultDeclaration:function(e,n){var r=e.node;if(o.isCallExpression(r.declaration)&&t(o,r.declaration.callee,null==i?void 0:i.customAtomNames)){var l=(n.filename||"unknown").replace(/\.\w+$/,""),m=l.split("/").pop();"index"===m&&(m=l.slice(0,-6).split("/").pop()||"unknown");var s=a("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ")({atomIdentifier:o.identifier(m),atom:r.declaration});e.replaceWithMultiple(s)}},VariableDeclarator:function(e){o.isIdentifier(e.node.id)&&o.isCallExpression(e.node.init)&&t(o,e.node.init.callee,null==i?void 0:i.customAtomNames)&&e.parentPath.insertAfter(o.expressionStatement(o.assignmentExpression("=",o.memberExpression(o.identifier(e.node.id.name),o.identifier("debugLabel")),o.stringLiteral(e.node.id.name))))}}}}}));
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('path'), require('@babel/template')) :
typeof define === 'function' && define.amd ? define(['path', '@babel/template'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jotaiBabelPreset = factory(global.path, global._templateBuilder));
})(this, (function (path, _templateBuilder) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@babel/template')) :
typeof define === 'function' && define.amd ? define(['@babel/template'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.jotaiBabelPreset = factory(global._templateBuilder));
})(this, (function (_templateBuilder) { 'use strict';

@@ -33,6 +33,6 @@ function isAtom(t, callee, customAtomNames) {

if (t.isCallExpression(node.declaration) && isAtom(t, node.declaration.callee, options == null ? void 0 : options.customAtomNames)) {
var filename = state.filename || 'unknown';
var displayName = path.basename(filename, path.extname(filename));
var filename = (state.filename || 'unknown').replace(/\.\w+$/, '');
var displayName = filename.split('/').pop();
if (displayName === 'index') {
displayName = path.basename(path.dirname(filename));
displayName = filename.slice(0, -'/index'.length).split('/').pop() || 'unknown';
}

@@ -39,0 +39,0 @@ var buildExport = templateBuilder$1("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ");

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("path"),require("@babel/template")):"function"==typeof define&&define.amd?define(["path","@babel/template"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).jotaiBabelPreset=t(e.path,e._templateBuilder)}(this,(function(e,t){"use strict";function a(e,t,a){void 0===a&&(a=[]);var n=[].concat(i,a);if(e.isIdentifier(t)&&n.includes(t.name))return!0;if(e.isMemberExpression(t)){var o=t.property;if(e.isIdentifier(o)&&n.includes(o.name))return!0}return!1}var i=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],n=t.default||t;function o(t,i){var o=t.types;return{visitor:{ExportDefaultDeclaration:function(t,r){var l=t.node;if(o.isCallExpression(l.declaration)&&a(o,l.declaration.callee,null==i?void 0:i.customAtomNames)){var m=r.filename||"unknown",s=e.basename(m,e.extname(m));"index"===s&&(s=e.basename(e.dirname(m)));var d=n("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ")({atomIdentifier:o.identifier(s),atom:l.declaration});t.replaceWithMultiple(d)}},VariableDeclarator:function(e){o.isIdentifier(e.node.id)&&o.isCallExpression(e.node.init)&&a(o,e.node.init.callee,null==i?void 0:i.customAtomNames)&&e.parentPath.insertAfter(o.expressionStatement(o.assignmentExpression("=",o.memberExpression(o.identifier(e.node.id.name),o.identifier("debugLabel")),o.stringLiteral(e.node.id.name))))}}}}var r=t.default||t;function l(e,t){var i=e.types;return{pre:function(e){if(!e.opts.filename)throw new Error("Filename must be available")},visitor:{Program:{exit:function(e){var t=r("\n globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {\n cache: new Map(),\n get(name, inst) { \n if (this.cache.has(name)) {\n return this.cache.get(name)\n }\n this.cache.set(name, inst)\n return inst\n },\n }")();e.unshiftContainer("body",t)}},ExportDefaultDeclaration:function(e,n){var o=e.node;if(i.isCallExpression(o.declaration)&&a(i,o.declaration.callee,null==t?void 0:t.customAtomNames)){var l=(n.filename||"unknown")+"/defaultExport",m=r("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:i.stringLiteral(l),atom:o.declaration});e.replaceWith(m)}},VariableDeclarator:function(e,n){var o,l;if(i.isIdentifier(e.node.id)&&i.isCallExpression(e.node.init)&&a(i,e.node.init.callee,null==t?void 0:t.customAtomNames)&&(null!=(o=e.parentPath.parentPath)&&o.isProgram()||null!=(l=e.parentPath.parentPath)&&l.isExportNamedDeclaration())){var m=(n.filename||"unknown")+"/"+e.node.id.name,s=r("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:i.identifier(e.node.id.name),atomKey:i.stringLiteral(m),atom:e.node.init});e.parentPath.replaceWith(s)}}}}}return function(e,t){return{plugins:[[o,t],[l,t]]}}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@babel/template")):"function"==typeof define&&define.amd?define(["@babel/template"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).jotaiBabelPreset=t(e._templateBuilder)}(this,(function(e){"use strict";function t(e,t,a){void 0===a&&(a=[]);var n=[].concat(i,a);if(e.isIdentifier(t)&&n.includes(t.name))return!0;if(e.isMemberExpression(t)){var o=t.property;if(e.isIdentifier(o)&&n.includes(o.name))return!0}return!1}var i=["atom","atomFamily","atomWithDefault","atomWithObservable","atomWithReducer","atomWithReset","atomWithStorage","freezeAtom","loadable","selectAtom","splitAtom","unwrap","atomWithMachine","atomWithImmer","atomWithProxy","atomWithQuery","atomWithMutation","atomWithSubscription","atomWithStore","atomWithHash","atomWithLocation","focusAtom","atomWithValidate","validateAtoms","atomWithCache","atomWithRecoilValue"],a=e.default||e;function n(e,i){var n=e.types;return{visitor:{ExportDefaultDeclaration:function(e,o){var r=e.node;if(n.isCallExpression(r.declaration)&&t(n,r.declaration.callee,null==i?void 0:i.customAtomNames)){var l=(o.filename||"unknown").replace(/\.\w+$/,""),m=l.split("/").pop();"index"===m&&(m=l.slice(0,-6).split("/").pop()||"unknown");var s=a("\n const %%atomIdentifier%% = %%atom%%;\n export default %%atomIdentifier%%\n ")({atomIdentifier:n.identifier(m),atom:r.declaration});e.replaceWithMultiple(s)}},VariableDeclarator:function(e){n.isIdentifier(e.node.id)&&n.isCallExpression(e.node.init)&&t(n,e.node.init.callee,null==i?void 0:i.customAtomNames)&&e.parentPath.insertAfter(n.expressionStatement(n.assignmentExpression("=",n.memberExpression(n.identifier(e.node.id.name),n.identifier("debugLabel")),n.stringLiteral(e.node.id.name))))}}}}var o=e.default||e;function r(e,i){var a=e.types;return{pre:function(e){if(!e.opts.filename)throw new Error("Filename must be available")},visitor:{Program:{exit:function(e){var t=o("\n globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {\n cache: new Map(),\n get(name, inst) { \n if (this.cache.has(name)) {\n return this.cache.get(name)\n }\n this.cache.set(name, inst)\n return inst\n },\n }")();e.unshiftContainer("body",t)}},ExportDefaultDeclaration:function(e,n){var r=e.node;if(a.isCallExpression(r.declaration)&&t(a,r.declaration.callee,null==i?void 0:i.customAtomNames)){var l=(n.filename||"unknown")+"/defaultExport",m=o("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:a.stringLiteral(l),atom:r.declaration});e.replaceWith(m)}},VariableDeclarator:function(e,n){var r,l;if(a.isIdentifier(e.node.id)&&a.isCallExpression(e.node.init)&&t(a,e.node.init.callee,null==i?void 0:i.customAtomNames)&&(null!=(r=e.parentPath.parentPath)&&r.isProgram()||null!=(l=e.parentPath.parentPath)&&l.isExportNamedDeclaration())){var m=(n.filename||"unknown")+"/"+e.node.id.name,s=o("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:a.identifier(e.node.id.name),atomKey:a.stringLiteral(m),atom:e.node.init});e.parentPath.replaceWith(s)}}}}}return function(e,t){return{plugins:[[n,t],[r,t]]}}}));

@@ -17,2 +17,5 @@ 'use client';

function useReducerAtom(anAtom, reducer, options) {
{
console.warn('[DEPRECATED] useReducerAtom is deprecated and will be removed in the future. Please create your own version using the recipe. https://github.com/pmndrs/jotai/pull/2467');
}
var _useAtom = react.useAtom(anAtom, options),

@@ -19,0 +22,0 @@ state = _useAtom[0],

@@ -118,3 +118,3 @@ (function (global, factory) {

};
var createStore = function createStore() {
var createStore$1 = function createStore() {
var atomStateMap = new WeakMap();

@@ -124,6 +124,6 @@ var mountedMap = new WeakMap();

var pendingMap = new WeakMap();
var storeListenersRev2;
var devListenersRev2;
var mountedAtoms;
{
storeListenersRev2 = new Set();
devListenersRev2 = new Set();
mountedAtoms = new Set();

@@ -435,3 +435,3 @@ }

{
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -460,3 +460,3 @@ type: 'async-write',

{
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -629,3 +629,3 @@ type: 'write',

{
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -641,3 +641,3 @@ type: 'sub',

{
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -655,9 +655,6 @@ type: 'unsub'

sub: subscribeAtom,
dev_subscribe_store: function dev_subscribe_store(l, rev) {
if (rev !== 2) {
throw new Error('The current StoreListener revision is 2.');
}
storeListenersRev2.add(l);
dev_subscribe_store: function dev_subscribe_store(l) {
devListenersRev2.add(l);
return function () {
storeListenersRev2.delete(l);
devListenersRev2.delete(l);
};

@@ -686,3 +683,3 @@ },

var flushed = flushPending(pendingStack.pop());
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -698,5 +695,5 @@ type: 'restore',

var defaultStore;
var getDefaultStore = function getDefaultStore() {
var getDefaultStore$1 = function getDefaultStore() {
if (!defaultStore) {
defaultStore = createStore();
defaultStore = createStore$1();
{

@@ -713,2 +710,5 @@ var _ref4;

var createStore = createStore$1;
var getDefaultStore = getDefaultStore$1;
exports.atom = atom;

@@ -715,0 +715,0 @@ exports.createStore = createStore;

@@ -1,1 +0,1 @@

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).jotaiVanilla={})}(this,(function(n){"use strict";var t=0;function r(n){return n(this)}function e(n,t,r){return t(this,"function"==typeof r?r(n(this)):r)}function i(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function o(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(r)return(r=r.call(n)).next.bind(r);if(Array.isArray(n)||(r=function(n,t){if(n){if("string"==typeof n)return i(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(n,t):void 0}}(n))||t&&n&&"number"==typeof n.length){r&&(n=r);var e=0;return function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=function(n,t){return n.unstable_is?n.unstable_is(t):t===n},f=function(n){return"init"in n},c=function(n){return!!n.write},v=new WeakMap,l=function(n,t){var r=v.get(n);r&&(v.delete(n),r(t))},d=function(n,t){n.status="fulfilled",n.value=t},s=function(n,t){n.status="rejected",n.reason=t},h=function(n,t){return!!n&&"v"in n&&"v"in t&&Object.is(n.v,t.v)},p=function(n,t){return!!n&&"e"in n&&"e"in t&&Object.is(n.e,t.e)},g=function(n){return!!n&&"v"in n&&n.v instanceof Promise},w=function(n){if("e"in n)throw n.e;return n.v},y=function(){var n=new WeakMap,t=new WeakMap,r=[],e=new WeakMap,i=function(t){return n.get(t)},a=function n(t,o){o.d.forEach((function(o,a){if(!e.has(a)){var u,f=i(a);null==(u=r[r.length-1])||u.add(a),e.set(a,[f,new Set]),f&&n(a,f)}e.get(a)[1].add(t)}))},y=function(t,o){var u,f=i(t);(n.set(t,o),e.has(t))||(null==(u=r[r.length-1])||u.add(t),e.set(t,[f,new Set]),a(t,o));if(g(f)){var c="v"in o?o.v instanceof Promise?o.v:Promise.resolve(o.v):Promise.reject(o.e);f.v!==c&&l(f.v,c)}},b=function(n,t,r,e){var i=new Map(e?t.d:null),o=!1;r.forEach((function(r,e){!r&&u(n,e)&&(r=t),r&&(i.set(e,r),t.d.get(e)!==r&&(o=!0))})),(o||t.d.size!==i.size)&&(t.d=i)},m=function(n,t,r,e){var o,a,u=i(n),f={d:(null==u?void 0:u.d)||new Map,v:t};if(r&&b(n,f,r,e),h(u,f)&&u.d===f.d)return u;if(g(u)&&g(f)&&(a=f,"v"in(o=u)&&"v"in a&&o.v.orig&&o.v.orig===a.v.orig)){if(u.d===f.d)return u;f.v=u.v}return y(n,f),f},S=function(n,r,e,o){if("function"==typeof(null==(c=r)?void 0:c.then)){var a,u=function(){var r=i(n);if(g(r)&&r.v===f){var o=m(n,f,e);t.has(n)&&r.d!==o.d&&P(n,o,r.d)}},f=new Promise((function(n,t){var e=!1;r.then((function(t){e||(e=!0,d(f,t),n(t),u())}),(function(n){e||(e=!0,s(f,n),t(n),u())})),a=function(t){e||(e=!0,t.then((function(n){return d(f,n)}),(function(n){return s(f,n)})),n(t))}}));return f.orig=r,f.status="pending",function(n,t){v.set(n,t),n.catch((function(){})).finally((function(){return v.delete(n)}))}(f,(function(n){n&&a(n),null==o||o()})),m(n,f,e,!0)}var c;return m(n,r,e)},E=function n(r,e){var o=i(r);if(!e&&o){if(t.has(r))return o;if(Array.from(o.d).every((function(t){var e=t[0],i=t[1];if(e===r)return!0;var o=n(e);return o===i||h(o,i)})))return o}var a,v,l=new Map,d=!0,s={get signal(){return a||(a=new AbortController),a.signal},get setSelf(){return!v&&c(r)&&(v=function(){if(!d){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}}),v}};try{var g=r.read((function(t){if(u(r,t)){var e=i(t);if(e)return l.set(t,e),w(e);if(f(t))return l.set(t,void 0),t.init;throw new Error("no atom init")}var o=n(t);return l.set(t,o),w(o)}),s);return S(r,g,l,(function(){var n;return null==(n=a)?void 0:n.abort()}))}catch(n){return function(n,t,r){var e=i(n),o={d:(null==e?void 0:e.d)||new Map,e:t};return r&&b(n,o,r),p(e,o)&&e.d===o.d?e:(y(n,o),o)}(r,n,l)}finally{d=!1}},A=function(n){var r=new Array,a=new Set;!function n(i){if(!a.has(i)){a.add(i);for(var u,f=o(function(n){var r,i,o=new Set(null==(r=t.get(n))?void 0:r.t);return null==(i=e.get(n))||i[1].forEach((function(n){o.add(n)})),o}(i));!(u=f()).done;){var c=u.value;i!==c&&n(c)}r.push(i)}}(n);for(var u=new Set([n]),f=r.length-1;f>=0;--f){var c=r[f],v=i(c);if(v){for(var l,d=!1,s=o(v.d.keys());!(l=s()).done;){var p=l.value;if(p!==c&&u.has(p)){d=!0;break}}if(d){var g=E(c,!0);h(v,g)||u.add(c)}}}},M=function n(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var c=t.write.apply(t,[function(n){return w(E(n))},function(e){var o,a=r.length>0;a||r.push(new Set([e]));for(var c=arguments.length,v=new Array(c>1?c-1:0),l=1;l<c;l++)v[l-1]=arguments[l];if(u(t,e)){if(!f(e))throw new Error("atom not writable");var d=i(e),s=S(e,v[0]);h(d,s)||A(e)}else o=n.apply(void 0,[e].concat(v));return a||x(r.pop()),o}].concat(o));return c},j=function(n){r.push(new Set([n]));for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var o=M.apply(void 0,[n].concat(e));return x(r.pop()),o},k=function n(r,e,o){var a,u=t.get(r);if(u)return e&&u.t.add(e),u;var f=o||[];null==(a=i(r))||a.d.forEach((function(t,e){e!==r&&n(e,r,f)})),E(r);var v={t:new Set(e&&[e]),l:new Set};if(t.set(r,v),c(r)&&r.onMount){var l=r.onMount;f.push((function(){var n=l((function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}));n&&(v.u=n)}))}return o||f.forEach((function(n){return n()})),v},z=function n(r,e){if(function(n,t){return!t.l.size&&(!t.t.size||1===t.t.size&&t.t.has(n))}(r,e)){var o=e.u;o&&o(),t.delete(r);var a=i(r);a&&(g(a)&&l(a.v),a.d.forEach((function(e,i){if(i!==r){var o=t.get(i);o&&(o.t.delete(r),n(i,o))}})))}},P=function(n,r,e){var i=new Set(r.d.keys()),o=new Set;null==e||e.forEach((function(r,e){if(i.has(e))i.delete(e);else{o.add(e);var a=t.get(e);a&&a.t.delete(n)}})),i.forEach((function(t){k(t,n)})),o.forEach((function(n){var r=t.get(n);r&&z(n,r)}))},x=function(n){var r=[];n.forEach((function n(t){var o;if(e.has(t)){var a=e.get(t),u=a[0],f=a[1];e.delete(t),r.push([t,u]),f.forEach(n),null==(o=i(t))||o.d.forEach((function(t,r){return n(r)}))}})),r.forEach((function(n){var r=n[0],e=n[1],o=i(r);if(o&&o!==e){var a=t.get(r);a&&o.d!==(null==e?void 0:e.d)&&P(r,o,null==e?void 0:e.d),a&&(g(e)||!h(e,o)&&!p(e,o))&&a.l.forEach((function(n){return n()}))}}))};return{get:function(n){return w(E(n))},set:j,sub:function(n,t){var r=k(n);x([n]);var e=r.l;return e.add(t),function(){e.delete(t),z(n,r)}}}};n.atom=function(n,i){var o="atom"+ ++t,a={toString:function(){return o}};return"function"==typeof n?a.read=n:(a.init=n,a.read=r,a.write=e),i&&(a.write=i),a},n.createStore=y,n.getDefaultStore=function(){return a||(a=y()),a}}));
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).jotaiVanilla={})}(this,(function(n){"use strict";var t=0;function r(n){return n(this)}function e(n,t,r){return t(this,"function"==typeof r?r(n(this)):r)}function i(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function o(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(r)return(r=r.call(n)).next.bind(r);if(Array.isArray(n)||(r=function(n,t){if(n){if("string"==typeof n)return i(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(n,t):void 0}}(n))||t&&n&&"number"==typeof n.length){r&&(n=r);var e=0;return function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=function(n,t){return n.unstable_is?n.unstable_is(t):t===n},f=function(n){return"init"in n},c=function(n){return!!n.write},v=new WeakMap,l=function(n,t){var r=v.get(n);r&&(v.delete(n),r(t))},d=function(n,t){n.status="fulfilled",n.value=t},s=function(n,t){n.status="rejected",n.reason=t},h=function(n,t){return!!n&&"v"in n&&"v"in t&&Object.is(n.v,t.v)},p=function(n,t){return!!n&&"e"in n&&"e"in t&&Object.is(n.e,t.e)},g=function(n){return!!n&&"v"in n&&n.v instanceof Promise},w=function(n){if("e"in n)throw n.e;return n.v},y=function(){var n=new WeakMap,t=new WeakMap,r=[],e=new WeakMap,i=function(t){return n.get(t)},a=function n(t,o){o.d.forEach((function(o,a){if(!e.has(a)){var u,f=i(a);null==(u=r[r.length-1])||u.add(a),e.set(a,[f,new Set]),f&&n(a,f)}e.get(a)[1].add(t)}))},y=function(t,o){var u,f=i(t);(n.set(t,o),e.has(t))||(null==(u=r[r.length-1])||u.add(t),e.set(t,[f,new Set]),a(t,o));if(g(f)){var c="v"in o?o.v instanceof Promise?o.v:Promise.resolve(o.v):Promise.reject(o.e);f.v!==c&&l(f.v,c)}},b=function(n,t,r,e){var i=new Map(e?t.d:null),o=!1;r.forEach((function(r,e){!r&&u(n,e)&&(r=t),r&&(i.set(e,r),t.d.get(e)!==r&&(o=!0))})),(o||t.d.size!==i.size)&&(t.d=i)},m=function(n,t,r,e){var o,a,u=i(n),f={d:(null==u?void 0:u.d)||new Map,v:t};if(r&&b(n,f,r,e),h(u,f)&&u.d===f.d)return u;if(g(u)&&g(f)&&(a=f,"v"in(o=u)&&"v"in a&&o.v.orig&&o.v.orig===a.v.orig)){if(u.d===f.d)return u;f.v=u.v}return y(n,f),f},S=function(n,r,e,o){if("function"==typeof(null==(c=r)?void 0:c.then)){var a,u=function(){var r=i(n);if(g(r)&&r.v===f){var o=m(n,f,e);t.has(n)&&r.d!==o.d&&P(n,o,r.d)}},f=new Promise((function(n,t){var e=!1;r.then((function(t){e||(e=!0,d(f,t),n(t),u())}),(function(n){e||(e=!0,s(f,n),t(n),u())})),a=function(t){e||(e=!0,t.then((function(n){return d(f,n)}),(function(n){return s(f,n)})),n(t))}}));return f.orig=r,f.status="pending",function(n,t){v.set(n,t),n.catch((function(){})).finally((function(){return v.delete(n)}))}(f,(function(n){n&&a(n),null==o||o()})),m(n,f,e,!0)}var c;return m(n,r,e)},E=function n(r,e){var o=i(r);if(!e&&o){if(t.has(r))return o;if(Array.from(o.d).every((function(t){var e=t[0],i=t[1];if(e===r)return!0;var o=n(e);return o===i||h(o,i)})))return o}var a,v,l=new Map,d=!0,s={get signal(){return a||(a=new AbortController),a.signal},get setSelf(){return!v&&c(r)&&(v=function(){if(!d){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}}),v}};try{var g=r.read((function(t){if(u(r,t)){var e=i(t);if(e)return l.set(t,e),w(e);if(f(t))return l.set(t,void 0),t.init;throw new Error("no atom init")}var o=n(t);return l.set(t,o),w(o)}),s);return S(r,g,l,(function(){var n;return null==(n=a)?void 0:n.abort()}))}catch(n){return function(n,t,r){var e=i(n),o={d:(null==e?void 0:e.d)||new Map,e:t};return r&&b(n,o,r),p(e,o)&&e.d===o.d?e:(y(n,o),o)}(r,n,l)}finally{d=!1}},A=function(n){var r=new Array,a=new Set;!function n(i){if(!a.has(i)){a.add(i);for(var u,f=o(function(n){var r,i,o=new Set(null==(r=t.get(n))?void 0:r.t);return null==(i=e.get(n))||i[1].forEach((function(n){o.add(n)})),o}(i));!(u=f()).done;){var c=u.value;i!==c&&n(c)}r.push(i)}}(n);for(var u=new Set([n]),f=r.length-1;f>=0;--f){var c=r[f],v=i(c);if(v){for(var l,d=!1,s=o(v.d.keys());!(l=s()).done;){var p=l.value;if(p!==c&&u.has(p)){d=!0;break}}if(d){var g=E(c,!0);h(v,g)||u.add(c)}}}},M=function n(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var c=t.write.apply(t,[function(n){return w(E(n))},function(e){var o,a=r.length>0;a||r.push(new Set([e]));for(var c=arguments.length,v=new Array(c>1?c-1:0),l=1;l<c;l++)v[l-1]=arguments[l];if(u(t,e)){if(!f(e))throw new Error("atom not writable");var d=i(e),s=S(e,v[0]);h(d,s)||A(e)}else o=n.apply(void 0,[e].concat(v));return a||x(r.pop()),o}].concat(o));return c},j=function(n){r.push(new Set([n]));for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var o=M.apply(void 0,[n].concat(e));return x(r.pop()),o},k=function n(r,e,o){var a,u=t.get(r);if(u)return e&&u.t.add(e),u;var f=o||[];null==(a=i(r))||a.d.forEach((function(t,e){e!==r&&n(e,r,f)})),E(r);var v={t:new Set(e&&[e]),l:new Set};if(t.set(r,v),c(r)&&r.onMount){var l=r.onMount;f.push((function(){var n=l((function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}));n&&(v.u=n)}))}return o||f.forEach((function(n){return n()})),v},z=function n(r,e){if(function(n,t){return!t.l.size&&(!t.t.size||1===t.t.size&&t.t.has(n))}(r,e)){var o=e.u;o&&o(),t.delete(r);var a=i(r);a&&(g(a)&&l(a.v),a.d.forEach((function(e,i){if(i!==r){var o=t.get(i);o&&(o.t.delete(r),n(i,o))}})))}},P=function(n,r,e){var i=new Set(r.d.keys()),o=new Set;null==e||e.forEach((function(r,e){if(i.has(e))i.delete(e);else{o.add(e);var a=t.get(e);a&&a.t.delete(n)}})),i.forEach((function(t){k(t,n)})),o.forEach((function(n){var r=t.get(n);r&&z(n,r)}))},x=function(n){var r=[];n.forEach((function n(t){var o;if(e.has(t)){var a=e.get(t),u=a[0],f=a[1];e.delete(t),r.push([t,u]),f.forEach(n),null==(o=i(t))||o.d.forEach((function(t,r){return n(r)}))}})),r.forEach((function(n){var r=n[0],e=n[1],o=i(r);if(o&&o!==e){var a=t.get(r);a&&o.d!==(null==e?void 0:e.d)&&P(r,o,null==e?void 0:e.d),a&&(g(e)||!h(e,o)&&!p(e,o))&&a.l.forEach((function(n){return n()}))}}))};return{get:function(n){return w(E(n))},set:j,sub:function(n,t){var r=k(n);x([n]);var e=r.l;return e.add(t),function(){e.delete(t),z(n,r)}}}},b=y,m=function(){return a||(a=y()),a};n.atom=function(n,i){var o="atom"+ ++t,a={toString:function(){return o}};return"function"==typeof n?a.read=n:(a.init=n,a.read=r,a.write=e),i&&(a.write=i),a},n.createStore=b,n.getDefaultStore=m}));

@@ -130,7 +130,7 @@ (function (global, factory) {

};
var cache1$4 = new WeakMap();
var cache1$3 = new WeakMap();
var memo3 = function memo3(create, dep1, dep2, dep3) {
var cache2 = getCached$2(function () {
return new WeakMap();
}, cache1$4, dep1);
}, cache1$3, dep1);
var cache3 = getCached$2(function () {

@@ -159,5 +159,2 @@ return new WeakMap();

var value = get(anAtom);
if (value instanceof Promise || prev instanceof Promise) {
return Promise.all([value, prev]).then(selectValue);
}
return selectValue([value, prev]);

@@ -170,6 +167,3 @@ });

var cache1$3 = new WeakMap();
var memo1$1 = function memo1(create, dep1) {
return (cache1$3.has(dep1) ? cache1$3 : cache1$3.set(dep1, create())).get(dep1);
};
var frozenAtoms = new WeakSet();
var deepFreeze = function deepFreeze(obj) {

@@ -187,19 +181,35 @@ if (typeof obj !== 'object' || obj === null) return;

function freezeAtom(anAtom) {
return memo1$1(function () {
var frozenAtom = vanilla.atom(function (get) {
return deepFreeze(get(anAtom));
}, function (_get, set, arg) {
return set(anAtom, arg);
});
return frozenAtom;
}, anAtom);
if (frozenAtoms.has(anAtom)) {
return anAtom;
}
frozenAtoms.add(anAtom);
var origRead = anAtom.read;
anAtom.read = function (get, options) {
return deepFreeze(origRead.call(this, get, options));
};
if ('write' in anAtom) {
var origWrite = anAtom.write;
anAtom.write = function (get, set) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
return origWrite.call.apply(origWrite, [this, get, function () {
for (var _len2 = arguments.length, setArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
setArgs[_key2] = arguments[_key2];
}
if (setArgs[0] === anAtom) {
setArgs[1] = deepFreeze(setArgs[1]);
}
return set.apply(void 0, setArgs);
}].concat(args));
};
}
return anAtom;
}
function freezeAtomCreator(createAtom) {
{
console.warn('[DEPRECATED] freezeAtomCreator is deprecated, define it on users end');
}
return function () {
var anAtom = createAtom.apply(void 0, arguments);
var origRead = anAtom.read;
anAtom.read = function (get, options) {
return deepFreeze(origRead.call(this, get, options));
};
return anAtom;
return freezeAtom(createAtom.apply(void 0, arguments));
};

@@ -815,5 +825,17 @@ }

function atomWithLazy(makeInitial) {
var a = vanilla.atom(undefined);
delete a.init;
Object.defineProperty(a, 'init', {
get: function get() {
return makeInitial();
}
});
return a;
}
exports.RESET = RESET;
exports.atomFamily = atomFamily;
exports.atomWithDefault = atomWithDefault;
exports.atomWithLazy = atomWithLazy;
exports.atomWithObservable = atomWithObservable;

@@ -820,0 +842,0 @@ exports.atomWithReducer = atomWithReducer;

@@ -1,1 +0,1 @@

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiVanillaUtils={},t.jotaiVanilla)}(this,(function(t,n){"use strict";var e=Symbol("");function r(){return r=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},r.apply(this,arguments)}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function i(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return o(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},u=new WeakMap;var f=new WeakMap,c=function t(n){if("object"==typeof n&&null!==n){Object.freeze(n);for(var e,r=i(Object.getOwnPropertyNames(n));!(e=r()).done;){t(n[e.value])}return n}};var s=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},l=new WeakMap,v={},m=function(t){return!!t.write};var d=function(t){return"function"==typeof(null==t?void 0:t.then)};function h(t,n){var e,r;void 0===t&&(t=function(){try{return window.localStorage}catch(t){return}});var o={getItem:function(o,i){var a,u,f=function(t){if(e!==(t=t||"")){try{r=JSON.parse(t,null==n?void 0:n.reviver)}catch(t){return i}e=t}return r},c=null!=(a=null==(u=t())?void 0:u.getItem(o))?a:null;return d(c)?c.then(f):f(c)},setItem:function(e,r){var o;return null==(o=t())?void 0:o.setItem(e,JSON.stringify(r,null==n?void 0:n.replacer))},removeItem:function(n){var e;return null==(e=t())?void 0:e.removeItem(n)}};return"undefined"!=typeof window&&"function"==typeof window.addEventListener&&window.Storage&&(o.subscribe=function(n,e,r){if(!(t()instanceof window.Storage))return function(){};var o=function(o){if(o.storageArea===t()&&o.key===n){var i;try{i=JSON.parse(o.newValue||"")}catch(t){i=r}e(i)}};return window.addEventListener("storage",o),function(){window.removeEventListener("storage",o)}}),o}var p=h();var b=new WeakMap,y={state:"loading"};var g=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},w=new WeakMap,k=function(){};t.RESET=e,t.atomFamily=function(t,n){var e=null,r=new Map,o=function o(a){var u;if(void 0===n)u=r.get(a);else for(var f,c=i(r);!(f=c()).done;){var s=f.value,l=s[0],v=s[1];if(n(l,a)){u=v;break}}if(void 0!==u){if(null==e||!e(u[1],a))return u[0];o.remove(a)}var m=t(a);return r.set(a,[m,Date.now()]),m};return o.remove=function(t){if(void 0===n)r.delete(t);else for(var e,o=i(r);!(e=o()).done;){var a=e.value[0];if(n(a,t)){r.delete(a);break}}},o.setShouldRemove=function(t){if(e=t)for(var n,o=i(r);!(n=o()).done;){var a=n.value,u=a[0],f=a[1];e(f[1],u)&&r.delete(u)}},o},t.atomWithDefault=function(t){var r=Symbol(),o=n.atom(r),i=n.atom((function(n,e){var i=n(o);return i!==r?i:t(n,e)}),(function(t,n,a){if(a===e)n(o,r);else if("function"==typeof a){var u=t(i);n(o,a(u))}else n(o,a)}));return i},t.atomWithObservable=function(t,e){var r=function(t){if("e"in t)throw t.e;return t.d},o=n.atom((function(r){var o,i,a,u=t(r),f=null==(o=(i=u)[Symbol.observable])?void 0:o.call(i);f&&(u=f);var c,s,l,v,m=function(){return new Promise((function(t){a=t}))},d=e&&"initialValue"in e?{d:"function"==typeof e.initialValue?e.initialValue():e.initialValue}:m(),h=function(t){s=t,null==a||a(t),null==c||c(t)},p=function(){return!c},b=function(){l&&(clearTimeout(v),l.unsubscribe()),l=u.subscribe({next:function(t){return h({d:t})},error:function(t){return h({e:t})},complete:function(){}}),p()&&null!=e&&e.unstable_timeout&&(v=setTimeout((function(){l&&(l.unsubscribe(),l=void 0)}),e.unstable_timeout))};b();var y=n.atom(s||d);return y.onMount=function(t){return c=t,s&&t(s),l?clearTimeout(v):b(),function(){c=void 0,l&&(l.unsubscribe(),l=void 0)}},[y,u,m,b,p]}));return n.atom((function(t){var n=t(o),e=t(n[0]);return e instanceof Promise?e.then(r):r(e)}),(function(t,n,e){var r=t(o),i=r[0],a=r[1],u=r[2],f=r[3],c=r[4];if(!("next"in a))throw new Error("observable is not subject");c()&&(n(i,u()),f()),a.next(e)}))},t.atomWithReducer=function(t,e){return n.atom(t,(function(t,n,r){n(this,e(t(this),r))}))},t.atomWithRefresh=function(t,e){var r=n.atom(0);return n.atom((function(n,e){return n(r),t(n,e)}),(function(t,n){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];if(0===i.length)n(r,(function(t){return t+1}));else if(e)return e.apply(void 0,[t,n].concat(i))}))},t.atomWithReset=function(t){var r=n.atom(t,(function(n,o,i){var a="function"==typeof i?i(n(r)):i;o(r,a===e?t:a)}));return r},t.atomWithStorage=function(t,r,o,i){void 0===o&&(o=p);var a=null==i?void 0:i.getOnInit,u=n.atom(a?o.getItem(t,r):r);return u.onMount=function(n){var e;return n(o.getItem(t,r)),o.subscribe&&(e=o.subscribe(t,n,r)),e},n.atom((function(t){return t(u)}),(function(n,i,a){var f="function"==typeof a?a(n(u)):a;return f===e?(i(u,r),o.removeItem(t)):f instanceof Promise?f.then((function(n){return i(u,n),o.setItem(t,n)})):(i(u,f),o.setItem(t,f))}))},t.createJSONStorage=h,t.freezeAtom=function(t){return e=function(){return n.atom((function(n){return c(n(t))}),(function(n,e,r){return e(t,r)}))},r=t,(f.has(r)?f:f.set(r,e())).get(r);var e,r},t.freezeAtomCreator=function(t){return function(){var n=t.apply(void 0,arguments),e=n.read;return n.read=function(t,n){return c(e.call(this,t,n))},n}},t.loadable=function(t){return e=function(){var e=new WeakMap,r=n.atom(0),o=n.atom((function(n,o){var i,a=o.setSelf;n(r);try{i=n(t)}catch(t){return{state:"hasError",error:t}}if(!(i instanceof Promise))return{state:"hasData",data:i};var u=i,f=e.get(u);if(f)return f;"fulfilled"===u.status?e.set(u,{state:"hasData",data:u.value}):"rejected"===u.status?e.set(u,{state:"hasError",error:u.reason}):u.then((function(t){e.set(u,{state:"hasData",data:t})}),(function(t){e.set(u,{state:"hasError",error:t})})).finally(a);var c=e.get(u);return c||(e.set(u,y),y)}),(function(t,n){n(r,(function(t){return t+1}))}));return n.atom((function(t){return t(o)}))},r=t,(b.has(r)?b:b.set(r,e())).get(r);var e,r},t.selectAtom=function(t,e,r){return void 0===r&&(r=Object.is),o=function(){var o=Symbol(),i=function(t){var n=t[0],i=t[1];if(i===o)return e(n);var a=e(n,i);return r(i,a)?i:a},a=n.atom((function(n){var e=n(a),r=n(t);return r instanceof Promise||e instanceof Promise?Promise.all([r,e]).then(i):i([r,e])}));return a.init=o,a},i=e,f=r,c=a((function(){return new WeakMap}),u,t),s=a((function(){return new WeakMap}),c,i),a(o,s,f);var o,i,f,c,s},t.splitAtom=function(t,e){return r=function(){var r=new WeakMap,o=function o(a,u){var f=r.get(a);if(f)return f;var c=u&&r.get(u),s=[],l=[];return a.forEach((function(r,u){var f=e?e(r):u;l[u]=f;var v=c&&c.atomList[c.keyList.indexOf(f)];if(v)s[u]=v;else{var d=function(n){var e=n(i),r=n(t),u=o(r,null==e?void 0:e.arr).keyList.indexOf(f);if(u<0||u>=r.length){var c=a[o(a).keyList.indexOf(f)];if(c)return c;throw new Error("splitAtom: index out of bounds for read")}return r[u]};s[u]=m(t)?n.atom(d,(function(n,e,r){var a=n(i),u=n(t),c=o(u,null==a?void 0:a.arr).keyList.indexOf(f);if(c<0||c>=u.length)throw new Error("splitAtom: index out of bounds for write");var s="function"==typeof r?r(u[c]):r;Object.is(u[c],s)||e(t,[].concat(u.slice(0,c),[s],u.slice(c+1)))})):n.atom(d)}})),f=c&&c.keyList.length===l.length&&c.keyList.every((function(t,n){return t===l[n]}))?c:{arr:a,atomList:s,keyList:l},r.set(a,f),f},i=n.atom((function(n){var e=n(i),r=n(t);return o(r,null==e?void 0:e.arr)}));i.init=void 0;var a=m(t)?n.atom((function(t){return t(i).atomList}),(function(n,e,r){switch(r.type){case"remove":var o=n(a).indexOf(r.atom);if(o>=0){var i=n(t);e(t,[].concat(i.slice(0,o),i.slice(o+1)))}break;case"insert":var u=r.before?n(a).indexOf(r.before):n(a).length;if(u>=0){var f=n(t);e(t,[].concat(f.slice(0,u),[r.value],f.slice(u)))}break;case"move":var c=n(a).indexOf(r.atom),s=r.before?n(a).indexOf(r.before):n(a).length;if(c>=0&&s>=0){var l=n(t);e(t,c<s?[].concat(l.slice(0,c),l.slice(c+1,s),[l[c]],l.slice(s)):[].concat(l.slice(0,s),[l[c]],l.slice(s,c),l.slice(c+1)))}}})):n.atom((function(t){return t(i).atomList}));return a},o=e||v,i=s((function(){return new WeakMap}),l,t),s(r,i,o);var r,o,i},t.unstable_withStorageValidator=function(t){return function(n){return r({},n,{getItem:function(e,r){var o=function(n){return t(n)?n:r},i=n.getItem(e,r);return d(i)?i.then(o):o(i)}})}},t.unwrap=function(t,e){return void 0===e&&(e=k),r=function(){var r=new WeakMap,o=new WeakMap,i=n.atom(0),a=n.atom((function(n,u){var f=u.setSelf;n(i);var c=n(a),s=n(t);if(!(s instanceof Promise))return{v:s};if(s!==(null==c?void 0:c.p)&&("fulfilled"===s.status?o.set(s,s.value):"rejected"===s.status?r.set(s,s.reason):s.then((function(t){return o.set(s,t)}),(function(t){return r.set(s,t)})).finally(f)),r.has(s))throw r.get(s);return o.has(s)?{p:s,v:o.get(s)}:c&&"v"in c?{p:s,f:e(c.v),v:c.v}:{p:s,f:e()}}),(function(t,n){n(i,(function(t){return t+1}))}));return a.init=void 0,n.atom((function(t){var n=t(a);return"f"in n?n.f:n.v}),(function(n,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(void 0,[t].concat(o))}))},o=e,i=g((function(){return new WeakMap}),w,t),g(r,i,o);var r,o,i}}));
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiVanillaUtils={},t.jotaiVanilla)}(this,(function(t,n){"use strict";var e=Symbol("");function r(){return r=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},r.apply(this,arguments)}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function i(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return o(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,n):void 0}}(t))||n&&t&&"number"==typeof t.length){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},u=new WeakMap;var f=new WeakSet,c=function t(n){if("object"==typeof n&&null!==n){Object.freeze(n);for(var e,r=i(Object.getOwnPropertyNames(n));!(e=r()).done;){t(n[e.value])}return n}};function l(t){if(f.has(t))return t;f.add(t);var n=t.read;if(t.read=function(t,e){return c(n.call(this,t,e))},"write"in t){var e=t.write;t.write=function(n,r){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];return e.call.apply(e,[this,n,function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];return e[0]===t&&(e[1]=c(e[1])),r.apply(void 0,e)}].concat(i))}}return t}var s=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},v=new WeakMap,d={},m=function(t){return!!t.write};var h=function(t){return"function"==typeof(null==t?void 0:t.then)};function p(t,n){var e,r;void 0===t&&(t=function(){try{return window.localStorage}catch(t){return}});var o={getItem:function(o,i){var a,u,f=function(t){if(e!==(t=t||"")){try{r=JSON.parse(t,null==n?void 0:n.reviver)}catch(t){return i}e=t}return r},c=null!=(a=null==(u=t())?void 0:u.getItem(o))?a:null;return h(c)?c.then(f):f(c)},setItem:function(e,r){var o;return null==(o=t())?void 0:o.setItem(e,JSON.stringify(r,null==n?void 0:n.replacer))},removeItem:function(n){var e;return null==(e=t())?void 0:e.removeItem(n)}};return"undefined"!=typeof window&&"function"==typeof window.addEventListener&&window.Storage&&(o.subscribe=function(n,e,r){if(!(t()instanceof window.Storage))return function(){};var o=function(o){if(o.storageArea===t()&&o.key===n){var i;try{i=JSON.parse(o.newValue||"")}catch(t){i=r}e(i)}};return window.addEventListener("storage",o),function(){window.removeEventListener("storage",o)}}),o}var y=p();var b=new WeakMap,w={state:"loading"};var g=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},O=new WeakMap,k=function(){};t.RESET=e,t.atomFamily=function(t,n){var e=null,r=new Map,o=function o(a){var u;if(void 0===n)u=r.get(a);else for(var f,c=i(r);!(f=c()).done;){var l=f.value,s=l[0],v=l[1];if(n(s,a)){u=v;break}}if(void 0!==u){if(null==e||!e(u[1],a))return u[0];o.remove(a)}var d=t(a);return r.set(a,[d,Date.now()]),d};return o.remove=function(t){if(void 0===n)r.delete(t);else for(var e,o=i(r);!(e=o()).done;){var a=e.value[0];if(n(a,t)){r.delete(a);break}}},o.setShouldRemove=function(t){if(e=t)for(var n,o=i(r);!(n=o()).done;){var a=n.value,u=a[0],f=a[1];e(f[1],u)&&r.delete(u)}},o},t.atomWithDefault=function(t){var r=Symbol(),o=n.atom(r),i=n.atom((function(n,e){var i=n(o);return i!==r?i:t(n,e)}),(function(t,n,a){if(a===e)n(o,r);else if("function"==typeof a){var u=t(i);n(o,a(u))}else n(o,a)}));return i},t.atomWithLazy=function(t){var e=n.atom(void 0);return delete e.init,Object.defineProperty(e,"init",{get:function(){return t()}}),e},t.atomWithObservable=function(t,e){var r=function(t){if("e"in t)throw t.e;return t.d},o=n.atom((function(r){var o,i,a,u=t(r),f=null==(o=(i=u)[Symbol.observable])?void 0:o.call(i);f&&(u=f);var c,l,s,v,d=function(){return new Promise((function(t){a=t}))},m=e&&"initialValue"in e?{d:"function"==typeof e.initialValue?e.initialValue():e.initialValue}:d(),h=function(t){l=t,null==a||a(t),null==c||c(t)},p=function(){return!c},y=function(){s&&(clearTimeout(v),s.unsubscribe()),s=u.subscribe({next:function(t){return h({d:t})},error:function(t){return h({e:t})},complete:function(){}}),p()&&null!=e&&e.unstable_timeout&&(v=setTimeout((function(){s&&(s.unsubscribe(),s=void 0)}),e.unstable_timeout))};y();var b=n.atom(l||m);return b.onMount=function(t){return c=t,l&&t(l),s?clearTimeout(v):y(),function(){c=void 0,s&&(s.unsubscribe(),s=void 0)}},[b,u,d,y,p]}));return n.atom((function(t){var n=t(o),e=t(n[0]);return e instanceof Promise?e.then(r):r(e)}),(function(t,n,e){var r=t(o),i=r[0],a=r[1],u=r[2],f=r[3],c=r[4];if(!("next"in a))throw new Error("observable is not subject");c()&&(n(i,u()),f()),a.next(e)}))},t.atomWithReducer=function(t,e){return n.atom(t,(function(t,n,r){n(this,e(t(this),r))}))},t.atomWithRefresh=function(t,e){var r=n.atom(0);return n.atom((function(n,e){return n(r),t(n,e)}),(function(t,n){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];if(0===i.length)n(r,(function(t){return t+1}));else if(e)return e.apply(void 0,[t,n].concat(i))}))},t.atomWithReset=function(t){var r=n.atom(t,(function(n,o,i){var a="function"==typeof i?i(n(r)):i;o(r,a===e?t:a)}));return r},t.atomWithStorage=function(t,r,o,i){void 0===o&&(o=y);var a=null==i?void 0:i.getOnInit,u=n.atom(a?o.getItem(t,r):r);return u.onMount=function(n){var e;return n(o.getItem(t,r)),o.subscribe&&(e=o.subscribe(t,n,r)),e},n.atom((function(t){return t(u)}),(function(n,i,a){var f="function"==typeof a?a(n(u)):a;return f===e?(i(u,r),o.removeItem(t)):f instanceof Promise?f.then((function(n){return i(u,n),o.setItem(t,n)})):(i(u,f),o.setItem(t,f))}))},t.createJSONStorage=p,t.freezeAtom=l,t.freezeAtomCreator=function(t){return function(){return l(t.apply(void 0,arguments))}},t.loadable=function(t){return e=function(){var e=new WeakMap,r=n.atom(0),o=n.atom((function(n,o){var i,a=o.setSelf;n(r);try{i=n(t)}catch(t){return{state:"hasError",error:t}}if(!(i instanceof Promise))return{state:"hasData",data:i};var u=i,f=e.get(u);if(f)return f;"fulfilled"===u.status?e.set(u,{state:"hasData",data:u.value}):"rejected"===u.status?e.set(u,{state:"hasError",error:u.reason}):u.then((function(t){e.set(u,{state:"hasData",data:t})}),(function(t){e.set(u,{state:"hasError",error:t})})).finally(a);var c=e.get(u);return c||(e.set(u,w),w)}),(function(t,n){n(r,(function(t){return t+1}))}));return n.atom((function(t){return t(o)}))},r=t,(b.has(r)?b:b.set(r,e())).get(r);var e,r},t.selectAtom=function(t,e,r){return void 0===r&&(r=Object.is),o=function(){var o=Symbol(),i=n.atom((function(n){var a=n(i);return function(t){var n=t[0],i=t[1];if(i===o)return e(n);var a=e(n,i);return r(i,a)?i:a}([n(t),a])}));return i.init=o,i},i=e,f=r,c=a((function(){return new WeakMap}),u,t),l=a((function(){return new WeakMap}),c,i),a(o,l,f);var o,i,f,c,l},t.splitAtom=function(t,e){return r=function(){var r=new WeakMap,o=function o(a,u){var f=r.get(a);if(f)return f;var c=u&&r.get(u),l=[],s=[];return a.forEach((function(r,u){var f=e?e(r):u;s[u]=f;var v=c&&c.atomList[c.keyList.indexOf(f)];if(v)l[u]=v;else{var d=function(n){var e=n(i),r=n(t),u=o(r,null==e?void 0:e.arr).keyList.indexOf(f);if(u<0||u>=r.length){var c=a[o(a).keyList.indexOf(f)];if(c)return c;throw new Error("splitAtom: index out of bounds for read")}return r[u]};l[u]=m(t)?n.atom(d,(function(n,e,r){var a=n(i),u=n(t),c=o(u,null==a?void 0:a.arr).keyList.indexOf(f);if(c<0||c>=u.length)throw new Error("splitAtom: index out of bounds for write");var l="function"==typeof r?r(u[c]):r;Object.is(u[c],l)||e(t,[].concat(u.slice(0,c),[l],u.slice(c+1)))})):n.atom(d)}})),f=c&&c.keyList.length===s.length&&c.keyList.every((function(t,n){return t===s[n]}))?c:{arr:a,atomList:l,keyList:s},r.set(a,f),f},i=n.atom((function(n){var e=n(i),r=n(t);return o(r,null==e?void 0:e.arr)}));i.init=void 0;var a=m(t)?n.atom((function(t){return t(i).atomList}),(function(n,e,r){switch(r.type){case"remove":var o=n(a).indexOf(r.atom);if(o>=0){var i=n(t);e(t,[].concat(i.slice(0,o),i.slice(o+1)))}break;case"insert":var u=r.before?n(a).indexOf(r.before):n(a).length;if(u>=0){var f=n(t);e(t,[].concat(f.slice(0,u),[r.value],f.slice(u)))}break;case"move":var c=n(a).indexOf(r.atom),l=r.before?n(a).indexOf(r.before):n(a).length;if(c>=0&&l>=0){var s=n(t);e(t,c<l?[].concat(s.slice(0,c),s.slice(c+1,l),[s[c]],s.slice(l)):[].concat(s.slice(0,l),[s[c]],s.slice(l,c),s.slice(c+1)))}}})):n.atom((function(t){return t(i).atomList}));return a},o=e||d,i=s((function(){return new WeakMap}),v,t),s(r,i,o);var r,o,i},t.unstable_withStorageValidator=function(t){return function(n){return r({},n,{getItem:function(e,r){var o=function(n){return t(n)?n:r},i=n.getItem(e,r);return h(i)?i.then(o):o(i)}})}},t.unwrap=function(t,e){return void 0===e&&(e=k),r=function(){var r=new WeakMap,o=new WeakMap,i=n.atom(0),a=n.atom((function(n,u){var f=u.setSelf;n(i);var c=n(a),l=n(t);if(!(l instanceof Promise))return{v:l};if(l!==(null==c?void 0:c.p)&&("fulfilled"===l.status?o.set(l,l.value):"rejected"===l.status?r.set(l,l.reason):l.then((function(t){return o.set(l,t)}),(function(t){return r.set(l,t)})).finally(f)),r.has(l))throw r.get(l);return o.has(l)?{p:l,v:o.get(l)}:c&&"v"in c?{p:l,f:e(c.v),v:c.v}:{p:l,f:e()}}),(function(t,n){n(i,(function(t){return t+1}))}));return a.init=void 0,n.atom((function(t){var n=t(a);return"f"in n?n.f:n.v}),(function(n,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(void 0,[t].concat(o))}))},o=e,i=g((function(){return new WeakMap}),O,t),g(r,i,o);var r,o,i}}));
export { atom } from './vanilla/atom';
export type { Atom, WritableAtom, PrimitiveAtom } from './vanilla/atom';
export { createStore, getDefaultStore } from './vanilla/store';
import * as store from './vanilla/store';
type CreateStore = typeof store.createStore;
type GetDefaultStore = typeof store.getDefaultStore;
export declare const createStore: CreateStore;
export declare const getDefaultStore: GetDefaultStore;
export type { Getter, Setter, ExtractAtomValue, ExtractAtomArgs, ExtractAtomResult, SetStateAction, } from './vanilla/typeUtils';

@@ -114,3 +114,3 @@ 'use strict';

};
var createStore = function createStore() {
var createStore$1 = function createStore() {
var atomStateMap = new WeakMap();

@@ -120,6 +120,6 @@ var mountedMap = new WeakMap();

var pendingMap = new WeakMap();
var storeListenersRev2;
var devListenersRev2;
var mountedAtoms;
if (process.env.NODE_ENV !== 'production') {
storeListenersRev2 = new Set();
devListenersRev2 = new Set();
mountedAtoms = new Set();

@@ -431,3 +431,3 @@ }

if (process.env.NODE_ENV !== 'production') {
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -456,3 +456,3 @@ type: 'async-write',

if (process.env.NODE_ENV !== 'production') {
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -625,3 +625,3 @@ type: 'write',

if (process.env.NODE_ENV !== 'production') {
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -637,3 +637,3 @@ type: 'sub',

if (process.env.NODE_ENV !== 'production') {
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -651,9 +651,6 @@ type: 'unsub'

sub: subscribeAtom,
dev_subscribe_store: function dev_subscribe_store(l, rev) {
if (rev !== 2) {
throw new Error('The current StoreListener revision is 2.');
}
storeListenersRev2.add(l);
dev_subscribe_store: function dev_subscribe_store(l) {
devListenersRev2.add(l);
return function () {
storeListenersRev2.delete(l);
devListenersRev2.delete(l);
};

@@ -682,3 +679,3 @@ },

var flushed = flushPending(pendingStack.pop());
storeListenersRev2.forEach(function (l) {
devListenersRev2.forEach(function (l) {
return l({

@@ -699,5 +696,5 @@ type: 'restore',

var defaultStore;
var getDefaultStore = function getDefaultStore() {
var getDefaultStore$1 = function getDefaultStore() {
if (!defaultStore) {
defaultStore = createStore();
defaultStore = createStore$1();
if (process.env.NODE_ENV !== 'production') {

@@ -714,4 +711,7 @@ var _ref4;

var createStore = createStore$1;
var getDefaultStore = getDefaultStore$1;
exports.atom = atom;
exports.createStore = createStore;
exports.getDefaultStore = getDefaultStore;

@@ -41,3 +41,3 @@ import type { Atom, WritableAtom } from './atom';

};
type StoreListenerRev2 = (action: {
type DevListenerRev2 = (action: {
type: 'write';

@@ -57,12 +57,17 @@ flushed: Set<AnyAtom>;

}) => void;
type Store = {
type DevStoreRev2 = {
dev_subscribe_store: (l: DevListenerRev2, rev: 2) => () => void;
dev_get_mounted_atoms: () => IterableIterator<AnyAtom>;
dev_get_atom_state: (a: AnyAtom) => AtomState | undefined;
dev_get_mounted: (a: AnyAtom) => Mounted | undefined;
dev_restore_atoms: (values: Iterable<readonly [AnyAtom, AnyValue]>) => void;
};
type PrdStore = {
get: <Value>(atom: Atom<Value>) => Value;
set: <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
sub: (atom: AnyAtom, listener: () => void) => () => void;
dev_subscribe_store?: (l: StoreListenerRev2, rev: 2) => () => void;
dev_get_mounted_atoms?: () => IterableIterator<AnyAtom>;
dev_get_atom_state?: (a: AnyAtom) => AtomState | undefined;
dev_get_mounted?: (a: AnyAtom) => Mounted | undefined;
dev_restore_atoms?: (values: Iterable<readonly [AnyAtom, AnyValue]>) => void;
};
type Store = PrdStore & Partial<DevStoreRev2>;
export type INTERNAL_DevStoreRev2 = DevStoreRev2;
export type INTERNAL_PrdStore = PrdStore;
/**

@@ -69,0 +74,0 @@ * Create a new store. Each store is an independent, isolated universe of atom

@@ -14,1 +14,2 @@ export { RESET } from './utils/constants';

export { atomWithRefresh } from './utils/atomWithRefresh';
export { atomWithLazy } from './utils/atomWithLazy';

@@ -128,7 +128,7 @@ 'use strict';

};
var cache1$4 = new WeakMap();
var cache1$3 = new WeakMap();
var memo3 = function memo3(create, dep1, dep2, dep3) {
var cache2 = getCached$2(function () {
return new WeakMap();
}, cache1$4, dep1);
}, cache1$3, dep1);
var cache3 = getCached$2(function () {

@@ -157,5 +157,2 @@ return new WeakMap();

var value = get(anAtom);
if (value instanceof Promise || prev instanceof Promise) {
return Promise.all([value, prev]).then(selectValue);
}
return selectValue([value, prev]);

@@ -168,6 +165,3 @@ });

var cache1$3 = new WeakMap();
var memo1$1 = function memo1(create, dep1) {
return (cache1$3.has(dep1) ? cache1$3 : cache1$3.set(dep1, create())).get(dep1);
};
var frozenAtoms = new WeakSet();
var deepFreeze = function deepFreeze(obj) {

@@ -185,19 +179,35 @@ if (typeof obj !== 'object' || obj === null) return;

function freezeAtom(anAtom) {
return memo1$1(function () {
var frozenAtom = vanilla.atom(function (get) {
return deepFreeze(get(anAtom));
}, function (_get, set, arg) {
return set(anAtom, arg);
});
return frozenAtom;
}, anAtom);
if (frozenAtoms.has(anAtom)) {
return anAtom;
}
frozenAtoms.add(anAtom);
var origRead = anAtom.read;
anAtom.read = function (get, options) {
return deepFreeze(origRead.call(this, get, options));
};
if ('write' in anAtom) {
var origWrite = anAtom.write;
anAtom.write = function (get, set) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
return origWrite.call.apply(origWrite, [this, get, function () {
for (var _len2 = arguments.length, setArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
setArgs[_key2] = arguments[_key2];
}
if (setArgs[0] === anAtom) {
setArgs[1] = deepFreeze(setArgs[1]);
}
return set.apply(void 0, setArgs);
}].concat(args));
};
}
return anAtom;
}
function freezeAtomCreator(createAtom) {
if (process.env.NODE_ENV !== 'production') {
console.warn('[DEPRECATED] freezeAtomCreator is deprecated, define it on users end');
}
return function () {
var anAtom = createAtom.apply(void 0, arguments);
var origRead = anAtom.read;
anAtom.read = function (get, options) {
return deepFreeze(origRead.call(this, get, options));
};
return anAtom;
return freezeAtom(createAtom.apply(void 0, arguments));
};

@@ -813,5 +823,17 @@ }

function atomWithLazy(makeInitial) {
var a = vanilla.atom(undefined);
delete a.init;
Object.defineProperty(a, 'init', {
get: function get() {
return makeInitial();
}
});
return a;
}
exports.RESET = RESET;
exports.atomFamily = atomFamily;
exports.atomWithDefault = atomWithDefault;
exports.atomWithLazy = atomWithLazy;
exports.atomWithObservable = atomWithObservable;

@@ -818,0 +840,0 @@ exports.atomWithReducer = atomWithReducer;

import type { Atom } from 'jotai/vanilla';
export declare function freezeAtom<AtomType extends Atom<unknown>>(anAtom: AtomType): AtomType;
export declare function freezeAtomCreator<CreateAtom extends (...params: never[]) => Atom<unknown>>(createAtom: CreateAtom): CreateAtom;
/**
* @deprecated Define it on users end
*/
export declare function freezeAtomCreator<CreateAtom extends (...args: unknown[]) => Atom<unknown>>(createAtom: CreateAtom): CreateAtom;
import type { Atom } from 'jotai/vanilla';
export declare function selectAtom<Value, Slice>(anAtom: Atom<Value>, selector: (v: Awaited<Value>, prevSlice?: Slice) => Slice, equalityFn?: (a: Slice, b: Slice) => boolean): Atom<Value extends Promise<unknown> ? Promise<Slice> : Slice>;
export declare function selectAtom<Value, Slice>(anAtom: Atom<Value>, selector: (v: Value, prevSlice?: Slice) => Slice, equalityFn?: (a: Slice, b: Slice) => boolean): Atom<Slice>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc