yaml-flow 8.4.18 → 8.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/browser/asset-integrity.json +3 -3
  2. package/browser/board-livecards-localstorage.js +7 -7
  3. package/cli/browser-api/board-live-cards-browser-adapter.d.ts +2 -2
  4. package/cli/browser-api/board-live-cards-browser-adapter.js +3 -3
  5. package/cli/browser-api/card-store-browser-api.js +1 -1
  6. package/cli/bundled/artifacts-store-cli.mjs +9 -9
  7. package/cli/bundled/board-live-cards-cli.mjs +19 -19
  8. package/cli/{execution-interface-BCIhu1gO.d.ts → execution-interface-_BN4kSuA.d.ts} +7 -1
  9. package/cli/{types-juH2nFpz.d.ts → types-CaQhDvWD.d.ts} +8 -1
  10. package/examples/board/demo-shell-with-server.html +2 -2
  11. package/examples/board/doc.html +2 -2
  12. package/examples/board-local/demo-shell-localstorage.html +3 -3
  13. package/lib/{artifacts-store-lib-D-k-E8Vy.d.ts → artifacts-store-lib-CODxnrXD.d.ts} +1 -1
  14. package/lib/{artifacts-store-lib-CVgtQrNZ.d.cts → artifacts-store-lib-DuatIrVb.d.cts} +1 -1
  15. package/lib/artifacts-store-public.d.cts +3 -3
  16. package/lib/artifacts-store-public.d.ts +3 -3
  17. package/lib/board-live-cards-node.cjs +10 -10
  18. package/lib/board-live-cards-node.d.cts +10 -10
  19. package/lib/board-live-cards-node.d.ts +10 -10
  20. package/lib/board-live-cards-node.js +10 -10
  21. package/lib/{board-live-cards-public-B4RcYPC_.d.cts → board-live-cards-public-DTuWGcCs.d.cts} +8 -1
  22. package/lib/{board-live-cards-public-ydXuA4zh.d.ts → board-live-cards-public-KyDR96Rf.d.ts} +8 -1
  23. package/lib/board-live-cards-public.cjs +2 -2
  24. package/lib/board-live-cards-public.d.cts +2 -2
  25. package/lib/board-live-cards-public.d.ts +2 -2
  26. package/lib/board-live-cards-public.js +2 -2
  27. package/lib/board-live-cards-server-runtime.cjs +3 -3
  28. package/lib/board-live-cards-server-runtime.d.cts +5 -5
  29. package/lib/board-live-cards-server-runtime.d.ts +5 -5
  30. package/lib/board-live-cards-server-runtime.js +3 -3
  31. package/lib/card-store-public.d.cts +2 -2
  32. package/lib/card-store-public.d.ts +2 -2
  33. package/lib/{chat-storage-lib-DsF4kPon.d.ts → chat-storage-lib-DFUsokwy.d.ts} +1 -1
  34. package/lib/{chat-storage-lib-B1wU27y3.d.cts → chat-storage-lib-DxyFlJVt.d.cts} +1 -1
  35. package/lib/chat-store-public.d.cts +3 -3
  36. package/lib/chat-store-public.d.ts +3 -3
  37. package/lib/execution-refs.cjs +2 -2
  38. package/lib/execution-refs.js +2 -2
  39. package/lib/index.d.cts +1 -1
  40. package/lib/index.d.ts +1 -1
  41. package/lib/server-runtime/index.cjs +3 -3
  42. package/lib/server-runtime/index.d.cts +6 -6
  43. package/lib/server-runtime/index.d.ts +6 -6
  44. package/lib/server-runtime/index.js +3 -3
  45. package/lib/step-machine-public/index.cjs +3 -3
  46. package/lib/step-machine-public/index.d.cts +1 -1
  47. package/lib/step-machine-public/index.d.ts +1 -1
  48. package/lib/step-machine-public/index.js +3 -3
  49. package/lib/{storage-interface-B2WD9D5n.d.cts → storage-interface-D4Ny0Men.d.cts} +7 -1
  50. package/lib/{storage-interface-B2WD9D5n.d.ts → storage-interface-D4Ny0Men.d.ts} +7 -1
  51. package/lib/stores/index.d.cts +1 -1
  52. package/lib/stores/index.d.ts +1 -1
  53. package/lib/stores/kv.d.cts +1 -1
  54. package/lib/stores/kv.d.ts +1 -1
  55. package/lib/{types-1L1D33mr.d.ts → types-Bep-vtP0.d.ts} +4 -4
  56. package/lib/{types-D501gMQt.d.cts → types-DbvoDam4.d.cts} +4 -4
  57. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { B as BoardPlatformAdapter, N as NotificationTransport, C as ChatStorage } from '../types-juH2nFpz.js';
2
- import { E as ExecutionRef } from '../execution-interface-BCIhu1gO.js';
1
+ import { B as BoardPlatformAdapter, N as NotificationTransport, C as ChatStorage } from '../types-CaQhDvWD.js';
2
+ import { E as ExecutionRef } from '../execution-interface-_BN4kSuA.js';
3
3
  import '../board-live-cards-lib-COi4bSpk.js';
4
4
 
5
5
  declare function createLocalStorageChatStorage(namespace: string): ChatStorage;
@@ -1,4 +1,4 @@
1
- var A="b64:";function D(t){let e=new TextEncoder().encode(t),g=globalThis.Buffer,a;if(g)a=g.from(e).toString("base64");else if(typeof btoa=="function"){let s="";for(let l of e)s+=String.fromCharCode(l);a=btoa(s);}else throw new Error("No base64 encoder available in this runtime");return a.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function W(t){let e=t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4),g=globalThis.Buffer;if(g)return g.from(e,"base64").toString("utf8");if(typeof atob=="function"){let a=atob(e),s=new Uint8Array(a.length);for(let l=0;l<a.length;l+=1)s[l]=a.charCodeAt(l);return new TextDecoder().decode(s)}throw new Error("No base64 decoder available in this runtime")}function v(t){return `${A}${D(JSON.stringify(t))}`}function k(t){if(!t.startsWith(A))throw new Error(`Invalid ref format (expected ${A}<base64url(json)>): ${t}`);let e;try{e=JSON.parse(W(t.slice(A.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${t}`)}if(!e||typeof e!="object")throw new Error(`Invalid ref format (expected object payload): ${t}`);let g=e;if(typeof g.kind!="string"||typeof g.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:g.kind,value:g.value}}function E(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}function L(t){let e=t.payload??{};return {id:t.id,role:typeof e.role=="string"?e.role:"system",text:typeof e.text=="string"?e.text:"",files:Array.isArray(e.files)?e.files:[],updated_at:typeof e.updated_at=="string"?e.updated_at:""}}function M(t,e){let g=s=>`chats/${E(s)}/processing`,a=s=>`chats/${E(s)}/config`;return {append(s,l,r,o=[]){return t(s).append({role:l,text:r,files:o,updated_at:new Date().toISOString()}).id},readAll(s){return t(s).readAll().map(L)},readAfter(s,l){let r=t(s).readAfter(l);return {records:r.entries.map(L),cursor:r.newCursor}},clear(s){t(s).clear?.();},setProcessing(s,l){l?e.write(g(s),true):e.delete(g(s));},isProcessing(s){return e.read(g(s))===true},getConfig(s){return e.read(a(s))??{}},setConfig(s,l){let r=e.read(a(s))??{};e.write(a(s),{...r,...l});}}}function $(t){if(t==null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return `[${t.map($).join(",")}]`;let e=t;return `{${Object.keys(e).sort().map(a=>`${JSON.stringify(a)}:${$(e[a])}`).join(",")}}`}function I(t,e){let g=e>>>0;for(let a=0;a<t.length;a++)g^=t.charCodeAt(a),g=Math.imul(g,16777619)>>>0;return g}function O(t){let e=$(t),g=I(e,2166136261),a=I(e,3735928559),s=I(e,19088743),l=I(e,4277009102);return [g,a,s,l].map(r=>r.toString(16).padStart(8,"0")).join("")}function R(t){function e(l){return `${t}:blob:${l}`}let g=new TextEncoder;function a(l){if(typeof btoa=="function"){let r="";for(let o=0;o<l.length;o++)r+=String.fromCharCode(l[o]);return btoa(r)}return ""}function s(l){if(typeof atob=="function"){let r=atob(l),o=new Uint8Array(r.length);for(let i=0;i<r.length;i++)o[i]=r.charCodeAt(i);return o}return new Uint8Array}return {read(l){return globalThis.localStorage.getItem(e(l))},write(l,r){globalThis.localStorage.setItem(e(l),r);},exists(l){return globalThis.localStorage.getItem(e(l))!==null},remove(l){globalThis.localStorage.removeItem(e(l));},readBytes(l){let r=globalThis.localStorage.getItem(e(l));if(r===null)return null;try{let o=JSON.parse(r);if(o&&o.__kind==="bytes-b64"&&typeof o.data=="string")return s(o.data)}catch{}return g.encode(r)},writeBytes(l,r){let o=JSON.stringify({__kind:"bytes-b64",data:a(r)});globalThis.localStorage.setItem(e(l),o);},listKeys(l){let r=e(l??""),o=[];for(let i=0;i<globalThis.localStorage.length;i++){let u=globalThis.localStorage.key(i);u&&u.startsWith(r)&&o.push(u.slice(e("").length));}return o.sort()},stat(l){let r=globalThis.localStorage.getItem(e(l));if(r===null)return null;let o=g.encode(r).byteLength;try{let i=JSON.parse(r);i&&i.__kind==="bytes-b64"&&typeof i.data=="string"&&(o=s(i.data).byteLength);}catch{}return {key:l,size:o}}}}var V=":scratch-marker",H=":scratch-config",T=":scratch:",z=1440*60*1e3,X=720*60*1e3,q=200;function N(t,e){if(!t)return e;let g=t.replace(/[^A-Za-z0-9._-]/g,"_");return g.length>0?g:e}function B(t){let e=`${t}${V}`,g=`${t}${H}`,a=n=>`${t}${T}${n}`,s=n=>`${t}${T}${n}:__ts`,l=globalThis.localStorage.getItem(e)===null;if(l)try{globalThis.localStorage.setItem(e,`scratch-store
2
- ${new Date().toISOString()}`);}catch{}function r(){let n=globalThis.localStorage.getItem(g);if(n===null)return {};try{let c=JSON.parse(n);return c&&typeof c=="object"&&!Array.isArray(c)?c:{}}catch{return {}}}function o(n){try{globalThis.localStorage.setItem(g,JSON.stringify(n));}catch{}}if(l){let n=r();typeof n["retention.lastSweepAt"]!="number"&&(n["retention.lastSweepAt"]=Date.now(),o(n));}function i(){if(globalThis.localStorage.getItem(e)===null)return;let n=r(),c=typeof n["retention.maxAgeMs"]=="number"?n["retention.maxAgeMs"]:z,f=typeof n["retention.sweepIntervalMs"]=="number"?n["retention.sweepIntervalMs"]:X;if(c<=0||f<=0)return;let h=typeof n["retention.lastSweepAt"]=="number"?n["retention.lastSweepAt"]:0,y=Date.now();if(y-h<f)return;n["retention.lastSweepAt"]=y,o(n);let p=y,S=`${t}${T}`,b=[];for(let m=0;m<globalThis.localStorage.length;m++){let w=globalThis.localStorage.key(m);w&&w.startsWith(S)&&!w.endsWith(":__ts")&&b.push(w);}for(let m of b){if(Date.now()-p>q)break;let w=globalThis.localStorage.getItem(`${m}:__ts`),C=w===null?0:Number(w);if(Number.isFinite(C)&&C>0&&y-C>c){try{globalThis.localStorage.removeItem(m);}catch{}try{globalThis.localStorage.removeItem(`${m}:__ts`);}catch{}}}}function u(n,c){let f=N(n,"scratch"),h=N(c,".json"),y=h.startsWith(".")?h:`.${h}`,p=Math.random().toString(36).slice(2,10);return `${f}-${Date.now()}-${p}${y}`}function d(n,c){globalThis.localStorage.setItem(a(n),c),globalThis.localStorage.setItem(s(n),String(Date.now()));}return {read(n){return globalThis.localStorage.getItem(a(n))},write(n,c){d(n,c);try{i();}catch{}},exists(n){return globalThis.localStorage.getItem(a(n))!==null},remove(n){try{globalThis.localStorage.removeItem(a(n));}catch{}try{globalThis.localStorage.removeItem(s(n));}catch{}},readBytes(n){let c=globalThis.localStorage.getItem(a(n));return c===null?null:new TextEncoder().encode(c)},writeBytes(n,c){let f="";for(let h=0;h<c.length;h++)f+=String.fromCharCode(c[h]);d(n,f);try{i();}catch{}},stat(n){let c=globalThis.localStorage.getItem(a(n));if(c===null)return null;let f=globalThis.localStorage.getItem(s(n)),h=f===null?null:Number(f);return {key:n,size:new TextEncoder().encode(c).byteLength,updatedAt:h!==null&&Number.isFinite(h)?new Date(h).toISOString():void 0}},listKeys(n){let c=`${t}${T}`,f=[];for(let h=0;h<globalThis.localStorage.length;h++){let y=globalThis.localStorage.key(h);if(y&&y.startsWith(c)&&!y.endsWith(":__ts")){let p=y.slice(c.length);(!n||p.startsWith(n))&&f.push(p);}}return f.sort()},getUniqueKey(n,c){return u(n,c)},create(n,c,f){let h=u(c,f);d(h,n);try{i();}catch{}return h},keyRef(n){return {kind:"local-storage-scratch",value:n,extra:{prefix:t}}},config:{get(n){return r()[n]??null},set(n,c){let f=r();c==null?delete f[n]:f[n]=c,o(f);}}}}var G=":archive-marker",Z=":archive-config",_=":archive:stream:",K=":archive:blob:";function U(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"_");if(!e)throw new Error("Archive segment name cannot be empty after sanitization");return e}function J(t){let e=`${t}${G}`,g=`${t}${Z}`,a=o=>`${t}${_}${o}`;if(globalThis.localStorage.getItem(e)===null)try{globalThis.localStorage.setItem(e,`archive-store
3
- ${new Date().toISOString()}`);}catch{}function s(){let o=globalThis.localStorage.getItem(g);if(o===null)return {};try{let i=JSON.parse(o);return i&&typeof i=="object"&&!Array.isArray(i)?i:{}}catch{return {}}}function l(o){try{globalThis.localStorage.setItem(g,JSON.stringify(o));}catch{}}function r(){if(globalThis.localStorage.getItem(e)===null)return;let o=s(),i=typeof o["retention.maxAgeMs"]=="number"?o["retention.maxAgeMs"]:0,u=typeof o["retention.sweepIntervalMs"]=="number"?o["retention.sweepIntervalMs"]:0;if(i<=0||u<=0)return;let d=typeof o["retention.lastSweepAt"]=="number"?o["retention.lastSweepAt"]:0,n=Date.now();if(n-d<u)return;o["retention.lastSweepAt"]=n,l(o);let c=`${t}${_}`;for(let f=0;f<globalThis.localStorage.length;f++){let h=globalThis.localStorage.key(f);if(!h||!h.startsWith(c))continue;let y=globalThis.localStorage.getItem(h);if(y)try{let p=JSON.parse(y),S=p.filter(b=>typeof b.__ts!="number"||n-b.__ts<=i);S.length!==p.length&&globalThis.localStorage.setItem(h,JSON.stringify(S));}catch{}}}return {stream(o){let i=U(o),u=a(i);function d(){let c=globalThis.localStorage.getItem(u);if(!c)return [];try{return JSON.parse(c)}catch{return []}}function n(c){try{globalThis.localStorage.setItem(u,JSON.stringify(c));}catch{}}return {append(c){let f={id:globalThis.crypto.randomUUID(),payload:c,__ts:Date.now()},h=d();h.push(f),n(h);try{r();}catch{}return {id:f.id,payload:f.payload}},readAll(){return d().map(c=>({id:c.id,payload:c.payload}))},readAfter(c){let f=d();if(!c){let S=f.map(b=>({id:b.id,payload:b.payload}));return {entries:S,newCursor:S.length>0?S[S.length-1].id:null}}let h=f.findIndex(S=>S.id===c),p=(h===-1?f:f.slice(h+1)).map(S=>({id:S.id,payload:S.payload}));return {entries:p,newCursor:p.length>0?p[p.length-1].id:c}},clear(){try{globalThis.localStorage.removeItem(u);}catch{}}}},blob(o){let i=U(o),u=R(`${t}${K}${i}`);return {read:d=>u.read(d),write:(d,n)=>{u.write(d,n);try{r();}catch{}},exists:d=>u.exists(d),remove:d=>u.remove(d),readBytes:u.readBytes?d=>u.readBytes(d):void 0,writeBytes:u.writeBytes?(d,n)=>{u.writeBytes(d,n);try{r();}catch{}}:void 0,listKeys:d=>u.listKeys(d),stat:u.stat?d=>u.stat(d):void 0}},listStreams(o){let i=`${t}${_}`,u=[];for(let d=0;d<globalThis.localStorage.length;d++){let n=globalThis.localStorage.key(d);if(!n||!n.startsWith(i))continue;let c=n.slice(i.length);(!o||c.startsWith(o))&&u.push(c);}return u.sort()},listBlobs(o){let i=`${t}${K}`,u=new Set;for(let d=0;d<globalThis.localStorage.length;d++){let n=globalThis.localStorage.key(d);if(!n||!n.startsWith(i))continue;let c=n.slice(i.length),f=c.indexOf(":"),h=f===-1?c:c.slice(0,f);(!o||h.startsWith(o))&&u.add(h);}return Array.from(u).sort()},config:{get(o){return s()[o]??null},set(o,i){let u=s();i==null?delete u[o]:u[o]=i,l(u);}}}}function x(t){function e(g){return `${t}:kv:${g}`}return {read(g){let a=globalThis.localStorage.getItem(e(g));if(a===null)return null;try{return JSON.parse(a)}catch{return null}},write(g,a){globalThis.localStorage.setItem(e(g),JSON.stringify(a));},delete(g){globalThis.localStorage.removeItem(e(g));},listKeys(g){let a=e(g??""),s=[];for(let l=0;l<globalThis.localStorage.length;l++){let r=globalThis.localStorage.key(l);r!==null&&r.startsWith(a)&&s.push(r.slice(e("").length));}return s}}}function j(t){function e(){let a=globalThis.localStorage.getItem(t);if(!a)return [];try{return JSON.parse(a)}catch{return []}}function g(a){globalThis.localStorage.setItem(t,JSON.stringify(a));}return {readAllEntries(){return e()},appendEntry(a){let s=e();s.push(a),g(s);},generateId(){return globalThis.crypto.randomUUID()}}}function Y(){let t=false;return {tryAcquire(){return t?null:(t=true,()=>{t=false;})}}}function Q(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}function tt(t){function e(){let a=globalThis.localStorage.getItem(t);if(!a)return [];try{return JSON.parse(a)}catch{return []}}function g(a){globalThis.localStorage.setItem(t,JSON.stringify(a));}return {append(a){let s={id:globalThis.crypto.randomUUID(),payload:a},l=e();return l.push(s),g(l),s},readAll(){return e()},readAfter(a){let s=e();if(!a)return {entries:s,newCursor:s.length>0?s[s.length-1].id:null};let l=s.findIndex(o=>o.id===a),r=l===-1?s:s.slice(l+1);return {entries:r,newCursor:r.length>0?r[r.length-1].id:a}},clear(){globalThis.localStorage.removeItem(t);}}}function it(t){return M(e=>tt(`${t}:chat:journal:${Q(e)}`),x(`${t}:chat`))}var P=new Map;function F(t){let e=P.get(t);if(!e){let g=new Set;e={publish(a){for(let s of g)s(a);},subscribe(a){return g.add(a),()=>{g.delete(a);}}},P.set(t,e);}return e}function lt(){return {async subscribe(t,e){return t.kind!=="in-memory-bus"?(console.warn(`[in-memory-transport] unsupported kind: ${t.kind}`),()=>{}):F(t.value).subscribe(a=>{let s=a;if(s&&s.kind==="notification-batch"&&Array.isArray(s.notifications)){for(let l of s.notifications)e(l);return}e(a);})}}}function ct(t,e){let g=e?.callbackBaseUrl?{meta:"board-live-cards",howToRun:"http:post",whatToRun:e.callbackBaseUrl}:{meta:"board-live-cards",howToRun:"in-browser",whatToRun:v({kind:"in-browser",value:t})},a=new Map,s=new Map,l=Y();return {kvStorage:r=>x(`${t}:${r}`),blobStorage:r=>R(r?`${t}:${r}`:t),scratchStorage:()=>B(`${t}:scratch`),scratchStorageForRef:r=>B(k(r).value),archiveFactory:()=>J(`${t}:archive`),archiveFactoryForRef:r=>J(k(r).value),journalAdapter:()=>j(`${t}:journal`),lock:l,selfRef:g,async dispatchExecution(r,o){if(r.howToRun==="http:post")try{let i=r.whatToRun,u=typeof i=="object"?i.value:k(i).value,d=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});return d.ok?{dispatched:!0}:{dispatched:!1,error:`HTTP ${d.status}: ${d.statusText}`}}catch(i){return {dispatched:false,error:i instanceof Error?i.message:String(i)}}if(r.howToRun==="http:get")try{let i=r.whatToRun,u=typeof i=="object"?i.value:k(i).value,d=new URLSearchParams(Object.entries(o).filter(([,f])=>f!=null).map(([f,h])=>[f,String(h)])),n=`${u}?${d.toString()}`,c=await fetch(n);return c.ok?{dispatched:!0}:{dispatched:!1,error:`HTTP ${c.status}: ${c.statusText}`}}catch(i){return {dispatched:false,error:i instanceof Error?i.message:String(i)}}if(r.howToRun==="in-browser"){let i=r.whatToRun,u=typeof i=="object"?i.value:k(i).value,d=a.get(u);return d?d(r,o):{dispatched:false,error:`No in-browser handler registered for: ${u}`}}return {dispatched:false,error:`Browser adapter: unsupported dispatch kind (got: ${r.howToRun})`}},resolveBlob(r){if(r.kind==="in-memory"){let u=s.get(r.value);if(u==null)throw new Error(`resolveBlob: in-memory blob not found: ${v(r)}`);return u}let i=R(t).read(r.value);if(i===null)throw new Error(`resolveBlob: blob not found: ${v(r)}`);return i},hashFn:O,genId:()=>globalThis.crypto.randomUUID().replace(/-/g,""),kvStorageForRef:r=>x(k(r).value),publishBoardChangeNotifications(r){if(!e?.notifyChannel||r.length===0)return;F(e.notifyChannel).publish({kind:"notification-batch",notifications:r});},onWarn:e?.onWarn,registerHandler(r,o){a.set(r,o);},writeMemoryBlob(r,o){return s.set(r,o),v({kind:"in-memory",value:r})}}}export{ct as createBrowserBoardPlatformAdapter,lt as createInMemoryNotificationTransport,it as createLocalStorageChatStorage,F as getInMemoryNotificationBus};//# sourceMappingURL=board-live-cards-browser-adapter.js.map
1
+ var A="b64:";function D(t){let e=new TextEncoder().encode(t),g=globalThis.Buffer,a;if(g)a=g.from(e).toString("base64");else if(typeof btoa=="function"){let i="";for(let l of e)i+=String.fromCharCode(l);a=btoa(i);}else throw new Error("No base64 encoder available in this runtime");return a.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function W(t){let e=t.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-t.length%4)%4),g=globalThis.Buffer;if(g)return g.from(e,"base64").toString("utf8");if(typeof atob=="function"){let a=atob(e),i=new Uint8Array(a.length);for(let l=0;l<a.length;l+=1)i[l]=a.charCodeAt(l);return new TextDecoder().decode(i)}throw new Error("No base64 decoder available in this runtime")}function v(t){return `${A}${D(JSON.stringify(t))}`}function k(t){if(!t.startsWith(A))throw new Error(`Invalid ref format (expected ${A}<base64url(json)>): ${t}`);let e;try{e=JSON.parse(W(t.slice(A.length)));}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${t}`)}if(!e||typeof e!="object")throw new Error(`Invalid ref format (expected object payload): ${t}`);let g=e;if(typeof g.kind!="string"||typeof g.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${t}`);return {kind:g.kind,value:g.value}}function J(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}function L(t){let e=t.payload??{};return {id:t.id,role:typeof e.role=="string"?e.role:"system",text:typeof e.text=="string"?e.text:"",files:Array.isArray(e.files)?e.files:[],updated_at:typeof e.updated_at=="string"?e.updated_at:""}}function N(t,e){let g=i=>`chats/${J(i)}/processing`,a=i=>`chats/${J(i)}/config`;return {append(i,l,r,o=[]){return t(i).append({role:l,text:r,files:o,updated_at:new Date().toISOString()}).id},readAll(i){return t(i).readAll().map(L)},readAfter(i,l){let r=t(i).readAfter(l);return {records:r.entries.map(L),cursor:r.newCursor}},clear(i){t(i).clear?.();},setProcessing(i,l){l?e.write(g(i),true):e.delete(g(i));},isProcessing(i){return e.read(g(i))===true},getConfig(i){return e.read(a(i))??{}},setConfig(i,l){let r=e.read(a(i))??{};e.write(a(i),{...r,...l});}}}function _(t){if(t==null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return `[${t.map(_).join(",")}]`;let e=t;return `{${Object.keys(e).sort().map(a=>`${JSON.stringify(a)}:${_(e[a])}`).join(",")}}`}function I(t,e){let g=e>>>0;for(let a=0;a<t.length;a++)g^=t.charCodeAt(a),g=Math.imul(g,16777619)>>>0;return g}function U(t){let e=_(t),g=I(e,2166136261),a=I(e,3735928559),i=I(e,19088743),l=I(e,4277009102);return [g,a,i,l].map(r=>r.toString(16).padStart(8,"0")).join("")}function T(t){function e(l){return `${t}:blob:${l}`}let g=new TextEncoder;function a(l){if(typeof btoa=="function"){let r="";for(let o=0;o<l.length;o++)r+=String.fromCharCode(l[o]);return btoa(r)}return ""}function i(l){if(typeof atob=="function"){let r=atob(l),o=new Uint8Array(r.length);for(let s=0;s<r.length;s++)o[s]=r.charCodeAt(s);return o}return new Uint8Array}return {read(l){return globalThis.localStorage.getItem(e(l))},write(l,r){globalThis.localStorage.setItem(e(l),r);},exists(l){return globalThis.localStorage.getItem(e(l))!==null},remove(l){globalThis.localStorage.removeItem(e(l));},readBytes(l){let r=globalThis.localStorage.getItem(e(l));if(r===null)return null;try{let o=JSON.parse(r);if(o&&o.__kind==="bytes-b64"&&typeof o.data=="string")return i(o.data)}catch{}return g.encode(r)},writeBytes(l,r){let o=JSON.stringify({__kind:"bytes-b64",data:a(r)});globalThis.localStorage.setItem(e(l),o);},listKeys(l){let r=e(l??""),o=[];for(let s=0;s<globalThis.localStorage.length;s++){let u=globalThis.localStorage.key(s);u&&u.startsWith(r)&&o.push(u.slice(e("").length));}return o.sort()},stat(l){let r=globalThis.localStorage.getItem(e(l));if(r===null)return null;let o=g.encode(r).byteLength;try{let s=JSON.parse(r);s&&s.__kind==="bytes-b64"&&typeof s.data=="string"&&(o=i(s.data).byteLength);}catch{}return {key:l,size:o}}}}var V=":scratch-marker",H=":scratch-config",R=":scratch:",z=1440*60*1e3,X=720*60*1e3,q=200;function M(t,e){if(!t)return e;let g=t.replace(/[^A-Za-z0-9._-]/g,"_");return g.length>0?g:e}function E(t){let e=`${t}${V}`,g=`${t}${H}`,a=n=>`${t}${R}${n}`,i=n=>`${t}${R}${n}:__ts`,l=globalThis.localStorage.getItem(e)===null;if(l)try{globalThis.localStorage.setItem(e,`scratch-store
2
+ ${new Date().toISOString()}`);}catch{}function r(){let n=globalThis.localStorage.getItem(g);if(n===null)return {};try{let c=JSON.parse(n);return c&&typeof c=="object"&&!Array.isArray(c)?c:{}}catch{return {}}}function o(n){try{globalThis.localStorage.setItem(g,JSON.stringify(n));}catch{}}if(l){let n=r();typeof n["retention.lastSweepAt"]!="number"&&(n["retention.lastSweepAt"]=Date.now(),o(n));}function s(){if(globalThis.localStorage.getItem(e)===null)return;let n=r(),c=typeof n["retention.maxAgeMs"]=="number"?n["retention.maxAgeMs"]:z,f=typeof n["retention.sweepIntervalMs"]=="number"?n["retention.sweepIntervalMs"]:X;if(c<=0||f<=0)return;let y=typeof n["retention.lastSweepAt"]=="number"?n["retention.lastSweepAt"]:0,h=Date.now();if(h-y<f)return;n["retention.lastSweepAt"]=h,o(n);let p=h,S=`${t}${R}`,b=[];for(let w=0;w<globalThis.localStorage.length;w++){let m=globalThis.localStorage.key(w);m&&m.startsWith(S)&&!m.endsWith(":__ts")&&b.push(m);}for(let w of b){if(Date.now()-p>q)break;let m=globalThis.localStorage.getItem(`${w}:__ts`),C=m===null?0:Number(m);if(Number.isFinite(C)&&C>0&&h-C>c){try{globalThis.localStorage.removeItem(w);}catch{}try{globalThis.localStorage.removeItem(`${w}:__ts`);}catch{}}}}function u(n,c){let f=M(n,"scratch"),y=M(c,".json"),h=y.startsWith(".")?y:`.${y}`,p=Math.random().toString(36).slice(2,10);return `${f}-${Date.now()}-${p}${h}`}function d(n,c){globalThis.localStorage.setItem(a(n),c),globalThis.localStorage.setItem(i(n),String(Date.now()));}return {read(n){return globalThis.localStorage.getItem(a(n))},write(n,c){d(n,c);try{s();}catch{}},exists(n){return globalThis.localStorage.getItem(a(n))!==null},remove(n){try{globalThis.localStorage.removeItem(a(n));}catch{}try{globalThis.localStorage.removeItem(i(n));}catch{}},readBytes(n){let c=globalThis.localStorage.getItem(a(n));return c===null?null:new TextEncoder().encode(c)},writeBytes(n,c){let f="";for(let y=0;y<c.length;y++)f+=String.fromCharCode(c[y]);d(n,f);try{s();}catch{}},stat(n){let c=globalThis.localStorage.getItem(a(n));if(c===null)return null;let f=globalThis.localStorage.getItem(i(n)),y=f===null?null:Number(f);return {key:n,size:new TextEncoder().encode(c).byteLength,updatedAt:y!==null&&Number.isFinite(y)?new Date(y).toISOString():void 0}},listKeys(n){let c=`${t}${R}`,f=[];for(let y=0;y<globalThis.localStorage.length;y++){let h=globalThis.localStorage.key(y);if(h&&h.startsWith(c)&&!h.endsWith(":__ts")){let p=h.slice(c.length);(!n||p.startsWith(n))&&f.push(p);}}return f.sort()},getUniqueKey(n,c){return u(n,c)},create(n,c,f){let y=u(c,f);d(y,n);try{s();}catch{}return y},keyRef(n){return {kind:"local-storage-scratch",value:n,extra:{prefix:t}}},config:{get(n){return r()[n]??null},set(n,c){let f=r();c==null?delete f[n]:f[n]=c,o(f);}}}}var G=":archive-marker",Z=":archive-config",$=":archive:stream:",K=":archive:blob:";function O(t){let e=t.replace(/[^A-Za-z0-9._-]/g,"_");if(!e)throw new Error("Archive segment name cannot be empty after sanitization");return e}function B(t){let e=`${t}${G}`,g=`${t}${Z}`,a=o=>`${t}${$}${o}`;if(globalThis.localStorage.getItem(e)===null)try{globalThis.localStorage.setItem(e,`archive-store
3
+ ${new Date().toISOString()}`);}catch{}function i(){let o=globalThis.localStorage.getItem(g);if(o===null)return {};try{let s=JSON.parse(o);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return {}}}function l(o){try{globalThis.localStorage.setItem(g,JSON.stringify(o));}catch{}}function r(){if(globalThis.localStorage.getItem(e)===null)return;let o=i(),s=typeof o["retention.maxAgeMs"]=="number"?o["retention.maxAgeMs"]:0,u=typeof o["retention.sweepIntervalMs"]=="number"?o["retention.sweepIntervalMs"]:0;if(s<=0||u<=0)return;let d=typeof o["retention.lastSweepAt"]=="number"?o["retention.lastSweepAt"]:0,n=Date.now();if(n-d<u)return;o["retention.lastSweepAt"]=n,l(o);let c=`${t}${$}`;for(let f=0;f<globalThis.localStorage.length;f++){let y=globalThis.localStorage.key(f);if(!y||!y.startsWith(c))continue;let h=globalThis.localStorage.getItem(y);if(h)try{let p=JSON.parse(h),S=p.filter(b=>typeof b.__ts!="number"||n-b.__ts<=s);S.length!==p.length&&globalThis.localStorage.setItem(y,JSON.stringify(S));}catch{}}}return {stream(o){let s=O(o),u=a(s);function d(){let c=globalThis.localStorage.getItem(u);if(!c)return [];try{return JSON.parse(c)}catch{return []}}function n(c){try{globalThis.localStorage.setItem(u,JSON.stringify(c));}catch{}}return {append(c){let f={id:globalThis.crypto.randomUUID(),payload:c,__ts:Date.now()},y=d();y.push(f),n(y);try{r();}catch{}return {id:f.id,payload:f.payload}},readAll(){return d().map(c=>({id:c.id,payload:c.payload}))},readAfter(c){let f=d();if(!c){let S=f.map(b=>({id:b.id,payload:b.payload}));return {entries:S,newCursor:S.length>0?S[S.length-1].id:null}}let y=f.findIndex(S=>S.id===c),p=(y===-1?f:f.slice(y+1)).map(S=>({id:S.id,payload:S.payload}));return {entries:p,newCursor:p.length>0?p[p.length-1].id:c}},clear(){try{globalThis.localStorage.removeItem(u);}catch{}}}},blob(o){let s=O(o),u=T(`${t}${K}${s}`);return {read:d=>u.read(d),write:(d,n)=>{u.write(d,n);try{r();}catch{}},exists:d=>u.exists(d),remove:d=>u.remove(d),readBytes:u.readBytes?d=>u.readBytes(d):void 0,writeBytes:u.writeBytes?(d,n)=>{u.writeBytes(d,n);try{r();}catch{}}:void 0,listKeys:d=>u.listKeys(d),stat:u.stat?d=>u.stat(d):void 0}},listStreams(o){let s=`${t}${$}`,u=[];for(let d=0;d<globalThis.localStorage.length;d++){let n=globalThis.localStorage.key(d);if(!n||!n.startsWith(s))continue;let c=n.slice(s.length);(!o||c.startsWith(o))&&u.push(c);}return u.sort()},listBlobs(o){let s=`${t}${K}`,u=new Set;for(let d=0;d<globalThis.localStorage.length;d++){let n=globalThis.localStorage.key(d);if(!n||!n.startsWith(s))continue;let c=n.slice(s.length),f=c.indexOf(":"),y=f===-1?c:c.slice(0,f);(!o||y.startsWith(o))&&u.add(y);}return Array.from(u).sort()},config:{get(o){return i()[o]??null},set(o,s){let u=i();s==null?delete u[o]:u[o]=s,l(u);}}}}function x(t){function e(g){return `${t}:kv:${g}`}return {read(g){let a=globalThis.localStorage.getItem(e(g));if(a===null)return null;try{return JSON.parse(a)}catch{return null}},write(g,a){globalThis.localStorage.setItem(e(g),JSON.stringify(a));},delete(g){globalThis.localStorage.removeItem(e(g));},listKeys(g){let a=e(g??""),i=[];for(let l=0;l<globalThis.localStorage.length;l++){let r=globalThis.localStorage.key(l);r!==null&&r.startsWith(a)&&i.push(r.slice(e("").length));}return i}}}function j(t){function e(){let a=globalThis.localStorage.getItem(t);if(!a)return [];try{return JSON.parse(a)}catch{return []}}function g(a){globalThis.localStorage.setItem(t,JSON.stringify(a));}return {readAllEntries(){return e()},appendEntry(a){let i=e();i.push(a),g(i);},generateId(){return globalThis.crypto.randomUUID()}}}function Y(){let t=false;return {tryAcquire(){return t?null:(t=true,()=>{t=false;})}}}function Q(t){return String(t).replace(/[^a-zA-Z0-9_-]/g,"_")}function tt(t){function e(){let a=globalThis.localStorage.getItem(t);if(!a)return [];try{return JSON.parse(a)}catch{return []}}function g(a){globalThis.localStorage.setItem(t,JSON.stringify(a));}return {append(a){let i={id:globalThis.crypto.randomUUID(),payload:a},l=e();return l.push(i),g(l),i},readAll(){return e()},readAfter(a){let i=e();if(!a)return {entries:i,newCursor:i.length>0?i[i.length-1].id:null};let l=i.findIndex(o=>o.id===a),r=l===-1?i:i.slice(l+1);return {entries:r,newCursor:r.length>0?r[r.length-1].id:a}},clear(){globalThis.localStorage.removeItem(t);}}}function st(t){return N(e=>tt(`${t}:chat:journal:${Q(e)}`),x(`${t}:chat`))}var P=new Map;function F(t){let e=P.get(t);if(!e){let g=new Set;e={publish(a){for(let i of g)i(a);},subscribe(a){return g.add(a),()=>{g.delete(a);}}},P.set(t,e);}return e}function lt(){return {async subscribe(t,e){return t.kind!=="in-memory-bus"?(console.warn(`[in-memory-transport] unsupported kind: ${t.kind}`),()=>{}):F(t.value).subscribe(a=>{let i=a;if(i&&i.kind==="notification-batch"&&Array.isArray(i.notifications)){for(let l of i.notifications)e(l);return}e(a);})}}}function ct(t,e){let g=e?.callbackBaseUrl?{meta:"board-live-cards",howToRun:"http:post",whatToRun:e.callbackBaseUrl}:{meta:"board-live-cards",howToRun:"in-browser",whatToRun:v({kind:"in-browser",value:t})},a=new Map,i=new Map,l=Y();return {kvStorage:r=>x(`${t}:${r}`),blobStorage:r=>T(r?`${t}:${r}`:t),scratchStorage:()=>E(`${t}:scratch`),scratchStorageForRef:r=>E(k(r).value),archiveFactory:()=>B(`${t}:archive`),archiveFactoryForRef:r=>B(k(r).value),journalAdapter:()=>j(`${t}:journal`),lock:l,selfRef:g,async dispatchExecution(r,o){if(r.howToRun==="http:post")try{let s=r.whatToRun,u=typeof s=="object"?s.value:k(s).value,d=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});return d.ok?{dispatched:!0}:{dispatched:!1,error:`HTTP ${d.status}: ${d.statusText}`}}catch(s){return {dispatched:false,error:s instanceof Error?s.message:String(s)}}if(r.howToRun==="http:get")try{let s=r.whatToRun,u=typeof s=="object"?s.value:k(s).value,d=new URLSearchParams(Object.entries(o).filter(([,f])=>f!=null).map(([f,y])=>[f,String(y)])),n=`${u}?${d.toString()}`,c=await fetch(n);return c.ok?{dispatched:!0}:{dispatched:!1,error:`HTTP ${c.status}: ${c.statusText}`}}catch(s){return {dispatched:false,error:s instanceof Error?s.message:String(s)}}if(r.howToRun==="in-browser"){let s=r.whatToRun,u=typeof s=="object"?s.value:k(s).value,d=a.get(u);return d?d(r,o):{dispatched:false,error:`No in-browser handler registered for: ${u}`}}return {dispatched:false,error:`Browser adapter: unsupported dispatch kind (got: ${r.howToRun})`}},resolveBlob(r){if(r.kind==="in-memory"){let u=i.get(r.value);if(u==null)throw new Error(`resolveBlob: in-memory blob not found: ${v(r)}`);return u}let s=T(t).read(r.value);if(s===null)throw new Error(`resolveBlob: blob not found: ${v(r)}`);return s},hashFn:U,genId:()=>globalThis.crypto.randomUUID().replace(/-/g,""),kvStorageForRef:r=>x(k(r).value),publishBoardChangeNotifications(r){if(!e?.notifyChannel||r.length===0)return;F(e.notifyChannel).publish({kind:"notification-batch",notifications:r});},onWarn:e?.onWarn,registerHandler(r,o){a.set(r,o);},writeMemoryBlob(r,o){return i.set(r,o),v({kind:"in-memory",value:r})}}}export{ct as createBrowserBoardPlatformAdapter,lt as createInMemoryNotificationTransport,st as createLocalStorageChatStorage,F as getInMemoryNotificationBus};//# sourceMappingURL=board-live-cards-browser-adapter.js.map
4
4
  //# sourceMappingURL=board-live-cards-browser-adapter.js.map
@@ -1,2 +1,2 @@
1
- import {createRequire}from'module';import'ajv-formats';var R=createRequire(import.meta.url);R("./jsonata-sync.cjs");var x=createRequire(import.meta.url);x("./jsonata-sync.cjs");function y(n,o){function e(){return n.readIndex()??{}}function r(t,s,i){let a=String(s||"").split(".").filter(Boolean);if(a.length===0)return i&&typeof i=="object"&&!Array.isArray(i)?i:{value:i};let u={...t},c=u;for(let d=0;d<a.length-1;d++){let l=a[d],g=c[l],m=g&&typeof g=="object"&&!Array.isArray(g)?{...g}:{};c[l]=m,c=m;}return c[a[a.length-1]]=i,u}return {readCard(t){let s=e()[t];return !s||!n.cardExists(s.key)?null:n.readCard(s.key)},readCardKey(t){return e()[t]?.key??null},readAllCards(){let t=[];for(let[s,i]of Object.entries(e())){if(!n.cardExists(i.key))continue;let a=n.readCard(i.key);a?t.push(a):o?.(`[card-store] could not read card "${s}" at key "${i.key}"`);}return t},readChecksumIndex(){let t={};for(let[s,i]of Object.entries(e()))t[s]=i.checksum;return t},changedSince(t){let s=e(),i=[];for(let[a,u]of Object.entries(s))t[a]!==u.checksum&&i.push(a);for(let a of Object.keys(t))s[a]||i.push(a);return i},validateUpsert(t,s){let i=e(),a=i[t],u=Object.entries(i).find(([,c])=>c.key===s);return a&&a.key!==s?{ok:false,error:`Card id "${t}" is already mapped to key "${a.key}", cannot remap to "${s}"`}:u&&u[0]!==t?{ok:false,error:`Key "${s}" is already mapped to card id "${u[0]}", cannot remap to "${t}"`}:{ok:true}},writeCard(t,s,i){let a=e(),u=i??a[t]?.key??n.defaultCardKey(t),c=n.writeCard(u,s);a[t]={key:u,checksum:c,updatedAt:new Date().toISOString()},n.writeIndex(a);},patchCard(t,s,i){let a=e(),u=a[t];if(!u||!n.cardExists(u.key))throw new Error(`card "${t}" not found`);let c=n.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${t}" is not patchable`);let d=r(c,s,i),l=n.writeCard(u.key,d);a[t]={key:u.key,checksum:l,updatedAt:new Date().toISOString()},n.writeIndex(a);},removeCard(t){let s=e(),i=s[t];i&&(n.removeCard(i.key),delete s[t],n.writeIndex(s));},readIndex(){return e()}}}function p(n){if(n==null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return `[${n.map(p).join(",")}]`;let o=n;return `{${Object.keys(o).sort().map(r=>`${JSON.stringify(r)}:${p(o[r])}`).join(",")}}`}function f(n,o){let e=o>>>0;for(let r=0;r<n.length;r++)e^=n.charCodeAt(r),e=Math.imul(e,16777619)>>>0;return e}function _(n){let o=p(n),e=f(o,2166136261),r=f(o,3735928559),t=f(o,19088743),s=f(o,4277009102);return [e,r,t,s].map(i=>i.toString(16).padStart(8,"0")).join("")}function A(n){function o(e){return `${n}:kv:${e}`}return {read(e){let r=globalThis.localStorage.getItem(o(e));if(r===null)return null;try{return JSON.parse(r)}catch{return null}},write(e,r){globalThis.localStorage.setItem(o(e),JSON.stringify(r));},delete(e){globalThis.localStorage.removeItem(o(e));},listKeys(e){let r=o(e??""),t=[];for(let s=0;s<globalThis.localStorage.length;s++){let i=globalThis.localStorage.key(s);i!==null&&i.startsWith(r)&&t.push(i.slice(o("").length));}return t}}}function h(n,o){let e={...n};for(let[r,t]of Object.entries(o))t!==null&&typeof t=="object"&&!Array.isArray(t)&&e[r]!==null&&typeof e[r]=="object"&&!Array.isArray(e[r])?e[r]=h(e[r],t):e[r]=t;return e}function S(n,o,e){if(o.length===0)return n;let[r,...t]=o;if(t.length===0)return {...n,[r]:e};let s=n[r]!==null&&typeof n[r]=="object"&&!Array.isArray(n[r])?n[r]:{};return {...n,[r]:S(s,t,e)}}function T(n){let o=A(n);return {read:e=>o.read(e),get(e,r){let t=o.read(e);if(t===null)return null;let s=t;for(let i of r.split(".").filter(Boolean)){if(s===null||typeof s!="object"||Array.isArray(s))return null;s=s[i]??null;}return s??null},write:(e,r)=>o.write(e,r),delete:e=>o.delete(e),listKeys:e=>o.listKeys(e),shallowMerge(e,r){let t=o.read(e)??{};o.write(e,{...t,...r});},deepMerge(e,r){let t=o.read(e)??{};o.write(e,h(t,r));},patch(e,r,t){let s=o.read(e)??{},i=r.split(".").filter(Boolean);o.write(e,S(s,i,t));}}}function k(n){let o=T(n);return {readIndex(){return o.read("_index")},writeIndex(e){o.write("_index",e);},readCard(e){return o.read(e)},writeCard(e,r){return o.write(e,r),_(r)},removeCard(e){o.delete(e);},cardExists(e){return o.read(e)!==null},defaultCardKey(e){return e}}}function ke(n){let o=k(n),e=y(o);return {getCard(r){return e.readCard(r)},getAllCards(){return e.readAllCards()},upsertCard(r){let t=o.defaultCardKey(r.id);e.writeCard(r.id,r,t);},removeCard(r){e.removeCard(r);}}}export{ke as createBrowserCardStoreApi};//# sourceMappingURL=card-store-browser-api.js.map
1
+ import {createRequire}from'module';import'ajv-formats';var C=createRequire(import.meta.url);C("./jsonata-sync.cjs");var x=createRequire(import.meta.url);x("./jsonata-sync.cjs");function y(n,o){function e(){return n.readIndex()??{}}function r(t,s,i){let a=String(s||"").split(".").filter(Boolean);if(a.length===0)return i&&typeof i=="object"&&!Array.isArray(i)?i:{value:i};let u={...t},c=u;for(let d=0;d<a.length-1;d++){let l=a[d],g=c[l],m=g&&typeof g=="object"&&!Array.isArray(g)?{...g}:{};c[l]=m,c=m;}return c[a[a.length-1]]=i,u}return {readCard(t){let s=e()[t];return !s||!n.cardExists(s.key)?null:n.readCard(s.key)},readCardKey(t){return e()[t]?.key??null},readAllCards(){let t=[];for(let[s,i]of Object.entries(e())){if(!n.cardExists(i.key))continue;let a=n.readCard(i.key);a?t.push(a):o?.(`[card-store] could not read card "${s}" at key "${i.key}"`);}return t},readChecksumIndex(){let t={};for(let[s,i]of Object.entries(e()))t[s]=i.checksum;return t},changedSince(t){let s=e(),i=[];for(let[a,u]of Object.entries(s))t[a]!==u.checksum&&i.push(a);for(let a of Object.keys(t))s[a]||i.push(a);return i},validateUpsert(t,s){let i=e(),a=i[t],u=Object.entries(i).find(([,c])=>c.key===s);return a&&a.key!==s?{ok:false,error:`Card id "${t}" is already mapped to key "${a.key}", cannot remap to "${s}"`}:u&&u[0]!==t?{ok:false,error:`Key "${s}" is already mapped to card id "${u[0]}", cannot remap to "${t}"`}:{ok:true}},writeCard(t,s,i){let a=e(),u=i??a[t]?.key??n.defaultCardKey(t),c=n.writeCard(u,s);a[t]={key:u,checksum:c,updatedAt:new Date().toISOString()},n.writeIndex(a);},patchCard(t,s,i){let a=e(),u=a[t];if(!u||!n.cardExists(u.key))throw new Error(`card "${t}" not found`);let c=n.readCard(u.key);if(!c||typeof c!="object"||Array.isArray(c))throw new Error(`card "${t}" is not patchable`);let d=r(c,s,i),l=n.writeCard(u.key,d);a[t]={key:u.key,checksum:l,updatedAt:new Date().toISOString()},n.writeIndex(a);},removeCard(t){let s=e(),i=s[t];i&&(n.removeCard(i.key),delete s[t],n.writeIndex(s));},readIndex(){return e()}}}function p(n){if(n==null||typeof n!="object")return JSON.stringify(n);if(Array.isArray(n))return `[${n.map(p).join(",")}]`;let o=n;return `{${Object.keys(o).sort().map(r=>`${JSON.stringify(r)}:${p(o[r])}`).join(",")}}`}function f(n,o){let e=o>>>0;for(let r=0;r<n.length;r++)e^=n.charCodeAt(r),e=Math.imul(e,16777619)>>>0;return e}function _(n){let o=p(n),e=f(o,2166136261),r=f(o,3735928559),t=f(o,19088743),s=f(o,4277009102);return [e,r,t,s].map(i=>i.toString(16).padStart(8,"0")).join("")}function A(n){function o(e){return `${n}:kv:${e}`}return {read(e){let r=globalThis.localStorage.getItem(o(e));if(r===null)return null;try{return JSON.parse(r)}catch{return null}},write(e,r){globalThis.localStorage.setItem(o(e),JSON.stringify(r));},delete(e){globalThis.localStorage.removeItem(o(e));},listKeys(e){let r=o(e??""),t=[];for(let s=0;s<globalThis.localStorage.length;s++){let i=globalThis.localStorage.key(s);i!==null&&i.startsWith(r)&&t.push(i.slice(o("").length));}return t}}}function h(n,o){let e={...n};for(let[r,t]of Object.entries(o))t!==null&&typeof t=="object"&&!Array.isArray(t)&&e[r]!==null&&typeof e[r]=="object"&&!Array.isArray(e[r])?e[r]=h(e[r],t):e[r]=t;return e}function S(n,o,e){if(o.length===0)return n;let[r,...t]=o;if(t.length===0)return {...n,[r]:e};let s=n[r]!==null&&typeof n[r]=="object"&&!Array.isArray(n[r])?n[r]:{};return {...n,[r]:S(s,t,e)}}function E(n){let o=A(n);return {read:e=>o.read(e),get(e,r){let t=o.read(e);if(t===null)return null;let s=t;for(let i of r.split(".").filter(Boolean)){if(s===null||typeof s!="object"||Array.isArray(s))return null;s=s[i]??null;}return s??null},write:(e,r)=>o.write(e,r),delete:e=>o.delete(e),listKeys:e=>o.listKeys(e),shallowMerge(e,r){let t=o.read(e)??{};o.write(e,{...t,...r});},deepMerge(e,r){let t=o.read(e)??{};o.write(e,h(t,r));},patch(e,r,t){let s=o.read(e)??{},i=r.split(".").filter(Boolean);o.write(e,S(s,i,t));}}}function k(n){let o=E(n);return {readIndex(){return o.read("_index")},writeIndex(e){o.write("_index",e);},readCard(e){return o.read(e)},writeCard(e,r){return o.write(e,r),_(r)},removeCard(e){o.delete(e);},cardExists(e){return o.read(e)!==null},defaultCardKey(e){return e}}}function ke(n){let o=k(n),e=y(o);return {getCard(r){return e.readCard(r)},getAllCards(){return e.readAllCards()},upsertCard(r){let t=o.defaultCardKey(r.id);e.writeCard(r.id,r,t);},removeCard(r){e.removeCard(r);}}}export{ke as createBrowserCardStoreApi};//# sourceMappingURL=card-store-browser-api.js.map
2
2
  //# sourceMappingURL=card-store-browser-api.js.map
@@ -1,12 +1,12 @@
1
1
  import{createRequire}from"module";const require=createRequire(import.meta.url);
2
- var vt=Object.create;var De=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty;var $=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Et=(e,t,r,u)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _t(t))!Tt.call(e,n)&&n!==r&&De(e,n,{get:()=>t[n],enumerable:!(u=gt(t,n))||u.enumerable});return e};var Ot=(e,t,r)=>(r=e!=null?vt(xt(e)):{},Et(t||!e||!e.__esModule?De(r,"default",{value:e,enumerable:!0}):r,e));var Ae=P((yr,Me)=>{var q=$("constants"),kt=process.cwd,ie=null,bt=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ie||(ie=kt.call(process)),ie};try{process.cwd()}catch{}typeof process.chdir=="function"&&(me=process.chdir,process.chdir=function(e){ie=null,me.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,me));var me;Me.exports=Ft;function Ft(e){q.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=u(e.chmod),e.fchmod=u(e.fchmod),e.lchmod=u(e.lchmod),e.chownSync=a(e.chownSync),e.fchownSync=a(e.fchownSync),e.lchownSync=a(e.lchownSync),e.chmodSync=n(e.chmodSync),e.fchmodSync=n(e.fchmodSync),e.lchmodSync=n(e.lchmodSync),e.stat=c(e.stat),e.fstat=c(e.fstat),e.lstat=c(e.lstat),e.statSync=d(e.statSync),e.fstatSync=d(e.fstatSync),e.lstatSync=d(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(o,s,l){l&&process.nextTick(l)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(o,s,l,f){f&&process.nextTick(f)},e.lchownSync=function(){}),bt==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(o){function s(l,f,p){var _=Date.now(),v=0;o(l,f,function E(R){if(R&&(R.code==="EACCES"||R.code==="EPERM"||R.code==="EBUSY")&&Date.now()-_<6e4){setTimeout(function(){e.stat(f,function(A,Z){A&&A.code==="ENOENT"?o(l,f,E):p(R)})},v),v<100&&(v+=10);return}p&&p(R)})}return Object.setPrototypeOf&&Object.setPrototypeOf(s,o),s})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(o){function s(l,f,p,_,v,E){var R;if(E&&typeof E=="function"){var A=0;R=function(Z,Le,Ne){if(Z&&Z.code==="EAGAIN"&&A<10)return A++,o.call(e,l,f,p,_,v,R);E.apply(this,arguments)}}return o.call(e,l,f,p,_,v,R)}return Object.setPrototypeOf&&Object.setPrototypeOf(s,o),s})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(o){return function(s,l,f,p,_){for(var v=0;;)try{return o.call(e,s,l,f,p,_)}catch(E){if(E.code==="EAGAIN"&&v<10){v++;continue}throw E}}})(e.readSync);function t(o){o.lchmod=function(s,l,f){o.open(s,q.O_WRONLY|q.O_SYMLINK,l,function(p,_){if(p){f&&f(p);return}o.fchmod(_,l,function(v){o.close(_,function(E){f&&f(v||E)})})})},o.lchmodSync=function(s,l){var f=o.openSync(s,q.O_WRONLY|q.O_SYMLINK,l),p=!0,_;try{_=o.fchmodSync(f,l),p=!1}finally{if(p)try{o.closeSync(f)}catch{}else o.closeSync(f)}return _}}function r(o){q.hasOwnProperty("O_SYMLINK")&&o.futimes?(o.lutimes=function(s,l,f,p){o.open(s,q.O_SYMLINK,function(_,v){if(_){p&&p(_);return}o.futimes(v,l,f,function(E){o.close(v,function(R){p&&p(E||R)})})})},o.lutimesSync=function(s,l,f){var p=o.openSync(s,q.O_SYMLINK),_,v=!0;try{_=o.futimesSync(p,l,f),v=!1}finally{if(v)try{o.closeSync(p)}catch{}else o.closeSync(p)}return _}):o.futimes&&(o.lutimes=function(s,l,f,p){p&&process.nextTick(p)},o.lutimesSync=function(){})}function u(o){return o&&function(s,l,f){return o.call(e,s,l,function(p){h(p)&&(p=null),f&&f.apply(this,arguments)})}}function n(o){return o&&function(s,l){try{return o.call(e,s,l)}catch(f){if(!h(f))throw f}}}function i(o){return o&&function(s,l,f,p){return o.call(e,s,l,f,function(_){h(_)&&(_=null),p&&p.apply(this,arguments)})}}function a(o){return o&&function(s,l,f){try{return o.call(e,s,l,f)}catch(p){if(!h(p))throw p}}}function c(o){return o&&function(s,l,f){typeof l=="function"&&(f=l,l=null);function p(_,v){v&&(v.uid<0&&(v.uid+=4294967296),v.gid<0&&(v.gid+=4294967296)),f&&f.apply(this,arguments)}return l?o.call(e,s,l,p):o.call(e,s,p)}}function d(o){return o&&function(s,l){var f=l?o.call(e,s,l):o.call(e,s);return f&&(f.uid<0&&(f.uid+=4294967296),f.gid<0&&(f.gid+=4294967296)),f}}function h(o){if(!o||o.code==="ENOSYS")return!0;var s=!process.getuid||process.getuid()!==0;return!!(s&&(o.code==="EINVAL"||o.code==="EPERM"))}}});var Ce=P((pr,Pe)=>{var Re=$("stream").Stream;Pe.exports=It;function It(e){return{ReadStream:t,WriteStream:r};function t(u,n){if(!(this instanceof t))return new t(u,n);Re.call(this);var i=this;this.path=u,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,n=n||{};for(var a=Object.keys(n),c=0,d=a.length;c<d;c++){var h=a[c];this[h]=n[h]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(o,s){if(o){i.emit("error",o),i.readable=!1;return}i.fd=s,i.emit("open",s),i._read()})}function r(u,n){if(!(this instanceof r))return new r(u,n);Re.call(this),this.path=u,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,n=n||{};for(var i=Object.keys(n),a=0,c=i.length;a<c;a++){var d=i[a];this[d]=n[d]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Ue=P((dr,je)=>{"use strict";je.exports=Nt;var Lt=Object.getPrototypeOf||function(e){return e.__proto__};function Nt(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:Lt(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var ge=P((hr,ve)=>{var k=$("fs"),Dt=Ae(),Mt=Ce(),At=Ue(),ue=$("util"),M,ae;typeof Symbol=="function"&&typeof Symbol.for=="function"?(M=Symbol.for("graceful-fs.queue"),ae=Symbol.for("graceful-fs.previous")):(M="___graceful-fs.queue",ae="___graceful-fs.previous");function Rt(){}function Be(e,t){Object.defineProperty(e,M,{get:function(){return t}})}var G=Rt;ue.debuglog?G=ue.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(G=function(){var e=ue.format.apply(ue,arguments);e="GFS4: "+e.split(/\n/).join(`
3
- GFS4: `),console.error(e)});k[M]||($e=global[M]||[],Be(k,$e),k.close=(function(e){function t(r,u){return e.call(k,r,function(n){n||qe(),typeof u=="function"&&u.apply(this,arguments)})}return Object.defineProperty(t,ae,{value:e}),t})(k.close),k.closeSync=(function(e){function t(r){e.apply(k,arguments),qe()}return Object.defineProperty(t,ae,{value:e}),t})(k.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){G(k[M]),$("assert").equal(k[M].length,0)}));var $e;global[M]||Be(global,k[M]);ve.exports=Se(At(k));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!k.__patched&&(ve.exports=Se(k),k.__patched=!0);function Se(e){Dt(e),e.gracefulify=Se,e.createReadStream=Le,e.createWriteStream=Ne;var t=e.readFile;e.readFile=r;function r(y,S,m){return typeof S=="function"&&(m=S,S=null),L(y,S,m);function L(N,F,O,b){return t(N,F,function(g){g&&(g.code==="EMFILE"||g.code==="ENFILE")?J([L,[N,F,O],g,b||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var u=e.writeFile;e.writeFile=n;function n(y,S,m,L){return typeof m=="function"&&(L=m,m=null),N(y,S,m,L);function N(F,O,b,g,D){return u(F,O,b,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?J([N,[F,O,b,g],x,D||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var i=e.appendFile;i&&(e.appendFile=a);function a(y,S,m,L){return typeof m=="function"&&(L=m,m=null),N(y,S,m,L);function N(F,O,b,g,D){return i(F,O,b,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?J([N,[F,O,b,g],x,D||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var c=e.copyFile;c&&(e.copyFile=d);function d(y,S,m,L){return typeof m=="function"&&(L=m,m=0),N(y,S,m,L);function N(F,O,b,g,D){return c(F,O,b,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?J([N,[F,O,b,g],x,D||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var h=e.readdir;e.readdir=s;var o=/^v[0-5]\./;function s(y,S,m){typeof S=="function"&&(m=S,S=null);var L=o.test(process.version)?function(O,b,g,D){return h(O,N(O,b,g,D))}:function(O,b,g,D){return h(O,b,N(O,b,g,D))};return L(y,S,m);function N(F,O,b,g){return function(D,x){D&&(D.code==="EMFILE"||D.code==="ENFILE")?J([L,[F,O,b],D,g||Date.now(),Date.now()]):(x&&x.sort&&x.sort(),typeof b=="function"&&b.call(this,D,x))}}}if(process.version.substr(0,4)==="v0.8"){var l=Mt(e);E=l.ReadStream,A=l.WriteStream}var f=e.ReadStream;f&&(E.prototype=Object.create(f.prototype),E.prototype.open=R);var p=e.WriteStream;p&&(A.prototype=Object.create(p.prototype),A.prototype.open=Z),Object.defineProperty(e,"ReadStream",{get:function(){return E},set:function(y){E=y},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return A},set:function(y){A=y},enumerable:!0,configurable:!0});var _=E;Object.defineProperty(e,"FileReadStream",{get:function(){return _},set:function(y){_=y},enumerable:!0,configurable:!0});var v=A;Object.defineProperty(e,"FileWriteStream",{get:function(){return v},set:function(y){v=y},enumerable:!0,configurable:!0});function E(y,S){return this instanceof E?(f.apply(this,arguments),this):E.apply(Object.create(E.prototype),arguments)}function R(){var y=this;he(y.path,y.flags,y.mode,function(S,m){S?(y.autoClose&&y.destroy(),y.emit("error",S)):(y.fd=m,y.emit("open",m),y.read())})}function A(y,S){return this instanceof A?(p.apply(this,arguments),this):A.apply(Object.create(A.prototype),arguments)}function Z(){var y=this;he(y.path,y.flags,y.mode,function(S,m){S?(y.destroy(),y.emit("error",S)):(y.fd=m,y.emit("open",m))})}function Le(y,S){return new e.ReadStream(y,S)}function Ne(y,S){return new e.WriteStream(y,S)}var wt=e.open;e.open=he;function he(y,S,m,L){return typeof m=="function"&&(L=m,m=null),N(y,S,m,L);function N(F,O,b,g,D){return wt(F,O,b,function(x,sr){x&&(x.code==="EMFILE"||x.code==="ENFILE")?J([N,[F,O,b,g],x,D||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}return e}function J(e){G("ENQUEUE",e[0].name,e[1]),k[M].push(e),we()}var oe;function qe(){for(var e=Date.now(),t=0;t<k[M].length;++t)k[M][t].length>2&&(k[M][t][3]=e,k[M][t][4]=e);we()}function we(){if(clearTimeout(oe),oe=void 0,k[M].length!==0){var e=k[M].shift(),t=e[0],r=e[1],u=e[2],n=e[3],i=e[4];if(n===void 0)G("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-n>=6e4){G("TIMEOUT",t.name,r);var a=r.pop();typeof a=="function"&&a.call(null,u)}else{var c=Date.now()-i,d=Math.max(i-n,1),h=Math.min(d*1.2,100);c>=h?(G("RETRY",t.name,r),t.apply(null,r.concat([n]))):k[M].push(e)}oe===void 0&&(oe=setTimeout(we,0))}}});var We=P((mr,Ge)=>{function C(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}Ge.exports=C;C.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};C.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};C.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var u=this,n=setTimeout(function(){u._attempts++,u._operationTimeoutCb&&(u._timeout=setTimeout(function(){u._operationTimeoutCb(u._attempts)},u._operationTimeout),u._options.unref&&u._timeout.unref()),u._fn(u._attempts)},r);return this._options.unref&&n.unref(),!0};C.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};C.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};C.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};C.prototype.start=C.prototype.try;C.prototype.errors=function(){return this._errors};C.prototype.attempts=function(){return this._attempts};C.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,u=0;u<this._errors.length;u++){var n=this._errors[u],i=n.message,a=(e[i]||0)+1;e[i]=a,a>=r&&(t=n,r=a)}return t}});var ze=P(W=>{var Pt=We();W.operation=function(e){var t=W.timeouts(e);return new Pt(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};W.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var u=[],n=0;n<t.retries;n++)u.push(this.createTimeout(n,t));return e&&e.forever&&!u.length&&u.push(this.createTimeout(n,t)),u.sort(function(i,a){return i-a}),u};W.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,u=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return u=Math.min(u,t.maxTimeout),u};W.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var u in e)typeof e[u]=="function"&&r.push(u)}for(var n=0;n<r.length;n++){var i=r[n],a=e[i];e[i]=function(d){var h=W.operation(t),o=Array.prototype.slice.call(arguments,1),s=o.pop();o.push(function(l){h.retry(l)||(l&&(arguments[0]=h.mainError()),s.apply(this,arguments))}),h.attempt(function(){d.apply(e,o)})}.bind(e,a),e[i].options=t}}});var Je=P((wr,Ye)=>{Ye.exports=ze()});var Ke=P((vr,ce)=>{ce.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&ce.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ce.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Ze=P((gr,H)=>{var T=global.process,z=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};z(T)?(Qe=$("assert"),K=Ke(),He=/^win/i.test(T.platform),ee=$("events"),typeof ee!="function"&&(ee=ee.EventEmitter),T.__signal_exit_emitter__?I=T.__signal_exit_emitter__:(I=T.__signal_exit_emitter__=new ee,I.count=0,I.emitted={}),I.infinite||(I.setMaxListeners(1/0),I.infinite=!0),H.exports=function(e,t){if(!z(global.process))return function(){};Qe.equal(typeof e,"function","a callback must be provided for exit handler"),Q===!1&&_e();var r="exit";t&&t.alwaysLast&&(r="afterexit");var u=function(){I.removeListener(r,e),I.listeners("exit").length===0&&I.listeners("afterexit").length===0&&fe()};return I.on(r,e),u},fe=function(){!Q||!z(global.process)||(Q=!1,K.forEach(function(t){try{T.removeListener(t,se[t])}catch{}}),T.emit=le,T.reallyExit=xe,I.count-=1)},H.exports.unload=fe,Y=function(t,r,u){I.emitted[t]||(I.emitted[t]=!0,I.emit(t,r,u))},se={},K.forEach(function(e){se[e]=function(){if(z(global.process)){var r=T.listeners(e);r.length===I.count&&(fe(),Y("exit",null,e),Y("afterexit",null,e),He&&e==="SIGHUP"&&(e="SIGINT"),T.kill(T.pid,e))}}}),H.exports.signals=function(){return K},Q=!1,_e=function(){Q||!z(global.process)||(Q=!0,I.count+=1,K=K.filter(function(t){try{return T.on(t,se[t]),!0}catch{return!1}}),T.emit=Xe,T.reallyExit=Ve)},H.exports.load=_e,xe=T.reallyExit,Ve=function(t){z(global.process)&&(T.exitCode=t||0,Y("exit",T.exitCode,null),Y("afterexit",T.exitCode,null),xe.call(T,T.exitCode))},le=T.emit,Xe=function(t,r){if(t==="exit"&&z(global.process)){r!==void 0&&(T.exitCode=r);var u=le.apply(this,arguments);return Y("exit",T.exitCode,null),Y("afterexit",T.exitCode,null),u}else return le.apply(this,arguments)}):H.exports=function(){return function(){}};var Qe,K,He,ee,I,fe,Y,se,Q,_e,xe,Ve,le,Xe});var tt=P((_r,Te)=>{"use strict";var et=Symbol();function Ct(e,t,r){let u=t[et];if(u)return t.stat(e,(i,a)=>{if(i)return r(i);r(null,a.mtime,u)});let n=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,n,n,i=>{if(i)return r(i);t.stat(e,(a,c)=>{if(a)return r(a);let d=c.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(t,et,{value:d}),r(null,c.mtime,d)})})}function jt(e){let t=Date.now();return e==="s"&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}Te.exports.probe=Ct;Te.exports.getMtime=jt});var ot=P((xr,re)=>{"use strict";var Ut=$("path"),ke=ge(),$t=Je(),qt=Ze(),rt=tt(),U={};function te(e,t){return t.lockfilePath||`${e}.lock`}function be(e,t,r){if(!t.realpath)return r(null,Ut.resolve(e));t.fs.realpath(e,r)}function Oe(e,t,r){let u=te(e,t);t.fs.mkdir(u,n=>{if(!n)return rt.probe(u,t.fs,(i,a,c)=>{if(i)return t.fs.rmdir(u,()=>{}),r(i);r(null,a,c)});if(n.code!=="EEXIST")return r(n);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));t.fs.stat(u,(i,a)=>{if(i)return i.code==="ENOENT"?Oe(e,{...t,stale:0},r):r(i);if(!nt(a,t))return r(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));it(e,t,c=>{if(c)return r(c);Oe(e,{...t,stale:0},r)})})})}function nt(e,t){return e.mtime.getTime()<Date.now()-t.stale}function it(e,t,r){t.fs.rmdir(te(e,t),u=>{if(u&&u.code!=="ENOENT")return r(u);r()})}function ye(e,t){let r=U[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{r.updateTimeout=null,t.fs.stat(r.lockfilePath,(u,n)=>{let i=r.lastUpdate+t.stale<Date.now();if(u)return u.code==="ENOENT"||i?Ee(e,r,Object.assign(u,{code:"ECOMPROMISED"})):(r.updateDelay=1e3,ye(e,t));if(!(r.mtime.getTime()===n.mtime.getTime()))return Ee(e,r,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let c=rt.getMtime(r.mtimePrecision);t.fs.utimes(r.lockfilePath,c,c,d=>{let h=r.lastUpdate+t.stale<Date.now();if(!r.released){if(d)return d.code==="ENOENT"||h?Ee(e,r,Object.assign(d,{code:"ECOMPROMISED"})):(r.updateDelay=1e3,ye(e,t));r.mtime=c,r.lastUpdate=Date.now(),r.updateDelay=null,ye(e,t)}})})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function Ee(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),U[e]===t&&delete U[e],t.options.onCompromised(r)}function Bt(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:ke,onCompromised:u=>{throw u},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),be(e,t,(u,n)=>{if(u)return r(u);let i=$t.operation(t.retries);i.attempt(()=>{Oe(n,t,(a,c,d)=>{if(i.retry(a))return;if(a)return r(i.mainError());let h=U[n]={lockfilePath:te(n,t),mtime:c,mtimePrecision:d,options:t,lastUpdate:Date.now()};ye(n,t),r(null,o=>{if(h.released)return o&&o(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));ut(n,{...t,realpath:!1},o)})})})})}function ut(e,t,r){t={fs:ke,realpath:!0,...t},be(e,t,(u,n)=>{if(u)return r(u);let i=U[n];if(!i)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete U[n],it(n,t,r)})}function Gt(e,t,r){t={stale:1e4,realpath:!0,fs:ke,...t},t.stale=Math.max(t.stale||0,2e3),be(e,t,(u,n)=>{if(u)return r(u);t.fs.stat(te(n,t),(i,a)=>i?i.code==="ENOENT"?r(null,!1):r(i):r(null,!nt(a,t)))})}function Wt(){return U}qt(()=>{for(let e in U){let t=U[e].options;try{t.fs.rmdirSync(te(e,t))}catch{}}});re.exports.lock=Bt;re.exports.unlock=ut;re.exports.check=Gt;re.exports.getLocks=Wt});var ct=P((Tr,at)=>{"use strict";var zt=ge();function Yt(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(u=>{r[u]=(...n)=>{let i=n.pop(),a;try{a=e[`${u}Sync`](...n)}catch(c){return i(c)}i(null,a)}}),r}function Jt(e){return(...t)=>new Promise((r,u)=>{t.push((n,i)=>{n?u(n):r(i)}),e(...t)})}function Kt(e){return(...t)=>{let r,u;if(t.push((n,i)=>{r=n,u=i}),e(...t),r)throw r;return u}}function Qt(e){if(e={...e},e.fs=Yt(e.fs||zt),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}at.exports={toPromise:Jt,toSync:Kt,toSyncOptions:Qt}});var st=P((Er,B)=>{"use strict";var V=ot(),{toPromise:pe,toSync:de,toSyncOptions:Fe}=ct();async function ft(e,t){let r=await pe(V.lock)(e,t);return pe(r)}function Ht(e,t){let r=de(V.lock)(e,Fe(t));return de(r)}function Vt(e,t){return pe(V.unlock)(e,t)}function Xt(e,t){return de(V.unlock)(e,Fe(t))}function Zt(e,t){return pe(V.check)(e,t)}function er(e,t){return de(V.check)(e,Fe(t))}B.exports=ft;B.exports.lock=ft;B.exports.unlock=Vt;B.exports.lockSync=Ht;B.exports.unlockSync=Xt;B.exports.check=Zt;B.exports.checkSync=er});var kr=Ot(st(),1);import*as w from"fs";import*as j from"path";import{randomUUID as lt}from"crypto";import*as St from"os";var Ie="b64:";function tr(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),r=globalThis.Buffer;if(r)return r.from(t,"base64").toString("utf8");if(typeof atob=="function"){let u=atob(t),n=new Uint8Array(u.length);for(let i=0;i<u.length;i+=1)n[i]=u.charCodeAt(i);return new TextDecoder().decode(n)}throw new Error("No base64 decoder available in this runtime")}function rr(e){if(!e.startsWith(Ie))throw new Error(`Invalid ref format (expected ${Ie}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(tr(e.slice(Ie.length)))}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return{kind:r.kind,value:r.value}}function yt(e,t){if(process.platform!=="win32"){w.renameSync(e,t);return}let r=[10,20,40,80,160];for(let u=0;u<=r.length;u++)try{w.renameSync(e,t);return}catch(n){let i=n.code;if((i==="EPERM"||i==="EBUSY")&&u<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[u]);continue}throw n}}function nr(e){function t(n){return j.join(e,...n.split("/"))}function r(n){return j.relative(e,n).replace(/\\/g,"/")}function u(n,i){if(w.existsSync(n))for(let a of w.readdirSync(n,{withFileTypes:!0})){let c=j.join(n,a.name);if(a.isDirectory()){u(c,i);continue}a.isFile()&&i.push(r(c))}}return{read(n){let i=t(n);if(!w.existsSync(i))return null;try{return w.readFileSync(i,"utf-8")}catch{return null}},write(n,i){let a=t(n),c=`${a}.${process.pid}.${lt()}.tmp`;w.mkdirSync(j.dirname(a),{recursive:!0}),w.writeFileSync(c,i,"utf-8"),yt(c,a)},exists(n){return w.existsSync(t(n))},remove(n){let i=t(n);try{w.existsSync(i)&&w.unlinkSync(i)}catch{}},readBytes(n){let i=t(n);if(!w.existsSync(i))return null;try{return new Uint8Array(w.readFileSync(i))}catch{return null}},writeBytes(n,i){let a=t(n),c=`${a}.${process.pid}.${lt()}.tmp`;w.mkdirSync(j.dirname(a),{recursive:!0}),w.writeFileSync(c,Buffer.from(i)),yt(c,a)},listKeys(n){let i=[];u(e,i);let a=i.sort();return n?a.filter(c=>c.startsWith(n)):a},stat(n){let i=t(n);if(!w.existsSync(i))return null;try{let a=w.statSync(i);return{key:n,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}},keyRef(n){return{kind:"fs-path",value:t(n)}}}}function pt(){return new Date().toISOString()}function dt(e){return new TextEncoder().encode(e).byteLength}function ir(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function ur(e){function t(r){let u=e.stat?ir(e.stat(r)):null;if(u)return u;if(!e.exists(r))return null;let n=e.read(r);return n===null?{key:r}:{key:r,size:dt(n)}}return{exists(r){return e.exists(r)},putText(r,u,n="text/plain; charset=utf-8"){e.write(r,u);let i=t(r)??{key:r};return i.contentType=n,i.updatedAt=i.updatedAt??pt(),i.size=i.size??dt(u),i},putBytes(r,u,n="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,u);else{let a=JSON.stringify({__kind:"bytes-array",data:[...u]});e.write(r,a)}let i=t(r)??{key:r};return i.contentType=n,i.updatedAt=i.updatedAt??pt(),i.size=i.size??u.byteLength,i},getText(r){let u=e.read(r);if(u===null){if(!e.readBytes)return null;let n=e.readBytes(r);return n===null?null:Buffer.from(n).toString("utf-8")}try{let n=JSON.parse(u);if(n&&n.__kind==="bytes-array"&&Array.isArray(n.data))return new TextDecoder("utf-8").decode(new Uint8Array(n.data))}catch{}return u},getBytes(r){if(e.readBytes){let n=e.readBytes(r);if(n!==null)return n}let u=e.read(r);if(u===null)return null;try{let n=JSON.parse(u);if(n&&n.__kind==="bytes-array"&&Array.isArray(n.data))return new Uint8Array(n.data)}catch{}return new TextEncoder().encode(u)},head:t,list(r=""){return e.listKeys(r).map(u=>t(u)??{key:u}).sort((u,n)=>u.key.localeCompare(n.key))},remove(r){e.remove(r)}}}function or(e){function t(n){return{status:"success",data:n}}function r(n){return{status:"fail",error:n}}function u(n){return{status:"error",error:n instanceof Error?n.message:String(n)}}return{list(n){try{let i=n.params?.prefix??"";return t({artifacts:e.list(i)})}catch(i){return u(i)}},head(n){try{let i=n.params?.key;return i?t({artifact:e.head(i)}):r("head requires params.key")}catch(i){return u(i)}},put(n){try{let i=n.params?.key,a=n.params?.contentType;if(!i)return r("put requires params.key");let c=n.body;if(typeof c=="string")return t({artifact:e.putText(i,c,a)});if(c&&typeof c=="object"&&typeof c.text=="string")return t({artifact:e.putText(i,c.text,a)});if(c&&typeof c=="object"&&Array.isArray(c.bytes)){let d=c.bytes,h=new Uint8Array(d.map(o=>Math.max(0,Math.min(255,Number(o)||0))));return t({artifact:e.putBytes(i,h,a)})}return r("put requires body as string, {text}, or {bytes:number[]}")}catch(i){return u(i)}},get(n){try{let i=n.params?.key,a=n.params?.as??"base64";if(!i)return r("get requires params.key");let c=e.head(i);if(!c)return r(`artifact "${i}" not found`);if(a==="text"){let h=e.getText(i);return h===null?r(`artifact "${i}" not found`):t({key:i,contentType:c.contentType,size:c.size,text:h})}let d=e.getBytes(i);return d===null?r(`artifact "${i}" not found`):t({key:i,contentType:c.contentType,size:c.size,bytes:[...d]})}catch(i){return u(i)}},del(n){try{let i=n.params?.key;return i?(e.remove(i),t({ok:!0})):r("del requires params.key")}catch(i){return u(i)}}}}function ht(...e){return j.resolve(...e)}j.join(St.tmpdir(),".board-live-cards-git-bash-cache.json");function ne(e,t,r){let u=e.indexOf(t),n=u!==-1?e[u+1]:void 0;if(!n)throw new Error(`Missing ${t}
4
- Usage: ${r}`);return n}function X(e,t){let r=e.indexOf(t);return r!==-1?e[r+1]:void 0}async function ar(){let e=[];for await(let t of process.stdin)e.push(Buffer.isBuffer(t)?t:Buffer.from(t));return new Uint8Array(Buffer.concat(e))}var mt=["artifacts-store \u2014 generic artifact CRUD on a blob-backed store",""," artifacts-store put --store-ref <ref> --key <key> [--file <path> | --text <text>] [--content-type <mime>]"," artifacts-store get --store-ref <ref> --key <key> [--out <path>] [--as text|bytes]"," artifacts-store head --store-ref <ref> --key <key>"," artifacts-store list --store-ref <ref> [--prefix <prefix>]"," artifacts-store del --store-ref <ref> --key <key>"].join(`
5
- `);async function cr(e){let t=e[0],r=e.slice(1);if(!t||t==="help"||t==="--help"||t==="-h"){console.error(mt);return}let u=ne(r,"--store-ref",`artifacts-store ${t} --store-ref <b64-ref>`),n=rr(u).value,i=or(ur(nr(n)));if(t==="put"){let a=ne(r,"--key","artifacts-store put --store-ref <ref> --key <key>"),c=X(r,"--content-type"),d=X(r,"--file"),h=X(r,"--text"),o;if(d)o={bytes:[...new Uint8Array(w.readFileSync(d))]};else if(typeof h=="string")o={text:h};else if(!process.stdin.isTTY)o={bytes:[...await ar()]};else throw new Error("put requires --file, --text, or stdin bytes");let s=i.put({params:{key:a,...c?{contentType:c}:{}},body:o});if(s.status!=="success")throw new Error(s.error||"put failed");process.stdout.write(JSON.stringify(s.data,null,2)+`
6
- `);return}if(t==="get"){let a=ne(r,"--key","artifacts-store get --store-ref <ref> --key <key>"),c=(X(r,"--as")||"bytes").toLowerCase(),d=X(r,"--out"),h=i.get({params:{key:a,as:c}});if(h.status!=="success")throw new Error(h.error||"get failed");if(c==="text"){let s=h.data.text??"";d?w.writeFileSync(d,s,"utf-8"):process.stdout.write(s);return}let o=new Uint8Array(h.data.bytes??[]);d?w.writeFileSync(d,Buffer.from(o)):process.stdout.write(JSON.stringify({...h.data,bytes:void 0,byteLength:o.byteLength},null,2)+`
7
- `);return}if(t==="head"){let a=ne(r,"--key","artifacts-store head --store-ref <ref> --key <key>"),c=i.head({params:{key:a}});if(c.status!=="success")throw new Error(c.error||"head failed");process.stdout.write(JSON.stringify(c.data,null,2)+`
8
- `);return}if(t==="list"){let a=X(r,"--prefix")||"",c=i.list({params:a?{prefix:a}:{}});if(c.status!=="success")throw new Error(c.error||"list failed");process.stdout.write(JSON.stringify(c.data,null,2)+`
9
- `);return}if(t==="del"||t==="delete"||t==="rm"){let a=ne(r,"--key","artifacts-store del --store-ref <ref> --key <key>"),c=i.del({params:{key:a}});if(c.status!=="success")throw new Error(c.error||"del failed");process.stdout.write(JSON.stringify(c.data,null,2)+`
2
+ var Et=Object.create;var Ce=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty;var $=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ft=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of kt(t))!It.call(e,n)&&n!==r&&Ce(e,n,{get:()=>t[n],enumerable:!(o=Ot(t,n))||o.enumerable});return e};var Nt=(e,t,r)=>(r=e!=null?Et(bt(e)):{},Ft(t||!e||!e.__esModule?Ce(r,"default",{value:e,enumerable:!0}):r,e));var Ue=P((dr,je)=>{var q=$("constants"),Rt=process.cwd,ae=null,Lt=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ae||(ae=Rt.call(process)),ae};try{process.cwd()}catch{}typeof process.chdir=="function"&&(ge=process.chdir,process.chdir=function(e){ae=null,ge.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ge));var ge;je.exports=Dt;function Dt(e){q.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||r(e),e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=o(e.chmod),e.fchmod=o(e.fchmod),e.lchmod=o(e.lchmod),e.chownSync=a(e.chownSync),e.fchownSync=a(e.fchownSync),e.lchownSync=a(e.lchownSync),e.chmodSync=n(e.chmodSync),e.fchmodSync=n(e.fchmodSync),e.lchmodSync=n(e.lchmodSync),e.stat=c(e.stat),e.fstat=c(e.fstat),e.lstat=c(e.lstat),e.statSync=d(e.statSync),e.fstatSync=d(e.fstatSync),e.lstatSync=d(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,s,l){l&&process.nextTick(l)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,s,l,f){f&&process.nextTick(f)},e.lchownSync=function(){}),Lt==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function s(l,f,p){var _=Date.now(),S=0;u(l,f,function E(A){if(A&&(A.code==="EACCES"||A.code==="EPERM"||A.code==="EBUSY")&&Date.now()-_<6e4){setTimeout(function(){e.stat(f,function(M,ee){M&&M.code==="ENOENT"?u(l,f,E):p(A)})},S),S<100&&(S+=10);return}p&&p(A)})}return Object.setPrototypeOf&&Object.setPrototypeOf(s,u),s})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function s(l,f,p,_,S,E){var A;if(E&&typeof E=="function"){var M=0;A=function(ee,Ae,Pe){if(ee&&ee.code==="EAGAIN"&&M<10)return M++,u.call(e,l,f,p,_,S,A);E.apply(this,arguments)}}return u.call(e,l,f,p,_,S,A)}return Object.setPrototypeOf&&Object.setPrototypeOf(s,u),s})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(s,l,f,p,_){for(var S=0;;)try{return u.call(e,s,l,f,p,_)}catch(E){if(E.code==="EAGAIN"&&S<10){S++;continue}throw E}}})(e.readSync);function t(u){u.lchmod=function(s,l,f){u.open(s,q.O_WRONLY|q.O_SYMLINK,l,function(p,_){if(p){f&&f(p);return}u.fchmod(_,l,function(S){u.close(_,function(E){f&&f(S||E)})})})},u.lchmodSync=function(s,l){var f=u.openSync(s,q.O_WRONLY|q.O_SYMLINK,l),p=!0,_;try{_=u.fchmodSync(f,l),p=!1}finally{if(p)try{u.closeSync(f)}catch{}else u.closeSync(f)}return _}}function r(u){q.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(s,l,f,p){u.open(s,q.O_SYMLINK,function(_,S){if(_){p&&p(_);return}u.futimes(S,l,f,function(E){u.close(S,function(A){p&&p(E||A)})})})},u.lutimesSync=function(s,l,f){var p=u.openSync(s,q.O_SYMLINK),_,S=!0;try{_=u.futimesSync(p,l,f),S=!1}finally{if(S)try{u.closeSync(p)}catch{}else u.closeSync(p)}return _}):u.futimes&&(u.lutimes=function(s,l,f,p){p&&process.nextTick(p)},u.lutimesSync=function(){})}function o(u){return u&&function(s,l,f){return u.call(e,s,l,function(p){h(p)&&(p=null),f&&f.apply(this,arguments)})}}function n(u){return u&&function(s,l){try{return u.call(e,s,l)}catch(f){if(!h(f))throw f}}}function i(u){return u&&function(s,l,f,p){return u.call(e,s,l,f,function(_){h(_)&&(_=null),p&&p.apply(this,arguments)})}}function a(u){return u&&function(s,l,f){try{return u.call(e,s,l,f)}catch(p){if(!h(p))throw p}}}function c(u){return u&&function(s,l,f){typeof l=="function"&&(f=l,l=null);function p(_,S){S&&(S.uid<0&&(S.uid+=4294967296),S.gid<0&&(S.gid+=4294967296)),f&&f.apply(this,arguments)}return l?u.call(e,s,l,p):u.call(e,s,p)}}function d(u){return u&&function(s,l){var f=l?u.call(e,s,l):u.call(e,s);return f&&(f.uid<0&&(f.uid+=4294967296),f.gid<0&&(f.gid+=4294967296)),f}}function h(u){if(!u||u.code==="ENOSYS")return!0;var s=!process.getuid||process.getuid()!==0;return!!(s&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var Be=P((hr,qe)=>{var $e=$("stream").Stream;qe.exports=Mt;function Mt(e){return{ReadStream:t,WriteStream:r};function t(o,n){if(!(this instanceof t))return new t(o,n);$e.call(this);var i=this;this.path=o,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,n=n||{};for(var a=Object.keys(n),c=0,d=a.length;c<d;c++){var h=a[c];this[h]=n[h]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(u,s){if(u){i.emit("error",u),i.readable=!1;return}i.fd=s,i.emit("open",s),i._read()})}function r(o,n){if(!(this instanceof r))return new r(o,n);$e.call(this),this.path=o,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,n=n||{};for(var i=Object.keys(n),a=0,c=i.length;a<c;a++){var d=i[a];this[d]=n[d]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var We=P((mr,Ge)=>{"use strict";Ge.exports=Pt;var At=Object.getPrototypeOf||function(e){return e.__proto__};function Pt(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:At(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var Ee=P((vr,Te)=>{var k=$("fs"),Ct=Ue(),jt=Be(),Ut=We(),ce=$("util"),D,se;typeof Symbol=="function"&&typeof Symbol.for=="function"?(D=Symbol.for("graceful-fs.queue"),se=Symbol.for("graceful-fs.previous")):(D="___graceful-fs.queue",se="___graceful-fs.previous");function $t(){}function Je(e,t){Object.defineProperty(e,D,{get:function(){return t}})}var G=$t;ce.debuglog?G=ce.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(G=function(){var e=ce.format.apply(ce,arguments);e="GFS4: "+e.split(/\n/).join(`
3
+ GFS4: `),console.error(e)});k[D]||(ze=global[D]||[],Je(k,ze),k.close=(function(e){function t(r,o){return e.call(k,r,function(n){n||Ye(),typeof o=="function"&&o.apply(this,arguments)})}return Object.defineProperty(t,se,{value:e}),t})(k.close),k.closeSync=(function(e){function t(r){e.apply(k,arguments),Ye()}return Object.defineProperty(t,se,{value:e}),t})(k.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){G(k[D]),$("assert").equal(k[D].length,0)}));var ze;global[D]||Je(global,k[D]);Te.exports=_e(Ut(k));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!k.__patched&&(Te.exports=_e(k),k.__patched=!0);function _e(e){Ct(e),e.gracefulify=_e,e.createReadStream=Ae,e.createWriteStream=Pe;var t=e.readFile;e.readFile=r;function r(y,v,m){return typeof v=="function"&&(m=v,v=null),N(y,v,m);function N(R,I,O,b){return t(R,I,function(g){g&&(g.code==="EMFILE"||g.code==="ENFILE")?K([N,[R,I,O],g,b||Date.now(),Date.now()]):typeof O=="function"&&O.apply(this,arguments)})}}var o=e.writeFile;e.writeFile=n;function n(y,v,m,N){return typeof m=="function"&&(N=m,m=null),R(y,v,m,N);function R(I,O,b,g,L){return o(I,O,b,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?K([R,[I,O,b,g],x,L||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var i=e.appendFile;i&&(e.appendFile=a);function a(y,v,m,N){return typeof m=="function"&&(N=m,m=null),R(y,v,m,N);function R(I,O,b,g,L){return i(I,O,b,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?K([R,[I,O,b,g],x,L||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var c=e.copyFile;c&&(e.copyFile=d);function d(y,v,m,N){return typeof m=="function"&&(N=m,m=0),R(y,v,m,N);function R(I,O,b,g,L){return c(I,O,b,function(x){x&&(x.code==="EMFILE"||x.code==="ENFILE")?K([R,[I,O,b,g],x,L||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}var h=e.readdir;e.readdir=s;var u=/^v[0-5]\./;function s(y,v,m){typeof v=="function"&&(m=v,v=null);var N=u.test(process.version)?function(O,b,g,L){return h(O,R(O,b,g,L))}:function(O,b,g,L){return h(O,b,R(O,b,g,L))};return N(y,v,m);function R(I,O,b,g){return function(L,x){L&&(L.code==="EMFILE"||L.code==="ENFILE")?K([N,[I,O,b],L,g||Date.now(),Date.now()]):(x&&x.sort&&x.sort(),typeof b=="function"&&b.call(this,L,x))}}}if(process.version.substr(0,4)==="v0.8"){var l=jt(e);E=l.ReadStream,M=l.WriteStream}var f=e.ReadStream;f&&(E.prototype=Object.create(f.prototype),E.prototype.open=A);var p=e.WriteStream;p&&(M.prototype=Object.create(p.prototype),M.prototype.open=ee),Object.defineProperty(e,"ReadStream",{get:function(){return E},set:function(y){E=y},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return M},set:function(y){M=y},enumerable:!0,configurable:!0});var _=E;Object.defineProperty(e,"FileReadStream",{get:function(){return _},set:function(y){_=y},enumerable:!0,configurable:!0});var S=M;Object.defineProperty(e,"FileWriteStream",{get:function(){return S},set:function(y){S=y},enumerable:!0,configurable:!0});function E(y,v){return this instanceof E?(f.apply(this,arguments),this):E.apply(Object.create(E.prototype),arguments)}function A(){var y=this;Se(y.path,y.flags,y.mode,function(v,m){v?(y.autoClose&&y.destroy(),y.emit("error",v)):(y.fd=m,y.emit("open",m),y.read())})}function M(y,v){return this instanceof M?(p.apply(this,arguments),this):M.apply(Object.create(M.prototype),arguments)}function ee(){var y=this;Se(y.path,y.flags,y.mode,function(v,m){v?(y.destroy(),y.emit("error",v)):(y.fd=m,y.emit("open",m))})}function Ae(y,v){return new e.ReadStream(y,v)}function Pe(y,v){return new e.WriteStream(y,v)}var Tt=e.open;e.open=Se;function Se(y,v,m,N){return typeof m=="function"&&(N=m,m=null),R(y,v,m,N);function R(I,O,b,g,L){return Tt(I,O,b,function(x,yr){x&&(x.code==="EMFILE"||x.code==="ENFILE")?K([R,[I,O,b,g],x,L||Date.now(),Date.now()]):typeof g=="function"&&g.apply(this,arguments)})}}return e}function K(e){G("ENQUEUE",e[0].name,e[1]),k[D].push(e),xe()}var fe;function Ye(){for(var e=Date.now(),t=0;t<k[D].length;++t)k[D][t].length>2&&(k[D][t][3]=e,k[D][t][4]=e);xe()}function xe(){if(clearTimeout(fe),fe=void 0,k[D].length!==0){var e=k[D].shift(),t=e[0],r=e[1],o=e[2],n=e[3],i=e[4];if(n===void 0)G("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-n>=6e4){G("TIMEOUT",t.name,r);var a=r.pop();typeof a=="function"&&a.call(null,o)}else{var c=Date.now()-i,d=Math.max(i-n,1),h=Math.min(d*1.2,100);c>=h?(G("RETRY",t.name,r),t.apply(null,r.concat([n]))):k[D].push(e)}fe===void 0&&(fe=setTimeout(xe,0))}}});var Qe=P((wr,Ke)=>{function C(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}Ke.exports=C;C.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};C.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};C.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();else return!1;var o=this,n=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},r);return this._options.unref&&n.unref(),!0};C.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};C.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};C.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};C.prototype.start=C.prototype.try;C.prototype.errors=function(){return this._errors};C.prototype.attempts=function(){return this._attempts};C.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,r=0,o=0;o<this._errors.length;o++){var n=this._errors[o],i=n.message,a=(e[i]||0)+1;e[i]=a,a>=r&&(t=n,r=a)}return t}});var He=P(W=>{var qt=Qe();W.operation=function(e){var t=W.timeouts(e);return new qt(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};W.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in e)t[r]=e[r];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],n=0;n<t.retries;n++)o.push(this.createTimeout(n,t));return e&&e.forever&&!o.length&&o.push(this.createTimeout(n,t)),o.sort(function(i,a){return i-a}),o};W.createTimeout=function(e,t){var r=t.randomize?Math.random()+1:1,o=Math.round(r*t.minTimeout*Math.pow(t.factor,e));return o=Math.min(o,t.maxTimeout),o};W.wrap=function(e,t,r){if(t instanceof Array&&(r=t,t=null),!r){r=[];for(var o in e)typeof e[o]=="function"&&r.push(o)}for(var n=0;n<r.length;n++){var i=r[n],a=e[i];e[i]=function(d){var h=W.operation(t),u=Array.prototype.slice.call(arguments,1),s=u.pop();u.push(function(l){h.retry(l)||(l&&(arguments[0]=h.mainError()),s.apply(this,arguments))}),h.attempt(function(){d.apply(e,u)})}.bind(e,a),e[i].options=t}}});var Xe=P((gr,Ve)=>{Ve.exports=He()});var Ze=P((_r,le)=>{le.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&le.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&le.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var it=P((xr,V)=>{var T=global.process,z=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};z(T)?(et=$("assert"),Q=Ze(),tt=/^win/i.test(T.platform),te=$("events"),typeof te!="function"&&(te=te.EventEmitter),T.__signal_exit_emitter__?F=T.__signal_exit_emitter__:(F=T.__signal_exit_emitter__=new te,F.count=0,F.emitted={}),F.infinite||(F.setMaxListeners(1/0),F.infinite=!0),V.exports=function(e,t){if(!z(global.process))return function(){};et.equal(typeof e,"function","a callback must be provided for exit handler"),H===!1&&Oe();var r="exit";t&&t.alwaysLast&&(r="afterexit");var o=function(){F.removeListener(r,e),F.listeners("exit").length===0&&F.listeners("afterexit").length===0&&ye()};return F.on(r,e),o},ye=function(){!H||!z(global.process)||(H=!1,Q.forEach(function(t){try{T.removeListener(t,pe[t])}catch{}}),T.emit=de,T.reallyExit=ke,F.count-=1)},V.exports.unload=ye,Y=function(t,r,o){F.emitted[t]||(F.emitted[t]=!0,F.emit(t,r,o))},pe={},Q.forEach(function(e){pe[e]=function(){if(z(global.process)){var r=T.listeners(e);r.length===F.count&&(ye(),Y("exit",null,e),Y("afterexit",null,e),tt&&e==="SIGHUP"&&(e="SIGINT"),T.kill(T.pid,e))}}}),V.exports.signals=function(){return Q},H=!1,Oe=function(){H||!z(global.process)||(H=!0,F.count+=1,Q=Q.filter(function(t){try{return T.on(t,pe[t]),!0}catch{return!1}}),T.emit=nt,T.reallyExit=rt)},V.exports.load=Oe,ke=T.reallyExit,rt=function(t){z(global.process)&&(T.exitCode=t||0,Y("exit",T.exitCode,null),Y("afterexit",T.exitCode,null),ke.call(T,T.exitCode))},de=T.emit,nt=function(t,r){if(t==="exit"&&z(global.process)){r!==void 0&&(T.exitCode=r);var o=de.apply(this,arguments);return Y("exit",T.exitCode,null),Y("afterexit",T.exitCode,null),o}else return de.apply(this,arguments)}):V.exports=function(){return function(){}};var et,Q,tt,te,F,ye,Y,pe,H,Oe,ke,rt,de,nt});var ut=P((Tr,be)=>{"use strict";var ot=Symbol();function Bt(e,t,r){let o=t[ot];if(o)return t.stat(e,(i,a)=>{if(i)return r(i);r(null,a.mtime,o)});let n=new Date(Math.ceil(Date.now()/1e3)*1e3+5);t.utimes(e,n,n,i=>{if(i)return r(i);t.stat(e,(a,c)=>{if(a)return r(a);let d=c.mtime.getTime()%1e3===0?"s":"ms";Object.defineProperty(t,ot,{value:d}),r(null,c.mtime,d)})})}function Gt(e){let t=Date.now();return e==="s"&&(t=Math.ceil(t/1e3)*1e3),new Date(t)}be.exports.probe=Bt;be.exports.getMtime=Gt});var lt=P((Er,ne)=>{"use strict";var Wt=$("path"),Ne=Ee(),zt=Xe(),Yt=it(),at=ut(),U={};function re(e,t){return t.lockfilePath||`${e}.lock`}function Re(e,t,r){if(!t.realpath)return r(null,Wt.resolve(e));t.fs.realpath(e,r)}function Fe(e,t,r){let o=re(e,t);t.fs.mkdir(o,n=>{if(!n)return at.probe(o,t.fs,(i,a,c)=>{if(i)return t.fs.rmdir(o,()=>{}),r(i);r(null,a,c)});if(n.code!=="EEXIST")return r(n);if(t.stale<=0)return r(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));t.fs.stat(o,(i,a)=>{if(i)return i.code==="ENOENT"?Fe(e,{...t,stale:0},r):r(i);if(!ct(a,t))return r(Object.assign(new Error("Lock file is already being held"),{code:"ELOCKED",file:e}));ft(e,t,c=>{if(c)return r(c);Fe(e,{...t,stale:0},r)})})})}function ct(e,t){return e.mtime.getTime()<Date.now()-t.stale}function ft(e,t,r){t.fs.rmdir(re(e,t),o=>{if(o&&o.code!=="ENOENT")return r(o);r()})}function he(e,t){let r=U[e];r.updateTimeout||(r.updateDelay=r.updateDelay||t.update,r.updateTimeout=setTimeout(()=>{r.updateTimeout=null,t.fs.stat(r.lockfilePath,(o,n)=>{let i=r.lastUpdate+t.stale<Date.now();if(o)return o.code==="ENOENT"||i?Ie(e,r,Object.assign(o,{code:"ECOMPROMISED"})):(r.updateDelay=1e3,he(e,t));if(!(r.mtime.getTime()===n.mtime.getTime()))return Ie(e,r,Object.assign(new Error("Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"}));let c=at.getMtime(r.mtimePrecision);t.fs.utimes(r.lockfilePath,c,c,d=>{let h=r.lastUpdate+t.stale<Date.now();if(!r.released){if(d)return d.code==="ENOENT"||h?Ie(e,r,Object.assign(d,{code:"ECOMPROMISED"})):(r.updateDelay=1e3,he(e,t));r.mtime=c,r.lastUpdate=Date.now(),r.updateDelay=null,he(e,t)}})})},r.updateDelay),r.updateTimeout.unref&&r.updateTimeout.unref())}function Ie(e,t,r){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),U[e]===t&&delete U[e],t.options.onCompromised(r)}function Jt(e,t,r){t={stale:1e4,update:null,realpath:!0,retries:0,fs:Ne,onCompromised:o=>{throw o},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),Re(e,t,(o,n)=>{if(o)return r(o);let i=zt.operation(t.retries);i.attempt(()=>{Fe(n,t,(a,c,d)=>{if(i.retry(a))return;if(a)return r(i.mainError());let h=U[n]={lockfilePath:re(n,t),mtime:c,mtimePrecision:d,options:t,lastUpdate:Date.now()};he(n,t),r(null,u=>{if(h.released)return u&&u(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));st(n,{...t,realpath:!1},u)})})})})}function st(e,t,r){t={fs:Ne,realpath:!0,...t},Re(e,t,(o,n)=>{if(o)return r(o);let i=U[n];if(!i)return r(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));i.updateTimeout&&clearTimeout(i.updateTimeout),i.released=!0,delete U[n],ft(n,t,r)})}function Kt(e,t,r){t={stale:1e4,realpath:!0,fs:Ne,...t},t.stale=Math.max(t.stale||0,2e3),Re(e,t,(o,n)=>{if(o)return r(o);t.fs.stat(re(n,t),(i,a)=>i?i.code==="ENOENT"?r(null,!1):r(i):r(null,!ct(a,t)))})}function Qt(){return U}Yt(()=>{for(let e in U){let t=U[e].options;try{t.fs.rmdirSync(re(e,t))}catch{}}});ne.exports.lock=Jt;ne.exports.unlock=st;ne.exports.check=Kt;ne.exports.getLocks=Qt});var pt=P((Or,yt)=>{"use strict";var Ht=Ee();function Vt(e){let t=["mkdir","realpath","stat","rmdir","utimes"],r={...e};return t.forEach(o=>{r[o]=(...n)=>{let i=n.pop(),a;try{a=e[`${o}Sync`](...n)}catch(c){return i(c)}i(null,a)}}),r}function Xt(e){return(...t)=>new Promise((r,o)=>{t.push((n,i)=>{n?o(n):r(i)}),e(...t)})}function Zt(e){return(...t)=>{let r,o;if(t.push((n,i)=>{r=n,o=i}),e(...t),r)throw r;return o}}function er(e){if(e={...e},e.fs=Vt(e.fs||Ht),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}yt.exports={toPromise:Xt,toSync:Zt,toSyncOptions:er}});var ht=P((kr,B)=>{"use strict";var X=lt(),{toPromise:me,toSync:ve,toSyncOptions:Le}=pt();async function dt(e,t){let r=await me(X.lock)(e,t);return me(r)}function tr(e,t){let r=ve(X.lock)(e,Le(t));return ve(r)}function rr(e,t){return me(X.unlock)(e,t)}function nr(e,t){return ve(X.unlock)(e,Le(t))}function ir(e,t){return me(X.check)(e,t)}function or(e,t){return ve(X.check)(e,Le(t))}B.exports=dt;B.exports.lock=dt;B.exports.unlock=rr;B.exports.lockSync=tr;B.exports.unlockSync=nr;B.exports.check=ir;B.exports.checkSync=or});var Ir=Nt(ht(),1);import*as w from"fs";import*as j from"path";import{randomUUID as mt}from"crypto";import*as xt from"os";var De="b64:";function ur(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4),r=globalThis.Buffer;if(r)return r.from(t,"base64").toString("utf8");if(typeof atob=="function"){let o=atob(t),n=new Uint8Array(o.length);for(let i=0;i<o.length;i+=1)n[i]=o.charCodeAt(i);return new TextDecoder().decode(n)}throw new Error("No base64 decoder available in this runtime")}function Z(e){if(!e.startsWith(De))throw new Error(`Invalid ref format (expected ${De}<base64url(json)>): ${e}`);let t;try{t=JSON.parse(ur(e.slice(De.length)))}catch{throw new Error(`Invalid ref format (malformed base64url/json): ${e}`)}if(!t||typeof t!="object")throw new Error(`Invalid ref format (expected object payload): ${e}`);let r=t;if(typeof r.kind!="string"||typeof r.value!="string")throw new Error(`Invalid ref format (payload must contain string kind/value): ${e}`);return{kind:r.kind,value:r.value}}function ar(e){let t=Z(e);if(t.kind!=="artifacts-store-entry")throw new Error(`Invalid artifact entry ref kind: ${t.kind}`);let r;try{r=JSON.parse(t.value)}catch{throw new Error(`Invalid artifact entry ref payload: ${e}`)}if(!r||typeof r!="object")throw new Error(`Invalid artifact entry ref payload: ${e}`);let o=r;if(typeof o.storeRef!="string"||typeof o.key!="string")throw new Error(`Invalid artifact entry ref payload: ${e}`);return{storeRef:o.storeRef,key:o.key}}function vt(e,t){if(process.platform!=="win32"){w.renameSync(e,t);return}let r=[10,20,40,80,160];for(let o=0;o<=r.length;o++)try{w.renameSync(e,t);return}catch(n){let i=n.code;if((i==="EPERM"||i==="EBUSY")&&o<r.length){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r[o]);continue}throw n}}function ie(e){function t(n){return j.join(e,...n.split("/"))}function r(n){return j.relative(e,n).replace(/\\/g,"/")}function o(n,i){if(w.existsSync(n))for(let a of w.readdirSync(n,{withFileTypes:!0})){let c=j.join(n,a.name);if(a.isDirectory()){o(c,i);continue}a.isFile()&&i.push(r(c))}}return{read(n){let i=t(n);if(!w.existsSync(i))return null;try{return w.readFileSync(i,"utf-8")}catch{return null}},write(n,i){let a=t(n),c=`${a}.${process.pid}.${mt()}.tmp`;w.mkdirSync(j.dirname(a),{recursive:!0}),w.writeFileSync(c,i,"utf-8"),vt(c,a)},exists(n){return w.existsSync(t(n))},remove(n){let i=t(n);try{w.existsSync(i)&&w.unlinkSync(i)}catch{}},readBytes(n){let i=t(n);if(!w.existsSync(i))return null;try{return new Uint8Array(w.readFileSync(i))}catch{return null}},writeBytes(n,i){let a=t(n),c=`${a}.${process.pid}.${mt()}.tmp`;w.mkdirSync(j.dirname(a),{recursive:!0}),w.writeFileSync(c,Buffer.from(i)),vt(c,a)},listKeys(n){let i=[];o(e,i);let a=i.sort();return n?a.filter(c=>c.startsWith(n)):a},stat(n){let i=t(n);if(!w.existsSync(i))return null;try{let a=w.statSync(i);return{key:n,size:Number(a.size||0),updatedAt:new Date(a.mtimeMs).toISOString()}}catch{return null}},keyRef(n){return{kind:"fs-path",value:t(n)}}}}function wt(){return new Date().toISOString()}function St(e){return new TextEncoder().encode(e).byteLength}function cr(e){return e?{key:e.key,size:e.size,updatedAt:e.updatedAt,contentType:e.contentType}:null}function oe(e){function t(r){let o=e.stat?cr(e.stat(r)):null;if(o)return o;if(!e.exists(r))return null;let n=e.read(r);return n===null?{key:r}:{key:r,size:St(n)}}return{exists(r){return e.exists(r)},putText(r,o,n="text/plain; charset=utf-8"){e.write(r,o);let i=t(r)??{key:r};return i.contentType=n,i.updatedAt=i.updatedAt??wt(),i.size=i.size??St(o),i},putBytes(r,o,n="application/octet-stream"){if(e.writeBytes)e.writeBytes(r,o);else{let a=JSON.stringify({__kind:"bytes-array",data:[...o]});e.write(r,a)}let i=t(r)??{key:r};return i.contentType=n,i.updatedAt=i.updatedAt??wt(),i.size=i.size??o.byteLength,i},getText(r){let o=e.read(r);if(o===null){if(!e.readBytes)return null;let n=e.readBytes(r);return n===null?null:Buffer.from(n).toString("utf-8")}try{let n=JSON.parse(o);if(n&&n.__kind==="bytes-array"&&Array.isArray(n.data))return new TextDecoder("utf-8").decode(new Uint8Array(n.data))}catch{}return o},getBytes(r){if(e.readBytes){let n=e.readBytes(r);if(n!==null)return n}let o=e.read(r);if(o===null)return null;try{let n=JSON.parse(o);if(n&&n.__kind==="bytes-array"&&Array.isArray(n.data))return new Uint8Array(n.data)}catch{}return new TextEncoder().encode(o)},head:t,list(r=""){return e.listKeys(r).map(o=>t(o)??{key:o}).sort((o,n)=>o.key.localeCompare(n.key))},remove(r){e.remove(r)}}}function ue(e){function t(n){return{status:"success",data:n}}function r(n){return{status:"fail",error:n}}function o(n){return{status:"error",error:n instanceof Error?n.message:String(n)}}return{list(n){try{let i=n.params?.prefix??"";return t({artifacts:e.list(i)})}catch(i){return o(i)}},head(n){try{let i=n.params?.key;return i?t({artifact:e.head(i)}):r("head requires params.key")}catch(i){return o(i)}},put(n){try{let i=n.params?.key,a=n.params?.contentType;if(!i)return r("put requires params.key");let c=n.body;if(typeof c=="string")return t({artifact:e.putText(i,c,a)});if(c&&typeof c=="object"&&typeof c.text=="string")return t({artifact:e.putText(i,c.text,a)});if(c&&typeof c=="object"&&Array.isArray(c.bytes)){let d=c.bytes,h=new Uint8Array(d.map(u=>Math.max(0,Math.min(255,Number(u)||0))));return t({artifact:e.putBytes(i,h,a)})}return r("put requires body as string, {text}, or {bytes:number[]}")}catch(i){return o(i)}},get(n){try{let i=n.params?.key,a=n.params?.as??"base64";if(!i)return r("get requires params.key");let c=e.head(i);if(!c)return r(`artifact "${i}" not found`);if(a==="text"){let h=e.getText(i);return h===null?r(`artifact "${i}" not found`):t({key:i,contentType:c.contentType,size:c.size,text:h})}let d=e.getBytes(i);return d===null?r(`artifact "${i}" not found`):t({key:i,contentType:c.contentType,size:c.size,bytes:[...d]})}catch(i){return o(i)}},del(n){try{let i=n.params?.key;return i?(e.remove(i),t({ok:!0})):r("del requires params.key")}catch(i){return o(i)}}}}function gt(...e){return j.resolve(...e)}j.join(xt.tmpdir(),".board-live-cards-git-bash-cache.json");function Me(e,t,r){let o=e.indexOf(t),n=o!==-1?e[o+1]:void 0;if(!n)throw new Error(`Missing ${t}
4
+ Usage: ${r}`);return n}function J(e,t){let r=e.indexOf(t);return r!==-1?e[r+1]:void 0}function we(e,t){let r=J(e,"--ref");return r?ar(r):{storeRef:Me(e,"--store-ref",t),key:Me(e,"--key",t)}}async function fr(){let e=[];for await(let t of process.stdin)e.push(Buffer.isBuffer(t)?t:Buffer.from(t));return new Uint8Array(Buffer.concat(e))}var _t=["artifacts-store \u2014 generic artifact CRUD on a blob-backed store",""," artifacts-store put (--store-ref <ref> --key <key> | --ref <full-ref>) [--file <path> | --text <text>] [--content-type <mime>]"," artifacts-store get (--store-ref <ref> --key <key> | --ref <full-ref>) [--out <path>] [--as text|bytes]"," artifacts-store head (--store-ref <ref> --key <key> | --ref <full-ref>)"," artifacts-store list --store-ref <ref> [--prefix <prefix>]"," artifacts-store del (--store-ref <ref> --key <key> | --ref <full-ref>)"].join(`
5
+ `);async function sr(e){let t=e[0],r=e.slice(1);if(!t||t==="help"||t==="--help"||t==="-h"){console.error(_t);return}if(t==="put"){let{storeRef:o,key:n}=we(r,"artifacts-store put (--store-ref <ref> --key <key> | --ref <full-ref>)"),i=Z(o).value,a=ue(oe(ie(i))),c=J(r,"--content-type"),d=J(r,"--file"),h=J(r,"--text"),u;if(d)u={bytes:[...new Uint8Array(w.readFileSync(d))]};else if(typeof h=="string")u={text:h};else if(!process.stdin.isTTY)u={bytes:[...await fr()]};else throw new Error("put requires --file, --text, or stdin bytes");let s=a.put({params:{key:n,...c?{contentType:c}:{}},body:u});if(s.status!=="success")throw new Error(s.error||"put failed");process.stdout.write(JSON.stringify(s.data,null,2)+`
6
+ `);return}if(t==="get"){let{storeRef:o,key:n}=we(r,"artifacts-store get (--store-ref <ref> --key <key> | --ref <full-ref>)"),i=Z(o).value,a=ue(oe(ie(i))),c=(J(r,"--as")||"bytes").toLowerCase(),d=J(r,"--out"),h=a.get({params:{key:n,as:c}});if(h.status!=="success")throw new Error(h.error||"get failed");if(c==="text"){let s=h.data.text??"";d?w.writeFileSync(d,s,"utf-8"):process.stdout.write(s);return}let u=new Uint8Array(h.data.bytes??[]);d?w.writeFileSync(d,Buffer.from(u)):process.stdout.write(JSON.stringify({...h.data,bytes:void 0,byteLength:u.byteLength},null,2)+`
7
+ `);return}if(t==="head"){let{storeRef:o,key:n}=we(r,"artifacts-store head (--store-ref <ref> --key <key> | --ref <full-ref>)"),i=Z(o).value,a=ue(oe(ie(i))).head({params:{key:n}});if(a.status!=="success")throw new Error(a.error||"head failed");process.stdout.write(JSON.stringify(a.data,null,2)+`
8
+ `);return}if(t==="list"){let o=Me(r,"--store-ref","artifacts-store list --store-ref <ref> [--prefix <prefix>]"),n=Z(o).value,i=ue(oe(ie(n))),a=J(r,"--prefix")||"",c=i.list({params:a?{prefix:a}:{}});if(c.status!=="success")throw new Error(c.error||"list failed");process.stdout.write(JSON.stringify(c.data,null,2)+`
9
+ `);return}if(t==="del"||t==="delete"||t==="rm"){let{storeRef:o,key:n}=we(r,"artifacts-store del (--store-ref <ref> --key <key> | --ref <full-ref>)"),i=Z(o).value,a=ue(oe(ie(i))).del({params:{key:n}});if(a.status!=="success")throw new Error(a.error||"del failed");process.stdout.write(JSON.stringify(a.data,null,2)+`
10
10
  `);return}throw new Error(`Unknown command "${t}"
11
11
 
12
- ${mt}`)}var fr=process.argv[1]&&ht(process.argv[1])===ht(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/,"$1"));fr&&cr(process.argv.slice(2)).catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(t),process.exit(1)});export{cr as cli};
12
+ ${_t}`)}var lr=process.argv[1]&&gt(process.argv[1])===gt(new URL(import.meta.url).pathname.replace(/^\/([A-Z]:)/,"$1"));lr&&sr(process.argv.slice(2)).catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(t),process.exit(1)});export{sr as cli};