System.register(["@babel/core","@babel/template"],(function(d){"use strict";var s;return{setters:[null,function(l){s=l.default}],execute:(function(){d("default",b);function l(t,a,e=[]){const o=[...u,...e];if(t.isIdentifier(a)&&o.includes(a.name))return!0;if(t.isMemberExpression(a)){const{property:i}=a;if(t.isIdentifier(i)&&o.includes(i.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"],h=s.default||s;function p({types:t},a){return console.warn("[DEPRECATED] jotai/babel/plugin-debug-label is deprecated and will be removed in v3.\nPlease use the `jotai-babel` package instead: https://github.com/jotaijs/jotai-babel"),{visitor:{ExportDefaultDeclaration(e,o){const{node:i}=e;if(t.isCallExpression(i.declaration)&&l(t,i.declaration.callee,a==null?void 0:a.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=h(`
          const %%atomIdentifier%% = %%atom%%;
          export default %%atomIdentifier%%
          `)({atomIdentifier:t.identifier(r),atom:i.declaration});e.replaceWithMultiple(c)}},VariableDeclarator(e){t.isIdentifier(e.node.id)&&t.isCallExpression(e.node.init)&&l(t,e.node.init.callee,a==null?void 0:a.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))))}}}}const m=s.default||s;function f({types:t},a){return console.warn("[DEPRECATED] jotai/babel/plugin-react-refresh is deprecated and will be removed in v3.\nPlease use the `jotai-babel` package instead: https://github.com/jotaijs/jotai-babel"),{pre({opts:e}){if(!e.filename)throw new Error("Filename must be available")},visitor:{Program:{exit(e){const o=m(`
          globalThis.jotaiAtomCache = globalThis.jotaiAtomCache || {
            cache: new Map(),
            get(name, inst) { 
              if (this.cache.has(name)) {
                return this.cache.get(name)
              }
              this.cache.set(name, inst)
              return inst
            },
          }`)();e.unshiftContainer("body",o)}},ExportDefaultDeclaration(e,o){const{node:i}=e;if(t.isCallExpression(i.declaration)&&l(t,i.declaration.callee,a==null?void 0:a.customAtomNames)){const n=`${o.filename||"unknown"}/defaultExport`,r=m("export default globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomKey:t.stringLiteral(n),atom:i.declaration});e.replaceWith(r)}},VariableDeclarator(e,o){var i,n;if(t.isIdentifier(e.node.id)&&t.isCallExpression(e.node.init)&&l(t,e.node.init.callee,a==null?void 0:a.customAtomNames)&&((i=e.parentPath.parentPath)!=null&&i.isProgram()||(n=e.parentPath.parentPath)!=null&&n.isExportNamedDeclaration())){const r=`${o.filename||"unknown"}/${e.node.id.name}`,c=m("const %%atomIdentifier%% = globalThis.jotaiAtomCache.get(%%atomKey%%, %%atom%%)")({atomIdentifier:t.identifier(e.node.id.name),atomKey:t.stringLiteral(r),atom:e.node.init});e.parentPath.replaceWith(c)}}}}}function b(t,a){return console.warn("[DEPRECATED] jotai/babel/preset is deprecated and will be removed in v3.\nPlease use the `jotai-babel` package instead: https://github.com/jotaijs/jotai-babel"),{plugins:[[p,a],[f,a]]}}})}}));
