import{g as e}from"./paths-B4IRk3wi.js";import{Oo as t}from"./model-selection-p21GBPS6.js";import n from"node:path";import{randomBytes as r}from"node:crypto";function i(t,r){let i=t??e(),a=n.join(i,r);return{dir:a,pendingPath:n.join(a,`pending.json`),pairedPath:n.join(a,`paired.json`)}}function a(e,t,n){for(let[r,i]of Object.entries(e))t-i.ts>n&&delete e[r]}async function o(e){let t=Object.values(e.pendingById).find(e.isExisting);if(t)return{status:`pending`,request:t,created:!1};let n=e.createRequest(e.isRepair);return e.pendingById[n.requestId]=n,await e.persist(),{status:`pending`,request:n,created:!0}}async function s(e){let t=await e.loadState(),n=t.pendingById[e.requestId];return n?(delete t.pendingById[e.requestId],await e.persistState(t),{requestId:e.requestId,[e.idKey]:e.getId(n)}):null}function c(){return r(32).toString(`base64url`)}function l(e,n){return t(e,n)}export{i as a,a as i,l as n,o,s as r,c as t};
