import{s as e}from"./DrKWWDpL.js";import{t}from"./DYP3EJMY.js";import{g as n,i as r,l as i,n as a,p as o,u as s}from"./DeO5NWhN.js";import{t as c}from"./C0nwgWmB.js";import{h as l}from"./B8PRMiR2.js";var u=e(t(),1),d=(0,u.createRequire)(import.meta.url),{DatabaseSync:f}=d(`node:sqlite`),p=null;function m(){return p===null&&(p=d(`drizzle-orm/node-sqlite`).drizzle),p}var h=`2026.4.23`,g=null,_=null,v=null;function y(e){return r(`project`,e)}function b(){return s(`drizzle-conduit`)}function x(e){let t=b();n(e,t,`_conduit_meta`,`conduit`,i(`drizzle-conduit`)),o(m()({client:e,schema:l}),{migrationsFolder:t})}async function S(e){let t=y(e);if(g&&(!g.isOpen||_!==t)&&w(),g&&_===t)return{action:`exists`,path:t};if(v)return v;v=(async()=>{let n=(0,u.existsSync)(t),r=(await a(`project`,e)).db.$client??null;if(!r)throw Error(`E6-L3: openDualScopeDb returned a handle without $client — cannot extract DatabaseSync for legacy conduit-schema wrapping.`);return x(r),r.exec(`INSERT OR REPLACE INTO _conduit_meta (key, value, updated_at)
       VALUES ('schema_version', '${h}', strftime('%s', 'now'))`),g=r,_=t,{action:n?`exists`:`created`,path:t}})();try{return await v}finally{v=null}}function C(){return g}function w(){g=null,_=null,v=null}function T(e){let t=new f(y(e));return c(t),t}export{T as i,y as n,C as r,S as t};