@powerhousedao/connect 4.0.0-staging.1 → 4.0.0-staging.2

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 (58) hide show
  1. package/dist/assets/{AddDriveModal.B3Lc0Bve.js → AddDriveModal.DrmSTNsa.js} +2 -2
  2. package/dist/assets/{AddDriveModal.B3Lc0Bve.js.map → AddDriveModal.DrmSTNsa.js.map} +1 -1
  3. package/dist/assets/{CreateDocumentModal.BgY0HJIG.js → CreateDocumentModal.CGzc2dXN.js} +2 -2
  4. package/dist/assets/{CreateDocumentModal.BgY0HJIG.js.map → CreateDocumentModal.CGzc2dXN.js.map} +1 -1
  5. package/dist/assets/{DebugSettingsModal.CLXuq_T3.js → DebugSettingsModal.CWRYCw7H.js} +2 -2
  6. package/dist/assets/{DebugSettingsModal.CLXuq_T3.js.map → DebugSettingsModal.CWRYCw7H.js.map} +1 -1
  7. package/dist/assets/{SettingsModal.nsp7JEwj.js → SettingsModal.BYFtZAn8.js} +2 -2
  8. package/dist/assets/{SettingsModal.nsp7JEwj.js.map → SettingsModal.BYFtZAn8.js.map} +1 -1
  9. package/dist/assets/{app.Cczb-JTX.js → app.B0JuK2td.js} +4 -4
  10. package/dist/assets/{app.Cczb-JTX.js.map → app.B0JuK2td.js.map} +1 -1
  11. package/dist/assets/{atlas-import.B29EKWNS.js → atlas-import.Ek2RkKZ9.js} +2 -2
  12. package/dist/assets/{atlas-import.B29EKWNS.js.map → atlas-import.Ek2RkKZ9.js.map} +1 -1
  13. package/dist/assets/{connect.config.Dg2s1YFW.js → connect.config.rJjJZvYA.js} +2 -2
  14. package/dist/assets/{connect.config.Dg2s1YFW.js.map → connect.config.rJjJZvYA.js.map} +1 -1
  15. package/dist/assets/{content.Cx8CEoWU.js → content.pq0QIQ7J.js} +2 -2
  16. package/dist/assets/{content.Cx8CEoWU.js.map → content.pq0QIQ7J.js.map} +1 -1
  17. package/dist/assets/{cookie-banner.Bv934T2f.js → cookie-banner.CUkkO0Bv.js} +2 -2
  18. package/dist/assets/{cookie-banner.Bv934T2f.js.map → cookie-banner.CUkkO0Bv.js.map} +1 -1
  19. package/dist/assets/{home.C3xtsAKL.js → home.B5q71Wn7.js} +2 -2
  20. package/dist/assets/{home.C3xtsAKL.js.map → home.B5q71Wn7.js.map} +1 -1
  21. package/dist/assets/{index.DCVNtj9Q.js → index.BEglXqsU.js} +2 -2
  22. package/dist/assets/{index.DCVNtj9Q.js.map → index.BEglXqsU.js.map} +1 -1
  23. package/dist/assets/{index.DAt-A6aw.js → index.BmFhyB1Q.js} +2 -2
  24. package/dist/assets/{index.DAt-A6aw.js.map → index.BmFhyB1Q.js.map} +1 -1
  25. package/dist/assets/{index.B35eoM_p.js → index.CKisJNRj.js} +3 -3
  26. package/dist/assets/{index.B35eoM_p.js.map → index.CKisJNRj.js.map} +1 -1
  27. package/dist/assets/{index.CnxSc8u3.js → index.D-Wc4Q7C.js} +2 -2
  28. package/dist/assets/{index.CnxSc8u3.js.map → index.D-Wc4Q7C.js.map} +1 -1
  29. package/dist/assets/{index.DYajOAfv.js → index.DVp7KuB0.js} +2 -2
  30. package/dist/assets/{index.DYajOAfv.js.map → index.DVp7KuB0.js.map} +1 -1
  31. package/dist/assets/{index.DhtCB3qX.js → index.DYY-7jd2.js} +2 -2
  32. package/dist/assets/{index.DhtCB3qX.js.map → index.DYY-7jd2.js.map} +1 -1
  33. package/dist/assets/{main.DRWC5RhA.js → main.DpXjv5NU.js} +3 -3
  34. package/dist/assets/{main.DRWC5RhA.js.map → main.DpXjv5NU.js.map} +1 -1
  35. package/dist/assets/{modal.CoChI3Z8.js → modal.I0jBpvq1.js} +3 -3
  36. package/dist/assets/{modal.CoChI3Z8.js.map → modal.I0jBpvq1.js.map} +1 -1
  37. package/dist/assets/{modals.BDBwwAHa.js → modals.Dn_ncIrB.js} +2 -2
  38. package/dist/assets/{modals.BDBwwAHa.js.map → modals.Dn_ncIrB.js.map} +1 -1
  39. package/dist/assets/{registerServiceWorker.DTjJlxaP.js → registerServiceWorker.CFFodjhC.js} +2 -2
  40. package/dist/assets/{registerServiceWorker.DTjJlxaP.js.map → registerServiceWorker.CFFodjhC.js.map} +1 -1
  41. package/dist/assets/{root.BgZ2UXeU.js → root.CdBb-EYv.js} +2 -2
  42. package/dist/assets/{root.BgZ2UXeU.js.map → root.CdBb-EYv.js.map} +1 -1
  43. package/dist/assets/{useAcceptedCookies.B0GL_rH8.js → useAcceptedCookies.CRzVdFNU.js} +2 -2
  44. package/dist/assets/{useAcceptedCookies.B0GL_rH8.js.map → useAcceptedCookies.CRzVdFNU.js.map} +1 -1
  45. package/dist/assets/useConnectConfig.BRbXRrbe.js +2 -0
  46. package/dist/assets/{useConnectConfig.Dk_0m-Ti.js.map → useConnectConfig.BRbXRrbe.js.map} +1 -1
  47. package/dist/assets/{useDefaultDocumentModelEditor.CWI3XcpL.js → useDefaultDocumentModelEditor.Cpfnx_NF.js} +2 -2
  48. package/dist/assets/{useDefaultDocumentModelEditor.CWI3XcpL.js.map → useDefaultDocumentModelEditor.Cpfnx_NF.js.map} +1 -1
  49. package/dist/assets/{useDocumentDriveServer.BCFajpQ5.js → useDocumentDriveServer.C9u3SgiH.js} +2 -2
  50. package/dist/assets/{useDocumentDriveServer.BCFajpQ5.js.map → useDocumentDriveServer.C9u3SgiH.js.map} +1 -1
  51. package/dist/assets/{useFeatureFlags.DwHJ60S4.js → useFeatureFlags.DceCFoAY.js} +2 -2
  52. package/dist/assets/{useFeatureFlags.DwHJ60S4.js.map → useFeatureFlags.DceCFoAY.js.map} +1 -1
  53. package/dist/assets/{user.GGI-kGd1.js → user.SniiwLvT.js} +4 -4
  54. package/dist/assets/{user.GGI-kGd1.js.map → user.SniiwLvT.js.map} +1 -1
  55. package/dist/index.html +1 -1
  56. package/dist/vite-envs.sh +1 -1
  57. package/package.json +9 -9
  58. package/dist/assets/useConnectConfig.Dk_0m-Ti.js +0 -2
@@ -1,2 +1,2 @@
1
- var v=Object.defineProperty;var _=(r,e,t)=>e in r?v(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var S=(r,e,t)=>_(r,typeof e!="symbol"?e+"":e,t);import{c as O}from"./index.Ds87Cbij.js";import{A as n,D as I}from"./app.Cczb-JTX.js";import"react";import"react/jsx-runtime";import"react-dom";import"./connect.config.Dg2s1YFW.js";import"./browser.BkwNmV2Z.js";import"./user.GGI-kGd1.js";import"./index.B35eoM_p.js";import"react-dom/client";import"./app-skeleton.js";import"./useFeatureFlags.DwHJ60S4.js";import"./useAcceptedCookies.B0GL_rH8.js";import"./useConnectConfig.Dk_0m-Ti.js";import"./index.CAUjMUXb.js";import"./registerServiceWorker.DTjJlxaP.js";class w{constructor(e,t=O(["processor","document-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/doc/${t.driveId}/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{driveId:s,documentId:f,branch:E,scope:a}=t,p=s===f?"DRIVE":"NODE",l=50;for(let o=0;o<t.operations.length;o+=l){const i=t.operations.slice(o,o+l),c=[];for(const d of i){const g=d.index,h={source:u,metric:"DocumentOperations",start:I.fromISO(d.timestamp),value:1,dimensions:{drive:n.fromString(`ph/doc/drive/${s}/${E}/${a}/${g}`),operation:n.fromString(`ph/doc/operation/${d.type}/${d.index}`),target:n.fromString(`ph/doc/target/${s}/${p}/${f}`)}};for(c.push(h);c.length>=l;){const y=c.splice(0,l);await this.analyticsStore.addSeriesValues(y)}}c.length>0&&await this.analyticsStore.addSeriesValues(c)}}}async onDisconnect(){}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const $=["ADD_FILE","ADD_FOLDER"],T=["COPY_NODE"],C=["UPDATE_FILE","UPDATE_NODE"],A=["MOVE_NODE"],N=["DELETE_NODE"],V=[...$,...T,...C,...A,...N];class b{constructor(e,t=O(["processor","drive-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/drive/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{documentId:s,branch:f,scope:E}=t,a=50;for(let p=0;p<t.operations.length;p+=a){const l=t.operations.slice(p,p+a),o=[];for(const i of l){const c=i.index,d=this.getActionType(i.type),g=V.includes(i.type)?"NODE":"DRIVE";let h=s;if(g==="NODE"){const m=i.input;h=m.id||m.targetId||m.srcFolder||s}const y={source:u,metric:"DriveOperations",start:I.fromISO(i.timestamp),value:1,dimensions:{drive:n.fromString(`ph/drive/${s}/${f}/${E}/${c}`),operation:n.fromString(`ph/drive/operation/${i.type}/${i.index}`),target:n.fromString(`ph/drive/target/${g}/${h}`),actionType:n.fromString(`ph/drive/actionType/${d}/${h}`)}};for(o.push(y);o.length>=a;){const m=o.splice(0,a);await this.analyticsStore.addSeriesValues(m)}}o.length>0&&await this.analyticsStore.addSeriesValues(o)}}}async onDisconnect(){}getActionType(e){return $.includes(e)?"CREATED":T.includes(e)?"DUPLICATED":N.includes(e)?"REMOVED":A.includes(e)?"MOVED":"UPDATED"}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const J=r=>e=>[{processor:new b(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["powerhouse/document-drive"]}},{processor:new w(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{w as DocumentAnalyticsProcessor,b as DriveAnalyticsProcessor,J as processorFactory};
2
- //# sourceMappingURL=index.DYajOAfv.js.map
1
+ var v=Object.defineProperty;var _=(r,e,t)=>e in r?v(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var S=(r,e,t)=>_(r,typeof e!="symbol"?e+"":e,t);import{c as O}from"./index.Ds87Cbij.js";import{A as n,D as I}from"./app.B0JuK2td.js";import"react";import"react/jsx-runtime";import"react-dom";import"./connect.config.rJjJZvYA.js";import"./browser.BkwNmV2Z.js";import"./user.SniiwLvT.js";import"./index.CKisJNRj.js";import"react-dom/client";import"./app-skeleton.js";import"./useFeatureFlags.DceCFoAY.js";import"./useAcceptedCookies.CRzVdFNU.js";import"./useConnectConfig.BRbXRrbe.js";import"./index.CAUjMUXb.js";import"./registerServiceWorker.CFFodjhC.js";class w{constructor(e,t=O(["processor","document-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/doc/${t.driveId}/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{driveId:s,documentId:f,branch:E,scope:a}=t,p=s===f?"DRIVE":"NODE",l=50;for(let o=0;o<t.operations.length;o+=l){const i=t.operations.slice(o,o+l),c=[];for(const d of i){const g=d.index,h={source:u,metric:"DocumentOperations",start:I.fromISO(d.timestamp),value:1,dimensions:{drive:n.fromString(`ph/doc/drive/${s}/${E}/${a}/${g}`),operation:n.fromString(`ph/doc/operation/${d.type}/${d.index}`),target:n.fromString(`ph/doc/target/${s}/${p}/${f}`)}};for(c.push(h);c.length>=l;){const y=c.splice(0,l);await this.analyticsStore.addSeriesValues(y)}}c.length>0&&await this.analyticsStore.addSeriesValues(c)}}}async onDisconnect(){}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const $=["ADD_FILE","ADD_FOLDER"],T=["COPY_NODE"],C=["UPDATE_FILE","UPDATE_NODE"],A=["MOVE_NODE"],N=["DELETE_NODE"],V=[...$,...T,...C,...A,...N];class b{constructor(e,t=O(["processor","drive-analytics"])){S(this,"analyticsStore");S(this,"logger");this.analyticsStore=e,this.logger=t}async onStrands(e){if(e.length!==0)for(const t of e){if(t.operations.length===0)continue;const D=t.operations[0],u=n.fromString(`ph/drive/${t.documentId}/${t.branch}/${t.scope}`);D.index===0&&await this.clearSource(u);const{documentId:s,branch:f,scope:E}=t,a=50;for(let p=0;p<t.operations.length;p+=a){const l=t.operations.slice(p,p+a),o=[];for(const i of l){const c=i.index,d=this.getActionType(i.type),g=V.includes(i.type)?"NODE":"DRIVE";let h=s;if(g==="NODE"){const m=i.input;h=m.id||m.targetId||m.srcFolder||s}const y={source:u,metric:"DriveOperations",start:I.fromISO(i.timestamp),value:1,dimensions:{drive:n.fromString(`ph/drive/${s}/${f}/${E}/${c}`),operation:n.fromString(`ph/drive/operation/${i.type}/${i.index}`),target:n.fromString(`ph/drive/target/${g}/${h}`),actionType:n.fromString(`ph/drive/actionType/${d}/${h}`)}};for(o.push(y);o.length>=a;){const m=o.splice(0,a);await this.analyticsStore.addSeriesValues(m)}}o.length>0&&await this.analyticsStore.addSeriesValues(o)}}}async onDisconnect(){}getActionType(e){return $.includes(e)?"CREATED":T.includes(e)?"DUPLICATED":N.includes(e)?"REMOVED":A.includes(e)?"MOVED":"UPDATED"}async clearSource(e){try{await this.analyticsStore.clearSeriesBySource(e,!0)}catch(t){this.logger.error("Failed to clear source",t)}}}const J=r=>e=>[{processor:new b(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["powerhouse/document-drive"]}},{processor:new w(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{w as DocumentAnalyticsProcessor,b as DriveAnalyticsProcessor,J as processorFactory};
2
+ //# sourceMappingURL=index.DVp7KuB0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.DYajOAfv.js","sources":["../../../../packages/common/dist/drive-analytics/processor/document-processor.js","../../../../packages/common/dist/drive-analytics/processor/drive-processor.js","../../../../packages/common/dist/drive-analytics/processor/index.js"],"sourcesContent":["import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nexport class DocumentAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"document-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/doc/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { driveId, documentId, branch, scope } = strand;\n const target = driveId === documentId ? \"DRIVE\" : \"NODE\";\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const seriesInput = {\n source,\n metric: \"DocumentOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/doc/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/doc/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/doc/target/${driveId}/${target}/${documentId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=document-processor.js.map","import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nconst CREATE_NODE_ACTIONS = [\"ADD_FILE\", \"ADD_FOLDER\"];\nconst DUPLICATE_NODE_ACTIONS = [\"COPY_NODE\"];\nconst UPDATE_NODE_ACTIONS = [\"UPDATE_FILE\", \"UPDATE_NODE\"];\nconst MOVE_NODE_ACTIONS = [\"MOVE_NODE\"];\nconst REMOVE_NODE_ACTIONS = [\"DELETE_NODE\"];\nconst NODE_ACTIONS = [\n ...CREATE_NODE_ACTIONS,\n ...DUPLICATE_NODE_ACTIONS,\n ...UPDATE_NODE_ACTIONS,\n ...MOVE_NODE_ACTIONS,\n ...REMOVE_NODE_ACTIONS,\n];\nexport class DriveAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"drive-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/drive/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { documentId: driveId, branch, scope } = strand;\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const actionType = this.getActionType(operation.type);\n const target = NODE_ACTIONS.includes(operation.type)\n ? \"NODE\"\n : \"DRIVE\";\n let targetId = driveId;\n if (target === \"NODE\") {\n const operationInput = operation.input;\n targetId =\n operationInput.id ||\n operationInput.targetId ||\n operationInput.srcFolder ||\n driveId;\n }\n const seriesInput = {\n source,\n metric: \"DriveOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/drive/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/drive/target/${target}/${targetId}`),\n actionType: AnalyticsPath.fromString(`ph/drive/actionType/${actionType}/${targetId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n getActionType(action) {\n if (CREATE_NODE_ACTIONS.includes(action)) {\n return \"CREATED\";\n }\n if (DUPLICATE_NODE_ACTIONS.includes(action)) {\n return \"DUPLICATED\";\n }\n if (REMOVE_NODE_ACTIONS.includes(action)) {\n return \"REMOVED\";\n }\n if (MOVE_NODE_ACTIONS.includes(action)) {\n return \"MOVED\";\n }\n return \"UPDATED\";\n }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=drive-processor.js.map","import { DocumentAnalyticsProcessor } from \"./document-processor.js\";\nimport { DriveAnalyticsProcessor } from \"./drive-processor.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DriveAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"powerhouse/document-drive\"],\n },\n },\n {\n processor: new DocumentAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\nexport * from \"./document-processor.js\";\nexport * from \"./drive-processor.js\";\n//# sourceMappingURL=index.js.map"],"names":["DocumentAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","driveId","documentId","branch","scope","target","CHUNK_SIZE","i","chunk","buffer","operation","revision","seriesInput","DateTime","batch","e","CREATE_NODE_ACTIONS","DUPLICATE_NODE_ACTIONS","UPDATE_NODE_ACTIONS","MOVE_NODE_ACTIONS","REMOVE_NODE_ACTIONS","NODE_ACTIONS","DriveAnalyticsProcessor","actionType","targetId","operationInput","action","processorFactory","module"],"mappings":"8pBAEO,MAAMA,CAA2B,CAGpC,YAAYC,EAAgBC,EAASC,EAAY,CAAC,YAAa,oBAAoB,CAAC,EAAG,CAFvFC,EAAA,uBACAA,EAAA,eAEI,KAAK,eAAiBH,EACtB,KAAK,OAASC,CAEtB,CACI,MAAM,UAAUG,EAAS,CACrB,GAAIA,EAAQ,SAAW,EAGvB,UAAWC,KAAUD,EAAS,CAE1B,GAAIC,EAAO,WAAW,SAAW,EAC7B,SAEJ,MAAMC,EAAUD,EAAO,WAAW,CAAC,EAC7BE,EAASC,EAAc,WAAW,UAAUH,EAAO,OAAO,IAAIA,EAAO,UAAU,IAAIA,EAAO,MAAM,IAAIA,EAAO,KAAK,EAAE,EACpHC,EAAQ,QAAU,GAClB,MAAM,KAAK,YAAYC,CAAM,EAEjC,KAAM,CAAE,QAAAE,EAAS,WAAAC,EAAY,OAAAC,EAAQ,MAAAC,CAAK,EAAKP,EACzCQ,EAASJ,IAAYC,EAAa,QAAU,OAC5CI,EAAa,GACnB,QAASC,EAAI,EAAGA,EAAIV,EAAO,WAAW,OAAQU,GAAKD,EAAY,CAC3D,MAAME,EAAQX,EAAO,WAAW,MAAMU,EAAGA,EAAID,CAAU,EACjDG,EAAS,CAAA,EACf,UAAWC,KAAaF,EAAO,CAC3B,MAAMG,EAAWD,EAAU,MACrBE,EAAc,CAChB,OAAAb,EACA,OAAQ,qBACR,MAAOc,EAAS,QAAQH,EAAU,SAAS,EAC3C,MAAO,EACP,WAAY,CACR,MAAOV,EAAc,WAAW,gBAAgBC,CAAO,IAAIE,CAAM,IAAIC,CAAK,IAAIO,CAAQ,EAAE,EACxF,UAAWX,EAAc,WAAW,oBAAoBU,EAAU,IAAI,IAAIA,EAAU,KAA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M,CAAM,EAC5B,UAEPP,EAAkB,SAASO,CAAM,EAC1B,QAEJ,SACf,CACI,MAAM,YAAY3B,EAAQ,CACtB,GAAI,CACA,MAAM,KAAK,eAAe,oBAAoBA,EAAQ,EAAI,CACtE,OACegB,EAAG,CACN,KAAK,OAAO,MAAM,yBAA0BA,CAAC,CACzD,CACA,CACA,CCtGY,MAACY,EAAoBC,GAAY3B,GAClC,CACH,CACI,UAAW,IAAIqB,EAAwBM,EAAO,cAAc,EAC5D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,2BAA2B,CAC1D,CACA,EACQ,CACI,UAAW,IAAIrC,EAA2BqC,EAAO,cAAc,EAC/D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CAClC,CACA,CACA"}
1
+ {"version":3,"file":"index.DVp7KuB0.js","sources":["../../../../packages/common/dist/drive-analytics/processor/document-processor.js","../../../../packages/common/dist/drive-analytics/processor/drive-processor.js","../../../../packages/common/dist/drive-analytics/processor/index.js"],"sourcesContent":["import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nexport class DocumentAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"document-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/doc/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { driveId, documentId, branch, scope } = strand;\n const target = driveId === documentId ? \"DRIVE\" : \"NODE\";\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const seriesInput = {\n source,\n metric: \"DocumentOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/doc/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/doc/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/doc/target/${driveId}/${target}/${documentId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=document-processor.js.map","import { AnalyticsPath, DateTime, } from \"@powerhousedao/reactor-browser/analytics\";\nimport { childLogger } from \"document-drive\";\nconst CREATE_NODE_ACTIONS = [\"ADD_FILE\", \"ADD_FOLDER\"];\nconst DUPLICATE_NODE_ACTIONS = [\"COPY_NODE\"];\nconst UPDATE_NODE_ACTIONS = [\"UPDATE_FILE\", \"UPDATE_NODE\"];\nconst MOVE_NODE_ACTIONS = [\"MOVE_NODE\"];\nconst REMOVE_NODE_ACTIONS = [\"DELETE_NODE\"];\nconst NODE_ACTIONS = [\n ...CREATE_NODE_ACTIONS,\n ...DUPLICATE_NODE_ACTIONS,\n ...UPDATE_NODE_ACTIONS,\n ...MOVE_NODE_ACTIONS,\n ...REMOVE_NODE_ACTIONS,\n];\nexport class DriveAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"drive-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n // skip empty strands\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/drive/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const { documentId: driveId, branch, scope } = strand;\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const revision = operation.index;\n const actionType = this.getActionType(operation.type);\n const target = NODE_ACTIONS.includes(operation.type)\n ? \"NODE\"\n : \"DRIVE\";\n let targetId = driveId;\n if (target === \"NODE\") {\n const operationInput = operation.input;\n targetId =\n operationInput.id ||\n operationInput.targetId ||\n operationInput.srcFolder ||\n driveId;\n }\n const seriesInput = {\n source,\n metric: \"DriveOperations\",\n start: DateTime.fromISO(operation.timestamp),\n value: 1,\n dimensions: {\n drive: AnalyticsPath.fromString(`ph/drive/${driveId}/${branch}/${scope}/${revision}`),\n operation: AnalyticsPath.fromString(`ph/drive/operation/${operation.type}/${operation.index}`),\n target: AnalyticsPath.fromString(`ph/drive/target/${target}/${targetId}`),\n actionType: AnalyticsPath.fromString(`ph/drive/actionType/${actionType}/${targetId}`),\n },\n };\n buffer.push(seriesInput);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n getActionType(action) {\n if (CREATE_NODE_ACTIONS.includes(action)) {\n return \"CREATED\";\n }\n if (DUPLICATE_NODE_ACTIONS.includes(action)) {\n return \"DUPLICATED\";\n }\n if (REMOVE_NODE_ACTIONS.includes(action)) {\n return \"REMOVED\";\n }\n if (MOVE_NODE_ACTIONS.includes(action)) {\n return \"MOVED\";\n }\n return \"UPDATED\";\n }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n}\n//# sourceMappingURL=drive-processor.js.map","import { DocumentAnalyticsProcessor } from \"./document-processor.js\";\nimport { DriveAnalyticsProcessor } from \"./drive-processor.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DriveAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"powerhouse/document-drive\"],\n },\n },\n {\n processor: new DocumentAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\nexport * from \"./document-processor.js\";\nexport * from \"./drive-processor.js\";\n//# sourceMappingURL=index.js.map"],"names":["DocumentAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","driveId","documentId","branch","scope","target","CHUNK_SIZE","i","chunk","buffer","operation","revision","seriesInput","DateTime","batch","e","CREATE_NODE_ACTIONS","DUPLICATE_NODE_ACTIONS","UPDATE_NODE_ACTIONS","MOVE_NODE_ACTIONS","REMOVE_NODE_ACTIONS","NODE_ACTIONS","DriveAnalyticsProcessor","actionType","targetId","operationInput","action","processorFactory","module"],"mappings":"8pBAEO,MAAMA,CAA2B,CAGpC,YAAYC,EAAgBC,EAASC,EAAY,CAAC,YAAa,oBAAoB,CAAC,EAAG,CAFvFC,EAAA,uBACAA,EAAA,eAEI,KAAK,eAAiBH,EACtB,KAAK,OAASC,CAEtB,CACI,MAAM,UAAUG,EAAS,CACrB,GAAIA,EAAQ,SAAW,EAGvB,UAAWC,KAAUD,EAAS,CAE1B,GAAIC,EAAO,WAAW,SAAW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C,EAA2BqC,EAAO,cAAc,EAC/D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CAClC,CACA,CACA"}
@@ -1,2 +1,2 @@
1
- var m=Object.defineProperty;var y=(r,t,e)=>t in r?m(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>y(r,typeof t!="symbol"?t+"":t,e);import{A as d,D as $}from"./app.Cczb-JTX.js";import{c as S,w as v}from"./index.Ds87Cbij.js";import"react/jsx-runtime";import"react";import"./connect.config.Dg2s1YFW.js";import"./browser.BkwNmV2Z.js";import"./user.GGI-kGd1.js";import"./index.B35eoM_p.js";import"react-dom/client";import"./app-skeleton.js";import"./useFeatureFlags.DwHJ60S4.js";import"./useAcceptedCookies.B0GL_rH8.js";import"./useConnectConfig.Dk_0m-Ti.js";import"react-dom";import"./index.CAUjMUXb.js";import"./registerServiceWorker.DTjJlxaP.js";function w(r,t){const e=[],i=h(r,t,"state.global","global");e.push(...i);const o=e.filter(l=>l.type==="add").length,a=e.filter(l=>l.type==="remove").length,s={global:e.filter(l=>l.scope==="global")};return{totalChanges:e.length,additions:o,removals:a,changesByScope:s,changes:e}}function h(r,t,e,i){const o=[];if(Array.isArray(r)&&Array.isArray(t)){let n=0;for(;n<r.length;n++){const c=r[n];if(!t[n])o.push(...h(c,typeof c=="string"?"":null,`${e}[${n}]`,i));else{const f=h(c,t[n],`${e}[${n}]`,i);o.push(...f)}}for(;n<t.length;n++){const c=t[n];if(!r[n])o.push(...h(typeof c=="string"?"":null,c,`${e}[${n}]`,i));else{const f=h(r[n],c,`${e}[${n}]`,i);o.push(...f)}}return o}if(typeof r!="object"||typeof t!="object"||r===null||t===null){if(r!==t){if(typeof r=="string"&&typeof t=="string")return A(r,t,e,i);o.push({type:"remove",path:e,oldValue:r,scope:i}),o.push({type:"add",path:e,newValue:t,scope:i})}return o}const a=r,s=t,l=Object.keys(a),p=Object.keys(s);for(const n of l)n in s||o.push({type:"remove",path:`${e}.${n}`,oldValue:a[n],scope:i});for(const n of p)if(!(n in a))o.push({type:"add",path:`${e}.${n}`,newValue:s[n],scope:i});else if(a[n]!==s[n]){const c=h(a[n],s[n],`${e}.${n}`,i);o.push(...c)}return o}function A(r,t,e,i){const o=[],a=Math.max(r.length,t.length);for(let s=0;s<a;s++)s>=r.length?o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}):s>=t.length?o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}):r[s]!==t[s]&&(o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}),o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}));return o}class V{constructor(t,e=S(["processor","diff-analytics"])){g(this,"analyticsStore");g(this,"logger");this.analyticsStore=t,this.logger=e}async onStrands(t){if(t.length!==0)for(const e of t){if(e.operations.length===0)continue;const i=e.operations[0],o=d.fromString(`ph/diff/${e.driveId}/${e.documentId}/${e.branch}/${e.scope}`);i.index===0&&await this.clearSource(o);const a=50;for(let s=0;s<e.operations.length;s+=a){const l=e.operations.slice(s,s+a),p=[];for(const n of l){const f=(await v(async()=>w(n.previousState,n.state))).changes.map(u=>this.generateInput(e.driveId,e.documentId,e.branch,e.scope,n.index,u.type,1,o,n.timestamp,u.path));for(p.push(...f);p.length>=a;){const u=p.splice(0,a);await this.analyticsStore.addSeriesValues(u)}}p.length>0&&await this.analyticsStore.addSeriesValues(p)}}}async onDisconnect(){}async clearSource(t){try{await this.analyticsStore.clearSeriesBySource(t,!0)}catch(e){this.logger.error("Failed to clear source",e)}}generateInput(t,e,i,o,a,s,l,p,n,c){const f={},u=c.split("[")[0].replaceAll(".","/");return f.changes=d.fromString(`ph/diff/changes/${s}`),f.document=d.fromString(`ph/diff/document/${e}/${i}/${o}/${a}`),f.path=d.fromString(`ph/diff/path/${u}`),f.drive=d.fromString(`ph/diff/drive/${t}/${e}`),{dimensions:f,metric:"Count",start:$.fromISO(n),source:p,value:l}}}const U=r=>t=>[{processor:new V(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{U as processorFactory};
2
- //# sourceMappingURL=index.DhtCB3qX.js.map
1
+ var m=Object.defineProperty;var y=(r,t,e)=>t in r?m(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var g=(r,t,e)=>y(r,typeof t!="symbol"?t+"":t,e);import{A as d,D as $}from"./app.B0JuK2td.js";import{c as S,w as v}from"./index.Ds87Cbij.js";import"react/jsx-runtime";import"react";import"./connect.config.rJjJZvYA.js";import"./browser.BkwNmV2Z.js";import"./user.SniiwLvT.js";import"./index.CKisJNRj.js";import"react-dom/client";import"./app-skeleton.js";import"./useFeatureFlags.DceCFoAY.js";import"./useAcceptedCookies.CRzVdFNU.js";import"./useConnectConfig.BRbXRrbe.js";import"react-dom";import"./index.CAUjMUXb.js";import"./registerServiceWorker.CFFodjhC.js";function w(r,t){const e=[],i=h(r,t,"state.global","global");e.push(...i);const o=e.filter(l=>l.type==="add").length,a=e.filter(l=>l.type==="remove").length,s={global:e.filter(l=>l.scope==="global")};return{totalChanges:e.length,additions:o,removals:a,changesByScope:s,changes:e}}function h(r,t,e,i){const o=[];if(Array.isArray(r)&&Array.isArray(t)){let n=0;for(;n<r.length;n++){const c=r[n];if(!t[n])o.push(...h(c,typeof c=="string"?"":null,`${e}[${n}]`,i));else{const f=h(c,t[n],`${e}[${n}]`,i);o.push(...f)}}for(;n<t.length;n++){const c=t[n];if(!r[n])o.push(...h(typeof c=="string"?"":null,c,`${e}[${n}]`,i));else{const f=h(r[n],c,`${e}[${n}]`,i);o.push(...f)}}return o}if(typeof r!="object"||typeof t!="object"||r===null||t===null){if(r!==t){if(typeof r=="string"&&typeof t=="string")return A(r,t,e,i);o.push({type:"remove",path:e,oldValue:r,scope:i}),o.push({type:"add",path:e,newValue:t,scope:i})}return o}const a=r,s=t,l=Object.keys(a),p=Object.keys(s);for(const n of l)n in s||o.push({type:"remove",path:`${e}.${n}`,oldValue:a[n],scope:i});for(const n of p)if(!(n in a))o.push({type:"add",path:`${e}.${n}`,newValue:s[n],scope:i});else if(a[n]!==s[n]){const c=h(a[n],s[n],`${e}.${n}`,i);o.push(...c)}return o}function A(r,t,e,i){const o=[],a=Math.max(r.length,t.length);for(let s=0;s<a;s++)s>=r.length?o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}):s>=t.length?o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}):r[s]!==t[s]&&(o.push({type:"remove",path:`${e}[${s}]`,oldValue:r[s],scope:i}),o.push({type:"add",path:`${e}[${s}]`,newValue:t[s],scope:i}));return o}class V{constructor(t,e=S(["processor","diff-analytics"])){g(this,"analyticsStore");g(this,"logger");this.analyticsStore=t,this.logger=e}async onStrands(t){if(t.length!==0)for(const e of t){if(e.operations.length===0)continue;const i=e.operations[0],o=d.fromString(`ph/diff/${e.driveId}/${e.documentId}/${e.branch}/${e.scope}`);i.index===0&&await this.clearSource(o);const a=50;for(let s=0;s<e.operations.length;s+=a){const l=e.operations.slice(s,s+a),p=[];for(const n of l){const f=(await v(async()=>w(n.previousState,n.state))).changes.map(u=>this.generateInput(e.driveId,e.documentId,e.branch,e.scope,n.index,u.type,1,o,n.timestamp,u.path));for(p.push(...f);p.length>=a;){const u=p.splice(0,a);await this.analyticsStore.addSeriesValues(u)}}p.length>0&&await this.analyticsStore.addSeriesValues(p)}}}async onDisconnect(){}async clearSource(t){try{await this.analyticsStore.clearSeriesBySource(t,!0)}catch(e){this.logger.error("Failed to clear source",e)}}generateInput(t,e,i,o,a,s,l,p,n,c){const f={},u=c.split("[")[0].replaceAll(".","/");return f.changes=d.fromString(`ph/diff/changes/${s}`),f.document=d.fromString(`ph/diff/document/${e}/${i}/${o}/${a}`),f.path=d.fromString(`ph/diff/path/${u}`),f.drive=d.fromString(`ph/diff/drive/${t}/${e}`),{dimensions:f,metric:"Count",start:$.fromISO(n),source:p,value:l}}}const U=r=>t=>[{processor:new V(r.analyticsStore),filter:{branch:["main"],documentId:["*"],scope:["*"],documentType:["*"]}}];export{U as processorFactory};
2
+ //# sourceMappingURL=index.DYY-7jd2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.DhtCB3qX.js","sources":["../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/lib/document-diff.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/diff-analytics/index.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/index.js"],"sourcesContent":["/**\n * Calculates the difference between two document states\n */\nexport function diffDocumentStates(doc1, doc2) {\n const changes = [];\n // Compare global state\n const globalChanges = diffStateObjects(doc1, doc2, \"state.global\", \"global\");\n changes.push(...globalChanges);\n // Count changes by type\n const additions = changes.filter((c) => c.type === \"add\").length;\n const removals = changes.filter((c) => c.type === \"remove\").length;\n // Group changes by scope\n const changesByScope = {\n global: changes.filter((c) => c.scope === \"global\"),\n };\n return {\n totalChanges: changes.length,\n additions,\n removals,\n changesByScope,\n changes,\n };\n}\n/**\n * Recursively compares two state objects and returns a list of changes\n */\nfunction diffStateObjects(obj1, obj2, path, scope) {\n const changes = [];\n // Handle arrays\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n let index = 0;\n for (; index < obj1.length; index++) {\n const element = obj1[index];\n if (!obj2[index]) {\n changes.push(...diffStateObjects(element, typeof element === \"string\" ? \"\" : null, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(element, obj2[index], `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n for (; index < obj2.length; index++) {\n const element = obj2[index];\n if (!obj1[index]) {\n changes.push(...diffStateObjects(typeof element === \"string\" ? \"\" : null, element, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(obj1[index], element, `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n return changes;\n }\n // Handle primitive values\n if (typeof obj1 !== \"object\" ||\n typeof obj2 !== \"object\" ||\n obj1 === null ||\n obj2 === null) {\n if (obj1 !== obj2) {\n // Special handling for strings to diff character by character\n if (typeof obj1 === \"string\" && typeof obj2 === \"string\") {\n return diffStateStrings(obj1, obj2, path, scope);\n }\n else {\n // For non-string primitives, treat a change as a remove + add\n changes.push({\n type: \"remove\",\n path,\n oldValue: obj1,\n scope,\n });\n changes.push({\n type: \"add\",\n path,\n newValue: obj2,\n scope,\n });\n }\n }\n return changes;\n }\n // Handle objects\n const obj1Record = obj1;\n const obj2Record = obj2;\n const obj1Keys = Object.keys(obj1Record);\n const obj2Keys = Object.keys(obj2Record);\n // First, check for removed keys\n for (const key of obj1Keys) {\n if (!(key in obj2Record)) {\n // Key was removed\n changes.push({\n type: \"remove\",\n path: `${path}.${key}`,\n oldValue: obj1Record[key],\n scope,\n });\n }\n }\n // Then, check for added keys and modified values\n for (const key of obj2Keys) {\n if (!(key in obj1Record)) {\n // Key was added\n changes.push({\n type: \"add\",\n path: `${path}.${key}`,\n newValue: obj2Record[key],\n scope,\n });\n }\n else if (obj1Record[key] !== obj2Record[key]) {\n // For object changes, recursively diff the objects\n const nestedChanges = diffStateObjects(obj1Record[key], obj2Record[key], `${path}.${key}`, scope);\n changes.push(...nestedChanges);\n }\n }\n return changes;\n}\n/**\n * Compares two strings character by character and returns a list of changes\n */\nfunction diffStateStrings(str1, str2, path, scope) {\n const changes = [];\n const maxLen = Math.max(str1.length, str2.length);\n for (let i = 0; i < maxLen; i++) {\n if (i >= str1.length) {\n // Addition of new character\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n else if (i >= str2.length) {\n // Removal of character\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n }\n else if (str1[i] !== str2[i]) {\n // Character changed\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n }\n return changes;\n}\n/**\n * Generates analytics data from a state diff summary\n */\nexport function generateStateAnalyticsData(diff) {\n return {\n totalChanges: diff.totalChanges,\n changesByType: {\n add: diff.additions,\n remove: diff.removals,\n },\n changesByScope: {\n global: diff.changesByScope.global.length,\n },\n changePaths: diff.changes.map((c) => c.path),\n };\n}\n","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { DateTime } from \"luxon\";\nimport { diffDocumentStates } from \"../../lib/document-diff.js\";\nimport { childLogger } from \"document-drive\";\nimport { runAsapAsync } from \"document-drive/utils/misc\";\nexport class DiffAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"diff-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/diff/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const diff = await runAsapAsync(async () => diffDocumentStates(operation.previousState, operation.state));\n const inputs = diff.changes.map((change) => this.generateInput(strand.driveId, strand.documentId, strand.branch, strand.scope, operation.index, change.type, 1, source, operation.timestamp, change.path));\n buffer.push(...inputs);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n // Flush any remaining inputs\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n generateInput(driveId, documentId, branch, scope, revision, type, value, source, timestamp, path) {\n const dimensions = {};\n const changePath = path.split(\"[\")[0].replaceAll(\".\", \"/\");\n dimensions.changes = AnalyticsPath.fromString(`ph/diff/changes/${type}`);\n dimensions.document = AnalyticsPath.fromString(`ph/diff/document/${documentId}/${branch}/${scope}/${revision}`);\n dimensions.path = AnalyticsPath.fromString(`ph/diff/path/${changePath}`);\n dimensions.drive = AnalyticsPath.fromString(`ph/diff/drive/${driveId}/${documentId}`);\n return {\n dimensions,\n metric: \"Count\",\n start: DateTime.fromISO(timestamp),\n source,\n value,\n };\n }\n}\n","/**\n * This is a scaffold file meant for customization.\n * Delete the file and run the code generator again to have it reset\n */\nimport { DiffAnalyticsProcessor } from \"./diff-analytics/index.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DiffAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\n"],"names":["diffDocumentStates","doc1","doc2","changes","globalChanges","diffStateObjects","additions","c","removals","changesByScope","obj1","obj2","path","scope","index","element","elementChanges","diffStateStrings","obj1Record","obj2Record","obj1Keys","obj2Keys","key","nestedChanges","str1","str2","maxLen","i","DiffAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","CHUNK_SIZE","chunk","buffer","operation","inputs","runAsapAsync","change","batch","driveId","documentId","branch","revision","type","value","timestamp","dimensions","changePath","DateTime","processorFact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AAIC,CAAU,EAAE,EAC7E,CACH,WAAAM,EACA,OAAQ,QACR,MAAOE,EAAS,QAAQH,CAAS,EACjC,OAAAhB,EACA,MAAAe,CACZ,CACA,CACA,CCjEY,MAACK,EAAoBC,GAAYX,GAClC,CACH,CACI,UAAW,IAAIlB,EAAuB6B,EAAO,cAAc,EAC3D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CAClC,CACA,CACA","x_google_ignoreList":[0,1,2]}
1
+ {"version":3,"file":"index.DYY-7jd2.js","sources":["../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/lib/document-diff.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/diff-analytics/index.js","../../../../node_modules/.pnpm/@powerhousedao+diff-analyzer@0.0.0-dev.10_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@powerhousedao/diff-analyzer/dist/processors/index.js"],"sourcesContent":["/**\n * Calculates the difference between two document states\n */\nexport function diffDocumentStates(doc1, doc2) {\n const changes = [];\n // Compare global state\n const globalChanges = diffStateObjects(doc1, doc2, \"state.global\", \"global\");\n changes.push(...globalChanges);\n // Count changes by type\n const additions = changes.filter((c) => c.type === \"add\").length;\n const removals = changes.filter((c) => c.type === \"remove\").length;\n // Group changes by scope\n const changesByScope = {\n global: changes.filter((c) => c.scope === \"global\"),\n };\n return {\n totalChanges: changes.length,\n additions,\n removals,\n changesByScope,\n changes,\n };\n}\n/**\n * Recursively compares two state objects and returns a list of changes\n */\nfunction diffStateObjects(obj1, obj2, path, scope) {\n const changes = [];\n // Handle arrays\n if (Array.isArray(obj1) && Array.isArray(obj2)) {\n let index = 0;\n for (; index < obj1.length; index++) {\n const element = obj1[index];\n if (!obj2[index]) {\n changes.push(...diffStateObjects(element, typeof element === \"string\" ? \"\" : null, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(element, obj2[index], `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n for (; index < obj2.length; index++) {\n const element = obj2[index];\n if (!obj1[index]) {\n changes.push(...diffStateObjects(typeof element === \"string\" ? \"\" : null, element, `${path}[${index}]`, scope));\n }\n else {\n const elementChanges = diffStateObjects(obj1[index], element, `${path}[${index}]`, scope);\n changes.push(...elementChanges);\n }\n }\n return changes;\n }\n // Handle primitive values\n if (typeof obj1 !== \"object\" ||\n typeof obj2 !== \"object\" ||\n obj1 === null ||\n obj2 === null) {\n if (obj1 !== obj2) {\n // Special handling for strings to diff character by character\n if (typeof obj1 === \"string\" && typeof obj2 === \"string\") {\n return diffStateStrings(obj1, obj2, path, scope);\n }\n else {\n // For non-string primitives, treat a change as a remove + add\n changes.push({\n type: \"remove\",\n path,\n oldValue: obj1,\n scope,\n });\n changes.push({\n type: \"add\",\n path,\n newValue: obj2,\n scope,\n });\n }\n }\n return changes;\n }\n // Handle objects\n const obj1Record = obj1;\n const obj2Record = obj2;\n const obj1Keys = Object.keys(obj1Record);\n const obj2Keys = Object.keys(obj2Record);\n // First, check for removed keys\n for (const key of obj1Keys) {\n if (!(key in obj2Record)) {\n // Key was removed\n changes.push({\n type: \"remove\",\n path: `${path}.${key}`,\n oldValue: obj1Record[key],\n scope,\n });\n }\n }\n // Then, check for added keys and modified values\n for (const key of obj2Keys) {\n if (!(key in obj1Record)) {\n // Key was added\n changes.push({\n type: \"add\",\n path: `${path}.${key}`,\n newValue: obj2Record[key],\n scope,\n });\n }\n else if (obj1Record[key] !== obj2Record[key]) {\n // For object changes, recursively diff the objects\n const nestedChanges = diffStateObjects(obj1Record[key], obj2Record[key], `${path}.${key}`, scope);\n changes.push(...nestedChanges);\n }\n }\n return changes;\n}\n/**\n * Compares two strings character by character and returns a list of changes\n */\nfunction diffStateStrings(str1, str2, path, scope) {\n const changes = [];\n const maxLen = Math.max(str1.length, str2.length);\n for (let i = 0; i < maxLen; i++) {\n if (i >= str1.length) {\n // Addition of new character\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n else if (i >= str2.length) {\n // Removal of character\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n }\n else if (str1[i] !== str2[i]) {\n // Character changed\n changes.push({\n type: \"remove\",\n path: `${path}[${i}]`,\n oldValue: str1[i],\n scope,\n });\n changes.push({\n type: \"add\",\n path: `${path}[${i}]`,\n newValue: str2[i],\n scope,\n });\n }\n }\n return changes;\n}\n/**\n * Generates analytics data from a state diff summary\n */\nexport function generateStateAnalyticsData(diff) {\n return {\n totalChanges: diff.totalChanges,\n changesByType: {\n add: diff.additions,\n remove: diff.removals,\n },\n changesByScope: {\n global: diff.changesByScope.global.length,\n },\n changePaths: diff.changes.map((c) => c.path),\n };\n}\n","import { AnalyticsPath, } from \"@powerhousedao/analytics-engine-core\";\nimport { DateTime } from \"luxon\";\nimport { diffDocumentStates } from \"../../lib/document-diff.js\";\nimport { childLogger } from \"document-drive\";\nimport { runAsapAsync } from \"document-drive/utils/misc\";\nexport class DiffAnalyticsProcessor {\n analyticsStore;\n logger;\n constructor(analyticsStore, logger = childLogger([\"processor\", \"diff-analytics\"])) {\n this.analyticsStore = analyticsStore;\n this.logger = logger;\n //\n }\n async onStrands(strands) {\n if (strands.length === 0) {\n return;\n }\n for (const strand of strands) {\n if (strand.operations.length === 0) {\n continue;\n }\n const firstOp = strand.operations[0];\n const source = AnalyticsPath.fromString(`ph/diff/${strand.driveId}/${strand.documentId}/${strand.branch}/${strand.scope}`);\n if (firstOp.index === 0) {\n await this.clearSource(source);\n }\n const CHUNK_SIZE = 50;\n for (let i = 0; i < strand.operations.length; i += CHUNK_SIZE) {\n const chunk = strand.operations.slice(i, i + CHUNK_SIZE);\n const buffer = [];\n for (const operation of chunk) {\n const diff = await runAsapAsync(async () => diffDocumentStates(operation.previousState, operation.state));\n const inputs = diff.changes.map((change) => this.generateInput(strand.driveId, strand.documentId, strand.branch, strand.scope, operation.index, change.type, 1, source, operation.timestamp, change.path));\n buffer.push(...inputs);\n while (buffer.length >= CHUNK_SIZE) {\n const batch = buffer.splice(0, CHUNK_SIZE);\n await this.analyticsStore.addSeriesValues(batch);\n }\n }\n // Flush any remaining inputs\n if (buffer.length > 0) {\n await this.analyticsStore.addSeriesValues(buffer);\n }\n }\n }\n }\n async onDisconnect() { }\n async clearSource(source) {\n try {\n await this.analyticsStore.clearSeriesBySource(source, true);\n }\n catch (e) {\n this.logger.error(\"Failed to clear source\", e);\n }\n }\n generateInput(driveId, documentId, branch, scope, revision, type, value, source, timestamp, path) {\n const dimensions = {};\n const changePath = path.split(\"[\")[0].replaceAll(\".\", \"/\");\n dimensions.changes = AnalyticsPath.fromString(`ph/diff/changes/${type}`);\n dimensions.document = AnalyticsPath.fromString(`ph/diff/document/${documentId}/${branch}/${scope}/${revision}`);\n dimensions.path = AnalyticsPath.fromString(`ph/diff/path/${changePath}`);\n dimensions.drive = AnalyticsPath.fromString(`ph/diff/drive/${driveId}/${documentId}`);\n return {\n dimensions,\n metric: \"Count\",\n start: DateTime.fromISO(timestamp),\n source,\n value,\n };\n }\n}\n","/**\n * This is a scaffold file meant for customization.\n * Delete the file and run the code generator again to have it reset\n */\nimport { DiffAnalyticsProcessor } from \"./diff-analytics/index.js\";\nexport const processorFactory = (module) => (driveId) => {\n return [\n {\n processor: new DiffAnalyticsProcessor(module.analyticsStore),\n filter: {\n branch: [\"main\"],\n documentId: [\"*\"],\n scope: [\"*\"],\n documentType: [\"*\"],\n },\n },\n ];\n};\n"],"names":["diffDocumentStates","doc1","doc2","changes","globalChanges","diffStateObjects","additions","c","removals","changesByScope","obj1","obj2","path","scope","index","element","elementChanges","diffStateStrings","obj1Record","obj2Record","obj1Keys","obj2Keys","key","nestedChanges","str1","str2","maxLen","i","DiffAnalyticsProcessor","analyticsStore","logger","childLogger","__publicField","strands","strand","firstOp","source","AnalyticsPath","CHUNK_SIZE","chunk","buffer","operation","inputs","runAsapAsync","change","batch","driveId","documentId","branch","revision","type","value","timestamp","dimensions","changePath","DateTime","processorFactory","module"],"mappings":"qqBAGO,SAASA,EAAmBC,EAAMC,EAAM,CAC3C,MAAMC,EAAU,CAAA,EAEVC,EAAgBC,EAAiBJ,EAAMC,EAAM,eAAgB,QAAQ,EAC3EC,EAAQ,KAAK,GAAGC,CAAa,EAE7B,MAAME,EAAYH,EAAQ,OAAQI,GAAMA,EAAE,OAAS,KAAK,EAAE,OACpDC,EAAWL,EAAQ,OAAQI,GAAMA,EAAE,OAAS,QAAQ,EAAE,OAEtDE,EAAiB,CACnB,OAAQN,EAAQ,OAAQI,GAAMA,EAAE,QAAU,QAAQ,CAC1D,EACI,MAAO,CACH,aAAcJ,EAAQ,OACtB,UAAAG,EACA,SAAAE,EACA,eAAAC,EACA,QAAAN,CACR,CACA,CAIA,SAASE,EAAiBK,EAAMC,EAAMC,EAAMC,EAAO,CAC/C,MAAMV,EAAU,CAAA,EAEhB,GAAI,MAAM,QAAQO,CAAI,GAAK,MAAM,QAAQC,CAAI,EAAG,CAC5C,IAAIG,EAAQ,EACZ,KAAOA,EAAQJ,EAAK,OAAQI,IAAS,CACjC,MAAMC,EAAUL,EAAKI,CAAK,EAC1B,GAAI,CAACH,EAAKG,CAAK,EACXX,EAAQ,KAAK,GAAGE,EAAiBU,EAAS,OAAOA,GAAY,SAAW,GAAK,KAAM,GAAGH,CAAI,IAAIE,CAAK,IAAKD,CAAK,CAAC,MAE7G,CACD,MAAMG,EAAiBX,EAAiBU,EAASJ,EAAKG,CAAK,EAAG,GAAGF,CAAI,IAAIE,CAAK,IAAKD,CAAK,EACxFV,EAAQ,KAAK,GAAGa,CAAc,CAC9C,CACA,CACQ,KAAOF,EAAQH,EAAK,OAAQG,IAAS,CACjC,MA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,SAAWhB,EAAc,WAAW,oBAAoBU,CAAU,IAAIC,CAAM,IAAInC,CAAK,IAAIoC,CAAQ,EAAE,EAC9GI,EAAW,KAAOhB,EAAc,WAAW,gBAAgBiB,CAAU,EAAE,EACvED,EAAW,MAAQhB,EAAc,WAAW,iBAAiBS,CAAO,IAAIC,CAAU,EAAE,EAC7E,CACH,WAAAM,EACA,OAAQ,QACR,MAAOE,EAAS,QAAQH,CAAS,EACjC,OAAAhB,EACA,MAAAe,CACZ,CACA,CACA,CCjEY,MAACK,EAAoBC,GAAYX,GAClC,CACH,CACI,UAAW,IAAIlB,EAAuB6B,EAAO,cAAc,EAC3D,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,MAAO,CAAC,GAAG,EACX,aAAc,CAAC,GAAG,CAClC,CACA,CACA","x_google_ignoreList":[0,1,2]}
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index.B35eoM_p.js","./index.Ds87Cbij.js","./app-skeleton.js","./browser.BkwNmV2Z.js","./index-B7k827uL.css"])))=>i.map(i=>d[i]);
2
- import{_ as c}from"./index.Ds87Cbij.js";import"react";import"react/jsx-runtime";import"react-dom";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))s(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(e){if(e.ep)return;e.ep=!0;const r=n(e);fetch(e.href,r)}})();c(()=>import("./index.B35eoM_p.js").then(i=>i.i),__vite__mapDeps([0,1,2,3,4]),import.meta.url);
3
- //# sourceMappingURL=main.DRWC5RhA.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index.CKisJNRj.js","./index.Ds87Cbij.js","./app-skeleton.js","./browser.BkwNmV2Z.js","./index-B7k827uL.css"])))=>i.map(i=>d[i]);
2
+ import{_ as c}from"./index.Ds87Cbij.js";import"react";import"react/jsx-runtime";import"react-dom";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const e of document.querySelectorAll('link[rel="modulepreload"]'))s(e);new MutationObserver(e=>{for(const r of e)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function n(e){const r={};return e.integrity&&(r.integrity=e.integrity),e.referrerPolicy&&(r.referrerPolicy=e.referrerPolicy),e.crossOrigin==="use-credentials"?r.credentials="include":e.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function s(e){if(e.ep)return;e.ep=!0;const r=n(e);fetch(e.href,r)}})();c(()=>import("./index.CKisJNRj.js").then(i=>i.i),__vite__mapDeps([0,1,2,3,4]),import.meta.url);
3
+ //# sourceMappingURL=main.DpXjv5NU.js.map
@@ -1 +1 @@
1
- {"version":3,"mappings":";8yBA8BA,OAAO,qBAAY,OAAAA,KAAA","names":["n"],"ignoreList":[],"sources":["../../src/renderer.ts"],"sourcesContent":["/**\n * This file will automatically be loaded by vite and run in the \"renderer\" context.\n * To learn more about the differences between the \"main\" and the \"renderer\" context in\n * Electron, visit:\n *\n * https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes\n *\n * By default, Node.js integration in this file is disabled. When enabling Node.js integration\n * in a renderer process, please be aware of potential security implications. You can read\n * more about security risks here:\n *\n * https://electronjs.org/docs/tutorial/security\n *\n * To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`\n * flag:\n *\n * ```\n * // Create the browser window.\n * mainWindow = new BrowserWindow({\n * width: 800,\n * height: 600,\n * webPreferences: {\n * nodeIntegration: true\n * }\n * });\n * ```\n */\n\n// splits app code into separate chunk to avoid circular dependencies\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nimport('./index.js');\n"],"file":"assets/main.DRWC5RhA.js"}
1
+ {"version":3,"mappings":";8yBA8BA,OAAO,qBAAY,OAAAA,KAAA","names":["n"],"ignoreList":[],"sources":["../../src/renderer.ts"],"sourcesContent":["/**\n * This file will automatically be loaded by vite and run in the \"renderer\" context.\n * To learn more about the differences between the \"main\" and the \"renderer\" context in\n * Electron, visit:\n *\n * https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes\n *\n * By default, Node.js integration in this file is disabled. When enabling Node.js integration\n * in a renderer process, please be aware of potential security implications. You can read\n * more about security risks here:\n *\n * https://electronjs.org/docs/tutorial/security\n *\n * To enable Node.js integration in this file, open up `main.js` and enable the `nodeIntegration`\n * flag:\n *\n * ```\n * // Create the browser window.\n * mainWindow = new BrowserWindow({\n * width: 800,\n * height: 600,\n * webPreferences: {\n * nodeIntegration: true\n * }\n * });\n * ```\n */\n\n// splits app code into separate chunk to avoid circular dependencies\n// eslint-disable-next-line @typescript-eslint/no-floating-promises\nimport('./index.js');\n"],"file":"assets/main.DpXjv5NU.js"}
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DeleteItemModal.CgoRyH_P.js","./useTranslation.BpVv6XIW.js","./index.Ds87Cbij.js","./UpgradeDriveModal.BCTz6mcG.js","./CreateDocumentModal.BgY0HJIG.js","./useDocumentDriveServer.BCFajpQ5.js","./user.GGI-kGd1.js","./connect.config.Dg2s1YFW.js","./browser.BkwNmV2Z.js","./index.B35eoM_p.js","./app-skeleton.js","./index-B7k827uL.css","./useFeatureFlags.DwHJ60S4.js","./slug.C6xW_7Wm.js","./AddDriveModal.B3Lc0Bve.js","./AddLocalDriveModal.B7zNGR26.js","./AddRemoteDriveModal.Cysvf1QL.js","./DriveSettingsModal.Kma21wmZ.js","./SettingsModal.nsp7JEwj.js","./i18next.CqOP20KE.js","./useConnectConfig.Dk_0m-Ti.js","./index.CAUjMUXb.js","./useDefaultDocumentModelEditor.CWI3XcpL.js","./ConfirmationModal.3YDunJPd.js","./DeleteDriveModal.4FiD_g8R.js","./DebugSettingsModal.CLXuq_T3.js","./registerServiceWorker.DTjJlxaP.js","./DisclaimerModal.DNep5Iuz.js","./CookiesPolicyModal.DAcv8Zb3.js","./Trans.AE4w_7Vj.js"])))=>i.map(i=>d[i]);
2
- import{jsxs as P,jsx as m}from"react/jsx-runtime";import h,{lazy as t,useContext as A,useState as a,useCallback as n,useMemo as R,Suspense as I}from"react";import{_ as o}from"./index.Ds87Cbij.js";import"react-dom";const L={deleteItem:t(()=>o(()=>import("./DeleteItemModal.CgoRyH_P.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.DeleteItemModal}))),upgradeDrive:t(()=>o(()=>import("./UpgradeDriveModal.BCTz6mcG.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.UpgradeDriveModal}))),createDocument:t(()=>o(()=>import("./CreateDocumentModal.BgY0HJIG.js"),__vite__mapDeps([4,2,5,6,7,8,9,10,11,12,13]),import.meta.url).then(e=>({default:e.CreateDocumentModal}))),addDriveModal:t(()=>o(()=>import("./AddDriveModal.B3Lc0Bve.js"),__vite__mapDeps([14,2,6,7,8,9,10,11]),import.meta.url).then(e=>({default:e.AddDriveModal}))),addLocalDrive:t(()=>o(()=>import("./AddLocalDriveModal.B7zNGR26.js"),__vite__mapDeps([15,2]),import.meta.url).then(e=>({default:e.AddLocalDriveModal}))),addRemoteDrive:t(()=>o(()=>import("./AddRemoteDriveModal.Cysvf1QL.js"),__vite__mapDeps([16,2]),import.meta.url).then(e=>({default:e.AddRemoteDriveModal}))),driveSettings:t(()=>o(()=>import("./DriveSettingsModal.Kma21wmZ.js"),__vite__mapDeps([17,2]),import.meta.url).then(e=>({default:e.DriveSettingsModal}))),settingsModal:t(()=>o(()=>import("./SettingsModal.nsp7JEwj.js"),__vite__mapDeps([18,19,7,2,8,20,1,21,5,6,9,10,11,12,22]),import.meta.url).then(e=>({default:e.SettingsModal}))),confirmationModal:t(()=>o(()=>import("./ConfirmationModal.3YDunJPd.js"),__vite__mapDeps([23,2]),import.meta.url).then(e=>({default:e.ConfirmationModal}))),deleteDriveModal:t(()=>o(()=>import("./DeleteDriveModal.4FiD_g8R.js"),__vite__mapDeps([24,1,2]),import.meta.url).then(e=>({default:e.DeleteDriveModal}))),debugSettingsModal:t(()=>o(()=>import("./DebugSettingsModal.CLXuq_T3.js"),__vite__mapDeps([25,20,7,2,8,26,5,6,9,10,11,12]),import.meta.url).then(e=>({default:e.DebugSettingsModal}))),disclaimerModal:t(()=>o(()=>import("./DisclaimerModal.DNep5Iuz.js"),__vite__mapDeps([27,1,2]),import.meta.url).then(e=>({default:e.DisclaimerModal}))),cookiesPolicy:t(()=>o(()=>import("./CookiesPolicyModal.DAcv8Zb3.js"),__vite__mapDeps([28,1,29,2]),import.meta.url).then(e=>({default:e.CookiesPolicyModal})))},u=h.createContext({showModal:()=>{},closeModal:()=>{}}),C=()=>A(u),x=e=>{const{children:s}=e,[p,c]=a(),[l,M]=a(),[D,d]=a(!1),i=n((E,f)=>{d(!0),c(f),M(E)},[]),r=n(()=>{d(!1)},[]),_=l?L[l]:null,v=R(()=>({showModal:i,closeModal:r}),[r,i]);return P(u.Provider,{value:v,children:[s,m(I,{name:"ModalManager",children:_&&m(_,{...p,open:D,onClose:r})})]})};export{u as ModalContext,x as ModalManager,C as useModal};
3
- //# sourceMappingURL=modal.CoChI3Z8.js.map
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./DeleteItemModal.CgoRyH_P.js","./useTranslation.BpVv6XIW.js","./index.Ds87Cbij.js","./UpgradeDriveModal.BCTz6mcG.js","./CreateDocumentModal.CGzc2dXN.js","./useDocumentDriveServer.C9u3SgiH.js","./user.SniiwLvT.js","./connect.config.rJjJZvYA.js","./browser.BkwNmV2Z.js","./index.CKisJNRj.js","./app-skeleton.js","./index-B7k827uL.css","./useFeatureFlags.DceCFoAY.js","./slug.C6xW_7Wm.js","./AddDriveModal.DrmSTNsa.js","./AddLocalDriveModal.B7zNGR26.js","./AddRemoteDriveModal.Cysvf1QL.js","./DriveSettingsModal.Kma21wmZ.js","./SettingsModal.BYFtZAn8.js","./i18next.CqOP20KE.js","./useConnectConfig.BRbXRrbe.js","./index.CAUjMUXb.js","./useDefaultDocumentModelEditor.Cpfnx_NF.js","./ConfirmationModal.3YDunJPd.js","./DeleteDriveModal.4FiD_g8R.js","./DebugSettingsModal.CWRYCw7H.js","./registerServiceWorker.CFFodjhC.js","./DisclaimerModal.DNep5Iuz.js","./CookiesPolicyModal.DAcv8Zb3.js","./Trans.AE4w_7Vj.js"])))=>i.map(i=>d[i]);
2
+ import{jsxs as P,jsx as m}from"react/jsx-runtime";import h,{lazy as t,useContext as A,useState as a,useCallback as n,useMemo as R,Suspense as I}from"react";import{_ as o}from"./index.Ds87Cbij.js";import"react-dom";const L={deleteItem:t(()=>o(()=>import("./DeleteItemModal.CgoRyH_P.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.DeleteItemModal}))),upgradeDrive:t(()=>o(()=>import("./UpgradeDriveModal.BCTz6mcG.js"),__vite__mapDeps([3,1,2]),import.meta.url).then(e=>({default:e.UpgradeDriveModal}))),createDocument:t(()=>o(()=>import("./CreateDocumentModal.CGzc2dXN.js"),__vite__mapDeps([4,2,5,6,7,8,9,10,11,12,13]),import.meta.url).then(e=>({default:e.CreateDocumentModal}))),addDriveModal:t(()=>o(()=>import("./AddDriveModal.DrmSTNsa.js"),__vite__mapDeps([14,2,6,7,8,9,10,11]),import.meta.url).then(e=>({default:e.AddDriveModal}))),addLocalDrive:t(()=>o(()=>import("./AddLocalDriveModal.B7zNGR26.js"),__vite__mapDeps([15,2]),import.meta.url).then(e=>({default:e.AddLocalDriveModal}))),addRemoteDrive:t(()=>o(()=>import("./AddRemoteDriveModal.Cysvf1QL.js"),__vite__mapDeps([16,2]),import.meta.url).then(e=>({default:e.AddRemoteDriveModal}))),driveSettings:t(()=>o(()=>import("./DriveSettingsModal.Kma21wmZ.js"),__vite__mapDeps([17,2]),import.meta.url).then(e=>({default:e.DriveSettingsModal}))),settingsModal:t(()=>o(()=>import("./SettingsModal.BYFtZAn8.js"),__vite__mapDeps([18,19,7,2,8,20,1,21,5,6,9,10,11,12,22]),import.meta.url).then(e=>({default:e.SettingsModal}))),confirmationModal:t(()=>o(()=>import("./ConfirmationModal.3YDunJPd.js"),__vite__mapDeps([23,2]),import.meta.url).then(e=>({default:e.ConfirmationModal}))),deleteDriveModal:t(()=>o(()=>import("./DeleteDriveModal.4FiD_g8R.js"),__vite__mapDeps([24,1,2]),import.meta.url).then(e=>({default:e.DeleteDriveModal}))),debugSettingsModal:t(()=>o(()=>import("./DebugSettingsModal.CWRYCw7H.js"),__vite__mapDeps([25,20,7,2,8,26,5,6,9,10,11,12]),import.meta.url).then(e=>({default:e.DebugSettingsModal}))),disclaimerModal:t(()=>o(()=>import("./DisclaimerModal.DNep5Iuz.js"),__vite__mapDeps([27,1,2]),import.meta.url).then(e=>({default:e.DisclaimerModal}))),cookiesPolicy:t(()=>o(()=>import("./CookiesPolicyModal.DAcv8Zb3.js"),__vite__mapDeps([28,1,29,2]),import.meta.url).then(e=>({default:e.CookiesPolicyModal})))},u=h.createContext({showModal:()=>{},closeModal:()=>{}}),C=()=>A(u),x=e=>{const{children:s}=e,[p,c]=a(),[l,M]=a(),[D,d]=a(!1),i=n((E,f)=>{d(!0),c(f),M(E)},[]),r=n(()=>{d(!1)},[]),_=l?L[l]:null,v=R(()=>({showModal:i,closeModal:r}),[r,i]);return P(u.Provider,{value:v,children:[s,m(I,{name:"ModalManager",children:_&&m(_,{...p,open:D,onClose:r})})]})};export{u as ModalContext,x as ModalManager,C as useModal};
3
+ //# sourceMappingURL=modal.I0jBpvq1.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BACb,GAEN,cAAeF,EAAK,IAAAC,EAAA,IAChB,OAAO,kCAAyB,gDAAE,KAAKC,IAAM,CACzC,QAASA,EAAE,oBACb,EAEV,ECzCaC,EAAeC,EAAM,cAAiC,CAC/D,UAAW,IAAM,GACjB,WAAY,IAAM,EACtB,CAAC,EAEYC,EAAW,IACJC,EAAWH,CAAY,EAI9BI,EAAyDC,GAAS,CAC3E,KAAM,CAAE,SAAAC,GAAaD,EAEf,CAACE,EAAYC,CAAa,EAC5BC,EAAA,EACE,CAACC,EAAWC,CAAY,EAAIF,EAAA,EAC5B,CAACG,EAAMC,CAAO,EAAIJ,EAAS,EAAK,EAEhCK,EAA4CC,EAC9C,CAACL,EAAWL,IAAU,CAClBQ,EAAQ,EAAI,EACZL,EAAcH,CAAK,EACnBM,EAAaD,CAAS,GAE1B,EAAC,EAGCM,EAA8CD,EAAY,IAAM,CAClEF,EAAQ,EAAK,GACd,EAAE,EAECI,EAAiBP,EAAYd,EAAOc,CAAS,EAAI,KAEjDQ,EAAQC,EACV,KAAO,CAAE,UAAAL,EAAW,WAAAE,IACpB,CAACA,EAAYF,CAAS,GAG1B,OACIM,EAACpB,EAAa,SAAb,CAAsB,MAAAkB,EAClB,UAAAZ,EACDe,EAACC,EAAA,CAAS,KAAK,eACV,SAAAL,GACGI,EAACJ,EAAA,CACI,GAAIV,EACL,KAAAK,EACA,QAASI,CAAA,EACb,CAER,GACJ,CAER","names":["modals","lazy","__vitePreload","m","ModalContext","React","useModal","useContext","ModalManager","props","children","modalProps","setModalProps","useState","modalType","setModalType","open","setOpen","showModal","useCallback","closeModal","ModalComponent","value","useMemo","jsxs","jsx","Suspense"],"ignoreList":[],"sources":["../../src/components/modal/modals/index.ts","../../src/components/modal/modal.tsx"],"sourcesContent":["import { lazy } from 'react';\n\nexport const modals = {\n deleteItem: lazy(() =>\n import('./DeleteItemModal.js').then(m => ({\n default: m.DeleteItemModal,\n })),\n ),\n upgradeDrive: lazy(() =>\n import('./UpgradeDriveModal.js').then(m => ({\n default: m.UpgradeDriveModal,\n })),\n ),\n createDocument: lazy(() =>\n import('./CreateDocumentModal.js').then(m => ({\n default: m.CreateDocumentModal,\n })),\n ),\n addDriveModal: lazy(() =>\n import('./AddDriveModal.js').then(m => ({\n default: m.AddDriveModal,\n })),\n ),\n addLocalDrive: lazy(() =>\n import('./AddLocalDriveModal.js').then(m => ({\n default: m.AddLocalDriveModal,\n })),\n ),\n addRemoteDrive: lazy(() =>\n import('./AddRemoteDriveModal.js').then(m => ({\n default: m.AddRemoteDriveModal,\n })),\n ),\n driveSettings: lazy(() =>\n import('./DriveSettingsModal.js').then(m => ({\n default: m.DriveSettingsModal,\n })),\n ),\n settingsModal: lazy(() =>\n import('./SettingsModal.js').then(m => ({\n default: m.SettingsModal,\n })),\n ),\n confirmationModal: lazy(() =>\n import('./ConfirmationModal.js').then(m => ({\n default: m.ConfirmationModal,\n })),\n ),\n deleteDriveModal: lazy(() =>\n import('./DeleteDriveModal.js').then(m => ({\n default: m.DeleteDriveModal,\n })),\n ),\n debugSettingsModal: lazy(() =>\n import('./DebugSettingsModal.js').then(m => ({\n default: m.DebugSettingsModal,\n })),\n ),\n disclaimerModal: lazy(() =>\n import('./DisclaimerModal.js').then(m => ({\n default: m.DisclaimerModal,\n })),\n ),\n cookiesPolicy: lazy(() =>\n import('./CookiesPolicyModal.js').then(m => ({\n default: m.CookiesPolicyModal,\n })),\n ),\n} as const;\n\nexport type Modals = typeof modals;\n\nexport type ModalType = keyof Modals;\n\nexport type ModalPropsMapping = {\n [K in ModalType]: React.ComponentProps<Modals[K]>;\n};\n","import React, {\n Suspense,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from 'react';\nimport {\n type ModalPropsMapping,\n type ModalType,\n modals,\n} from './modals/index.js';\n\ntype MapModalProps<T> = {\n [K in keyof T]: Omit<T[K], 'open' | 'onClose'> & { onClose?: () => void };\n};\n\ntype ModalProps = MapModalProps<ModalPropsMapping>;\n\ninterface ModalContextValue {\n showModal: <T extends ModalType>(\n modalType: T,\n props: ModalProps[T],\n ) => void;\n closeModal: () => void;\n}\n\nexport const ModalContext = React.createContext<ModalContextValue>({\n showModal: () => {},\n closeModal: () => {},\n});\n\nexport const useModal = () => {\n const context = useContext(ModalContext);\n return context;\n};\n\nexport const ModalManager: React.FC<{ children?: React.ReactNode }> = props => {\n const { children } = props;\n\n const [modalProps, setModalProps] =\n useState<ModalProps[keyof ModalProps]>();\n const [modalType, setModalType] = useState<ModalType>();\n const [open, setOpen] = useState(false);\n\n const showModal: ModalContextValue['showModal'] = useCallback(\n (modalType, props) => {\n setOpen(true);\n setModalProps(props);\n setModalType(modalType);\n },\n [],\n );\n\n const closeModal: ModalContextValue['closeModal'] = useCallback(() => {\n setOpen(false);\n }, []);\n\n const ModalComponent = modalType ? modals[modalType] : null;\n\n const value = useMemo(\n () => ({ showModal, closeModal }),\n [closeModal, showModal],\n );\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n <Suspense name=\"ModalManager\">\n {ModalComponent && (\n <ModalComponent\n {...(modalProps as any)}\n open={open}\n onClose={closeModal}\n />\n )}\n </Suspense>\n </ModalContext.Provider>\n );\n};\n"],"file":"assets/modal.CoChI3Z8.js"}
1
+ {"version":3,"mappings":";sNAEO,MAAMA,EAAS,CAClB,WAAYC,EAAK,IAAAC,EAAA,IACb,OAAO,+BAAsB,4CAAE,KAAKC,IAAM,CACtC,QAASA,EAAE,iBACb,GAEN,aAAcF,EAAK,IAAAC,EAAA,IACf,OAAO,iCAAwB,4CAAE,KAAKC,IAAM,CACxC,QAASA,EAAE,mBACb,GAEN,eAAgBF,EAAK,IAAAC,EAAA,IACjB,OAAO,mCAA0B,gEAAE,KAAKC,IAAM,CAC1C,QAASA,EAAE,qBACb,GAEN,cAAeF,EAAK,IAAAC,EAAA,IAChB,OAAO,6BAAoB,yDAAE,KAAKC,IAAM,CACpC,QAASA,EAAE,eACb,GAEN,cAAeF,EAAK,IAAAC,EAAA,IAChB,OAAO,kCAAyB,2CAAE,KAA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,EAAC,EAGCM,EAA8CD,EAAY,IAAM,CAClEF,EAAQ,EAAK,GACd,EAAE,EAECI,EAAiBP,EAAYd,EAAOc,CAAS,EAAI,KAEjDQ,EAAQC,EACV,KAAO,CAAE,UAAAL,EAAW,WAAAE,IACpB,CAACA,EAAYF,CAAS,GAG1B,OACIM,EAACpB,EAAa,SAAb,CAAsB,MAAAkB,EAClB,UAAAZ,EACDe,EAACC,EAAA,CAAS,KAAK,eACV,SAAAL,GACGI,EAACJ,EAAA,CACI,GAAIV,EACL,KAAAK,EACA,QAASI,CAAA,EACb,CAER,GACJ,CAER","names":["modals","lazy","__vitePreload","m","ModalContext","React","useModal","useContext","ModalManager","props","children","modalProps","setModalProps","useState","modalType","setModalType","open","setOpen","showModal","useCallback","closeModal","ModalComponent","value","useMemo","jsxs","jsx","Suspense"],"ignoreList":[],"sources":["../../src/components/modal/modals/index.ts","../../src/components/modal/modal.tsx"],"sourcesContent":["import { lazy } from 'react';\n\nexport const modals = {\n deleteItem: lazy(() =>\n import('./DeleteItemModal.js').then(m => ({\n default: m.DeleteItemModal,\n })),\n ),\n upgradeDrive: lazy(() =>\n import('./UpgradeDriveModal.js').then(m => ({\n default: m.UpgradeDriveModal,\n })),\n ),\n createDocument: lazy(() =>\n import('./CreateDocumentModal.js').then(m => ({\n default: m.CreateDocumentModal,\n })),\n ),\n addDriveModal: lazy(() =>\n import('./AddDriveModal.js').then(m => ({\n default: m.AddDriveModal,\n })),\n ),\n addLocalDrive: lazy(() =>\n import('./AddLocalDriveModal.js').then(m => ({\n default: m.AddLocalDriveModal,\n })),\n ),\n addRemoteDrive: lazy(() =>\n import('./AddRemoteDriveModal.js').then(m => ({\n default: m.AddRemoteDriveModal,\n })),\n ),\n driveSettings: lazy(() =>\n import('./DriveSettingsModal.js').then(m => ({\n default: m.DriveSettingsModal,\n })),\n ),\n settingsModal: lazy(() =>\n import('./SettingsModal.js').then(m => ({\n default: m.SettingsModal,\n })),\n ),\n confirmationModal: lazy(() =>\n import('./ConfirmationModal.js').then(m => ({\n default: m.ConfirmationModal,\n })),\n ),\n deleteDriveModal: lazy(() =>\n import('./DeleteDriveModal.js').then(m => ({\n default: m.DeleteDriveModal,\n })),\n ),\n debugSettingsModal: lazy(() =>\n import('./DebugSettingsModal.js').then(m => ({\n default: m.DebugSettingsModal,\n })),\n ),\n disclaimerModal: lazy(() =>\n import('./DisclaimerModal.js').then(m => ({\n default: m.DisclaimerModal,\n })),\n ),\n cookiesPolicy: lazy(() =>\n import('./CookiesPolicyModal.js').then(m => ({\n default: m.CookiesPolicyModal,\n })),\n ),\n} as const;\n\nexport type Modals = typeof modals;\n\nexport type ModalType = keyof Modals;\n\nexport type ModalPropsMapping = {\n [K in ModalType]: React.ComponentProps<Modals[K]>;\n};\n","import React, {\n Suspense,\n useCallback,\n useContext,\n useMemo,\n useState,\n} from 'react';\nimport {\n type ModalPropsMapping,\n type ModalType,\n modals,\n} from './modals/index.js';\n\ntype MapModalProps<T> = {\n [K in keyof T]: Omit<T[K], 'open' | 'onClose'> & { onClose?: () => void };\n};\n\ntype ModalProps = MapModalProps<ModalPropsMapping>;\n\ninterface ModalContextValue {\n showModal: <T extends ModalType>(\n modalType: T,\n props: ModalProps[T],\n ) => void;\n closeModal: () => void;\n}\n\nexport const ModalContext = React.createContext<ModalContextValue>({\n showModal: () => {},\n closeModal: () => {},\n});\n\nexport const useModal = () => {\n const context = useContext(ModalContext);\n return context;\n};\n\nexport const ModalManager: React.FC<{ children?: React.ReactNode }> = props => {\n const { children } = props;\n\n const [modalProps, setModalProps] =\n useState<ModalProps[keyof ModalProps]>();\n const [modalType, setModalType] = useState<ModalType>();\n const [open, setOpen] = useState(false);\n\n const showModal: ModalContextValue['showModal'] = useCallback(\n (modalType, props) => {\n setOpen(true);\n setModalProps(props);\n setModalType(modalType);\n },\n [],\n );\n\n const closeModal: ModalContextValue['closeModal'] = useCallback(() => {\n setOpen(false);\n }, []);\n\n const ModalComponent = modalType ? modals[modalType] : null;\n\n const value = useMemo(\n () => ({ showModal, closeModal }),\n [closeModal, showModal],\n );\n\n return (\n <ModalContext.Provider value={value}>\n {children}\n <Suspense name=\"ModalManager\">\n {ModalComponent && (\n <ModalComponent\n {...(modalProps as any)}\n open={open}\n onClose={closeModal}\n />\n )}\n </Suspense>\n </ModalContext.Provider>\n );\n};\n"],"file":"assets/modal.I0jBpvq1.js"}
@@ -1,2 +1,2 @@
1
- import{t as m}from"./i18next.CqOP20KE.js";import{useCallback as v}from"react";import{u as b}from"./useDocumentDriveServer.BCFajpQ5.js";import{m as C}from"./slug.C6xW_7Wm.js";import{al as T,ag as A,ak as N,L as y,ah as M,x as U,am as I}from"./index.Ds87Cbij.js";import{g as F}from"./user.GGI-kGd1.js";import{useModal as L}from"./modal.CoChI3Z8.js";function E(){const{getSyncStatus:c}=b();return v(async a=>{const r="readContext"in a,{name:h,icon:d}=a.state.global,{id:t,slug:u}=a.header,{sharingType:f,availableOffline:o}=r?{sharingType:T,availableOffline:!1}:a.state.local,n=f==null?void 0:f.toUpperCase(),s=n==="PRIVATE"?A:n,l=r?void 0:await c(t,s),D=l==="INITIAL_SYNC"?"SYNCING":l,p={id:t,name:h,slug:u||null,kind:N,children:[],nodeMap:{},sharingType:s,syncStatus:D,availableOffline:o,icon:d,parentFolder:null,driveId:t},g=a.state.global.nodes.map(e=>{const i={...e,slug:C(e.name),driveId:t,parentFolder:e.parentFolder||t,kind:e.kind.toUpperCase(),syncStatus:D,sharingType:s};if(i.kind===N)throw new Error("Drive nodes should not be nested");return i.kind===y?i:{...i,children:[]}});for(const e of g)p.nodeMap[e.id]=e;for await(const e of g){if(e.kind===y){const w=r?void 0:await c(e.synchronizationUnits[0].syncId,s),k=w==="INITIAL_SYNC"?"SYNCING":w;e.syncStatus=k}if(e.parentFolder===t){p.children.push(e);continue}const i=p.nodeMap[e.parentFolder];if(i.kind===y)throw new Error(`Parent node ${e.parentFolder} is a file, not a folder`);i.children.push(e),e.syncStatus!==M&&(i.syncStatus=e.syncStatus)}return p},[c])}function G(){const{showModal:c}=L(),{addDrive:S,addRemoteDrive:a}=b(),{setSelectedNode:r}=U(),h=F(),d=E(),t=v(async o=>{try{const n=h.find(l=>l.id===o.appId),s=await S({id:"",slug:"",global:{name:o.name,icon:null},local:{availableOffline:o.availableOffline,sharingType:o.sharingType.toLowerCase(),listeners:[],triggers:[]}},n==null?void 0:n.driveEditor);if(I(m("notifications.addDriveSuccess"),{type:"connect-success"}),s){const l=await d(s);r(l)}}catch(n){console.error(n)}},[S,d,r,m]),u=v(async o=>{try{const n=await a(o.url,{sharingType:o.sharingType,availableOffline:o.availableOffline,listeners:[{block:!0,callInfo:{data:o.url,name:"switchboard-push",transmitterType:"SwitchboardPush"},filter:{branch:["main"],documentId:["*"],documentType:["*"],scope:["global"]},label:"Switchboard Sync",listenerId:"1",system:!0}],triggers:[]});if(I(m("notifications.addDriveSuccess"),{type:"connect-success"}),n){const s=await d(n);r(s)}}catch(n){console.error(n)}},[a,d,r,m]);return v(()=>c("addDriveModal",{onAddLocalDrive:t,onAddRemoteDrive:u}),[t,u,c])}export{E as a,G as u};
2
- //# sourceMappingURL=modals.BDBwwAHa.js.map
1
+ import{t as m}from"./i18next.CqOP20KE.js";import{useCallback as v}from"react";import{u as b}from"./useDocumentDriveServer.C9u3SgiH.js";import{m as C}from"./slug.C6xW_7Wm.js";import{al as T,ag as A,ak as N,L as y,ah as M,x as U,am as I}from"./index.Ds87Cbij.js";import{g as F}from"./user.SniiwLvT.js";import{useModal as L}from"./modal.I0jBpvq1.js";function E(){const{getSyncStatus:c}=b();return v(async a=>{const r="readContext"in a,{name:h,icon:d}=a.state.global,{id:t,slug:u}=a.header,{sharingType:f,availableOffline:o}=r?{sharingType:T,availableOffline:!1}:a.state.local,n=f==null?void 0:f.toUpperCase(),s=n==="PRIVATE"?A:n,l=r?void 0:await c(t,s),D=l==="INITIAL_SYNC"?"SYNCING":l,p={id:t,name:h,slug:u||null,kind:N,children:[],nodeMap:{},sharingType:s,syncStatus:D,availableOffline:o,icon:d,parentFolder:null,driveId:t},g=a.state.global.nodes.map(e=>{const i={...e,slug:C(e.name),driveId:t,parentFolder:e.parentFolder||t,kind:e.kind.toUpperCase(),syncStatus:D,sharingType:s};if(i.kind===N)throw new Error("Drive nodes should not be nested");return i.kind===y?i:{...i,children:[]}});for(const e of g)p.nodeMap[e.id]=e;for await(const e of g){if(e.kind===y){const w=r?void 0:await c(e.synchronizationUnits[0].syncId,s),k=w==="INITIAL_SYNC"?"SYNCING":w;e.syncStatus=k}if(e.parentFolder===t){p.children.push(e);continue}const i=p.nodeMap[e.parentFolder];if(i.kind===y)throw new Error(`Parent node ${e.parentFolder} is a file, not a folder`);i.children.push(e),e.syncStatus!==M&&(i.syncStatus=e.syncStatus)}return p},[c])}function G(){const{showModal:c}=L(),{addDrive:S,addRemoteDrive:a}=b(),{setSelectedNode:r}=U(),h=F(),d=E(),t=v(async o=>{try{const n=h.find(l=>l.id===o.appId),s=await S({id:"",slug:"",global:{name:o.name,icon:null},local:{availableOffline:o.availableOffline,sharingType:o.sharingType.toLowerCase(),listeners:[],triggers:[]}},n==null?void 0:n.driveEditor);if(I(m("notifications.addDriveSuccess"),{type:"connect-success"}),s){const l=await d(s);r(l)}}catch(n){console.error(n)}},[S,d,r,m]),u=v(async o=>{try{const n=await a(o.url,{sharingType:o.sharingType,availableOffline:o.availableOffline,listeners:[{block:!0,callInfo:{data:o.url,name:"switchboard-push",transmitterType:"SwitchboardPush"},filter:{branch:["main"],documentId:["*"],documentType:["*"],scope:["global"]},label:"Switchboard Sync",listenerId:"1",system:!0}],triggers:[]});if(I(m("notifications.addDriveSuccess"),{type:"connect-success"}),n){const s=await d(n);r(s)}}catch(n){console.error(n)}},[a,d,r,m]);return v(()=>c("addDriveModal",{onAddLocalDrive:t,onAddRemoteDrive:u}),[t,u,c])}export{E as a,G as u};
2
+ //# sourceMappingURL=modals.Dn_ncIrB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modals.BDBwwAHa.js","sources":["../../src/hooks/useUiNodes.ts","../../src/hooks/modals.ts"],"sourcesContent":["import { makeNodeSlugFromNodeName } from '#utils';\nimport {\n DRIVE,\n FILE,\n FOLDER,\n LOCAL,\n PUBLIC,\n type SharingType,\n SUCCESS,\n type UiDriveNode,\n type UiFileNode,\n type UiFolderNode,\n type UiNode,\n} from '@powerhousedao/design-system';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport { type DocumentDriveDocument, type ReadDrive } from 'document-drive';\nimport { useCallback, useMemo } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer.js';\n\nexport function useMakeUiDriveNode() {\n const { getSyncStatus } = useDocumentDriveServer();\n const makeUiDriveNode = useCallback(\n async (drive: DocumentDriveDocument | ReadDrive) => {\n const isReadDrive = 'readContext' in drive;\n const { name, icon } = drive.state.global;\n const { id, slug } = drive.header;\n const { sharingType: _sharingType, availableOffline } = !isReadDrive\n ? drive.state.local\n : { sharingType: PUBLIC, availableOffline: false };\n const __sharingType = _sharingType?.toUpperCase();\n const sharingType = (\n __sharingType === 'PRIVATE' ? LOCAL : __sharingType\n ) as SharingType;\n const driveSyncStatus = !isReadDrive\n ? await getSyncStatus(id, sharingType)\n : undefined;\n\n // TODO: rempve this after integration in design-system\n const normalizedDriveSyncStatus =\n driveSyncStatus === 'INITIAL_SYNC'\n ? 'SYNCING'\n : driveSyncStatus;\n\n const driveNode: UiDriveNode = {\n id,\n name,\n slug: slug || null,\n kind: DRIVE,\n children: [],\n nodeMap: {},\n sharingType,\n syncStatus: normalizedDriveSyncStatus,\n availableOffline,\n icon,\n parentFolder: null,\n driveId: id,\n };\n\n const nodes = drive.state.global.nodes.map(n => {\n const node = {\n ...n,\n slug: makeNodeSlugFromNodeName(n.name),\n driveId: id,\n parentFolder: n.parentFolder || id,\n kind: n.kind.toUpperCase(),\n syncStatus: normalizedDriveSyncStatus,\n sharingType,\n };\n\n if (node.kind === DRIVE) {\n throw new Error('Drive nodes should not be nested');\n }\n\n if (node.kind === FILE) {\n return node as UiFileNode;\n }\n\n return {\n ...node,\n children: [],\n } as UiFolderNode;\n });\n\n for (const node of nodes) {\n driveNode.nodeMap[node.id] = node;\n }\n\n // eslint-disable-next-line @typescript-eslint/await-thenable\n for await (const node of nodes) {\n if (node.kind === FILE) {\n const fileSyncStatus = !isReadDrive\n ? await getSyncStatus(\n node.synchronizationUnits[0].syncId,\n sharingType,\n )\n : undefined;\n\n // TODO: rempve this after integration in design-system\n const normalizedFileSyncStatus =\n fileSyncStatus === 'INITIAL_SYNC'\n ? 'SYNCING'\n : fileSyncStatus;\n\n node.syncStatus = normalizedFileSyncStatus;\n }\n\n if (node.parentFolder === id) {\n driveNode.children.push(node);\n continue;\n }\n const parent = driveNode.nodeMap[node.parentFolder];\n\n if (parent.kind === FILE) {\n throw new Error(\n `Parent node ${node.parentFolder} is a file, not a folder`,\n );\n }\n\n parent.children.push(node);\n\n if (node.syncStatus !== SUCCESS) {\n parent.syncStatus = node.syncStatus;\n }\n }\n\n return driveNode;\n },\n [getSyncStatus],\n );\n\n return makeUiDriveNode;\n}\n\nexport function useDebugHandlers() {\n const { removeTrigger, addTrigger, registerNewPullResponderTrigger } =\n useDocumentDriveServer();\n\n const onAddTrigger = useCallback(\n async (uiNodeDriveId: string) => {\n const url = window.prompt('url') || '';\n\n const pullResponderTrigger = await registerNewPullResponderTrigger(\n uiNodeDriveId,\n url,\n { pullInterval: 6000 },\n );\n await addTrigger(uiNodeDriveId, pullResponderTrigger);\n },\n [addTrigger, registerNewPullResponderTrigger],\n );\n\n const onRemoveTrigger = useCallback(\n async (uiNodeDriveId: string) => {\n const triggerId = window.prompt('triggerId:');\n\n if (triggerId) {\n await removeTrigger(uiNodeDriveId, triggerId);\n }\n },\n [removeTrigger],\n );\n\n const onAddInvalidTrigger = useCallback(\n async (uiNodeDriveId: string) => {\n const url = window.prompt('url') || '';\n\n await addTrigger(uiNodeDriveId, {\n id: 'some-invalid-id',\n type: 'PullResponder',\n data: {\n interval: '3000',\n listenerId: 'invalid-listener-id',\n url,\n },\n });\n },\n [addTrigger],\n );\n\n return {\n onAddTrigger,\n onRemoveTrigger,\n onAddInvalidTrigger,\n };\n}\n\nexport function useUiNodes() {\n const { selectedParentNode, setSelectedNode } = useUiNodesContext();\n const { addFolder, addFile, renameNode, copyNode, moveNode } =\n useDocumentDriveServer();\n\n const onAddFile = useCallback(\n async (file: File, parentNode: UiNode | null) => {\n if (!parentNode) {\n throw new Error('Parent node is required');\n }\n if (parentNode.kind === FILE) {\n throw new Error('Cannot add file to a file');\n }\n\n const fileName = file.name.replace(/\\.zip$/gim, '');\n\n return await addFile(\n file,\n parentNode.driveId,\n fileName,\n parentNode.id,\n );\n },\n [addFile],\n );\n\n const onAddFolder = useCallback(\n async (name: string, parentNode: UiNode | null) => {\n if (!parentNode) {\n throw new Error('Parent node is required');\n }\n if (parentNode.kind === FILE) {\n throw new Error('Cannot add folder to a file');\n }\n return await addFolder(parentNode.driveId, name, parentNode.id);\n },\n [addFolder],\n );\n\n const onRenameNode = useCallback(\n async (name: string, uiNode: UiNode) => {\n if (uiNode.kind === DRIVE) {\n throw new Error(\n 'Drive can only be renamed from the drive settings modal',\n );\n }\n return await renameNode(uiNode.driveId, uiNode.id, name);\n },\n [renameNode],\n );\n\n const onCopyNode = useCallback(\n async (uiNode: UiNode, targetNode: UiNode) => {\n if (uiNode.kind === DRIVE) {\n throw new Error('Drive cannot be duplicated');\n }\n\n await copyNode(uiNode, targetNode);\n },\n [copyNode],\n );\n\n const onMoveNode = useCallback(\n async (uiNode: UiNode, targetNode: UiNode) => {\n if (uiNode.kind === DRIVE) {\n throw new Error('Drive cannot be moved');\n }\n\n await moveNode(uiNode, targetNode);\n },\n [moveNode],\n );\n\n const onDuplicateNode = useCallback(\n async (uiNode: UiNode) => {\n if (!selectedParentNode) return;\n\n if (uiNode.kind === DRIVE) {\n throw new Error('Drive cannot be duplicated');\n }\n\n await copyNode(uiNode, selectedParentNode);\n },\n [copyNode, selectedParentNode],\n );\n\n const onAddAndSelectNewFolder = useCallback(\n async (name: string) => {\n if (!name || !selectedParentNode) return;\n\n const newFolder = await onAddFolder(name, selectedParentNode);\n\n setSelectedNode({\n ...newFolder,\n kind: FOLDER,\n slug: makeNodeSlugFromNodeName(newFolder.name),\n parentFolder: selectedParentNode.id,\n syncStatus: selectedParentNode.syncStatus,\n driveId: selectedParentNode.driveId,\n sharingType: selectedParentNode.sharingType,\n children: [],\n });\n },\n [onAddFolder, selectedParentNode, setSelectedNode],\n );\n\n return useMemo(\n () => ({\n onAddFile,\n onAddFolder,\n onRenameNode,\n onCopyNode,\n onMoveNode,\n onDuplicateNode,\n onAddAndSelectNewFolder,\n }),\n [\n onAddFolder,\n onAddFile,\n onCopyNode,\n onMoveNode,\n onRenameNode,\n onDuplicateNode,\n onAddAndSelectNewFolder,\n ],\n );\n}\n\nexport type TUiNodes = ReturnType<typeof useUiNodes>;\n","import { useModal } from '#components';\nimport { useApps } from '#store';\nimport {\n toast,\n type AddLocalDriveInput,\n type AddRemoteDriveInput,\n} from '@powerhousedao/design-system';\nimport {\n FOLDER,\n useUiNodesContext,\n type SharingType,\n type UiDriveNode,\n type UiFileNode,\n type UiFolderNode,\n} from '@powerhousedao/reactor-browser';\nimport { t } from 'i18next';\nimport { useCallback } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer';\nimport { useMakeUiDriveNode } from './useUiNodes';\n\nexport function useShowAddDriveModal() {\n const { showModal } = useModal();\n const { addDrive, addRemoteDrive } = useDocumentDriveServer();\n const { setSelectedNode } = useUiNodesContext();\n const apps = useApps();\n const makeUiDriveNode = useMakeUiDriveNode();\n const onAddLocalDrive = useCallback(\n async (data: AddLocalDriveInput) => {\n try {\n const app = apps.find(a => a.id === data.appId);\n const newDrive = await addDrive(\n {\n id: '',\n slug: '',\n global: {\n name: data.name,\n icon: null,\n },\n local: {\n availableOffline: data.availableOffline,\n sharingType: data.sharingType.toLowerCase(),\n listeners: [],\n triggers: [],\n },\n },\n app?.driveEditor,\n );\n\n toast(t('notifications.addDriveSuccess'), {\n type: 'connect-success',\n });\n\n if (newDrive) {\n const newDriveNode = await makeUiDriveNode(newDrive);\n setSelectedNode(newDriveNode);\n }\n } catch (e) {\n console.error(e);\n }\n },\n [addDrive, makeUiDriveNode, setSelectedNode, t],\n );\n\n const onAddRemoteDrive = useCallback(\n async (data: AddRemoteDriveInput) => {\n try {\n const newDrive = await addRemoteDrive(data.url, {\n sharingType: data.sharingType,\n availableOffline: data.availableOffline,\n listeners: [\n {\n block: true,\n callInfo: {\n data: data.url,\n name: 'switchboard-push',\n transmitterType: 'SwitchboardPush',\n },\n filter: {\n branch: ['main'],\n documentId: ['*'],\n documentType: ['*'],\n scope: ['global'],\n },\n label: 'Switchboard Sync',\n listenerId: '1',\n system: true,\n },\n ],\n triggers: [],\n });\n\n toast(t('notifications.addDriveSuccess'), {\n type: 'connect-success',\n });\n\n if (newDrive) {\n const newDriveNode = await makeUiDriveNode(newDrive);\n setSelectedNode(newDriveNode);\n }\n } catch (e) {\n console.error(e);\n }\n },\n [addRemoteDrive, makeUiDriveNode, setSelectedNode, t],\n );\n const showAddDriveModal = useCallback(\n () =>\n showModal('addDriveModal', {\n onAddLocalDrive,\n onAddRemoteDrive,\n }),\n [onAddLocalDrive, onAddRemoteDrive, showModal],\n );\n\n return showAddDriveModal;\n}\n\nexport function useShowDriveSettingsModal() {\n const { showModal } = useModal();\n const {\n renameDrive,\n setDriveAvailableOffline,\n setDriveSharingType,\n deleteDrive,\n } = useDocumentDriveServer();\n const { driveNodes, setSelectedNode } = useUiNodesContext();\n const onRenameDrive = useCallback(\n async (uiDriveNode: UiDriveNode, newName: string) => {\n await renameDrive(uiDriveNode.id, newName);\n },\n [renameDrive],\n );\n\n const onChangeSharingType = useCallback(\n async (uiDriveNode: UiDriveNode, newSharingType: SharingType) => {\n await setDriveSharingType(uiDriveNode.id, newSharingType);\n },\n [setDriveSharingType],\n );\n\n const onChangeAvailableOffline = useCallback(\n async (uiDriveNode: UiDriveNode, newAvailableOffline: boolean) => {\n await setDriveAvailableOffline(uiDriveNode.id, newAvailableOffline);\n },\n [setDriveAvailableOffline],\n );\n const onDeleteDrive = useCallback(\n (uiDriveNode: UiDriveNode) => {\n showModal('deleteDriveModal', {\n uiDriveNode,\n onDelete: async closeModal => {\n closeModal();\n await deleteDrive(uiDriveNode.id);\n\n setSelectedNode(driveNodes[0]);\n\n toast(t('notifications.deleteDriveSuccess'), {\n type: 'connect-deleted',\n });\n },\n });\n },\n [deleteDrive, driveNodes, setSelectedNode, showModal, t],\n );\n const showDriveSettingsModal = useCallback(\n (uiDriveNode: UiDriveNode) => {\n showModal('driveSettings', {\n uiDriveNode,\n onRenameDrive,\n onDeleteDrive,\n onChangeSharingType,\n onChangeAvailableOffline,\n });\n },\n [\n onChangeAvailableOffline,\n onChangeSharingType,\n onDeleteDrive,\n onRenameDrive,\n showModal,\n ],\n );\n\n return showDriveSettingsModal;\n}\n\nexport function useShowDeleteNodeModal() {\n const { showModal } = useModal();\n const { setSelectedNode, getParentNode } = useUiNodesContext();\n const { deleteNode } = useDocumentDriveServer();\n const showDeleteNodeModal = useCallback(\n (uiNode: UiFileNode | UiFolderNode) => {\n showModal('deleteItem', {\n uiNode,\n onDelete: async closeModal => {\n closeModal();\n\n const i18nKey =\n uiNode.kind === FOLDER\n ? 'notifications.deleteFolderSuccess'\n : 'notifications.fileDeleteSuccess';\n\n const parentNode = getParentNode(uiNode);\n\n await deleteNode(uiNode.driveId, uiNode.id);\n\n setSelectedNode(parentNode);\n\n toast(t(i18nKey), { type: 'connect-deleted' });\n },\n });\n },\n [deleteNode, getParentNode, setSelectedNode, showModal, t],\n );\n\n return showDeleteNodeModal;\n}\n"],"names":["useMakeUiDriveNode","getSyncStatus","useDocumentDriveServer","useCallback","drive","isReadDrive","name","icon","id","slug","_sharingType","availableOffline","PUBLIC","__sharingType","sharingType","LOCAL","driveSyncStatus","normalizedDriveSyncStatus","driveNode","DRIVE","nodes","n","node","makeNodeSlugFromNodeName","FILE","fileSyncStatus","normalizedFileSyncStatus","parent","SUCCESS","useShowAddDriveModal","showModal","useModal","addDrive","addRemoteDrive","setSelectedNode","useUiNodesContext","apps","useApps","makeUiDriveNode","onAddLocalDrive","data","app","a","newDrive","toast","t","newDriveNode","e","onAddRemoteDrive"],"mappings":"2VAmBO,SAASA,GAAqB,CACjC,KAAM,CAAE,cAAAC,CAAA,EAAkBC,EAAA,EA8G1B,OA7GwBC,EACpB,MAAOC,GAA6C,CAChD,MAAMC,EAAc,gBAAiBD,EAC/B,CAAE,KAAAE,EAAM,KAAAC,CAAA,EAASH,EAAM,MAAM,OAC7B,CAAE,GAAAI,EAAI,KAAAC,CAAA,EAASL,EAAM,OACrB,CAAE,YAAaM,EAAc,iBAAAC,CAAA,EAAsBN,EAEnD,CAAE,YAAaO,EAAQ,iBAAkB,EAAA,EADzCR,EAAM,MAAM,MAEZS,EAAgBH,GAAA,YAAAA,EAAc,cAC9BI,EACFD,IAAkB,UAAYE,EAAQF,EAEpCG,EAAmBX,EAEnB,OADA,MAAMJ,EAAcO,EAAIM,CAAW,EAInCG,EACFD,IAAoB,eACd,UACAA,EAEJE,EAAyB,CAC3B,GAAAV,EACA,KAAAF,EACA,KAAMG,GAAQ,KACd,KAAMU,EACN,SAAU,CAAA,EACV,QAAS,CAAA,EACT,YAAAL,EACA,WAAYG,EACZ,iBAAAN,EACA,KAAAJ,EACA,aAAc,KACd,QAASC,CAAA,EAGPY,EAAQhB,EAAM,MAAM,OAAO,MAAM,IAAIiB,GAAK,CAC5C,MAAMC,EAAO,CACT,GAAGD,EACH,KAAME,EAAyBF,EAAE,IAAI,EACrC,QAASb,EACT,aAAca,EAAE,cAAgBb,EAChC,KAAMa,EAAE,KAAK,YAAA,EACb,WAAYJ,EACZ,YAAAH,CAAA,EAGJ,GAAIQ,EAAK,OAASH,EACd,MAAM,IAAI,MAAM,kCAAkC,EAGtD,OAAIG,EAAK,OAASE,EACPF,EAGJ,CACH,GAAGA,EACH,SAA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EAAG,CACtC,KAAM,iBAAA,CACT,EAEGF,EAAU,CACV,MAAMG,EAAe,MAAMR,EAAgBK,CAAQ,EACnDT,EAAgBY,CAAY,CAAA,CAChC,OACKC,EAAG,CACR,QAAQ,MAAMA,CAAC,CAAA,CACnB,EAEJ,CAACf,EAAUM,EAAiBJ,EAAiBW,CAAC,CAAA,EAG5CG,EAAmB7C,EACrB,MAAOqC,GAA8B,CACjC,GAAI,CACA,MAAMG,EAAW,MAAMV,EAAeO,EAAK,IAAK,CAC5C,YAAaA,EAAK,YAClB,iBAAkBA,EAAK,iBACvB,UAAW,CACP,CACI,MAAO,GACP,SAAU,CACN,KAAMA,EAAK,IACX,KAAM,mBACN,gBAAiB,iBAAA,EAErB,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,aAAc,CAAC,GAAG,EAClB,MAAO,CAAC,QAAQ,CAAA,EAEpB,MAAO,mBACP,WAAY,IACZ,OAAQ,EAAA,CACZ,EAEJ,SAAU,CAAA,CAAC,CACd,EAMD,GAJAI,EAAMC,EAAE,+BAA+B,EAAG,CACtC,KAAM,iBAAA,CACT,EAEGF,EAAU,CACV,MAAMG,EAAe,MAAMR,EAAgBK,CAAQ,EACnDT,EAAgBY,CAAY,CAAA,CAChC,OACKC,EAAG,CACR,QAAQ,MAAMA,CAAC,CAAA,CACnB,EAEJ,CAACd,EAAgBK,EAAiBJ,EAAiBW,CAAC,CAAA,EAWxD,OAT0B1C,EACtB,IACI2B,EAAU,gBAAiB,CACvB,gBAAAS,EACA,iBAAAS,CAAA,CACH,EACL,CAACT,EAAiBS,EAAkBlB,CAAS,CAAA,CAIrD"}
1
+ {"version":3,"file":"modals.Dn_ncIrB.js","sources":["../../src/hooks/useUiNodes.ts","../../src/hooks/modals.ts"],"sourcesContent":["import { makeNodeSlugFromNodeName } from '#utils';\nimport {\n DRIVE,\n FILE,\n FOLDER,\n LOCAL,\n PUBLIC,\n type SharingType,\n SUCCESS,\n type UiDriveNode,\n type UiFileNode,\n type UiFolderNode,\n type UiNode,\n} from '@powerhousedao/design-system';\nimport { useUiNodesContext } from '@powerhousedao/reactor-browser/hooks/useUiNodesContext';\nimport { type DocumentDriveDocument, type ReadDrive } from 'document-drive';\nimport { useCallback, useMemo } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer.js';\n\nexport function useMakeUiDriveNode() {\n const { getSyncStatus } = useDocumentDriveServer();\n const makeUiDriveNode = useCallback(\n async (drive: DocumentDriveDocument | ReadDrive) => {\n const isReadDrive = 'readContext' in drive;\n const { name, icon } = drive.state.global;\n const { id, slug } = drive.header;\n const { sharingType: _sharingType, availableOffline } = !isReadDrive\n ? drive.state.local\n : { sharingType: PUBLIC, availableOffline: false };\n const __sharingType = _sharingType?.toUpperCase();\n const sharingType = (\n __sharingType === 'PRIVATE' ? LOCAL : __sharingType\n ) as SharingType;\n const driveSyncStatus = !isReadDrive\n ? await getSyncStatus(id, sharingType)\n : undefined;\n\n // TODO: rempve this after integration in design-system\n const normalizedDriveSyncStatus =\n driveSyncStatus === 'INITIAL_SYNC'\n ? 'SYNCING'\n : driveSyncStatus;\n\n const driveNode: UiDriveNode = {\n id,\n name,\n slug: slug || null,\n kind: DRIVE,\n children: [],\n nodeMap: {},\n sharingType,\n syncStatus: normalizedDriveSyncStatus,\n availableOffline,\n icon,\n parentFolder: null,\n driveId: id,\n };\n\n const nodes = drive.state.global.nodes.map(n => {\n const node = {\n ...n,\n slug: makeNodeSlugFromNodeName(n.name),\n driveId: id,\n parentFolder: n.parentFolder || id,\n kind: n.kind.toUpperCase(),\n syncStatus: normalizedDriveSyncStatus,\n sharingType,\n };\n\n if (node.kind === DRIVE) {\n throw new Error('Drive nodes should not be nested');\n }\n\n if (node.kind === FILE) {\n return node as UiFileNode;\n }\n\n return {\n ...node,\n children: [],\n } as UiFolderNode;\n });\n\n for (const node of nodes) {\n driveNode.nodeMap[node.id] = node;\n }\n\n // eslint-disable-next-line @typescript-eslint/await-thenable\n for await (const node of nodes) {\n if (node.kind === FILE) {\n const fileSyncStatus = !isReadDrive\n ? await getSyncStatus(\n node.synchronizationUnits[0].syncId,\n sharingType,\n )\n : undefined;\n\n // TODO: rempve this after integration in design-system\n const normalizedFileSyncStatus =\n fileSyncStatus === 'INITIAL_SYNC'\n ? 'SYNCING'\n : fileSyncStatus;\n\n node.syncStatus = normalizedFileSyncStatus;\n }\n\n if (node.parentFolder === id) {\n driveNode.children.push(node);\n continue;\n }\n const parent = driveNode.nodeMap[node.parentFolder];\n\n if (parent.kind === FILE) {\n throw new Error(\n `Parent node ${node.parentFolder} is a file, not a folder`,\n );\n }\n\n parent.children.push(node);\n\n if (node.syncStatus !== SUCCESS) {\n parent.syncStatus = node.syncStatus;\n }\n }\n\n return driveNode;\n },\n [getSyncStatus],\n );\n\n return makeUiDriveNode;\n}\n\nexport function useDebugHandlers() {\n const { removeTrigger, addTrigger, registerNewPullResponderTrigger } =\n useDocumentDriveServer();\n\n const onAddTrigger = useCallback(\n async (uiNodeDriveId: string) => {\n const url = window.prompt('url') || '';\n\n const pullResponderTrigger = await registerNewPullResponderTrigger(\n uiNodeDriveId,\n url,\n { pullInterval: 6000 },\n );\n await addTrigger(uiNodeDriveId, pullResponderTrigger);\n },\n [addTrigger, registerNewPullResponderTrigger],\n );\n\n const onRemoveTrigger = useCallback(\n async (uiNodeDriveId: string) => {\n const triggerId = window.prompt('triggerId:');\n\n if (triggerId) {\n await removeTrigger(uiNodeDriveId, triggerId);\n }\n },\n [removeTrigger],\n );\n\n const onAddInvalidTrigger = useCallback(\n async (uiNodeDriveId: string) => {\n const url = window.prompt('url') || '';\n\n await addTrigger(uiNodeDriveId, {\n id: 'some-invalid-id',\n type: 'PullResponder',\n data: {\n interval: '3000',\n listenerId: 'invalid-listener-id',\n url,\n },\n });\n },\n [addTrigger],\n );\n\n return {\n onAddTrigger,\n onRemoveTrigger,\n onAddInvalidTrigger,\n };\n}\n\nexport function useUiNodes() {\n const { selectedParentNode, setSelectedNode } = useUiNodesContext();\n const { addFolder, addFile, renameNode, copyNode, moveNode } =\n useDocumentDriveServer();\n\n const onAddFile = useCallback(\n async (file: File, parentNode: UiNode | null) => {\n if (!parentNode) {\n throw new Error('Parent node is required');\n }\n if (parentNode.kind === FILE) {\n throw new Error('Cannot add file to a file');\n }\n\n const fileName = file.name.replace(/\\.zip$/gim, '');\n\n return await addFile(\n file,\n parentNode.driveId,\n fileName,\n parentNode.id,\n );\n },\n [addFile],\n );\n\n const onAddFolder = useCallback(\n async (name: string, parentNode: UiNode | null) => {\n if (!parentNode) {\n throw new Error('Parent node is required');\n }\n if (parentNode.kind === FILE) {\n throw new Error('Cannot add folder to a file');\n }\n return await addFolder(parentNode.driveId, name, parentNode.id);\n },\n [addFolder],\n );\n\n const onRenameNode = useCallback(\n async (name: string, uiNode: UiNode) => {\n if (uiNode.kind === DRIVE) {\n throw new Error(\n 'Drive can only be renamed from the drive settings modal',\n );\n }\n return await renameNode(uiNode.driveId, uiNode.id, name);\n },\n [renameNode],\n );\n\n const onCopyNode = useCallback(\n async (uiNode: UiNode, targetNode: UiNode) => {\n if (uiNode.kind === DRIVE) {\n throw new Error('Drive cannot be duplicated');\n }\n\n await copyNode(uiNode, targetNode);\n },\n [copyNode],\n );\n\n const onMoveNode = useCallback(\n async (uiNode: UiNode, targetNode: UiNode) => {\n if (uiNode.kind === DRIVE) {\n throw new Error('Drive cannot be moved');\n }\n\n await moveNode(uiNode, targetNode);\n },\n [moveNode],\n );\n\n const onDuplicateNode = useCallback(\n async (uiNode: UiNode) => {\n if (!selectedParentNode) return;\n\n if (uiNode.kind === DRIVE) {\n throw new Error('Drive cannot be duplicated');\n }\n\n await copyNode(uiNode, selectedParentNode);\n },\n [copyNode, selectedParentNode],\n );\n\n const onAddAndSelectNewFolder = useCallback(\n async (name: string) => {\n if (!name || !selectedParentNode) return;\n\n const newFolder = await onAddFolder(name, selectedParentNode);\n\n setSelectedNode({\n ...newFolder,\n kind: FOLDER,\n slug: makeNodeSlugFromNodeName(newFolder.name),\n parentFolder: selectedParentNode.id,\n syncStatus: selectedParentNode.syncStatus,\n driveId: selectedParentNode.driveId,\n sharingType: selectedParentNode.sharingType,\n children: [],\n });\n },\n [onAddFolder, selectedParentNode, setSelectedNode],\n );\n\n return useMemo(\n () => ({\n onAddFile,\n onAddFolder,\n onRenameNode,\n onCopyNode,\n onMoveNode,\n onDuplicateNode,\n onAddAndSelectNewFolder,\n }),\n [\n onAddFolder,\n onAddFile,\n onCopyNode,\n onMoveNode,\n onRenameNode,\n onDuplicateNode,\n onAddAndSelectNewFolder,\n ],\n );\n}\n\nexport type TUiNodes = ReturnType<typeof useUiNodes>;\n","import { useModal } from '#components';\nimport { useApps } from '#store';\nimport {\n toast,\n type AddLocalDriveInput,\n type AddRemoteDriveInput,\n} from '@powerhousedao/design-system';\nimport {\n FOLDER,\n useUiNodesContext,\n type SharingType,\n type UiDriveNode,\n type UiFileNode,\n type UiFolderNode,\n} from '@powerhousedao/reactor-browser';\nimport { t } from 'i18next';\nimport { useCallback } from 'react';\nimport { useDocumentDriveServer } from './useDocumentDriveServer';\nimport { useMakeUiDriveNode } from './useUiNodes';\n\nexport function useShowAddDriveModal() {\n const { showModal } = useModal();\n const { addDrive, addRemoteDrive } = useDocumentDriveServer();\n const { setSelectedNode } = useUiNodesContext();\n const apps = useApps();\n const makeUiDriveNode = useMakeUiDriveNode();\n const onAddLocalDrive = useCallback(\n async (data: AddLocalDriveInput) => {\n try {\n const app = apps.find(a => a.id === data.appId);\n const newDrive = await addDrive(\n {\n id: '',\n slug: '',\n global: {\n name: data.name,\n icon: null,\n },\n local: {\n availableOffline: data.availableOffline,\n sharingType: data.sharingType.toLowerCase(),\n listeners: [],\n triggers: [],\n },\n },\n app?.driveEditor,\n );\n\n toast(t('notifications.addDriveSuccess'), {\n type: 'connect-success',\n });\n\n if (newDrive) {\n const newDriveNode = await makeUiDriveNode(newDrive);\n setSelectedNode(newDriveNode);\n }\n } catch (e) {\n console.error(e);\n }\n },\n [addDrive, makeUiDriveNode, setSelectedNode, t],\n );\n\n const onAddRemoteDrive = useCallback(\n async (data: AddRemoteDriveInput) => {\n try {\n const newDrive = await addRemoteDrive(data.url, {\n sharingType: data.sharingType,\n availableOffline: data.availableOffline,\n listeners: [\n {\n block: true,\n callInfo: {\n data: data.url,\n name: 'switchboard-push',\n transmitterType: 'SwitchboardPush',\n },\n filter: {\n branch: ['main'],\n documentId: ['*'],\n documentType: ['*'],\n scope: ['global'],\n },\n label: 'Switchboard Sync',\n listenerId: '1',\n system: true,\n },\n ],\n triggers: [],\n });\n\n toast(t('notifications.addDriveSuccess'), {\n type: 'connect-success',\n });\n\n if (newDrive) {\n const newDriveNode = await makeUiDriveNode(newDrive);\n setSelectedNode(newDriveNode);\n }\n } catch (e) {\n console.error(e);\n }\n },\n [addRemoteDrive, makeUiDriveNode, setSelectedNode, t],\n );\n const showAddDriveModal = useCallback(\n () =>\n showModal('addDriveModal', {\n onAddLocalDrive,\n onAddRemoteDrive,\n }),\n [onAddLocalDrive, onAddRemoteDrive, showModal],\n );\n\n return showAddDriveModal;\n}\n\nexport function useShowDriveSettingsModal() {\n const { showModal } = useModal();\n const {\n renameDrive,\n setDriveAvailableOffline,\n setDriveSharingType,\n deleteDrive,\n } = useDocumentDriveServer();\n const { driveNodes, setSelectedNode } = useUiNodesContext();\n const onRenameDrive = useCallback(\n async (uiDriveNode: UiDriveNode, newName: string) => {\n await renameDrive(uiDriveNode.id, newName);\n },\n [renameDrive],\n );\n\n const onChangeSharingType = useCallback(\n async (uiDriveNode: UiDriveNode, newSharingType: SharingType) => {\n await setDriveSharingType(uiDriveNode.id, newSharingType);\n },\n [setDriveSharingType],\n );\n\n const onChangeAvailableOffline = useCallback(\n async (uiDriveNode: UiDriveNode, newAvailableOffline: boolean) => {\n await setDriveAvailableOffline(uiDriveNode.id, newAvailableOffline);\n },\n [setDriveAvailableOffline],\n );\n const onDeleteDrive = useCallback(\n (uiDriveNode: UiDriveNode) => {\n showModal('deleteDriveModal', {\n uiDriveNode,\n onDelete: async closeModal => {\n closeModal();\n await deleteDrive(uiDriveNode.id);\n\n setSelectedNode(driveNodes[0]);\n\n toast(t('notifications.deleteDriveSuccess'), {\n type: 'connect-deleted',\n });\n },\n });\n },\n [deleteDrive, driveNodes, setSelectedNode, showModal, t],\n );\n const showDriveSettingsModal = useCallback(\n (uiDriveNode: UiDriveNode) => {\n showModal('driveSettings', {\n uiDriveNode,\n onRenameDrive,\n onDeleteDrive,\n onChangeSharingType,\n onChangeAvailableOffline,\n });\n },\n [\n onChangeAvailableOffline,\n onChangeSharingType,\n onDeleteDrive,\n onRenameDrive,\n showModal,\n ],\n );\n\n return showDriveSettingsModal;\n}\n\nexport function useShowDeleteNodeModal() {\n const { showModal } = useModal();\n const { setSelectedNode, getParentNode } = useUiNodesContext();\n const { deleteNode } = useDocumentDriveServer();\n const showDeleteNodeModal = useCallback(\n (uiNode: UiFileNode | UiFolderNode) => {\n showModal('deleteItem', {\n uiNode,\n onDelete: async closeModal => {\n closeModal();\n\n const i18nKey =\n uiNode.kind === FOLDER\n ? 'notifications.deleteFolderSuccess'\n : 'notifications.fileDeleteSuccess';\n\n const parentNode = getParentNode(uiNode);\n\n await deleteNode(uiNode.driveId, uiNode.id);\n\n setSelectedNode(parentNode);\n\n toast(t(i18nKey), { type: 'connect-deleted' });\n },\n });\n },\n [deleteNode, getParentNode, setSelectedNode, showModal, t],\n );\n\n return showDeleteNodeModal;\n}\n"],"names":["useMakeUiDriveNode","getSyncStatus","useDocumentDriveServer","useCallback","drive","isReadDrive","name","icon","id","slug","_sharingType","availableOffline","PUBLIC","__sharingType","sharingType","LOCAL","driveSyncStatus","normalizedDriveSyncStatus","driveNode","DRIVE","nodes","n","node","makeNodeSlugFromNodeName","FILE","fileSyncStatus","normalizedFileSyncStatus","parent","SUCCESS","useShowAddDriveModal","showModal","useModal","addDrive","addRemoteDrive","setSelectedNode","useUiNodesContext","apps","useApps","makeUiDriveNode","onAddLocalDrive","data","app","a","newDrive","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AAA,CACnB,EAEJ,CAACf,EAAUM,EAAiBJ,EAAiBW,CAAC,CAAA,EAG5CG,EAAmB7C,EACrB,MAAOqC,GAA8B,CACjC,GAAI,CACA,MAAMG,EAAW,MAAMV,EAAeO,EAAK,IAAK,CAC5C,YAAaA,EAAK,YAClB,iBAAkBA,EAAK,iBACvB,UAAW,CACP,CACI,MAAO,GACP,SAAU,CACN,KAAMA,EAAK,IACX,KAAM,mBACN,gBAAiB,iBAAA,EAErB,OAAQ,CACJ,OAAQ,CAAC,MAAM,EACf,WAAY,CAAC,GAAG,EAChB,aAAc,CAAC,GAAG,EAClB,MAAO,CAAC,QAAQ,CAAA,EAEpB,MAAO,mBACP,WAAY,IACZ,OAAQ,EAAA,CACZ,EAEJ,SAAU,CAAA,CAAC,CACd,EAMD,GAJAI,EAAMC,EAAE,+BAA+B,EAAG,CACtC,KAAM,iBAAA,CACT,EAEGF,EAAU,CACV,MAAMG,EAAe,MAAMR,EAAgBK,CAAQ,EACnDT,EAAgBY,CAAY,CAAA,CAChC,OACKC,EAAG,CACR,QAAQ,MAAMA,CAAC,CAAA,CACnB,EAEJ,CAACd,EAAgBK,EAAiBJ,EAAiBW,CAAC,CAAA,EAWxD,OAT0B1C,EACtB,IACI2B,EAAU,gBAAiB,CACvB,gBAAAS,EACA,iBAAAS,CAAA,CACH,EACL,CAACT,EAAiBS,EAAkBlB,CAAS,CAAA,CAIrD"}
@@ -1,2 +1,2 @@
1
- var h=Object.defineProperty;var c=i=>{throw TypeError(i)};var u=(i,e,r)=>e in i?h(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>u(i,typeof e!="symbol"?e+"":e,r),k=(i,e,r)=>e.has(i)||c("Cannot "+r);var d=(i,e,r)=>e.has(i)?c("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,r);var s=(i,e,r)=>(k(i,e,"access private method"),r);import{c as g}from"./connect.config.Dg2s1YFW.js";const f=parseInt(window.__VITE_ENVS.PH_CONNECT_VERSION_CHECK_INTERVAL)||60*60*1e3,w=g.routerBasename,W=[w,"service-worker.js"].join("/").replace(/\/{2,}/gm,"/");var a,l,n;class E{constructor(e=!1){d(this,a);o(this,"ready",!1);o(this,"debug",!1);o(this,"registration",null);this.debug=e}setDebug(e){this.debug=e}registerServiceWorker(e=!1){if(this.debug=e,!("serviceWorker"in navigator)){console.warn("Service Worker not available");return}window.addEventListener("load",async()=>{try{const r=await navigator.serviceWorker.getRegistration();if(r)await r.update(),s(this,a,n).call(this,r);else{const t=await navigator.serviceWorker.register(W);s(this,a,n).call(this,t),t.addEventListener("updatefound",()=>{s(this,a,n).call(this,t)})}const v=setInterval(async()=>{const t=await navigator.serviceWorker.getRegistration();t?await t.update():(clearInterval(v),this.registerServiceWorker())},f)}catch(r){console.error("ServiceWorker registration failed: ",r)}})}}a=new WeakSet,l=function(e){this.debug&&console.log("ServiceWorker message: ",e);const r="type"in e.data?e:null;switch(r==null?void 0:r.data.type){case"NEW_VERSION_AVAILABLE":{if(r.data.version===g.appVersion)return;r.data.requiresHardRefresh&&(this.debug&&console.log("New version available"),window.location.reload());break}default:{console.warn("Unhandled message:",r);break}}},n=function(e){this.debug&&console.log("ServiceWorker registered: ",e),navigator.serviceWorker.addEventListener("message",s(this,a,l).bind(this)),this.registration=e,this.ready=!0};const p=new E;export{p as s};
2
- //# sourceMappingURL=registerServiceWorker.DTjJlxaP.js.map
1
+ var h=Object.defineProperty;var c=i=>{throw TypeError(i)};var u=(i,e,r)=>e in i?h(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var o=(i,e,r)=>u(i,typeof e!="symbol"?e+"":e,r),k=(i,e,r)=>e.has(i)||c("Cannot "+r);var d=(i,e,r)=>e.has(i)?c("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,r);var s=(i,e,r)=>(k(i,e,"access private method"),r);import{c as g}from"./connect.config.rJjJZvYA.js";const f=parseInt(window.__VITE_ENVS.PH_CONNECT_VERSION_CHECK_INTERVAL)||60*60*1e3,w=g.routerBasename,W=[w,"service-worker.js"].join("/").replace(/\/{2,}/gm,"/");var a,l,n;class E{constructor(e=!1){d(this,a);o(this,"ready",!1);o(this,"debug",!1);o(this,"registration",null);this.debug=e}setDebug(e){this.debug=e}registerServiceWorker(e=!1){if(this.debug=e,!("serviceWorker"in navigator)){console.warn("Service Worker not available");return}window.addEventListener("load",async()=>{try{const r=await navigator.serviceWorker.getRegistration();if(r)await r.update(),s(this,a,n).call(this,r);else{const t=await navigator.serviceWorker.register(W);s(this,a,n).call(this,t),t.addEventListener("updatefound",()=>{s(this,a,n).call(this,t)})}const v=setInterval(async()=>{const t=await navigator.serviceWorker.getRegistration();t?await t.update():(clearInterval(v),this.registerServiceWorker())},f)}catch(r){console.error("ServiceWorker registration failed: ",r)}})}}a=new WeakSet,l=function(e){this.debug&&console.log("ServiceWorker message: ",e);const r="type"in e.data?e:null;switch(r==null?void 0:r.data.type){case"NEW_VERSION_AVAILABLE":{if(r.data.version===g.appVersion)return;r.data.requiresHardRefresh&&(this.debug&&console.log("New version available"),window.location.reload());break}default:{console.warn("Unhandled message:",r);break}}},n=function(e){this.debug&&console.log("ServiceWorker registered: ",e),navigator.serviceWorker.addEventListener("message",s(this,a,l).bind(this)),this.registration=e,this.ready=!0};const p=new E;export{p as s};
2
+ //# sourceMappingURL=registerServiceWorker.CFFodjhC.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registerServiceWorker.DTjJlxaP.js","sources":["../../src/utils/registerServiceWorker.ts"],"sourcesContent":["import connectConfig from '../connect.config.js';\nimport { type ServiceWorkerMessage } from '../service-worker.js';\n\nconst VERSION_CHECK_INTERVAL =\n parseInt(import.meta.env.PH_CONNECT_VERSION_CHECK_INTERVAL) ||\n 60 * 60 * 1000; // 1 hour;\n\nconst basePath = connectConfig.routerBasename;\n\nconst serviceWorkerScriptPath = [basePath, 'service-worker.js']\n .join('/')\n .replace(/\\/{2,}/gm, '/');\n\nexport interface IServiceWorkerMessageData {\n type: string;\n}\n\nexport interface ServiceWorkerEvent<T extends IServiceWorkerMessageData>\n extends ExtendableMessageEvent {\n data: T;\n}\n\nclass ServiceWorkerManager {\n ready = false;\n debug = false;\n registration: ServiceWorkerRegistration | null = null;\n\n constructor(debug = false) {\n this.debug = debug;\n }\n\n setDebug(debug: boolean) {\n this.debug = debug;\n }\n\n #handleServiceWorkerMessage(event: MessageEvent | ServiceWorkerMessage) {\n if (this.debug) {\n console.log('ServiceWorker message: ', event);\n }\n const message =\n 'type' in event.data ? (event as ServiceWorkerMessage) : null;\n switch (message?.data.type) {\n case 'NEW_VERSION_AVAILABLE': {\n if (message.data.version === connectConfig.appVersion) {\n return;\n }\n if (message.data.requiresHardRefresh) {\n if (this.debug) {\n console.log('New version available');\n }\n\n window.location.reload(); // Reload the page to load the new version\n }\n break;\n }\n default: {\n console.warn('Unhandled message:', message);\n break;\n }\n }\n }\n\n #handleServiceWorker(registration: ServiceWorkerRegistration) {\n {\n // Listen for messages from the service worker\n if (this.debug) {\n console.log('ServiceWorker registered: ', registration);\n }\n\n navigator.serviceWorker.addEventListener(\n 'message',\n this.#handleServiceWorkerMessage.bind(this),\n );\n\n this.registration = registration;\n this.ready = true;\n }\n }\n\n registerServiceWorker(debug = false) {\n this.debug = debug;\n\n if (!('serviceWorker' in navigator)) {\n console.warn('Service Worker not available');\n return;\n }\n window.addEventListener('load', async () => {\n try {\n // checks if there is a service worker installed already and calls\n // its the update method to check if there is a new version available\n const existingRegistration =\n await navigator.serviceWorker.getRegistration();\n if (existingRegistration) {\n await existingRegistration.update();\n this.#handleServiceWorker(existingRegistration);\n }\n\n // if no service worker is installed then registers the service worker\n else {\n const registration = await navigator.serviceWorker.register(\n serviceWorkerScriptPath,\n );\n this.#handleServiceWorker(registration);\n\n registration.addEventListener('updatefound', () => {\n this.#handleServiceWorker(registration);\n });\n }\n\n // calls the update on an interval to force\n // the browser to check for a new version\n const intervalId = setInterval(async () => {\n const existingRegistration =\n await navigator.serviceWorker.getRegistration();\n if (existingRegistration) {\n await existingRegistration.update();\n } else {\n clearInterval(intervalId);\n this.registerServiceWorker();\n }\n }, VERSION_CHECK_INTERVAL);\n } catch (error) {\n console.error('ServiceWorker registration failed: ', error);\n }\n });\n }\n}\n\nexport const serviceWorkerManager = new ServiceWorkerManager();\n"],"names":["VERSION_CHECK_INTERVAL","basePath","connectConfig","serviceWorkerScriptPath","ServiceWorkerManager","debug","__privateAdd","_ServiceWorkerManager_instances","__publicField","existingRegistration","__privateMethod","handleServiceWorker_fn","registration","intervalId","error","handleServiceWorkerMessage_fn","event","message","serviceWorkerManager"],"mappings":"icAGA,MAAMA,EACF,SAAS,OAAA,YAAA,iCAAiD,GAC1D,GAAK,GAAK,IAERC,EAAWC,EAAc,eAEzBC,EAA0B,CAACF,EAAU,mBAAmB,EACzD,KAAK,GAAG,EACR,QAAQ,WAAY,GAAG,YAW5B,MAAMG,CAAqB,CAKvB,YAAYC,EAAQ,GAAO,CAL/BC,EAAA,KAAAC,GACIC,EAAA,aAAQ,IACRA,EAAA,aAAQ,IACRA,EAAA,oBAAiD,MAG7C,KAAK,MAAQH,CAAA,CAGjB,SAASA,EAAgB,CACrB,KAAK,MAAQA,CAAA,CA+CjB,sBAAsBA,EAAQ,GAAO,CAGjC,GAFA,KAAK,MAAQA,EAET,EAAE,kBAAmB,WAAY,CACjC,QAAQ,KAAK,8BAA8B,EAC3C,MAAA,CAEJ,OAAO,iBAAiB,OAAQ,SAAY,CACxC,GAAI,CAGA,MAAMI,EACF,MAAM,UAAU,cAAc,gBAAA,EAClC,GAAIA,EACA,MAAMA,EAAqB,OAAA,EAC3BC,EAAA,KAAKH,EAAAI,GAAL,UAA0BF,OAIzB,CACD,MAAMG,EAAe,MAAM,UAAU,cAAc,SAC/CT,CAAA,EAEJO,EAAA,KAAKH,EAAAI,GAAL,UAA0BC,GAE1BA,EAAa,iBAAiB,cAAe,IAAM,CAC/CF,EAAA,KAAKH,EAAAI,GAAL,UAA0BC,EAAY,CACzC,CAAA,CAKL,MAAMC,EAAa,YAAY,SAAY,CACvC,MAAMJ,EACF,MAAM,UAAU,cAAc,gBAAA,EAC9BA,EACA,MAAMA,EAAqB,OAAA,GAE3B,cAAcI,CAAU,EACxB,KAAK,sBAAA,EACT,EACDb,CAAsB,CAAA,OACpBc,EAAO,CACZ,QAAQ,MAAM,sCAAuCA,CAAK,CAAA,CAC9D,CACH,CAAA,CAET,CAxGAP,EAAA,YAaIQ,WAA4BC,EAA4C,CAChE,KAAK,OACL,QAAQ,IAAI,0BAA2BA,CAAK,EAEhD,MAAMC,EACF,SAAUD,EAAM,KAAQA,EAAiC,KAC7D,OAAQC,GAAA,YAAAA,EAAS,KAAK,KAAA,CAClB,IAAK,wBAAyB,CAC1B,GAAIA,EAAQ,KAAK,UAAYf,EAAc,WACvC,OAEAe,EAAQ,KAAK,sBACT,KAAK,OACL,QAAQ,IAAI,uBAAuB,EAGvC,OAAO,SAAS,OAAA,GAEpB,KAAA,CAEJ,QAAS,CACL,QAAQ,KAAK,qBAAsBA,CAAO,EAC1C,KAAA,CACJ,CACJ,EAGJN,WAAqBC,EAAyC,CAGlD,KAAK,OACL,QAAQ,IAAI,6BAA8BA,CAAY,EAG1D,UAAU,cAAc,iBACpB,UACAF,EAAA,KAAKH,EAAAQ,GAA4B,KAAK,IAAI,CAAA,EAG9C,KAAK,aAAeH,EACpB,KAAK,MAAQ,EACjB,EAoDD,MAAMM,EAAuB,IAAId"}
1
+ {"version":3,"file":"registerServiceWorker.CFFodjhC.js","sources":["../../src/utils/registerServiceWorker.ts"],"sourcesContent":["import connectConfig from '../connect.config.js';\nimport { type ServiceWorkerMessage } from '../service-worker.js';\n\nconst VERSION_CHECK_INTERVAL =\n parseInt(import.meta.env.PH_CONNECT_VERSION_CHECK_INTERVAL) ||\n 60 * 60 * 1000; // 1 hour;\n\nconst basePath = connectConfig.routerBasename;\n\nconst serviceWorkerScriptPath = [basePath, 'service-worker.js']\n .join('/')\n .replace(/\\/{2,}/gm, '/');\n\nexport interface IServiceWorkerMessageData {\n type: string;\n}\n\nexport interface ServiceWorkerEvent<T extends IServiceWorkerMessageData>\n extends ExtendableMessageEvent {\n data: T;\n}\n\nclass ServiceWorkerManager {\n ready = false;\n debug = false;\n registration: ServiceWorkerRegistration | null = null;\n\n constructor(debug = false) {\n this.debug = debug;\n }\n\n setDebug(debug: boolean) {\n this.debug = debug;\n }\n\n #handleServiceWorkerMessage(event: MessageEvent | ServiceWorkerMessage) {\n if (this.debug) {\n console.log('ServiceWorker message: ', event);\n }\n const message =\n 'type' in event.data ? (event as ServiceWorkerMessage) : null;\n switch (message?.data.type) {\n case 'NEW_VERSION_AVAILABLE': {\n if (message.data.version === connectConfig.appVersion) {\n return;\n }\n if (message.data.requiresHardRefresh) {\n if (this.debug) {\n console.log('New version available');\n }\n\n window.location.reload(); // Reload the page to load the new version\n }\n break;\n }\n default: {\n console.warn('Unhandled message:', message);\n break;\n }\n }\n }\n\n #handleServiceWorker(registration: ServiceWorkerRegistration) {\n {\n // Listen for messages from the service worker\n if (this.debug) {\n console.log('ServiceWorker registered: ', registration);\n }\n\n navigator.serviceWorker.addEventListener(\n 'message',\n this.#handleServiceWorkerMessage.bind(this),\n );\n\n this.registration = registration;\n this.ready = true;\n }\n }\n\n registerServiceWorker(debug = false) {\n this.debug = debug;\n\n if (!('serviceWorker' in navigator)) {\n console.warn('Service Worker not available');\n return;\n }\n window.addEventListener('load', async () => {\n try {\n // checks if there is a service worker installed already and calls\n // its the update method to check if there is a new version available\n const existingRegistration =\n await navigator.serviceWorker.getRegistration();\n if (existingRegistration) {\n await existingRegistration.update();\n this.#handleServiceWorker(existingRegistration);\n }\n\n // if no service worker is installed then registers the service worker\n else {\n const registration = await navigator.serviceWorker.register(\n serviceWorkerScriptPath,\n );\n this.#handleServiceWorker(registration);\n\n registration.addEventListener('updatefound', () => {\n this.#handleServiceWorker(registration);\n });\n }\n\n // calls the update on an interval to force\n // the browser to check for a new version\n const intervalId = setInterval(async () => {\n const existingRegistration =\n await navigator.serviceWorker.getRegistration();\n if (existingRegistration) {\n await existingRegistration.update();\n } else {\n clearInterval(intervalId);\n this.registerServiceWorker();\n }\n }, VERSION_CHECK_INTERVAL);\n } catch (error) {\n console.error('ServiceWorker registration failed: ', error);\n }\n });\n }\n}\n\nexport const serviceWorkerManager = new ServiceWorkerManager();\n"],"names":["VERSION_CHECK_INTERVAL","basePath","connectConfig","serviceWorkerScriptPath","ServiceWorkerManager","debug","__privateAdd","_ServiceWorkerManager_instances","__publicField","existingRegistration","__privateMethod","handleServiceWorker_fn","registration","intervalId","error","handleServiceWorkerMessage_fn","event","message","serviceWorkerManager"],"mappings":"icAGA,MAAMA,EACF,SAAS,OAAA,YAAA,iCAAiD,GAC1D,GAAK,GAAK,IAERC,EAAWC,EAAc,eAEzBC,EAA0B,CAACF,EAAU,mBAAmB,EACzD,KAAK,GAAG,EACR,QAAQ,WAAY,GAAG,YAW5B,MAAMG,CAAqB,CAKvB,YAAYC,EAAQ,GAAO,CAL/BC,EAAA,KAAAC,GACIC,EAAA,aAAQ,IACRA,EAAA,aAAQ,IACRA,EAAA,oBAAiD,MAG7C,KAAK,MAAQH,CAAA,CAGjB,SAASA,EAAgB,CACrB,KAAK,MAAQA,CAAA,CA+CjB,sBAAsBA,EAAQ,GAAO,CAGjC,GAFA,KAAK,MAAQA,EAET,EAAE,kBAAmB,WAAY,CACjC,QAAQ,KAAK,8BAA8B,EAC3C,MAAA,CAEJ,OAAO,iBAAiB,OAAQ,SAAY,CACxC,GAAI,CAGA,MAAMI,EACF,MAAM,UAAU,cAAc,gBAAA,EAClC,GAAIA,EACA,MAAMA,EAAqB,OAAA,EAC3BC,EAAA,KAAKH,EAAAI,GAAL,UAA0BF,OAIzB,CACD,MAAMG,EAAe,MAAM,UAAU,cAAc,SAC/CT,CAAA,EAEJO,EAAA,KAAKH,EAAAI,GAAL,UAA0BC,GAE1BA,EAAa,iBAAiB,cAAe,IAAM,CAC/CF,EAAA,KAAKH,EAAAI,GAAL,UAA0BC,EAAY,CACzC,CAAA,CAKL,MAAMC,EAAa,YAAY,SAAY,CACvC,MAAMJ,EACF,MAAM,UAAU,cAAc,gBAAA,EAC9BA,EACA,MAAMA,EAAqB,OAAA,GAE3B,cAAcI,CAAU,EACxB,KAAK,sBAAA,EACT,EACDb,CAAsB,CAAA,OACpBc,EAAO,CACZ,QAAQ,MAAM,sCAAuCA,CAAK,CAAA,CAC9D,CACH,CAAA,CAET,CAxGAP,EAAA,YAaIQ,WAA4BC,EAA4C,CAChE,KAAK,OACL,QAAQ,IAAI,0BAA2BA,CAAK,EAEhD,MAAMC,EACF,SAAUD,EAAM,KAAQA,EAAiC,KAC7D,OAAQC,GAAA,YAAAA,EAAS,KAAK,KAAA,CAClB,IAAK,wBAAyB,CAC1B,GAAIA,EAAQ,KAAK,UAAYf,EAAc,WACvC,OAEAe,EAAQ,KAAK,sBACT,KAAK,OACL,QAAQ,IAAI,uBAAuB,EAGvC,OAAO,SAAS,OAAA,GAEpB,KAAA,CAEJ,QAAS,CACL,QAAQ,KAAK,qBAAsBA,CAAO,EAC1C,KAAA,CACJ,CACJ,EAGJN,WAAqBC,EAAyC,CAGlD,KAAK,OACL,QAAQ,IAAI,6BAA8BA,CAAY,EAG1D,UAAU,cAAc,iBACpB,UACAF,EAAA,KAAKH,EAAAQ,GAA4B,KAAK,IAAI,CAAA,EAG9C,KAAK,aAAeH,EACpB,KAAK,MAAQ,EACjB,EAoDD,MAAMM,EAAuB,IAAId"}
@@ -1,8 +1,8 @@
1
- import{jsx as m,jsxs as M}from"react/jsx-runtime";import*as v from"react";import{useCallback as E,useEffect as y,Suspense as G,useState as U,useRef as I,useMemo as W}from"react";import{d as Y,c as q}from"./app.Cczb-JTX.js";import{E as z,g as x}from"./react-error-boundary.esm.CHwBetsO.js";import{e as H,O as J,d as K,i as Q}from"./index.CAUjMUXb.js";import{u as X,a as e1}from"./modals.BDBwwAHa.js";import{x as P,C as t1,n as D,ae as n1,af as r1,B as s1,ag as O,ah as o1,ai as k,aj as a1,L as i1,ak as c1}from"./index.Ds87Cbij.js";import{useModal as l1,ModalManager as d1}from"./modal.CoChI3Z8.js";import{j as A,h as u1,i as C1}from"./useFeatureFlags.DwHJ60S4.js";import{u as j}from"./useConnectConfig.Dk_0m-Ti.js";import{t as V}from"./toast.M8Yl2BMq.js";import{u as B}from"./useTranslation.BpVv6XIW.js";import{u as F}from"./useDocumentDriveServer.BCFajpQ5.js";import"./connect.config.Dg2s1YFW.js";import"./browser.BkwNmV2Z.js";import"./user.GGI-kGd1.js";import"./index.B35eoM_p.js";import"react-dom/client";import"./app-skeleton.js";import"./useAcceptedCookies.B0GL_rH8.js";import"react-dom";import"./registerServiceWorker.DTjJlxaP.js";import"./i18next.CqOP20KE.js";import"./slug.C6xW_7Wm.js";const m1=e=>v.createElement("svg",{width:107,height:20,viewBox:"0 0 107 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("path",{d:"M0.666504 10.1087C0.666504 8.30419 1.056 6.69918 1.83499 5.29371C2.61398 3.8709 3.6959 2.76908 5.08077 1.98827C6.48295 1.1901 8.0669 0.791016 9.83261 0.791016C11.9965 0.791016 13.8487 1.36361 15.3894 2.50881C16.9301 3.654 17.9601 5.21563 18.4794 7.1937H13.5977C13.2342 6.43023 12.7149 5.84896 12.0397 5.44988C11.3819 5.05079 10.6289 4.85125 9.78067 4.85125C8.41311 4.85125 7.30522 5.32842 6.45699 6.28275C5.60876 7.23708 5.18464 8.51241 5.18464 10.1087C5.18464 11.7051 5.60876 12.9804 6.45699 13.9347C7.30522 14.8891 8.41311 15.3662 9.78067 15.3662C10.6289 15.3662 11.3819 15.1667 12.0397 14.7676C12.7149 14.3685 13.2342 13.7872 13.5977 13.0238H18.4794C17.9601 15.0018 16.9301 16.5635 15.3894 17.7087C13.8487 18.8365 11.9965 19.4004 9.83261 19.4004C8.0669 19.4004 6.48295 19.01 5.08077 18.2292C3.6959 17.431 2.61398 16.3292 1.83499 14.9238C1.056 13.5183 0.666504 11.9133 0.666504 10.1087Z"}),v.createElement("path",{d:"M26.7553 19.4785C25.3358 19.4785 24.0548 19.1749 22.9123 18.5676C21.7871 17.9603 20.8956 17.0927 20.2378 15.9648C19.5973 14.837 19.277 13.5183 19.277 12.0087C19.277 10.5165 19.6059 9.20646 20.2638 8.07862C20.9216 6.93343 21.8217 6.05718 22.9642 5.44988C24.1068 4.84258 25.3878 4.53893 26.8073 4.53893C28.2267 4.53893 29.5078 4.84258 30.6503 5.44988C31.7928 6.05718 32.693 6.93343 33.3508 8.07862C34.0086 9.20646 34.3375 10.5165 34.3375 12.0087C34.3375 13.5009 33.9999 14.8197 33.3248 15.9648C32.667 17.0927 31.7582 17.9603 30.5983 18.5676C29.4558 19.1749 28.1748 19.4785 26.7553 19.4785ZM26.7553 15.6265C27.6036 15.6265 28.322 15.3142 28.9105 14.6895C29.5164 14.0649 29.8193 13.1713 29.8193 12.0087C29.8193 10.8462 29.5251 9.95257 28.9365 9.32792C28.3652 8.70327 27.6555 8.39095 26.8073 8.39095C25.9417 8.39095 25.2233 8.70327 24.6521 9.32792C24.0808 9.93522 23.7952 10.8288 23.7952 12.0087C23.7952 13.1713 24.0721 14.0649 24.6261 14.6895C25.1973 15.3142 25.9071 15.6265 26.7553 15.6265Z"}),v.createElement("path",{d:"M44.483 4.59098C46.1795 4.59098 47.5297 5.14623 48.5337 6.25672C49.5551 7.34986 50.0658 8.85944 50.0658 10.7854V19.2703H45.6515V11.3841C45.6515 10.4124 45.4005 9.6576 44.8985 9.11971C44.3964 8.58181 43.7213 8.31286 42.8731 8.31286C42.0249 8.31286 41.3497 8.58181 40.8477 9.11971C40.3457 9.6576 40.0947 10.4124 40.0947 11.3841V19.2703H35.6545V4.74714H40.0947V6.67315C40.5448 6.03115 41.1507 5.52796 41.9123 5.16358C42.674 4.78185 43.5309 4.59098 44.483 4.59098Z"}),v.createElement("path",{d:"M60.9412 4.59098C62.6376 4.59098 63.9879 5.14623 64.9919 6.25672C66.0133 7.34986 66.5239 8.85944 66.5239 10.7854V19.2703H62.1096V11.3841C62.1096 10.4124 61.8586 9.6576 61.3566 9.11971C60.8546 8.58181 60.1795 8.31286 59.3313 8.31286C58.483 8.31286 57.8079 8.58181 57.3059 9.11971C56.8039 9.6576 56.5529 10.4124 56.5529 11.3841V19.2703H52.1126V4.74714H56.5529V6.67315C57.0029 6.03115 57.6088 5.52796 58.3705 5.16358C59.1322 4.78185 59.9891 4.59098 60.9412 4.59098Z"}),v.createElement("path",{d:"M82.2291 11.7745C82.2291 12.1909 82.2031 12.6247 82.1512 13.0758H72.1022C72.1715 13.9781 72.4571 14.6722 72.9591 15.158C73.4784 15.6265 74.1103 15.8607 74.8546 15.8607C75.9625 15.8607 76.7329 15.3923 77.1656 14.4553H81.8915C81.6491 15.4096 81.2077 16.2685 80.5672 17.032C79.944 17.7954 79.1564 18.3941 78.2043 18.8278C77.2522 19.2616 76.1876 19.4785 75.0104 19.4785C73.5909 19.4785 72.3272 19.1749 71.2194 18.5676C70.1115 17.9603 69.2459 17.0927 68.6227 15.9648C67.9995 14.837 67.6879 13.5183 67.6879 12.0087C67.6879 10.4991 67.9909 9.18044 68.5968 8.05259C69.2199 6.92475 70.0855 6.05718 71.1934 5.44988C72.3013 4.84258 73.5736 4.53893 75.0104 4.53893C76.4126 4.53893 77.659 4.8339 78.7496 5.42385C79.8402 6.0138 80.6884 6.85534 81.2943 7.94848C81.9175 9.04163 82.2291 10.317 82.2291 11.7745ZM77.685 10.6033C77.685 9.83979 77.4253 9.23249 76.906 8.78135C76.3866 8.33022 75.7375 8.10465 74.9585 8.10465C74.2141 8.10465 73.5823 8.32154 73.063 8.75533C72.561 9.18911 72.2494 9.80509 72.1282 10.6033H77.685Z"}),v.createElement("path",{d:"M82.65 12.0087C82.65 10.4991 82.9529 9.18044 83.5588 8.05259C84.182 6.92475 85.0389 6.05718 86.1295 5.44988C87.2374 4.84258 88.5011 4.53893 89.9206 4.53893C91.7382 4.53893 93.2529 5.01609 94.4647 5.97042C95.6937 6.92475 96.4987 8.26949 96.8795 10.0046H92.1537C91.7555 8.89414 90.9852 8.33889 89.8427 8.33889C89.0291 8.33889 88.3799 8.65989 87.8952 9.3019C87.4105 9.92655 87.1681 10.8288 87.1681 12.0087C87.1681 13.1886 87.4105 14.0996 87.8952 14.7416C88.3799 15.3662 89.0291 15.6786 89.8427 15.6786C90.9852 15.6786 91.7555 15.1233 92.1537 14.0128H96.8795C96.4987 15.7133 95.6937 17.0493 94.4647 18.021C93.2356 18.9927 91.7209 19.4785 89.9206 19.4785C88.5011 19.4785 87.2374 19.1749 86.1295 18.5676C85.0389 17.9603 84.182 17.0927 83.5588 15.9648C82.9529 14.837 82.65 13.5183 82.65 12.0087Z"}),v.createElement("path",{d:"M106.291 15.4964V19.2703H104.032C102.423 19.2703 101.167 18.8799 100.267 18.0991C99.3672 17.3009 98.9171 16.0082 98.9171 14.221V8.443H97.1514V4.74714H98.9171V1.20745H103.357V4.74714H106.266V8.443H103.357V14.2731C103.357 14.7069 103.461 15.0192 103.669 15.2101C103.877 15.4009 104.223 15.4964 104.708 15.4964H106.291Z"})),p1=e=>v.createElement("svg",{width:26,height:26,viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("path",{d:"M20.105 7.37978C19.9097 7.18452 19.9097 6.86795 20.105 6.67269L22.5725 4.20504C24.9229 6.75889 26.0649 10.0248 25.9972 13.2723L20.105 7.37978ZM16.1222 10.6556C15.927 10.8509 15.927 11.1674 16.1222 11.3627L24.2614 19.5023C25.125 18.0079 25.667 16.378 25.8875 14.7149L19.3289 8.15595C19.1336 7.96068 18.817 7.96068 18.6218 8.15595L16.1222 10.6556ZM0.00284613 12.729C-0.0649083 15.9752 1.07706 19.2411 3.42753 21.7962L5.89504 19.3285C6.09029 19.1333 6.09029 18.8167 5.89504 18.6214L0.00284613 12.729ZM4.20485 22.5723C6.75858 24.9229 10.0256 26.0649 13.2716 25.9972L7.37946 20.1047C7.1842 19.9094 6.8676 19.9094 6.67234 20.1047L4.20485 22.5723ZM13.0519 18.5174C13.2472 18.3222 13.2472 18.0056 13.0519 17.8103L1.73982 6.49772C0.87626 7.99209 0.334223 9.62072 0.113713 11.2851L9.84523 21.0171C10.0405 21.2124 10.3571 21.2124 10.5524 21.0171L13.0519 18.5174ZM9.60276 7.08454C9.78969 6.88798 9.7858 6.57823 9.594 6.38642L5.55009 2.34233C4.93783 2.77105 4.35391 3.25889 3.80695 3.80588C3.25998 4.35287 2.77216 4.93684 2.34346 5.54912L6.3864 9.59111C6.57859 9.78325 6.88907 9.7867 7.08548 9.59887L8.47817 8.26702L9.60276 7.08454ZM11.2072 21.6733C11.012 21.8685 11.012 22.1851 11.2072 22.3804L14.7142 25.8875C16.3785 25.667 18.0071 25.1249 19.5013 24.2613L14.4139 19.1736C14.2186 18.9783 13.902 18.9783 13.7067 19.1736L11.2072 21.6733ZM23.6565 20.4496L11.0843 7.87683C10.8891 7.68156 10.5725 7.68156 10.3772 7.87683L7.87766 10.3765C7.68241 10.5718 7.68241 10.8883 7.87766 11.0836L20.4499 23.6564C21.0622 23.2277 21.6461 22.7398 22.193 22.1929C22.74 21.6459 23.2278 21.0619 23.6565 20.4496ZM17.8445 7.37855C18.0397 7.18329 18.0397 6.86672 17.8445 6.67146L11.2858 0.112477C9.62151 0.332998 7.99294 0.875053 6.49865 1.73866L14.6378 9.87821C14.8331 10.0735 15.1497 10.0735 15.3449 9.87821L17.8445 7.37855ZM21.7951 3.42769C19.2414 1.07712 15.9744 -0.0649114 12.7284 0.00284625L18.6205 5.89529C18.8158 6.09056 19.1324 6.09056 19.3277 5.89529L21.7951 3.42769Z",fill:"url(#paint0_linear_526_12008)"}),v.createElement("defs",null,v.createElement("linearGradient",{id:"paint0_linear_526_12008",x1:13,y1:0,x2:13,y2:26,gradientUnits:"userSpaceOnUse"},v.createElement("stop",{stopColor:"currentColor"}),v.createElement("stop",{offset:1,stopColor:"currentColor"}))));function f1(){const{showModal:e}=l1(),s=H(),{user:n,openRenown:l,logout:a}=A(),{driveNodes:c,setSelectedNode:d,selectedNode:o}=P(),[p]=j(),f=X(),L=localStorage.getItem("CONNECT_DEBUG")==="true",h=()=>{e("settingsModal",{onRefresh:()=>s(0)})},w=E(()=>{d(null),s("/")},[s,d]),S=E(()=>{f()},[f]),b=M("div",{className:"flex h-full items-center",children:[m(s1,{name:"Connect",className:"!h-[30px] !w-[100px] cursor-pointer",onClick:w}),L&&m("button",{"aria-label":"Home",id:"connect-debug-button",className:"ml-6",onClick:()=>e("debugSettingsModal",{}),children:m("img",{src:"settings.png",className:"h-5 text-gray-600"})})]}),C=E(t=>{d(t)},[d]),u=n!=null&&n.address?`https://etherscan.io/address/${n.address}`:"";return m(t1,{id:"sidebar",onClick:()=>w(),onClickSettings:h,headerContent:b,address:n==null?void 0:n.address,onLogin:l,onDisconnect:a,etherscanUrl:u,children:M(z,{fallback:m("div",{className:"text-center",children:"There was an error loading drives"}),onError:D.error,children:[c.map((t,g)=>m(n1,{title:t.name,onClick:()=>C(t),active:(o==null?void 0:o.id)===t.id,icon:t.icon?m("img",{src:t.icon,alt:t.name,width:32,height:32}):void 0},g)),p.drives.addDriveEnabled&&m(r1,{onClick:S})]})})}function Q1(){E1(),D1();const e=H(),{login:s}=A();y(()=>{var a;(a=window.electronAPI)==null||a.ready()},[]);const[n,l]=Y();return y(()=>{const a=n.get("user");if(a&&s){const c=decodeURIComponent(a);n.delete("user"),l(n),s(c).catch(D.error)}},[s,n,l]),y(()=>{var c;return(c=window.electronAPI)==null?void 0:c.handleURL((d,o)=>{e(`/${o}`)})},[e]),m(d1,{children:M("div",{className:"h-screen",children:[Z&&M("div",{className:`h-8 w-full
1
+ import{jsx as m,jsxs as M}from"react/jsx-runtime";import*as v from"react";import{useCallback as E,useEffect as y,Suspense as G,useState as U,useRef as I,useMemo as W}from"react";import{d as Y,c as q}from"./app.B0JuK2td.js";import{E as z,g as x}from"./react-error-boundary.esm.CHwBetsO.js";import{e as H,O as J,d as K,i as Q}from"./index.CAUjMUXb.js";import{u as X,a as e1}from"./modals.Dn_ncIrB.js";import{x as P,C as t1,n as D,ae as n1,af as r1,B as s1,ag as O,ah as o1,ai as k,aj as a1,L as i1,ak as c1}from"./index.Ds87Cbij.js";import{useModal as l1,ModalManager as d1}from"./modal.I0jBpvq1.js";import{j as A,h as u1,i as C1}from"./useFeatureFlags.DceCFoAY.js";import{u as j}from"./useConnectConfig.BRbXRrbe.js";import{t as V}from"./toast.M8Yl2BMq.js";import{u as B}from"./useTranslation.BpVv6XIW.js";import{u as F}from"./useDocumentDriveServer.C9u3SgiH.js";import"./connect.config.rJjJZvYA.js";import"./browser.BkwNmV2Z.js";import"./user.SniiwLvT.js";import"./index.CKisJNRj.js";import"react-dom/client";import"./app-skeleton.js";import"./useAcceptedCookies.CRzVdFNU.js";import"react-dom";import"./registerServiceWorker.CFFodjhC.js";import"./i18next.CqOP20KE.js";import"./slug.C6xW_7Wm.js";const m1=e=>v.createElement("svg",{width:107,height:20,viewBox:"0 0 107 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("path",{d:"M0.666504 10.1087C0.666504 8.30419 1.056 6.69918 1.83499 5.29371C2.61398 3.8709 3.6959 2.76908 5.08077 1.98827C6.48295 1.1901 8.0669 0.791016 9.83261 0.791016C11.9965 0.791016 13.8487 1.36361 15.3894 2.50881C16.9301 3.654 17.9601 5.21563 18.4794 7.1937H13.5977C13.2342 6.43023 12.7149 5.84896 12.0397 5.44988C11.3819 5.05079 10.6289 4.85125 9.78067 4.85125C8.41311 4.85125 7.30522 5.32842 6.45699 6.28275C5.60876 7.23708 5.18464 8.51241 5.18464 10.1087C5.18464 11.7051 5.60876 12.9804 6.45699 13.9347C7.30522 14.8891 8.41311 15.3662 9.78067 15.3662C10.6289 15.3662 11.3819 15.1667 12.0397 14.7676C12.7149 14.3685 13.2342 13.7872 13.5977 13.0238H18.4794C17.9601 15.0018 16.9301 16.5635 15.3894 17.7087C13.8487 18.8365 11.9965 19.4004 9.83261 19.4004C8.0669 19.4004 6.48295 19.01 5.08077 18.2292C3.6959 17.431 2.61398 16.3292 1.83499 14.9238C1.056 13.5183 0.666504 11.9133 0.666504 10.1087Z"}),v.createElement("path",{d:"M26.7553 19.4785C25.3358 19.4785 24.0548 19.1749 22.9123 18.5676C21.7871 17.9603 20.8956 17.0927 20.2378 15.9648C19.5973 14.837 19.277 13.5183 19.277 12.0087C19.277 10.5165 19.6059 9.20646 20.2638 8.07862C20.9216 6.93343 21.8217 6.05718 22.9642 5.44988C24.1068 4.84258 25.3878 4.53893 26.8073 4.53893C28.2267 4.53893 29.5078 4.84258 30.6503 5.44988C31.7928 6.05718 32.693 6.93343 33.3508 8.07862C34.0086 9.20646 34.3375 10.5165 34.3375 12.0087C34.3375 13.5009 33.9999 14.8197 33.3248 15.9648C32.667 17.0927 31.7582 17.9603 30.5983 18.5676C29.4558 19.1749 28.1748 19.4785 26.7553 19.4785ZM26.7553 15.6265C27.6036 15.6265 28.322 15.3142 28.9105 14.6895C29.5164 14.0649 29.8193 13.1713 29.8193 12.0087C29.8193 10.8462 29.5251 9.95257 28.9365 9.32792C28.3652 8.70327 27.6555 8.39095 26.8073 8.39095C25.9417 8.39095 25.2233 8.70327 24.6521 9.32792C24.0808 9.93522 23.7952 10.8288 23.7952 12.0087C23.7952 13.1713 24.0721 14.0649 24.6261 14.6895C25.1973 15.3142 25.9071 15.6265 26.7553 15.6265Z"}),v.createElement("path",{d:"M44.483 4.59098C46.1795 4.59098 47.5297 5.14623 48.5337 6.25672C49.5551 7.34986 50.0658 8.85944 50.0658 10.7854V19.2703H45.6515V11.3841C45.6515 10.4124 45.4005 9.6576 44.8985 9.11971C44.3964 8.58181 43.7213 8.31286 42.8731 8.31286C42.0249 8.31286 41.3497 8.58181 40.8477 9.11971C40.3457 9.6576 40.0947 10.4124 40.0947 11.3841V19.2703H35.6545V4.74714H40.0947V6.67315C40.5448 6.03115 41.1507 5.52796 41.9123 5.16358C42.674 4.78185 43.5309 4.59098 44.483 4.59098Z"}),v.createElement("path",{d:"M60.9412 4.59098C62.6376 4.59098 63.9879 5.14623 64.9919 6.25672C66.0133 7.34986 66.5239 8.85944 66.5239 10.7854V19.2703H62.1096V11.3841C62.1096 10.4124 61.8586 9.6576 61.3566 9.11971C60.8546 8.58181 60.1795 8.31286 59.3313 8.31286C58.483 8.31286 57.8079 8.58181 57.3059 9.11971C56.8039 9.6576 56.5529 10.4124 56.5529 11.3841V19.2703H52.1126V4.74714H56.5529V6.67315C57.0029 6.03115 57.6088 5.52796 58.3705 5.16358C59.1322 4.78185 59.9891 4.59098 60.9412 4.59098Z"}),v.createElement("path",{d:"M82.2291 11.7745C82.2291 12.1909 82.2031 12.6247 82.1512 13.0758H72.1022C72.1715 13.9781 72.4571 14.6722 72.9591 15.158C73.4784 15.6265 74.1103 15.8607 74.8546 15.8607C75.9625 15.8607 76.7329 15.3923 77.1656 14.4553H81.8915C81.6491 15.4096 81.2077 16.2685 80.5672 17.032C79.944 17.7954 79.1564 18.3941 78.2043 18.8278C77.2522 19.2616 76.1876 19.4785 75.0104 19.4785C73.5909 19.4785 72.3272 19.1749 71.2194 18.5676C70.1115 17.9603 69.2459 17.0927 68.6227 15.9648C67.9995 14.837 67.6879 13.5183 67.6879 12.0087C67.6879 10.4991 67.9909 9.18044 68.5968 8.05259C69.2199 6.92475 70.0855 6.05718 71.1934 5.44988C72.3013 4.84258 73.5736 4.53893 75.0104 4.53893C76.4126 4.53893 77.659 4.8339 78.7496 5.42385C79.8402 6.0138 80.6884 6.85534 81.2943 7.94848C81.9175 9.04163 82.2291 10.317 82.2291 11.7745ZM77.685 10.6033C77.685 9.83979 77.4253 9.23249 76.906 8.78135C76.3866 8.33022 75.7375 8.10465 74.9585 8.10465C74.2141 8.10465 73.5823 8.32154 73.063 8.75533C72.561 9.18911 72.2494 9.80509 72.1282 10.6033H77.685Z"}),v.createElement("path",{d:"M82.65 12.0087C82.65 10.4991 82.9529 9.18044 83.5588 8.05259C84.182 6.92475 85.0389 6.05718 86.1295 5.44988C87.2374 4.84258 88.5011 4.53893 89.9206 4.53893C91.7382 4.53893 93.2529 5.01609 94.4647 5.97042C95.6937 6.92475 96.4987 8.26949 96.8795 10.0046H92.1537C91.7555 8.89414 90.9852 8.33889 89.8427 8.33889C89.0291 8.33889 88.3799 8.65989 87.8952 9.3019C87.4105 9.92655 87.1681 10.8288 87.1681 12.0087C87.1681 13.1886 87.4105 14.0996 87.8952 14.7416C88.3799 15.3662 89.0291 15.6786 89.8427 15.6786C90.9852 15.6786 91.7555 15.1233 92.1537 14.0128H96.8795C96.4987 15.7133 95.6937 17.0493 94.4647 18.021C93.2356 18.9927 91.7209 19.4785 89.9206 19.4785C88.5011 19.4785 87.2374 19.1749 86.1295 18.5676C85.0389 17.9603 84.182 17.0927 83.5588 15.9648C82.9529 14.837 82.65 13.5183 82.65 12.0087Z"}),v.createElement("path",{d:"M106.291 15.4964V19.2703H104.032C102.423 19.2703 101.167 18.8799 100.267 18.0991C99.3672 17.3009 98.9171 16.0082 98.9171 14.221V8.443H97.1514V4.74714H98.9171V1.20745H103.357V4.74714H106.266V8.443H103.357V14.2731C103.357 14.7069 103.461 15.0192 103.669 15.2101C103.877 15.4009 104.223 15.4964 104.708 15.4964H106.291Z"})),p1=e=>v.createElement("svg",{width:26,height:26,viewBox:"0 0 26 26",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},v.createElement("path",{d:"M20.105 7.37978C19.9097 7.18452 19.9097 6.86795 20.105 6.67269L22.5725 4.20504C24.9229 6.75889 26.0649 10.0248 25.9972 13.2723L20.105 7.37978ZM16.1222 10.6556C15.927 10.8509 15.927 11.1674 16.1222 11.3627L24.2614 19.5023C25.125 18.0079 25.667 16.378 25.8875 14.7149L19.3289 8.15595C19.1336 7.96068 18.817 7.96068 18.6218 8.15595L16.1222 10.6556ZM0.00284613 12.729C-0.0649083 15.9752 1.07706 19.2411 3.42753 21.7962L5.89504 19.3285C6.09029 19.1333 6.09029 18.8167 5.89504 18.6214L0.00284613 12.729ZM4.20485 22.5723C6.75858 24.9229 10.0256 26.0649 13.2716 25.9972L7.37946 20.1047C7.1842 19.9094 6.8676 19.9094 6.67234 20.1047L4.20485 22.5723ZM13.0519 18.5174C13.2472 18.3222 13.2472 18.0056 13.0519 17.8103L1.73982 6.49772C0.87626 7.99209 0.334223 9.62072 0.113713 11.2851L9.84523 21.0171C10.0405 21.2124 10.3571 21.2124 10.5524 21.0171L13.0519 18.5174ZM9.60276 7.08454C9.78969 6.88798 9.7858 6.57823 9.594 6.38642L5.55009 2.34233C4.93783 2.77105 4.35391 3.25889 3.80695 3.80588C3.25998 4.35287 2.77216 4.93684 2.34346 5.54912L6.3864 9.59111C6.57859 9.78325 6.88907 9.7867 7.08548 9.59887L8.47817 8.26702L9.60276 7.08454ZM11.2072 21.6733C11.012 21.8685 11.012 22.1851 11.2072 22.3804L14.7142 25.8875C16.3785 25.667 18.0071 25.1249 19.5013 24.2613L14.4139 19.1736C14.2186 18.9783 13.902 18.9783 13.7067 19.1736L11.2072 21.6733ZM23.6565 20.4496L11.0843 7.87683C10.8891 7.68156 10.5725 7.68156 10.3772 7.87683L7.87766 10.3765C7.68241 10.5718 7.68241 10.8883 7.87766 11.0836L20.4499 23.6564C21.0622 23.2277 21.6461 22.7398 22.193 22.1929C22.74 21.6459 23.2278 21.0619 23.6565 20.4496ZM17.8445 7.37855C18.0397 7.18329 18.0397 6.86672 17.8445 6.67146L11.2858 0.112477C9.62151 0.332998 7.99294 0.875053 6.49865 1.73866L14.6378 9.87821C14.8331 10.0735 15.1497 10.0735 15.3449 9.87821L17.8445 7.37855ZM21.7951 3.42769C19.2414 1.07712 15.9744 -0.0649114 12.7284 0.00284625L18.6205 5.89529C18.8158 6.09056 19.1324 6.09056 19.3277 5.89529L21.7951 3.42769Z",fill:"url(#paint0_linear_526_12008)"}),v.createElement("defs",null,v.createElement("linearGradient",{id:"paint0_linear_526_12008",x1:13,y1:0,x2:13,y2:26,gradientUnits:"userSpaceOnUse"},v.createElement("stop",{stopColor:"currentColor"}),v.createElement("stop",{offset:1,stopColor:"currentColor"}))));function f1(){const{showModal:e}=l1(),s=H(),{user:n,openRenown:l,logout:a}=A(),{driveNodes:c,setSelectedNode:d,selectedNode:o}=P(),[p]=j(),f=X(),L=localStorage.getItem("CONNECT_DEBUG")==="true",h=()=>{e("settingsModal",{onRefresh:()=>s(0)})},w=E(()=>{d(null),s("/")},[s,d]),S=E(()=>{f()},[f]),b=M("div",{className:"flex h-full items-center",children:[m(s1,{name:"Connect",className:"!h-[30px] !w-[100px] cursor-pointer",onClick:w}),L&&m("button",{"aria-label":"Home",id:"connect-debug-button",className:"ml-6",onClick:()=>e("debugSettingsModal",{}),children:m("img",{src:"settings.png",className:"h-5 text-gray-600"})})]}),C=E(t=>{d(t)},[d]),u=n!=null&&n.address?`https://etherscan.io/address/${n.address}`:"";return m(t1,{id:"sidebar",onClick:()=>w(),onClickSettings:h,headerContent:b,address:n==null?void 0:n.address,onLogin:l,onDisconnect:a,etherscanUrl:u,children:M(z,{fallback:m("div",{className:"text-center",children:"There was an error loading drives"}),onError:D.error,children:[c.map((t,g)=>m(n1,{title:t.name,onClick:()=>C(t),active:(o==null?void 0:o.id)===t.id,icon:t.icon?m("img",{src:t.icon,alt:t.name,width:32,height:32}):void 0},g)),p.drives.addDriveEnabled&&m(r1,{onClick:S})]})})}function Q1(){E1(),D1();const e=H(),{login:s}=A();y(()=>{var a;(a=window.electronAPI)==null||a.ready()},[]);const[n,l]=Y();return y(()=>{const a=n.get("user");if(a&&s){const c=decodeURIComponent(a);n.delete("user"),l(n),s(c).catch(D.error)}},[s,n,l]),y(()=>{var c;return(c=window.electronAPI)==null?void 0:c.handleURL((d,o)=>{e(`/${o}`)})},[e]),m(d1,{children:M("div",{className:"h-screen",children:[Z&&M("div",{className:`h-8 w-full
2
2
  ${L1&&"justify-center"}
3
3
  flex items-center bg-gray-50`,children:[m(p1,{className:"ml-1 mr-0.5 p-1.5"}),m(m1,{className:"h-3 w-fit"})]}),m("div",{className:`flex items-stretch overflow-auto
4
4
  ${Z?"h-app-height":"h-screen"}
5
5
  `,role:"presentation",tabIndex:0,children:M(G,{name:"Root",children:[m(f1,{}),m("div",{className:"relative flex-1 overflow-auto",children:m(J,{})})]})})]})})}const h1=()=>{const{t:e}=B();return M("div",{children:[m("p",{className:"font-medium",children:e("notifications.reloadApp")}),M("button",{onClick:()=>location.reload(),className:"underline decoration-solid underline-offset-2",children:[e("common.reloadConnect")," 🔄"]})]})},g1=1e5,v1=(e,s)=>s?e.toLocaleLowerCase().includes(`transmitter ${s} not found`):!1,w1=()=>{const[e,s]=U([]),[n,l]=U(new Map),{addTrigger:a,removeTrigger:c,registerNewPullResponderTrigger:d,renameDrive:o,addRemoteDrive:p,documentDrives:f,setDriveSharingType:L}=F();u1();const h=I(new Map),w=E(async(C,u,t)=>{s(r=>[...r,t]);const g=u.data;try{let r=n.get(t);r||(r=await d(C,g.url,{pullInterval:Number(g.interval)||3e3}),n.set(t,r),l(n)),await c(C,u.id),await a(C,r),h.current.delete(t)}catch(r){const i=h.current.get(t)||1;h.current.set(t,i===g1?i:i*10),D.error(r)}finally{s(r=>r.filter(i=>i!==t))}},[n,c,a,h,d]),S=E(async(C,u,t)=>{var g;s(r=>[...r,t]);try{const r=f.find(i=>i.header.id===C);if(!r)return;if(await c(C,u.id),await o(C,r.state.global.name+` (${r.header.id})`),await L(C,O),(g=u.data)!=null&&g.url&&r.header.slug){const i=await x(u.data.url,r.header.slug);if(i){const N=u.data.url.split("/");N[N.length-1]=i;const R=N.join("/");await p(R,{availableOffline:!0,sharingType:"PUBLIC",listeners:[],triggers:[]})}}}catch(r){D.error(r)}finally{s(r=>r.filter(i=>i!==t))}},[f,c,o,L,x,p]),b=E(async(C,u,t,g)=>{var r;switch(t){case 400:{if(v1(g,(r=u.data)==null?void 0:r.listenerId)){if(!(localStorage.getItem("AUTO_REGISTER_PULL_RESPONDER")!=="false"))return;const N=`strands:${C}:${t}`;if(e.includes(N)||!u.data)return;const R=h.current.get(N)||0;setTimeout(()=>w(C,u,N),R)}break}case 404:{const i=`strands:${C}:${t}`;if(e.includes(i))return;setTimeout(()=>S(C,u,i),0);break}}},[S,w,e]);return W(()=>({strandsErrorHandler:b}),[b])},T=window.__VITE_ENVS.APP_VERSION,Z=window.navigator.userAgent.includes("Electron"),L1=window.navigator.appVersion.includes("Mac"),_={"staging/makerdao":"deployments/staging/makerdao","staging/arbitrum":"arb-ltip","staging/powerhouse":"staging",makerdao:"deployments/makerdao",arbitrum:"deployments/arbitrum",arbgrants:"deployments/arbitrum",localhost:"develop"},N1=()=>{const e="https://raw.githubusercontent.com/powerhouse-inc/connect",s=window.location.href,n=Object.keys(_).find(a=>s.includes(a)),l=n?_[n]:void 0;if(l)return`${e}/${l}/package.json`},y1=async()=>{const e=N1();if(!e)return;const n=await(await fetch(e)).json(),{version:l}=n;return l},S1=async()=>{const e=await y1();return e?{isLatest:e===T,currentVersion:T,latestVersion:e}:null},E1=()=>{const{t:e}=B(),{reactorLoaded:s,documentDrives:n,onSyncStatus:l}=F(),{driveNodes:a,setDriveNodes:c}=P(),d=I([...a]),o=I([]),[,,p]=C1(),{readDrives:f}=q(),L=w1(),[h]=j();async function w(){const t=await S1();if(t!==null){if(t.isLatest||t.currentVersion.includes("-"))return!0;window.__VITE_ENVS.MODE==="development"||h.studioMode||!h.warnOutdatedApp?D.warn(`Connect is outdated:
6
6
  Current: ${t.currentVersion}
7
7
  Latest: ${t.latestVersion}`):V(m(h1,{}),{type:"connect-warning",toastId:"outdated-app",autoClose:!1})}}y(()=>{w().catch(console.error)},[]),y(()=>p(L),[p,n,L]);const S=E(async(t,g)=>{t.forEach(r=>{const i=d.current.find(N=>N.id===r.id);if(i){if(r.sharingType!==O&&r.syncStatus===o1&&o.current.includes(r))return o.current=o.current.filter(N=>N.id!==r.id),V(g("notifications.driveSyncSuccess"),{type:"connect-success"});(r.syncStatus===k||r.syncStatus===a1)&&r.syncStatus!==i.syncStatus&&o.current.push(r)}}),d.current=[...t],o.current.length>0&&await w()&&o.current.forEach(i=>{V(g(`notifications.${i.syncStatus===k?"driveSyncConflict":"driveSyncError"}`,{drive:i.name}),{type:"connect-warning",toastId:`${i.syncStatus===k?"driveSyncConflict":"driveSyncError"}-${i.id}`})})},[]);y(()=>{S(a,e).catch(console.error)},[a,e,S]);const b=e1(),C=E(async t=>Promise.all(t.map(b)),[b]),u=E(async t=>{const g=await C(t);c(g)},[C,c]);y(()=>{const t=[...f,...n];u(t).catch(console.error)},[n,f,u]),y(()=>s?l(()=>u(n)):void 0,[s,n,l,u])};function b1(e){const s=e[0];if(!s)return;if(s.kind!==c1)throw new Error("Node path is invalid, first node is not a drive node.");const n=M1(s),l=e.slice(1).map(c=>encodeURIComponent(c.slug||c.name));return[n,...l].join("/")}function M1(e){const s=e.slug||e.name||e.id;return`/d/${encodeURIComponent(s)}`}function $(e,s,n){if(!s)return null;const l=decodeURIComponent(s),a=e.find(o=>(o==null?void 0:o.id)===l||(o==null?void 0:o.slug)===l||(o==null?void 0:o.name)===l);if(!a)return null;if(!n)return a;const c=n.split("/").filter(Boolean).map(decodeURIComponent);let d=a;for(const o of c){if(d.kind===i1)break;const p=d.children.find(f=>f.slug===o||f.name===o);if(!p){console.error("Node not found:",o);break}d=p}return d}const D1=()=>{const e=H(),s=K(),{search:n,pathname:l}=s,a=Q(),{driveNodes:c,selectedNode:d,selectedNodePath:o,setSelectedNode:p}=P(),f=a.driveId,L=a["*"],h=$(c,f,L),w=b1(o);y(()=>{!w||w===l||e({pathname:w,search:n})},[n,e,w]),y(()=>{d||!h||p(h)},[d,h,p]),y(()=>{const S=$(c,f,L);S&&p(S)},[c,f,L,p])};export{Q1 as default};
8
- //# sourceMappingURL=root.BgZ2UXeU.js.map
8
+ //# sourceMappingURL=root.CdBb-EYv.js.map