@powerhousedao/connect 6.0.0-dev.48 → 6.0.0-dev.49

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 (34) hide show
  1. package/dist/assets/{AddDriveModal-Ye3Mh1wS.js → AddDriveModal-BYfZzMIC.js} +1 -1
  2. package/dist/assets/{ClearStorageModal-TF2Az59b.js → ClearStorageModal-DFZ-m6f-.js} +1 -1
  3. package/dist/assets/{CookiesPolicyModal-CzgDrJSd.js → CookiesPolicyModal-Cj5Xl9jN.js} +1 -1
  4. package/dist/assets/{CreateDocumentModal-BZT0AQbp.js → CreateDocumentModal-ohHswNs9.js} +1 -1
  5. package/dist/assets/{DebugSettingsModal-DRgFCUaE.js → DebugSettingsModal-CkP1JPUx.js} +1 -1
  6. package/dist/assets/{DeleteDriveModal-CAKRSzep.js → DeleteDriveModal-CyvW_Fxo.js} +1 -1
  7. package/dist/assets/{DeleteItemModal-Bedrw_K4.js → DeleteItemModal-IjQJN5Ta.js} +1 -1
  8. package/dist/assets/{DisclaimerModal-CnULHZvG.js → DisclaimerModal-DOQ36Dok.js} +1 -1
  9. package/dist/assets/{DriveSettingsModal-DI0f4hhb.js → DriveSettingsModal-Diohqk0G.js} +1 -1
  10. package/dist/assets/{ExportDocumentWithErrorsModal-MybSjsIo.js → ExportDocumentWithErrorsModal-CouuHIrQ.js} +1 -1
  11. package/dist/assets/{SettingsModal-BVz-2tRo.js → SettingsModal-DpeJc9tM.js} +1 -1
  12. package/dist/assets/{UpgradeDriveModal-B25uUHzR.js → UpgradeDriveModal-DQ9hGANt.js} +1 -1
  13. package/dist/assets/{design_system-CsZGT9TM.js → design_system-ChgkHQcK.js} +1 -1
  14. package/dist/assets/{design_system_connect-BSdZqe0N.js → design_system_connect-f0RXCh0R.js} +34 -34
  15. package/dist/assets/{design_system_ui-Da_rgtD8.js → design_system_ui-Lpzxckn7.js} +1 -1
  16. package/dist/assets/{document_engineering-CMR68YBl.js → document_engineering-BS3VZcWJ.js} +1 -1
  17. package/dist/assets/{document_model_editor-HuDfvP--.js → document_model_editor-BAQgvoKN.js} +4 -4
  18. package/dist/assets/{drive_explorer-DkSmm_6V.js → drive_explorer-nRFwqJAw.js} +2 -2
  19. package/dist/assets/{editor-B9vllGu6.js → editor-5W_5a3le.js} +1 -1
  20. package/dist/assets/{graphql-editor-BtUjTy78.js → graphql-editor-xhSUHLWA.js} +1 -1
  21. package/dist/assets/{hooks-9tjOzqAb.js → hooks-C-55R4U3.js} +1 -1
  22. package/dist/assets/{index-BM_QAxjp.js → index-B2VqKMxE.js} +2 -2
  23. package/dist/assets/{index-CiXwH5Va.js → index-BsJNDFx7.js} +3 -3
  24. package/dist/assets/{index-D6qKZ6iW.js → index-DZ2-VOmJ.js} +4 -4
  25. package/dist/assets/{json-editor-P_aSaNhS.js → json-editor-BMVwxcpO.js} +1 -1
  26. package/dist/assets/{nodefs-vkYnwUuq.js → nodefs-BiKhI2zu.js} +1 -1
  27. package/dist/assets/{nodefs-CNUPZuPQ.js → nodefs-Cduw_E70.js} +1 -1
  28. package/dist/assets/{opfs-ahp-u2x5CYEO.js → opfs-ahp-DfbuA6YK.js} +1 -1
  29. package/dist/assets/{opfs-ahp-B4ifW-lB.js → opfs-ahp-TIKnVjki.js} +1 -1
  30. package/dist/assets/{reactor_browser-3cdrx3At.js → reactor_browser-Cq7Q4foD.js} +4 -4
  31. package/dist/assets/rwa-report-Bb0W5-ac.png +0 -0
  32. package/dist/assets/{state-schemas-BdgOobOb.js → state-schemas-BIGJ6tBY.js} +2 -2
  33. package/dist/index.html +7 -7
  34. package/package.json +11 -11
@@ -1 +1 @@
1
- import{j as l}from"./document_model_editor-HuDfvP--.js";import{b as g,s as f,t,L as R,i as y,f as T,x as u,c as h,a as S,u as b,E as k,g as m,h as j,k as C,j as E,l as x,m as $,n as N,o as V,p as Z,q as w,r as W,v as X,w as Y}from"./hooks-9tjOzqAb.js";import{r as Q}from"./sentry_react-CVx4Qq7f.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-DkSmm_6V.js";import"./react/jsx-runtime-DldvXD6N.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./design_system-CsZGT9TM.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./reactor_browser-3cdrx3At.js";import"./document_drive-DiwReQ7A.js";import"./design_system_connect-BSdZqe0N.js";import"./design_system_ui-Da_rgtD8.js";import"./sentry_browser-TIBDlywD.js";const L=f({String:t.string,Number:t.number,"True False":t.bool,PropertyName:t.propertyName,Null:t.null,", :":t.separator,"[ ]":t.squareBracket,"{ }":t.brace}),H=g.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[L],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),q=()=>a=>{try{JSON.parse(a.state.doc.toString())}catch(r){if(!(r instanceof SyntaxError))throw r;const e=v(r,a.state.doc);return[{from:e,message:r.message,severity:"error",to:e}]}return[]};function v(a,r){let e;return(e=a.message.match(/at position (\d+)/))?Math.min(+e[1],r.length):(e=a.message.match(/at line (\d+) column (\d+)/))?Math.min(r.line(+e[1]).from+ +e[2]-1,r.length):0}const d=R.define({name:"json",parser:H.configure({props:[y.add({Object:u({except:/^\s*\}/}),Array:u({except:/^\s*\]/})}),T.add({"Object Array":h})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function G(){return new S(d)}const ne=Q.memo(function(r){const{doc:e,readonly:o=!1,updateDocumentInModel:n}=r,{editorRef:i,viewRef:O,updateListenerCompartment:c,focusHandlerCompartment:P,pasteHandlerCompartment:p,timeoutRef:s}=b();return Q.useEffect(()=>{O.current||(O.current=new k({state:m.create({doc:e,extensions:[...j,C.of($),E,d,G(),x(q()),c.current.of(N(o,s,n)),P.current.of(V(o,s,n)),p.current.of(Z(o,s,n)),m.readOnly.of(o)]}),parent:i.current}),w(O.current))},[]),W(O),X(O.current,o,s,n,{updateListener:c.current,focusHandler:P.current,pasteHandler:p.current}),Y(O.current,e),l.jsx("div",{ref:i})});export{ne as default};
1
+ import{j as l}from"./document_model_editor-BAQgvoKN.js";import{b as g,s as f,t,L as R,i as y,f as T,x as u,c as h,a as S,u as b,E as k,g as m,h as j,k as C,j as E,l as x,m as $,n as N,o as V,p as Z,q as w,r as W,v as X,w as Y}from"./hooks-C-55R4U3.js";import{r as Q}from"./sentry_react-CVx4Qq7f.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-nRFwqJAw.js";import"./react/jsx-runtime-DldvXD6N.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./design_system-ChgkHQcK.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./reactor_browser-Cq7Q4foD.js";import"./document_drive-DiwReQ7A.js";import"./design_system_connect-f0RXCh0R.js";import"./design_system_ui-Lpzxckn7.js";import"./sentry_browser-TIBDlywD.js";const L=f({String:t.string,Number:t.number,"True False":t.bool,PropertyName:t.propertyName,Null:t.null,", :":t.separator,"[ ]":t.squareBracket,"{ }":t.brace}),H=g.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[L],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),q=()=>a=>{try{JSON.parse(a.state.doc.toString())}catch(r){if(!(r instanceof SyntaxError))throw r;const e=v(r,a.state.doc);return[{from:e,message:r.message,severity:"error",to:e}]}return[]};function v(a,r){let e;return(e=a.message.match(/at position (\d+)/))?Math.min(+e[1],r.length):(e=a.message.match(/at line (\d+) column (\d+)/))?Math.min(r.line(+e[1]).from+ +e[2]-1,r.length):0}const d=R.define({name:"json",parser:H.configure({props:[y.add({Object:u({except:/^\s*\}/}),Array:u({except:/^\s*\]/})}),T.add({"Object Array":h})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function G(){return new S(d)}const ne=Q.memo(function(r){const{doc:e,readonly:o=!1,updateDocumentInModel:n}=r,{editorRef:i,viewRef:O,updateListenerCompartment:c,focusHandlerCompartment:P,pasteHandlerCompartment:p,timeoutRef:s}=b();return Q.useEffect(()=>{O.current||(O.current=new k({state:m.create({doc:e,extensions:[...j,C.of($),E,d,G(),x(q()),c.current.of(N(o,s,n)),P.current.of(V(o,s,n)),p.current.of(Z(o,s,n)),m.readOnly.of(o)]}),parent:i.current}),w(O.current))},[]),W(O),X(O.current,o,s,n,{updateListener:c.current,focusHandler:P.current,pasteHandler:p.current}),Y(O.current,e),l.jsx("div",{ref:i})});export{ne as default};
@@ -1 +1 @@
1
- import{bf as s,bg as o,a9 as e}from"./reactor_browser-3cdrx3At.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-HuDfvP--.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-DkSmm_6V.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-CsZGT9TM.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-BSdZqe0N.js";import"./design_system_ui-Da_rgtD8.js";e();var N=class extends s{constructor(t){super(t),this.rootDir=(void 0)(t),(void 0)((void 0)(this.rootDir))||(void 0)(this.rootDir)}async init(t,r){return this.pg=t,{emscriptenOpts:{...r,preRun:[...r.preRun||[],i=>{let p=i.FS.filesystems.NODEFS;i.FS.mkdir(o),i.FS.mount(p,{root:this.rootDir},o)}]}}}async closeFs(){this.pg.Module.FS.quit()}};export{N as NodeFS};
1
+ import{bf as s,bg as o,a9 as e}from"./reactor_browser-Cq7Q4foD.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-BAQgvoKN.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-nRFwqJAw.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-ChgkHQcK.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-f0RXCh0R.js";import"./design_system_ui-Lpzxckn7.js";e();var N=class extends s{constructor(t){super(t),this.rootDir=(void 0)(t),(void 0)((void 0)(this.rootDir))||(void 0)(this.rootDir)}async init(t,r){return this.pg=t,{emscriptenOpts:{...r,preRun:[...r.preRun||[],i=>{let p=i.FS.filesystems.NODEFS;i.FS.mkdir(o),i.FS.mount(p,{root:this.rootDir},o)}]}}}async closeFs(){this.pg.Module.FS.quit()}};export{N as NodeFS};
@@ -1 +1 @@
1
- import{u as m,C as o,a as s}from"./index-D6qKZ6iW.js";import"./reactor_browser-3cdrx3At.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-HuDfvP--.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-DkSmm_6V.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-CsZGT9TM.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-BSdZqe0N.js";import"./design_system_ui-Da_rgtD8.js";s();var R=class extends m{constructor(t){super(t),this.rootDir=(void 0)(t),(void 0)((void 0)(this.rootDir))||(void 0)(this.rootDir)}async init(t,r){return this.pg=t,{emscriptenOpts:{...r,preRun:[...r.preRun||[],i=>{let p=i.FS.filesystems.NODEFS;i.FS.mkdir(o),i.FS.mount(p,{root:this.rootDir},o)}]}}}async closeFs(){this.pg.Module.FS.quit()}};export{R as NodeFS};
1
+ import{u as m,C as o,a as s}from"./index-DZ2-VOmJ.js";import"./reactor_browser-Cq7Q4foD.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-BAQgvoKN.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-nRFwqJAw.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-ChgkHQcK.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-f0RXCh0R.js";import"./design_system_ui-Lpzxckn7.js";s();var R=class extends m{constructor(t){super(t),this.rootDir=(void 0)(t),(void 0)((void 0)(this.rootDir))||(void 0)(this.rootDir)}async init(t,r){return this.pg=t,{emscriptenOpts:{...r,preRun:[...r.preRun||[],i=>{let p=i.FS.filesystems.NODEFS;i.FS.mkdir(o),i.FS.mount(p,{root:this.rootDir},o)}]}}}async closeFs(){this.pg.Module.FS.quit()}};export{R as NodeFS};
@@ -1,3 +1,3 @@
1
- import{bh as H,ab as m,ae as o,ad as a,bi as A,a9 as C,ac as P,bj as $}from"./reactor_browser-3cdrx3At.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-HuDfvP--.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-DkSmm_6V.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-CsZGT9TM.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-BSdZqe0N.js";import"./design_system_ui-Da_rgtD8.js";C();var B="state.txt",L="data",x={DIR:16384,FILE:32768},T,I,E,_,w,k,y,j,N,b,S,l,v,O,M,g,f,D,R,W,ot=class extends H{constructor(t,{initialPoolSize:e=1e3,maintainedPoolSize:s=100,debug:i=!1}={}){super(t,{debug:i}),m(this,l),m(this,T),m(this,I),m(this,E),m(this,_),m(this,w),m(this,k,new Map),m(this,y,new Map),m(this,j,0),m(this,N,new Map),m(this,b,new Map),this.lastCheckpoint=0,this.checkpointInterval=1e3*60,this.poolCounter=0,m(this,S,new Set),this.initialPoolSize=e,this.maintainedPoolSize=s}async init(t,e){return await o(this,l,v).call(this),super.init(t,e)}async syncToFs(t=!1){await this.maybeCheckpointState(),await this.maintainPool(),t||this.flush()}async closeFs(){for(let t of a(this,y).values())t.close();a(this,w).flush(),a(this,w).close(),this.pg.Module.FS.quit()}async maintainPool(t){t=t||this.maintainedPoolSize;let e=t-this.state.pool.length,s=[];for(let i=0;i<e;i++)s.push(new Promise(async h=>{++this.poolCounter;let r=`${(Date.now()-1704063600).toString(16).padStart(8,"0")}-${this.poolCounter.toString(16).padStart(8,"0")}`,c=await a(this,E).getFileHandle(r,{create:!0}),d=await c.createSyncAccessHandle();a(this,k).set(r,c),a(this,y).set(r,d),o(this,l,M).call(this,{opp:"createPoolFile",args:[r]}),this.state.pool.push(r),h()}));for(let i=0;i>e;i--)s.push(new Promise(async h=>{let r=this.state.pool.pop();o(this,l,M).call(this,{opp:"deletePoolFile",args:[r]});let c=a(this,k).get(r);a(this,y).get(r)?.close(),await a(this,E).removeEntry(c.name),a(this,k).delete(r),a(this,y).delete(r),h()}));await Promise.all(s)}_createPoolFileState(t){this.state.pool.push(t)}_deletePoolFileState(t){let e=this.state.pool.indexOf(t);e>-1&&this.state.pool.splice(e,1)}async maybeCheckpointState(){Date.now()-this.lastCheckpoint>this.checkpointInterval&&await this.checkpointState()}async checkpointState(){let t=new TextEncoder().encode(JSON.stringify(this.state));a(this,w).truncate(0),a(this,w).write(t,{at:0}),a(this,w).flush(),this.lastCheckpoint=Date.now()}flush(){for(let t of a(this,S))try{t.flush()}catch{}a(this,S).clear()}chmod(t,e){o(this,l,O).call(this,{opp:"chmod",args:[t,e]},()=>{this._chmodState(t,e)})}_chmodState(t,e){let s=o(this,l,f).call(this,t);s.mode=e}close(t){let e=o(this,l,D).call(this,t);a(this,N).delete(t),a(this,b).delete(e)}fstat(t){let e=o(this,l,D).call(this,t);return this.lstat(e)}lstat(t){let e=o(this,l,f).call(this,t),s=e.type==="file"?a(this,y).get(e.backingFilename).getSize():0,i=4096;return{dev:0,ino:0,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:s,blksize:i,blocks:Math.ceil(s/i),atime:e.lastModified,mtime:e.lastModified,ctime:e.lastModified}}mkdir(t,e){o(this,l,O).call(this,{opp:"mkdir",args:[t,e]},()=>{this._mkdirState(t,e)})}_mkdirState(t,e){let s=o(this,l,g).call(this,t),i=s.pop(),h=[],r=this.state.root;for(let d of s){if(h.push(t),!Object.prototype.hasOwnProperty.call(r.children,d))if(e?.recursive)this.mkdir(h.join("/"));else throw new p("ENOENT","No such file or directory");if(r.children[d].type!=="directory")throw new p("ENOTDIR","Not a directory");r=r.children[d]}if(Object.prototype.hasOwnProperty.call(r.children,i))throw new p("EEXIST","File exists");let c={type:"directory",lastModified:Date.now(),mode:e?.mode||x.DIR,children:{}};r.children[i]=c}open(t,e,s){if(o(this,l,f).call(this,t).type!=="file")throw new p("EISDIR","Is a directory");let i=o(this,l,R).call(this);return a(this,N).set(i,t),a(this,b).set(t,i),i}readdir(t){let e=o(this,l,f).call(this,t);if(e.type!=="directory")throw new p("ENOTDIR","Not a directory");return Object.keys(e.children)}read(t,e,s,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");return a(this,y).get(c.backingFilename).read(new Uint8Array(e.buffer,s,i),{at:h})}rename(t,e){o(this,l,O).call(this,{opp:"rename",args:[t,e]},()=>{this._renameState(t,e,!0)})}_renameState(t,e,s=!1){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(!Object.prototype.hasOwnProperty.call(r.children,h))throw new p("ENOENT","No such file or directory");let c=o(this,l,g).call(this,e),d=c.pop(),n=o(this,l,f).call(this,c.join("/"));if(s&&Object.prototype.hasOwnProperty.call(n.children,d)){let u=n.children[d];a(this,y).get(u.backingFilename).truncate(0),this.state.pool.push(u.backingFilename)}n.children[d]=r.children[h],delete r.children[h]}rmdir(t){o(this,l,O).call(this,{opp:"rmdir",args:[t]},()=>{this._rmdirState(t)})}_rmdirState(t){let e=o(this,l,g).call(this,t),s=e.pop(),i=o(this,l,f).call(this,e.join("/"));if(!Object.prototype.hasOwnProperty.call(i.children,s))throw new p("ENOENT","No such file or directory");let h=i.children[s];if(h.type!=="directory")throw new p("ENOTDIR","Not a directory");if(Object.keys(h.children).length>0)throw new p("ENOTEMPTY","Directory not empty");delete i.children[s]}truncate(t,e=0){let s=o(this,l,f).call(this,t);if(s.type!=="file")throw new p("EISDIR","Is a directory");let i=a(this,y).get(s.backingFilename);if(!i)throw new p("ENOENT","No such file or directory");i.truncate(e),a(this,S).add(i)}unlink(t){o(this,l,O).call(this,{opp:"unlink",args:[t]},()=>{this._unlinkState(t,!0)})}_unlinkState(t,e=!1){let s=o(this,l,g).call(this,t),i=s.pop(),h=o(this,l,f).call(this,s.join("/"));if(!Object.prototype.hasOwnProperty.call(h.children,i))throw new p("ENOENT","No such file or directory");let r=h.children[i];if(r.type!=="file")throw new p("EISDIR","Is a directory");if(delete h.children[i],e){let c=a(this,y).get(r.backingFilename);c?.truncate(0),a(this,S).add(c),a(this,b).has(t)&&(a(this,N).delete(a(this,b).get(t)),a(this,b).delete(t))}this.state.pool.push(r.backingFilename)}utimes(t,e,s){o(this,l,O).call(this,{opp:"utimes",args:[t,e,s]},()=>{this._utimesState(t,e,s)})}_utimesState(t,e,s){let i=o(this,l,f).call(this,t);i.lastModified=s}writeFile(t,e,s){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(Object.prototype.hasOwnProperty.call(r.children,h)){let n=r.children[h];n.lastModified=Date.now(),o(this,l,M).call(this,{opp:"setLastModified",args:[t,n.lastModified]})}else{if(this.state.pool.length===0)throw new Error("No more file handles available in the pool");let n={type:"file",lastModified:Date.now(),mode:s?.mode||x.FILE,backingFilename:this.state.pool.pop()};r.children[h]=n,o(this,l,M).call(this,{opp:"createFileNode",args:[t,n]})}let c=r.children[h],d=a(this,y).get(c.backingFilename);e.length>0&&(d.write(typeof e=="string"?new TextEncoder().encode(e):new Uint8Array(e),{at:0}),t.startsWith("/pg_wal")&&a(this,S).add(d))}_createFileNodeState(t,e){let s=o(this,l,g).call(this,t),i=s.pop(),h=o(this,l,f).call(this,s.join("/"));h.children[i]=e;let r=this.state.pool.indexOf(e.backingFilename);return r>-1&&this.state.pool.splice(r,1),e}_setLastModifiedState(t,e){let s=o(this,l,f).call(this,t);s.lastModified=e}write(t,e,s,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");let d=a(this,y).get(c.backingFilename);if(!d)throw new p("EBADF","Bad file descriptor");let n=d.write(new Uint8Array(e,s,i),{at:h});return r.startsWith("/pg_wal")&&a(this,S).add(d),n}};T=new WeakMap,I=new WeakMap,E=new WeakMap,_=new WeakMap,w=new WeakMap,k=new WeakMap,y=new WeakMap,j=new WeakMap,N=new WeakMap,b=new WeakMap,S=new WeakMap,l=new WeakSet,v=async function(){P(this,T,await navigator.storage.getDirectory()),P(this,I,await o(this,l,W).call(this,this.dataDir,{create:!0})),P(this,E,await o(this,l,W).call(this,L,{from:a(this,I),create:!0})),P(this,_,await a(this,I).getFileHandle(B,{create:!0})),P(this,w,await a(this,_).createSyncAccessHandle());let t=new ArrayBuffer(a(this,w).getSize());a(this,w).read(t,{at:0});let e,s=new TextDecoder().decode(t).split(`
1
+ import{bh as H,ab as m,ae as o,ad as a,bi as A,a9 as C,ac as P,bj as $}from"./reactor_browser-Cq7Q4foD.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-BAQgvoKN.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-nRFwqJAw.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-ChgkHQcK.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-f0RXCh0R.js";import"./design_system_ui-Lpzxckn7.js";C();var B="state.txt",L="data",x={DIR:16384,FILE:32768},T,I,E,_,w,k,y,j,N,b,S,l,v,O,M,g,f,D,R,W,ot=class extends H{constructor(t,{initialPoolSize:e=1e3,maintainedPoolSize:s=100,debug:i=!1}={}){super(t,{debug:i}),m(this,l),m(this,T),m(this,I),m(this,E),m(this,_),m(this,w),m(this,k,new Map),m(this,y,new Map),m(this,j,0),m(this,N,new Map),m(this,b,new Map),this.lastCheckpoint=0,this.checkpointInterval=1e3*60,this.poolCounter=0,m(this,S,new Set),this.initialPoolSize=e,this.maintainedPoolSize=s}async init(t,e){return await o(this,l,v).call(this),super.init(t,e)}async syncToFs(t=!1){await this.maybeCheckpointState(),await this.maintainPool(),t||this.flush()}async closeFs(){for(let t of a(this,y).values())t.close();a(this,w).flush(),a(this,w).close(),this.pg.Module.FS.quit()}async maintainPool(t){t=t||this.maintainedPoolSize;let e=t-this.state.pool.length,s=[];for(let i=0;i<e;i++)s.push(new Promise(async h=>{++this.poolCounter;let r=`${(Date.now()-1704063600).toString(16).padStart(8,"0")}-${this.poolCounter.toString(16).padStart(8,"0")}`,c=await a(this,E).getFileHandle(r,{create:!0}),d=await c.createSyncAccessHandle();a(this,k).set(r,c),a(this,y).set(r,d),o(this,l,M).call(this,{opp:"createPoolFile",args:[r]}),this.state.pool.push(r),h()}));for(let i=0;i>e;i--)s.push(new Promise(async h=>{let r=this.state.pool.pop();o(this,l,M).call(this,{opp:"deletePoolFile",args:[r]});let c=a(this,k).get(r);a(this,y).get(r)?.close(),await a(this,E).removeEntry(c.name),a(this,k).delete(r),a(this,y).delete(r),h()}));await Promise.all(s)}_createPoolFileState(t){this.state.pool.push(t)}_deletePoolFileState(t){let e=this.state.pool.indexOf(t);e>-1&&this.state.pool.splice(e,1)}async maybeCheckpointState(){Date.now()-this.lastCheckpoint>this.checkpointInterval&&await this.checkpointState()}async checkpointState(){let t=new TextEncoder().encode(JSON.stringify(this.state));a(this,w).truncate(0),a(this,w).write(t,{at:0}),a(this,w).flush(),this.lastCheckpoint=Date.now()}flush(){for(let t of a(this,S))try{t.flush()}catch{}a(this,S).clear()}chmod(t,e){o(this,l,O).call(this,{opp:"chmod",args:[t,e]},()=>{this._chmodState(t,e)})}_chmodState(t,e){let s=o(this,l,f).call(this,t);s.mode=e}close(t){let e=o(this,l,D).call(this,t);a(this,N).delete(t),a(this,b).delete(e)}fstat(t){let e=o(this,l,D).call(this,t);return this.lstat(e)}lstat(t){let e=o(this,l,f).call(this,t),s=e.type==="file"?a(this,y).get(e.backingFilename).getSize():0,i=4096;return{dev:0,ino:0,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:s,blksize:i,blocks:Math.ceil(s/i),atime:e.lastModified,mtime:e.lastModified,ctime:e.lastModified}}mkdir(t,e){o(this,l,O).call(this,{opp:"mkdir",args:[t,e]},()=>{this._mkdirState(t,e)})}_mkdirState(t,e){let s=o(this,l,g).call(this,t),i=s.pop(),h=[],r=this.state.root;for(let d of s){if(h.push(t),!Object.prototype.hasOwnProperty.call(r.children,d))if(e?.recursive)this.mkdir(h.join("/"));else throw new p("ENOENT","No such file or directory");if(r.children[d].type!=="directory")throw new p("ENOTDIR","Not a directory");r=r.children[d]}if(Object.prototype.hasOwnProperty.call(r.children,i))throw new p("EEXIST","File exists");let c={type:"directory",lastModified:Date.now(),mode:e?.mode||x.DIR,children:{}};r.children[i]=c}open(t,e,s){if(o(this,l,f).call(this,t).type!=="file")throw new p("EISDIR","Is a directory");let i=o(this,l,R).call(this);return a(this,N).set(i,t),a(this,b).set(t,i),i}readdir(t){let e=o(this,l,f).call(this,t);if(e.type!=="directory")throw new p("ENOTDIR","Not a directory");return Object.keys(e.children)}read(t,e,s,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");return a(this,y).get(c.backingFilename).read(new Uint8Array(e.buffer,s,i),{at:h})}rename(t,e){o(this,l,O).call(this,{opp:"rename",args:[t,e]},()=>{this._renameState(t,e,!0)})}_renameState(t,e,s=!1){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(!Object.prototype.hasOwnProperty.call(r.children,h))throw new p("ENOENT","No such file or directory");let c=o(this,l,g).call(this,e),d=c.pop(),n=o(this,l,f).call(this,c.join("/"));if(s&&Object.prototype.hasOwnProperty.call(n.children,d)){let u=n.children[d];a(this,y).get(u.backingFilename).truncate(0),this.state.pool.push(u.backingFilename)}n.children[d]=r.children[h],delete r.children[h]}rmdir(t){o(this,l,O).call(this,{opp:"rmdir",args:[t]},()=>{this._rmdirState(t)})}_rmdirState(t){let e=o(this,l,g).call(this,t),s=e.pop(),i=o(this,l,f).call(this,e.join("/"));if(!Object.prototype.hasOwnProperty.call(i.children,s))throw new p("ENOENT","No such file or directory");let h=i.children[s];if(h.type!=="directory")throw new p("ENOTDIR","Not a directory");if(Object.keys(h.children).length>0)throw new p("ENOTEMPTY","Directory not empty");delete i.children[s]}truncate(t,e=0){let s=o(this,l,f).call(this,t);if(s.type!=="file")throw new p("EISDIR","Is a directory");let i=a(this,y).get(s.backingFilename);if(!i)throw new p("ENOENT","No such file or directory");i.truncate(e),a(this,S).add(i)}unlink(t){o(this,l,O).call(this,{opp:"unlink",args:[t]},()=>{this._unlinkState(t,!0)})}_unlinkState(t,e=!1){let s=o(this,l,g).call(this,t),i=s.pop(),h=o(this,l,f).call(this,s.join("/"));if(!Object.prototype.hasOwnProperty.call(h.children,i))throw new p("ENOENT","No such file or directory");let r=h.children[i];if(r.type!=="file")throw new p("EISDIR","Is a directory");if(delete h.children[i],e){let c=a(this,y).get(r.backingFilename);c?.truncate(0),a(this,S).add(c),a(this,b).has(t)&&(a(this,N).delete(a(this,b).get(t)),a(this,b).delete(t))}this.state.pool.push(r.backingFilename)}utimes(t,e,s){o(this,l,O).call(this,{opp:"utimes",args:[t,e,s]},()=>{this._utimesState(t,e,s)})}_utimesState(t,e,s){let i=o(this,l,f).call(this,t);i.lastModified=s}writeFile(t,e,s){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(Object.prototype.hasOwnProperty.call(r.children,h)){let n=r.children[h];n.lastModified=Date.now(),o(this,l,M).call(this,{opp:"setLastModified",args:[t,n.lastModified]})}else{if(this.state.pool.length===0)throw new Error("No more file handles available in the pool");let n={type:"file",lastModified:Date.now(),mode:s?.mode||x.FILE,backingFilename:this.state.pool.pop()};r.children[h]=n,o(this,l,M).call(this,{opp:"createFileNode",args:[t,n]})}let c=r.children[h],d=a(this,y).get(c.backingFilename);e.length>0&&(d.write(typeof e=="string"?new TextEncoder().encode(e):new Uint8Array(e),{at:0}),t.startsWith("/pg_wal")&&a(this,S).add(d))}_createFileNodeState(t,e){let s=o(this,l,g).call(this,t),i=s.pop(),h=o(this,l,f).call(this,s.join("/"));h.children[i]=e;let r=this.state.pool.indexOf(e.backingFilename);return r>-1&&this.state.pool.splice(r,1),e}_setLastModifiedState(t,e){let s=o(this,l,f).call(this,t);s.lastModified=e}write(t,e,s,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");let d=a(this,y).get(c.backingFilename);if(!d)throw new p("EBADF","Bad file descriptor");let n=d.write(new Uint8Array(e,s,i),{at:h});return r.startsWith("/pg_wal")&&a(this,S).add(d),n}};T=new WeakMap,I=new WeakMap,E=new WeakMap,_=new WeakMap,w=new WeakMap,k=new WeakMap,y=new WeakMap,j=new WeakMap,N=new WeakMap,b=new WeakMap,S=new WeakMap,l=new WeakSet,v=async function(){P(this,T,await navigator.storage.getDirectory()),P(this,I,await o(this,l,W).call(this,this.dataDir,{create:!0})),P(this,E,await o(this,l,W).call(this,L,{from:a(this,I),create:!0})),P(this,_,await a(this,I).getFileHandle(B,{create:!0})),P(this,w,await a(this,_).createSyncAccessHandle());let t=new ArrayBuffer(a(this,w).getSize());a(this,w).read(t,{at:0});let e,s=new TextDecoder().decode(t).split(`
2
2
  `),i=!1;try{e=JSON.parse(s[0])}catch{e={root:{type:"directory",lastModified:Date.now(),mode:x.DIR,children:{}},pool:[]},a(this,w).truncate(0),a(this,w).write(new TextEncoder().encode(JSON.stringify(e)),{at:0}),i=!0}this.state=e;let h=s.slice(1).filter(Boolean).map(n=>JSON.parse(n));for(let n of h){let u=`_${n.opp}State`;if(typeof this[u]=="function")try{this[u].bind(this)(...n.args)}catch(F){console.warn("Error applying OPFS AHP WAL entry",n,F)}}let r=[],c=async n=>{if(n.type==="file")try{let u=await a(this,E).getFileHandle(n.backingFilename),F=await u.createSyncAccessHandle();a(this,k).set(n.backingFilename,u),a(this,y).set(n.backingFilename,F)}catch(u){console.error("Error opening file handle for node",n,u)}else for(let u of Object.values(n.children))r.push(c(u))};await c(this.state.root);let d=[];for(let n of this.state.pool)d.push(new Promise(async u=>{a(this,k).has(n)&&console.warn("File handle already exists for pool file",n);let F=await a(this,E).getFileHandle(n),z=await F.createSyncAccessHandle();a(this,k).set(n,F),a(this,y).set(n,z),u()}));await Promise.all([...r,...d]),await this.maintainPool(i?this.initialPoolSize:this.maintainedPoolSize)},O=function(t,e){let s=o(this,l,M).call(this,t);try{e()}catch(i){throw a(this,w).truncate(s),i}},M=function(t){let e=JSON.stringify(t),s=new TextEncoder().encode(`
3
3
  ${e}`),i=a(this,w).getSize();return a(this,w).write(s,{at:i}),a(this,S).add(a(this,w)),i},g=function(t){return t.split("/").filter(Boolean)},f=function(t,e){let s=o(this,l,g).call(this,t),i=e||this.state.root;for(let h of s){if(i.type!=="directory")throw new p("ENOTDIR","Not a directory");if(!Object.prototype.hasOwnProperty.call(i.children,h))throw new p("ENOENT","No such file or directory");i=i.children[h]}return i},D=function(t){let e=a(this,N).get(t);if(!e)throw new p("EBADF","Bad file descriptor");return e},R=function(){let t=++$(this,j)._;for(;a(this,N).has(t);)$(this,j)._++;return t},W=async function(t,e){let s=o(this,l,g).call(this,t),i=e?.from||a(this,T);for(let h of s)i=await i.getDirectoryHandle(h,{create:e?.create});return i};var p=class extends Error{constructor(t,e){super(e),typeof t=="number"?this.code=t:typeof t=="string"&&(this.code=A[t])}};export{ot as OpfsAhpFS};
@@ -1,3 +1,3 @@
1
- import{c as H,R as m,T as o,h as s,p as A,a as C,x as P,U as $}from"./index-D6qKZ6iW.js";import"./reactor_browser-3cdrx3At.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-HuDfvP--.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-DkSmm_6V.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-CsZGT9TM.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-BSdZqe0N.js";import"./design_system_ui-Da_rgtD8.js";C();var B="state.txt",L="data",W={DIR:16384,FILE:32768},T,I,N,_,w,k,y,j,F,O,S,l,R,E,M,g,f,D,v,x,rt=class extends H{constructor(t,{initialPoolSize:e=1e3,maintainedPoolSize:a=100,debug:i=!1}={}){super(t,{debug:i}),m(this,l),m(this,T),m(this,I),m(this,N),m(this,_),m(this,w),m(this,k,new Map),m(this,y,new Map),m(this,j,0),m(this,F,new Map),m(this,O,new Map),this.lastCheckpoint=0,this.checkpointInterval=1e3*60,this.poolCounter=0,m(this,S,new Set),this.initialPoolSize=e,this.maintainedPoolSize=a}async init(t,e){return await o(this,l,R).call(this),super.init(t,e)}async syncToFs(t=!1){await this.maybeCheckpointState(),await this.maintainPool(),t||this.flush()}async closeFs(){for(let t of s(this,y).values())t.close();s(this,w).flush(),s(this,w).close(),this.pg.Module.FS.quit()}async maintainPool(t){t=t||this.maintainedPoolSize;let e=t-this.state.pool.length,a=[];for(let i=0;i<e;i++)a.push(new Promise(async h=>{++this.poolCounter;let r=`${(Date.now()-1704063600).toString(16).padStart(8,"0")}-${this.poolCounter.toString(16).padStart(8,"0")}`,c=await s(this,N).getFileHandle(r,{create:!0}),d=await c.createSyncAccessHandle();s(this,k).set(r,c),s(this,y).set(r,d),o(this,l,M).call(this,{opp:"createPoolFile",args:[r]}),this.state.pool.push(r),h()}));for(let i=0;i>e;i--)a.push(new Promise(async h=>{let r=this.state.pool.pop();o(this,l,M).call(this,{opp:"deletePoolFile",args:[r]});let c=s(this,k).get(r);s(this,y).get(r)?.close(),await s(this,N).removeEntry(c.name),s(this,k).delete(r),s(this,y).delete(r),h()}));await Promise.all(a)}_createPoolFileState(t){this.state.pool.push(t)}_deletePoolFileState(t){let e=this.state.pool.indexOf(t);e>-1&&this.state.pool.splice(e,1)}async maybeCheckpointState(){Date.now()-this.lastCheckpoint>this.checkpointInterval&&await this.checkpointState()}async checkpointState(){let t=new TextEncoder().encode(JSON.stringify(this.state));s(this,w).truncate(0),s(this,w).write(t,{at:0}),s(this,w).flush(),this.lastCheckpoint=Date.now()}flush(){for(let t of s(this,S))try{t.flush()}catch{}s(this,S).clear()}chmod(t,e){o(this,l,E).call(this,{opp:"chmod",args:[t,e]},()=>{this._chmodState(t,e)})}_chmodState(t,e){let a=o(this,l,f).call(this,t);a.mode=e}close(t){let e=o(this,l,D).call(this,t);s(this,F).delete(t),s(this,O).delete(e)}fstat(t){let e=o(this,l,D).call(this,t);return this.lstat(e)}lstat(t){let e=o(this,l,f).call(this,t),a=e.type==="file"?s(this,y).get(e.backingFilename).getSize():0,i=4096;return{dev:0,ino:0,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:a,blksize:i,blocks:Math.ceil(a/i),atime:e.lastModified,mtime:e.lastModified,ctime:e.lastModified}}mkdir(t,e){o(this,l,E).call(this,{opp:"mkdir",args:[t,e]},()=>{this._mkdirState(t,e)})}_mkdirState(t,e){let a=o(this,l,g).call(this,t),i=a.pop(),h=[],r=this.state.root;for(let d of a){if(h.push(t),!Object.prototype.hasOwnProperty.call(r.children,d))if(e?.recursive)this.mkdir(h.join("/"));else throw new p("ENOENT","No such file or directory");if(r.children[d].type!=="directory")throw new p("ENOTDIR","Not a directory");r=r.children[d]}if(Object.prototype.hasOwnProperty.call(r.children,i))throw new p("EEXIST","File exists");let c={type:"directory",lastModified:Date.now(),mode:e?.mode||W.DIR,children:{}};r.children[i]=c}open(t,e,a){if(o(this,l,f).call(this,t).type!=="file")throw new p("EISDIR","Is a directory");let i=o(this,l,v).call(this);return s(this,F).set(i,t),s(this,O).set(t,i),i}readdir(t){let e=o(this,l,f).call(this,t);if(e.type!=="directory")throw new p("ENOTDIR","Not a directory");return Object.keys(e.children)}read(t,e,a,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");return s(this,y).get(c.backingFilename).read(new Uint8Array(e.buffer,a,i),{at:h})}rename(t,e){o(this,l,E).call(this,{opp:"rename",args:[t,e]},()=>{this._renameState(t,e,!0)})}_renameState(t,e,a=!1){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(!Object.prototype.hasOwnProperty.call(r.children,h))throw new p("ENOENT","No such file or directory");let c=o(this,l,g).call(this,e),d=c.pop(),n=o(this,l,f).call(this,c.join("/"));if(a&&Object.prototype.hasOwnProperty.call(n.children,d)){let u=n.children[d];s(this,y).get(u.backingFilename).truncate(0),this.state.pool.push(u.backingFilename)}n.children[d]=r.children[h],delete r.children[h]}rmdir(t){o(this,l,E).call(this,{opp:"rmdir",args:[t]},()=>{this._rmdirState(t)})}_rmdirState(t){let e=o(this,l,g).call(this,t),a=e.pop(),i=o(this,l,f).call(this,e.join("/"));if(!Object.prototype.hasOwnProperty.call(i.children,a))throw new p("ENOENT","No such file or directory");let h=i.children[a];if(h.type!=="directory")throw new p("ENOTDIR","Not a directory");if(Object.keys(h.children).length>0)throw new p("ENOTEMPTY","Directory not empty");delete i.children[a]}truncate(t,e=0){let a=o(this,l,f).call(this,t);if(a.type!=="file")throw new p("EISDIR","Is a directory");let i=s(this,y).get(a.backingFilename);if(!i)throw new p("ENOENT","No such file or directory");i.truncate(e),s(this,S).add(i)}unlink(t){o(this,l,E).call(this,{opp:"unlink",args:[t]},()=>{this._unlinkState(t,!0)})}_unlinkState(t,e=!1){let a=o(this,l,g).call(this,t),i=a.pop(),h=o(this,l,f).call(this,a.join("/"));if(!Object.prototype.hasOwnProperty.call(h.children,i))throw new p("ENOENT","No such file or directory");let r=h.children[i];if(r.type!=="file")throw new p("EISDIR","Is a directory");if(delete h.children[i],e){let c=s(this,y).get(r.backingFilename);c?.truncate(0),s(this,S).add(c),s(this,O).has(t)&&(s(this,F).delete(s(this,O).get(t)),s(this,O).delete(t))}this.state.pool.push(r.backingFilename)}utimes(t,e,a){o(this,l,E).call(this,{opp:"utimes",args:[t,e,a]},()=>{this._utimesState(t,e,a)})}_utimesState(t,e,a){let i=o(this,l,f).call(this,t);i.lastModified=a}writeFile(t,e,a){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(Object.prototype.hasOwnProperty.call(r.children,h)){let n=r.children[h];n.lastModified=Date.now(),o(this,l,M).call(this,{opp:"setLastModified",args:[t,n.lastModified]})}else{if(this.state.pool.length===0)throw new Error("No more file handles available in the pool");let n={type:"file",lastModified:Date.now(),mode:a?.mode||W.FILE,backingFilename:this.state.pool.pop()};r.children[h]=n,o(this,l,M).call(this,{opp:"createFileNode",args:[t,n]})}let c=r.children[h],d=s(this,y).get(c.backingFilename);e.length>0&&(d.write(typeof e=="string"?new TextEncoder().encode(e):new Uint8Array(e),{at:0}),t.startsWith("/pg_wal")&&s(this,S).add(d))}_createFileNodeState(t,e){let a=o(this,l,g).call(this,t),i=a.pop(),h=o(this,l,f).call(this,a.join("/"));h.children[i]=e;let r=this.state.pool.indexOf(e.backingFilename);return r>-1&&this.state.pool.splice(r,1),e}_setLastModifiedState(t,e){let a=o(this,l,f).call(this,t);a.lastModified=e}write(t,e,a,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");let d=s(this,y).get(c.backingFilename);if(!d)throw new p("EBADF","Bad file descriptor");let n=d.write(new Uint8Array(e,a,i),{at:h});return r.startsWith("/pg_wal")&&s(this,S).add(d),n}};T=new WeakMap,I=new WeakMap,N=new WeakMap,_=new WeakMap,w=new WeakMap,k=new WeakMap,y=new WeakMap,j=new WeakMap,F=new WeakMap,O=new WeakMap,S=new WeakMap,l=new WeakSet,R=async function(){P(this,T,await navigator.storage.getDirectory()),P(this,I,await o(this,l,x).call(this,this.dataDir,{create:!0})),P(this,N,await o(this,l,x).call(this,L,{from:s(this,I),create:!0})),P(this,_,await s(this,I).getFileHandle(B,{create:!0})),P(this,w,await s(this,_).createSyncAccessHandle());let t=new ArrayBuffer(s(this,w).getSize());s(this,w).read(t,{at:0});let e,a=new TextDecoder().decode(t).split(`
1
+ import{c as H,R as m,T as o,h as s,p as A,a as C,x as P,U as $}from"./index-DZ2-VOmJ.js";import"./reactor_browser-Cq7Q4foD.js";import"./document_model-ly1Z8uco.js";import"./zod-Cc38s6JG.js";import"./react-D_vzfE_e.js";import"./document_drive-DiwReQ7A.js";import"./sentry_react-CVx4Qq7f.js";import"./sentry_browser-TIBDlywD.js";import"./document_model_editor-BAQgvoKN.js";import"./graphql-BXSeDpaV.js";import"./drive_explorer-nRFwqJAw.js";import"./react/jsx-runtime-DldvXD6N.js";import"./design_system-ChgkHQcK.js";import"./tailwind_merge-CXl88Wxt.js";import"./react-dom-Cz_KAjfm.js";import"./design_system_connect-f0RXCh0R.js";import"./design_system_ui-Lpzxckn7.js";C();var B="state.txt",L="data",W={DIR:16384,FILE:32768},T,I,N,_,w,k,y,j,F,O,S,l,R,E,M,g,f,D,v,x,rt=class extends H{constructor(t,{initialPoolSize:e=1e3,maintainedPoolSize:a=100,debug:i=!1}={}){super(t,{debug:i}),m(this,l),m(this,T),m(this,I),m(this,N),m(this,_),m(this,w),m(this,k,new Map),m(this,y,new Map),m(this,j,0),m(this,F,new Map),m(this,O,new Map),this.lastCheckpoint=0,this.checkpointInterval=1e3*60,this.poolCounter=0,m(this,S,new Set),this.initialPoolSize=e,this.maintainedPoolSize=a}async init(t,e){return await o(this,l,R).call(this),super.init(t,e)}async syncToFs(t=!1){await this.maybeCheckpointState(),await this.maintainPool(),t||this.flush()}async closeFs(){for(let t of s(this,y).values())t.close();s(this,w).flush(),s(this,w).close(),this.pg.Module.FS.quit()}async maintainPool(t){t=t||this.maintainedPoolSize;let e=t-this.state.pool.length,a=[];for(let i=0;i<e;i++)a.push(new Promise(async h=>{++this.poolCounter;let r=`${(Date.now()-1704063600).toString(16).padStart(8,"0")}-${this.poolCounter.toString(16).padStart(8,"0")}`,c=await s(this,N).getFileHandle(r,{create:!0}),d=await c.createSyncAccessHandle();s(this,k).set(r,c),s(this,y).set(r,d),o(this,l,M).call(this,{opp:"createPoolFile",args:[r]}),this.state.pool.push(r),h()}));for(let i=0;i>e;i--)a.push(new Promise(async h=>{let r=this.state.pool.pop();o(this,l,M).call(this,{opp:"deletePoolFile",args:[r]});let c=s(this,k).get(r);s(this,y).get(r)?.close(),await s(this,N).removeEntry(c.name),s(this,k).delete(r),s(this,y).delete(r),h()}));await Promise.all(a)}_createPoolFileState(t){this.state.pool.push(t)}_deletePoolFileState(t){let e=this.state.pool.indexOf(t);e>-1&&this.state.pool.splice(e,1)}async maybeCheckpointState(){Date.now()-this.lastCheckpoint>this.checkpointInterval&&await this.checkpointState()}async checkpointState(){let t=new TextEncoder().encode(JSON.stringify(this.state));s(this,w).truncate(0),s(this,w).write(t,{at:0}),s(this,w).flush(),this.lastCheckpoint=Date.now()}flush(){for(let t of s(this,S))try{t.flush()}catch{}s(this,S).clear()}chmod(t,e){o(this,l,E).call(this,{opp:"chmod",args:[t,e]},()=>{this._chmodState(t,e)})}_chmodState(t,e){let a=o(this,l,f).call(this,t);a.mode=e}close(t){let e=o(this,l,D).call(this,t);s(this,F).delete(t),s(this,O).delete(e)}fstat(t){let e=o(this,l,D).call(this,t);return this.lstat(e)}lstat(t){let e=o(this,l,f).call(this,t),a=e.type==="file"?s(this,y).get(e.backingFilename).getSize():0,i=4096;return{dev:0,ino:0,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:a,blksize:i,blocks:Math.ceil(a/i),atime:e.lastModified,mtime:e.lastModified,ctime:e.lastModified}}mkdir(t,e){o(this,l,E).call(this,{opp:"mkdir",args:[t,e]},()=>{this._mkdirState(t,e)})}_mkdirState(t,e){let a=o(this,l,g).call(this,t),i=a.pop(),h=[],r=this.state.root;for(let d of a){if(h.push(t),!Object.prototype.hasOwnProperty.call(r.children,d))if(e?.recursive)this.mkdir(h.join("/"));else throw new p("ENOENT","No such file or directory");if(r.children[d].type!=="directory")throw new p("ENOTDIR","Not a directory");r=r.children[d]}if(Object.prototype.hasOwnProperty.call(r.children,i))throw new p("EEXIST","File exists");let c={type:"directory",lastModified:Date.now(),mode:e?.mode||W.DIR,children:{}};r.children[i]=c}open(t,e,a){if(o(this,l,f).call(this,t).type!=="file")throw new p("EISDIR","Is a directory");let i=o(this,l,v).call(this);return s(this,F).set(i,t),s(this,O).set(t,i),i}readdir(t){let e=o(this,l,f).call(this,t);if(e.type!=="directory")throw new p("ENOTDIR","Not a directory");return Object.keys(e.children)}read(t,e,a,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");return s(this,y).get(c.backingFilename).read(new Uint8Array(e.buffer,a,i),{at:h})}rename(t,e){o(this,l,E).call(this,{opp:"rename",args:[t,e]},()=>{this._renameState(t,e,!0)})}_renameState(t,e,a=!1){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(!Object.prototype.hasOwnProperty.call(r.children,h))throw new p("ENOENT","No such file or directory");let c=o(this,l,g).call(this,e),d=c.pop(),n=o(this,l,f).call(this,c.join("/"));if(a&&Object.prototype.hasOwnProperty.call(n.children,d)){let u=n.children[d];s(this,y).get(u.backingFilename).truncate(0),this.state.pool.push(u.backingFilename)}n.children[d]=r.children[h],delete r.children[h]}rmdir(t){o(this,l,E).call(this,{opp:"rmdir",args:[t]},()=>{this._rmdirState(t)})}_rmdirState(t){let e=o(this,l,g).call(this,t),a=e.pop(),i=o(this,l,f).call(this,e.join("/"));if(!Object.prototype.hasOwnProperty.call(i.children,a))throw new p("ENOENT","No such file or directory");let h=i.children[a];if(h.type!=="directory")throw new p("ENOTDIR","Not a directory");if(Object.keys(h.children).length>0)throw new p("ENOTEMPTY","Directory not empty");delete i.children[a]}truncate(t,e=0){let a=o(this,l,f).call(this,t);if(a.type!=="file")throw new p("EISDIR","Is a directory");let i=s(this,y).get(a.backingFilename);if(!i)throw new p("ENOENT","No such file or directory");i.truncate(e),s(this,S).add(i)}unlink(t){o(this,l,E).call(this,{opp:"unlink",args:[t]},()=>{this._unlinkState(t,!0)})}_unlinkState(t,e=!1){let a=o(this,l,g).call(this,t),i=a.pop(),h=o(this,l,f).call(this,a.join("/"));if(!Object.prototype.hasOwnProperty.call(h.children,i))throw new p("ENOENT","No such file or directory");let r=h.children[i];if(r.type!=="file")throw new p("EISDIR","Is a directory");if(delete h.children[i],e){let c=s(this,y).get(r.backingFilename);c?.truncate(0),s(this,S).add(c),s(this,O).has(t)&&(s(this,F).delete(s(this,O).get(t)),s(this,O).delete(t))}this.state.pool.push(r.backingFilename)}utimes(t,e,a){o(this,l,E).call(this,{opp:"utimes",args:[t,e,a]},()=>{this._utimesState(t,e,a)})}_utimesState(t,e,a){let i=o(this,l,f).call(this,t);i.lastModified=a}writeFile(t,e,a){let i=o(this,l,g).call(this,t),h=i.pop(),r=o(this,l,f).call(this,i.join("/"));if(Object.prototype.hasOwnProperty.call(r.children,h)){let n=r.children[h];n.lastModified=Date.now(),o(this,l,M).call(this,{opp:"setLastModified",args:[t,n.lastModified]})}else{if(this.state.pool.length===0)throw new Error("No more file handles available in the pool");let n={type:"file",lastModified:Date.now(),mode:a?.mode||W.FILE,backingFilename:this.state.pool.pop()};r.children[h]=n,o(this,l,M).call(this,{opp:"createFileNode",args:[t,n]})}let c=r.children[h],d=s(this,y).get(c.backingFilename);e.length>0&&(d.write(typeof e=="string"?new TextEncoder().encode(e):new Uint8Array(e),{at:0}),t.startsWith("/pg_wal")&&s(this,S).add(d))}_createFileNodeState(t,e){let a=o(this,l,g).call(this,t),i=a.pop(),h=o(this,l,f).call(this,a.join("/"));h.children[i]=e;let r=this.state.pool.indexOf(e.backingFilename);return r>-1&&this.state.pool.splice(r,1),e}_setLastModifiedState(t,e){let a=o(this,l,f).call(this,t);a.lastModified=e}write(t,e,a,i,h){let r=o(this,l,D).call(this,t),c=o(this,l,f).call(this,r);if(c.type!=="file")throw new p("EISDIR","Is a directory");let d=s(this,y).get(c.backingFilename);if(!d)throw new p("EBADF","Bad file descriptor");let n=d.write(new Uint8Array(e,a,i),{at:h});return r.startsWith("/pg_wal")&&s(this,S).add(d),n}};T=new WeakMap,I=new WeakMap,N=new WeakMap,_=new WeakMap,w=new WeakMap,k=new WeakMap,y=new WeakMap,j=new WeakMap,F=new WeakMap,O=new WeakMap,S=new WeakMap,l=new WeakSet,R=async function(){P(this,T,await navigator.storage.getDirectory()),P(this,I,await o(this,l,x).call(this,this.dataDir,{create:!0})),P(this,N,await o(this,l,x).call(this,L,{from:s(this,I),create:!0})),P(this,_,await s(this,I).getFileHandle(B,{create:!0})),P(this,w,await s(this,_).createSyncAccessHandle());let t=new ArrayBuffer(s(this,w).getSize());s(this,w).read(t,{at:0});let e,a=new TextDecoder().decode(t).split(`
2
2
  `),i=!1;try{e=JSON.parse(a[0])}catch{e={root:{type:"directory",lastModified:Date.now(),mode:W.DIR,children:{}},pool:[]},s(this,w).truncate(0),s(this,w).write(new TextEncoder().encode(JSON.stringify(e)),{at:0}),i=!0}this.state=e;let h=a.slice(1).filter(Boolean).map(n=>JSON.parse(n));for(let n of h){let u=`_${n.opp}State`;if(typeof this[u]=="function")try{this[u].bind(this)(...n.args)}catch(b){console.warn("Error applying OPFS AHP WAL entry",n,b)}}let r=[],c=async n=>{if(n.type==="file")try{let u=await s(this,N).getFileHandle(n.backingFilename),b=await u.createSyncAccessHandle();s(this,k).set(n.backingFilename,u),s(this,y).set(n.backingFilename,b)}catch(u){console.error("Error opening file handle for node",n,u)}else for(let u of Object.values(n.children))r.push(c(u))};await c(this.state.root);let d=[];for(let n of this.state.pool)d.push(new Promise(async u=>{s(this,k).has(n)&&console.warn("File handle already exists for pool file",n);let b=await s(this,N).getFileHandle(n),z=await b.createSyncAccessHandle();s(this,k).set(n,b),s(this,y).set(n,z),u()}));await Promise.all([...r,...d]),await this.maintainPool(i?this.initialPoolSize:this.maintainedPoolSize)},E=function(t,e){let a=o(this,l,M).call(this,t);try{e()}catch(i){throw s(this,w).truncate(a),i}},M=function(t){let e=JSON.stringify(t),a=new TextEncoder().encode(`
3
3
  ${e}`),i=s(this,w).getSize();return s(this,w).write(a,{at:i}),s(this,S).add(s(this,w)),i},g=function(t){return t.split("/").filter(Boolean)},f=function(t,e){let a=o(this,l,g).call(this,t),i=e||this.state.root;for(let h of a){if(i.type!=="directory")throw new p("ENOTDIR","Not a directory");if(!Object.prototype.hasOwnProperty.call(i.children,h))throw new p("ENOENT","No such file or directory");i=i.children[h]}return i},D=function(t){let e=s(this,F).get(t);if(!e)throw new p("EBADF","Bad file descriptor");return e},v=function(){let t=++$(this,j)._;for(;s(this,F).has(t);)$(this,j)._++;return t},x=async function(t,e){let a=o(this,l,g).call(this,t),i=e?.from||s(this,T);for(let h of a)i=await i.getDirectoryHandle(h,{create:e?.create});return i};var p=class extends Error{constructor(t,e){super(e),typeof t=="number"?this.code=t:typeof t=="string"&&(this.code=A[t])}};export{rt as OpfsAhpFS};