@powerhousedao/connect 4.1.0-dev.11 → 4.1.0-dev.111

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 (604) hide show
  1. package/{dist/.env → .env} +5 -7
  2. package/README.md +3 -4
  3. package/assets/icon.icns +0 -0
  4. package/assets/icon.ico +0 -0
  5. package/assets/icon.png +0 -0
  6. package/assets/icons/Atlas-Logomark.svg +24 -0
  7. package/assets/icons/BBP-logo-hover-dark.svg +14 -0
  8. package/assets/icons/BBP-logo-hover-light.svg +14 -0
  9. package/assets/icons/BBP-logo-main.svg +14 -0
  10. package/assets/icons/collapse.svg +7 -0
  11. package/assets/icons/connect-small.svg +3 -0
  12. package/assets/icons/connect.svg +16 -0
  13. package/assets/icons/cross.svg +4 -0
  14. package/assets/icons/dark.svg +5 -0
  15. package/assets/icons/draft.svg +3 -0
  16. package/assets/icons/file.svg +3 -0
  17. package/assets/icons/file2.svg +10 -0
  18. package/assets/icons/folder.svg +3 -0
  19. package/assets/icons/light.svg +20 -0
  20. package/assets/icons/logo.svg +11 -0
  21. package/assets/icons/plus-circle.svg +5 -0
  22. package/assets/icons/refresh.svg +4 -0
  23. package/assets/icons/renown.svg +27 -0
  24. package/assets/icons/settings.svg +6 -0
  25. package/assets/icons/template.svg +3 -0
  26. package/assets/info.plist +85 -0
  27. package/dist/assets/AddDriveModal-DxzkGUoU.js +1 -0
  28. package/dist/assets/ClearStorageModal-BKqeaqVc.js +1 -0
  29. package/dist/assets/CookiesPolicyModal-DoOAAbgS.js +1 -0
  30. package/dist/assets/CreateDocumentModal-CpbJt2MG.js +1 -0
  31. package/dist/assets/DebugSettingsModal-l77zW03G.js +1 -0
  32. package/dist/assets/DeleteDriveModal-C3FfnniV.js +1 -0
  33. package/dist/assets/DeleteItemModal-BemSEf0J.js +1 -0
  34. package/dist/assets/DisclaimerModal-Bx6sn1p0.js +1 -0
  35. package/dist/assets/DriveSettingsModal-Db-UDGAM.js +1 -0
  36. package/dist/assets/ExportDocumentWithErrorsModal-COWWjtzM.js +1 -0
  37. package/dist/assets/SettingsModal-3W1XLipd.js +1 -0
  38. package/dist/assets/UpgradeDriveModal-BVNqQqRU.js +1 -0
  39. package/dist/assets/_virtual_ph_external-packages-CM1tCR4L.js +1 -0
  40. package/dist/assets/config-CU-aFfVJ.js +1 -0
  41. package/dist/assets/design_system-BzocxAs0.js +45 -0
  42. package/dist/assets/design_system_connect-DjKMS_YB.js +45 -0
  43. package/dist/assets/design_system_ui-DgRp0MRr.js +1 -0
  44. package/dist/assets/document_drive-BEIKnuGM.js +305 -0
  45. package/dist/assets/document_engineering-4d0IV_Zv.js +1 -0
  46. package/dist/assets/document_model-DXcLJEjZ.js +230 -0
  47. package/dist/assets/document_model_editor-CiZRsEBL.js +23 -0
  48. package/dist/assets/drive_explorer-Ltb9MzaI.js +2 -0
  49. package/dist/assets/graphql-BS4Brs_E.js +75 -0
  50. package/dist/assets/graphql-editor-Vwbfb243.js +73 -0
  51. package/dist/assets/graphql_request-9RNJ00DB.js +3 -0
  52. package/dist/assets/hmr-LMNkvzP7.js +1 -0
  53. package/dist/assets/hooks-UsE4RXsD.js +12 -0
  54. package/dist/assets/index-Br7E7qjt.css +1 -0
  55. package/dist/assets/index-ChH_VcwA.js +18 -0
  56. package/dist/assets/json-editor-B3jHnGSL.js +1 -0
  57. package/dist/assets/react/jsx-runtime-DldvXD6N.js +1 -0
  58. package/dist/assets/react-DQSxOgtG.js +1 -0
  59. package/dist/assets/react-dom/client-BVPiT_FE.js +9 -0
  60. package/dist/assets/react-dom-D6zQJsh6.js +1 -0
  61. package/dist/assets/reactor_browser-BOvVQIWy.js +25 -0
  62. package/dist/assets/sentry_browser-B4YoBIIG.js +498 -0
  63. package/dist/assets/sentry_react-cODD7zWc.js +3 -0
  64. package/dist/assets/state-schemas-ULSdWLm-.js +2 -0
  65. package/dist/assets/tailwind_merge-Dr4f9Rms.js +1 -0
  66. package/dist/assets/zod-C6yxFxyo.js +1 -0
  67. package/dist/index.html +51 -84
  68. package/heroku/Dockerfile +98 -0
  69. package/heroku/Procfile +1 -0
  70. package/heroku/config/nginx.conf.template +77 -0
  71. package/heroku/heroku-entrypoint.sh +38 -0
  72. package/lib/cypress/e2e/navigation.cy.d.ts +2 -0
  73. package/lib/cypress/e2e/navigation.cy.d.ts.map +1 -0
  74. package/lib/cypress/e2e/navigation.cy.js +221 -0
  75. package/lib/cypress/e2e/navigation.cy.js.map +1 -0
  76. package/lib/cypress/e2e/utils/index.d.ts +15 -0
  77. package/lib/cypress/e2e/utils/index.d.ts.map +1 -0
  78. package/lib/cypress/e2e/utils/index.js +121 -0
  79. package/lib/cypress/e2e/utils/index.js.map +1 -0
  80. package/lib/cypress/support/commands.d.ts +2 -0
  81. package/lib/cypress/support/commands.d.ts.map +1 -0
  82. package/lib/cypress/support/commands.js +29 -0
  83. package/lib/cypress/support/commands.js.map +1 -0
  84. package/lib/cypress/support/e2e.d.ts +2 -0
  85. package/lib/cypress/support/e2e.d.ts.map +1 -0
  86. package/lib/cypress/support/e2e.js +19 -0
  87. package/lib/cypress/support/e2e.js.map +1 -0
  88. package/lib/cypress.config.d.ts +3 -0
  89. package/lib/cypress.config.d.ts.map +1 -0
  90. package/lib/cypress.config.js +15 -0
  91. package/lib/cypress.config.js.map +1 -0
  92. package/lib/package.copy.json +165 -0
  93. package/lib/scripts/render-skeleton.d.ts +2 -0
  94. package/lib/scripts/render-skeleton.d.ts.map +1 -0
  95. package/lib/scripts/render-skeleton.js +11 -0
  96. package/lib/scripts/render-skeleton.js.map +1 -0
  97. package/lib/src/components/analytics.d.ts +8 -0
  98. package/lib/src/components/analytics.d.ts.map +1 -0
  99. package/lib/src/components/analytics.js +30 -0
  100. package/lib/src/components/analytics.js.map +1 -0
  101. package/lib/src/components/app-loader.d.ts +7 -0
  102. package/lib/src/components/app-loader.d.ts.map +1 -0
  103. package/lib/src/components/app-loader.js +20 -0
  104. package/lib/src/components/app-loader.js.map +1 -0
  105. package/lib/src/components/app-skeleton.d.ts +3 -0
  106. package/lib/src/components/app-skeleton.d.ts.map +1 -0
  107. package/lib/src/components/app-skeleton.js +38 -0
  108. package/lib/src/components/app-skeleton.js.map +1 -0
  109. package/lib/src/components/app.d.ts +2 -0
  110. package/lib/src/components/app.d.ts.map +1 -0
  111. package/lib/src/components/app.js +18 -0
  112. package/lib/src/components/app.js.map +1 -0
  113. package/lib/src/components/button.d.ts +3 -0
  114. package/lib/src/components/button.d.ts.map +1 -0
  115. package/lib/src/components/button.js +7 -0
  116. package/lib/src/components/button.js.map +1 -0
  117. package/lib/src/components/cookie-banner.d.ts +2 -0
  118. package/lib/src/components/cookie-banner.d.ts.map +1 -0
  119. package/lib/src/components/cookie-banner.js +48 -0
  120. package/lib/src/components/cookie-banner.js.map +1 -0
  121. package/lib/src/components/document-editor-container.d.ts +2 -0
  122. package/lib/src/components/document-editor-container.d.ts.map +1 -0
  123. package/lib/src/components/document-editor-container.js +62 -0
  124. package/lib/src/components/document-editor-container.js.map +1 -0
  125. package/lib/src/components/dots-loader.d.ts +2 -0
  126. package/lib/src/components/dots-loader.d.ts.map +1 -0
  127. package/lib/src/components/dots-loader.js +15 -0
  128. package/lib/src/components/dots-loader.js.map +1 -0
  129. package/lib/src/components/drive-editor-container.d.ts +2 -0
  130. package/lib/src/components/drive-editor-container.d.ts.map +1 -0
  131. package/lib/src/components/drive-editor-container.js +25 -0
  132. package/lib/src/components/drive-editor-container.js.map +1 -0
  133. package/lib/src/components/drive-icon.d.ts +5 -0
  134. package/lib/src/components/drive-icon.d.ts.map +1 -0
  135. package/lib/src/components/drive-icon.js +15 -0
  136. package/lib/src/components/drive-icon.js.map +1 -0
  137. package/lib/src/components/editor-loader.d.ts +9 -0
  138. package/lib/src/components/editor-loader.d.ts.map +1 -0
  139. package/lib/src/components/editor-loader.js +19 -0
  140. package/lib/src/components/editor-loader.js.map +1 -0
  141. package/lib/src/components/editors.d.ts +10 -0
  142. package/lib/src/components/editors.d.ts.map +1 -0
  143. package/lib/src/components/editors.js +93 -0
  144. package/lib/src/components/editors.js.map +1 -0
  145. package/lib/src/components/footer.d.ts +2 -0
  146. package/lib/src/components/footer.d.ts.map +1 -0
  147. package/lib/src/components/footer.js +16 -0
  148. package/lib/src/components/footer.js.map +1 -0
  149. package/lib/src/components/index.d.ts +22 -0
  150. package/lib/src/components/index.d.ts.map +1 -0
  151. package/lib/src/components/index.js +22 -0
  152. package/lib/src/components/index.js.map +1 -0
  153. package/lib/src/components/login.d.ts +2 -0
  154. package/lib/src/components/login.d.ts.map +1 -0
  155. package/lib/src/components/login.js +12 -0
  156. package/lib/src/components/login.js.map +1 -0
  157. package/lib/src/components/modal/index.d.ts +19 -0
  158. package/lib/src/components/modal/index.d.ts.map +1 -0
  159. package/lib/src/components/modal/index.js +19 -0
  160. package/lib/src/components/modal/index.js.map +1 -0
  161. package/lib/src/components/modal/modals/AddDriveModal.d.ts +2 -0
  162. package/lib/src/components/modal/modals/AddDriveModal.d.ts.map +1 -0
  163. package/lib/src/components/modal/modals/AddDriveModal.js +113 -0
  164. package/lib/src/components/modal/modals/AddDriveModal.js.map +1 -0
  165. package/lib/src/components/modal/modals/ClearStorageModal.d.ts +2 -0
  166. package/lib/src/components/modal/modals/ClearStorageModal.d.ts.map +1 -0
  167. package/lib/src/components/modal/modals/ClearStorageModal.js +35 -0
  168. package/lib/src/components/modal/modals/ClearStorageModal.js.map +1 -0
  169. package/lib/src/components/modal/modals/CookiesPolicyModal.d.ts +2 -0
  170. package/lib/src/components/modal/modals/CookiesPolicyModal.d.ts.map +1 -0
  171. package/lib/src/components/modal/modals/CookiesPolicyModal.js +16 -0
  172. package/lib/src/components/modal/modals/CookiesPolicyModal.js.map +1 -0
  173. package/lib/src/components/modal/modals/CreateDocumentModal.d.ts +2 -0
  174. package/lib/src/components/modal/modals/CreateDocumentModal.d.ts.map +1 -0
  175. package/lib/src/components/modal/modals/CreateDocumentModal.js +24 -0
  176. package/lib/src/components/modal/modals/CreateDocumentModal.js.map +1 -0
  177. package/lib/src/components/modal/modals/DebugSettingsModal.d.ts +2 -0
  178. package/lib/src/components/modal/modals/DebugSettingsModal.d.ts.map +1 -0
  179. package/lib/src/components/modal/modals/DebugSettingsModal.js +108 -0
  180. package/lib/src/components/modal/modals/DebugSettingsModal.js.map +1 -0
  181. package/lib/src/components/modal/modals/DeleteDriveModal.d.ts +2 -0
  182. package/lib/src/components/modal/modals/DeleteDriveModal.d.ts.map +1 -0
  183. package/lib/src/components/modal/modals/DeleteDriveModal.js +32 -0
  184. package/lib/src/components/modal/modals/DeleteDriveModal.js.map +1 -0
  185. package/lib/src/components/modal/modals/DeleteItemModal.d.ts +3 -0
  186. package/lib/src/components/modal/modals/DeleteItemModal.d.ts.map +1 -0
  187. package/lib/src/components/modal/modals/DeleteItemModal.js +33 -0
  188. package/lib/src/components/modal/modals/DeleteItemModal.js.map +1 -0
  189. package/lib/src/components/modal/modals/DisclaimerModal.d.ts +3 -0
  190. package/lib/src/components/modal/modals/DisclaimerModal.d.ts.map +1 -0
  191. package/lib/src/components/modal/modals/DisclaimerModal.js +12 -0
  192. package/lib/src/components/modal/modals/DisclaimerModal.js.map +1 -0
  193. package/lib/src/components/modal/modals/DriveSettingsModal.d.ts +2 -0
  194. package/lib/src/components/modal/modals/DriveSettingsModal.d.ts.map +1 -0
  195. package/lib/src/components/modal/modals/DriveSettingsModal.js +28 -0
  196. package/lib/src/components/modal/modals/DriveSettingsModal.js.map +1 -0
  197. package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.d.ts +2 -0
  198. package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.d.ts.map +1 -0
  199. package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js +30 -0
  200. package/lib/src/components/modal/modals/ExportDocumentWithErrorsModal.js.map +1 -0
  201. package/lib/src/components/modal/modals/SettingsModal.d.ts +3 -0
  202. package/lib/src/components/modal/modals/SettingsModal.d.ts.map +1 -0
  203. package/lib/src/components/modal/modals/SettingsModal.js +45 -0
  204. package/lib/src/components/modal/modals/SettingsModal.js.map +1 -0
  205. package/lib/src/components/modal/modals/UpgradeDriveModal.d.ts +3 -0
  206. package/lib/src/components/modal/modals/UpgradeDriveModal.d.ts.map +1 -0
  207. package/lib/src/components/modal/modals/UpgradeDriveModal.js +21 -0
  208. package/lib/src/components/modal/modals/UpgradeDriveModal.js.map +1 -0
  209. package/lib/src/components/modal/modals/settings/about.d.ts +2 -0
  210. package/lib/src/components/modal/modals/settings/about.d.ts.map +1 -0
  211. package/lib/src/components/modal/modals/settings/about.js +10 -0
  212. package/lib/src/components/modal/modals/settings/about.js.map +1 -0
  213. package/lib/src/components/modal/modals/settings/danger-zone.d.ts +2 -0
  214. package/lib/src/components/modal/modals/settings/danger-zone.d.ts.map +1 -0
  215. package/lib/src/components/modal/modals/settings/danger-zone.js +15 -0
  216. package/lib/src/components/modal/modals/settings/danger-zone.js.map +1 -0
  217. package/lib/src/components/modal/modals/settings/default-editor.d.ts +2 -0
  218. package/lib/src/components/modal/modals/settings/default-editor.d.ts.map +1 -0
  219. package/lib/src/components/modal/modals/settings/default-editor.js +18 -0
  220. package/lib/src/components/modal/modals/settings/default-editor.js.map +1 -0
  221. package/lib/src/components/modal/modals/settings/package-manager.d.ts +3 -0
  222. package/lib/src/components/modal/modals/settings/package-manager.d.ts.map +1 -0
  223. package/lib/src/components/modal/modals/settings/package-manager.js +87 -0
  224. package/lib/src/components/modal/modals/settings/package-manager.js.map +1 -0
  225. package/lib/src/components/modal/modals-container.d.ts +2 -0
  226. package/lib/src/components/modal/modals-container.d.ts.map +1 -0
  227. package/lib/src/components/modal/modals-container.js +62 -0
  228. package/lib/src/components/modal/modals-container.js.map +1 -0
  229. package/lib/src/components/modal/modals-error-boundary.d.ts +18 -0
  230. package/lib/src/components/modal/modals-error-boundary.d.ts.map +1 -0
  231. package/lib/src/components/modal/modals-error-boundary.js +22 -0
  232. package/lib/src/components/modal/modals-error-boundary.js.map +1 -0
  233. package/lib/src/components/ph-logo.d.ts +2 -0
  234. package/lib/src/components/ph-logo.d.ts.map +1 -0
  235. package/lib/src/components/ph-logo.js +7 -0
  236. package/lib/src/components/ph-logo.js.map +1 -0
  237. package/lib/src/components/reload-connect-toast.d.ts +2 -0
  238. package/lib/src/components/reload-connect-toast.d.ts.map +1 -0
  239. package/lib/src/components/reload-connect-toast.js +7 -0
  240. package/lib/src/components/reload-connect-toast.js.map +1 -0
  241. package/lib/src/components/root.d.ts +2 -0
  242. package/lib/src/components/root.d.ts.map +1 -0
  243. package/lib/src/components/root.js +8 -0
  244. package/lib/src/components/root.js.map +1 -0
  245. package/lib/src/components/router.d.ts +2 -0
  246. package/lib/src/components/router.d.ts.map +1 -0
  247. package/lib/src/components/router.js +41 -0
  248. package/lib/src/components/router.js.map +1 -0
  249. package/lib/src/components/search-bar.d.ts +2 -0
  250. package/lib/src/components/search-bar.d.ts.map +1 -0
  251. package/lib/src/components/search-bar.js +36 -0
  252. package/lib/src/components/search-bar.js.map +1 -0
  253. package/lib/src/components/sidebar.d.ts +2 -0
  254. package/lib/src/components/sidebar.d.ts.map +1 -0
  255. package/lib/src/components/sidebar.js +27 -0
  256. package/lib/src/components/sidebar.js.map +1 -0
  257. package/lib/src/connect.config.d.ts +113 -0
  258. package/lib/src/connect.config.d.ts.map +1 -0
  259. package/lib/src/connect.config.js +147 -0
  260. package/lib/src/connect.config.js.map +1 -0
  261. package/lib/src/context/index.d.ts +4 -0
  262. package/lib/src/context/index.d.ts.map +1 -0
  263. package/lib/src/context/index.js +4 -0
  264. package/lib/src/context/index.js.map +1 -0
  265. package/lib/src/context/processor-manager.d.ts +3 -0
  266. package/lib/src/context/processor-manager.d.ts.map +1 -0
  267. package/lib/src/context/processor-manager.js +189 -0
  268. package/lib/src/context/processor-manager.js.map +1 -0
  269. package/lib/src/context/read-mode.d.ts +2 -0
  270. package/lib/src/context/read-mode.d.ts.map +1 -0
  271. package/lib/src/context/read-mode.js +219 -0
  272. package/lib/src/context/read-mode.js.map +1 -0
  273. package/lib/src/context/sentry-provider.d.ts +6 -0
  274. package/lib/src/context/sentry-provider.d.ts.map +1 -0
  275. package/lib/src/context/sentry-provider.js +6 -0
  276. package/lib/src/context/sentry-provider.js.map +1 -0
  277. package/lib/src/feature-flags.d.ts +34 -0
  278. package/lib/src/feature-flags.d.ts.map +1 -0
  279. package/lib/src/feature-flags.js +124 -0
  280. package/lib/src/feature-flags.js.map +1 -0
  281. package/lib/src/globals.d.ts +9 -0
  282. package/lib/src/globals.d.ts.map +1 -0
  283. package/lib/src/globals.js +2 -0
  284. package/lib/src/globals.js.map +1 -0
  285. package/lib/src/hmr.d.ts +3 -0
  286. package/lib/src/hmr.d.ts.map +1 -0
  287. package/lib/src/hmr.js +2 -0
  288. package/lib/src/hmr.js.map +1 -0
  289. package/lib/src/hooks/index.d.ts +10 -0
  290. package/lib/src/hooks/index.d.ts.map +1 -0
  291. package/lib/src/hooks/index.js +10 -0
  292. package/lib/src/hooks/index.js.map +1 -0
  293. package/lib/src/hooks/useAcceptedCookies.d.ts +9 -0
  294. package/lib/src/hooks/useAcceptedCookies.d.ts.map +1 -0
  295. package/lib/src/hooks/useAcceptedCookies.js +34 -0
  296. package/lib/src/hooks/useAcceptedCookies.js.map +1 -0
  297. package/lib/src/hooks/useCheckLatestVersion.d.ts +2 -0
  298. package/lib/src/hooks/useCheckLatestVersion.d.ts.map +1 -0
  299. package/lib/src/hooks/useCheckLatestVersion.js +33 -0
  300. package/lib/src/hooks/useCheckLatestVersion.js.map +1 -0
  301. package/lib/src/hooks/useClientErrorHandler.d.ts +6 -0
  302. package/lib/src/hooks/useClientErrorHandler.d.ts.map +1 -0
  303. package/lib/src/hooks/useClientErrorHandler.js +120 -0
  304. package/lib/src/hooks/useClientErrorHandler.js.map +1 -0
  305. package/lib/src/hooks/useCookieBanner.d.ts +5 -0
  306. package/lib/src/hooks/useCookieBanner.d.ts.map +1 -0
  307. package/lib/src/hooks/useCookieBanner.js +32 -0
  308. package/lib/src/hooks/useCookieBanner.js.map +1 -0
  309. package/lib/src/hooks/useInitSentry.d.ts +2 -0
  310. package/lib/src/hooks/useInitSentry.d.ts.map +1 -0
  311. package/lib/src/hooks/useInitSentry.js +80 -0
  312. package/lib/src/hooks/useInitSentry.js.map +1 -0
  313. package/lib/src/hooks/useNodeActions.d.ts +6 -0
  314. package/lib/src/hooks/useNodeActions.d.ts.map +1 -0
  315. package/lib/src/hooks/useNodeActions.js +35 -0
  316. package/lib/src/hooks/useNodeActions.js.map +1 -0
  317. package/lib/src/hooks/useUndoRedoShortcuts.d.ts +8 -0
  318. package/lib/src/hooks/useUndoRedoShortcuts.d.ts.map +1 -0
  319. package/lib/src/hooks/useUndoRedoShortcuts.js +26 -0
  320. package/lib/src/hooks/useUndoRedoShortcuts.js.map +1 -0
  321. package/lib/src/hooks/useWindowSize.d.ts +5 -0
  322. package/lib/src/hooks/useWindowSize.d.ts.map +1 -0
  323. package/lib/src/hooks/useWindowSize.js +21 -0
  324. package/lib/src/hooks/useWindowSize.js.map +1 -0
  325. package/lib/src/hooks/utils.d.ts +7 -0
  326. package/lib/src/hooks/utils.d.ts.map +1 -0
  327. package/lib/src/hooks/utils.js +46 -0
  328. package/lib/src/hooks/utils.js.map +1 -0
  329. package/lib/src/i18n/index.d.ts +4 -0
  330. package/lib/src/i18n/index.d.ts.map +1 -0
  331. package/lib/src/i18n/index.js +26 -0
  332. package/lib/src/i18n/index.js.map +1 -0
  333. package/lib/src/i18n/locales/en.json +114 -0
  334. package/lib/src/index.d.ts +2 -0
  335. package/lib/src/index.d.ts.map +1 -0
  336. package/lib/src/index.js +2 -0
  337. package/lib/src/index.js.map +1 -0
  338. package/lib/src/main.d.ts +2 -0
  339. package/lib/src/main.d.ts.map +1 -0
  340. package/lib/src/main.js +5 -0
  341. package/lib/src/main.js.map +1 -0
  342. package/lib/src/pages/content.d.ts +2 -0
  343. package/lib/src/pages/content.d.ts.map +1 -0
  344. package/lib/src/pages/content.js +39 -0
  345. package/lib/src/pages/content.js.map +1 -0
  346. package/lib/src/pages/demo/atlas-import.d.ts +2 -0
  347. package/lib/src/pages/demo/atlas-import.d.ts.map +1 -0
  348. package/lib/src/pages/demo/atlas-import.js +122 -0
  349. package/lib/src/pages/demo/atlas-import.js.map +1 -0
  350. package/lib/src/pages/index.d.ts +4 -0
  351. package/lib/src/pages/index.d.ts.map +1 -0
  352. package/lib/src/pages/index.js +4 -0
  353. package/lib/src/pages/index.js.map +1 -0
  354. package/lib/src/pages/settings.d.ts +4 -0
  355. package/lib/src/pages/settings.d.ts.map +1 -0
  356. package/lib/src/pages/settings.js +9 -0
  357. package/lib/src/pages/settings.js.map +1 -0
  358. package/lib/src/service-worker.d.ts +2 -0
  359. package/lib/src/service-worker.d.ts.map +1 -0
  360. package/lib/src/service-worker.js +58 -0
  361. package/lib/src/service-worker.js.map +1 -0
  362. package/lib/src/services/hmr.d.ts +13 -0
  363. package/lib/src/services/hmr.d.ts.map +1 -0
  364. package/lib/src/services/hmr.js +85 -0
  365. package/lib/src/services/hmr.js.map +1 -0
  366. package/lib/src/services/index.d.ts +10 -0
  367. package/lib/src/services/index.d.ts.map +1 -0
  368. package/lib/src/services/index.js +9 -0
  369. package/lib/src/services/index.js.map +1 -0
  370. package/lib/src/services/logger.d.ts +2 -0
  371. package/lib/src/services/logger.d.ts.map +1 -0
  372. package/lib/src/services/logger.js +28 -0
  373. package/lib/src/services/logger.js.map +1 -0
  374. package/lib/src/services/renown/browser.d.ts +2 -0
  375. package/lib/src/services/renown/browser.d.ts.map +1 -0
  376. package/lib/src/services/renown/browser.js +6 -0
  377. package/lib/src/services/renown/browser.js.map +1 -0
  378. package/lib/src/services/renown/constants.d.ts +130 -0
  379. package/lib/src/services/renown/constants.d.ts.map +1 -0
  380. package/lib/src/services/renown/constants.js +41 -0
  381. package/lib/src/services/renown/constants.js.map +1 -0
  382. package/lib/src/services/renown/utils.d.ts +7 -0
  383. package/lib/src/services/renown/utils.d.ts.map +1 -0
  384. package/lib/src/services/renown/utils.js +20 -0
  385. package/lib/src/services/renown/utils.js.map +1 -0
  386. package/lib/src/services/storage/base-storage.d.ts +9 -0
  387. package/lib/src/services/storage/base-storage.d.ts.map +1 -0
  388. package/lib/src/services/storage/base-storage.js +21 -0
  389. package/lib/src/services/storage/base-storage.js.map +1 -0
  390. package/lib/src/services/storage/browser.d.ts +5 -0
  391. package/lib/src/services/storage/browser.d.ts.map +1 -0
  392. package/lib/src/services/storage/browser.js +25 -0
  393. package/lib/src/services/storage/browser.js.map +1 -0
  394. package/lib/src/services/storage/types.d.ts +6 -0
  395. package/lib/src/services/storage/types.d.ts.map +1 -0
  396. package/lib/src/services/storage/types.js +2 -0
  397. package/lib/src/services/storage/types.js.map +1 -0
  398. package/lib/src/services/toast.d.ts +8 -0
  399. package/lib/src/services/toast.d.ts.map +1 -0
  400. package/lib/src/services/toast.js +11 -0
  401. package/lib/src/services/toast.js.map +1 -0
  402. package/lib/src/store/document-model.d.ts +3 -0
  403. package/lib/src/store/document-model.d.ts.map +1 -0
  404. package/lib/src/store/document-model.js +79 -0
  405. package/lib/src/store/document-model.js.map +1 -0
  406. package/lib/src/store/editor.d.ts +5 -0
  407. package/lib/src/store/editor.d.ts.map +1 -0
  408. package/lib/src/store/editor.js +31 -0
  409. package/lib/src/store/editor.js.map +1 -0
  410. package/lib/src/store/external-packages.d.ts +4 -0
  411. package/lib/src/store/external-packages.d.ts.map +1 -0
  412. package/lib/src/store/external-packages.js +36 -0
  413. package/lib/src/store/external-packages.js.map +1 -0
  414. package/lib/src/store/index.d.ts +7 -0
  415. package/lib/src/store/index.d.ts.map +1 -0
  416. package/lib/src/store/index.js +7 -0
  417. package/lib/src/store/index.js.map +1 -0
  418. package/lib/src/store/reactor.d.ts +3 -0
  419. package/lib/src/store/reactor.d.ts.map +1 -0
  420. package/lib/src/store/reactor.js +177 -0
  421. package/lib/src/store/reactor.js.map +1 -0
  422. package/lib/src/store/user.d.ts +2 -0
  423. package/lib/src/store/user.d.ts.map +1 -0
  424. package/lib/src/store/user.js +16 -0
  425. package/lib/src/store/user.js.map +1 -0
  426. package/lib/src/store/utils.d.ts +2 -0
  427. package/lib/src/store/utils.d.ts.map +1 -0
  428. package/lib/src/store/utils.js +59 -0
  429. package/lib/src/store/utils.js.map +1 -0
  430. package/lib/src/utils/browser.d.ts +2 -0
  431. package/lib/src/utils/browser.d.ts.map +1 -0
  432. package/lib/src/utils/browser.js +9 -0
  433. package/lib/src/utils/browser.js.map +1 -0
  434. package/lib/src/utils/document-editor-debug-tools.d.ts +17 -0
  435. package/lib/src/utils/document-editor-debug-tools.d.ts.map +1 -0
  436. package/lib/src/utils/document-editor-debug-tools.js +55 -0
  437. package/lib/src/utils/document-editor-debug-tools.js.map +1 -0
  438. package/lib/src/utils/drive-preservation.d.ts +19 -0
  439. package/lib/src/utils/drive-preservation.d.ts.map +1 -0
  440. package/lib/src/utils/drive-preservation.js +51 -0
  441. package/lib/src/utils/drive-preservation.js.map +1 -0
  442. package/lib/src/utils/drive-sections.d.ts +31 -0
  443. package/lib/src/utils/drive-sections.d.ts.map +1 -0
  444. package/lib/src/utils/drive-sections.js +63 -0
  445. package/lib/src/utils/drive-sections.js.map +1 -0
  446. package/lib/src/utils/index.d.ts +12 -0
  447. package/lib/src/utils/index.d.ts.map +1 -0
  448. package/lib/src/utils/index.js +12 -0
  449. package/lib/src/utils/index.js.map +1 -0
  450. package/lib/src/utils/join.d.ts +2 -0
  451. package/lib/src/utils/join.d.ts.map +1 -0
  452. package/lib/src/utils/join.js +11 -0
  453. package/lib/src/utils/join.js.map +1 -0
  454. package/lib/src/utils/openUrl.d.ts +2 -0
  455. package/lib/src/utils/openUrl.d.ts.map +1 -0
  456. package/lib/src/utils/openUrl.js +3 -0
  457. package/lib/src/utils/openUrl.js.map +1 -0
  458. package/lib/src/utils/path.d.ts +4 -0
  459. package/lib/src/utils/path.d.ts.map +1 -0
  460. package/lib/src/utils/path.js +17 -0
  461. package/lib/src/utils/path.js.map +1 -0
  462. package/lib/src/utils/reactor.d.ts +6 -0
  463. package/lib/src/utils/reactor.d.ts.map +1 -0
  464. package/lib/src/utils/reactor.js +57 -0
  465. package/lib/src/utils/reactor.js.map +1 -0
  466. package/lib/src/utils/registerServiceWorker.d.ts +12 -0
  467. package/lib/src/utils/registerServiceWorker.d.ts.map +1 -0
  468. package/lib/src/utils/registerServiceWorker.js +97 -0
  469. package/lib/src/utils/registerServiceWorker.js.map +1 -0
  470. package/lib/src/utils/signature.d.ts +4 -0
  471. package/lib/src/utils/signature.d.ts.map +1 -0
  472. package/lib/src/utils/signature.js +36 -0
  473. package/lib/src/utils/signature.js.map +1 -0
  474. package/lib/src/utils/slug.d.ts +2 -0
  475. package/lib/src/utils/slug.d.ts.map +1 -0
  476. package/lib/src/utils/slug.js +4 -0
  477. package/lib/src/utils/slug.js.map +1 -0
  478. package/lib/src/workers/pglite-worker.d.ts +2 -0
  479. package/lib/src/workers/pglite-worker.d.ts.map +1 -0
  480. package/lib/src/workers/pglite-worker.js +32 -0
  481. package/lib/src/workers/pglite-worker.js.map +1 -0
  482. package/lib/tsconfig.tsbuildinfo +1 -0
  483. package/lib/vite.config.d.ts +3 -0
  484. package/lib/vite.config.d.ts.map +1 -0
  485. package/lib/vite.config.js +55 -0
  486. package/lib/vite.config.js.map +1 -0
  487. package/package.copy.json +165 -0
  488. package/package.json +129 -96
  489. package/public/icon.ico +0 -0
  490. package/public/robots.txt +3 -0
  491. package/public/settings.png +0 -0
  492. package/scripts/render-skeleton.ts +8 -10
  493. package/src/index.css +4 -0
  494. package/dist/assets/AddDriveModal.CDgN-pun.js +0 -2
  495. package/dist/assets/AddDriveModal.CDgN-pun.js.map +0 -1
  496. package/dist/assets/AddLocalDriveModal.C9MD4Ysa.js +0 -2
  497. package/dist/assets/AddLocalDriveModal.C9MD4Ysa.js.map +0 -1
  498. package/dist/assets/AddRemoteDriveModal.xblpg2cW.js +0 -2
  499. package/dist/assets/AddRemoteDriveModal.xblpg2cW.js.map +0 -1
  500. package/dist/assets/ConfirmationModal.B8lr2E2g.js +0 -2
  501. package/dist/assets/ConfirmationModal.B8lr2E2g.js.map +0 -1
  502. package/dist/assets/CookiesPolicyModal.b_FmtWcR.js +0 -2
  503. package/dist/assets/CookiesPolicyModal.b_FmtWcR.js.map +0 -1
  504. package/dist/assets/CreateDocumentModal.B5Ztd78w.js +0 -2
  505. package/dist/assets/CreateDocumentModal.B5Ztd78w.js.map +0 -1
  506. package/dist/assets/DebugSettingsModal.BOzjtOHO.js +0 -2
  507. package/dist/assets/DebugSettingsModal.BOzjtOHO.js.map +0 -1
  508. package/dist/assets/DeleteDriveModal.BULot_P9.js +0 -2
  509. package/dist/assets/DeleteDriveModal.BULot_P9.js.map +0 -1
  510. package/dist/assets/DeleteItemModal.z8hCTkaW.js +0 -2
  511. package/dist/assets/DeleteItemModal.z8hCTkaW.js.map +0 -1
  512. package/dist/assets/DisclaimerModal.aDgJttL_.js +0 -2
  513. package/dist/assets/DisclaimerModal.aDgJttL_.js.map +0 -1
  514. package/dist/assets/DriveSettingsModal.DKoGnm3q.js +0 -2
  515. package/dist/assets/DriveSettingsModal.DKoGnm3q.js.map +0 -1
  516. package/dist/assets/SettingsModal.DpaP7xQq.js +0 -2
  517. package/dist/assets/SettingsModal.DpaP7xQq.js.map +0 -1
  518. package/dist/assets/Trans.BQm_oYqq.js +0 -2
  519. package/dist/assets/Trans.BQm_oYqq.js.map +0 -1
  520. package/dist/assets/UpgradeDriveModal.aU2KMg4z.js +0 -2
  521. package/dist/assets/UpgradeDriveModal.aU2KMg4z.js.map +0 -1
  522. package/dist/assets/app-skeleton.js +0 -11
  523. package/dist/assets/app-skeleton.js.map +0 -1
  524. package/dist/assets/atlas-import.CZSFwuj4.js +0 -6
  525. package/dist/assets/atlas-import.CZSFwuj4.js.map +0 -1
  526. package/dist/assets/browser.BkwNmV2Z.js +0 -2
  527. package/dist/assets/browser.BkwNmV2Z.js.map +0 -1
  528. package/dist/assets/content.7P2XZwjp.js +0 -3
  529. package/dist/assets/content.7P2XZwjp.js.map +0 -1
  530. package/dist/assets/cookie-banner.UvJrgFVN.js +0 -2
  531. package/dist/assets/cookie-banner.UvJrgFVN.js.map +0 -1
  532. package/dist/assets/i18next.CqOP20KE.js +0 -2
  533. package/dist/assets/i18next.CqOP20KE.js.map +0 -1
  534. package/dist/assets/index-B7k827uL.css +0 -1
  535. package/dist/assets/index.BDg-q7cb.js +0 -2
  536. package/dist/assets/index.BDg-q7cb.js.map +0 -1
  537. package/dist/assets/index.BTPk1US_.js +0 -16
  538. package/dist/assets/index.BTPk1US_.js.map +0 -1
  539. package/dist/assets/index.COdN5sTb.js +0 -445
  540. package/dist/assets/index.COdN5sTb.js.map +0 -1
  541. package/dist/assets/index.CdXCK5kR.js +0 -2
  542. package/dist/assets/index.CdXCK5kR.js.map +0 -1
  543. package/dist/assets/index.CvjHAqar.js +0 -361
  544. package/dist/assets/index.CvjHAqar.js.map +0 -1
  545. package/dist/assets/index.DAzo9kzY.js +0 -333
  546. package/dist/assets/index.DAzo9kzY.js.map +0 -1
  547. package/dist/assets/index.DH4RwKCZ.js +0 -2
  548. package/dist/assets/index.DH4RwKCZ.js.map +0 -1
  549. package/dist/assets/index.DhdwD1w0.js +0 -114
  550. package/dist/assets/index.DhdwD1w0.js.map +0 -1
  551. package/dist/assets/index.RKFvkVvX.js +0 -2
  552. package/dist/assets/index.RKFvkVvX.js.map +0 -1
  553. package/dist/assets/main-CT4nIKNi.css +0 -1
  554. package/dist/assets/main.C9SRxGTs.js +0 -3
  555. package/dist/assets/main.C9SRxGTs.js.map +0 -1
  556. package/dist/assets/modal.CqA_mJUN.js +0 -3
  557. package/dist/assets/modal.CqA_mJUN.js.map +0 -1
  558. package/dist/assets/modals.B2yWw4rS.js +0 -2
  559. package/dist/assets/modals.B2yWw4rS.js.map +0 -1
  560. package/dist/assets/nodefs-CbgXeDrX.js +0 -2
  561. package/dist/assets/nodefs-CbgXeDrX.js.map +0 -1
  562. package/dist/assets/nodefs.zW4Fwgrd.js +0 -2
  563. package/dist/assets/nodefs.zW4Fwgrd.js.map +0 -1
  564. package/dist/assets/nodes.POEKD5Qa.js +0 -2
  565. package/dist/assets/nodes.POEKD5Qa.js.map +0 -1
  566. package/dist/assets/opfs-ahp-CvqFFNTs.js +0 -4
  567. package/dist/assets/opfs-ahp-CvqFFNTs.js.map +0 -1
  568. package/dist/assets/opfs-ahp.Ct4DcoTP.js +0 -4
  569. package/dist/assets/opfs-ahp.Ct4DcoTP.js.map +0 -1
  570. package/dist/assets/pglite-worker-CBI3hEVN.js +0 -144
  571. package/dist/assets/pglite-worker-CBI3hEVN.js.map +0 -1
  572. package/dist/assets/pglite-worker.dssW4LQw.js +0 -2
  573. package/dist/assets/pglite-worker.dssW4LQw.js.map +0 -1
  574. package/dist/assets/postgres-CkP7QCDB.data +0 -0
  575. package/dist/assets/postgres-CyuUVpXN.wasm +0 -0
  576. package/dist/assets/registerServiceWorker.BeE0-hEw.js +0 -2
  577. package/dist/assets/registerServiceWorker.BeE0-hEw.js.map +0 -1
  578. package/dist/assets/root.kpAPoqo9.js +0 -6
  579. package/dist/assets/root.kpAPoqo9.js.map +0 -1
  580. package/dist/assets/style-BkLV0sfQ.css +0 -1
  581. package/dist/assets/style-CszWl8pU.css +0 -1
  582. package/dist/assets/useAcceptedCookies.BUsKgauT.js +0 -2
  583. package/dist/assets/useAcceptedCookies.BUsKgauT.js.map +0 -1
  584. package/dist/assets/useDefaultDocumentModelEditor.joSxCJtY.js +0 -2
  585. package/dist/assets/useDefaultDocumentModelEditor.joSxCJtY.js.map +0 -1
  586. package/dist/assets/useInitSentry.DBsKo0vo.js +0 -368
  587. package/dist/assets/useInitSentry.DBsKo0vo.js.map +0 -1
  588. package/dist/external-packages.js +0 -1
  589. package/dist/fonts/Inter-Black.ttf +0 -0
  590. package/dist/fonts/Inter-Bold.ttf +0 -0
  591. package/dist/fonts/Inter-ExtraBold.ttf +0 -0
  592. package/dist/fonts/Inter-ExtraLight.ttf +0 -0
  593. package/dist/fonts/Inter-Light.ttf +0 -0
  594. package/dist/fonts/Inter-Medium.ttf +0 -0
  595. package/dist/fonts/Inter-Regular.ttf +0 -0
  596. package/dist/fonts/Inter-SemiBold.ttf +0 -0
  597. package/dist/fonts/Inter-Thin.ttf +0 -0
  598. package/dist/fonts/Inter-VariableFont_slnt,wght.ttf +0 -0
  599. package/dist/hmr.js +0 -2
  600. package/dist/hmr.js.map +0 -1
  601. package/dist/service-worker.js +0 -2
  602. package/dist/service-worker.js.map +0 -1
  603. package/dist/swEnv.js +0 -70
  604. package/dist/vite-envs.sh +0 -494
@@ -1,445 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index.BTPk1US_.js","./index.DAzo9kzY.js","./index.RKFvkVvX.js","./browser.BkwNmV2Z.js","./app-skeleton.js","./useInitSentry.DBsKo0vo.js","./useAcceptedCookies.BUsKgauT.js","./registerServiceWorker.BeE0-hEw.js","./cookie-banner.UvJrgFVN.js","./i18next.CqOP20KE.js","./modal.CqA_mJUN.js","./Trans.BQm_oYqq.js"])))=>i.map(i=>d[i]);
2
- var fp=Object.defineProperty;var Ea=t=>{throw TypeError(t)};var pp=(t,e,n)=>e in t?fp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var U=(t,e,n)=>pp(t,typeof e!="symbol"?e+"":e,n),Zi=(t,e,n)=>e.has(t)||Ea("Cannot "+n);var he=(t,e,n)=>(Zi(t,e,"read from private field"),n?n.call(t):e.get(t)),et=(t,e,n)=>e.has(t)?Ea("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Ht=(t,e,n,r)=>(Zi(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),ut=(t,e,n)=>(Zi(t,e,"access private method"),n);import{createRoot as hp}from"react-dom/client";import{p as _a,L as rr,P as mp,a as gp,g as Ii,o as ye,s as ie,b as Cs,e as Qc,l as hr,c as oo,d as Cr,f as ao,i as co,h as Di,j as uo,k as Ni,m as lo,n as fo,q as rt,r as po,t as be,u as ho,v as Ft,w as Xc,x as zr,y as ba,z as yp,B as vp,D as Ep,E as _p,F as bp,G as wp,I as Sp,J as Yr,K as Zc,M as Tp,N as Ip,O as Dp,Q as Lr,R as Np,_ as jt,S as Op,T as Ap,U as Rp,V as Cp,W as Ls,X as Lp,Y as es}from"./index.DAzo9kzY.js";import{jsxs as ri,jsx as Et}from"react/jsx-runtime";import Oi,{useRef as an,createElement as xp,createContext as mo,useReducer as eu,useEffect as xe,useDebugValue as tu,useContext as go,useCallback as ce,useState as Cn,useMemo as mr,StrictMode as Mp,Suspense as wa,lazy as yo}from"react";import{g as Pp}from"./browser.BkwNmV2Z.js";import{A as kp}from"./app-skeleton.js";function $p(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}const tt={verbose:1,debug:2,info:3,warn:4,error:5,silent:6};function nu(t){return typeof t=="string"&&t in tt}var Up={},kt,sn,$t,Ut,wn;class ru{constructor(e,n){et(this,Ut);et(this,kt);et(this,sn,"env");et(this,$t);Ht(this,kt,(e||[]).map(r=>`[${r}]`)),Ht(this,$t,n),this.log=this.log.bind(this),this.info=this.info.bind(this),this.warn=this.warn.bind(this),this.error=this.error.bind(this),this.debug=this.debug.bind(this),this.verbose=this.verbose.bind(this)}get level(){return he(this,sn)}set level(e){if(e!=="env"&&!nu(e))throw new Error(`Invalid log level: ${JSON.stringify(e)}.
3
- Must be one of ${Object.keys(tt).concat(["env"]).join(", ")}.`);Ht(this,sn,e)}get errorHandler(){return he(this,$t)}set errorHandler(e){Ht(this,$t,e)}log(...e){return this.debug(...e)}verbose(...e){if(!(he(this,Ut,wn)>tt.verbose))return this.debug(...e)}debug(...e){if(!(he(this,Ut,wn)>tt.debug))return console.debug(...he(this,kt),...e)}info(...e){if(!(he(this,Ut,wn)>tt.info))return console.info(...he(this,kt),...e)}warn(...e){if(!(he(this,Ut,wn)>tt.warn))return console.warn(...he(this,kt),...e)}error(...e){if(!(he(this,Ut,wn)>tt.error))return he(this,$t)&&he(this,$t).call(this,...e),console.error(...he(this,kt),...e)}}kt=new WeakMap,sn=new WeakMap,$t=new WeakMap,Ut=new WeakSet,wn=function(){if(he(this,sn)==="env"){const e=typeof _a<"u"&&"env"in _a?Up.LOG_LEVEL:void 0;return!e||!(e in tt)?tt.debug:tt[e]}return tt[he(this,sn)]};const Ai=new ru;let vo="env",iu;Ai.level=vo;Ai.errorHandler=iu;const pe=Ai,Fp=t=>{vo=t,Ai.level=t},wt=t=>{const e=new ru(t);return e.level=vo,e.errorHandler=iu,e},Bp="@powerhousedao/connect",jp="Powerhouse-Connect",Vp="4.1.0-dev.11",Gp="Powerhouse Connect",zp="./dist/index.html",Yp="module",qp={node:">=22.0.0"},Hp=["dist","nginx.conf","nginx.sh","scripts"],Jp="AGPL-3.0-only",Wp="acaldas@powerhouse.inc",Kp={type:"git",url:"https://github.com/powerhouse-inc/powerhouse"},Qp={url:"https://github.com/powerhouse-inc/powerhouse/issues"},Xp="https://github.com/powerhouse-inc/powerhouse#readme",Zp={"build:tsc":"tsc --build",start:"electron-forge start",package:"electron-forge package",make:"PH_CONNECT_BASE_HREF=./ electron-forge make","make:mac":"PH_CONNECT_BASE_HREF=./ electron-forge make -p darwin","make:linux":"PH_CONNECT_BASE_HREF=./ electron-forge make -p linux","make:windows":"PH_CONNECT_BASE_HREF=./ electron-forge make -p win32","publish:electron":"electron-forge publish",prepublishOnly:"npm run build",lint:"eslint .","lint:fix":"eslint --fix .","lint:nx":"eslint --quiet --fix .",format:'prettier --write "**/*.+(js|ts|jsx|tsx|json)"',dev:"vite -c vite.renderer.config.mts","dev:nocache":"rm -rf node_modules/.vite && rm -rf node_modules/.cache && npm run dev",prebuild:"npm run clean && tsc --build --noEmit",build:"NODE_OPTIONS=--max-old-space-size=6144 vite build -c vite.renderer.config.mts",preview:"vite preview -c vite.renderer.config.mts",e2e:"playwright test","cy:open":"cypress open","build:service-worker":"tsc --build ./tsconfig.sw.json",clean:"rimraf dist","clean:node_modules":"rimraf node_modules","docker:build":"docker build -f ./Dockerfile --tag connect-test-dev --build-arg TAG=dev .","docker:run":"docker run -it -p 4000:4000 -v $(realpath ../../../monorepo):/monorepo -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf.template -e PH_USE_LOCAL=true -e PH_CONNECT_BASE_PATH=/develop/powerhouse/connect -e PORT=4000 connect-test-dev"},eh={"@didtools/key-webcrypto":"^0.2.0","@electron-forge/cli":"^6.1.1","@electron-forge/maker-deb":"^6.1.1","@electron-forge/maker-rpm":"^6.1.1","@electron-forge/maker-squirrel":"^6.1.1","@electron-forge/maker-zip":"^6.1.1","@electron-forge/plugin-vite":"^6.1.1","@electron-forge/publisher-electron-release-server":"^6.2.1","@electron-forge/publisher-github":"^7.2.0","@electron-forge/shared-types":"^7.7.0","@playwright/test":"^1.41.2","@powerhousedao/builder-tools":"workspace:*","@powerhousedao/common":"workspace:*","@powerhousedao/config":"workspace:*","@powerhousedao/design-system":"workspace:*","@powerhousedao/vetra":"workspace:*","@powerhousedao/diff-analyzer":"^0.0.0-dev.10","@powerhousedao/reactor-browser":"workspace:*","@powerhousedao/state":"workspace:*","@renown/sdk":"workspace:*","@rollup/plugin-node-resolve":"^15.2.3","@sentry/browser":"^9.1.0","@sentry/react":"^7.109.0","@sentry/vite-plugin":"^2.23.0","@tailwindcss/vite":"^4.1.4","@tanstack/react-virtual":"^3.8.1","@types/node":"^22.15.17","@types/react":"^18.2.79","@types/react-dom":"^18.2.18","@types/uuid":"^9.0.7","@types/wicg-file-system-access":"^2020.9.6","@vitejs/plugin-basic-ssl":"^2.0.0","@vitejs/plugin-react":"^4.4.1",asar:"^3.2.0","did-jwt":"^8.0.14","did-jwt-vc":"^4.0.12","did-key-creator":"^1.2.0","document-drive":"workspace:*","document-model":"workspace:*",electron:"30.0.0","electron-is-dev":"^3.0.1","electron-playwright-helpers":"^1.7.1","electron-squirrel-startup":"^1.0.0","electron-store":"^8.1.0",esbuild:"^0.24.0","fast-deep-equal":"^3.1.3",graphql:"^16.11.0","graphql-request":"^6.1.0",i18next:"^23.7.6",jotai:"^2.1.0","jotai-devtools":"^0.12.0","jotai-effect":"^1.1.6",localforage:"^1.10.0",playwright:"^1.41.2","playwright-core":"^1.41.2",react:"^18.3.1","react-dom":"^18.3.1","react-error-boundary":"^4.0.11","react-hotkeys-hook":"^4.5.0","react-i18next":"^13.5.0","react-router-dom":"^6.11.2","tailwind-merge":"^3.0.2",tailwindcss:"^4.1.4",uint8arrays:"^5.1.0",uuid:"^9.0.1",viem:"^2.8.13",vite:"^6.3.3","vite-envs":"^4.6.0","vite-plugin-html":"^3.2.2","vite-plugin-node-polyfills":"^0.23.0","vite-plugin-svgr":"^4.3.0","vite-tsconfig-paths":"^5.1.4","xvfb-maybe":"^0.2.1"},th={"@esbuild/linux-x64":"^0.21.4","@rollup/rollup-linux-x64-musl":"4.14.3"},nh={name:Bp,productName:jp,version:Vp,description:Gp,main:zp,type:Yp,engines:qp,files:Hp,license:Jp,author:Wp,repository:Kp,bugs:Qp,homepage:Xp,scripts:Zp,devDependencies:eh,optionalDependencies:th},rh=nh.version,ih=window.__VITE_ENVS.APP_VERSION||rh,sh=window.__VITE_ENVS.PH_CONNECT_WARN_OUTDATED_APP||"false",oh=window.__VITE_ENVS.PH_CONNECT_STUDIO_MODE||"false",ah=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_DRIVE||"false",ch=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_PUBLIC_DRIVES||void 0,uh=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_CLOUD_DRIVES||void 0,lh=window.__VITE_ENVS.PH_CONNECT_DISABLE_ADD_LOCAL_DRIVES||void 0,dh=window.__VITE_ENVS.PH_CONNECT_DISABLE_DELETE_PUBLIC_DRIVES||void 0,fh=window.__VITE_ENVS.PH_CONNECT_DISABLE_DELETE_CLOUD_DRIVES||void 0,ph=window.__VITE_ENVS.PH_CONNECT_DISABLE_DELETE_LOCAL_DRIVES||void 0,hh=window.__VITE_ENVS.PH_CONNECT_LOCAL_DRIVES_ENABLED||void 0,mh=window.__VITE_ENVS.PH_CONNECT_CLOUD_DRIVES_ENABLED||void 0,gh=window.__VITE_ENVS.PH_CONNECT_PUBLIC_DRIVES_ENABLED||void 0,yh=window.__VITE_ENVS.PH_CONNECT_SEARCH_BAR_ENABLED||void 0,vh=window.__VITE_ENVS.PH_CONNECT_HIDE_DOCUMENT_MODEL_SELECTION_SETTINGS||"false",su=Pp()||"/",Eh=window.__VITE_ENVS.PH_CONNECT_SENTRY_DSN||"",_h=window.__VITE_ENVS.PH_CONNECT_SENTRY_ENV||"dev",bh=window.__VITE_ENVS.PH_CONNECT_SENTRY_TRACING_ENABLED||"false",wh=window.__VITE_ENVS.PH_CONNECT_GA_TRACKING_ID,Sh=window.__VITE_ENVS.PH_CONNECT_CLI_VERSION||void 0,Th=window.__VITE_ENVS.PH_CONNECT_ANALYTICS_DATABASE_NAME||`${su.replace(/\//g,"")}:analytics`,Ih=window.__VITE_ENVS.PH_CONNECT_ANALYTICS_DATABASE_WORKER_DISABLED||"false",Dh=window.__VITE_ENVS.PH_CONNECT_DIFF_ANALYTICS_ENABLED||"false",Nh=window.__VITE_ENVS.PH_CONNECT_DRIVE_ANALYTICS_ENABLED||"false",Oh=window.__VITE_ENVS.PH_CONNECT_EXTERNAL_PROCESSORS_ENABLED||"true",Ah=nu(window.__VITE_ENVS.LOG_LEVEL)?window.__VITE_ENVS.LOG_LEVEL:"info";Fp(Ah);pe.debug(`Setting log level to ${window.__VITE_ENVS.LOG_LEVEL}.`);const gr={appVersion:ih,studioMode:oh.toString()==="true",warnOutdatedApp:sh==="true",routerBasename:su,analytics:{databaseName:Th,useWorker:Ih!=="true",driveAnalyticsEnabled:Nh==="true",diffProcessorEnabled:Dh==="true",externalProcessorsEnabled:Oh==="true"},sentry:{dsn:Eh,env:_h,tracing:bh==="true"},content:{showSearchBar:yh!=="false",showDocumentModelSelectionSetting:vh!=="true"},drives:{addDriveEnabled:ah!=="true",sections:{[rr]:{enabled:hh!=="false",allowAdd:lh!=="true",allowDelete:ph!=="true"},[gp]:{enabled:mh!=="false",allowAdd:uh!=="true",allowDelete:fh!=="true"},[mp]:{enabled:gh!=="false",allowAdd:ch!=="true",allowDelete:dh!=="true"}}},gaTrackingId:wh,phCliVersion:Sh},Yn={},Sa=(t,e)=>t.unstable_is?t.unstable_is(e):e===t,Ta=t=>"init"in t,ts=t=>!!t.write,Ia=t=>"v"in t||"e"in t,xr=t=>{if("e"in t)throw t.e;if((Yn?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v},ii=new WeakMap,Da=t=>{var e;return si(t)&&!!((e=ii.get(t))!=null&&e[0])},Rh=t=>{const e=ii.get(t);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(n=>n()))},ou=(t,e)=>{let n=ii.get(t);if(!n){n=[!0,new Set],ii.set(t,n);const r=()=>{n[0]=!1};t.then(r,r)}n[1].add(e)},si=t=>typeof(t==null?void 0:t.then)=="function",au=(t,e,n)=>{n.p.has(t)||(n.p.add(t),e.then(()=>{n.p.delete(t)},()=>{n.p.delete(t)}))},ns=(t,e,n)=>{const r=n(t),i="v"in r,s=r.v;if(si(e))for(const o of r.d.keys())au(t,e,n(o));r.v=e,delete r.e,(!i||!Object.is(s,r.v))&&(++r.n,si(s)&&Rh(s))},Na=(t,e,n)=>{var r;const i=new Set;for(const s of((r=n.get(t))==null?void 0:r.t)||[])n.has(s)&&i.add(s);for(const s of e.p)i.add(s);return i},Ch=()=>{const t=new Set,e=()=>{t.forEach(n=>n())};return e.add=n=>(t.add(n),()=>{t.delete(n)}),e},rs=()=>{const t={},e=new WeakMap,n=r=>{var i,s;(i=e.get(t))==null||i.forEach(o=>o(r)),(s=e.get(r))==null||s.forEach(o=>o())};return n.add=(r,i)=>{const s=r||t,o=(e.has(s)?e:e.set(s,new Set)).get(s);return o.add(i),()=>{o==null||o.delete(i),o.size||e.delete(s)}},n},Lh=t=>(t.c||(t.c=rs()),t.m||(t.m=rs()),t.u||(t.u=rs()),t.f||(t.f=Ch()),t),xh=Symbol(),Mh=(t=new WeakMap,e=new WeakMap,n=new WeakMap,r=new Set,i=new Set,s=new Set,o={},a=(f,...h)=>f.read(...h),c=(f,...h)=>f.write(...h),u=(f,h)=>{var g;return(g=f.unstable_onInit)==null?void 0:g.call(f,h)},d=(f,h)=>{var g;return(g=f.onMount)==null?void 0:g.call(f,h)},...l)=>{const f=l[0]||(b=>{if((Yn?"production":void 0)!=="production"&&!b)throw new Error("Atom is undefined or null");let $=t.get(b);return $||($={d:new Map,p:new Set,n:0},t.set(b,$),u==null||u(b,X)),$}),h=l[1]||(()=>{const b=[],$=A=>{try{A()}catch(C){b.push(C)}};do{o.f&&$(o.f);const A=new Set,C=A.add.bind(A);r.forEach(L=>{var O;return(O=e.get(L))==null?void 0:O.l.forEach(C)}),r.clear(),s.forEach(C),s.clear(),i.forEach(C),i.clear(),A.forEach($),r.size&&g()}while(r.size||s.size||i.size);if(b.length)throw new AggregateError(b)}),g=l[2]||(()=>{const b=[],$=new WeakSet,A=new WeakSet,C=Array.from(r);for(;C.length;){const L=C[C.length-1],O=f(L);if(A.has(L)){C.pop();continue}if($.has(L)){if(n.get(L)===O.n)b.push([L,O]);else if((Yn?"production":void 0)!=="production"&&n.has(L))throw new Error("[Bug] invalidated atom exists");A.add(L),C.pop();continue}$.add(L);for(const re of Na(L,O,e))$.has(re)||C.push(re)}for(let L=b.length-1;L>=0;--L){const[O,re]=b[L];let oe=!1;for(const I of re.d.keys())if(I!==O&&r.has(I)){oe=!0;break}oe&&(E(O),B(O)),n.delete(O)}}),E=l[3]||(b=>{var $;const A=f(b);if(Ia(A)&&(e.has(b)&&n.get(b)!==A.n||Array.from(A.d).every(([q,j])=>E(q).n===j)))return A;A.d.clear();let C=!0;const L=()=>{e.has(b)&&(B(b),g(),h())},O=q=>{var j;if(Sa(b,q)){const V=f(q);if(!Ia(V))if(Ta(q))ns(q,q.init,f);else throw new Error("no atom init");return xr(V)}const Y=E(q);try{return xr(Y)}finally{A.d.set(q,Y.n),Da(A.v)&&au(b,A.v,Y),(j=e.get(q))==null||j.t.add(b),C||L()}};let re,oe;const I={get signal(){return re||(re=new AbortController),re.signal},get setSelf(){return(Yn?"production":void 0)!=="production"&&!ts(b)&&console.warn("setSelf function cannot be used with read-only atom"),!oe&&ts(b)&&(oe=(...q)=>{if((Yn?"production":void 0)!=="production"&&C&&console.warn("setSelf function cannot be called in sync"),!C)try{return P(b,...q)}finally{g(),h()}}),oe}},k=A.n;try{const q=a(b,O,I);return ns(b,q,f),si(q)&&(ou(q,()=>re==null?void 0:re.abort()),q.then(L,L)),A}catch(q){return delete A.v,A.e=q,++A.n,A}finally{C=!1,k!==A.n&&n.get(b)===k&&(n.set(b,A.n),r.add(b),($=o.c)==null||$.call(o,b))}}),D=l[4]||(b=>{const $=[b];for(;$.length;){const A=$.pop(),C=f(A);for(const L of Na(A,C,e)){const O=f(L);n.set(L,O.n),$.push(L)}}}),P=l[5]||((b,...$)=>{let A=!0;const C=O=>xr(E(O)),L=(O,...re)=>{var oe;const I=f(O);try{if(Sa(b,O)){if(!Ta(O))throw new Error("atom not writable");const k=I.n,q=re[0];ns(O,q,f),B(O),k!==I.n&&(r.add(O),(oe=o.c)==null||oe.call(o,O),D(O));return}else return P(O,...re)}finally{A||(g(),h())}};try{return c(b,C,L,...$)}finally{A=!1}}),B=l[6]||(b=>{var $;const A=f(b),C=e.get(b);if(C&&!Da(A.v)){for(const[L,O]of A.d)if(!C.d.has(L)){const re=f(L);R(L).t.add(b),C.d.add(L),O!==re.n&&(r.add(L),($=o.c)==null||$.call(o,L),D(L))}for(const L of C.d||[])if(!A.d.has(L)){C.d.delete(L);const O=K(L);O==null||O.t.delete(b)}}}),R=l[7]||(b=>{var $;const A=f(b);let C=e.get(b);if(!C){E(b);for(const L of A.d.keys())R(L).t.add(b);if(C={l:new Set,d:new Set(A.d.keys()),t:new Set},e.set(b,C),($=o.m)==null||$.call(o,b),ts(b)){const L=()=>{let O=!0;const re=(...oe)=>{try{return P(b,...oe)}finally{O||(g(),h())}};try{const oe=d(b,re);oe&&(C.u=()=>{O=!0;try{oe()}finally{O=!1}})}finally{O=!1}};i.add(L)}}return C}),K=l[8]||(b=>{var $;const A=f(b);let C=e.get(b);if(C&&!C.l.size&&!Array.from(C.t).some(L=>{var O;return(O=e.get(L))==null?void 0:O.d.has(b)})){C.u&&s.add(C.u),C=void 0,e.delete(b),($=o.u)==null||$.call(o,b);for(const L of A.d.keys()){const O=K(L);O==null||O.t.delete(b)}return}return C}),N=[t,e,n,r,i,s,o,a,c,u,d,f,h,g,E,D,P,B,R,K],X={get:b=>xr(E(b)),set:(b,...$)=>{try{return P(b,...$)}finally{g(),h()}},sub:(b,$)=>{const C=R(b).l;return C.add($),h(),()=>{C.delete($),K(b),h()}}};return Object.defineProperty(X,xh,{value:N}),X},cu=Mh,Ph=Lh,Oa=ou,Eo={};let kh=0;function ke(t,e){const n=`atom${++kh}`,r={toString(){return(Eo?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof t=="function"?r.read=t:(r.init=t,r.read=$h,r.write=Uh),e&&(r.write=e),r}function $h(t){return t(this)}function Uh(t,e,n){return e(this,typeof n=="function"?n(t(this)):n)}const Fh=()=>{let t=0;const e=Ph({}),n=new WeakMap,r=new WeakMap,i=cu(n,r,void 0,void 0,void 0,void 0,e,void 0,(a,c,u,...d)=>t?u(a,...d):a.write(c,u,...d)),s=new Set;return e.m.add(void 0,a=>{s.add(a);const c=n.get(a);c.m=r.get(a)}),e.u.add(void 0,a=>{s.delete(a);const c=n.get(a);delete c.m}),Object.assign(i,{dev4_get_internal_weak_map:()=>(console.log("Deprecated: Use devstore from the devtools library"),n),dev4_get_mounted_atoms:()=>s,dev4_restore_atoms:a=>{const c={read:()=>null,write:(u,d)=>{++t;try{for(const[l,f]of a)"init"in l&&d(l,f)}finally{--t}}};i.set(c)}})};function uu(){return(Eo?"production":void 0)!=="production"?Fh():cu()}let jn;function Bh(){return jn||(jn=uu(),(Eo?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=jn),globalThis.__JOTAI_DEFAULT_STORE__!==jn&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),jn}const jh={},lu=mo(void 0);function du(t){return go(lu)||Bh()}function Vh({children:t,store:e}){const n=an(void 0);return!e&&!n.current&&(n.current=uu()),xp(lu.Provider,{value:e||n.current},t)}const xs=t=>typeof(t==null?void 0:t.then)=="function",Ms=t=>{t.status||(t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}))},Gh=Oi.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(Ms(t),t)}),is=new WeakMap,Aa=(t,e)=>{let n=is.get(t);return n||(n=new Promise((r,i)=>{let s=t;const o=u=>d=>{s===u&&r(d)},a=u=>d=>{s===u&&i(d)},c=()=>{try{const u=e();xs(u)?(is.set(u,n),s=u,u.then(o(u),a(u)),Oa(u,c)):r(u)}catch(u){i(u)}};t.then(o(t),a(t)),Oa(t,c)}),is.set(t,n)),n};function Vt(t,e){const{delay:n,unstable_promiseStatus:r=!Oi.use}={},i=du(),[[s,o,a],c]=eu(d=>{const l=i.get(t);return Object.is(d[0],l)&&d[1]===i&&d[2]===t?d:[l,i,t]},void 0,()=>[i.get(t),i,t]);let u=s;if((o!==i||a!==t)&&(c(),u=i.get(t)),xe(()=>{const d=i.sub(t,()=>{if(r)try{const l=i.get(t);xs(l)&&Ms(Aa(l,()=>i.get(t)))}catch{}if(typeof n=="number"){setTimeout(c,n);return}c()});return c(),d},[i,t,n,r]),tu(u),xs(u)){const d=Aa(u,()=>i.get(t));return r&&Ms(d),Gh(d)}return u}function zh(t,e){const n=du();return ce((...i)=>{if((jh?"production":void 0)!=="production"&&!("write"in t))throw new Error("not writable atom");return n.set(t,...i)},[n,t])}function cn(t,e){return[Vt(t),zh(t)]}const Yh=ke(gr);function qh(){return cn(Yh)}const qn={},Ra=(t,e)=>t.unstable_is?t.unstable_is(e):e===t,Ca=t=>"init"in t,ss=t=>!!t.write,La=t=>"v"in t||"e"in t,Mr=t=>{if("e"in t)throw t.e;if((qn?"production":void 0)!=="production"&&!("v"in t))throw new Error("[Bug] atom state is not initialized");return t.v},oi=new WeakMap,xa=t=>{var e;return ai(t)&&!!((e=oi.get(t))!=null&&e[0])},Hh=t=>{const e=oi.get(t);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(n=>n()))},fu=(t,e)=>{let n=oi.get(t);if(!n){n=[!0,new Set],oi.set(t,n);const r=()=>{n[0]=!1};t.then(r,r)}n[1].add(e)},ai=t=>typeof(t==null?void 0:t.then)=="function",pu=(t,e,n)=>{n.p.has(t)||(n.p.add(t),e.then(()=>{n.p.delete(t)},()=>{n.p.delete(t)}))},os=(t,e,n)=>{const r=n(t),i="v"in r,s=r.v;if(ai(e))for(const o of r.d.keys())pu(t,e,n(o));r.v=e,delete r.e,(!i||!Object.is(s,r.v))&&(++r.n,ai(s)&&Hh(s))},Ma=(t,e,n)=>{var r;const i=new Set;for(const s of((r=n.get(t))==null?void 0:r.t)||[])n.has(s)&&i.add(s);for(const s of e.p)i.add(s);return i},Jh=()=>{const t=new Set,e=()=>{t.forEach(n=>n())};return e.add=n=>(t.add(n),()=>{t.delete(n)}),e},as=()=>{const t={},e=new WeakMap,n=r=>{var i,s;(i=e.get(t))==null||i.forEach(o=>o(r)),(s=e.get(r))==null||s.forEach(o=>o())};return n.add=(r,i)=>{const s=r||t,o=(e.has(s)?e:e.set(s,new Set)).get(s);return o.add(i),()=>{o==null||o.delete(i),o.size||e.delete(s)}},n},Wh=t=>(t.c||(t.c=as()),t.m||(t.m=as()),t.u||(t.u=as()),t.f||(t.f=Jh()),t),Kh=Symbol(),Qh=(t=new WeakMap,e=new WeakMap,n=new WeakMap,r=new Set,i=new Set,s=new Set,o={},a=(f,...h)=>f.read(...h),c=(f,...h)=>f.write(...h),u=(f,h)=>{var g;return(g=f.unstable_onInit)==null?void 0:g.call(f,h)},d=(f,h)=>{var g;return(g=f.onMount)==null?void 0:g.call(f,h)},...l)=>{const f=l[0]||(b=>{if((qn?"production":void 0)!=="production"&&!b)throw new Error("Atom is undefined or null");let $=t.get(b);return $||($={d:new Map,p:new Set,n:0},t.set(b,$),u==null||u(b,X)),$}),h=l[1]||(()=>{const b=[],$=A=>{try{A()}catch(C){b.push(C)}};do{o.f&&$(o.f);const A=new Set,C=A.add.bind(A);r.forEach(L=>{var O;return(O=e.get(L))==null?void 0:O.l.forEach(C)}),r.clear(),s.forEach(C),s.clear(),i.forEach(C),i.clear(),A.forEach($),r.size&&g()}while(r.size||s.size||i.size);if(b.length)throw new AggregateError(b)}),g=l[2]||(()=>{const b=[],$=new WeakSet,A=new WeakSet,C=Array.from(r);for(;C.length;){const L=C[C.length-1],O=f(L);if(A.has(L)){C.pop();continue}if($.has(L)){if(n.get(L)===O.n)b.push([L,O]);else if((qn?"production":void 0)!=="production"&&n.has(L))throw new Error("[Bug] invalidated atom exists");A.add(L),C.pop();continue}$.add(L);for(const re of Ma(L,O,e))$.has(re)||C.push(re)}for(let L=b.length-1;L>=0;--L){const[O,re]=b[L];let oe=!1;for(const I of re.d.keys())if(I!==O&&r.has(I)){oe=!0;break}oe&&(E(O),B(O)),n.delete(O)}}),E=l[3]||(b=>{var $;const A=f(b);if(La(A)&&(e.has(b)&&n.get(b)!==A.n||Array.from(A.d).every(([q,j])=>E(q).n===j)))return A;A.d.clear();let C=!0;const L=()=>{e.has(b)&&(B(b),g(),h())},O=q=>{var j;if(Ra(b,q)){const V=f(q);if(!La(V))if(Ca(q))os(q,q.init,f);else throw new Error("no atom init");return Mr(V)}const Y=E(q);try{return Mr(Y)}finally{A.d.set(q,Y.n),xa(A.v)&&pu(b,A.v,Y),(j=e.get(q))==null||j.t.add(b),C||L()}};let re,oe;const I={get signal(){return re||(re=new AbortController),re.signal},get setSelf(){return(qn?"production":void 0)!=="production"&&!ss(b)&&console.warn("setSelf function cannot be used with read-only atom"),!oe&&ss(b)&&(oe=(...q)=>{if((qn?"production":void 0)!=="production"&&C&&console.warn("setSelf function cannot be called in sync"),!C)try{return P(b,...q)}finally{g(),h()}}),oe}},k=A.n;try{const q=a(b,O,I);return os(b,q,f),ai(q)&&(fu(q,()=>re==null?void 0:re.abort()),q.then(L,L)),A}catch(q){return delete A.v,A.e=q,++A.n,A}finally{C=!1,k!==A.n&&n.get(b)===k&&(n.set(b,A.n),r.add(b),($=o.c)==null||$.call(o,b))}}),D=l[4]||(b=>{const $=[b];for(;$.length;){const A=$.pop(),C=f(A);for(const L of Ma(A,C,e)){const O=f(L);n.set(L,O.n),$.push(L)}}}),P=l[5]||((b,...$)=>{let A=!0;const C=O=>Mr(E(O)),L=(O,...re)=>{var oe;const I=f(O);try{if(Ra(b,O)){if(!Ca(O))throw new Error("atom not writable");const k=I.n,q=re[0];os(O,q,f),B(O),k!==I.n&&(r.add(O),(oe=o.c)==null||oe.call(o,O),D(O));return}else return P(O,...re)}finally{A||(g(),h())}};try{return c(b,C,L,...$)}finally{A=!1}}),B=l[6]||(b=>{var $;const A=f(b),C=e.get(b);if(C&&!xa(A.v)){for(const[L,O]of A.d)if(!C.d.has(L)){const re=f(L);R(L).t.add(b),C.d.add(L),O!==re.n&&(r.add(L),($=o.c)==null||$.call(o,L),D(L))}for(const L of C.d||[])if(!A.d.has(L)){C.d.delete(L);const O=K(L);O==null||O.t.delete(b)}}}),R=l[7]||(b=>{var $;const A=f(b);let C=e.get(b);if(!C){E(b);for(const L of A.d.keys())R(L).t.add(b);if(C={l:new Set,d:new Set(A.d.keys()),t:new Set},e.set(b,C),($=o.m)==null||$.call(o,b),ss(b)){const L=()=>{let O=!0;const re=(...oe)=>{try{return P(b,...oe)}finally{O||(g(),h())}};try{const oe=d(b,re);oe&&(C.u=()=>{O=!0;try{oe()}finally{O=!1}})}finally{O=!1}};i.add(L)}}return C}),K=l[8]||(b=>{var $;const A=f(b);let C=e.get(b);if(C&&!C.l.size&&!Array.from(C.t).some(L=>{var O;return(O=e.get(L))==null?void 0:O.d.has(b)})){C.u&&s.add(C.u),C=void 0,e.delete(b),($=o.u)==null||$.call(o,b);for(const L of A.d.keys()){const O=K(L);O==null||O.t.delete(b)}return}return C}),N=[t,e,n,r,i,s,o,a,c,u,d,f,h,g,E,D,P,B,R,K],X={get:b=>Mr(E(b)),set:(b,...$)=>{try{return P(b,...$)}finally{g(),h()}},sub:(b,$)=>{const C=R(b).l;return C.add($),h(),()=>{C.delete($),K(b),h()}}};return Object.defineProperty(X,Kh,{value:N}),X},hu=Qh,Xh=Wh,Pa=fu,_o={};let Zh=0;function Ne(t,e){const n=`atom${++Zh}`,r={toString(){return(_o?"production":void 0)!=="production"&&this.debugLabel?n+":"+this.debugLabel:n}};return typeof t=="function"?r.read=t:(r.init=t,r.read=em,r.write=tm),e&&(r.write=e),r}function em(t){return t(this)}function tm(t,e,n){return e(this,typeof n=="function"?n(t(this)):n)}const nm=()=>{let t=0;const e=Xh({}),n=new WeakMap,r=new WeakMap,i=hu(n,r,void 0,void 0,void 0,void 0,e,void 0,(a,c,u,...d)=>t?u(a,...d):a.write(c,u,...d)),s=new Set;return e.m.add(void 0,a=>{s.add(a);const c=n.get(a);c.m=r.get(a)}),e.u.add(void 0,a=>{s.delete(a);const c=n.get(a);delete c.m}),Object.assign(i,{dev4_get_internal_weak_map:()=>(console.log("Deprecated: Use devstore from the devtools library"),n),dev4_get_mounted_atoms:()=>s,dev4_restore_atoms:a=>{const c={read:()=>null,write:(u,d)=>{++t;try{for(const[l,f]of a)"init"in l&&d(l,f)}finally{--t}}};i.set(c)}})};function rm(){return(_o?"production":void 0)!=="production"?nm():hu()}let Vn;function im(){return Vn||(Vn=rm(),(_o?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=Vn),globalThis.__JOTAI_DEFAULT_STORE__!==Vn&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),Vn}const sm={},om=mo(void 0);function mu(t){return go(om)||im()}const Ps=t=>typeof(t==null?void 0:t.then)=="function",ks=t=>{t.status||(t.status="pending",t.then(e=>{t.status="fulfilled",t.value=e},e=>{t.status="rejected",t.reason=e}))},am=Oi.use||(t=>{if(t.status==="pending")throw t;if(t.status==="fulfilled")return t.value;throw t.status==="rejected"?t.reason:(ks(t),t)}),cs=new WeakMap,ka=(t,e)=>{let n=cs.get(t);return n||(n=new Promise((r,i)=>{let s=t;const o=u=>d=>{s===u&&r(d)},a=u=>d=>{s===u&&i(d)},c=()=>{try{const u=e();Ps(u)?(cs.set(u,n),s=u,u.then(o(u),a(u)),Pa(u,c)):r(u)}catch(u){i(u)}};t.then(o(t),a(t)),Pa(t,c)}),cs.set(t,n)),n};function Rt(t,e){const{delay:n,unstable_promiseStatus:r=!Oi.use}={},i=mu(),[[s,o,a],c]=eu(d=>{const l=i.get(t);return Object.is(d[0],l)&&d[1]===i&&d[2]===t?d:[l,i,t]},void 0,()=>[i.get(t),i,t]);let u=s;if((o!==i||a!==t)&&(c(),u=i.get(t)),xe(()=>{const d=i.sub(t,()=>{if(r)try{const l=i.get(t);Ps(l)&&ks(ka(l,()=>i.get(t)))}catch{}if(typeof n=="number"){setTimeout(c,n);return}c()});return c(),d},[i,t,n,r]),tu(u),Ps(u)){const d=ka(u,()=>i.get(t));return r&&ks(d),am(d)}return u}function un(t,e){const n=mu();return ce((...i)=>{if((sm?"production":void 0)!=="production"&&!("write"in t))throw new Error("not writable atom");return n.set(t,...i)},[n,t])}var us,$a;function cm(){return $a||($a=1,us=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),us}var um=cm();const gu=Ii(um),ir={},lm=t=>typeof(t==null?void 0:t.then)=="function";function dm(t=()=>{try{return window.localStorage}catch(n){(ir?"production":void 0)!=="production"&&typeof window<"u"&&console.warn(n);return}},e){var n;let r,i;const s={getItem:(c,u)=>{var d,l;const f=g=>{if(g=g||"",r!==g){try{i=JSON.parse(g,void 0)}catch{return u}r=g}return i},h=(l=(d=t())==null?void 0:d.getItem(c))!=null?l:null;return lm(h)?h.then(f):f(h)},setItem:(c,u)=>{var d;return(d=t())==null?void 0:d.setItem(c,JSON.stringify(u,void 0))},removeItem:c=>{var u;return(u=t())==null?void 0:u.removeItem(c)}},o=c=>(u,d,l)=>c(u,f=>{let h;try{h=JSON.parse(f||"")}catch{h=l}d(h)});let a;try{a=(n=t())==null?void 0:n.subscribe}catch{}return!a&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(a=(c,u)=>{if(!(t()instanceof window.Storage))return()=>{};const d=l=>{l.storageArea===t()&&l.key===c&&u(l.newValue)};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}}),a&&(s.subscribe=o(a)),s}dm();const ls=new WeakMap,fm=(t,e)=>(ls.has(e)?ls:ls.set(e,t())).get(e),pm=t=>typeof(t==null?void 0:t.then)=="function",Ua={state:"loading"};function gn(t){return fm(()=>{const e=new WeakMap,n=Ne(0);(ir?"production":void 0)!=="production"&&(n.debugPrivate=!0);const r=Ne((i,{setSelf:s})=>{i(n);let o;try{o=i(t)}catch(d){return{state:"hasError",error:d}}if(!pm(o))return{state:"hasData",data:o};const a=o,c=e.get(a);if(c)return c;a.then(d=>{e.set(a,{state:"hasData",data:d}),s()},d=>{e.set(a,{state:"hasError",error:d}),s()});const u=e.get(a);return u||(e.set(a,Ua),Ua)},(i,s)=>{s(n,o=>o+1)});return(ir?"production":void 0)!=="production"&&(r.debugPrivate=!0),Ne(i=>i(r))},t)}const Fa=(t,e,n)=>(e.has(n)?e:e.set(n,t())).get(n),hm=new WeakMap,mm=(t,e,n)=>{const r=Fa(()=>new WeakMap,hm,e);return Fa(t,r,n)},gm=t=>typeof(t==null?void 0:t.then)=="function",ym=()=>{};function yn(t,e=ym){return mm(()=>{const n=new WeakMap,r=new WeakMap,i=Ne(0);(ir?"production":void 0)!=="production"&&(i.debugPrivate=!0);const s=Ne((o,{setSelf:a})=>{o(i);const c=o(s),u=o(t);if(!gm(u))return{v:u};if(u!==(c==null?void 0:c.p)&&u.then(d=>{r.set(u,d),a()},d=>{n.set(u,d),a()}),n.has(u))throw n.get(u);return r.has(u)?{p:u,v:r.get(u)}:c&&"v"in c?{p:u,f:e(c.v),v:c.v}:{p:u,f:e()}},(o,a)=>{a(i,c=>c+1)});return s.init=void 0,(ir?"production":void 0)!=="production"&&(s.debugPrivate=!0),Ne(o=>{const a=o(s);return"f"in a?a.f:a.v},(o,a,...c)=>a(t,...c))},t,e)}function $s(t){if(!t)return"PUBLIC";const e="readContext"in t,{sharingType:n}=e?{sharingType:"PUBLIC"}:t.state.local,r=n==null?void 0:n.toUpperCase();return r==="PRIVATE"?"LOCAL":r}function vm(t){if(!t)return!1;const e="readContext"in t,{availableOffline:n}=e?{availableOffline:!1}:t.state.local;return n??!1}function gS(t){if(t)return{id:t.header.id,name:t.state.global.name,kind:"FOLDER",parentFolder:null}}async function Em(t,e){if(!t||!e)return[];const n=await t.getDocuments(e);return await Promise.all(n.map(i=>t.getDocument(i)))}async function _m(t){if(!t)return[];const e=await t.getDrives();return await Promise.all(e.map(r=>t.getDrive(r)))}function yS(t){return t.toSorted((e,n)=>e.name.localeCompare(n.name))}function vS(t){return t?t.kind.toUpperCase()==="FILE":!1}function bm(t){return t?t.kind.toUpperCase()==="FOLDER":!1}const qe="NOT_SET";function yr(){return new Promise(()=>{})}const ci=Ne(qe);ci.debugLabel="baseProcessorManagerAtom";const yu=Ne(t=>t(ci)!==qe);yu.debugLabel="processorManagerInitializedAtom";const Ri=Ne(t=>{const e=t(ci);return e===qe?yr():e},(t,e,n)=>{e(ci,n)});Ri.debugLabel="processorManagerAtom";const wm=gn(Ri);wm.debugLabel="loadableProcessorManagerAtom";const Sm=yn(Ri);Sm.debugLabel="unwrappedProcessorManagerAtom";const Xn=Ne(qe);Xn.debugLabel="baseDrivesAtom";const vu=Ne(t=>t(Xn)!==qe);vu.debugLabel="drivesInitializedAtom";const vr=Ne(async t=>{const e=t(Xn);return e===qe?yr():e},async(t,e)=>{const n=t(Xn),r=window.reactor,i=await _m(r);gu(i,n)||e(Xn,i)});vr.debugLabel="drivesAtom";const Tm=gn(vr);Tm.debugLabel="loadableDrivesAtom";const Eu=yn(vr);Eu.debugLabel="unwrappedDrivesAtom";const ui=Ne(qe);ui.debugLabel="selectedDriveIdAtom";const bo=Ne(t=>t(ui)!==qe);bo.debugLabel="driveIdInitializedAtom";const xn=Ne(async t=>{const e=t(ui),n=await t(vr);return e===qe?yr():n==null?void 0:n.find(i=>i.header.id===e)},(t,e,n)=>{e(ui,n),e(sr,void 0)});xn.debugLabel="selectedDriveAtom";const _u=gn(xn);_u.debugLabel="loadableSelectedDriveAtom";const bu=yn(xn);bu.debugLabel="unwrappedSelectedDriveAtom";const Er=Ne(async t=>{const e=await t(xn);return e==null?void 0:e.state.global.nodes});Er.debugLabel="nodesAtom";const Im=gn(Er);Im.debugLabel="loadableNodesAtom";const Dm=yn(Er);Dm.debugLabel="unwrappedNodesAtom";const sr=Ne(qe);sr.debugLabel="selectedNodeIdAtom";const wu=Ne(t=>t(sr)!==qe);wu.debugLabel="selectedNodeIdInitializedAtom";const _r=Ne(async t=>{const e=t(sr),n=await t(Er);return e===qe?yr():n==null?void 0:n.find(r=>r.id===e)},(t,e,n)=>{e(sr,n)});_r.debugLabel="selectedNodeAtom";const wo=Ne(async t=>{const e=await t(Er),n=await t(_r),r=e==null?void 0:e.filter(bm);return r==null?void 0:r.find(i=>i.id===(n==null?void 0:n.id))});wo.debugLabel="selectedFolderAtom";const Nm=gn(wo);Nm.debugLabel="loadableSelectedFolderAtom";const Om=yn(wo);Om.debugLabel="unwrappedSelectedFolderAtom";const Zn=Ne(qe);Zn.debugLabel="baseDocumentsAtom";const Su=Ne(t=>t(Zn)!==qe);Su.debugLabel="documentsInitializedAtom";const br=Ne(t=>{const e=t(Zn);return e===qe?yr():e},async(t,e,n)=>{const r=t(Zn),i=window.reactor,s=await Em(i,n);gu(s,r)||e(Zn,s)});br.debugLabel="documentsAtom";const Am=gn(br);Am.debugLabel="loadableDocumentsAtom";const Rm=yn(br);Rm.debugLabel="unwrappedDocumentsAtom";const So=Ne(async t=>{const e=await t(br),n=await t(_r);return e==null?void 0:e.find(r=>r.header.id===(n==null?void 0:n.id))});So.debugLabel="selectedDocumentAtom";const Cm=gn(So);Cm.debugLabel="loadableSelectedDocumentAtom";const Lm=yn(So);Lm.debugLabel="unwrappedSelectedDocumentAtom";const Ba=t=>{const e=t.operations.global.map(r=>(delete r.resultingState,r)),n=t.operations.local.map(r=>(delete r.resultingState,r));return{...t,operations:{global:e,local:n}}};class xm{constructor(e){U(this,"index",0);U(this,"cache");this.cache=e}createStorage(){const e=this.index;this.index+=1;function n(i){return`${e}-${i}`}const r={get:i=>this.cache.get(n(i)),set:(i,s)=>(this.cache.set(n(i),s),r),delete:i=>this.cache.delete(n(i)),clear:()=>{this.cache.clear()}};return r}}class Tu{constructor(e=new Map){U(this,"cache");U(this,"cacheStorageManager");U(this,"idToDocument");U(this,"idToDrive");U(this,"slugToDriveId");this.cache=e,this.cacheStorageManager=new xm(e),this.idToDocument=this.cacheStorageManager.createStorage(),this.idToDrive=this.cacheStorageManager.createStorage(),this.slugToDriveId=this.cacheStorageManager.createStorage()}clear(){this.idToDocument.clear(),this.idToDrive.clear(),this.slugToDriveId.clear()}async setDocument(e,n){const r=Ba(n);this.idToDocument.set(e,r)}async getDocument(e){return this.idToDocument.get(e)}async deleteDocument(e){return this.idToDocument.delete(e)}async setDrive(e,n){const r=Ba(n);this.idToDrive.set(e,r)}async getDrive(e){return this.idToDrive.get(e)}async deleteDrive(e){const n=this.idToDrive.get(e);if(!n)return!1;const r=n.header.slug.length>0?n.header.slug:e;return r&&this.slugToDriveId.delete(r),this.idToDrive.delete(e)}async setDriveBySlug(e,n){const r=n.header.id;this.slugToDriveId.set(e,r),this.setDrive(r,n)}async getDriveBySlug(e){const n=this.slugToDriveId.get(e);if(n)return this.getDrive(n)}async deleteDriveBySlug(e){const n=this.slugToDriveId.get(e);return n?(this.slugToDriveId.delete(e),this.deleteDrive(n)):!1}}const Iu={id:"powerhouse/document-drive",name:"DocumentDrive",extension:"phdd",description:"",author:{name:"Powerhouse Inc",website:"https://www.powerhouse.inc/"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type FolderNode {
4
- id: String!
5
- name: String!
6
- kind: String!
7
- parentFolder: String
8
- }
9
-
10
- type FileNode {
11
- id: String!
12
- name: String!
13
- kind: String!
14
- documentType: String!
15
- parentFolder: String
16
- }
17
-
18
- union Node = FolderNode | FileNode
19
-
20
- type DocumentDriveState {
21
- name: String!
22
- nodes: [Node!]!
23
- icon: String
24
- }`,initialValue:'"{\\"name\\":\\"\\",\\"nodes\\":[],\\"icon\\":null}"',examples:[]},local:{schema:`type ListenerFilter {
25
- documentType: [String!]!
26
- documentId: [ID!]
27
- scope: [String!]
28
- branch: [String!]
29
- }
30
-
31
- enum TransmitterType {
32
- Internal,
33
- SwitchboardPush,
34
- PullResponder,
35
- SecureConnect,
36
- MatrixConnect,
37
- RESTWebhook
38
- }
39
-
40
- type ListenerCallInfo {
41
- transmitterType: TransmitterType
42
- name: String
43
- data: String
44
- }
45
-
46
- type Listener {
47
- listenerId: ID!
48
- label: String
49
- block: Boolean!
50
- system: Boolean!
51
- filter: ListenerFilter!
52
- callInfo: ListenerCallInfo
53
- }
54
-
55
- enum TriggerType {
56
- PullResponder
57
- }
58
-
59
- type PullResponderTriggerData {
60
- listenerId: ID!
61
- url: String!
62
- interval: String!
63
- }
64
-
65
- union TriggerData = PullResponderTriggerData
66
-
67
- type Trigger {
68
- id: ID!
69
- type: TriggerType!
70
- data: TriggerData
71
- }
72
-
73
- type DocumentDriveLocalState{
74
- sharingType: String
75
- listeners: [Listener!]!
76
- triggers: [Trigger!]!
77
- availableOffline: Boolean!
78
- }`,initialValue:'"{ \\"listeners\\": [], \\"triggers\\": [], \\"sharingType\\": \\"private\\", \\"availableOffline\\": false}"',examples:[]}},modules:[{id:"GRzuvv78tBvmB6ciitokLfonNHA=",name:"Node",description:"",operations:[{id:"7xiTdxonc9yEASR8sfV/KnbSV10=",name:"ADD_FILE",description:"",schema:`input AddFileInput {
79
- id: ID!
80
- name: String!
81
- documentType: String!
82
- parentFolder: ID
83
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"4lzNMMKKdIAtEU6i12xLgi9hp+U=",name:"ADD_FOLDER",description:"",schema:`input AddFolderInput {
84
- id: ID!
85
- name: String!
86
- parentFolder: ID
87
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"53jH2/3TWTTcgCJiv2C+BmuC6i0=",name:"DELETE_NODE",description:"",schema:`input DeleteNodeInput {
88
- id: ID!
89
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"pNn+Y1/HVq/GNMk7t0u3g3gtMLE=",name:"UPDATE_FILE",description:"",schema:`input UpdateFileInput {
90
- id: ID!
91
- parentFolder: ID
92
- name: String
93
- documentType: String
94
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"P0x1M8Mnt+Q/+9nggkwgVbfybsc=",name:"UPDATE_NODE",description:"",schema:`input UpdateNodeInput {
95
- id: ID!
96
- parentFolder: ID
97
- name: String
98
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"vnQ7OB5b3wGLgjhbgJqAIpA+JLE=",name:"COPY_NODE",description:"",schema:`input CopyNodeInput {
99
- srcId: ID!
100
- targetId: ID!
101
- targetName: String
102
- targetParentFolder: ID
103
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"VNyiD/sNGzk6k9A1Qe7s8dmrJxA=",name:"MOVE_NODE",description:"",schema:`input MoveNodeInput {
104
- srcFolder: ID!
105
- targetParentFolder: ID
106
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"}]},{id:"0dHwHlxOM9x0vMZ+gLnKxf2qTEo=",name:"Drive",description:"",operations:[{id:"qGCiPGpTt/cyz3HzyrBn92z1dsU=",name:"SET_DRIVE_NAME",description:"",schema:`input SetDriveNameInput {
107
- name: String!
108
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"qGCiPGpTt/cyz3HzyrBn92z30dsU=",name:"SET_DRIVE_ICON",description:"",schema:`input SetDriveIconInput {
109
- icon: String!
110
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"qGCiPGpTt/cyz3HzyrBn92z2dsU=",name:"SET_SHARING_TYPE",description:"",schema:`input SetSharingTypeInput {
111
- type: String!
112
- }`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z3dsU=",name:"SET_AVAILABLE_OFFLINE",description:"",schema:`input SetAvailableOfflineInput {
113
- availableOffline: Boolean!
114
- }`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z9dsU=",name:"ADD_LISTENER",description:"",schema:`input AddListenerInput {
115
- listener: Listener!
116
- }`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z10dsU=",name:"REMOVE_LISTENER",description:"",schema:`input RemoveListenerInput {
117
- listenerId: String!
118
- }`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z20dsU=",name:"ADD_TRIGGER",description:"",schema:`input AddTriggerInput {
119
- trigger: Trigger!
120
- }`,template:"",reducer:"",errors:[],examples:[],scope:"local"},{id:"qGCiPGpTt/cyz3HzyrBn92z30dsU=",name:"REMOVE_TRIGGER",description:"",schema:`input RemoveTriggerInput {
121
- triggerId: String!
122
- }`,template:"",reducer:"",errors:[],examples:[],scope:"local"}]}]}]},To=Iu.id,Mm=t=>t!=null;oo().refine(t=>Mm(t));const Pm=Qc(["Internal","MatrixConnect","PullResponder","RESTWebhook","SecureConnect","SwitchboardPush"]),km=Qc(["PullResponder"]);function Du(){return ye({documentType:ie(),id:ie(),name:ie(),parentFolder:ie().nullish()})}function Nu(){return ye({id:ie(),name:ie(),parentFolder:ie().nullish()})}function Ou(){return ye({listener:$m()})}function Au(){return ye({trigger:jm()})}function Ru(){return ye({srcId:ie(),targetId:ie(),targetName:ie().nullish(),targetParentFolder:ie().nullish()})}function Cu(){return ye({id:ie()})}function $m(){return ye({__typename:hr("Listener").optional(),block:Cs(),callInfo:Um().nullable(),filter:Fm(),label:ie().nullable(),listenerId:ie(),system:Cs()})}function Um(){return ye({__typename:hr("ListenerCallInfo").optional(),data:ie().nullable(),name:ie().nullable(),transmitterType:Pm.nullable()})}function Fm(){return ye({__typename:hr("ListenerFilter").optional(),branch:Cr(ie()).nullable(),documentId:Cr(ie()).nullable(),documentType:Cr(ie()),scope:Cr(ie()).nullable()})}function Lu(){return ye({srcFolder:ie(),targetParentFolder:ie().nullish()})}function Bm(){return ye({__typename:hr("PullResponderTriggerData").optional(),interval:ie(),listenerId:ie(),url:ie()})}function xu(){return ye({listenerId:ie()})}function Mu(){return ye({triggerId:ie()})}function Pu(){return ye({availableOffline:Cs()})}function ku(){return ye({icon:ie()})}function $u(){return ye({name:ie()})}function Uu(){return ye({type:ie()})}function jm(){return ye({__typename:hr("Trigger").optional(),data:Vm().nullable(),id:ie(),type:km})}function Vm(){return Bm()}function Fu(){return ye({documentType:ie().nullish(),id:ie(),name:ie().nullish(),parentFolder:ie().nullish()})}function Bu(){return ye({id:ie(),name:ie().nullish(),parentFolder:ie().nullish()})}const Pt={setDriveNameOperation(t,e,n){t.name=e.input.name},setDriveIconOperation(t,e,n){t.icon=e.input.icon},setSharingTypeOperation(t,e,n){t.sharingType=e.input.type},setAvailableOfflineOperation(t,e,n){t.availableOffline=e.input.availableOffline},addListenerOperation(t,e,n){if(t.listeners.find(r=>r.listenerId===e.input.listener.listenerId))throw new Error(`A listener with Id: ${e.input.listener.listenerId} already exists`);t.listeners.push(e.input.listener)},removeListenerOperation(t,e,n){t.listeners=t.listeners.filter(r=>r.listenerId!==e.input.listenerId)},addTriggerOperation(t,e,n){if(t.triggers.find(r=>r.id===e.input.trigger.id))throw new Error(`A trigger with Id: ${e.input.trigger.id} already exists`);t.triggers.push(e.input.trigger)},removeTriggerOperation(t,e,n){t.triggers=t.triggers.filter(r=>r.id!==e.input.triggerId)}};class Gm extends Error{constructor(n,r){super(`Document model "${n}" not found`,{cause:r});U(this,"id");this.id=n}}class Ge extends Error{constructor(n,r,i,s){super(i,{cause:s??r});U(this,"status");U(this,"operation");this.status=n,this.operation=r,s instanceof Error&&(this.stack=s.stack)}}class zm extends Ge{constructor(e,n){super("CONFLICT",n,`Conflicting operation on index ${n.index}`,{existingOperation:e,newOperation:n})}}class li extends Error{constructor(e){super(`Invalid document id: ${e}`)}}class ju extends Error{constructor(e){super(`Invalid slug: ${e}`)}}class Sn extends Error{constructor(n){super(`Document with id ${n} uses id or slug that already exists`);U(this,"documentId");this.documentId=n}}class Ot extends Error{constructor(n){super(`Document with id ${n} not found`);U(this,"documentId");this.documentId=n}}class Us extends Error{constructor(n){super(`Sync unit ${JSON.stringify(n)} not found`);U(this,"syncUnitId");this.syncUnitId=n}}const di=t=>t&&t.length>0&&/^[a-zA-Z0-9_-]+$/.test(t),Vu=t=>t&&t.length>0&&/^[a-zA-Z0-9_-]+$/.test(t),Gn=t=>t&&t.length>0&&!t.includes("*")?new Set(t):null,Gu=t=>({parentId:Gn(t.parentId),documentId:Gn(t.documentId),documentModelType:Gn(t.documentModelType),scope:Gn(t.scope),branch:Gn(t.branch)});function or(t){return t.kind==="file"}function Io(t){return t.kind==="folder"}function zu(t,e){if(t.parentFolder){const n=e.find(r=>r.id===t.parentFolder);if(!n)throw new Error(`Parent node with id ${t.parentFolder} not found`);return[n,...zu(n,e)]}else return[]}function ar(t,e){const n=e.filter(i=>i.parentFolder===t.id),r=n.map(i=>ar(i,e));return[...n,...r.flat()]}function Yu(t,e,n){const r=n.find(c=>c.id===t.srcId);if(!r)throw new Error(`Node with id ${t.srcId} not found`);const i=[{...r,name:t.targetName||r.name,parentFolder:t.targetParentFolder||null},...ar(r,n)],s={};t.targetParentFolder&&(s[t.targetParentFolder]=t.targetParentFolder);const o=c=>{let u=s[c.id];if(!u){const d=c.id;u=e(c),s[d]=u}return u};return i.map(c=>({srcId:c.id,targetId:o(c),targetName:c.name,targetParentFolder:c.parentFolder?s[c.parentFolder]:null}))}function qu(t,e){let n=0;const r=new RegExp(`^${Hu(e)} \\(copy\\)(?: (\\d+))?$`);for(const i of t){const s=i.match(r);if(s){const o=s[1]?parseInt(s[1],10):1;o>n&&(n=o)}}return n+1}function Hu(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xt(t){const{nodes:e,targetParentFolder:n,srcName:r}=t,i=e.filter(a=>n===""?a.parentFolder===null:a.parentFolder===n).map(a=>a.name);return i.includes(r)?`${r} (copy) ${qu(i,r)}`:r}const Ym=Object.freeze(Object.defineProperty({__proto__:null,escapeRegExp:Hu,generateNodesCopy:Yu,getAncestors:zu,getDescendants:ar,getNextCopyNumber:qu,handleTargetNameCollisions:Xt,isFileNode:or,isFolderNode:Io},Symbol.toStringTag,{value:"Module"})),Jt={addFileOperation(t,e,n){if(t.nodes.find(s=>s.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);if(!di(e.input.id))throw new li(e.input.id);const r=Xt({nodes:t.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null}),i={id:e.input.id,name:r,kind:"file",parentFolder:e.input.parentFolder??null,documentType:e.input.documentType};t.nodes.push(i),n==null||n({type:"CREATE_CHILD_DOCUMENT",input:{id:e.input.id,documentType:e.input.documentType}})},addFolderOperation(t,e){if(t.nodes.find(r=>r.id===e.input.id))throw new Error(`Node with id ${e.input.id} already exists!`);const n=Xt({nodes:t.nodes,srcName:e.input.name,targetParentFolder:e.input.parentFolder||null});t.nodes.push({...e.input,name:n,kind:"folder",parentFolder:e.input.parentFolder??null})},deleteNodeOperation(t,e,n){const r=t.nodes.find(s=>s.id===e.input.id);if(!r)throw new Error(`Node with id ${e.input.id} not found`);const i=ar(r,t.nodes);t.nodes=t.nodes.filter(s=>s.id!==e.input.id&&!i.find(o=>o.id===s.id)),[r,...i].filter(s=>or(s)).forEach(s=>{n==null||n({type:"DELETE_CHILD_DOCUMENT",input:{id:s.id}})})},updateFileOperation(t,e){t.nodes=t.nodes.map(n=>n.id===e.input.id?{...n,name:Xt({nodes:t.nodes,srcName:e.input.name??n.name,targetParentFolder:e.input.parentFolder||null}),documentType:e.input.documentType??n.documentType}:n)},updateNodeOperation(t,e){t.nodes=t.nodes.map(n=>n.id===e.input.id?{...n,name:Xt({nodes:t.nodes,srcName:e.input.name??n.name,targetParentFolder:e.input.parentFolder||null}),parentFolder:e.input.parentFolder===null?null:n.parentFolder}:n)},copyNodeOperation(t,e,n){const r=t.nodes.find(c=>c.id===e.input.srcId);if(!r)throw new Error(`Node with id ${e.input.srcId} not found`);if(!di(e.input.targetId))throw new li(e.input.targetId);if(t.nodes.find(c=>c.id===e.input.targetId))throw new Error(`Node with id ${e.input.targetId} already exists`);const s=Xt({nodes:t.nodes,srcName:e.input.targetName||r.name,targetParentFolder:e.input.targetParentFolder||null}),o={...r,id:e.input.targetId,slug:e.input.targetId,name:s,parentFolder:e.input.targetParentFolder||null};t.nodes.push(o),or(o)&&(n==null||n({type:"COPY_CHILD_DOCUMENT",input:{id:e.input.srcId,newId:e.input.targetId}}))},moveNodeOperation(t,e){if(e.input.srcFolder===e.input.targetParentFolder)throw new Error("Circular Reference Error: Attempting to move a node to its current parent folder");const n=t.nodes.find(i=>i.id===e.input.srcFolder);if(!n)throw new Error(`Node with id ${e.input.srcFolder} not found`);const r=Xt({nodes:t.nodes,srcName:n.name,targetParentFolder:e.input.targetParentFolder||null});if(Io(n)&&ar(n,t.nodes).find(s=>s.id===e.input.targetParentFolder))throw new Error("Circular Reference Error: Cannot move a folder to one of its descendants");t.nodes=t.nodes.map(i=>i.id===e.input.srcFolder?{...i,name:r,parentFolder:e.input.targetParentFolder||null}:i)}},qm=(t,e,n)=>{if(co(e))return t;const r=e;switch(r.type){case"ADD_FILE":Du().parse(r.input),Jt.addFileOperation(t[r.scope],e,n);break;case"ADD_FOLDER":Nu().parse(r.input),Jt.addFolderOperation(t[r.scope],e,n);break;case"DELETE_NODE":Cu().parse(r.input),Jt.deleteNodeOperation(t[r.scope],e,n);break;case"UPDATE_FILE":Fu().parse(r.input),Jt.updateFileOperation(t[r.scope],e,n);break;case"UPDATE_NODE":Bu().parse(r.input),Jt.updateNodeOperation(t[r.scope],e,n);break;case"COPY_NODE":Ru().parse(r.input),Jt.copyNodeOperation(t[r.scope],e,n);break;case"MOVE_NODE":Lu().parse(r.input),Jt.moveNodeOperation(t[r.scope],e,n);break;case"SET_DRIVE_NAME":$u().parse(r.input),Pt.setDriveNameOperation(t[r.scope],e,n);break;case"SET_DRIVE_ICON":ku().parse(r.input),Pt.setDriveIconOperation(t[r.scope],e,n);break;case"SET_SHARING_TYPE":Uu().parse(r.input),Pt.setSharingTypeOperation(t[r.scope],e,n);break;case"SET_AVAILABLE_OFFLINE":Pu().parse(r.input),Pt.setAvailableOfflineOperation(t[r.scope],e,n);break;case"ADD_LISTENER":Ou().parse(r.input),Pt.addListenerOperation(t[r.scope],e,n);break;case"REMOVE_LISTENER":xu().parse(r.input),Pt.removeListenerOperation(t[r.scope],e,n);break;case"ADD_TRIGGER":Au().parse(r.input),Pt.addTriggerOperation(t[r.scope],e,n);break;case"REMOVE_TRIGGER":Mu().parse(r.input),Pt.removeTriggerOperation(t[r.scope],e,n);break;default:return t}},cr=ao(qm),Hm={name:"",nodes:[],icon:null},Jm={listeners:[],triggers:[],sharingType:"private",availableOffline:!1},Tn={fileExtension:"phdd",createState(t){return{global:{...Hm,...t==null?void 0:t.global},local:{...Jm,...t==null?void 0:t.local}}},createExtendedState(t){return po({...t},Tn.createState)},createDocument(t){const e=fo(Tn.createExtendedState(t),Tn.createState);return e.header.documentType=To,e.header.id=rt(),e},saveToFile(t,e,n){return lo(t,e,"phdd",n)},saveToFileHandle(t,e){return Ni(t,e)},loadFromFile(t){return uo(t,cr)},loadFromInput(t){return Di(t,cr)}},Wm=Tn.createDocument;function Ju(t){return t&&typeof t=="object"&&"synchronizationUnits"in t?be("ADD_FILE",{...t},void 0,void 0,"global"):be("ADD_FILE",{...t},void 0,Du,"global")}const Wu=t=>be("ADD_FOLDER",{...t},void 0,Nu,"global"),Ku=t=>be("DELETE_NODE",{...t},void 0,Cu,"global"),Qu=t=>be("UPDATE_FILE",{...t},void 0,Fu,"global"),Xu=t=>be("UPDATE_NODE",{...t},void 0,Bu,"global"),Zu=t=>be("COPY_NODE",{...t},void 0,Ru,"global"),el=t=>be("MOVE_NODE",{...t},void 0,Lu,"global"),tl=t=>be("SET_DRIVE_NAME",{...t},void 0,$u,"global"),Km=t=>be("SET_DRIVE_ICON",{...t},void 0,ku,"global"),Do=t=>be("SET_SHARING_TYPE",{...t},void 0,Uu,"local"),nl=t=>be("SET_AVAILABLE_OFFLINE",{...t},void 0,Pu,"local"),Qm=t=>be("ADD_LISTENER",{...t},void 0,Ou,"local"),rl=t=>be("REMOVE_LISTENER",{...t},void 0,xu,"local"),il=t=>be("ADD_TRIGGER",{...t},void 0,Au,"local"),No=t=>be("REMOVE_TRIGGER",{...t},void 0,Mu,"local"),Xm=Object.freeze(Object.defineProperty({__proto__:null,addFile:Ju,addFolder:Wu,addListener:Qm,addTrigger:il,copyNode:Zu,deleteNode:Ku,moveNode:el,removeListener:rl,removeTrigger:No,setAvailableOffline:nl,setDriveIcon:Km,setDriveName:tl,setSharingType:Do,updateFile:Qu,updateNode:Xu},Symbol.toStringTag,{value:"Module"})),Zm={...Tn,...Ym},eg={...ho,...Xm},sl={reducer:cr,actions:eg,utils:Zm,documentModel:Iu},tg=sl;let ol=()=>({emit(t,...e){for(let n=this.events[t]||[],r=0,i=n.length;r<i;r++)n[r](...e)},events:{},on(t,e){var n;return((n=this.events)[t]||(n[t]=[])).push(e),()=>{var r;this.events[t]=(r=this.events[t])==null?void 0:r.filter(i=>e!==i)}}});class ng{constructor(e){U(this,"id");U(this,"running",!1);U(this,"deleted",!1);U(this,"items",[]);U(this,"dependencies",new Array);this.id=e}async isRunning(){return this.running}async setRunning(e){this.running=e}async setDeleted(e){this.deleted=e}async isDeleted(){return this.deleted}async addJob(e){return this.items.push(e),Promise.resolve()}async getNextJob(){const e=this.items.shift();return Promise.resolve(e)}async amountOfJobs(){return Promise.resolve(this.items.length)}getId(){return this.id}async isBlocked(){return this.running||this.deleted||this.dependencies.length>0}async getJobs(){return this.items}async addDependency(e){this.dependencies.includes(e.jobId)||this.dependencies.push(e.jobId)}async removeDependency(e){const n=this.dependencies.indexOf(e.jobId);n>-1&&this.dependencies.splice(n,1)}}function qr(t){return"documentType"in t}function al(t){return"operations"in t}function rg(t){return"actions"in t}class cl{constructor(e=1,n=0){U(this,"logger",wt(["EventQueueManager"]));U(this,"emitter",ol());U(this,"queues",new Map);U(this,"globalQueue",new Array);U(this,"isFindingJob",!1);U(this,"maxWorkers");U(this,"workers");U(this,"runningJobs",new Array);U(this,"timeout");U(this,"delegate");U(this,"onError");this.maxWorkers=e,this.workers=0,this.timeout=n}async init(e,n){this.delegate=e,this.onError=n;function r(i){return async(...s)=>{try{await i(...s)}catch(o){throw o instanceof Error?o:new Error(JSON.stringify(o))}}}return this.emitter.on("jobAdded",r(async i=>{this.logger.verbose("Added job",i),await this.processNextJob()})),this.emitter.on("jobStarted",r(async i=>{this.logger.verbose("Started job",i.jobId),this.runningJobs.push(i),await this.processNextJob()})),this.emitter.on("jobCompleted",r(async(i,s)=>{this.logger.verbose("Completed job",i.jobId),await this.handleJobCompleted(i,s)})),this.emitter.on("jobFailed",r(async(i,s)=>{this.logger.error("Failed job",i,s),this.removeJob(i),n(s),await this.processNextJob()})),Promise.resolve()}async addJob(e){var c;if(!this.delegate)throw new Error("No server delegate defined");const n=rt(),r=qr(e),i=qr(e)?void 0:al(e)?e.operations:e.actions;if(!r&&!(i!=null&&i.length))throw new Error("Job has no operations or actions: "+JSON.stringify(e));const s=((c=i==null?void 0:i.at(0))==null?void 0:c.scope)??"global";if(i!=null&&i.find(u=>u.scope!==s))throw new Error("Job has actions with different scopes");const o=this.getQueue(e.documentId,s);if(!qr(e)&&await o.isDeleted())throw new Error("Job has operations for deleted document");const a=Object.freeze({jobId:n,...e});return await o.addJob(a),this.globalQueue.push({jobId:n,documentId:e.documentId,scope:s,timestamp:new Date().toUTCString()}),this.emit("jobAdded",a),n}getQueue(e,n){let r=this.queues.get(e);r||(r=new Map,this.queues.set(e,r));let i=r.get(n);return i||(i=new ng(n),r.set(n,i)),i}getDocumentQueues(e){return this.queues.get(e)}removeQueue(e,n){const r=this.queues.get(e),i=r==null?void 0:r.delete(n);return i&&this.emit("queueRemoved",{documentId:e,scope:n}),i}removeDocumentQueues(e){const n=this.queues.get(e);n==null||n.keys().forEach(r=>{this.removeQueue(e,r)})}removeJob(e){const n=this.runningJobs.findIndex(i=>i.jobId===e.jobId);n===-1&&this.logger.warn("Running job not found",e.jobId),this.runningJobs.splice(n,1);const r=this.globalQueue.findIndex(i=>i.jobId===e.jobId);r===-1&&this.logger.warn("Job not found on global queue",e.jobId),this.globalQueue.splice(r,1)}async handleJobCompleted(e,n){return this.removeJob(e),this.processNextJob()}isBusy(){return this.workers>=this.maxWorkers}async processNextJob(){if(this.isFindingJob)return;if(!this.delegate)throw new Error("No server delegate defined");if(this.globalQueue.length===0||this.isBusy())return;this.isFindingJob=!0,this.workers++;let e,n;try{const r=await this.findNextJob();e=r==null?void 0:r.queue,n=r==null?void 0:r.job}catch(r){pe.error("Error finding next job",r)}if(!e||!n){this.workers--,this.isFindingJob=!1;return}try{await e.setRunning(!0),this.isFindingJob=!1,this.emit("jobStarted",n);const r=await this.delegate.processJob(n);this.workers--,await e.setRunning(!1),this.emit("jobCompleted",n,r)}catch(r){pe.error("Job failed",r),this.workers--,this.isFindingJob=!1,await e.setRunning(!1),this.emit("jobFailed",n,r instanceof Error?r:new Error(JSON.stringify(r)))}}async findNextJob(){const e=new Set;for(const n of this.globalQueue){const r=this.getQueue(n.documentId,n.scope),i=r.getId();if(e.has(i))continue;if(await r.isBlocked()){e.add(r.getId());continue}const s=await r.getNextJob();if((s==null?void 0:s.jobId)!==n.jobId){pe.warn("Queue has different job waiting to be picked up"),pe.error(n,s);continue}return{queue:r,job:s}}}emit(e,...n){this.emitter.emit(e,...n)}on(e,n){return this.emitter.on(e,n)}}class Ci extends Error{}class Wt extends Ci{constructor(e){super(`Read drive ${e} not found.`)}}class ig extends Ci{constructor(e){super(`Read drive with slug ${e} not found.`)}}class ja extends Ci{constructor(e,n){super(`Document with id ${n} not found on read drive ${e}.`)}}function ve(t,e){if(!!!t)throw new Error(e)}function ln(t){return typeof t=="object"&&t!==null}function mt(t,e){if(!!!t)throw new Error(e??"Unexpected invariant triggered.")}const sg=/\r\n|[\n\r]/g;function Fs(t,e){let n=0,r=1;for(const i of t.body.matchAll(sg)){if(typeof i.index=="number"||mt(!1),i.index>=e)break;n=i.index+i[0].length,r+=1}return{line:r,column:e+1-n}}function og(t){return ul(t.source,Fs(t.source,t.start))}function ul(t,e){const n=t.locationOffset.column-1,r="".padStart(n)+t.body,i=e.line-1,s=t.locationOffset.line-1,o=e.line+s,a=e.line===1?n:0,c=e.column+a,u=`${t.name}:${o}:${c}
123
- `,d=r.split(/\r\n|[\n\r]/g),l=d[i];if(l.length>120){const f=Math.floor(c/80),h=c%80,g=[];for(let E=0;E<l.length;E+=80)g.push(l.slice(E,E+80));return u+Va([[`${o} |`,g[0]],...g.slice(1,f+1).map(E=>["|",E]),["|","^".padStart(h)],["|",g[f+1]]])}return u+Va([[`${o-1} |`,d[i-1]],[`${o} |`,l],["|","^".padStart(c)],[`${o+1} |`,d[i+1]]])}function Va(t){const e=t.filter(([r,i])=>i!==void 0),n=Math.max(...e.map(([r])=>r.length));return e.map(([r,i])=>r.padStart(n)+(i?" "+i:"")).join(`
124
- `)}function ag(t){const e=t[0];return e==null||"kind"in e||"length"in e?{nodes:e,source:t[1],positions:t[2],path:t[3],originalError:t[4],extensions:t[5]}:e}class z extends Error{constructor(e,...n){var r,i,s;const{nodes:o,source:a,positions:c,path:u,originalError:d,extensions:l}=ag(n);super(e),this.name="GraphQLError",this.path=u??void 0,this.originalError=d??void 0,this.nodes=Ga(Array.isArray(o)?o:o?[o]:void 0);const f=Ga((r=this.nodes)===null||r===void 0?void 0:r.map(g=>g.loc).filter(g=>g!=null));this.source=a??(f==null||(i=f[0])===null||i===void 0?void 0:i.source),this.positions=c??(f==null?void 0:f.map(g=>g.start)),this.locations=c&&a?c.map(g=>Fs(a,g)):f==null?void 0:f.map(g=>Fs(g.source,g.start));const h=ln(d==null?void 0:d.extensions)?d==null?void 0:d.extensions:void 0;this.extensions=(s=l??h)!==null&&s!==void 0?s:Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),d!=null&&d.stack?Object.defineProperty(this,"stack",{value:d.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,z):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return"GraphQLError"}toString(){let e=this.message;if(this.nodes)for(const n of this.nodes)n.loc&&(e+=`
125
-
126
- `+og(n.loc));else if(this.source&&this.locations)for(const n of this.locations)e+=`
127
-
128
- `+ul(this.source,n);return e}toJSON(){const e={message:this.message};return this.locations!=null&&(e.locations=this.locations),this.path!=null&&(e.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}}function Ga(t){return t===void 0||t.length===0?void 0:t}function Fe(t,e,n){return new z(`Syntax Error: ${n}`,{source:t,positions:[e]})}class cg{constructor(e,n,r){this.start=e.start,this.end=n.end,this.startToken=e,this.endToken=n,this.source=r}get[Symbol.toStringTag](){return"Location"}toJSON(){return{start:this.start,end:this.end}}}class ll{constructor(e,n,r,i,s,o){this.kind=e,this.start=n,this.end=r,this.line=i,this.column=s,this.value=o,this.prev=null,this.next=null}get[Symbol.toStringTag](){return"Token"}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}}const dl={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},ug=new Set(Object.keys(dl));function Bs(t){const e=t==null?void 0:t.kind;return typeof e=="string"&&ug.has(e)}var Ye;(function(t){t.QUERY="query",t.MUTATION="mutation",t.SUBSCRIPTION="subscription"})(Ye||(Ye={}));var se;(function(t){t.QUERY="QUERY",t.MUTATION="MUTATION",t.SUBSCRIPTION="SUBSCRIPTION",t.FIELD="FIELD",t.FRAGMENT_DEFINITION="FRAGMENT_DEFINITION",t.FRAGMENT_SPREAD="FRAGMENT_SPREAD",t.INLINE_FRAGMENT="INLINE_FRAGMENT",t.VARIABLE_DEFINITION="VARIABLE_DEFINITION",t.SCHEMA="SCHEMA",t.SCALAR="SCALAR",t.OBJECT="OBJECT",t.FIELD_DEFINITION="FIELD_DEFINITION",t.ARGUMENT_DEFINITION="ARGUMENT_DEFINITION",t.INTERFACE="INTERFACE",t.UNION="UNION",t.ENUM="ENUM",t.ENUM_VALUE="ENUM_VALUE",t.INPUT_OBJECT="INPUT_OBJECT",t.INPUT_FIELD_DEFINITION="INPUT_FIELD_DEFINITION"})(se||(se={}));var y;(function(t){t.NAME="Name",t.DOCUMENT="Document",t.OPERATION_DEFINITION="OperationDefinition",t.VARIABLE_DEFINITION="VariableDefinition",t.SELECTION_SET="SelectionSet",t.FIELD="Field",t.ARGUMENT="Argument",t.FRAGMENT_SPREAD="FragmentSpread",t.INLINE_FRAGMENT="InlineFragment",t.FRAGMENT_DEFINITION="FragmentDefinition",t.VARIABLE="Variable",t.INT="IntValue",t.FLOAT="FloatValue",t.STRING="StringValue",t.BOOLEAN="BooleanValue",t.NULL="NullValue",t.ENUM="EnumValue",t.LIST="ListValue",t.OBJECT="ObjectValue",t.OBJECT_FIELD="ObjectField",t.DIRECTIVE="Directive",t.NAMED_TYPE="NamedType",t.LIST_TYPE="ListType",t.NON_NULL_TYPE="NonNullType",t.SCHEMA_DEFINITION="SchemaDefinition",t.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",t.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",t.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",t.FIELD_DEFINITION="FieldDefinition",t.INPUT_VALUE_DEFINITION="InputValueDefinition",t.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",t.UNION_TYPE_DEFINITION="UnionTypeDefinition",t.ENUM_TYPE_DEFINITION="EnumTypeDefinition",t.ENUM_VALUE_DEFINITION="EnumValueDefinition",t.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",t.DIRECTIVE_DEFINITION="DirectiveDefinition",t.SCHEMA_EXTENSION="SchemaExtension",t.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",t.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",t.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",t.UNION_TYPE_EXTENSION="UnionTypeExtension",t.ENUM_TYPE_EXTENSION="EnumTypeExtension",t.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension"})(y||(y={}));function js(t){return t===9||t===32}function ur(t){return t>=48&&t<=57}function fl(t){return t>=97&&t<=122||t>=65&&t<=90}function Oo(t){return fl(t)||t===95}function pl(t){return fl(t)||ur(t)||t===95}function lg(t){var e;let n=Number.MAX_SAFE_INTEGER,r=null,i=-1;for(let o=0;o<t.length;++o){var s;const a=t[o],c=dg(a);c!==a.length&&(r=(s=r)!==null&&s!==void 0?s:o,i=o,o!==0&&c<n&&(n=c))}return t.map((o,a)=>a===0?o:o.slice(n)).slice((e=r)!==null&&e!==void 0?e:0,i+1)}function dg(t){let e=0;for(;e<t.length&&js(t.charCodeAt(e));)++e;return e}function ES(t){if(t==="")return!0;let e=!0,n=!1,r=!0,i=!1;for(let s=0;s<t.length;++s)switch(t.codePointAt(s)){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 11:case 12:case 14:case 15:return!1;case 13:return!1;case 10:if(e&&!i)return!1;i=!0,e=!0,n=!1;break;case 9:case 32:n||(n=e);break;default:r&&(r=n),e=!1}return!(e||r&&i)}function fg(t,e){const n=t.replace(/"""/g,'\\"""'),r=n.split(/\r\n|[\n\r]/g),i=r.length===1,s=r.length>1&&r.slice(1).every(h=>h.length===0||js(h.charCodeAt(0))),o=n.endsWith('\\"""'),a=t.endsWith('"')&&!o,c=t.endsWith("\\"),u=a||c,d=!i||t.length>70||u||s||o;let l="";const f=i&&js(t.charCodeAt(0));return(d&&!f||s)&&(l+=`
129
- `),l+=n,(d||u)&&(l+=`
130
- `),'"""'+l+'"""'}var M;(function(t){t.SOF="<SOF>",t.EOF="<EOF>",t.BANG="!",t.DOLLAR="$",t.AMP="&",t.PAREN_L="(",t.PAREN_R=")",t.SPREAD="...",t.COLON=":",t.EQUALS="=",t.AT="@",t.BRACKET_L="[",t.BRACKET_R="]",t.BRACE_L="{",t.PIPE="|",t.BRACE_R="}",t.NAME="Name",t.INT="Int",t.FLOAT="Float",t.STRING="String",t.BLOCK_STRING="BlockString",t.COMMENT="Comment"})(M||(M={}));class pg{constructor(e){const n=new ll(M.SOF,0,0,0,0);this.source=e,this.lastToken=n,this.token=n,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return"Lexer"}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==M.EOF)do if(e.next)e=e.next;else{const n=mg(this,e.end);e.next=n,n.prev=e,e=n}while(e.kind===M.COMMENT);return e}}function hg(t){return t===M.BANG||t===M.DOLLAR||t===M.AMP||t===M.PAREN_L||t===M.PAREN_R||t===M.SPREAD||t===M.COLON||t===M.EQUALS||t===M.AT||t===M.BRACKET_L||t===M.BRACKET_R||t===M.BRACE_L||t===M.PIPE||t===M.BRACE_R}function Mn(t){return t>=0&&t<=55295||t>=57344&&t<=1114111}function Li(t,e){return hl(t.charCodeAt(e))&&ml(t.charCodeAt(e+1))}function hl(t){return t>=55296&&t<=56319}function ml(t){return t>=56320&&t<=57343}function dn(t,e){const n=t.source.body.codePointAt(e);if(n===void 0)return M.EOF;if(n>=32&&n<=126){const r=String.fromCodePoint(n);return r==='"'?`'"'`:`"${r}"`}return"U+"+n.toString(16).toUpperCase().padStart(4,"0")}function Pe(t,e,n,r,i){const s=t.line,o=1+n-t.lineStart;return new ll(e,n,r,s,o,i)}function mg(t,e){const n=t.source.body,r=n.length;let i=e;for(;i<r;){const s=n.charCodeAt(i);switch(s){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++t.line,t.lineStart=i;continue;case 13:n.charCodeAt(i+1)===10?i+=2:++i,++t.line,t.lineStart=i;continue;case 35:return gg(t,i);case 33:return Pe(t,M.BANG,i,i+1);case 36:return Pe(t,M.DOLLAR,i,i+1);case 38:return Pe(t,M.AMP,i,i+1);case 40:return Pe(t,M.PAREN_L,i,i+1);case 41:return Pe(t,M.PAREN_R,i,i+1);case 46:if(n.charCodeAt(i+1)===46&&n.charCodeAt(i+2)===46)return Pe(t,M.SPREAD,i,i+3);break;case 58:return Pe(t,M.COLON,i,i+1);case 61:return Pe(t,M.EQUALS,i,i+1);case 64:return Pe(t,M.AT,i,i+1);case 91:return Pe(t,M.BRACKET_L,i,i+1);case 93:return Pe(t,M.BRACKET_R,i,i+1);case 123:return Pe(t,M.BRACE_L,i,i+1);case 124:return Pe(t,M.PIPE,i,i+1);case 125:return Pe(t,M.BRACE_R,i,i+1);case 34:return n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34?wg(t,i):vg(t,i)}if(ur(s)||s===45)return yg(t,i,s);if(Oo(s))return Sg(t,i);throw Fe(t.source,i,s===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:Mn(s)||Li(n,i)?`Unexpected character: ${dn(t,i)}.`:`Invalid character: ${dn(t,i)}.`)}return Pe(t,M.EOF,r,r)}function gg(t,e){const n=t.source.body,r=n.length;let i=e+1;for(;i<r;){const s=n.charCodeAt(i);if(s===10||s===13)break;if(Mn(s))++i;else if(Li(n,i))i+=2;else break}return Pe(t,M.COMMENT,e,i,n.slice(e+1,i))}function yg(t,e,n){const r=t.source.body;let i=e,s=n,o=!1;if(s===45&&(s=r.charCodeAt(++i)),s===48){if(s=r.charCodeAt(++i),ur(s))throw Fe(t.source,i,`Invalid number, unexpected digit after 0: ${dn(t,i)}.`)}else i=ds(t,i,s),s=r.charCodeAt(i);if(s===46&&(o=!0,s=r.charCodeAt(++i),i=ds(t,i,s),s=r.charCodeAt(i)),(s===69||s===101)&&(o=!0,s=r.charCodeAt(++i),(s===43||s===45)&&(s=r.charCodeAt(++i)),i=ds(t,i,s),s=r.charCodeAt(i)),s===46||Oo(s))throw Fe(t.source,i,`Invalid number, expected digit but got: ${dn(t,i)}.`);return Pe(t,o?M.FLOAT:M.INT,e,i,r.slice(e,i))}function ds(t,e,n){if(!ur(n))throw Fe(t.source,e,`Invalid number, expected digit but got: ${dn(t,e)}.`);const r=t.source.body;let i=e+1;for(;ur(r.charCodeAt(i));)++i;return i}function vg(t,e){const n=t.source.body,r=n.length;let i=e+1,s=i,o="";for(;i<r;){const a=n.charCodeAt(i);if(a===34)return o+=n.slice(s,i),Pe(t,M.STRING,e,i+1,o);if(a===92){o+=n.slice(s,i);const c=n.charCodeAt(i+1)===117?n.charCodeAt(i+2)===123?Eg(t,i):_g(t,i):bg(t,i);o+=c.value,i+=c.size,s=i;continue}if(a===10||a===13)break;if(Mn(a))++i;else if(Li(n,i))i+=2;else throw Fe(t.source,i,`Invalid character within String: ${dn(t,i)}.`)}throw Fe(t.source,i,"Unterminated string.")}function Eg(t,e){const n=t.source.body;let r=0,i=3;for(;i<12;){const s=n.charCodeAt(e+i++);if(s===125){if(i<5||!Mn(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|Hn(s),r<0)break}throw Fe(t.source,e,`Invalid Unicode escape sequence: "${n.slice(e,e+i)}".`)}function _g(t,e){const n=t.source.body,r=za(n,e+2);if(Mn(r))return{value:String.fromCodePoint(r),size:6};if(hl(r)&&n.charCodeAt(e+6)===92&&n.charCodeAt(e+7)===117){const i=za(n,e+8);if(ml(i))return{value:String.fromCodePoint(r,i),size:12}}throw Fe(t.source,e,`Invalid Unicode escape sequence: "${n.slice(e,e+6)}".`)}function za(t,e){return Hn(t.charCodeAt(e))<<12|Hn(t.charCodeAt(e+1))<<8|Hn(t.charCodeAt(e+2))<<4|Hn(t.charCodeAt(e+3))}function Hn(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:-1}function bg(t,e){const n=t.source.body;switch(n.charCodeAt(e+1)){case 34:return{value:'"',size:2};case 92:return{value:"\\",size:2};case 47:return{value:"/",size:2};case 98:return{value:"\b",size:2};case 102:return{value:"\f",size:2};case 110:return{value:`
131
- `,size:2};case 114:return{value:"\r",size:2};case 116:return{value:" ",size:2}}throw Fe(t.source,e,`Invalid character escape sequence: "${n.slice(e,e+2)}".`)}function wg(t,e){const n=t.source.body,r=n.length;let i=t.lineStart,s=e+3,o=s,a="";const c=[];for(;s<r;){const u=n.charCodeAt(s);if(u===34&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34){a+=n.slice(o,s),c.push(a);const d=Pe(t,M.BLOCK_STRING,e,s+3,lg(c).join(`
132
- `));return t.line+=c.length-1,t.lineStart=i,d}if(u===92&&n.charCodeAt(s+1)===34&&n.charCodeAt(s+2)===34&&n.charCodeAt(s+3)===34){a+=n.slice(o,s),o=s+1,s+=4;continue}if(u===10||u===13){a+=n.slice(o,s),c.push(a),u===13&&n.charCodeAt(s+1)===10?s+=2:++s,a="",o=s,i=s;continue}if(Mn(u))++s;else if(Li(n,s))s+=2;else throw Fe(t.source,s,`Invalid character within String: ${dn(t,s)}.`)}throw Fe(t.source,s,"Unterminated string.")}function Sg(t,e){const n=t.source.body,r=n.length;let i=e+1;for(;i<r;){const s=n.charCodeAt(i);if(pl(s))++i;else break}return Pe(t,M.NAME,e,i,n.slice(e,i))}const Tg=10,gl=2;function ee(t){return xi(t,[])}function xi(t,e){switch(typeof t){case"string":return JSON.stringify(t);case"function":return t.name?`[function ${t.name}]`:"[function]";case"object":return Ig(t,e);default:return String(t)}}function Ig(t,e){if(t===null)return"null";if(e.includes(t))return"[Circular]";const n=[...e,t];if(Dg(t)){const r=t.toJSON();if(r!==t)return typeof r=="string"?r:xi(r,n)}else if(Array.isArray(t))return Og(t,n);return Ng(t,n)}function Dg(t){return typeof t.toJSON=="function"}function Ng(t,e){const n=Object.entries(t);return n.length===0?"{}":e.length>gl?"["+Ag(t)+"]":"{ "+n.map(([i,s])=>i+": "+xi(s,e)).join(", ")+" }"}function Og(t,e){if(t.length===0)return"[]";if(e.length>gl)return"[Array]";const n=Math.min(Tg,t.length),r=t.length-n,i=[];for(let s=0;s<n;++s)i.push(xi(t[s],e));return r===1?i.push("... 1 more item"):r>1&&i.push(`... ${r} more items`),"["+i.join(", ")+"]"}function Ag(t){const e=Object.prototype.toString.call(t).replace(/^\[object /,"").replace(/]$/,"");if(e==="Object"&&typeof t.constructor=="function"){const n=t.constructor.name;if(typeof n=="string"&&n!=="")return n}return e}const Rg=globalThis.process&&!0,gt=Rg?function(e,n){return e instanceof n}:function(e,n){if(e instanceof n)return!0;if(typeof e=="object"&&e!==null){var r;const i=n.prototype[Symbol.toStringTag],s=Symbol.toStringTag in e?e[Symbol.toStringTag]:(r=e.constructor)===null||r===void 0?void 0:r.name;if(i===s){const o=ee(e);throw new Error(`Cannot use ${i} "${o}" from another module or realm.
133
-
134
- Ensure that there is only one instance of "graphql" in the node_modules
135
- directory. If different versions of "graphql" are the dependencies of other
136
- relied on modules, use "resolutions" to ensure only one version is installed.
137
-
138
- https://yarnpkg.com/en/docs/selective-version-resolutions
139
-
140
- Duplicate "graphql" modules cannot be used at the same time since different
141
- versions may have different capabilities and behavior. The data from one
142
- version used in the function from another could produce confusing and
143
- spurious results.`)}}return!1};class yl{constructor(e,n="GraphQL request",r={line:1,column:1}){typeof e=="string"||ve(!1,`Body must be a string. Received: ${ee(e)}.`),this.body=e,this.name=n,this.locationOffset=r,this.locationOffset.line>0||ve(!1,"line in locationOffset is 1-indexed and must be positive."),this.locationOffset.column>0||ve(!1,"column in locationOffset is 1-indexed and must be positive.")}get[Symbol.toStringTag](){return"Source"}}function Cg(t){return gt(t,yl)}function vl(t,e){const n=new Lg(t,e),r=n.parseDocument();return Object.defineProperty(r,"tokenCount",{enumerable:!1,value:n.tokenCount}),r}class Lg{constructor(e,n={}){const r=Cg(e)?e:new yl(e);this._lexer=new pg(r),this._options=n,this._tokenCounter=0}get tokenCount(){return this._tokenCounter}parseName(){const e=this.expectToken(M.NAME);return this.node(e,{kind:y.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:y.DOCUMENT,definitions:this.many(M.SOF,this.parseDefinition,M.EOF)})}parseDefinition(){if(this.peek(M.BRACE_L))return this.parseOperationDefinition();const e=this.peekDescription(),n=e?this._lexer.lookahead():this._lexer.token;if(n.kind===M.NAME){switch(n.value){case"schema":return this.parseSchemaDefinition();case"scalar":return this.parseScalarTypeDefinition();case"type":return this.parseObjectTypeDefinition();case"interface":return this.parseInterfaceTypeDefinition();case"union":return this.parseUnionTypeDefinition();case"enum":return this.parseEnumTypeDefinition();case"input":return this.parseInputObjectTypeDefinition();case"directive":return this.parseDirectiveDefinition()}if(e)throw Fe(this._lexer.source,this._lexer.token.start,"Unexpected description, descriptions are supported only on type definitions.");switch(n.value){case"query":case"mutation":case"subscription":return this.parseOperationDefinition();case"fragment":return this.parseFragmentDefinition();case"extend":return this.parseTypeSystemExtension()}}throw this.unexpected(n)}parseOperationDefinition(){const e=this._lexer.token;if(this.peek(M.BRACE_L))return this.node(e,{kind:y.OPERATION_DEFINITION,operation:Ye.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});const n=this.parseOperationType();let r;return this.peek(M.NAME)&&(r=this.parseName()),this.node(e,{kind:y.OPERATION_DEFINITION,operation:n,name:r,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){const e=this.expectToken(M.NAME);switch(e.value){case"query":return Ye.QUERY;case"mutation":return Ye.MUTATION;case"subscription":return Ye.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(M.PAREN_L,this.parseVariableDefinition,M.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:y.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(M.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(M.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){const e=this._lexer.token;return this.expectToken(M.DOLLAR),this.node(e,{kind:y.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:y.SELECTION_SET,selections:this.many(M.BRACE_L,this.parseSelection,M.BRACE_R)})}parseSelection(){return this.peek(M.SPREAD)?this.parseFragment():this.parseField()}parseField(){const e=this._lexer.token,n=this.parseName();let r,i;return this.expectOptionalToken(M.COLON)?(r=n,i=this.parseName()):i=n,this.node(e,{kind:y.FIELD,alias:r,name:i,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(M.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){const n=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(M.PAREN_L,n,M.PAREN_R)}parseArgument(e=!1){const n=this._lexer.token,r=this.parseName();return this.expectToken(M.COLON),this.node(n,{kind:y.ARGUMENT,name:r,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){const e=this._lexer.token;this.expectToken(M.SPREAD);const n=this.expectOptionalKeyword("on");return!n&&this.peek(M.NAME)?this.node(e,{kind:y.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:y.INLINE_FRAGMENT,typeCondition:n?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){const e=this._lexer.token;return this.expectKeyword("fragment"),this._options.allowLegacyFragmentVariables===!0?this.node(e,{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:y.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword("on"),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value==="on")throw this.unexpected();return this.parseName()}parseValueLiteral(e){const n=this._lexer.token;switch(n.kind){case M.BRACKET_L:return this.parseList(e);case M.BRACE_L:return this.parseObject(e);case M.INT:return this.advanceLexer(),this.node(n,{kind:y.INT,value:n.value});case M.FLOAT:return this.advanceLexer(),this.node(n,{kind:y.FLOAT,value:n.value});case M.STRING:case M.BLOCK_STRING:return this.parseStringLiteral();case M.NAME:switch(this.advanceLexer(),n.value){case"true":return this.node(n,{kind:y.BOOLEAN,value:!0});case"false":return this.node(n,{kind:y.BOOLEAN,value:!1});case"null":return this.node(n,{kind:y.NULL});default:return this.node(n,{kind:y.ENUM,value:n.value})}case M.DOLLAR:if(e)if(this.expectToken(M.DOLLAR),this._lexer.token.kind===M.NAME){const r=this._lexer.token.value;throw Fe(this._lexer.source,n.start,`Unexpected variable "$${r}" in constant value.`)}else throw this.unexpected(n);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){const e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:y.STRING,value:e.value,block:e.kind===M.BLOCK_STRING})}parseList(e){const n=()=>this.parseValueLiteral(e);return this.node(this._lexer.token,{kind:y.LIST,values:this.any(M.BRACKET_L,n,M.BRACKET_R)})}parseObject(e){const n=()=>this.parseObjectField(e);return this.node(this._lexer.token,{kind:y.OBJECT,fields:this.any(M.BRACE_L,n,M.BRACE_R)})}parseObjectField(e){const n=this._lexer.token,r=this.parseName();return this.expectToken(M.COLON),this.node(n,{kind:y.OBJECT_FIELD,name:r,value:this.parseValueLiteral(e)})}parseDirectives(e){const n=[];for(;this.peek(M.AT);)n.push(this.parseDirective(e));return n}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){const n=this._lexer.token;return this.expectToken(M.AT),this.node(n,{kind:y.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){const e=this._lexer.token;let n;if(this.expectOptionalToken(M.BRACKET_L)){const r=this.parseTypeReference();this.expectToken(M.BRACKET_R),n=this.node(e,{kind:y.LIST_TYPE,type:r})}else n=this.parseNamedType();return this.expectOptionalToken(M.BANG)?this.node(e,{kind:y.NON_NULL_TYPE,type:n}):n}parseNamedType(){return this.node(this._lexer.token,{kind:y.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(M.STRING)||this.peek(M.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("schema");const r=this.parseConstDirectives(),i=this.many(M.BRACE_L,this.parseOperationTypeDefinition,M.BRACE_R);return this.node(e,{kind:y.SCHEMA_DEFINITION,description:n,directives:r,operationTypes:i})}parseOperationTypeDefinition(){const e=this._lexer.token,n=this.parseOperationType();this.expectToken(M.COLON);const r=this.parseNamedType();return this.node(e,{kind:y.OPERATION_TYPE_DEFINITION,operation:n,type:r})}parseScalarTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("scalar");const r=this.parseName(),i=this.parseConstDirectives();return this.node(e,{kind:y.SCALAR_TYPE_DEFINITION,description:n,name:r,directives:i})}parseObjectTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("type");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:y.OBJECT_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:o})}parseImplementsInterfaces(){return this.expectOptionalKeyword("implements")?this.delimitedMany(M.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(M.BRACE_L,this.parseFieldDefinition,M.BRACE_R)}parseFieldDefinition(){const e=this._lexer.token,n=this.parseDescription(),r=this.parseName(),i=this.parseArgumentDefs();this.expectToken(M.COLON);const s=this.parseTypeReference(),o=this.parseConstDirectives();return this.node(e,{kind:y.FIELD_DEFINITION,description:n,name:r,arguments:i,type:s,directives:o})}parseArgumentDefs(){return this.optionalMany(M.PAREN_L,this.parseInputValueDef,M.PAREN_R)}parseInputValueDef(){const e=this._lexer.token,n=this.parseDescription(),r=this.parseName();this.expectToken(M.COLON);const i=this.parseTypeReference();let s;this.expectOptionalToken(M.EQUALS)&&(s=this.parseConstValueLiteral());const o=this.parseConstDirectives();return this.node(e,{kind:y.INPUT_VALUE_DEFINITION,description:n,name:r,type:i,defaultValue:s,directives:o})}parseInterfaceTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("interface");const r=this.parseName(),i=this.parseImplementsInterfaces(),s=this.parseConstDirectives(),o=this.parseFieldsDefinition();return this.node(e,{kind:y.INTERFACE_TYPE_DEFINITION,description:n,name:r,interfaces:i,directives:s,fields:o})}parseUnionTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("union");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseUnionMemberTypes();return this.node(e,{kind:y.UNION_TYPE_DEFINITION,description:n,name:r,directives:i,types:s})}parseUnionMemberTypes(){return this.expectOptionalToken(M.EQUALS)?this.delimitedMany(M.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("enum");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseEnumValuesDefinition();return this.node(e,{kind:y.ENUM_TYPE_DEFINITION,description:n,name:r,directives:i,values:s})}parseEnumValuesDefinition(){return this.optionalMany(M.BRACE_L,this.parseEnumValueDefinition,M.BRACE_R)}parseEnumValueDefinition(){const e=this._lexer.token,n=this.parseDescription(),r=this.parseEnumValueName(),i=this.parseConstDirectives();return this.node(e,{kind:y.ENUM_VALUE_DEFINITION,description:n,name:r,directives:i})}parseEnumValueName(){if(this._lexer.token.value==="true"||this._lexer.token.value==="false"||this._lexer.token.value==="null")throw Fe(this._lexer.source,this._lexer.token.start,`${Pr(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("input");const r=this.parseName(),i=this.parseConstDirectives(),s=this.parseInputFieldsDefinition();return this.node(e,{kind:y.INPUT_OBJECT_TYPE_DEFINITION,description:n,name:r,directives:i,fields:s})}parseInputFieldsDefinition(){return this.optionalMany(M.BRACE_L,this.parseInputValueDef,M.BRACE_R)}parseTypeSystemExtension(){const e=this._lexer.lookahead();if(e.kind===M.NAME)switch(e.value){case"schema":return this.parseSchemaExtension();case"scalar":return this.parseScalarTypeExtension();case"type":return this.parseObjectTypeExtension();case"interface":return this.parseInterfaceTypeExtension();case"union":return this.parseUnionTypeExtension();case"enum":return this.parseEnumTypeExtension();case"input":return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("schema");const n=this.parseConstDirectives(),r=this.optionalMany(M.BRACE_L,this.parseOperationTypeDefinition,M.BRACE_R);if(n.length===0&&r.length===0)throw this.unexpected();return this.node(e,{kind:y.SCHEMA_EXTENSION,directives:n,operationTypes:r})}parseScalarTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("scalar");const n=this.parseName(),r=this.parseConstDirectives();if(r.length===0)throw this.unexpected();return this.node(e,{kind:y.SCALAR_TYPE_EXTENSION,name:n,directives:r})}parseObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("type");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(e,{kind:y.OBJECT_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseInterfaceTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("interface");const n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),s=this.parseFieldsDefinition();if(r.length===0&&i.length===0&&s.length===0)throw this.unexpected();return this.node(e,{kind:y.INTERFACE_TYPE_EXTENSION,name:n,interfaces:r,directives:i,fields:s})}parseUnionTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("union");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:y.UNION_TYPE_EXTENSION,name:n,directives:r,types:i})}parseEnumTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("enum");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:y.ENUM_TYPE_EXTENSION,name:n,directives:r,values:i})}parseInputObjectTypeExtension(){const e=this._lexer.token;this.expectKeyword("extend"),this.expectKeyword("input");const n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();if(r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:y.INPUT_OBJECT_TYPE_EXTENSION,name:n,directives:r,fields:i})}parseDirectiveDefinition(){const e=this._lexer.token,n=this.parseDescription();this.expectKeyword("directive"),this.expectToken(M.AT);const r=this.parseName(),i=this.parseArgumentDefs(),s=this.expectOptionalKeyword("repeatable");this.expectKeyword("on");const o=this.parseDirectiveLocations();return this.node(e,{kind:y.DIRECTIVE_DEFINITION,description:n,name:r,arguments:i,repeatable:s,locations:o})}parseDirectiveLocations(){return this.delimitedMany(M.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){const e=this._lexer.token,n=this.parseName();if(Object.prototype.hasOwnProperty.call(se,n.value))return n;throw this.unexpected(e)}node(e,n){return this._options.noLocation!==!0&&(n.loc=new cg(e,this._lexer.lastToken,this._lexer.source)),n}peek(e){return this._lexer.token.kind===e}expectToken(e){const n=this._lexer.token;if(n.kind===e)return this.advanceLexer(),n;throw Fe(this._lexer.source,n.start,`Expected ${El(e)}, found ${Pr(n)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e?(this.advanceLexer(),!0):!1}expectKeyword(e){const n=this._lexer.token;if(n.kind===M.NAME&&n.value===e)this.advanceLexer();else throw Fe(this._lexer.source,n.start,`Expected "${e}", found ${Pr(n)}.`)}expectOptionalKeyword(e){const n=this._lexer.token;return n.kind===M.NAME&&n.value===e?(this.advanceLexer(),!0):!1}unexpected(e){const n=e??this._lexer.token;return Fe(this._lexer.source,n.start,`Unexpected ${Pr(n)}.`)}any(e,n,r){this.expectToken(e);const i=[];for(;!this.expectOptionalToken(r);)i.push(n.call(this));return i}optionalMany(e,n,r){if(this.expectOptionalToken(e)){const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}return[]}many(e,n,r){this.expectToken(e);const i=[];do i.push(n.call(this));while(!this.expectOptionalToken(r));return i}delimitedMany(e,n){this.expectOptionalToken(e);const r=[];do r.push(n.call(this));while(this.expectOptionalToken(e));return r}advanceLexer(){const{maxTokens:e}=this._options,n=this._lexer.advance();if(n.kind!==M.EOF&&(++this._tokenCounter,e!==void 0&&this._tokenCounter>e))throw Fe(this._lexer.source,n.start,`Document contains more that ${e} tokens. Parsing aborted.`)}}function Pr(t){const e=t.value;return El(t.kind)+(e!=null?` "${e}"`:"")}function El(t){return hg(t)?`"${t}"`:t}const xg=5;function Gt(t,e){const[n,r]=e?[t,e]:[void 0,t];let i=" Did you mean ";n&&(i+=n+" ");const s=r.map(c=>`"${c}"`);switch(s.length){case 0:return"";case 1:return i+s[0]+"?";case 2:return i+s[0]+" or "+s[1]+"?"}const o=s.slice(0,xg),a=o.pop();return i+o.join(", ")+", or "+a+"?"}function Ya(t){return t}function fn(t,e){const n=Object.create(null);for(const r of t)n[e(r)]=r;return n}function Ao(t,e,n){const r=Object.create(null);for(const i of t)r[e(i)]=n(i);return r}function At(t,e){const n=Object.create(null);for(const r of Object.keys(t))n[r]=e(t[r],r);return n}function Ro(t,e){let n=0,r=0;for(;n<t.length&&r<e.length;){let i=t.charCodeAt(n),s=e.charCodeAt(r);if(kr(i)&&kr(s)){let o=0;do++n,o=o*10+i-Vs,i=t.charCodeAt(n);while(kr(i)&&o>0);let a=0;do++r,a=a*10+s-Vs,s=e.charCodeAt(r);while(kr(s)&&a>0);if(o<a)return-1;if(o>a)return 1}else{if(i<s)return-1;if(i>s)return 1;++n,++r}}return t.length-e.length}const Vs=48,Mg=57;function kr(t){return!isNaN(t)&&Vs<=t&&t<=Mg}function vn(t,e){const n=Object.create(null),r=new Pg(t),i=Math.floor(t.length*.4)+1;for(const s of e){const o=r.measure(s,i);o!==void 0&&(n[s]=o)}return Object.keys(n).sort((s,o)=>{const a=n[s]-n[o];return a!==0?a:Ro(s,o)})}class Pg{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=qa(this._inputLowerCase),this._rows=[new Array(e.length+1).fill(0),new Array(e.length+1).fill(0),new Array(e.length+1).fill(0)]}measure(e,n){if(this._input===e)return 0;const r=e.toLowerCase();if(this._inputLowerCase===r)return 1;let i=qa(r),s=this._inputArray;if(i.length<s.length){const d=i;i=s,s=d}const o=i.length,a=s.length;if(o-a>n)return;const c=this._rows;for(let d=0;d<=a;d++)c[0][d]=d;for(let d=1;d<=o;d++){const l=c[(d-1)%3],f=c[d%3];let h=f[0]=d;for(let g=1;g<=a;g++){const E=i[d-1]===s[g-1]?0:1;let D=Math.min(l[g]+1,f[g-1]+1,l[g-1]+E);if(d>1&&g>1&&i[d-1]===s[g-2]&&i[d-2]===s[g-1]){const P=c[(d-2)%3][g-2];D=Math.min(D,P+1)}D<h&&(h=D),f[g]=D}if(h>n)return}const u=c[o%3][a];return u<=n?u:void 0}}function qa(t){const e=t.length,n=new Array(e);for(let r=0;r<e;++r)n[r]=t.charCodeAt(r);return n}function ct(t){if(t==null)return Object.create(null);if(Object.getPrototypeOf(t)===null)return t;const e=Object.create(null);for(const[n,r]of Object.entries(t))e[n]=r;return e}function kg(t){return`"${t.replace($g,Ug)}"`}const $g=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function Ug(t){return Fg[t.charCodeAt(0)]}const Fg=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"],Jn=Object.freeze({});function Mi(t,e,n=dl){const r=new Map;for(const P of Object.values(y))r.set(P,fi(e,P));let i,s=Array.isArray(t),o=[t],a=-1,c=[],u=t,d,l;const f=[],h=[];do{a++;const P=a===o.length,B=P&&c.length!==0;if(P){if(d=h.length===0?void 0:f[f.length-1],u=l,l=h.pop(),B)if(s){u=u.slice();let K=0;for(const[N,X]of c){const b=N-K;X===null?(u.splice(b,1),K++):u[b]=X}}else{u={...u};for(const[K,N]of c)u[K]=N}a=i.index,o=i.keys,c=i.edits,s=i.inArray,i=i.prev}else if(l){if(d=s?a:o[a],u=l[d],u==null)continue;f.push(d)}let R;if(!Array.isArray(u)){var g,E;Bs(u)||ve(!1,`Invalid AST Node: ${ee(u)}.`);const K=P?(g=r.get(u.kind))===null||g===void 0?void 0:g.leave:(E=r.get(u.kind))===null||E===void 0?void 0:E.enter;if(R=K==null?void 0:K.call(e,u,d,l,f,h),R===Jn)break;if(R===!1){if(!P){f.pop();continue}}else if(R!==void 0&&(c.push([d,R]),!P))if(Bs(R))u=R;else{f.pop();continue}}if(R===void 0&&B&&c.push([d,u]),P)f.pop();else{var D;i={inArray:s,index:a,keys:o,edits:c,prev:i},s=Array.isArray(u),o=s?u:(D=n[u.kind])!==null&&D!==void 0?D:[],a=-1,c=[],l&&h.push(l),l=u}}while(i!==void 0);return c.length!==0?c[c.length-1][1]:t}function _l(t){const e=new Array(t.length).fill(null),n=Object.create(null);for(const r of Object.values(y)){let i=!1;const s=new Array(t.length).fill(void 0),o=new Array(t.length).fill(void 0);for(let c=0;c<t.length;++c){const{enter:u,leave:d}=fi(t[c],r);i||(i=u!=null||d!=null),s[c]=u,o[c]=d}if(!i)continue;const a={enter(...c){const u=c[0];for(let l=0;l<t.length;l++)if(e[l]===null){var d;const f=(d=s[l])===null||d===void 0?void 0:d.apply(t[l],c);if(f===!1)e[l]=u;else if(f===Jn)e[l]=Jn;else if(f!==void 0)return f}},leave(...c){const u=c[0];for(let l=0;l<t.length;l++)if(e[l]===null){var d;const f=(d=o[l])===null||d===void 0?void 0:d.apply(t[l],c);if(f===Jn)e[l]=Jn;else if(f!==void 0&&f!==!1)return f}else e[l]===u&&(e[l]=null)}};n[r]=a}return n}function fi(t,e){const n=t[e];return typeof n=="object"?n:typeof n=="function"?{enter:n,leave:void 0}:{enter:t.enter,leave:t.leave}}function $e(t){return Mi(t,jg)}const Bg=80,jg={Name:{leave:t=>t.value},Variable:{leave:t=>"$"+t.name},Document:{leave:t=>te(t.definitions,`
144
-
145
- `)},OperationDefinition:{leave(t){const e=me("(",te(t.variableDefinitions,", "),")"),n=te([t.operation,te([t.name,e]),te(t.directives," ")]," ");return(n==="query"?"":n+" ")+t.selectionSet}},VariableDefinition:{leave:({variable:t,type:e,defaultValue:n,directives:r})=>t+": "+e+me(" = ",n)+me(" ",te(r," "))},SelectionSet:{leave:({selections:t})=>lt(t)},Field:{leave({alias:t,name:e,arguments:n,directives:r,selectionSet:i}){const s=me("",t,": ")+e;let o=s+me("(",te(n,", "),")");return o.length>Bg&&(o=s+me(`(
146
- `,Hr(te(n,`
147
- `)),`
148
- )`)),te([o,te(r," "),i]," ")}},Argument:{leave:({name:t,value:e})=>t+": "+e},FragmentSpread:{leave:({name:t,directives:e})=>"..."+t+me(" ",te(e," "))},InlineFragment:{leave:({typeCondition:t,directives:e,selectionSet:n})=>te(["...",me("on ",t),te(e," "),n]," ")},FragmentDefinition:{leave:({name:t,typeCondition:e,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${t}${me("(",te(n,", "),")")} on ${e} ${me("",te(r," ")," ")}`+i},IntValue:{leave:({value:t})=>t},FloatValue:{leave:({value:t})=>t},StringValue:{leave:({value:t,block:e})=>e?fg(t):kg(t)},BooleanValue:{leave:({value:t})=>t?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:t})=>t},ListValue:{leave:({values:t})=>"["+te(t,", ")+"]"},ObjectValue:{leave:({fields:t})=>"{"+te(t,", ")+"}"},ObjectField:{leave:({name:t,value:e})=>t+": "+e},Directive:{leave:({name:t,arguments:e})=>"@"+t+me("(",te(e,", "),")")},NamedType:{leave:({name:t})=>t},ListType:{leave:({type:t})=>"["+t+"]"},NonNullType:{leave:({type:t})=>t+"!"},SchemaDefinition:{leave:({description:t,directives:e,operationTypes:n})=>me("",t,`
149
- `)+te(["schema",te(e," "),lt(n)]," ")},OperationTypeDefinition:{leave:({operation:t,type:e})=>t+": "+e},ScalarTypeDefinition:{leave:({description:t,name:e,directives:n})=>me("",t,`
150
- `)+te(["scalar",e,te(n," ")]," ")},ObjectTypeDefinition:{leave:({description:t,name:e,interfaces:n,directives:r,fields:i})=>me("",t,`
151
- `)+te(["type",e,me("implements ",te(n," & ")),te(r," "),lt(i)]," ")},FieldDefinition:{leave:({description:t,name:e,arguments:n,type:r,directives:i})=>me("",t,`
152
- `)+e+(Ha(n)?me(`(
153
- `,Hr(te(n,`
154
- `)),`
155
- )`):me("(",te(n,", "),")"))+": "+r+me(" ",te(i," "))},InputValueDefinition:{leave:({description:t,name:e,type:n,defaultValue:r,directives:i})=>me("",t,`
156
- `)+te([e+": "+n,me("= ",r),te(i," ")]," ")},InterfaceTypeDefinition:{leave:({description:t,name:e,interfaces:n,directives:r,fields:i})=>me("",t,`
157
- `)+te(["interface",e,me("implements ",te(n," & ")),te(r," "),lt(i)]," ")},UnionTypeDefinition:{leave:({description:t,name:e,directives:n,types:r})=>me("",t,`
158
- `)+te(["union",e,te(n," "),me("= ",te(r," | "))]," ")},EnumTypeDefinition:{leave:({description:t,name:e,directives:n,values:r})=>me("",t,`
159
- `)+te(["enum",e,te(n," "),lt(r)]," ")},EnumValueDefinition:{leave:({description:t,name:e,directives:n})=>me("",t,`
160
- `)+te([e,te(n," ")]," ")},InputObjectTypeDefinition:{leave:({description:t,name:e,directives:n,fields:r})=>me("",t,`
161
- `)+te(["input",e,te(n," "),lt(r)]," ")},DirectiveDefinition:{leave:({description:t,name:e,arguments:n,repeatable:r,locations:i})=>me("",t,`
162
- `)+"directive @"+e+(Ha(n)?me(`(
163
- `,Hr(te(n,`
164
- `)),`
165
- )`):me("(",te(n,", "),")"))+(r?" repeatable":"")+" on "+te(i," | ")},SchemaExtension:{leave:({directives:t,operationTypes:e})=>te(["extend schema",te(t," "),lt(e)]," ")},ScalarTypeExtension:{leave:({name:t,directives:e})=>te(["extend scalar",t,te(e," ")]," ")},ObjectTypeExtension:{leave:({name:t,interfaces:e,directives:n,fields:r})=>te(["extend type",t,me("implements ",te(e," & ")),te(n," "),lt(r)]," ")},InterfaceTypeExtension:{leave:({name:t,interfaces:e,directives:n,fields:r})=>te(["extend interface",t,me("implements ",te(e," & ")),te(n," "),lt(r)]," ")},UnionTypeExtension:{leave:({name:t,directives:e,types:n})=>te(["extend union",t,te(e," "),me("= ",te(n," | "))]," ")},EnumTypeExtension:{leave:({name:t,directives:e,values:n})=>te(["extend enum",t,te(e," "),lt(n)]," ")},InputObjectTypeExtension:{leave:({name:t,directives:e,fields:n})=>te(["extend input",t,te(e," "),lt(n)]," ")}};function te(t,e=""){var n;return(n=t==null?void 0:t.filter(r=>r).join(e))!==null&&n!==void 0?n:""}function lt(t){return me(`{
166
- `,Hr(te(t,`
167
- `)),`
168
- }`)}function me(t,e,n=""){return e!=null&&e!==""?t+e+n:""}function Hr(t){return me(" ",t.replace(/\n/g,`
169
- `))}function Ha(t){var e;return(e=t==null?void 0:t.some(n=>n.includes(`
170
- `)))!==null&&e!==void 0?e:!1}function Gs(t,e){switch(t.kind){case y.NULL:return null;case y.INT:return parseInt(t.value,10);case y.FLOAT:return parseFloat(t.value);case y.STRING:case y.ENUM:case y.BOOLEAN:return t.value;case y.LIST:return t.values.map(n=>Gs(n,e));case y.OBJECT:return Ao(t.fields,n=>n.name.value,n=>Gs(n.value,e));case y.VARIABLE:return e==null?void 0:e[t.name.value]}}function yt(t){if(t!=null||ve(!1,"Must provide name."),typeof t=="string"||ve(!1,"Expected name to be a string."),t.length===0)throw new z("Expected name to be a non-empty string.");for(let e=1;e<t.length;++e)if(!pl(t.charCodeAt(e)))throw new z(`Names must only contain [_a-zA-Z0-9] but "${t}" does not.`);if(!Oo(t.charCodeAt(0)))throw new z(`Names must start with [_a-zA-Z] but "${t}" does not.`);return t}function Vg(t){if(t==="true"||t==="false"||t==="null")throw new z(`Enum values cannot be named: ${t}`);return yt(t)}function Co(t){return qt(t)||Oe(t)||Re(t)||ot(t)||Qe(t)||Be(t)||Ve(t)||Se(t)}function qt(t){return gt(t,Lt)}function Oe(t){return gt(t,st)}function Re(t){return gt(t,zs)}function ot(t){return gt(t,Dn)}function Qe(t){return gt(t,lr)}function Be(t){return gt(t,Ys)}function Ve(t){return gt(t,ze)}function Se(t){return gt(t,ue)}function bt(t){return qt(t)||Qe(t)||Be(t)||Lo(t)&&bt(t.ofType)}function er(t){return qt(t)||Oe(t)||Re(t)||ot(t)||Qe(t)||Lo(t)&&er(t.ofType)}function Ln(t){return qt(t)||Qe(t)}function zt(t){return Oe(t)||Re(t)||ot(t)}function Bt(t){return Re(t)||ot(t)}function _S(t){if(!Bt(t))throw new Error(`Expected ${ee(t)} to be a GraphQL abstract type.`);return t}class ze{constructor(e){Co(e)||ve(!1,`Expected ${ee(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLList"}toString(){return"["+String(this.ofType)+"]"}toJSON(){return this.toString()}}class ue{constructor(e){bl(e)||ve(!1,`Expected ${ee(e)} to be a GraphQL nullable type.`),this.ofType=e}get[Symbol.toStringTag](){return"GraphQLNonNull"}toString(){return String(this.ofType)+"!"}toJSON(){return this.toString()}}function Lo(t){return Ve(t)||Se(t)}function bl(t){return Co(t)&&!Se(t)}function wl(t){if(t)return Se(t)?t.ofType:t}function Gg(t){return qt(t)||Oe(t)||Re(t)||ot(t)||Qe(t)||Be(t)}function pt(t){if(t){let e=t;for(;Lo(e);)e=e.ofType;return e}}function Sl(t){return typeof t=="function"?t():t}function Tl(t){return typeof t=="function"?t():t}class Lt{constructor(e){var n,r,i,s;const o=(n=e.parseValue)!==null&&n!==void 0?n:Ya;this.name=yt(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=(r=e.serialize)!==null&&r!==void 0?r:Ya,this.parseValue=o,this.parseLiteral=(i=e.parseLiteral)!==null&&i!==void 0?i:(a,c)=>o(Gs(a,c)),this.extensions=ct(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(s=e.extensionASTNodes)!==null&&s!==void 0?s:[],e.specifiedByURL==null||typeof e.specifiedByURL=="string"||ve(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${ee(e.specifiedByURL)}.`),e.serialize==null||typeof e.serialize=="function"||ve(!1,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),e.parseLiteral&&(typeof e.parseValue=="function"&&typeof e.parseLiteral=="function"||ve(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return"GraphQLScalarType"}toConfig(){return{name:this.name,description:this.description,specifiedByURL:this.specifiedByURL,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class st{constructor(e){var n;this.name=yt(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=ct(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=()=>Dl(e),this._interfaces=()=>Il(e),e.isTypeOf==null||typeof e.isTypeOf=="function"||ve(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${ee(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return"GraphQLObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:Ol(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function Il(t){var e;const n=Sl((e=t.interfaces)!==null&&e!==void 0?e:[]);return Array.isArray(n)||ve(!1,`${t.name} interfaces must be an Array or a function which returns an Array.`),n}function Dl(t){const e=Tl(t.fields);return In(e)||ve(!1,`${t.name} fields must be an object with field names as keys or a function which returns such an object.`),At(e,(n,r)=>{var i;In(n)||ve(!1,`${t.name}.${r} field config must be an object.`),n.resolve==null||typeof n.resolve=="function"||ve(!1,`${t.name}.${r} field resolver must be a function if provided, but got: ${ee(n.resolve)}.`);const s=(i=n.args)!==null&&i!==void 0?i:{};return In(s)||ve(!1,`${t.name}.${r} args must be an object with argument names as keys.`),{name:yt(r),description:n.description,type:n.type,args:Nl(s),resolve:n.resolve,subscribe:n.subscribe,deprecationReason:n.deprecationReason,extensions:ct(n.extensions),astNode:n.astNode}})}function Nl(t){return Object.entries(t).map(([e,n])=>({name:yt(e),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:ct(n.extensions),astNode:n.astNode}))}function In(t){return ln(t)&&!Array.isArray(t)}function Ol(t){return At(t,e=>({description:e.description,type:e.type,args:Al(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}))}function Al(t){return Ao(t,e=>e.name,e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}))}function wr(t){return Se(t.type)&&t.defaultValue===void 0}class zs{constructor(e){var n;this.name=yt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ct(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._fields=Dl.bind(void 0,e),this._interfaces=Il.bind(void 0,e),e.resolveType==null||typeof e.resolveType=="function"||ve(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLInterfaceType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces=="function"&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:Ol(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}class Dn{constructor(e){var n;this.name=yt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=ct(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._types=zg.bind(void 0,e),e.resolveType==null||typeof e.resolveType=="function"||ve(!1,`${this.name} must provide "resolveType" as a function, but got: ${ee(e.resolveType)}.`)}get[Symbol.toStringTag](){return"GraphQLUnionType"}getTypes(){return typeof this._types=="function"&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function zg(t){const e=Sl(t.types);return Array.isArray(e)||ve(!1,`Must provide Array of types or a function which returns such an array for Union ${t.name}.`),e}class lr{constructor(e){var n;this.name=yt(e.name),this.description=e.description,this.extensions=ct(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._values=typeof e.values=="function"?e.values:Ja(this.name,e.values),this._valueLookup=null,this._nameLookup=null}get[Symbol.toStringTag](){return"GraphQLEnumType"}getValues(){return typeof this._values=="function"&&(this._values=Ja(this.name,this._values())),this._values}getValue(e){return this._nameLookup===null&&(this._nameLookup=fn(this.getValues(),n=>n.name)),this._nameLookup[e]}serialize(e){this._valueLookup===null&&(this._valueLookup=new Map(this.getValues().map(r=>[r.value,r])));const n=this._valueLookup.get(e);if(n===void 0)throw new z(`Enum "${this.name}" cannot represent value: ${ee(e)}`);return n.name}parseValue(e){if(typeof e!="string"){const r=ee(e);throw new z(`Enum "${this.name}" cannot represent non-string value: ${r}.`+$r(this,r))}const n=this.getValue(e);if(n==null)throw new z(`Value "${e}" does not exist in "${this.name}" enum.`+$r(this,e));return n.value}parseLiteral(e,n){if(e.kind!==y.ENUM){const i=$e(e);throw new z(`Enum "${this.name}" cannot represent non-enum value: ${i}.`+$r(this,i),{nodes:e})}const r=this.getValue(e.value);if(r==null){const i=$e(e);throw new z(`Value "${i}" does not exist in "${this.name}" enum.`+$r(this,i),{nodes:e})}return r.value}toConfig(){const e=Ao(this.getValues(),n=>n.name,n=>({description:n.description,value:n.value,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}}function $r(t,e){const n=t.getValues().map(i=>i.name),r=vn(e,n);return Gt("the enum value",r)}function Ja(t,e){return In(e)||ve(!1,`${t} values must be an object with value names as keys.`),Object.entries(e).map(([n,r])=>(In(r)||ve(!1,`${t}.${n} must refer to an object with a "value" key representing an internal value but got: ${ee(r)}.`),{name:Vg(n),description:r.description,value:r.value!==void 0?r.value:n,deprecationReason:r.deprecationReason,extensions:ct(r.extensions),astNode:r.astNode}))}class Ys{constructor(e){var n,r;this.name=yt(e.name),this.description=e.description,this.extensions=ct(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this.isOneOf=(r=e.isOneOf)!==null&&r!==void 0?r:!1,this._fields=Yg.bind(void 0,e)}get[Symbol.toStringTag](){return"GraphQLInputObjectType"}getFields(){return typeof this._fields=="function"&&(this._fields=this._fields()),this._fields}toConfig(){const e=At(this.getFields(),n=>({description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:n.extensions,astNode:n.astNode}));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,isOneOf:this.isOneOf}}toString(){return this.name}toJSON(){return this.toString()}}function Yg(t){const e=Tl(t.fields);return In(e)||ve(!1,`${t.name} fields must be an object with field names as keys or a function which returns such an object.`),At(e,(n,r)=>(!("resolve"in n)||ve(!1,`${t.name}.${r} field has a resolve property, but Input Types cannot define resolvers.`),{name:yt(r),description:n.description,type:n.type,defaultValue:n.defaultValue,deprecationReason:n.deprecationReason,extensions:ct(n.extensions),astNode:n.astNode}))}function Rl(t){return Se(t.type)&&t.defaultValue===void 0}function qs(t,e){return t===e?!0:Se(t)&&Se(e)||Ve(t)&&Ve(e)?qs(t.ofType,e.ofType):!1}function Nn(t,e,n){return e===n?!0:Se(n)?Se(e)?Nn(t,e.ofType,n.ofType):!1:Se(e)?Nn(t,e.ofType,n):Ve(n)?Ve(e)?Nn(t,e.ofType,n.ofType):!1:Ve(e)?!1:Bt(n)&&(Re(e)||Oe(e))&&t.isSubType(n,e)}function Wa(t,e,n){return e===n?!0:Bt(e)?Bt(n)?t.getPossibleTypes(e).some(r=>t.isSubType(n,r)):t.isSubType(e,n):Bt(n)?t.isSubType(n,e):!1}const fs=2147483647,ps=-2147483648,qg=new Lt({name:"Int",description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize(t){const e=Sr(t);if(typeof e=="boolean")return e?1:0;let n=e;if(typeof e=="string"&&e!==""&&(n=Number(e)),typeof n!="number"||!Number.isInteger(n))throw new z(`Int cannot represent non-integer value: ${ee(e)}`);if(n>fs||n<ps)throw new z("Int cannot represent non 32-bit signed integer value: "+ee(e));return n},parseValue(t){if(typeof t!="number"||!Number.isInteger(t))throw new z(`Int cannot represent non-integer value: ${ee(t)}`);if(t>fs||t<ps)throw new z(`Int cannot represent non 32-bit signed integer value: ${t}`);return t},parseLiteral(t){if(t.kind!==y.INT)throw new z(`Int cannot represent non-integer value: ${$e(t)}`,{nodes:t});const e=parseInt(t.value,10);if(e>fs||e<ps)throw new z(`Int cannot represent non 32-bit signed integer value: ${t.value}`,{nodes:t});return e}}),Hg=new Lt({name:"Float",description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize(t){const e=Sr(t);if(typeof e=="boolean")return e?1:0;let n=e;if(typeof e=="string"&&e!==""&&(n=Number(e)),typeof n!="number"||!Number.isFinite(n))throw new z(`Float cannot represent non numeric value: ${ee(e)}`);return n},parseValue(t){if(typeof t!="number"||!Number.isFinite(t))throw new z(`Float cannot represent non numeric value: ${ee(t)}`);return t},parseLiteral(t){if(t.kind!==y.FLOAT&&t.kind!==y.INT)throw new z(`Float cannot represent non numeric value: ${$e(t)}`,t);return parseFloat(t.value)}}),Le=new Lt({name:"String",description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize(t){const e=Sr(t);if(typeof e=="string")return e;if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number"&&Number.isFinite(e))return e.toString();throw new z(`String cannot represent value: ${ee(t)}`)},parseValue(t){if(typeof t!="string")throw new z(`String cannot represent a non string value: ${ee(t)}`);return t},parseLiteral(t){if(t.kind!==y.STRING)throw new z(`String cannot represent a non string value: ${$e(t)}`,{nodes:t});return t.value}}),Ke=new Lt({name:"Boolean",description:"The `Boolean` scalar type represents `true` or `false`.",serialize(t){const e=Sr(t);if(typeof e=="boolean")return e;if(Number.isFinite(e))return e!==0;throw new z(`Boolean cannot represent a non boolean value: ${ee(e)}`)},parseValue(t){if(typeof t!="boolean")throw new z(`Boolean cannot represent a non boolean value: ${ee(t)}`);return t},parseLiteral(t){if(t.kind!==y.BOOLEAN)throw new z(`Boolean cannot represent a non boolean value: ${$e(t)}`,{nodes:t});return t.value}}),Cl=new Lt({name:"ID",description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize(t){const e=Sr(t);if(typeof e=="string")return e;if(Number.isInteger(e))return String(e);throw new z(`ID cannot represent value: ${ee(t)}`)},parseValue(t){if(typeof t=="string")return t;if(typeof t=="number"&&Number.isInteger(t))return t.toString();throw new z(`ID cannot represent value: ${ee(t)}`)},parseLiteral(t){if(t.kind!==y.STRING&&t.kind!==y.INT)throw new z("ID cannot represent a non-string and non-integer value: "+$e(t),{nodes:t});return t.value}}),xo=Object.freeze([Le,qg,Hg,Ke,Cl]);function Jg(t){return xo.some(({name:e})=>t.name===e)}function Sr(t){if(ln(t)){if(typeof t.valueOf=="function"){const e=t.valueOf();if(!ln(e))return e}if(typeof t.toJSON=="function")return t.toJSON()}return t}function Ll(t){return gt(t,Yt)}class Yt{constructor(e){var n,r;this.name=yt(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=(n=e.isRepeatable)!==null&&n!==void 0?n:!1,this.extensions=ct(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||ve(!1,`@${e.name} locations must be an Array.`);const i=(r=e.args)!==null&&r!==void 0?r:{};ln(i)&&!Array.isArray(i)||ve(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Nl(i)}get[Symbol.toStringTag](){return"GraphQLDirective"}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:Al(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return"@"+this.name}toJSON(){return this.toString()}}const xl=new Yt({name:"include",description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[se.FIELD,se.FRAGMENT_SPREAD,se.INLINE_FRAGMENT],args:{if:{type:new ue(Ke),description:"Included when true."}}}),Ml=new Yt({name:"skip",description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[se.FIELD,se.FRAGMENT_SPREAD,se.INLINE_FRAGMENT],args:{if:{type:new ue(Ke),description:"Skipped when true."}}}),Wg="No longer supported",Mo=new Yt({name:"deprecated",description:"Marks an element of a GraphQL schema as no longer supported.",locations:[se.FIELD_DEFINITION,se.ARGUMENT_DEFINITION,se.INPUT_FIELD_DEFINITION,se.ENUM_VALUE],args:{reason:{type:Le,description:"Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).",defaultValue:Wg}}}),Pl=new Yt({name:"specifiedBy",description:"Exposes a URL that specifies the behavior of this scalar.",locations:[se.SCALAR],args:{url:{type:new ue(Le),description:"The URL that specifies the behavior of this scalar."}}}),kl=new Yt({name:"oneOf",description:"Indicates exactly one field must be supplied and this field must not be `null`.",locations:[se.INPUT_OBJECT],args:{}}),En=Object.freeze([xl,Ml,Mo,Pl,kl]);function bS(t){return En.some(({name:e})=>e===t.name)}function Kg(t){return typeof t=="object"&&typeof(t==null?void 0:t[Symbol.iterator])=="function"}function Wn(t,e){if(Se(e)){const n=Wn(t,e.ofType);return(n==null?void 0:n.kind)===y.NULL?null:n}if(t===null)return{kind:y.NULL};if(t===void 0)return null;if(Ve(e)){const n=e.ofType;if(Kg(t)){const r=[];for(const i of t){const s=Wn(i,n);s!=null&&r.push(s)}return{kind:y.LIST,values:r}}return Wn(t,n)}if(Be(e)){if(!ln(t))return null;const n=[];for(const r of Object.values(e.getFields())){const i=Wn(t[r.name],r.type);i&&n.push({kind:y.OBJECT_FIELD,name:{kind:y.NAME,value:r.name},value:i})}return{kind:y.OBJECT,fields:n}}if(Ln(e)){const n=e.serialize(t);if(n==null)return null;if(typeof n=="boolean")return{kind:y.BOOLEAN,value:n};if(typeof n=="number"&&Number.isFinite(n)){const r=String(n);return Ka.test(r)?{kind:y.INT,value:r}:{kind:y.FLOAT,value:r}}if(typeof n=="string")return Qe(e)?{kind:y.ENUM,value:n}:e===Cl&&Ka.test(n)?{kind:y.INT,value:n}:{kind:y.STRING,value:n};throw new TypeError(`Cannot convert value to AST: ${ee(n)}.`)}mt(!1,"Unexpected input type: "+ee(e))}const Ka=/^-?(?:0|[1-9][0-9]*)$/,Po=new st({name:"__Schema",description:"A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",fields:()=>({description:{type:Le,resolve:t=>t.description},types:{description:"A list of all types supported by this server.",type:new ue(new ze(new ue(ht))),resolve(t){return Object.values(t.getTypeMap())}},queryType:{description:"The type that query operations will be rooted at.",type:new ue(ht),resolve:t=>t.getQueryType()},mutationType:{description:"If this server supports mutation, the type that mutation operations will be rooted at.",type:ht,resolve:t=>t.getMutationType()},subscriptionType:{description:"If this server support subscription, the type that subscription operations will be rooted at.",type:ht,resolve:t=>t.getSubscriptionType()},directives:{description:"A list of all directives supported by this server.",type:new ue(new ze(new ue($l))),resolve:t=>t.getDirectives()}})}),$l=new st({name:"__Directive",description:`A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
171
-
172
- In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.`,fields:()=>({name:{type:new ue(Le),resolve:t=>t.name},description:{type:Le,resolve:t=>t.description},isRepeatable:{type:new ue(Ke),resolve:t=>t.isRepeatable},locations:{type:new ue(new ze(new ue(Ul))),resolve:t=>t.locations},args:{type:new ue(new ze(new ue(Pi))),args:{includeDeprecated:{type:Ke,defaultValue:!1}},resolve(t,{includeDeprecated:e}){return e?t.args:t.args.filter(n=>n.deprecationReason==null)}}})}),Ul=new lr({name:"__DirectiveLocation",description:"A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",values:{QUERY:{value:se.QUERY,description:"Location adjacent to a query operation."},MUTATION:{value:se.MUTATION,description:"Location adjacent to a mutation operation."},SUBSCRIPTION:{value:se.SUBSCRIPTION,description:"Location adjacent to a subscription operation."},FIELD:{value:se.FIELD,description:"Location adjacent to a field."},FRAGMENT_DEFINITION:{value:se.FRAGMENT_DEFINITION,description:"Location adjacent to a fragment definition."},FRAGMENT_SPREAD:{value:se.FRAGMENT_SPREAD,description:"Location adjacent to a fragment spread."},INLINE_FRAGMENT:{value:se.INLINE_FRAGMENT,description:"Location adjacent to an inline fragment."},VARIABLE_DEFINITION:{value:se.VARIABLE_DEFINITION,description:"Location adjacent to a variable definition."},SCHEMA:{value:se.SCHEMA,description:"Location adjacent to a schema definition."},SCALAR:{value:se.SCALAR,description:"Location adjacent to a scalar definition."},OBJECT:{value:se.OBJECT,description:"Location adjacent to an object type definition."},FIELD_DEFINITION:{value:se.FIELD_DEFINITION,description:"Location adjacent to a field definition."},ARGUMENT_DEFINITION:{value:se.ARGUMENT_DEFINITION,description:"Location adjacent to an argument definition."},INTERFACE:{value:se.INTERFACE,description:"Location adjacent to an interface definition."},UNION:{value:se.UNION,description:"Location adjacent to a union definition."},ENUM:{value:se.ENUM,description:"Location adjacent to an enum definition."},ENUM_VALUE:{value:se.ENUM_VALUE,description:"Location adjacent to an enum value definition."},INPUT_OBJECT:{value:se.INPUT_OBJECT,description:"Location adjacent to an input object type definition."},INPUT_FIELD_DEFINITION:{value:se.INPUT_FIELD_DEFINITION,description:"Location adjacent to an input object field definition."}}}),ht=new st({name:"__Type",description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new ue(jl),resolve(t){if(qt(t))return Ue.SCALAR;if(Oe(t))return Ue.OBJECT;if(Re(t))return Ue.INTERFACE;if(ot(t))return Ue.UNION;if(Qe(t))return Ue.ENUM;if(Be(t))return Ue.INPUT_OBJECT;if(Ve(t))return Ue.LIST;if(Se(t))return Ue.NON_NULL;mt(!1,`Unexpected type: "${ee(t)}".`)}},name:{type:Le,resolve:t=>"name"in t?t.name:void 0},description:{type:Le,resolve:t=>"description"in t?t.description:void 0},specifiedByURL:{type:Le,resolve:t=>"specifiedByURL"in t?t.specifiedByURL:void 0},fields:{type:new ze(new ue(Fl)),args:{includeDeprecated:{type:Ke,defaultValue:!1}},resolve(t,{includeDeprecated:e}){if(Oe(t)||Re(t)){const n=Object.values(t.getFields());return e?n:n.filter(r=>r.deprecationReason==null)}}},interfaces:{type:new ze(new ue(ht)),resolve(t){if(Oe(t)||Re(t))return t.getInterfaces()}},possibleTypes:{type:new ze(new ue(ht)),resolve(t,e,n,{schema:r}){if(Bt(t))return r.getPossibleTypes(t)}},enumValues:{type:new ze(new ue(Bl)),args:{includeDeprecated:{type:Ke,defaultValue:!1}},resolve(t,{includeDeprecated:e}){if(Qe(t)){const n=t.getValues();return e?n:n.filter(r=>r.deprecationReason==null)}}},inputFields:{type:new ze(new ue(Pi)),args:{includeDeprecated:{type:Ke,defaultValue:!1}},resolve(t,{includeDeprecated:e}){if(Be(t)){const n=Object.values(t.getFields());return e?n:n.filter(r=>r.deprecationReason==null)}}},ofType:{type:ht,resolve:t=>"ofType"in t?t.ofType:void 0},isOneOf:{type:Ke,resolve:t=>{if(Be(t))return t.isOneOf}}})}),Fl=new st({name:"__Field",description:"Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",fields:()=>({name:{type:new ue(Le),resolve:t=>t.name},description:{type:Le,resolve:t=>t.description},args:{type:new ue(new ze(new ue(Pi))),args:{includeDeprecated:{type:Ke,defaultValue:!1}},resolve(t,{includeDeprecated:e}){return e?t.args:t.args.filter(n=>n.deprecationReason==null)}},type:{type:new ue(ht),resolve:t=>t.type},isDeprecated:{type:new ue(Ke),resolve:t=>t.deprecationReason!=null},deprecationReason:{type:Le,resolve:t=>t.deprecationReason}})}),Pi=new st({name:"__InputValue",description:"Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",fields:()=>({name:{type:new ue(Le),resolve:t=>t.name},description:{type:Le,resolve:t=>t.description},type:{type:new ue(ht),resolve:t=>t.type},defaultValue:{type:Le,description:"A GraphQL-formatted string representing the default value for this input value.",resolve(t){const{type:e,defaultValue:n}=t,r=Wn(n,e);return r?$e(r):null}},isDeprecated:{type:new ue(Ke),resolve:t=>t.deprecationReason!=null},deprecationReason:{type:Le,resolve:t=>t.deprecationReason}})}),Bl=new st({name:"__EnumValue",description:"One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",fields:()=>({name:{type:new ue(Le),resolve:t=>t.name},description:{type:Le,resolve:t=>t.description},isDeprecated:{type:new ue(Ke),resolve:t=>t.deprecationReason!=null},deprecationReason:{type:Le,resolve:t=>t.deprecationReason}})});var Ue;(function(t){t.SCALAR="SCALAR",t.OBJECT="OBJECT",t.INTERFACE="INTERFACE",t.UNION="UNION",t.ENUM="ENUM",t.INPUT_OBJECT="INPUT_OBJECT",t.LIST="LIST",t.NON_NULL="NON_NULL"})(Ue||(Ue={}));const jl=new lr({name:"__TypeKind",description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:Ue.SCALAR,description:"Indicates this type is a scalar."},OBJECT:{value:Ue.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:Ue.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:Ue.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:Ue.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:Ue.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:Ue.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:Ue.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Qa={name:"__schema",type:new ue(Po),description:"Access the current type schema of this server.",args:[],resolve:(t,e,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Xa={name:"__type",type:ht,description:"Request the type information of a single type.",args:[{name:"name",description:void 0,type:new ue(Le),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(t,{name:e},n,{schema:r})=>r.getType(e),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Za={name:"__typename",type:new ue(Le),description:"The name of the current Object type at runtime.",args:[],resolve:(t,e,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},ko=Object.freeze([Po,$l,Ul,ht,Fl,Pi,Bl,jl]);function Vl(t){return ko.some(({name:e})=>t.name===e)}function Qg(t){return gt(t,Gl)}function Xg(t){if(!Qg(t))throw new Error(`Expected ${ee(t)} to be a GraphQL schema.`);return t}class Gl{constructor(e){var n,r;this.__validationErrors=e.assumeValid===!0?[]:void 0,ln(e)||ve(!1,"Must provide configuration object."),!e.types||Array.isArray(e.types)||ve(!1,`"types" must be Array if provided but got: ${ee(e.types)}.`),!e.directives||Array.isArray(e.directives)||ve(!1,`"directives" must be Array if provided but got: ${ee(e.directives)}.`),this.description=e.description,this.extensions=ct(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=(n=e.extensionASTNodes)!==null&&n!==void 0?n:[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=(r=e.directives)!==null&&r!==void 0?r:En;const i=new Set(e.types);if(e.types!=null)for(const s of e.types)i.delete(s),ft(s,i);this._queryType!=null&&ft(this._queryType,i),this._mutationType!=null&&ft(this._mutationType,i),this._subscriptionType!=null&&ft(this._subscriptionType,i);for(const s of this._directives)if(Ll(s))for(const o of s.args)ft(o.type,i);ft(Po,i),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(const s of i){if(s==null)continue;const o=s.name;if(o||ve(!1,"One of the provided types for building the Schema is missing a name."),this._typeMap[o]!==void 0)throw new Error(`Schema must contain uniquely named types but contains multiple types named "${o}".`);if(this._typeMap[o]=s,Re(s)){for(const a of s.getInterfaces())if(Re(a)){let c=this._implementationsMap[a.name];c===void 0&&(c=this._implementationsMap[a.name]={objects:[],interfaces:[]}),c.interfaces.push(s)}}else if(Oe(s)){for(const a of s.getInterfaces())if(Re(a)){let c=this._implementationsMap[a.name];c===void 0&&(c=this._implementationsMap[a.name]={objects:[],interfaces:[]}),c.objects.push(s)}}}}get[Symbol.toStringTag](){return"GraphQLSchema"}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case Ye.QUERY:return this.getQueryType();case Ye.MUTATION:return this.getMutationType();case Ye.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return ot(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){const n=this._implementationsMap[e.name];return n??{objects:[],interfaces:[]}}isSubType(e,n){let r=this._subTypeMap[e.name];if(r===void 0){if(r=Object.create(null),ot(e))for(const i of e.getTypes())r[i.name]=!0;else{const i=this.getImplementations(e);for(const s of i.objects)r[s.name]=!0;for(const s of i.interfaces)r[s.name]=!0}this._subTypeMap[e.name]=r}return r[n.name]!==void 0}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find(n=>n.name===e)}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:this.__validationErrors!==void 0}}}function ft(t,e){const n=pt(t);if(!e.has(n)){if(e.add(n),ot(n))for(const r of n.getTypes())ft(r,e);else if(Oe(n)||Re(n)){for(const r of n.getInterfaces())ft(r,e);for(const r of Object.values(n.getFields())){ft(r.type,e);for(const i of r.args)ft(i.type,e)}}else if(Be(n))for(const r of Object.values(n.getFields()))ft(r.type,e)}return e}function Zg(t){if(Xg(t),t.__validationErrors)return t.__validationErrors;const e=new ty(t);ny(e),ry(e),iy(e);const n=e.getErrors();return t.__validationErrors=n,n}function ey(t){const e=Zg(t);if(e.length!==0)throw new Error(e.map(n=>n.message).join(`
173
-
174
- `))}class ty{constructor(e){this._errors=[],this.schema=e}reportError(e,n){const r=Array.isArray(n)?n.filter(Boolean):n;this._errors.push(new z(e,{nodes:r}))}getErrors(){return this._errors}}function ny(t){const e=t.schema,n=e.getQueryType();if(!n)t.reportError("Query root type must be provided.",e.astNode);else if(!Oe(n)){var r;t.reportError(`Query root type must be Object type, it cannot be ${ee(n)}.`,(r=hs(e,Ye.QUERY))!==null&&r!==void 0?r:n.astNode)}const i=e.getMutationType();if(i&&!Oe(i)){var s;t.reportError(`Mutation root type must be Object type if provided, it cannot be ${ee(i)}.`,(s=hs(e,Ye.MUTATION))!==null&&s!==void 0?s:i.astNode)}const o=e.getSubscriptionType();if(o&&!Oe(o)){var a;t.reportError(`Subscription root type must be Object type if provided, it cannot be ${ee(o)}.`,(a=hs(e,Ye.SUBSCRIPTION))!==null&&a!==void 0?a:o.astNode)}}function hs(t,e){var n;return(n=[t.astNode,...t.extensionASTNodes].flatMap(r=>{var i;return(i=r==null?void 0:r.operationTypes)!==null&&i!==void 0?i:[]}).find(r=>r.operation===e))===null||n===void 0?void 0:n.type}function ry(t){for(const n of t.schema.getDirectives()){if(!Ll(n)){t.reportError(`Expected directive but got: ${ee(n)}.`,n==null?void 0:n.astNode);continue}pn(t,n),n.locations.length===0&&t.reportError(`Directive @${n.name} must include 1 or more locations.`,n.astNode);for(const r of n.args)if(pn(t,r),bt(r.type)||t.reportError(`The type of @${n.name}(${r.name}:) must be Input Type but got: ${ee(r.type)}.`,r.astNode),wr(r)&&r.deprecationReason!=null){var e;t.reportError(`Required argument @${n.name}(${r.name}:) cannot be deprecated.`,[$o(r.astNode),(e=r.astNode)===null||e===void 0?void 0:e.type])}}}function pn(t,e){e.name.startsWith("__")&&t.reportError(`Name "${e.name}" must not begin with "__", which is reserved by GraphQL introspection.`,e.astNode)}function iy(t){const e=dy(t),n=t.schema.getTypeMap();for(const r of Object.values(n)){if(!Gg(r)){t.reportError(`Expected GraphQL named type but got: ${ee(r)}.`,r.astNode);continue}Vl(r)||pn(t,r),Oe(r)||Re(r)?(ec(t,r),tc(t,r)):ot(r)?ay(t,r):Qe(r)?cy(t,r):Be(r)&&(uy(t,r),e(r))}}function ec(t,e){const n=Object.values(e.getFields());n.length===0&&t.reportError(`Type ${e.name} must define one or more fields.`,[e.astNode,...e.extensionASTNodes]);for(const o of n){if(pn(t,o),!er(o.type)){var r;t.reportError(`The type of ${e.name}.${o.name} must be Output Type but got: ${ee(o.type)}.`,(r=o.astNode)===null||r===void 0?void 0:r.type)}for(const a of o.args){const c=a.name;if(pn(t,a),!bt(a.type)){var i;t.reportError(`The type of ${e.name}.${o.name}(${c}:) must be Input Type but got: ${ee(a.type)}.`,(i=a.astNode)===null||i===void 0?void 0:i.type)}if(wr(a)&&a.deprecationReason!=null){var s;t.reportError(`Required argument ${e.name}.${o.name}(${c}:) cannot be deprecated.`,[$o(a.astNode),(s=a.astNode)===null||s===void 0?void 0:s.type])}}}}function tc(t,e){const n=Object.create(null);for(const r of e.getInterfaces()){if(!Re(r)){t.reportError(`Type ${ee(e)} must only implement Interface types, it cannot implement ${ee(r)}.`,tr(e,r));continue}if(e===r){t.reportError(`Type ${e.name} cannot implement itself because it would create a circular reference.`,tr(e,r));continue}if(n[r.name]){t.reportError(`Type ${e.name} can only implement ${r.name} once.`,tr(e,r));continue}n[r.name]=!0,oy(t,e,r),sy(t,e,r)}}function sy(t,e,n){const r=e.getFields();for(const c of Object.values(n.getFields())){const u=c.name,d=r[u];if(!d){t.reportError(`Interface field ${n.name}.${u} expected but ${e.name} does not provide it.`,[c.astNode,e.astNode,...e.extensionASTNodes]);continue}if(!Nn(t.schema,d.type,c.type)){var i,s;t.reportError(`Interface field ${n.name}.${u} expects type ${ee(c.type)} but ${e.name}.${u} is type ${ee(d.type)}.`,[(i=c.astNode)===null||i===void 0?void 0:i.type,(s=d.astNode)===null||s===void 0?void 0:s.type])}for(const l of c.args){const f=l.name,h=d.args.find(g=>g.name===f);if(!h){t.reportError(`Interface field argument ${n.name}.${u}(${f}:) expected but ${e.name}.${u} does not provide it.`,[l.astNode,d.astNode]);continue}if(!qs(l.type,h.type)){var o,a;t.reportError(`Interface field argument ${n.name}.${u}(${f}:) expects type ${ee(l.type)} but ${e.name}.${u}(${f}:) is type ${ee(h.type)}.`,[(o=l.astNode)===null||o===void 0?void 0:o.type,(a=h.astNode)===null||a===void 0?void 0:a.type])}}for(const l of d.args){const f=l.name;!c.args.find(g=>g.name===f)&&wr(l)&&t.reportError(`Object field ${e.name}.${u} includes required argument ${f} that is missing from the Interface field ${n.name}.${u}.`,[l.astNode,c.astNode])}}}function oy(t,e,n){const r=e.getInterfaces();for(const i of n.getInterfaces())r.includes(i)||t.reportError(i===e?`Type ${e.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${e.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...tr(n,i),...tr(e,n)])}function ay(t,e){const n=e.getTypes();n.length===0&&t.reportError(`Union type ${e.name} must define one or more member types.`,[e.astNode,...e.extensionASTNodes]);const r=Object.create(null);for(const i of n){if(r[i.name]){t.reportError(`Union type ${e.name} can only include type ${i.name} once.`,nc(e,i.name));continue}r[i.name]=!0,Oe(i)||t.reportError(`Union type ${e.name} can only include Object types, it cannot include ${ee(i)}.`,nc(e,String(i)))}}function cy(t,e){const n=e.getValues();n.length===0&&t.reportError(`Enum type ${e.name} must define one or more values.`,[e.astNode,...e.extensionASTNodes]);for(const r of n)pn(t,r)}function uy(t,e){const n=Object.values(e.getFields());n.length===0&&t.reportError(`Input Object type ${e.name} must define one or more fields.`,[e.astNode,...e.extensionASTNodes]);for(const s of n){if(pn(t,s),!bt(s.type)){var r;t.reportError(`The type of ${e.name}.${s.name} must be Input Type but got: ${ee(s.type)}.`,(r=s.astNode)===null||r===void 0?void 0:r.type)}if(Rl(s)&&s.deprecationReason!=null){var i;t.reportError(`Required input field ${e.name}.${s.name} cannot be deprecated.`,[$o(s.astNode),(i=s.astNode)===null||i===void 0?void 0:i.type])}e.isOneOf&&ly(e,s,t)}}function ly(t,e,n){if(Se(e.type)){var r;n.reportError(`OneOf input field ${t.name}.${e.name} must be nullable.`,(r=e.astNode)===null||r===void 0?void 0:r.type)}e.defaultValue!==void 0&&n.reportError(`OneOf input field ${t.name}.${e.name} cannot have a default value.`,e.astNode)}function dy(t){const e=Object.create(null),n=[],r=Object.create(null);return i;function i(s){if(e[s.name])return;e[s.name]=!0,r[s.name]=n.length;const o=Object.values(s.getFields());for(const a of o)if(Se(a.type)&&Be(a.type.ofType)){const c=a.type.ofType,u=r[c.name];if(n.push(a),u===void 0)i(c);else{const d=n.slice(u),l=d.map(f=>f.name).join(".");t.reportError(`Cannot reference Input Object "${c.name}" within itself through a series of non-null fields: "${l}".`,d.map(f=>f.astNode))}n.pop()}r[s.name]=void 0}}function tr(t,e){const{astNode:n,extensionASTNodes:r}=t;return(n!=null?[n,...r]:r).flatMap(s=>{var o;return(o=s.interfaces)!==null&&o!==void 0?o:[]}).filter(s=>s.name.value===e.name)}function nc(t,e){const{astNode:n,extensionASTNodes:r}=t;return(n!=null?[n,...r]:r).flatMap(s=>{var o;return(o=s.types)!==null&&o!==void 0?o:[]}).filter(s=>s.name.value===e)}function $o(t){var e;return t==null||(e=t.directives)===null||e===void 0?void 0:e.find(n=>n.name.value===Mo.name)}function at(t,e){switch(e.kind){case y.LIST_TYPE:{const n=at(t,e.type);return n&&new ze(n)}case y.NON_NULL_TYPE:{const n=at(t,e.type);return n&&new ue(n)}case y.NAMED_TYPE:return t.getType(e.name.value)}}class zl{constructor(e,n,r){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=r??fy,n&&(bt(n)&&this._inputTypeStack.push(n),zt(n)&&this._parentTypeStack.push(n),er(n)&&this._typeStack.push(n))}get[Symbol.toStringTag](){return"TypeInfo"}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(e){const n=this._schema;switch(e.kind){case y.SELECTION_SET:{const i=pt(this.getType());this._parentTypeStack.push(zt(i)?i:void 0);break}case y.FIELD:{const i=this.getParentType();let s,o;i&&(s=this._getFieldDef(n,i,e),s&&(o=s.type)),this._fieldDefStack.push(s),this._typeStack.push(er(o)?o:void 0);break}case y.DIRECTIVE:this._directive=n.getDirective(e.name.value);break;case y.OPERATION_DEFINITION:{const i=n.getRootType(e.operation);this._typeStack.push(Oe(i)?i:void 0);break}case y.INLINE_FRAGMENT:case y.FRAGMENT_DEFINITION:{const i=e.typeCondition,s=i?at(n,i):pt(this.getType());this._typeStack.push(er(s)?s:void 0);break}case y.VARIABLE_DEFINITION:{const i=at(n,e.type);this._inputTypeStack.push(bt(i)?i:void 0);break}case y.ARGUMENT:{var r;let i,s;const o=(r=this.getDirective())!==null&&r!==void 0?r:this.getFieldDef();o&&(i=o.args.find(a=>a.name===e.name.value),i&&(s=i.type)),this._argument=i,this._defaultValueStack.push(i?i.defaultValue:void 0),this._inputTypeStack.push(bt(s)?s:void 0);break}case y.LIST:{const i=wl(this.getInputType()),s=Ve(i)?i.ofType:i;this._defaultValueStack.push(void 0),this._inputTypeStack.push(bt(s)?s:void 0);break}case y.OBJECT_FIELD:{const i=pt(this.getInputType());let s,o;Be(i)&&(o=i.getFields()[e.name.value],o&&(s=o.type)),this._defaultValueStack.push(o?o.defaultValue:void 0),this._inputTypeStack.push(bt(s)?s:void 0);break}case y.ENUM:{const i=pt(this.getInputType());let s;Qe(i)&&(s=i.getValue(e.value)),this._enumValue=s;break}}}leave(e){switch(e.kind){case y.SELECTION_SET:this._parentTypeStack.pop();break;case y.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case y.DIRECTIVE:this._directive=null;break;case y.OPERATION_DEFINITION:case y.INLINE_FRAGMENT:case y.FRAGMENT_DEFINITION:this._typeStack.pop();break;case y.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case y.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case y.LIST:case y.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case y.ENUM:this._enumValue=null;break}}}function fy(t,e,n){const r=n.name.value;if(r===Qa.name&&t.getQueryType()===e)return Qa;if(r===Xa.name&&t.getQueryType()===e)return Xa;if(r===Za.name&&zt(e))return Za;if(Oe(e)||Re(e))return e.getFields()[r]}function Yl(t,e){return{enter(...n){const r=n[0];t.enter(r);const i=fi(e,r.kind).enter;if(i){const s=i.apply(e,n);return s!==void 0&&(t.leave(r),Bs(s)&&t.enter(s)),s}},leave(...n){const r=n[0],i=fi(e,r.kind).leave;let s;return i&&(s=i.apply(e,n)),t.leave(r),s}}}function py(t){return t.kind===y.OPERATION_DEFINITION||t.kind===y.FRAGMENT_DEFINITION}function hy(t){return t.kind===y.SCHEMA_DEFINITION||Tr(t)||t.kind===y.DIRECTIVE_DEFINITION}function Tr(t){return t.kind===y.SCALAR_TYPE_DEFINITION||t.kind===y.OBJECT_TYPE_DEFINITION||t.kind===y.INTERFACE_TYPE_DEFINITION||t.kind===y.UNION_TYPE_DEFINITION||t.kind===y.ENUM_TYPE_DEFINITION||t.kind===y.INPUT_OBJECT_TYPE_DEFINITION}function my(t){return t.kind===y.SCHEMA_EXTENSION||Uo(t)}function Uo(t){return t.kind===y.SCALAR_TYPE_EXTENSION||t.kind===y.OBJECT_TYPE_EXTENSION||t.kind===y.INTERFACE_TYPE_EXTENSION||t.kind===y.UNION_TYPE_EXTENSION||t.kind===y.ENUM_TYPE_EXTENSION||t.kind===y.INPUT_OBJECT_TYPE_EXTENSION}function gy(t){return{Document(e){for(const n of e.definitions)if(!py(n)){const r=n.kind===y.SCHEMA_DEFINITION||n.kind===y.SCHEMA_EXTENSION?"schema":'"'+n.name.value+'"';t.reportError(new z(`The ${r} definition is not executable.`,{nodes:n}))}return!1}}}function yy(t){return{Field(e){const n=t.getParentType();if(n&&!t.getFieldDef()){const i=t.getSchema(),s=e.name.value;let o=Gt("to use an inline fragment on",vy(i,n,s));o===""&&(o=Gt(Ey(n,s))),t.reportError(new z(`Cannot query field "${s}" on type "${n.name}".`+o,{nodes:e}))}}}}function vy(t,e,n){if(!Bt(e))return[];const r=new Set,i=Object.create(null);for(const o of t.getPossibleTypes(e))if(o.getFields()[n]){r.add(o),i[o.name]=1;for(const a of o.getInterfaces()){var s;a.getFields()[n]&&(r.add(a),i[a.name]=((s=i[a.name])!==null&&s!==void 0?s:0)+1)}}return[...r].sort((o,a)=>{const c=i[a.name]-i[o.name];return c!==0?c:Re(o)&&t.isSubType(o,a)?-1:Re(a)&&t.isSubType(a,o)?1:Ro(o.name,a.name)}).map(o=>o.name)}function Ey(t,e){if(Oe(t)||Re(t)){const n=Object.keys(t.getFields());return vn(e,n)}return[]}function _y(t){return{InlineFragment(e){const n=e.typeCondition;if(n){const r=at(t.getSchema(),n);if(r&&!zt(r)){const i=$e(n);t.reportError(new z(`Fragment cannot condition on non composite type "${i}".`,{nodes:n}))}}},FragmentDefinition(e){const n=at(t.getSchema(),e.typeCondition);if(n&&!zt(n)){const r=$e(e.typeCondition);t.reportError(new z(`Fragment "${e.name.value}" cannot condition on non composite type "${r}".`,{nodes:e.typeCondition}))}}}}function by(t){return{...ql(t),Argument(e){const n=t.getArgument(),r=t.getFieldDef(),i=t.getParentType();if(!n&&r&&i){const s=e.name.value,o=r.args.map(c=>c.name),a=vn(s,o);t.reportError(new z(`Unknown argument "${s}" on field "${i.name}.${r.name}".`+Gt(a),{nodes:e}))}}}}function ql(t){const e=Object.create(null),n=t.getSchema(),r=n?n.getDirectives():En;for(const o of r)e[o.name]=o.args.map(a=>a.name);const i=t.getDocument().definitions;for(const o of i)if(o.kind===y.DIRECTIVE_DEFINITION){var s;const a=(s=o.arguments)!==null&&s!==void 0?s:[];e[o.name.value]=a.map(c=>c.name.value)}return{Directive(o){const a=o.name.value,c=e[a];if(o.arguments&&c)for(const u of o.arguments){const d=u.name.value;if(!c.includes(d)){const l=vn(d,c);t.reportError(new z(`Unknown argument "${d}" on directive "@${a}".`+Gt(l),{nodes:u}))}}return!1}}}function Hl(t){const e=Object.create(null),n=t.getSchema(),r=n?n.getDirectives():En;for(const s of r)e[s.name]=s.locations;const i=t.getDocument().definitions;for(const s of i)s.kind===y.DIRECTIVE_DEFINITION&&(e[s.name.value]=s.locations.map(o=>o.value));return{Directive(s,o,a,c,u){const d=s.name.value,l=e[d];if(!l){t.reportError(new z(`Unknown directive "@${d}".`,{nodes:s}));return}const f=wy(u);f&&!l.includes(f)&&t.reportError(new z(`Directive "@${d}" may not be used on ${f}.`,{nodes:s}))}}}function wy(t){const e=t[t.length-1];switch("kind"in e||mt(!1),e.kind){case y.OPERATION_DEFINITION:return Sy(e.operation);case y.FIELD:return se.FIELD;case y.FRAGMENT_SPREAD:return se.FRAGMENT_SPREAD;case y.INLINE_FRAGMENT:return se.INLINE_FRAGMENT;case y.FRAGMENT_DEFINITION:return se.FRAGMENT_DEFINITION;case y.VARIABLE_DEFINITION:return se.VARIABLE_DEFINITION;case y.SCHEMA_DEFINITION:case y.SCHEMA_EXTENSION:return se.SCHEMA;case y.SCALAR_TYPE_DEFINITION:case y.SCALAR_TYPE_EXTENSION:return se.SCALAR;case y.OBJECT_TYPE_DEFINITION:case y.OBJECT_TYPE_EXTENSION:return se.OBJECT;case y.FIELD_DEFINITION:return se.FIELD_DEFINITION;case y.INTERFACE_TYPE_DEFINITION:case y.INTERFACE_TYPE_EXTENSION:return se.INTERFACE;case y.UNION_TYPE_DEFINITION:case y.UNION_TYPE_EXTENSION:return se.UNION;case y.ENUM_TYPE_DEFINITION:case y.ENUM_TYPE_EXTENSION:return se.ENUM;case y.ENUM_VALUE_DEFINITION:return se.ENUM_VALUE;case y.INPUT_OBJECT_TYPE_DEFINITION:case y.INPUT_OBJECT_TYPE_EXTENSION:return se.INPUT_OBJECT;case y.INPUT_VALUE_DEFINITION:{const n=t[t.length-3];return"kind"in n||mt(!1),n.kind===y.INPUT_OBJECT_TYPE_DEFINITION?se.INPUT_FIELD_DEFINITION:se.ARGUMENT_DEFINITION}default:mt(!1,"Unexpected kind: "+ee(e.kind))}}function Sy(t){switch(t){case Ye.QUERY:return se.QUERY;case Ye.MUTATION:return se.MUTATION;case Ye.SUBSCRIPTION:return se.SUBSCRIPTION}}function Ty(t){return{FragmentSpread(e){const n=e.name.value;t.getFragment(n)||t.reportError(new z(`Unknown fragment "${n}".`,{nodes:e.name}))}}}function Jl(t){const e=t.getSchema(),n=e?e.getTypeMap():Object.create(null),r=Object.create(null);for(const s of t.getDocument().definitions)Tr(s)&&(r[s.name.value]=!0);const i=[...Object.keys(n),...Object.keys(r)];return{NamedType(s,o,a,c,u){const d=s.name.value;if(!n[d]&&!r[d]){var l;const f=(l=u[2])!==null&&l!==void 0?l:a,h=f!=null&&Iy(f);if(h&&rc.includes(d))return;const g=vn(d,h?rc.concat(i):i);t.reportError(new z(`Unknown type "${d}".`+Gt(g),{nodes:s}))}}}}const rc=[...xo,...ko].map(t=>t.name);function Iy(t){return"kind"in t&&(hy(t)||my(t))}function Dy(t){let e=0;return{Document(n){e=n.definitions.filter(r=>r.kind===y.OPERATION_DEFINITION).length},OperationDefinition(n){!n.name&&e>1&&t.reportError(new z("This anonymous operation must be the only defined operation.",{nodes:n}))}}}function Ny(t){var e,n,r;const i=t.getSchema(),s=(e=(n=(r=i==null?void 0:i.astNode)!==null&&r!==void 0?r:i==null?void 0:i.getQueryType())!==null&&n!==void 0?n:i==null?void 0:i.getMutationType())!==null&&e!==void 0?e:i==null?void 0:i.getSubscriptionType();let o=0;return{SchemaDefinition(a){if(s){t.reportError(new z("Cannot define a new schema within a schema extension.",{nodes:a}));return}o>0&&t.reportError(new z("Must provide only one schema definition.",{nodes:a})),++o}}}const Oy=3;function Ay(t){function e(n,r=Object.create(null),i=0){if(n.kind===y.FRAGMENT_SPREAD){const s=n.name.value;if(r[s]===!0)return!1;const o=t.getFragment(s);if(!o)return!1;try{return r[s]=!0,e(o,r,i)}finally{r[s]=void 0}}if(n.kind===y.FIELD&&(n.name.value==="fields"||n.name.value==="interfaces"||n.name.value==="possibleTypes"||n.name.value==="inputFields")&&(i++,i>=Oy))return!0;if("selectionSet"in n&&n.selectionSet){for(const s of n.selectionSet.selections)if(e(s,r,i))return!0}return!1}return{Field(n){if((n.name.value==="__schema"||n.name.value==="__type")&&e(n))return t.reportError(new z("Maximum introspection depth exceeded",{nodes:[n]})),!1}}}function Ry(t){const e=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(s){return i(s),!1}};function i(s){if(e[s.name.value])return;const o=s.name.value;e[o]=!0;const a=t.getFragmentSpreads(s.selectionSet);if(a.length!==0){r[o]=n.length;for(const c of a){const u=c.name.value,d=r[u];if(n.push(c),d===void 0){const l=t.getFragment(u);l&&i(l)}else{const l=n.slice(d),f=l.slice(0,-1).map(h=>'"'+h.name.value+'"').join(", ");t.reportError(new z(`Cannot spread fragment "${u}" within itself`+(f!==""?` via ${f}.`:"."),{nodes:l}))}n.pop()}r[o]=void 0}}}function Cy(t){let e=Object.create(null);return{OperationDefinition:{enter(){e=Object.create(null)},leave(n){const r=t.getRecursiveVariableUsages(n);for(const{node:i}of r){const s=i.name.value;e[s]!==!0&&t.reportError(new z(n.name?`Variable "$${s}" is not defined by operation "${n.name.value}".`:`Variable "$${s}" is not defined.`,{nodes:[i,n]}))}}},VariableDefinition(n){e[n.variable.name.value]=!0}}}function Ly(t){const e=[],n=[];return{OperationDefinition(r){return e.push(r),!1},FragmentDefinition(r){return n.push(r),!1},Document:{leave(){const r=Object.create(null);for(const i of e)for(const s of t.getRecursivelyReferencedFragments(i))r[s.name.value]=!0;for(const i of n){const s=i.name.value;r[s]!==!0&&t.reportError(new z(`Fragment "${s}" is never used.`,{nodes:i}))}}}}}function xy(t){let e=[];return{OperationDefinition:{enter(){e=[]},leave(n){const r=Object.create(null),i=t.getRecursiveVariableUsages(n);for(const{node:s}of i)r[s.name.value]=!0;for(const s of e){const o=s.variable.name.value;r[o]!==!0&&t.reportError(new z(n.name?`Variable "$${o}" is never used in operation "${n.name.value}".`:`Variable "$${o}" is never used.`,{nodes:s}))}}},VariableDefinition(n){e.push(n)}}}function Fo(t){switch(t.kind){case y.OBJECT:return{...t,fields:My(t.fields)};case y.LIST:return{...t,values:t.values.map(Fo)};case y.INT:case y.FLOAT:case y.STRING:case y.BOOLEAN:case y.NULL:case y.ENUM:case y.VARIABLE:return t}}function My(t){return t.map(e=>({...e,value:Fo(e.value)})).sort((e,n)=>Ro(e.name.value,n.name.value))}function Wl(t){return Array.isArray(t)?t.map(([e,n])=>`subfields "${e}" conflict because `+Wl(n)).join(" and "):t}function Py(t){const e=new Xl,n=new jy,r=new Map;return{SelectionSet(i){const s=ky(t,r,e,n,t.getParentType(),i);for(const[[o,a],c,u]of s){const d=Wl(a);t.reportError(new z(`Fields "${o}" conflict because ${d}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:c.concat(u)}))}}}}function ky(t,e,n,r,i,s){const o=[],[a,c]=mi(t,e,i,s);if(Uy(t,o,e,n,r,a),c.length!==0)for(let u=0;u<c.length;u++){pi(t,o,e,n,r,!1,a,c[u]);for(let d=u+1;d<c.length;d++)hi(t,o,e,n,r,!1,c[u],c[d])}return o}function pi(t,e,n,r,i,s,o,a){if(r.has(o,a,s))return;r.add(o,a,s);const c=t.getFragment(a);if(!c)return;const[u,d]=Js(t,n,c);if(o!==u){Bo(t,e,n,r,i,s,o,u);for(const l of d)pi(t,e,n,r,i,s,o,l)}}function hi(t,e,n,r,i,s,o,a){if(o===a||i.has(o,a,s))return;i.add(o,a,s);const c=t.getFragment(o),u=t.getFragment(a);if(!c||!u)return;const[d,l]=Js(t,n,c),[f,h]=Js(t,n,u);Bo(t,e,n,r,i,s,d,f);for(const g of h)hi(t,e,n,r,i,s,o,g);for(const g of l)hi(t,e,n,r,i,s,g,a)}function $y(t,e,n,r,i,s,o,a,c){const u=[],[d,l]=mi(t,e,s,o),[f,h]=mi(t,e,a,c);Bo(t,u,e,n,r,i,d,f);for(const g of h)pi(t,u,e,n,r,i,d,g);for(const g of l)pi(t,u,e,n,r,i,f,g);for(const g of l)for(const E of h)hi(t,u,e,n,r,i,g,E);return u}function Uy(t,e,n,r,i,s){for(const[o,a]of Object.entries(s))if(a.length>1)for(let c=0;c<a.length;c++)for(let u=c+1;u<a.length;u++){const d=Kl(t,n,r,i,!1,o,a[c],a[u]);d&&e.push(d)}}function Bo(t,e,n,r,i,s,o,a){for(const[c,u]of Object.entries(o)){const d=a[c];if(d)for(const l of u)for(const f of d){const h=Kl(t,n,r,i,s,c,l,f);h&&e.push(h)}}}function Kl(t,e,n,r,i,s,o,a){const[c,u,d]=o,[l,f,h]=a,g=i||c!==l&&Oe(c)&&Oe(l);if(!g){const R=u.name.value,K=f.name.value;if(R!==K)return[[s,`"${R}" and "${K}" are different fields`],[u],[f]];if(!Fy(u,f))return[[s,"they have differing arguments"],[u],[f]]}const E=d==null?void 0:d.type,D=h==null?void 0:h.type;if(E&&D&&Hs(E,D))return[[s,`they return conflicting types "${ee(E)}" and "${ee(D)}"`],[u],[f]];const P=u.selectionSet,B=f.selectionSet;if(P&&B){const R=$y(t,e,n,r,g,pt(E),P,pt(D),B);return By(R,s,u,f)}}function Fy(t,e){const n=t.arguments,r=e.arguments;if(n===void 0||n.length===0)return r===void 0||r.length===0;if(r===void 0||r.length===0||n.length!==r.length)return!1;const i=new Map(r.map(({name:s,value:o})=>[s.value,o]));return n.every(s=>{const o=s.value,a=i.get(s.name.value);return a===void 0?!1:ic(o)===ic(a)})}function ic(t){return $e(Fo(t))}function Hs(t,e){return Ve(t)?Ve(e)?Hs(t.ofType,e.ofType):!0:Ve(e)?!0:Se(t)?Se(e)?Hs(t.ofType,e.ofType):!0:Se(e)?!0:Ln(t)||Ln(e)?t!==e:!1}function mi(t,e,n,r){const i=e.get(r);if(i)return i;const s=Object.create(null),o=Object.create(null);Ql(t,n,r,s,o);const a=[s,Object.keys(o)];return e.set(r,a),a}function Js(t,e,n){const r=e.get(n.selectionSet);if(r)return r;const i=at(t.getSchema(),n.typeCondition);return mi(t,e,i,n.selectionSet)}function Ql(t,e,n,r,i){for(const s of n.selections)switch(s.kind){case y.FIELD:{const o=s.name.value;let a;(Oe(e)||Re(e))&&(a=e.getFields()[o]);const c=s.alias?s.alias.value:o;r[c]||(r[c]=[]),r[c].push([e,s,a]);break}case y.FRAGMENT_SPREAD:i[s.name.value]=!0;break;case y.INLINE_FRAGMENT:{const o=s.typeCondition,a=o?at(t.getSchema(),o):e;Ql(t,a,s.selectionSet,r,i);break}}}function By(t,e,n,r){if(t.length>0)return[[e,t.map(([i])=>i)],[n,...t.map(([,i])=>i).flat()],[r,...t.map(([,,i])=>i).flat()]]}class Xl{constructor(){this._data=new Map}has(e,n,r){var i;const s=(i=this._data.get(e))===null||i===void 0?void 0:i.get(n);return s===void 0?!1:r?!0:r===s}add(e,n,r){const i=this._data.get(e);i===void 0?this._data.set(e,new Map([[n,r]])):i.set(n,r)}}class jy{constructor(){this._orderedPairSet=new Xl}has(e,n,r){return e<n?this._orderedPairSet.has(e,n,r):this._orderedPairSet.has(n,e,r)}add(e,n,r){e<n?this._orderedPairSet.add(e,n,r):this._orderedPairSet.add(n,e,r)}}function Vy(t){return{InlineFragment(e){const n=t.getType(),r=t.getParentType();if(zt(n)&&zt(r)&&!Wa(t.getSchema(),n,r)){const i=ee(r),s=ee(n);t.reportError(new z(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${s}".`,{nodes:e}))}},FragmentSpread(e){const n=e.name.value,r=Gy(t,n),i=t.getParentType();if(r&&i&&!Wa(t.getSchema(),r,i)){const s=ee(i),o=ee(r);t.reportError(new z(`Fragment "${n}" cannot be spread here as objects of type "${s}" can never be of type "${o}".`,{nodes:e}))}}}}function Gy(t,e){const n=t.getFragment(e);if(n){const r=at(t.getSchema(),n.typeCondition);if(zt(r))return r}}function zy(t){const e=t.getSchema(),n=Object.create(null);for(const i of t.getDocument().definitions)Tr(i)&&(n[i.name.value]=i);return{ScalarTypeExtension:r,ObjectTypeExtension:r,InterfaceTypeExtension:r,UnionTypeExtension:r,EnumTypeExtension:r,InputObjectTypeExtension:r};function r(i){const s=i.name.value,o=n[s],a=e==null?void 0:e.getType(s);let c;if(o?c=Yy[o.kind]:a&&(c=qy(a)),c){if(c!==i.kind){const u=Hy(i.kind);t.reportError(new z(`Cannot extend non-${u} type "${s}".`,{nodes:o?[o,i]:i}))}}else{const u=Object.keys({...n,...e==null?void 0:e.getTypeMap()}),d=vn(s,u);t.reportError(new z(`Cannot extend type "${s}" because it is not defined.`+Gt(d),{nodes:i.name}))}}}const Yy={[y.SCALAR_TYPE_DEFINITION]:y.SCALAR_TYPE_EXTENSION,[y.OBJECT_TYPE_DEFINITION]:y.OBJECT_TYPE_EXTENSION,[y.INTERFACE_TYPE_DEFINITION]:y.INTERFACE_TYPE_EXTENSION,[y.UNION_TYPE_DEFINITION]:y.UNION_TYPE_EXTENSION,[y.ENUM_TYPE_DEFINITION]:y.ENUM_TYPE_EXTENSION,[y.INPUT_OBJECT_TYPE_DEFINITION]:y.INPUT_OBJECT_TYPE_EXTENSION};function qy(t){if(qt(t))return y.SCALAR_TYPE_EXTENSION;if(Oe(t))return y.OBJECT_TYPE_EXTENSION;if(Re(t))return y.INTERFACE_TYPE_EXTENSION;if(ot(t))return y.UNION_TYPE_EXTENSION;if(Qe(t))return y.ENUM_TYPE_EXTENSION;if(Be(t))return y.INPUT_OBJECT_TYPE_EXTENSION;mt(!1,"Unexpected type: "+ee(t))}function Hy(t){switch(t){case y.SCALAR_TYPE_EXTENSION:return"scalar";case y.OBJECT_TYPE_EXTENSION:return"object";case y.INTERFACE_TYPE_EXTENSION:return"interface";case y.UNION_TYPE_EXTENSION:return"union";case y.ENUM_TYPE_EXTENSION:return"enum";case y.INPUT_OBJECT_TYPE_EXTENSION:return"input object";default:mt(!1,"Unexpected kind: "+ee(t))}}function Jy(t){return{...Zl(t),Field:{leave(e){var n;const r=t.getFieldDef();if(!r)return!1;const i=new Set((n=e.arguments)===null||n===void 0?void 0:n.map(s=>s.name.value));for(const s of r.args)if(!i.has(s.name)&&wr(s)){const o=ee(s.type);t.reportError(new z(`Field "${r.name}" argument "${s.name}" of type "${o}" is required, but it was not provided.`,{nodes:e}))}}}}}function Zl(t){var e;const n=Object.create(null),r=t.getSchema(),i=(e=r==null?void 0:r.getDirectives())!==null&&e!==void 0?e:En;for(const a of i)n[a.name]=fn(a.args.filter(wr),c=>c.name);const s=t.getDocument().definitions;for(const a of s)if(a.kind===y.DIRECTIVE_DEFINITION){var o;const c=(o=a.arguments)!==null&&o!==void 0?o:[];n[a.name.value]=fn(c.filter(Wy),u=>u.name.value)}return{Directive:{leave(a){const c=a.name.value,u=n[c];if(u){var d;const l=(d=a.arguments)!==null&&d!==void 0?d:[],f=new Set(l.map(h=>h.name.value));for(const[h,g]of Object.entries(u))if(!f.has(h)){const E=Co(g.type)?ee(g.type):$e(g.type);t.reportError(new z(`Directive "@${c}" argument "${h}" of type "${E}" is required, but it was not provided.`,{nodes:a}))}}}}}}function Wy(t){return t.type.kind===y.NON_NULL_TYPE&&t.defaultValue==null}function Ky(t){return{Field(e){const n=t.getType(),r=e.selectionSet;if(n)if(Ln(pt(n))){if(r){const i=e.name.value,s=ee(n);t.reportError(new z(`Field "${i}" must not have a selection since type "${s}" has no subfields.`,{nodes:r}))}}else if(r){if(r.selections.length===0){const i=e.name.value,s=ee(n);t.reportError(new z(`Field "${i}" of type "${s}" must have at least one field selected.`,{nodes:e}))}}else{const i=e.name.value,s=ee(n);t.reportError(new z(`Field "${i}" of type "${s}" must have a selection of subfields. Did you mean "${i} { ... }"?`,{nodes:e}))}}}}function nn(t,e,n){if(t){if(t.kind===y.VARIABLE){const r=t.name.value;if(n==null||n[r]===void 0)return;const i=n[r];return i===null&&Se(e)?void 0:i}if(Se(e))return t.kind===y.NULL?void 0:nn(t,e.ofType,n);if(t.kind===y.NULL)return null;if(Ve(e)){const r=e.ofType;if(t.kind===y.LIST){const s=[];for(const o of t.values)if(sc(o,n)){if(Se(r))return;s.push(null)}else{const a=nn(o,r,n);if(a===void 0)return;s.push(a)}return s}const i=nn(t,r,n);return i===void 0?void 0:[i]}if(Be(e)){if(t.kind!==y.OBJECT)return;const r=Object.create(null),i=fn(t.fields,s=>s.name.value);for(const s of Object.values(e.getFields())){const o=i[s.name];if(!o||sc(o.value,n)){if(s.defaultValue!==void 0)r[s.name]=s.defaultValue;else if(Se(s.type))return;continue}const a=nn(o.value,s.type,n);if(a===void 0)return;r[s.name]=a}if(e.isOneOf){const s=Object.keys(r);if(s.length!==1||r[s[0]]===null)return}return r}if(Ln(e)){let r;try{r=e.parseLiteral(t,n)}catch{return}return r===void 0?void 0:r}mt(!1,"Unexpected input type: "+ee(e))}}function sc(t,e){return t.kind===y.VARIABLE&&(e==null||e[t.name.value]===void 0)}function Qy(t,e,n){var r;const i={},s=(r=e.arguments)!==null&&r!==void 0?r:[],o=fn(s,a=>a.name.value);for(const a of t.args){const c=a.name,u=a.type,d=o[c];if(!d){if(a.defaultValue!==void 0)i[c]=a.defaultValue;else if(Se(u))throw new z(`Argument "${c}" of required type "${ee(u)}" was not provided.`,{nodes:e});continue}const l=d.value;let f=l.kind===y.NULL;if(l.kind===y.VARIABLE){const g=l.name.value;if(n==null||!Xy(n,g)){if(a.defaultValue!==void 0)i[c]=a.defaultValue;else if(Se(u))throw new z(`Argument "${c}" of required type "${ee(u)}" was provided the variable "$${g}" which was not provided a runtime value.`,{nodes:l});continue}f=n[g]==null}if(f&&Se(u))throw new z(`Argument "${c}" of non-null type "${ee(u)}" must not be null.`,{nodes:l});const h=nn(l,u,n);if(h===void 0)throw new z(`Argument "${c}" has invalid value ${$e(l)}.`,{nodes:l});i[c]=h}return i}function dr(t,e,n){var r;const i=(r=e.directives)===null||r===void 0?void 0:r.find(s=>s.name.value===t.name);if(i)return Qy(t,i,n)}function Xy(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Zy(t,e,n,r,i){const s=new Map;return Ws(t,e,n,r,i,s,new Set),s}function Ws(t,e,n,r,i,s,o){for(const a of i.selections)switch(a.kind){case y.FIELD:{if(!ms(n,a))continue;const c=ev(a),u=s.get(c);u!==void 0?u.push(a):s.set(c,[a]);break}case y.INLINE_FRAGMENT:{if(!ms(n,a)||!oc(t,a,r))continue;Ws(t,e,n,r,a.selectionSet,s,o);break}case y.FRAGMENT_SPREAD:{const c=a.name.value;if(o.has(c)||!ms(n,a))continue;o.add(c);const u=e[c];if(!u||!oc(t,u,r))continue;Ws(t,e,n,r,u.selectionSet,s,o);break}}}function ms(t,e){const n=dr(Ml,e,t);if((n==null?void 0:n.if)===!0)return!1;const r=dr(xl,e,t);return(r==null?void 0:r.if)!==!1}function oc(t,e,n){const r=e.typeCondition;if(!r)return!0;const i=at(t,r);return i===n?!0:Bt(i)?t.isSubType(i,n):!1}function ev(t){return t.alias?t.alias.value:t.name.value}function tv(t){return{OperationDefinition(e){if(e.operation==="subscription"){const n=t.getSchema(),r=n.getSubscriptionType();if(r){const i=e.name?e.name.value:null,s=Object.create(null),o=t.getDocument(),a=Object.create(null);for(const u of o.definitions)u.kind===y.FRAGMENT_DEFINITION&&(a[u.name.value]=u);const c=Zy(n,a,s,r,e.selectionSet);if(c.size>1){const l=[...c.values()].slice(1).flat();t.reportError(new z(i!=null?`Subscription "${i}" must select only one top level field.`:"Anonymous Subscription must select only one top level field.",{nodes:l}))}for(const u of c.values())u[0].name.value.startsWith("__")&&t.reportError(new z(i!=null?`Subscription "${i}" must not select an introspection top level field.`:"Anonymous Subscription must not select an introspection top level field.",{nodes:u}))}}}}}function jo(t,e){const n=new Map;for(const r of t){const i=e(r),s=n.get(i);s===void 0?n.set(i,[r]):s.push(r)}return n}function nv(t){return{DirectiveDefinition(r){var i;const s=(i=r.arguments)!==null&&i!==void 0?i:[];return n(`@${r.name.value}`,s)},InterfaceTypeDefinition:e,InterfaceTypeExtension:e,ObjectTypeDefinition:e,ObjectTypeExtension:e};function e(r){var i;const s=r.name.value,o=(i=r.fields)!==null&&i!==void 0?i:[];for(const c of o){var a;const u=c.name.value,d=(a=c.arguments)!==null&&a!==void 0?a:[];n(`${s}.${u}`,d)}return!1}function n(r,i){const s=jo(i,o=>o.name.value);for(const[o,a]of s)a.length>1&&t.reportError(new z(`Argument "${r}(${o}:)" can only be defined once.`,{nodes:a.map(c=>c.name)}));return!1}}function ed(t){return{Field:e,Directive:e};function e(n){var r;const i=(r=n.arguments)!==null&&r!==void 0?r:[],s=jo(i,o=>o.name.value);for(const[o,a]of s)a.length>1&&t.reportError(new z(`There can be only one argument named "${o}".`,{nodes:a.map(c=>c.name)}))}}function rv(t){const e=Object.create(null),n=t.getSchema();return{DirectiveDefinition(r){const i=r.name.value;if(n!=null&&n.getDirective(i)){t.reportError(new z(`Directive "@${i}" already exists in the schema. It cannot be redefined.`,{nodes:r.name}));return}return e[i]?t.reportError(new z(`There can be only one directive named "@${i}".`,{nodes:[e[i],r.name]})):e[i]=r.name,!1}}}function td(t){const e=Object.create(null),n=t.getSchema(),r=n?n.getDirectives():En;for(const a of r)e[a.name]=!a.isRepeatable;const i=t.getDocument().definitions;for(const a of i)a.kind===y.DIRECTIVE_DEFINITION&&(e[a.name.value]=!a.repeatable);const s=Object.create(null),o=Object.create(null);return{enter(a){if(!("directives"in a)||!a.directives)return;let c;if(a.kind===y.SCHEMA_DEFINITION||a.kind===y.SCHEMA_EXTENSION)c=s;else if(Tr(a)||Uo(a)){const u=a.name.value;c=o[u],c===void 0&&(o[u]=c=Object.create(null))}else c=Object.create(null);for(const u of a.directives){const d=u.name.value;e[d]&&(c[d]?t.reportError(new z(`The directive "@${d}" can only be used once at this location.`,{nodes:[c[d],u]})):c[d]=u)}}}}function iv(t){const e=t.getSchema(),n=e?e.getTypeMap():Object.create(null),r=Object.create(null);return{EnumTypeDefinition:i,EnumTypeExtension:i};function i(s){var o;const a=s.name.value;r[a]||(r[a]=Object.create(null));const c=(o=s.values)!==null&&o!==void 0?o:[],u=r[a];for(const d of c){const l=d.name.value,f=n[a];Qe(f)&&f.getValue(l)?t.reportError(new z(`Enum value "${a}.${l}" already exists in the schema. It cannot also be defined in this type extension.`,{nodes:d.name})):u[l]?t.reportError(new z(`Enum value "${a}.${l}" can only be defined once.`,{nodes:[u[l],d.name]})):u[l]=d.name}return!1}}function sv(t){const e=t.getSchema(),n=e?e.getTypeMap():Object.create(null),r=Object.create(null);return{InputObjectTypeDefinition:i,InputObjectTypeExtension:i,InterfaceTypeDefinition:i,InterfaceTypeExtension:i,ObjectTypeDefinition:i,ObjectTypeExtension:i};function i(s){var o;const a=s.name.value;r[a]||(r[a]=Object.create(null));const c=(o=s.fields)!==null&&o!==void 0?o:[],u=r[a];for(const d of c){const l=d.name.value;ov(n[a],l)?t.reportError(new z(`Field "${a}.${l}" already exists in the schema. It cannot also be defined in this type extension.`,{nodes:d.name})):u[l]?t.reportError(new z(`Field "${a}.${l}" can only be defined once.`,{nodes:[u[l],d.name]})):u[l]=d.name}return!1}}function ov(t,e){return Oe(t)||Re(t)||Be(t)?t.getFields()[e]!=null:!1}function av(t){const e=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){const r=n.name.value;return e[r]?t.reportError(new z(`There can be only one fragment named "${r}".`,{nodes:[e[r],n.name]})):e[r]=n.name,!1}}}function nd(t){const e=[];let n=Object.create(null);return{ObjectValue:{enter(){e.push(n),n=Object.create(null)},leave(){const r=e.pop();r||mt(!1),n=r}},ObjectField(r){const i=r.name.value;n[i]?t.reportError(new z(`There can be only one input field named "${i}".`,{nodes:[n[i],r.name]})):n[i]=r.name}}}function cv(t){const e=Object.create(null);return{OperationDefinition(n){const r=n.name;return r&&(e[r.value]?t.reportError(new z(`There can be only one operation named "${r.value}".`,{nodes:[e[r.value],r]})):e[r.value]=r),!1},FragmentDefinition:()=>!1}}function uv(t){const e=t.getSchema(),n=Object.create(null),r=e?{query:e.getQueryType(),mutation:e.getMutationType(),subscription:e.getSubscriptionType()}:{};return{SchemaDefinition:i,SchemaExtension:i};function i(s){var o;const a=(o=s.operationTypes)!==null&&o!==void 0?o:[];for(const c of a){const u=c.operation,d=n[u];r[u]?t.reportError(new z(`Type for ${u} already defined in the schema. It cannot be redefined.`,{nodes:c})):d?t.reportError(new z(`There can be only one ${u} type in schema.`,{nodes:[d,c]})):n[u]=c}return!1}}function lv(t){const e=Object.create(null),n=t.getSchema();return{ScalarTypeDefinition:r,ObjectTypeDefinition:r,InterfaceTypeDefinition:r,UnionTypeDefinition:r,EnumTypeDefinition:r,InputObjectTypeDefinition:r};function r(i){const s=i.name.value;if(n!=null&&n.getType(s)){t.reportError(new z(`Type "${s}" already exists in the schema. It cannot also be defined in this type definition.`,{nodes:i.name}));return}return e[s]?t.reportError(new z(`There can be only one type named "${s}".`,{nodes:[e[s],i.name]})):e[s]=i.name,!1}}function dv(t){return{OperationDefinition(e){var n;const r=(n=e.variableDefinitions)!==null&&n!==void 0?n:[],i=jo(r,s=>s.variable.name.value);for(const[s,o]of i)o.length>1&&t.reportError(new z(`There can be only one variable named "$${s}".`,{nodes:o.map(a=>a.variable.name)}))}}}function fv(t){let e={};return{OperationDefinition:{enter(){e={}}},VariableDefinition(n){e[n.variable.name.value]=n},ListValue(n){const r=wl(t.getParentInputType());if(!Ve(r))return Kt(t,n),!1},ObjectValue(n){const r=pt(t.getInputType());if(!Be(r))return Kt(t,n),!1;const i=fn(n.fields,s=>s.name.value);for(const s of Object.values(r.getFields()))if(!i[s.name]&&Rl(s)){const a=ee(s.type);t.reportError(new z(`Field "${r.name}.${s.name}" of required type "${a}" was not provided.`,{nodes:n}))}r.isOneOf&&pv(t,n,r,i,e)},ObjectField(n){const r=pt(t.getParentInputType());if(!t.getInputType()&&Be(r)){const s=vn(n.name.value,Object.keys(r.getFields()));t.reportError(new z(`Field "${n.name.value}" is not defined by type "${r.name}".`+Gt(s),{nodes:n}))}},NullValue(n){const r=t.getInputType();Se(r)&&t.reportError(new z(`Expected value of type "${ee(r)}", found ${$e(n)}.`,{nodes:n}))},EnumValue:n=>Kt(t,n),IntValue:n=>Kt(t,n),FloatValue:n=>Kt(t,n),StringValue:n=>Kt(t,n),BooleanValue:n=>Kt(t,n)}}function Kt(t,e){const n=t.getInputType();if(!n)return;const r=pt(n);if(!Ln(r)){const i=ee(n);t.reportError(new z(`Expected value of type "${i}", found ${$e(e)}.`,{nodes:e}));return}try{if(r.parseLiteral(e,void 0)===void 0){const s=ee(n);t.reportError(new z(`Expected value of type "${s}", found ${$e(e)}.`,{nodes:e}))}}catch(i){const s=ee(n);i instanceof z?t.reportError(i):t.reportError(new z(`Expected value of type "${s}", found ${$e(e)}; `+i.message,{nodes:e,originalError:i}))}}function pv(t,e,n,r,i){var s;const o=Object.keys(r);if(o.length!==1){t.reportError(new z(`OneOf Input Object "${n.name}" must specify exactly one key.`,{nodes:[e]}));return}const c=(s=r[o[0]])===null||s===void 0?void 0:s.value,u=!c||c.kind===y.NULL,d=(c==null?void 0:c.kind)===y.VARIABLE;if(u){t.reportError(new z(`Field "${n.name}.${o[0]}" must be non-null.`,{nodes:[e]}));return}if(d){const l=c.name.value;i[l].type.kind!==y.NON_NULL_TYPE&&t.reportError(new z(`Variable "${l}" must be non-nullable to be used for OneOf Input Object "${n.name}".`,{nodes:[e]}))}}function hv(t){return{VariableDefinition(e){const n=at(t.getSchema(),e.type);if(n!==void 0&&!bt(n)){const r=e.variable.name.value,i=$e(e.type);t.reportError(new z(`Variable "$${r}" cannot be non-input type "${i}".`,{nodes:e.type}))}}}}function mv(t){let e=Object.create(null);return{OperationDefinition:{enter(){e=Object.create(null)},leave(n){const r=t.getRecursiveVariableUsages(n);for(const{node:i,type:s,defaultValue:o,parentType:a}of r){const c=i.name.value,u=e[c];if(u&&s){const d=t.getSchema(),l=at(d,u.type);if(l&&!gv(d,l,u.defaultValue,s,o)){const f=ee(l),h=ee(s);t.reportError(new z(`Variable "$${c}" of type "${f}" used in position expecting type "${h}".`,{nodes:[u,i]}))}Be(a)&&a.isOneOf&&bl(l)&&t.reportError(new z(`Variable "$${c}" is of type "${l}" but must be non-nullable to be used for OneOf Input Object "${a}".`,{nodes:[u,i]}))}}}},VariableDefinition(n){e[n.variable.name.value]=n}}}function gv(t,e,n,r,i){if(Se(r)&&!Se(e)){if(!(n!=null&&n.kind!==y.NULL)&&!(i!==void 0))return!1;const a=r.ofType;return Nn(t,e,a)}return Nn(t,e,r)}const yv=Object.freeze([Ay]),vv=Object.freeze([gy,cv,Dy,tv,Jl,_y,hv,Ky,yy,av,Ty,Ly,Vy,Ry,dv,Cy,xy,Hl,td,by,ed,fv,Jy,mv,Py,nd,...yv]),Ev=Object.freeze([Ny,uv,lv,iv,sv,nv,rv,Jl,Hl,td,zy,ql,ed,nd,Zl]);class rd{constructor(e,n){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=n}get[Symbol.toStringTag](){return"ASTValidationContext"}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let n;if(this._fragments)n=this._fragments;else{n=Object.create(null);for(const r of this.getDocument().definitions)r.kind===y.FRAGMENT_DEFINITION&&(n[r.name.value]=r);this._fragments=n}return n[e]}getFragmentSpreads(e){let n=this._fragmentSpreads.get(e);if(!n){n=[];const r=[e];let i;for(;i=r.pop();)for(const s of i.selections)s.kind===y.FRAGMENT_SPREAD?n.push(s):s.selectionSet&&r.push(s.selectionSet);this._fragmentSpreads.set(e,n)}return n}getRecursivelyReferencedFragments(e){let n=this._recursivelyReferencedFragments.get(e);if(!n){n=[];const r=Object.create(null),i=[e.selectionSet];let s;for(;s=i.pop();)for(const o of this.getFragmentSpreads(s)){const a=o.name.value;if(r[a]!==!0){r[a]=!0;const c=this.getFragment(a);c&&(n.push(c),i.push(c.selectionSet))}}this._recursivelyReferencedFragments.set(e,n)}return n}}class _v extends rd{constructor(e,n,r){super(e,r),this._schema=n}get[Symbol.toStringTag](){return"SDLValidationContext"}getSchema(){return this._schema}}class bv extends rd{constructor(e,n,r,i){super(n,i),this._schema=e,this._typeInfo=r,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}get[Symbol.toStringTag](){return"ValidationContext"}getSchema(){return this._schema}getVariableUsages(e){let n=this._variableUsages.get(e);if(!n){const r=[],i=new zl(this._schema);Mi(e,Yl(i,{VariableDefinition:()=>!1,Variable(s){r.push({node:s,type:i.getInputType(),defaultValue:i.getDefaultValue(),parentType:i.getParentInputType()})}})),n=r,this._variableUsages.set(e,n)}return n}getRecursiveVariableUsages(e){let n=this._recursiveVariableUsages.get(e);if(!n){n=this.getVariableUsages(e);for(const r of this.getRecursivelyReferencedFragments(e))n=n.concat(this.getVariableUsages(r));this._recursiveVariableUsages.set(e,n)}return n}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}}function wS(t,e,n=vv,r,i=new zl(t)){var s;const o=(s=void 0)!==null&&s!==void 0?s:100;e||ve(!1,"Must provide document."),ey(t);const a=Object.freeze({}),c=[],u=new bv(t,e,i,l=>{if(c.length>=o)throw c.push(new z("Too many validation errors, error limit reached. Validation aborted.")),a;c.push(l)}),d=_l(n.map(l=>l(u)));try{Mi(e,Yl(i,d))}catch(l){if(l!==a)throw l}return c}function wv(t,e,n=Ev){const r=[],i=new _v(t,e,o=>{r.push(o)}),s=n.map(o=>o(i));return Mi(t,_l(s)),r}function Sv(t){const e=wv(t);if(e.length!==0)throw new Error(e.map(n=>n.message).join(`
175
-
176
- `))}function Tv(t,e,n){var r,i,s,o;const a=[],c=Object.create(null),u=[];let d;const l=[];for(const S of e.definitions)if(S.kind===y.SCHEMA_DEFINITION)d=S;else if(S.kind===y.SCHEMA_EXTENSION)l.push(S);else if(Tr(S))a.push(S);else if(Uo(S)){const W=S.name.value,F=c[W];c[W]=F?F.concat([S]):[S]}else S.kind===y.DIRECTIVE_DEFINITION&&u.push(S);if(Object.keys(c).length===0&&a.length===0&&u.length===0&&l.length===0&&d==null)return t;const f=Object.create(null);for(const S of t.types)f[S.name]=B(S);for(const S of a){var h;const W=S.name.value;f[W]=(h=ac[W])!==null&&h!==void 0?h:ae(S)}const g={query:t.query&&D(t.query),mutation:t.mutation&&D(t.mutation),subscription:t.subscription&&D(t.subscription),...d&&L([d]),...L(l)};return{description:(r=d)===null||r===void 0||(i=r.description)===null||i===void 0?void 0:i.value,...g,types:Object.values(f),directives:[...t.directives.map(P),...u.map(oe)],extensions:Object.create(null),astNode:(s=d)!==null&&s!==void 0?s:t.astNode,extensionASTNodes:t.extensionASTNodes.concat(l),assumeValid:(o=n==null?void 0:n.assumeValid)!==null&&o!==void 0?o:!1};function E(S){return Ve(S)?new ze(E(S.ofType)):Se(S)?new ue(E(S.ofType)):D(S)}function D(S){return f[S.name]}function P(S){const W=S.toConfig();return new Yt({...W,args:At(W.args,C)})}function B(S){if(Vl(S)||Jg(S))return S;if(qt(S))return N(S);if(Oe(S))return X(S);if(Re(S))return b(S);if(ot(S))return $(S);if(Qe(S))return K(S);if(Be(S))return R(S);mt(!1,"Unexpected type: "+ee(S))}function R(S){var W;const F=S.toConfig(),Q=(W=c[F.name])!==null&&W!==void 0?W:[];return new Ys({...F,fields:()=>({...At(F.fields,ge=>({...ge,type:E(ge.type)})),...q(Q)}),extensionASTNodes:F.extensionASTNodes.concat(Q)})}function K(S){var W;const F=S.toConfig(),Q=(W=c[S.name])!==null&&W!==void 0?W:[];return new lr({...F,values:{...F.values,...j(Q)},extensionASTNodes:F.extensionASTNodes.concat(Q)})}function N(S){var W;const F=S.toConfig(),Q=(W=c[F.name])!==null&&W!==void 0?W:[];let ge=F.specifiedByURL;for(const Ee of Q){var le;ge=(le=cc(Ee))!==null&&le!==void 0?le:ge}return new Lt({...F,specifiedByURL:ge,extensionASTNodes:F.extensionASTNodes.concat(Q)})}function X(S){var W;const F=S.toConfig(),Q=(W=c[F.name])!==null&&W!==void 0?W:[];return new st({...F,interfaces:()=>[...S.getInterfaces().map(D),...Y(Q)],fields:()=>({...At(F.fields,A),...I(Q)}),extensionASTNodes:F.extensionASTNodes.concat(Q)})}function b(S){var W;const F=S.toConfig(),Q=(W=c[F.name])!==null&&W!==void 0?W:[];return new zs({...F,interfaces:()=>[...S.getInterfaces().map(D),...Y(Q)],fields:()=>({...At(F.fields,A),...I(Q)}),extensionASTNodes:F.extensionASTNodes.concat(Q)})}function $(S){var W;const F=S.toConfig(),Q=(W=c[F.name])!==null&&W!==void 0?W:[];return new Dn({...F,types:()=>[...S.getTypes().map(D),...V(Q)],extensionASTNodes:F.extensionASTNodes.concat(Q)})}function A(S){return{...S,type:E(S.type),args:S.args&&At(S.args,C)}}function C(S){return{...S,type:E(S.type)}}function L(S){const W={};for(const Q of S){var F;const ge=(F=Q.operationTypes)!==null&&F!==void 0?F:[];for(const le of ge)W[le.operation]=O(le.type)}return W}function O(S){var W;const F=S.name.value,Q=(W=ac[F])!==null&&W!==void 0?W:f[F];if(Q===void 0)throw new Error(`Unknown type: "${F}".`);return Q}function re(S){return S.kind===y.LIST_TYPE?new ze(re(S.type)):S.kind===y.NON_NULL_TYPE?new ue(re(S.type)):O(S)}function oe(S){var W;return new Yt({name:S.name.value,description:(W=S.description)===null||W===void 0?void 0:W.value,locations:S.locations.map(({value:F})=>F),isRepeatable:S.repeatable,args:k(S.arguments),astNode:S})}function I(S){const W=Object.create(null);for(const ge of S){var F;const le=(F=ge.fields)!==null&&F!==void 0?F:[];for(const Ee of le){var Q;W[Ee.name.value]={type:re(Ee.type),description:(Q=Ee.description)===null||Q===void 0?void 0:Q.value,args:k(Ee.arguments),deprecationReason:Ur(Ee),astNode:Ee}}}return W}function k(S){const W=S??[],F=Object.create(null);for(const ge of W){var Q;const le=re(ge.type);F[ge.name.value]={type:le,description:(Q=ge.description)===null||Q===void 0?void 0:Q.value,defaultValue:nn(ge.defaultValue,le),deprecationReason:Ur(ge),astNode:ge}}return F}function q(S){const W=Object.create(null);for(const ge of S){var F;const le=(F=ge.fields)!==null&&F!==void 0?F:[];for(const Ee of le){var Q;const Xe=re(Ee.type);W[Ee.name.value]={type:Xe,description:(Q=Ee.description)===null||Q===void 0?void 0:Q.value,defaultValue:nn(Ee.defaultValue,Xe),deprecationReason:Ur(Ee),astNode:Ee}}}return W}function j(S){const W=Object.create(null);for(const ge of S){var F;const le=(F=ge.values)!==null&&F!==void 0?F:[];for(const Ee of le){var Q;W[Ee.name.value]={description:(Q=Ee.description)===null||Q===void 0?void 0:Q.value,deprecationReason:Ur(Ee),astNode:Ee}}}return W}function Y(S){return S.flatMap(W=>{var F,Q;return(F=(Q=W.interfaces)===null||Q===void 0?void 0:Q.map(O))!==null&&F!==void 0?F:[]})}function V(S){return S.flatMap(W=>{var F,Q;return(F=(Q=W.types)===null||Q===void 0?void 0:Q.map(O))!==null&&F!==void 0?F:[]})}function ae(S){var W;const F=S.name.value,Q=(W=c[F])!==null&&W!==void 0?W:[];switch(S.kind){case y.OBJECT_TYPE_DEFINITION:{var ge;const We=[S,...Q];return new st({name:F,description:(ge=S.description)===null||ge===void 0?void 0:ge.value,interfaces:()=>Y(We),fields:()=>I(We),astNode:S,extensionASTNodes:Q})}case y.INTERFACE_TYPE_DEFINITION:{var le;const We=[S,...Q];return new zs({name:F,description:(le=S.description)===null||le===void 0?void 0:le.value,interfaces:()=>Y(We),fields:()=>I(We),astNode:S,extensionASTNodes:Q})}case y.ENUM_TYPE_DEFINITION:{var Ee;const We=[S,...Q];return new lr({name:F,description:(Ee=S.description)===null||Ee===void 0?void 0:Ee.value,values:j(We),astNode:S,extensionASTNodes:Q})}case y.UNION_TYPE_DEFINITION:{var Xe;const We=[S,...Q];return new Dn({name:F,description:(Xe=S.description)===null||Xe===void 0?void 0:Xe.value,types:()=>V(We),astNode:S,extensionASTNodes:Q})}case y.SCALAR_TYPE_DEFINITION:{var St;return new Lt({name:F,description:(St=S.description)===null||St===void 0?void 0:St.value,specifiedByURL:cc(S),astNode:S,extensionASTNodes:Q})}case y.INPUT_OBJECT_TYPE_DEFINITION:{var Tt;const We=[S,...Q];return new Ys({name:F,description:(Tt=S.description)===null||Tt===void 0?void 0:Tt.value,fields:()=>q(We),astNode:S,extensionASTNodes:Q,isOneOf:Iv(S)})}}}}const ac=fn([...xo,...ko],t=>t.name);function Ur(t){const e=dr(Mo,t);return e==null?void 0:e.reason}function cc(t){const e=dr(Pl,t);return e==null?void 0:e.url}function Iv(t){return!!dr(kl,t)}function Dv(t,e){t!=null&&t.kind===y.DOCUMENT||ve(!1,"Must provide valid Document AST."),(e==null?void 0:e.assumeValid)!==!0&&(e==null?void 0:e.assumeValidSDL)!==!0&&Sv(t);const r=Tv({description:void 0,types:[],directives:[],extensions:Object.create(null),extensionASTNodes:[],assumeValid:!1},t,e);if(r.astNode==null)for(const s of r.types)switch(s.name){case"Query":r.query=s;break;case"Mutation":r.mutation=s;break;case"Subscription":r.subscription=s;break}const i=[...r.directives,...En.filter(s=>r.directives.every(o=>o.name!==s.name))];return new Gl({...r,directives:i})}function Nv(t,e){const n=vl(t,{noLocation:void 0,allowLegacyFragmentVariables:void 0});return Dv(n,{assumeValidSDL:void 0,assumeValid:void 0})}const Vo=JSON,Ov=t=>t.toUpperCase(),Av=t=>{const e={};return t.forEach((n,r)=>{e[r]=n}),e},Rv=(t,e,n)=>t.document?t:{document:t,variables:e,requestHeaders:n,signal:void 0},Cv=(t,e,n)=>t.query?t:{query:t,variables:e,requestHeaders:n,signal:void 0},Lv=(t,e)=>t.documents?t:{documents:t,requestHeaders:e,signal:void 0},xv=(t,e,...n)=>{const[r,i]=n;return t.document?t:{url:t,document:e,variables:r,requestHeaders:i,signal:void 0}},uc=t=>{var r,i;let e;const n=t.definitions.filter(s=>s.kind==="OperationDefinition");return n.length===1&&(e=(i=(r=n[0])==null?void 0:r.name)==null?void 0:i.value),e},gs=t=>{if(typeof t=="string"){let n;try{const r=vl(t);n=uc(r)}catch{}return{query:t,operationName:n}}const e=uc(t);return{query:$e(t),operationName:e}};class On extends Error{constructor(e,n){const r=`${On.extractMessage(e)}: ${JSON.stringify({response:e,request:n})}`;super(r),Object.setPrototypeOf(this,On.prototype),this.response=e,this.request=n,typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,On)}static extractMessage(e){var n,r;return((r=(n=e.errors)==null?void 0:n[0])==null?void 0:r.message)??`GraphQL Error (Code: ${e.status})`}}var Fr={exports:{}},lc;function Mv(){return lc||(lc=1,function(t,e){var n=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ft<"u"&&Ft,r=function(){function s(){this.fetch=!1,this.DOMException=n.DOMException}return s.prototype=n,new s}();(function(s){(function(o){var a=typeof s<"u"&&s||typeof self<"u"&&self||typeof Ft<"u"&&Ft||{},c={searchParams:"URLSearchParams"in a,iterable:"Symbol"in a&&"iterator"in Symbol,blob:"FileReader"in a&&"Blob"in a&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in a,arrayBuffer:"ArrayBuffer"in a};function u(I){return I&&DataView.prototype.isPrototypeOf(I)}if(c.arrayBuffer)var d=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(I){return I&&d.indexOf(Object.prototype.toString.call(I))>-1};function f(I){if(typeof I!="string"&&(I=String(I)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(I)||I==="")throw new TypeError('Invalid character in header field name: "'+I+'"');return I.toLowerCase()}function h(I){return typeof I!="string"&&(I=String(I)),I}function g(I){var k={next:function(){var q=I.shift();return{done:q===void 0,value:q}}};return c.iterable&&(k[Symbol.iterator]=function(){return k}),k}function E(I){this.map={},I instanceof E?I.forEach(function(k,q){this.append(q,k)},this):Array.isArray(I)?I.forEach(function(k){if(k.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+k.length);this.append(k[0],k[1])},this):I&&Object.getOwnPropertyNames(I).forEach(function(k){this.append(k,I[k])},this)}E.prototype.append=function(I,k){I=f(I),k=h(k);var q=this.map[I];this.map[I]=q?q+", "+k:k},E.prototype.delete=function(I){delete this.map[f(I)]},E.prototype.get=function(I){return I=f(I),this.has(I)?this.map[I]:null},E.prototype.has=function(I){return this.map.hasOwnProperty(f(I))},E.prototype.set=function(I,k){this.map[f(I)]=h(k)},E.prototype.forEach=function(I,k){for(var q in this.map)this.map.hasOwnProperty(q)&&I.call(k,this.map[q],q,this)},E.prototype.keys=function(){var I=[];return this.forEach(function(k,q){I.push(q)}),g(I)},E.prototype.values=function(){var I=[];return this.forEach(function(k){I.push(k)}),g(I)},E.prototype.entries=function(){var I=[];return this.forEach(function(k,q){I.push([q,k])}),g(I)},c.iterable&&(E.prototype[Symbol.iterator]=E.prototype.entries);function D(I){if(!I._noBody){if(I.bodyUsed)return Promise.reject(new TypeError("Already read"));I.bodyUsed=!0}}function P(I){return new Promise(function(k,q){I.onload=function(){k(I.result)},I.onerror=function(){q(I.error)}})}function B(I){var k=new FileReader,q=P(k);return k.readAsArrayBuffer(I),q}function R(I){var k=new FileReader,q=P(k),j=/charset=([A-Za-z0-9_-]+)/.exec(I.type),Y=j?j[1]:"utf-8";return k.readAsText(I,Y),q}function K(I){for(var k=new Uint8Array(I),q=new Array(k.length),j=0;j<k.length;j++)q[j]=String.fromCharCode(k[j]);return q.join("")}function N(I){if(I.slice)return I.slice(0);var k=new Uint8Array(I.byteLength);return k.set(new Uint8Array(I)),k.buffer}function X(){return this.bodyUsed=!1,this._initBody=function(I){this.bodyUsed=this.bodyUsed,this._bodyInit=I,I?typeof I=="string"?this._bodyText=I:c.blob&&Blob.prototype.isPrototypeOf(I)?this._bodyBlob=I:c.formData&&FormData.prototype.isPrototypeOf(I)?this._bodyFormData=I:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(I)?this._bodyText=I.toString():c.arrayBuffer&&c.blob&&u(I)?(this._bodyArrayBuffer=N(I.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(I)||l(I))?this._bodyArrayBuffer=N(I):this._bodyText=I=Object.prototype.toString.call(I):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof I=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(I)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var I=D(this);if(I)return I;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var I=D(this);return I||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(c.blob)return this.blob().then(B);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var I=D(this);if(I)return I;if(this._bodyBlob)return R(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(K(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(C)}),this.json=function(){return this.text().then(JSON.parse)},this}var b=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function $(I){var k=I.toUpperCase();return b.indexOf(k)>-1?k:I}function A(I,k){if(!(this instanceof A))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');k=k||{};var q=k.body;if(I instanceof A){if(I.bodyUsed)throw new TypeError("Already read");this.url=I.url,this.credentials=I.credentials,k.headers||(this.headers=new E(I.headers)),this.method=I.method,this.mode=I.mode,this.signal=I.signal,!q&&I._bodyInit!=null&&(q=I._bodyInit,I.bodyUsed=!0)}else this.url=String(I);if(this.credentials=k.credentials||this.credentials||"same-origin",(k.headers||!this.headers)&&(this.headers=new E(k.headers)),this.method=$(k.method||this.method||"GET"),this.mode=k.mode||this.mode||null,this.signal=k.signal||this.signal||function(){if("AbortController"in a){var V=new AbortController;return V.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&q)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(q),(this.method==="GET"||this.method==="HEAD")&&(k.cache==="no-store"||k.cache==="no-cache")){var j=/([?&])_=[^&]*/;if(j.test(this.url))this.url=this.url.replace(j,"$1_="+new Date().getTime());else{var Y=/\?/;this.url+=(Y.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}A.prototype.clone=function(){return new A(this,{body:this._bodyInit})};function C(I){var k=new FormData;return I.trim().split("&").forEach(function(q){if(q){var j=q.split("="),Y=j.shift().replace(/\+/g," "),V=j.join("=").replace(/\+/g," ");k.append(decodeURIComponent(Y),decodeURIComponent(V))}}),k}function L(I){var k=new E,q=I.replace(/\r?\n[\t ]+/g," ");return q.split("\r").map(function(j){return j.indexOf(`
177
- `)===0?j.substr(1,j.length):j}).forEach(function(j){var Y=j.split(":"),V=Y.shift().trim();if(V){var ae=Y.join(":").trim();try{k.append(V,ae)}catch(S){console.warn("Response "+S.message)}}}),k}X.call(A.prototype);function O(I,k){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(k||(k={}),this.type="default",this.status=k.status===void 0?200:k.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=k.statusText===void 0?"":""+k.statusText,this.headers=new E(k.headers),this.url=k.url||"",this._initBody(I)}X.call(O.prototype),O.prototype.clone=function(){return new O(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new E(this.headers),url:this.url})},O.error=function(){var I=new O(null,{status:200,statusText:""});return I.ok=!1,I.status=0,I.type="error",I};var re=[301,302,303,307,308];O.redirect=function(I,k){if(re.indexOf(k)===-1)throw new RangeError("Invalid status code");return new O(null,{status:k,headers:{location:I}})},o.DOMException=a.DOMException;try{new o.DOMException}catch{o.DOMException=function(k,q){this.message=k,this.name=q;var j=Error(k);this.stack=j.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function oe(I,k){return new Promise(function(q,j){var Y=new A(I,k);if(Y.signal&&Y.signal.aborted)return j(new o.DOMException("Aborted","AbortError"));var V=new XMLHttpRequest;function ae(){V.abort()}V.onload=function(){var F={statusText:V.statusText,headers:L(V.getAllResponseHeaders()||"")};Y.url.indexOf("file://")===0&&(V.status<200||V.status>599)?F.status=200:F.status=V.status,F.url="responseURL"in V?V.responseURL:F.headers.get("X-Request-URL");var Q="response"in V?V.response:V.responseText;setTimeout(function(){q(new O(Q,F))},0)},V.onerror=function(){setTimeout(function(){j(new TypeError("Network request failed"))},0)},V.ontimeout=function(){setTimeout(function(){j(new TypeError("Network request timed out"))},0)},V.onabort=function(){setTimeout(function(){j(new o.DOMException("Aborted","AbortError"))},0)};function S(F){try{return F===""&&a.location.href?a.location.href:F}catch{return F}}if(V.open(Y.method,S(Y.url),!0),Y.credentials==="include"?V.withCredentials=!0:Y.credentials==="omit"&&(V.withCredentials=!1),"responseType"in V&&(c.blob?V.responseType="blob":c.arrayBuffer&&(V.responseType="arraybuffer")),k&&typeof k.headers=="object"&&!(k.headers instanceof E||a.Headers&&k.headers instanceof a.Headers)){var W=[];Object.getOwnPropertyNames(k.headers).forEach(function(F){W.push(f(F)),V.setRequestHeader(F,h(k.headers[F]))}),Y.headers.forEach(function(F,Q){W.indexOf(Q)===-1&&V.setRequestHeader(Q,F)})}else Y.headers.forEach(function(F,Q){V.setRequestHeader(Q,F)});Y.signal&&(Y.signal.addEventListener("abort",ae),V.onreadystatechange=function(){V.readyState===4&&Y.signal.removeEventListener("abort",ae)}),V.send(typeof Y._bodyInit>"u"?null:Y._bodyInit)})}return oe.polyfill=!0,a.fetch||(a.fetch=oe,a.Headers=E,a.Request=A,a.Response=O),o.Headers=E,o.Request=A,o.Response=O,o.fetch=oe,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var i=n.fetch?n:r;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e}(Fr,Fr.exports)),Fr.exports}var gi=Mv();const Jr=Ii(gi),Pv=$p({__proto__:null,default:Jr},[gi]),bn=t=>{let e={};return t&&(typeof Headers<"u"&&t instanceof Headers||Pv&&gi.Headers&&t instanceof gi.Headers?e=Av(t):Array.isArray(t)?t.forEach(([n,r])=>{n&&r!==void 0&&(e[n]=r)}):e=t),e},dc=t=>t.replace(/([\s,]|#[^\n\r]+)+/g," ").trim(),kv=t=>{if(!Array.isArray(t.query)){const r=t,i=[`query=${encodeURIComponent(dc(r.query))}`];return t.variables&&i.push(`variables=${encodeURIComponent(r.jsonSerializer.stringify(r.variables))}`),r.operationName&&i.push(`operationName=${encodeURIComponent(r.operationName)}`),i.join("&")}if(typeof t.variables<"u"&&!Array.isArray(t.variables))throw new Error("Cannot create query with given variable type, array expected");const e=t,n=t.query.reduce((r,i,s)=>(r.push({query:dc(i),variables:e.variables?e.jsonSerializer.stringify(e.variables[s]):void 0}),r),[]);return`query=${encodeURIComponent(e.jsonSerializer.stringify(n))}`},$v=t=>async e=>{const{url:n,query:r,variables:i,operationName:s,fetch:o,fetchOptions:a,middleware:c}=e,u={...e.headers};let d="",l;t==="POST"?(l=Uv(r,i,s,a.jsonSerializer),typeof l=="string"&&(u["Content-Type"]="application/json")):d=kv({query:r,variables:i,operationName:s,jsonSerializer:a.jsonSerializer??Vo});const f={method:t,headers:u,body:l,...a};let h=n,g=f;if(c){const E=await Promise.resolve(c({...f,url:n,operationName:s,variables:i})),{url:D,...P}=E;h=D,g=P}return d&&(h=`${h}?${d}`),await o(h,g)};class id{constructor(e,n={}){this.url=e,this.requestConfig=n,this.rawRequest=async(...r)=>{const[i,s,o]=r,a=Cv(i,s,o),{headers:c,fetch:u=Jr,method:d="POST",requestMiddleware:l,responseMiddleware:f,...h}=this.requestConfig,{url:g}=this;a.signal!==void 0&&(h.signal=a.signal);const{operationName:E}=gs(a.query);return ys({url:g,query:a.query,variables:a.variables,headers:{...bn(vs(c)),...bn(a.requestHeaders)},operationName:E,fetch:u,method:d,fetchOptions:h,middleware:l}).then(D=>(f&&f(D),D)).catch(D=>{throw f&&f(D),D})}}async request(e,...n){const[r,i]=n,s=Rv(e,r,i),{headers:o,fetch:a=Jr,method:c="POST",requestMiddleware:u,responseMiddleware:d,...l}=this.requestConfig,{url:f}=this;s.signal!==void 0&&(l.signal=s.signal);const{query:h,operationName:g}=gs(s.document);return ys({url:f,query:h,variables:s.variables,headers:{...bn(vs(o)),...bn(s.requestHeaders)},operationName:g,fetch:a,method:c,fetchOptions:l,middleware:u}).then(E=>(d&&d(E),E.data)).catch(E=>{throw d&&d(E),E})}batchRequests(e,n){const r=Lv(e,n),{headers:i,...s}=this.requestConfig;r.signal!==void 0&&(s.signal=r.signal);const o=r.documents.map(({document:c})=>gs(c).query),a=r.documents.map(({variables:c})=>c);return ys({url:this.url,query:o,variables:a,headers:{...bn(vs(i)),...bn(r.requestHeaders)},operationName:void 0,fetch:this.requestConfig.fetch??Jr,method:this.requestConfig.method||"POST",fetchOptions:s,middleware:this.requestConfig.requestMiddleware}).then(c=>(this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(c),c.data)).catch(c=>{throw this.requestConfig.responseMiddleware&&this.requestConfig.responseMiddleware(c),c})}setHeaders(e){return this.requestConfig.headers=e,this}setHeader(e,n){const{headers:r}=this.requestConfig;return r?r[e]=n:this.requestConfig.headers={[e]:n},this}setEndpoint(e){return this.url=e,this}}const ys=async t=>{const{query:e,variables:n,fetchOptions:r}=t,i=$v(Ov(t.method??"post")),s=Array.isArray(t.query),o=await i(t),a=await Fv(o,r.jsonSerializer??Vo),c=Array.isArray(a)?!a.some(({data:d})=>!d):!!a.data,u=Array.isArray(a)||!a.errors||Array.isArray(a.errors)&&!a.errors.length||r.errorPolicy==="all"||r.errorPolicy==="ignore";if(o.ok&&u&&c){const{errors:d,...l}=(Array.isArray(a),a),f=r.errorPolicy==="ignore"?l:a;return{...s?{data:f}:f,headers:o.headers,status:o.status}}else{const d=typeof a=="string"?{error:a}:a;throw new On({...d,status:o.status,headers:o.headers},{query:e,variables:n})}};async function SS(t,e,...n){const r=xv(t,e,...n);return new id(r.url).request({...r})}const Uv=(t,e,n,r)=>{const i=r??Vo;if(!Array.isArray(t))return i.stringify({query:t,variables:e,operationName:n});if(typeof e<"u"&&!Array.isArray(e))throw new Error("Cannot create request body with given variable type, array expected");const s=t.reduce((o,a,c)=>(o.push({query:a,variables:e?e[c]:void 0}),o),[]);return i.stringify(s)},Fv=async(t,e)=>{let n;return t.headers.forEach((r,i)=>{i.toLowerCase()==="content-type"&&(n=r)}),n&&(n.toLowerCase().startsWith("application/json")||n.toLowerCase().startsWith("application/graphql+json")||n.toLowerCase().startsWith("application/graphql-response+json"))?e.parse(await t.text()):t.text()},vs=t=>typeof t=="function"?t():t,Nt=(t,...e)=>t.reduce((n,r,i)=>`${n}${r}${i in e?String(e[i]):""}`,"");async function nt(t,e,n,r){const i=new id(t,{fetch,headers:r||{}}),{errors:s,...o}=await i.request(e,n),a={...o};return s!=null&&s.length&&(a.errors=s.map(({message:c,...u})=>new z(c,u))),a}function Wr(t,e){return t instanceof st?Object.entries(t.getFields()).map(([n,r])=>{const i=r.type instanceof ue?r.type.ofType:r.type;if(i instanceof st||i instanceof Dn)return`${n} { ${Wr(i,e)} }`;if(i instanceof ze){const s=i.ofType instanceof ue?i.ofType.ofType:i.ofType;if(s instanceof Lt)return n;if(s instanceof st||s instanceof Dn)return`${n} { ${Wr(s,e)} }`;throw new Error(`List item type ${s.toString()} is not handled`)}return n}).join(" "):t instanceof Dn?t.getTypes().map(n=>`... on ${e?`${e}_`:""}${n.name} { ${Wr(n,e)} }`).join(" "):""}function sd(t,e,n){const r=Xc(t.name),i=t.specifications.at(-1);if(!i)throw new Error("No document model specification found");const s=`${i.state.global.schema} type Query { ${r}: ${r}State }`,a=Nv(s).getQueryType();if(!a)throw new Error("No query type found");const u=a.getFields()[r];if(!u)throw new Error("No state query found");return Wr(u.type,e)}async function Kn(t,e){var i;const n=await((i=e.generateJwtHandler)==null?void 0:i.call(e,t)),r=n?{Authorization:`Bearer ${n}`}:{};return od(t,r)}async function od(t,e){var r,i;let n;try{const s=await nt(t,Nt`
178
- query getDrive {
179
- drive {
180
- id
181
- name
182
- icon
183
- slug
184
- meta {
185
- preferredEditor
186
- }
187
- }
188
- }
189
- `,void 0,e);if((r=s.errors)!=null&&r.length||!s.drive)throw((i=s.errors)==null?void 0:i.at(0))??new Error("Drive not found");n=s.drive}catch(s){throw pe.error(s),new Error("Couldn't find drive info")}return n}async function fc(t,e,n){var u;const{documentModel:r,utils:i}=n,s=Xc(r.name),o=sd(r,s),a=await nt(t,Nt`
190
- query ($id: String!) {
191
- document(id: $id) {
192
- id
193
- name
194
- created
195
- documentType
196
- lastModified
197
- revision
198
- operations {
199
- id
200
- error
201
- hash
202
- index
203
- skip
204
- timestamp
205
- type
206
- inputText
207
- context {
208
- signer {
209
- user {
210
- address
211
- networkId
212
- chainId
213
- }
214
- app {
215
- name
216
- key
217
- }
218
- signatures
219
- }
220
- }
221
- }
222
- ... on ${s} {
223
- state {
224
- ${o}
225
- }
226
- initialState {
227
- ${o}
228
- }
229
- }
230
- }
231
- }
232
- `,{id:e}),c=a.document?{clipboard:a.document.clipboard,header:a.document.header,initialState:{...i.createExtendedState({state:i.createState({global:a.document.initialState})})},operations:{global:a.document.operations.map(({inputText:d,...l})=>({...l,error:l.error??void 0,scope:"global",input:JSON.parse(d)})),local:[]},state:a.document.state}:null;return(u=a==null?void 0:a.document)!=null&&u.attachments&&(c.attachments=a.document.attachments),{...a,document:c}}var pr,dt,mn,Ks,ad;class Bv{constructor(e){et(this,mn);et(this,pr);et(this,dt,new Map);Ht(this,pr,e)}async fetchDrive(e){const n=he(this,dt).get(e);if(!n)return new Wt(e);const r=await this.fetchDocument(e,e,To);if(r instanceof Error)return r;const i={...r,readContext:n.context};return n.drive=i,i}async fetchDocument(e,n,r){const i=he(this,dt).get(e);if(!i)return new Wt(e);let s;try{s=he(this,pr).call(this,r)}catch(u){return new Gm(r,u)}const{url:o}=i.context,{errors:a,document:c}=await fc(o,n,s);if(a){const u=ut(this,mn,Ks).call(this,a,e,n);if(u instanceof Ci)return u;if(u)throw u}return c||new ja(e,n)}async addReadDrive(e,n){let r;n!=null&&n.expectedDriveInfo?r=n.expectedDriveInfo.id:r=(await od(e)).id;const i=await ut(this,mn,ad).call(this,r,e);if(i instanceof Error)throw i;if(!i)throw new Wt(r);he(this,dt).set(r,{drive:i,context:{...n,url:e}})}async getReadDrives(){return Promise.resolve([...he(this,dt).keys()])}async getReadDrive(e){const n=he(this,dt).get(e);return Promise.resolve(n?{...n.drive,readContext:n.context}:new Wt(e))}async getReadDriveBySlug(e){const n=[...he(this,dt).values()].find(({drive:r})=>r.header.slug===e);return Promise.resolve(n?{...n.drive,readContext:n.context}:new ig(e))}getReadDriveContext(e){var n;return Promise.resolve(((n=he(this,dt).get(e))==null?void 0:n.context)??new Wt(e))}deleteReadDrive(e){const n=he(this,dt).delete(e);return Promise.resolve(n?void 0:new Wt(e))}}pr=new WeakMap,dt=new WeakMap,mn=new WeakSet,Ks=function(e,n,r){for(const s of e){if(s.message===`Drive with id ${n} not found`)return new Wt(n);if(r&&s.message===`Document with id ${r} not found`)return new ja(n,r)}const i=e.at(0);if(i)return i},ad=async function(e,n){const{errors:r,document:i}=await fc(n,e,tg);return(r?ut(this,mn,Ks).call(this,r,e):void 0)||i};function jv(t){var e,n,r,Kr,Qr,o;return o=class extends t{constructor(...u){super(...u);et(this,r);et(this,e);et(this,n,new Set);Ht(this,e,new Bv(this.getDocumentModelModule.bind(this))),ut(this,r,Kr).call(this).then(d=>{d.length&&ut(this,r,Qr).call(this,d,"add")}).catch(pe.error)}getReadDrives(){return he(this,e).getReadDrives()}getReadDrive(u){return he(this,e).getReadDrive(u)}getReadDriveBySlug(u){return he(this,e).getReadDriveBySlug(u)}getReadDriveContext(u){return he(this,e).getReadDriveContext(u)}async addReadDrive(u,d){await he(this,e).addReadDrive(u,d),ut(this,r,Qr).call(this,await ut(this,r,Kr).call(this),"add")}fetchDrive(u){return he(this,e).fetchDrive(u)}fetchDocument(u,d,l){return he(this,e).fetchDocument(u,d,l)}async deleteReadDrive(u){const d=await he(this,e).deleteReadDrive(u);if(d)return d;ut(this,r,Qr).call(this,await ut(this,r,Kr).call(this),"delete")}async migrateReadDrive(u,d){const l=await this.getReadDriveContext(u);if(l instanceof Error)return l;const{url:f,...h}=l;try{return await this.addRemoteDrive(f,d)}catch(g){throw pe.error(g),await this.addReadDrive(l.url,h),g}}onReadDrivesUpdate(u){return he(this,n).add(u),Promise.resolve(()=>he(this,n).delete(u))}},e=new WeakMap,n=new WeakMap,r=new WeakSet,Kr=async function(){const u=await this.getReadDrives();return(await Promise.all(u.map(l=>this.getReadDrive(l)))).filter(l=>!(l instanceof Error))},Qr=function(u,d){he(this,n).forEach(l=>l(u,d))},o}function Vv(t){return typeof t.getReadDrives=="function"}class Gv{constructor(e,n,r){U(this,"server");U(this,"delegate");U(this,"defaultRemoteDrives",new Map);U(this,"removeOldRemoteDrivesConfig");var i,s;if(this.server=e,this.delegate=n,(i=r==null?void 0:r.defaultDrives)!=null&&i.remoteDrives)for(const o of r.defaultDrives.remoteDrives)this.defaultRemoteDrives.set(o.url,{...o,status:"PENDING"});this.removeOldRemoteDrivesConfig=((s=r==null?void 0:r.defaultDrives)==null?void 0:s.removeOldRemoteDrives)||{strategy:"preserve-all"}}getDefaultRemoteDrives(){return new Map(JSON.parse(JSON.stringify(Array.from(this.defaultRemoteDrives))))}async deleteDriveById(e){try{await this.server.deleteDrive(e)}catch(n){pe.error(n)}}async preserveDrivesById(e,n,r="detach"){const i=n.map(a=>this.server.getDrive(a)),o=(await Promise.all(i)).filter(a=>a.state.local.listeners.length>0||a.state.local.triggers.length>0).filter(a=>!e.includes(a.header.id)).map(a=>a.header.id);r==="detach"?await this.detachDrivesById(o):await this.removeDrivesById(o)}async removeDrivesById(e){for(const n of e)await this.deleteDriveById(n)}async detachDrivesById(e){const n=e.map(r=>this.delegate.detachDrive(r));await Promise.all(n)}async removeOldremoteDrives(){const e=await this.server.getDrives();switch(this.removeOldRemoteDrivesConfig.strategy){case"preserve-by-id-and-detach":case"preserve-by-id":{const n=this.removeOldRemoteDrivesConfig.strategy==="preserve-by-id-and-detach"?"detach":"remove";await this.preserveDrivesById(this.removeOldRemoteDrivesConfig.ids,e,n);break}case"preserve-by-url-and-detach":case"preserve-by-url":{const n=this.removeOldRemoteDrivesConfig.strategy==="preserve-by-url-and-detach"?"detach":"remove",r=this.removeOldRemoteDrivesConfig.urls.map(s=>Kn(s,this.server)),i=(await Promise.all(r)).map(s=>s.id);await this.preserveDrivesById(i,e,n);break}case"remove-by-id":{const n=this.removeOldRemoteDrivesConfig.ids.filter(r=>e.includes(r));await this.removeDrivesById(n);break}case"remove-by-url":{const n=this.removeOldRemoteDrivesConfig.urls.map(s=>Kn(s,this.server)),i=(await Promise.all(n)).map(s=>s.id).filter(s=>e.includes(s));await this.removeDrivesById(i);break}case"remove-all":{const n=e.map(s=>this.server.getDrive(s)),i=(await Promise.all(n)).filter(s=>s.state.local.listeners.length>0||s.state.local.triggers.length>0).map(s=>s.header.id);await this.removeDrivesById(i);break}case"detach-by-id":{const r=this.removeOldRemoteDrivesConfig.ids.filter(i=>e.includes(i)).map(i=>this.delegate.detachDrive(i));await Promise.all(r);break}case"detach-by-url":{const n=this.removeOldRemoteDrivesConfig.urls.map(o=>Kn(o,this.server)),s=(await Promise.all(n)).map(o=>o.id).filter(o=>e.includes(o)).map(o=>this.delegate.detachDrive(o));await Promise.all(s);break}}}async setAllDefaultDrivesAccessLevel(e){const n=this.defaultRemoteDrives.values();for(const r of n)await this.setDefaultDriveAccessLevel(r.url,e)}async setDefaultDriveAccessLevel(e,n){const r=this.defaultRemoteDrives.get(e);if(r&&r.options.accessLevel!==n){const i={...r,options:{...r.options,accessLevel:n}};this.defaultRemoteDrives.set(e,i),await this.initializeDefaultRemoteDrives([i])}}async initializeDefaultRemoteDrives(e=Array.from(this.defaultRemoteDrives.values())){const n=await this.server.getDrives(),r=Vv(this.server)?this.server:void 0,i=await(r==null?void 0:r.getReadDrives());for(const s of e){let o={...s};try{const a=s.metadata??await Kn(s.url,this.server);o={...s,metadata:a},this.defaultRemoteDrives.set(s.url,o);const c=n.includes(a.id),u=i==null?void 0:i.includes(a.id),d=s.options.accessLevel!==void 0,l=r&&s.options.accessLevel==="READ",f=l?u:c;if(d&&(l?c:u))try{await(l?this.server.deleteDrive(a.id):r==null?void 0:r.deleteReadDrive(a.id))}catch(g){pe.error(g)}if(f){o.status="ALREADY_ADDED",this.defaultRemoteDrives.set(s.url,o),this.delegate.emit("ALREADY_ADDED",this.defaultRemoteDrives,o,a.id,a.name);continue}o.status="ADDING",this.defaultRemoteDrives.set(s.url,o),this.delegate.emit("ADDING",this.defaultRemoteDrives,o),s.options.accessLevel==="READ"&&r||l?await r.addReadDrive(s.url,{...s.options,expectedDriveInfo:a}):await this.server.addRemoteDrive(s.url,{...s.options,expectedDriveInfo:a}),o.status="SUCCESS",this.defaultRemoteDrives.set(s.url,o),this.delegate.emit("SUCCESS",this.defaultRemoteDrives,o,a.id,a.name)}catch(a){o.status="ERROR",this.defaultRemoteDrives.set(s.url,o),this.delegate.emit("ERROR",this.defaultRemoteDrives,o,void 0,void 0,a)}}}}var on;(function(t){t.useMessageChannel=typeof MessageChannel>"u"?new Error("MessageChannel is not supported"):r=>{const i=new AbortController,s=i.signal,o=new MessageChannel;return o.port1.postMessage(null),o.port2.addEventListener("message",()=>{r(),o.port1.close(),o.port2.close()},{once:!0,signal:s}),o.port2.start(),()=>i.abort()},t.usePostMessage=(()=>{const r=typeof window=="object"&&window||typeof global=="object"&&global||typeof self=="object"&&self;if(!r)return new Error("No global object found");const i=r;if(!i.postMessage||!i.addEventListener||i.importScripts)return new Error("postMessage is not supported");let s=0;const o=new Map;function a(){return s===9007199254740991?0:++s}const c="com.usePostMessage"+Math.random();return i.addEventListener("message",u=>{const d=u;if(typeof d.data!="string"||d.source!==i||!d.data.startsWith(c))return;const l=d.data.split(":").at(1);if(l===void 0)return;const f=+l,h=o.get(f);h&&(h(),o.delete(f))},!1),u=>{const d=a();return o.set(d,u),i.postMessage(c+":"+d,{targetOrigin:"*"}),()=>{o.delete(d)}}})(),t.useSetImmediate=typeof window<"u"?new Error("setImmediate is not supported on the browser"):typeof setImmediate>"u"?new Error("setImmediate is not supported"):r=>{const i=setImmediate(r);return()=>clearImmediate(i)},t.useSetTimeout=r=>{const i=setTimeout(r,0);return()=>clearTimeout(i)};function e(r){return t.useSetImmediate instanceof Error?t.useMessageChannel instanceof Error?t.usePostMessage instanceof Error?t.useSetTimeout(r):t.usePostMessage(r):t.useMessageChannel(r):t.useSetImmediate(r)}t.runAsap=e;function n(r,i=e){if(i instanceof Error)throw new Error("queueMethod is not supported",{cause:i});return new Promise((s,o)=>{i(()=>{r().then(s).catch(o)})})}t.runAsapAsync=n})(on||(on={}));const zv=on.runAsapAsync;function It(t){return t.header.documentType===To}function yi(t,e){const n=Object.keys(t).reduce((i,s)=>{var a;const o=s;return i[o]=((a=t[o].at(-1))==null?void 0:a.index)??0,i},{}),r=e.find(i=>i.index<(n[i.scope]??0));if(r)throw new Ge("ERROR",r,`Tried to add operation with index ${r.index} and document is at index ${n[r.scope]}`);return e.sort((i,s)=>i.index-s.index).reduce((i,s)=>{const o=i[s.scope]||[];return{...i,[s.scope]:[...o,s]}},t)}function Yv(t,e){return new Date(t)<new Date(e)}function Pn(t){const e=t==null?void 0:t.at(-1);return e?e.index+1:0}const qv=1500,pc=100,Hv=50;let Es;const fe=()=>(Es||(Es=wt(["PullResponderTransmitter","static"])),Es);class He{constructor(e,n){U(this,"logger",wt(["PullResponderTransmitter",Math.floor(Math.random()*999).toString()]));U(this,"listener");U(this,"manager");this.listener=e,this.manager=n,this.logger.verbose(`constructor(listener: ${e.listenerId})`)}static async getAuthHeaders(e,n){if(!(n!=null&&n.generateJwtHandler))return fe().verbose(`No JWT handler available for ${e}`),{};try{const r=await n.generateJwtHandler(e);return r?{Authorization:`Bearer ${r}`}:(fe().verbose(`No JWT generated for ${e}`),{})}catch(r){return fe().error(`Error generating JWT for ${e}:`,r),{}}}async requestWithAuth(e,n,r){var a;const i=await He.getAuthHeaders(e,this.manager),s=await nt(e,n,r,i),o=(a=s.errors)==null?void 0:a.at(0);if(o!=null&&o.message.includes("Unauthorized")){const c=await He.getAuthHeaders(e,this.manager);return nt(e,n,r,c)}return s}getStrands(e){return this.logger.verbose(`[SYNC DEBUG] PullResponderTransmitter.getStrands called for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}, options: ${JSON.stringify(e||{})}`),this.manager.getStrands(this.listener.driveId,this.listener.listenerId,e).then(n=>{if(this.logger.verbose(`[SYNC DEBUG] PullResponderTransmitter.getStrands returning ${n.length} strands for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}`),n.length===0)this.logger.verbose(`[SYNC DEBUG] No strands returned for drive: ${this.listener.driveId}, listener: ${this.listener.listenerId}`);else for(const r of n)this.logger.verbose(`[SYNC DEBUG] Strand for drive: ${r.driveId}, document: ${r.documentId}, scope: ${r.scope}, operations: ${r.operations.length}`);return n})}disconnect(){return Promise.resolve()}async processAcknowledge(e,n,r){this.logger.verbose(`processAcknowledge(drive: ${e}, listener: ${n})`,r);let i=!0;for(const s of r)try{await this.manager.updateListenerRevision(n,e,{documentId:s.documentId,scope:s.scope,branch:s.branch},s.revision)}catch(o){this.logger.warn("Error acknowledging sync unit",o,s),i=!1;continue}return i}static async registerPullResponder(e,n,r,i,s){var u,d;fe().verbose(`registerPullResponder(url: ${n})`,r);const o=await this.getAuthHeaders(n,s),a=await nt(n,Nt`
233
- mutation registerPullResponderListener(
234
- $filter: InputListenerFilter!
235
- $listenerId: String
236
- ) {
237
- registerPullResponderListener(
238
- filter: $filter
239
- listenerId: $listenerId
240
- ) {
241
- listenerId
242
- }
243
- }
244
- `,{filter:r,listenerId:i},o),c=(u=a.errors)==null?void 0:u.at(0);if(c){if(c.message.includes("Unauthorized")){const l=await this.getAuthHeaders(n,s),f=await nt(n,Nt`
245
- mutation registerPullResponderListener(
246
- $filter: InputListenerFilter!
247
- $listenerId: String
248
- ) {
249
- registerPullResponderListener(
250
- filter: $filter
251
- listenerId: $listenerId
252
- ) {
253
- listenerId
254
- }
255
- }
256
- `,{filter:r,listenerId:i},l);if((d=f.errors)!=null&&d.at(0))throw f.errors[0];if(!f.registerPullResponderListener)throw new Error("Error registering listener");return f.registerPullResponderListener.listenerId}throw c}if(!a.registerPullResponderListener)throw new Error("Error registering listener");return a.registerPullResponderListener.listenerId}static async pullStrands(e,n,r,i,s){var d,l;fe().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands called for drive: ${e}, url: ${n}, listener: ${r}, options: ${JSON.stringify(i||{})}`);const o=await this.getAuthHeaders(n,s),a=await nt(n,Nt`
257
- query strands($listenerId: ID!) {
258
- system {
259
- sync {
260
- strands(listenerId: $listenerId) {
261
- driveId
262
- documentId
263
- documentType
264
- scope
265
- branch
266
- operations {
267
- id
268
- timestamp
269
- skip
270
- type
271
- input
272
- hash
273
- index
274
- context {
275
- signer {
276
- user {
277
- address
278
- networkId
279
- chainId
280
- }
281
- app {
282
- name
283
- key
284
- }
285
- signatures
286
- }
287
- }
288
- }
289
- }
290
- }
291
- }
292
- }
293
- `,{listenerId:r},o),c=(d=a.errors)==null?void 0:d.at(0);if(c){if(c.message.includes("Unauthorized")){const f=await this.getAuthHeaders(n,s),h=await nt(n,Nt`
294
- query strands($listenerId: ID!) {
295
- system {
296
- sync {
297
- strands(listenerId: $listenerId) {
298
- driveId
299
- documentId
300
- documentType
301
- scope
302
- branch
303
- operations {
304
- id
305
- timestamp
306
- skip
307
- type
308
- input
309
- hash
310
- index
311
- context {
312
- signer {
313
- user {
314
- address
315
- networkId
316
- chainId
317
- }
318
- app {
319
- name
320
- key
321
- }
322
- signatures
323
- }
324
- }
325
- }
326
- }
327
- }
328
- }
329
- }
330
- `,{listenerId:r},f);if((l=h.errors)!=null&&l.at(0))throw h.errors[0];return h.system?h.system.sync.strands.map(g=>({...g,operations:g.operations.map(E=>({...E,input:JSON.parse(E.input)}))})):[]}throw c}if(!a.system)return fe().verbose(`[SYNC DEBUG] No system data returned when pulling strands for drive: ${e}, listener: ${r}`),[];const u=a.system.sync.strands.map(f=>({...f,operations:f.operations.map(h=>({...h,input:JSON.parse(h.input)}))}));return fe().verbose(`[SYNC DEBUG] PullResponderTransmitter.pullStrands returning ${u.length} strands for drive: ${e}, listener: ${r}`),u.length>0&&fe().verbose(`[SYNC DEBUG] Strands being returned: ${u.map(f=>`${f.documentId}:${f.scope}`).join(", ")}`),u}static async acknowledgeStrands(e,n,r,i){fe().verbose(`acknowledgeStrands(url: ${e}, listener: ${n})`,r);const s=[];for(let u=0;u<r.length;u+=pc)s.push(r.slice(u,u+pc));s.length>1&&fe().verbose(`Breaking strand acknowledgement into ${s.length} chunks...`);const o=await this.getAuthHeaders(e,i);if((await Promise.allSettled(s.map(async u=>{var f,h;const d=await nt(e,Nt`
331
- mutation acknowledge(
332
- $listenerId: String!
333
- $revisions: [ListenerRevisionInput]
334
- ) {
335
- acknowledge(listenerId: $listenerId, revisions: $revisions)
336
- }
337
- `,{listenerId:n,revisions:u},o),l=(f=d.errors)==null?void 0:f.at(0);if(l){if(l.message.includes("Unauthorized")){const g=await this.getAuthHeaders(e,i),E=await nt(e,Nt`
338
- mutation acknowledge(
339
- $listenerId: String!
340
- $revisions: [ListenerRevisionInput]
341
- ) {
342
- acknowledge(listenerId: $listenerId, revisions: $revisions)
343
- }
344
- `,{listenerId:n,revisions:u},g);if((h=E.errors)!=null&&h.at(0))throw E.errors[0];if(E.acknowledge===null||!E.acknowledge)throw new Error("Error acknowledging strands");return}throw l}if(d.acknowledge===null||!d.acknowledge)throw new Error("Error acknowledging strands")}))).filter(u=>u.status==="rejected").length>0)throw new Error("Error acknowledging strands")}static async executePull(e,n,r,i,s,o,a){var g;fe().verbose(`executePull(driveId: ${e}), trigger:`,n),fe().debug(`[SYNC DEBUG] PullResponderTransmitter.executePull starting for drive: ${e}, listenerId: ${n.data.listenerId}`);const{url:c}=n.data;let u,d;const l=n.data.listenerId;try{u=await He.pullStrands(e,c,l,void 0,a)}catch(E){d=E;const P=((g=d.response)==null?void 0:g.errors)??[];for(const B of P)if(B.message==="Listener not found"){fe().verbose(`[SYNC DEBUG] Auto-registering pull responder for drive: ${e}`),await He.registerPullResponder(n.driveId,c,n.filter,l);try{u=await He.pullStrands(e,c,l,void 0,a),fe().verbose(`Successfully auto-registered and pulled strands for drive: ${e}, listenerId: ${l}`)}catch(R){return fe().error(`Could not resolve 'Listener not found' error by registering a new pull responder for drive: ${e}, listenerId: ${l}: ${R}`),i(R),!1}break}}if(!u)return fe().error(`Error pulling strands for drive, and could not auto-register: ${e}, listenerId: ${n.data.listenerId}: ${d}`),i(d),!1;if(!u.length){fe().verbose(`[SYNC DEBUG] No strands returned in pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);try{s==null||s([])}catch(E){fe().error(`Error calling onRevisions for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),i(E)}return!1}fe().verbose(`[SYNC DEBUG] Processing ${u.length} strands in pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);const f=[];for(const E of u){const D=E.operations.map(B=>({...B,scope:E.scope,branch:E.branch}));fe().verbose(`[SYNC DEBUG] Processing strand for drive: ${E.driveId}, document: ${E.documentId}, scope: ${E.scope}, with ${D.length} operations`);let P;try{const B=await r(E,{type:"trigger",trigger:n});if(B.error)throw B.error}catch(B){fe().error(`Error processing strand for drive: ${E.driveId}, document: ${E.documentId}, scope: ${E.scope}, with ${D.length} operations: ${B}`),P=B,i(P)}f.push({branch:E.branch,documentId:E.documentId||"",documentType:E.documentType,driveId:E.driveId,revision:Pn(D),scope:E.scope,status:P?P instanceof Ge?P.status:"ERROR":"SUCCESS",error:P})}fe().verbose("Processed strands...");try{s==null||s(f)}catch(E){fe().error(`Error calling onRevisions for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),i(E)}fe().verbose(`[SYNC DEBUG] Acknowledging ${f.length} strands for drive: ${e}, listenerId: ${n.data.listenerId}`);let h=!1;try{await He.acknowledgeStrands(c,n.data.listenerId,f.map(E=>{const{error:D,...P}=E;return P}),a),h=!0}catch(E){fe().error(`Error acknowledging strands for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),i(E)}h?fe().verbose(`[SYNC DEBUG] Successfully acknowledged strands for drive: ${e}, listenerId: ${n.data.listenerId}`):fe().error("Failed to acknowledge strands");try{o==null||o(h)}catch(E){fe().error(`Error calling onAcknowledge for drive: ${e}, listenerId: ${n.data.listenerId}: ${E}`),i(E)}return u.length>0}static setupPull(e,n,r,i,s,o,a){fe().verbose(`[SYNC DEBUG] PullResponderTransmitter.setupPull initiated for drive: ${e}, listenerId: ${n.data.listenerId}`);const{interval:c}=n.data;let u=qv;if(c)try{const h=parseInt(c);h&&(u=h)}catch{}fe().verbose(`[SYNC DEBUG] Pull interval set to ${u}ms for drive: ${e}, listenerId: ${n.data.listenerId}`);let d=!1,l;return(async()=>{for(;!d;){fe().verbose(`[SYNC DEBUG] Starting pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);let h=0,g=!0;for(;g&&!d&&h<Hv;)h++,g=await this.executePull(e,n,r,i,s,o,a),g&&fe().verbose(`[SYNC DEBUG] More strands available, continuing pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}`);fe().verbose(`[SYNC DEBUG] Completed pull cycle for drive: ${e}, listenerId: ${n.data.listenerId}, waiting ${u}ms for next cycle`),await new Promise(E=>{fe().verbose(`Scheduling next pull in ${u} ms`),l=setTimeout(E,u)})}})().catch(h=>{fe().error(`Error in executeLoop for drive: ${e}, listenerId: ${n.data.listenerId}: ${h}`)}),()=>{fe().verbose(`[SYNC DEBUG] Cancelling pull loop for drive: ${e}, listenerId: ${n.data.listenerId}`),d=!0,l!==void 0&&clearTimeout(l)}}static async createPullResponderTrigger(e,n,r,i){fe().verbose(`createPullResponderTrigger(drive: ${e}, url: ${n})`);const{pullFilter:s,pullInterval:o}=r,a=s??{documentId:["*"],documentType:["*"],branch:["*"],scope:["*"]},c=await He.registerPullResponder(e,n,a,void 0,i);return{id:rt(),type:"PullResponder",driveId:e,filter:a,data:{url:n,listenerId:c,interval:(o==null?void 0:o.toString())??""}}}static isPullResponderTrigger(e){return e.type==="PullResponder"}}var _s,hc;function Jv(){return hc||(hc=1,_s={space:"",cycles:!1,replacer:(t,e)=>e,stringify:JSON.stringify}),_s}var bs,mc;function Qt(){return mc||(mc=1,bs={isArray:Array.isArray,assign:Object.assign,isObject:t=>typeof t=="object",isFunction:t=>typeof t=="function",isBoolean:t=>typeof t=="boolean",isRegex:t=>t instanceof RegExp,keys:Object.keys}),bs}var ws,gc;function Wv(){if(gc)return ws;gc=1;const t=Jv(),e=Qt().isFunction,n=Qt().isBoolean,r=Qt().isObject,i=Qt().isArray,s=Qt().isRegex,o=Qt().assign,a=Qt().keys;function c(d){return d==null?d:s(d)?d.toString():d.toJSON?d.toJSON():d}function u(d,l){l=l||o({},t),e(l)&&(l={compare:l});const f=l.space||t.space,h=n(l.cycles)?l.cycles:t.cycles,g=l.replacer||t.replacer,E=l.stringify||t.stringify,D=l.compare&&function(B){return function(R){return function(K,N){const X={key:K,value:R[K]},b={key:N,value:R[N]};return B(X,b)}}}(l.compare);h||E(d);const P=[];return function B(R,K,N,X){const b=f?`
345
- `+new Array(X+1).join(f):"",$=f?": ":":";if(N=c(N),N=g.call(R,K,N),N!==void 0){if(!r(N)||N===null)return E(N);if(i(N)){const A=[];for(let C=0;C<N.length;C++){const L=B(N,C,N[C],X+1)||E(null);A.push(b+f+L)}return"["+A.join(",")+b+"]"}else{if(h){if(P.indexOf(N)!==-1)return E("[Circular]");P.push(N)}const A=a(N).sort(D&&D(N)),C=[];for(let L=0;L<A.length;L++){const O=A[L],re=B(N,O,N[O],X+1);if(!re)continue;const oe=E(O)+$+re;C.push(b+f+oe)}return P.splice(P.indexOf(N),1),"{"+C.join(",")+b+"}"}}}({"":d},"",d,0)}return ws=u,ws}var Kv=Wv();const Qv=Ii(Kv),yc=10;class cd{constructor(e,n){U(this,"targetURL");U(this,"manager");U(this,"logger",wt(["SwitchboardPushTransmitter",Math.floor(Math.random()*999).toString()]));this.targetURL=e,this.manager=n}async getAuthHeaders(){var e;if(!((e=this.manager)!=null&&e.generateJwtHandler))return this.logger.verbose(`No JWT handler available for ${this.targetURL}`),{};try{const n=await this.manager.generateJwtHandler(this.targetURL);return n?{Authorization:`Bearer ${n}`}:(this.logger.verbose(`No JWT generated for ${this.targetURL}`),{})}catch(n){return this.logger.error(`Error generating JWT for ${this.targetURL}:`,n),{}}}async requestWithAuth(e,n){var o;const r=await this.getAuthHeaders(),i=await nt(this.targetURL,e,n,r),s=(o=i.errors)==null?void 0:o.at(0);if(s!=null&&s.message.includes("Unauthorized")){const a=await this.getAuthHeaders();return nt(this.targetURL,e,n,a)}return i}async transmit(e,n){var s;if(n.type==="trigger"&&((s=n.trigger.data)==null?void 0:s.url)===this.targetURL)return this.logger.verbose(`Cutting trigger loop from ${this.targetURL}.`),e.map(o=>({driveId:o.driveId,documentId:o.documentId,documentType:o.documentType,scope:o.scope,branch:o.branch,status:"SUCCESS",revision:Pn(o.operations)}));const r=[];let i=0;for(let o=0;i<=yc&&o<e.length;o++){const a=e.at(o);if(!a)break;const c=Math.min(yc-i,a.operations.length);r.push({...a,operations:a.operations.slice(0,c)}),i+=c}this.logger.verbose(` Total update: [${e.map(o=>o.operations.length).join(", ")}] operations`),this.logger.verbose(`Culled update: [${r.map(o=>o.operations.length).join(", ")}] operations`);try{const o=await this.requestWithAuth(Nt`
346
- mutation pushUpdates($strands: [InputStrandUpdate!]) {
347
- pushUpdates(strands: $strands) {
348
- driveId
349
- documentId
350
- documentType
351
- scope
352
- branch
353
- status
354
- revision
355
- error
356
- }
357
- }
358
- `,{strands:r.map(a=>({...a,operations:a.operations.map(c=>({...c,input:Qv(c.input)}))}))});if(!o.pushUpdates)throw new Error("Couldn't update listener revision");return o.pushUpdates}catch(o){throw this.logger.error(o),o}}}var vc;(function(t){t[t.Internal=0]="Internal",t[t.SwitchboardPush=1]="SwitchboardPush",t[t.PullResponder=2]="PullResponder",t[t.SecureConnect=3]="SecureConnect",t[t.MatrixConnect=4]="MatrixConnect",t[t.RESTWebhook=5]="RESTWebhook"})(vc||(vc={}));const vi={sequentialUpdates:!0};function Ec(t,e){return e?Object.keys(t).reduce((n,r)=>{const i=e[r];return i!==void 0&&(n[r]=t[r].filter(s=>s.index<=i)),n},{global:[],local:[]}):t}function Ss(t,e){return!e||Object.entries(e).find(([n,r])=>{const i=t.operations[n].at(-1);return r===-1?i!==void 0:(i==null?void 0:i.index)!==r})===void 0}function _c(t){return{id:Xv(t),documentType:Zv(t),document:eE(t)}}function Xv(t){return"id"in t?t.id:"header"in t?t.header.id:"document"in t?t.document.header.id:void 0}function Zv(t){return"documentType"in t?t.documentType:"header"in t?t.header.documentType:t.document.header.documentType}function eE(t){return"document"in t?t.document:void 0}class tE{constructor(e,n,r,i,s,o,a,c,u){U(this,"logger",wt(["BaseDocumentDriveServer"]));U(this,"documentModelModules");U(this,"legacyStorage");U(this,"documentStorage");U(this,"cache");U(this,"queueManager");U(this,"eventEmitter");U(this,"options");U(this,"listenerManager");U(this,"synchronizationManager");U(this,"generateJwtHandler");U(this,"defaultDrivesManager");U(this,"defaultDrivesManagerDelegate",{detachDrive:this.detachDrive.bind(this),emit:(...e)=>this.eventEmitter.emit("defaultRemoteDrive",...e)});U(this,"queueDelegate",{exists:e=>this.documentStorage.exists(e),processOperationJob:async({documentId:e,operations:n,options:r})=>{const i=await this.getDocument(e);return It(i)?this.processDriveOperations(e,n,r):this.processOperations(e,n,r)},processActionJob:async({documentId:e,actions:n,options:r})=>{const i=await this.getDocument(e);return It(i)?this.processDriveActions(e,n,r):this.processActions(e,n,r)},processDocumentJob:async({documentId:e,documentType:n,initialState:r,options:i})=>{const o=this.getDocumentModelModule(n).utils.createDocument({...r}),a=zr(e,n);o.header.id=e,o.header.sig=a.sig,o.header.documentType=n;try{const c=await this.createDocument({document:o},(i==null?void 0:i.source)??{type:"local"},r==null?void 0:r.header.meta);return{status:"SUCCESS",operations:[],document:c,signals:[]}}catch(c){const u=c instanceof Error?c:new Error(JSON.stringify(c));return{status:"ERROR",error:new Ge("ERROR",void 0,`Error creating document: ${u.message}`,u),operations:[],document:void 0,signals:[]}}},processJob:async e=>{if(al(e))return this.queueDelegate.processOperationJob(e);if(rg(e))return this.queueDelegate.processActionJob(e);if(qr(e))return this.queueDelegate.processDocumentJob(e);throw new Error("Unknown job type",e)}});U(this,"triggerMap",new Map);U(this,"initializePromise");this.documentModelModules=e,this.legacyStorage=n,this.documentStorage=r,this.cache=i,this.queueManager=s,this.eventEmitter=o,this.synchronizationManager=a,this.listenerManager=c,this.options={...u,defaultDrives:{...u==null?void 0:u.defaultDrives},listenerManager:{...vi,...u==null?void 0:u.listenerManager},jwtHandler:(u==null?void 0:u.jwtHandler)===void 0?()=>Promise.resolve(""):u.jwtHandler,taskQueueMethod:(u==null?void 0:u.taskQueueMethod)===void 0?on.runAsap:u.taskQueueMethod},this.defaultDrivesManager=new Gv(this,this.defaultDrivesManagerDelegate,u),this.initializePromise=this._initialize()}get listeners(){return this.listenerManager}initialize(){return this.initializePromise}async _initialize(){await this.listenerManager.initialize(this.handleListenerError.bind(this)),await this.queueManager.init(this.queueDelegate,r=>{this.logger.error("Error initializing queue manager",r),e.push(r)});try{await this.defaultDrivesManager.removeOldremoteDrives()}catch(r){this.logger.error(r)}const e=[],n=await this.getDrives();for(const r of n)await this._initializeDrive(r).catch(i=>{this.logger.error(`Error initializing drive ${r}`,i),e.push(i)});return this.options.defaultDrives.loadOnInit!==!1&&await this.defaultDrivesManager.initializeDefaultRemoteDrives(),e.length===0?null:e}setDocumentModelModules(e){this.documentModelModules=[...e],this.synchronizationManager.setDocumentModelModules([...e]),this.eventEmitter.emit("documentModelModules",[...e])}initializeDefaultRemoteDrives(){return this.defaultDrivesManager.initializeDefaultRemoteDrives()}getDefaultRemoteDrives(){return this.defaultDrivesManager.getDefaultRemoteDrives()}setDefaultDriveAccessLevel(e,n){return this.defaultDrivesManager.setDefaultDriveAccessLevel(e,n)}setAllDefaultDrivesAccessLevel(e){return this.defaultDrivesManager.setAllDefaultDrivesAccessLevel(e)}getOperationSource(e){return e.type==="local"?"push":"pull"}handleListenerError(e,n,r){this.logger.error(`Listener ${r.listener.label??r.listener.listenerId} error:`,e);const i=e instanceof Ge?e.status:"ERROR";this.synchronizationManager.updateSyncStatus(n,{push:i},e)}shouldSyncRemoteDrive(e){return e.state.local.availableOffline&&e.state.local.triggers.length>0}async startSyncRemoteDrive(e){let n=this.triggerMap.get(e);const r=await this.synchronizationManager.getSynchronizationUnitsIds(e),i=await this.getDrive(e);for(const s of i.state.local.triggers)if(!(n!=null&&n.get(s.id))){n||(n=new Map),this.synchronizationManager.updateSyncStatus(e,{pull:"SYNCING"});for(const o of r)this.synchronizationManager.updateSyncStatus(o,{pull:"SYNCING"});if(He.isPullResponderTrigger(s)){let o=!0;const a=He.setupPull(e,s,this.saveStrand.bind(this),c=>{const u=c instanceof Ge?c.status:"ERROR";this.synchronizationManager.updateSyncStatus(e,{pull:u},c),c instanceof On&&this.eventEmitter.emit("clientStrandsError",e,s,c.response.status,c.message)},async c=>{c.filter(d=>d.status!=="SUCCESS").length<1&&this.synchronizationManager.updateSyncStatus(e,{pull:"SUCCESS"});for(const d of c){const{documentId:l,scope:f,branch:h,status:g,error:E}=d;this.synchronizationManager.updateSyncStatus({documentId:l,scope:f,branch:h},{pull:g},E)}if(o){o=!1,(await this.synchronizationManager.getSynchronizationUnitsIds(e)).filter(h=>!c.find(g=>g.documentId===h.documentId&&g.scope===h.scope&&g.branch===h.branch)).forEach(h=>{this.synchronizationManager.updateSyncStatus(h,{pull:"SUCCESS"})});const f=i.state.local.listeners.find(h=>{var g;return s.data.url===((g=h.callInfo)==null?void 0:g.data)});if(f)for(const h of c){const{documentId:g,scope:E,branch:D}=h;this.listenerManager.updateListenerRevision(f.listenerId,e,{documentId:g,scope:E,branch:D},h.revision).catch(this.logger.error)}}},void 0,this.listeners);n.set(s.id,a),this.triggerMap.set(e,n)}}}async stopSyncRemoteDrive(e){const n=this.triggerMap.get(e);n==null||n.forEach(i=>i()),this.synchronizationManager.updateSyncStatus(e,null);const r=await this.synchronizationManager.getSynchronizationUnitsIds(e);for(const i of r)this.synchronizationManager.updateSyncStatus(i,null);return this.triggerMap.delete(e)}async _initializeDrive(e){var r,i,s;const n=await this.getDrive(e);this.logger.verbose(`[SYNC DEBUG] Initializing drive ${e} with slug "${n.header.slug}"`),await this.synchronizationManager.initializeDriveSyncStatus(e,n),this.shouldSyncRemoteDrive(n)&&(this.logger.verbose(`[SYNC DEBUG] Starting sync for remote drive ${e}`),await this.startSyncRemoteDrive(e)),this.logger.verbose(`[SYNC DEBUG] Processing ${n.state.local.listeners.length} listeners for drive ${e}`);for(const o of n.state.local.listeners)if(((r=o.callInfo)==null?void 0:r.transmitterType)==="SwitchboardPush"){this.logger.verbose(`[SYNC DEBUG] Setting up SwitchboardPush listener ${o.listenerId} for drive ${e}`);const a=new cd(o.callInfo.data??"",this.listeners);this.logger.verbose(`[SYNC DEBUG] Created SwitchboardPush transmitter with URL: ${o.callInfo.data||"none"}`),await this.listenerManager.setListener(e,{block:o.block,driveId:n.header.id,filter:{branch:o.filter.branch??[],documentId:o.filter.documentId??[],documentType:o.filter.documentType??[],scope:o.filter.scope??[]},listenerId:o.listenerId,callInfo:o.callInfo,system:o.system,label:o.label??"",transmitter:a}).then(()=>{this.logger.verbose(`[SYNC DEBUG] Successfully set up listener ${o.listenerId} for drive ${e}`)})}else if(((i=o.callInfo)==null?void 0:i.transmitterType)==="PullResponder"){this.logger.verbose(`[SYNC DEBUG] Setting up PullResponder listener ${o.listenerId} for drive ${e}`);const a={driveId:e,listenerId:o.listenerId,block:!1,filter:o.filter,system:!1,label:`PullResponder #${o.listenerId}`,callInfo:{data:"",name:"PullResponder",transmitterType:"PullResponder"}},c=new He(a,this.listenerManager);a.transmitter=c,await this.listenerManager.setListener(e,a)}else this.logger.error(`Skipping listener ${o.listenerId} with unsupported type ${((s=o.callInfo)==null?void 0:s.transmitterType)||"unknown"}`)}getDocumentModelModule(e){const n=this.documentModelModules.find(r=>r.documentModel.id===e);if(!n)throw new Error(`Document type ${e} not supported`);return n}getDocumentModelModules(){return[...this.documentModelModules]}addDocument(e,n){const r=typeof e=="string"?{documentType:e}:{document:e};return this.createDocument(r,{type:"local"},n)}async addDrive(e,n){const r=Wm({state:{global:{icon:e.global.icon??null,name:e.global.name},local:e.local??{}}});e.id&&e.id.length>0&&(r.header.id=e.id),e.slug&&e.slug.length>0&&(r.header.slug=e.slug);const i=e.preferredEditor||n;return i&&(r.header.meta={preferredEditor:i}),await this.documentStorage.create(r),e.slug&&e.slug.length>0&&await this.cache.deleteDriveBySlug(e.slug),await this._initializeDrive(r.header.id),this.eventEmitter.emit("driveAdded",r),r}async addRemoteDrive(e,n){var E;await((E=this.generateJwtHandler)==null?void 0:E.call(this,e));const{id:r,name:i,slug:s,icon:o,meta:a}=n.expectedDriveInfo||await Kn(e,this),{pullFilter:c,pullInterval:u,availableOffline:d,sharingType:l,listeners:f,triggers:h}=n,g=await He.createPullResponderTrigger(r,e,{pullFilter:c,pullInterval:u},this.listeners);return await this.addDrive({id:r,slug:s,global:{name:i,icon:o},local:{triggers:[...h,g],listeners:f,availableOffline:d,sharingType:l}},a==null?void 0:a.preferredEditor)}async deleteDrive(e){const n=await Promise.allSettled([this.stopSyncRemoteDrive(e),this.listenerManager.removeDrive(e),this.cache.deleteDrive(e),this.documentStorage.delete(e)]);this.eventEmitter.emit("driveDeleted",e),n.forEach(r=>{if(r.status==="rejected")throw r.reason})}async getDrives(){const e=[];let n;do{const{documents:r,nextCursor:i}=await this.documentStorage.findByType("powerhouse/document-drive",100,n);e.push(...r),n=i}while(n);return e}async getDrivesSlugs(){const e=await this.getDrives();return this.documentStorage.resolveSlugs(e)}async getDrive(e,n){let r;try{const o=await this.cache.getDrive(e);if(o&&It(o)&&(r=o,Ss(r,n==null?void 0:n.revisions)))return r}catch(o){this.logger.error("Error getting drive from cache",o)}const i=r??await this.documentStorage.get(e),s=this._buildDocument(i,n);if(It(s))return n!=null&&n.revisions||(this.cache.setDocument(e,s).catch(this.logger.error),this.cache.setDrive(e,s).catch(this.logger.error)),s;throw new Error(`Document with id ${e} is not a Document Drive`)}async getDriveBySlug(e,n){try{const s=await this.cache.getDriveBySlug(e);if(s)return s}catch(s){this.logger.error("Error getting drive from cache",s)}const r=await this.documentStorage.getBySlug(e),i=this._buildDocument(r,n);if(It(i))return this.cache.setDriveBySlug(e,i).catch(this.logger.error),i;throw new Error(`Document with slug ${e} is not a Document Drive`)}async getDriveIdBySlug(e){try{const r=await this.cache.getDriveBySlug(e);if(r)return r.header.id}catch(r){this.logger.error("Error getting drive from cache",r)}return(await this.documentStorage.getBySlug(e)).header.id}getDocument(e,n,r){const i=typeof n=="string"?n:e,s=typeof n=="object"?n:r;return this._getDocument(i,s)}async _getDocument(e,n){let r;try{if(r=await this.cache.getDocument(e),r&&Ss(r,n==null?void 0:n.revisions))return r}catch(o){this.logger.error("Error getting document from cache",o)}const i=r??await this.documentStorage.get(e),s=this._buildDocument(i,n);return n!=null&&n.revisions||this.cache.setDocument(e,s).catch(this.logger.error),s}getDocuments(e){return this.documentStorage.getChildren(e)}async addChild(e,n){try{await this.documentStorage.addChild(e,n)}catch(r){throw this.logger.error("Error adding child document",r),r}}async removeChild(e,n){try{const r=await this.synchronizationManager.getSynchronizationUnitsIds(e,[n]);await this.listenerManager.removeSyncUnits(e,r)}catch(r){this.logger.warn("Error removing sync units of child",r)}try{await this.documentStorage.removeChild(e,n)}catch(r){throw this.logger.error("Error adding child document",r),r}}async createDocument(e,n,r){const{documentType:i,document:s}=_c(e);let o;if(s){if("documentType"in e&&i!==s.header.documentType)throw new Error(`Provided document is not ${i}`);o=this._buildDocument(s).state}const a=s??this.getDocumentModelModule(i).utils.createDocument({state:o});let c;if("id"in e&&e.id)s?(c=a.header,a.header.id=e.id,this.logger.warn("Assigning an id to a document is deprecated. Use the header field instead.")):(this.logger.warn("Creating a document with an id is deprecated. Use the header field instead."),c=zr(e.id,i));else if("header"in e)await ba(e.header),c=e.header;else if(s!=null&&s.header){if(!s.header.id)throw new Error("Document header id is required");if(!s.header.documentType)throw new Error("Document header documentType is required");if(!s.header.createdAtUtcIso)throw new Error("Document header createdAtUtcIso is required");s.header.sig.nonce?await ba(s.header):this.logger.warn("Creating a document with an unsigned id is deprecated. Use createSignedHeaderForSigner."),c=s.header}else c=zr(void 0,i);r&&(c.meta={...c.meta,...r});const u={header:c,history:a.history,operations:{global:[],local:[]},initialState:a.initialState,clipboard:[],attachments:a.attachments,state:o??a.state};await this.documentStorage.create(u);const d=Object.values(a.operations).flat();return d.length&&(It(a)?await this.legacyStorage.addDriveOperations(c.id,d,a):await this.legacyStorage.addDocumentOperations(c.id,d,a)),await this.getDocument(u.header.id)}async deleteDocument(e){try{const n=await this.synchronizationManager.getSynchronizationUnitsIds(void 0,[e]);for(const i of n)this.synchronizationManager.updateSyncStatus(i,null);const r=await this.documentStorage.getParents(e);for(const i of r)this.listenerManager.removeSyncUnits(i,n).catch(this.logger.warn)}catch(n){this.logger.warn("Error deleting document",n)}await this.cache.deleteDocument(e),await this.documentStorage.delete(e)}async _processOperations(e,n,r){const i=[],s=[],o=await this._addDocumentResultingStage(n,e);let a=this._buildDocument(o),c;const u=yp(r);for(const d of Object.keys(u)){const l=n.operations[d],f=vp(u[d]||[],l);if(f.length<1)continue;const h=Ep(_p(l)),[g,E]=bp(h,f),P=(E.length<1?g:wp(h,g,Ip)).filter(B=>h.length<1||Sp(h[h.length-1],B));for(const B of P){let R=!1;if(E.length>0){const K=r.find(N=>N.hash===B.hash);R=!K||K.index!==B.index||K.skip!==B.skip}try{const K=this.options.taskQueueMethod,N=()=>this._performOperation(e,a,B,R),X=await(K?zv(N,K):N());a=X.document,s.push(...X.signals),i.push(X.operation)}catch(K){c=K instanceof Ge?K:new Ge("ERROR",B,K.message,K.cause);break}}}return{document:a,operationsApplied:i,signals:s,error:c}}async _addDocumentResultingStage(e,n,r){var o,a,c,u;const i=(r==null?void 0:r.revisions)!==void 0?Ec(e.operations,r.revisions):e.operations,s=Yr(i);for(const d of Object.keys(s)){const l=s[d].at(-1);l&&!l.resultingState&&(l.resultingState=await(It(e)?(a=(o=this.legacyStorage).getOperationResultingState)==null?void 0:a.call(o,n,l.index,l.scope,"main"):(u=(c=this.legacyStorage).getDriveOperationResultingState)==null?void 0:u.call(c,n,l.index,l.scope,"main")))}return{...e,operations:s}}_buildDocument(e,n){if(e.state&&(!n||n.checkHashes===!1)&&Ss(e,n==null?void 0:n.revisions))return e;const r=this.getDocumentModelModule(e.header.documentType),i=(n==null?void 0:n.revisions)!==void 0?Ec(e.operations,n.revisions):e.operations,s=Yr(i);return Zc(e.initialState,s,r.reducer,void 0,e.header,void 0,{...n,checkHashes:(n==null?void 0:n.checkHashes)??!0,reuseOperationResultingState:(n==null?void 0:n.checkHashes)??!0})}async _performOperation(e,n,r,i=!1){var g,E,D,P;const s=this.getDocumentModelModule(n.header.documentType),o=[];let a=n;const c=r.scope,d=Yr({...n.operations,[c]:Tp(n.operations[c],r)})[c].at(-1);d&&!d.resultingState&&(d.resultingState=await(It(n)?(E=(g=this.legacyStorage).getOperationResultingState)==null?void 0:E.call(g,e,d.index,d.scope,"main"):(P=(D=this.legacyStorage).getDriveOperationResultingState)==null?void 0:P.call(D,e,d.index,d.scope,"main")));const l=[];a=s.reducer(a,r,B=>{let R;switch(B.type){case"CREATE_CHILD_DOCUMENT":R=()=>this.addChild(e,B.input.id);break;case"DELETE_CHILD_DOCUMENT":R=()=>this.removeChild(e,B.input.id);break;case"COPY_CHILD_DOCUMENT":R=()=>this.addChild(e,B.input.newId);break}R&&l.push(()=>R().then(K=>({signal:B,result:K})))},{skip:r.skip,reuseOperationResultingState:!0});const h=a.operations[r.scope].filter(B=>B.index==r.index&&B.skip==r.skip).at(0);if(!h)throw new Ge("ERROR",r,`Operation with index ${r.index}:${r.skip} was not applied.`);if(!h.error&&h.hash!==r.hash&&!i)throw this.logger.warn(JSON.stringify(h,null,2)),new zm(r,h);for(const B of l){const R=await B();o.push(R)}return{document:a,signals:o,operation:h}}addOperation(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this.addOperations(s,[o],a)}async _addOperations(e,n){if(this.legacyStorage.addDocumentOperationsWithTransaction)await this.legacyStorage.addDocumentOperationsWithTransaction(e,n);else{const r=await this.documentStorage.get(e),i=await n(r);i.operations.length>0&&await this.legacyStorage.addDocumentOperations(e,i.operations,i.document)}}async queueDocument(e,n){const{id:r,documentType:i,document:s}=_c(e);if(!r)throw new Error("Document id is required",{cause:e});if(!i)throw new Error("Document type is required",{cause:e});if(await this.documentStorage.exists(r))throw new Sn(r);let a;const c=new Promise((u,d)=>{const l=this.queueManager.on("jobCompleted",(h,g)=>{h.jobId===a&&(l(),f(),u(g))}),f=this.queueManager.on("jobFailed",(h,g)=>{h.jobId===a&&(l(),f(),d(g))})});try{a=await this.queueManager.addJob({documentId:r,documentType:i,initialState:s,options:n})}catch(u){throw this.logger.error("Error adding job",u),u}return c}queueOperation(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this._queueOperations(s,[o],a)}async resultIfExistingOperations(e,n){try{const r=await this.getDocument(e);return n.find(s=>!s.id||!r.operations[s.scope].find(o=>o.id===s.id&&o.index===s.index&&o.type===s.type&&o.hash===s.hash))?void 0:{status:"SUCCESS",document:r,operations:n,signals:[]}}catch(r){r.message.includes(`Document with id ${e} not found`)||console.error(r);return}}queueOperations(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this._queueOperations(s,o,a)}async _queueOperations(e,n,r){const i=await this.resultIfExistingOperations(e,n);if(i)return i;let s;const o=new Promise((a,c)=>{const u=this.queueManager.on("jobCompleted",(l,f)=>{l.jobId===s&&(u(),d(),a(f))}),d=this.queueManager.on("jobFailed",(l,f)=>{l.jobId===s&&(u(),d(),c(f))})});try{s=await this.queueManager.addJob({documentId:e,operations:n,options:r})}catch(a){throw this.logger.error("Error adding job",a),a}return o}queueAction(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this._queueActions(s,[o],a)}queueActions(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this._queueActions(s,o,a)}async _queueActions(e,n,r){try{const i=await this.queueManager.addJob({documentId:e,actions:n,options:r});return await new Promise((s,o)=>{const a=this.queueManager.on("jobCompleted",(u,d)=>{u.jobId===i&&(a(),c(),s(d))}),c=this.queueManager.on("jobFailed",(u,d)=>{u.jobId===i&&(a(),c(),o(d))})})}catch(i){throw this.logger.error("Error adding job",i),i}}async queueDriveAction(e,n,r){return this.queueDriveActions(e,[n],r)}async queueDriveActions(e,n,r){try{const i=await this.queueManager.addJob({documentId:e,actions:n,options:r});return await new Promise((s,o)=>{const a=this.queueManager.on("jobCompleted",(u,d)=>{u.jobId===i&&(a(),c(),s(d))}),c=this.queueManager.on("jobFailed",(u,d)=>{u.jobId===i&&(a(),c(),o(d))})})}catch(i){throw this.logger.error("Error adding drive job",i),i}}addOperations(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this._queueOperations(s,o,a)}async processOperations(e,n,r){const i=await this.resultIfExistingOperations(e,n);if(i)return i;let s;const o=[],a=[];let c;try{await this._addOperations(e,async h=>{const g=await this._processOperations(e,h,n);if(!g.document)throw this.logger.error("Invalid document"),g.error??new Error("Invalid document");return s=g.document,c=g.error,a.push(...g.signals),o.push(...g.operationsApplied),{operations:g.operationsApplied,document:g.document}});const u=new Array;if(s){this.cache.setDocument(e,s).catch(this.logger.error);for(const h of o){const g={documentId:e,documentType:s.header.documentType,scope:h.scope,branch:"main",revision:h.index+1,lastUpdated:h.timestamp};u.some(D=>D.documentId===g.documentId&&D.scope===g.scope&&D.branch===g.branch)||u.push(g)}}const l=o.find(h=>!n.find(g=>g.id===h.id&&g.index===h.index&&g.skip===h.skip&&g.hash===h.hash))?{type:"local"}:(r==null?void 0:r.source)??{type:"local"},f=this.getOperationSource(l);if(u.length&&this.listenerManager.updateSynchronizationRevisions(u,l,()=>{this.synchronizationManager.updateSyncStatus(e,{[f]:"SYNCING"});for(const h of u)this.synchronizationManager.updateSyncStatus(h,{[f]:"SYNCING"})},this.handleListenerError.bind(this),(r==null?void 0:r.forceSync)??l.type==="local").then(h=>{h.length&&this.synchronizationManager.updateSyncStatus(e,{[f]:"SUCCESS"});for(const g of u)this.synchronizationManager.updateSyncStatus(g,{[f]:"SUCCESS"})}).catch(h=>{this.logger.error("Non handled error updating sync revision",h),this.synchronizationManager.updateSyncStatus(e,{[f]:"ERROR"},h);for(const g of u)this.synchronizationManager.updateSyncStatus(g,{[f]:"ERROR"},h)}),c)throw c;return this.eventEmitter.emit("documentOperationsAdded",e,n),this.eventEmitter.emit("operationsAdded",e,n),{status:"SUCCESS",document:s,operations:o,signals:a}}catch(u){const d=u instanceof Ge?u:new Ge("ERROR",void 0,u.message,u.cause);return{status:d.status,error:d,document:s,operations:o,signals:a}}}addDriveOperation(e,n,r){return this.addDriveOperations(e,[n],r)}async _addDriveOperations(e,n){if(this.legacyStorage.addDriveOperationsWithTransaction)return this.legacyStorage.addDriveOperationsWithTransaction(e,n);{const r=await this.documentStorage.get(e),i=await n(r);return i.operations.length>0&&await this.legacyStorage.addDriveOperations(e,i.operations,i.document),i}}queueDriveOperation(e,n,r){return this.queueDriveOperations(e,[n],r)}async resultIfExistingDriveOperations(e,n){try{const r=await this.getDrive(e);return n.find(s=>!s.id||!r.operations[s.scope].find(o=>o.id===s.id&&o.index===s.index&&o.type===s.type&&o.hash===s.hash))?void 0:{status:"SUCCESS",document:r,operations:n,signals:[]}}catch(r){console.error(r);return}}async queueDriveOperations(e,n,r){const i=await this.resultIfExistingDriveOperations(e,n);if(i)return i;try{const s=await this.queueManager.addJob({documentId:e,operations:n,options:r});return await new Promise((o,a)=>{const c=this.queueManager.on("jobCompleted",(d,l)=>{d.jobId===s&&(c(),u(),o(l))}),u=this.queueManager.on("jobFailed",(d,l)=>{d.jobId===s&&(c(),u(),a(l))})})}catch(s){throw this.logger.error("Error adding drive job",s),s}}async addDriveOperations(e,n,r){return this.queueDriveOperations(e,n,r)}async processDriveOperations(e,n,r){let i;const s=[],o=[];let a;const c=await this.resultIfExistingDriveOperations(e,n);if(c)return c;try{if(await this._addDriveOperations(e,async d=>{const l=await this._processOperations(e,d,n.slice());return i=l.document,s.push(...l.operationsApplied),o.push(...l.signals),a=l.error,{operations:l.operationsApplied,document:l.document}}),!i||!It(i))throw a??new Error("Invalid Document Drive document");this.cache.setDocument(e,i).catch(this.logger.error),this.cache.setDrive(e,i).catch(this.logger.error);const u=s.filter(d=>d.scope==="global").slice().pop();if(u){const l=s.find(h=>!n.find(g=>g.id===h.id&&g.index===h.index&&g.skip===h.skip&&g.hash===h.hash))?{type:"local"}:(r==null?void 0:r.source)??{type:"local"},f=this.getOperationSource(l);this.listenerManager.updateSynchronizationRevisions([{documentId:e,documentType:i.header.documentType,scope:"global",branch:"main",lastUpdated:u.timestamp,revision:u.index}],l,()=>{this.synchronizationManager.updateSyncStatus(e,{[f]:"SYNCING"})},this.handleListenerError.bind(this),(r==null?void 0:r.forceSync)??l.type==="local").then(h=>{h.length&&this.synchronizationManager.updateSyncStatus(e,{[f]:"SUCCESS"})}).catch(h=>{this.logger.error("Non handled error updating sync revision",h),this.synchronizationManager.updateSyncStatus(e,{[f]:"ERROR"},h)})}if(this.shouldSyncRemoteDrive(i)?this.startSyncRemoteDrive(e).catch(this.logger.error):this.stopSyncRemoteDrive(e).catch(this.logger.error),a)throw a;return this.eventEmitter.emit("driveOperationsAdded",e,n),this.eventEmitter.emit("operationsAdded",e,n),{status:"SUCCESS",document:i,operations:s,signals:o}}catch(u){const d=u instanceof Ge?u:new Ge("ERROR",void 0,u.message,u);return{status:d.status,error:d,document:i,operations:s,signals:o}}}_buildOperations(e,n){const r=[],{reducer:i}=this.getDocumentModelModule(e.header.documentType);for(const s of n){e=i(e,s);const o=e.operations[s.scope].slice().pop();if(!o)throw new Error("Error creating operations");r.push(o)}return r}addAction(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this._addAction(s,o,a)}async _addAction(e,n,r){return this.addActions(e,[n],r)}addActions(e,n,r,i){let s,o,a;return typeof n=="string"?(s=n,o=r,a=i):(s=e,o=n,a=r),this._queueActions(s,o,a)}async processActions(e,n,r){const i=await this.getDocument(e),s=this._buildOperations(i,n);return this.processOperations(e,s,r)}async addDriveAction(e,n,r){return"synchronizationUnits"in n.input?this._legacyAddFileAction(e,n,r):this.addDriveActions(e,[n],r)}async _legacyAddFileAction(e,n,r){const i=this.getDocumentModelModule(n.input.documentType).utils.createDocument({...n.input.document});i.header.id=n.input.id,i.header.name=n.input.name,i.header.documentType=n.input.documentType,await this.queueDocument({document:i},{source:(r==null?void 0:r.source)||{type:"local"}});const s={...n,input:{id:n.input.id,documentType:i.header.documentType,name:n.input.name,parentFolder:n.input.parentFolder}};return await this.addAction(e,s,r)}async addDriveActions(e,n,r){return this.queueDriveActions(e,n,r)}async processDriveActions(e,n,r){const i=await this.getDrive(e),s=this._buildOperations(i,n);return this.processDriveOperations(e,s,r)}async detachDrive(e){const n=await this.getDrive(e),r=n.state.local.listeners||[],i=n.state.local.triggers||[];for(const s of r)await this.addDriveAction(e,rl({listenerId:s.listenerId}));for(const s of i)await this.addDriveAction(e,No({triggerId:s.id}));await this.addDriveAction(e,Do({type:"LOCAL"}))}getSyncStatus(e,n,r){return this.synchronizationManager.getSyncStatus(e,n,r)}on(e,n){return this.eventEmitter.on(e,n)}emit(e,...n){return this.eventEmitter.emit(e,...n)}updateSyncStatus(e,n,r){this.synchronizationManager.updateSyncStatus(e,n,r)}initializeDriveSyncStatus(e,n){return this.synchronizationManager.initializeDriveSyncStatus(e,n)}getCombinedSyncUnitStatus(e){return this.synchronizationManager.getCombinedSyncUnitStatus(e)}async saveStrand(e,n){const r=!await this.documentStorage.exists(e.documentId);let i;r&&(i=await this.queueDocument({id:e.documentId,documentType:e.documentType}));const s=e.operations.map(o=>({...o,scope:e.scope,branch:e.branch}));if((!r||(i==null?void 0:i.status)==="SUCCESS")&&s.length)try{i=await this.queueOperations(e.documentId,s,{source:n})}catch(o){throw this.logger.error("Error queueing operations",o),o}if(!i)return this.logger.debug(`Document ${e.documentId} already exists`),{status:"SUCCESS",document:await this.getDocument(e.documentId),operations:[],signals:[]};if(i.status==="ERROR"){const o=this.getOperationSource(n);this.synchronizationManager.updateSyncStatus({documentId:e.documentId||e.driveId,scope:e.scope,branch:e.branch},{[o]:i.status},i.error)}return this.eventEmitter.emit("strandUpdate",e),i}setGenerateJwtHandler(e){this.generateJwtHandler=e,this.listenerManager.setGenerateJwtHandler(e)}removeJwtHandler(){this.generateJwtHandler=void 0,this.listenerManager.removeJwtHandler()}}const nE=jv(tE);class Ei extends Error{constructor(e){super(e||"Aborted"),this.name="AbortError"}}class rE{constructor(){U(this,"documents");U(this,"driveManifests");U(this,"slugToDocumentId");this.documents={},this.driveManifests={},this.slugToDocumentId={}}resolveIds(e,n){const r=[];for(const i of e){const s=this.slugToDocumentId[i];if(!s)throw new Ot(i);r.push(s)}if(n!=null&&n.aborted)throw new Ei("Aborted");return Promise.resolve(r)}resolveSlugs(e,n){const r=[];for(const i of e){const s=this.documents[i];if(!s)throw new Ot(i);r.push(s.header.slug)}if(n!=null&&n.aborted)throw new Ei("Aborted");return Promise.resolve(r)}exists(e){return Promise.resolve(!!this.documents[e])}create(e){var i;const n=e.header.id;if(!di(n))throw new li(n);if(this.documents[n])throw new Sn(n);const r=((i=e.header.slug)==null?void 0:i.length)>0?e.header.slug:n;if(!Vu(r))throw new ju(r);if(r&&this.slugToDocumentId[r])throw new Sn(n);if(e.header.slug=r,this.documents[n]=e,r){if(this.slugToDocumentId[r])throw new Sn(n);this.slugToDocumentId[r]=n}return e.header.documentType==="powerhouse/document-drive"&&this.updateDriveManifest(n,{documentIds:new Set}),Promise.resolve()}get(e){const n=this.documents[e];return n?Promise.resolve(n):Promise.reject(new Ot(e))}getBySlug(e){const n=this.slugToDocumentId[e];return n?this.get(n):Promise.reject(new Ot(e))}async findByType(e,n=100,r){const i=Object.entries(this.documents).filter(([c,u])=>u.header.documentType===e).map(([c,u])=>({id:c,document:u}));i.sort((c,u)=>{const d=new Date(c.document.header.createdAtUtcIso),l=new Date(u.document.header.createdAtUtcIso);if(d.getTime()===l.getTime()){const f=c.id,h=u.id;return f.localeCompare(h)}return d.getTime()-l.getTime()});let s=0;if(r){const c=i.findIndex(({id:u})=>u===r);c!==-1&&(s=c)}const o=Math.min(s+n,i.length);let a;return o<i.length&&(a=i[o].id),{documents:i.slice(s,o).map(({id:c})=>c),nextCursor:a}}async delete(e){var i;const n=this.documents[e];if(n){const s=((i=n.header.slug)==null?void 0:i.length)>0?n.header.slug:e;s&&this.slugToDocumentId[s]===e&&delete this.slugToDocumentId[s]}const r=await this.getParents(e);for(const s of r)await this.removeChild(s,e);return delete this.driveManifests[e],this.documents[e]?(delete this.documents[e],Promise.resolve(!0)):Promise.resolve(!1)}async addChild(e,n){if(e===n)return Promise.reject(new Error("Cannot associate a document with itself"));if((await this.getChildren(n)).includes(e))return Promise.reject(new Error("Cannot associate a document with its child"));const i=this.getManifest(e);return i.documentIds.add(n),this.updateDriveManifest(e,i),Promise.resolve()}async removeChild(e,n){const r=this.getManifest(e);return r.documentIds.delete(n)?(this.updateDriveManifest(e,r),Promise.resolve(!0)):Promise.resolve(!1)}async getChildren(e){return[...this.getManifest(e).documentIds]}async getParents(e){const n=[];for(const[r,i]of Object.entries(this.driveManifests))i.documentIds.has(e)&&n.push(r);return n}async clear(){this.documents={},this.driveManifests={},this.slugToDocumentId={}}async addDocumentOperations(e,n,r){const i=await this.get(e);if(!r)return Promise.reject(new Ot(e));const s=yi(i.operations,n);this.documents[e]={...i,...r,operations:s}}async addDriveOperations(e,n,r){const i=await this.get(e),s=yi(i.operations,n);this.documents[e]={...i,...r,operations:s}}async getSynchronizationUnitsRevision(e){return(await Promise.allSettled(e.map(async r=>{var i;try{const s=await this.get(r.documentId);if(!s||!Object.keys(s.state).includes(r.scope))return;const o=s.operations[r.scope];return{documentId:r.documentId,documentType:r.documentType,scope:r.scope,branch:r.branch,lastUpdated:((i=o.at(-1))==null?void 0:i.timestamp)??s.header.createdAtUtcIso,revision:Pn(o)}}catch{return}}))).reduce((r,i)=>(i.status==="fulfilled"&&i.value!==void 0&&r.push(i.value),r),[])}async findStorageUnitsBy(e,n,r){const i=[],{parentId:s,documentId:o,documentModelType:a,scope:c}=Gu(e);let u;if(s){const h=new Set;for(const g of s)(await this.getChildren(g)).forEach(D=>h.add(D));u=s.union(h)}else u=new Set(Object.keys(this.documents));u=o?o.intersection(u):u;for(const h of u){const g=this.documents[h];if(g&&!(a&&!a.has(g.header.documentType)))for(const[E]of Object.entries(g.state))c&&!c.has(E)||i.push({documentId:h,documentModelType:g.header.documentType,scope:E,branch:"main"})}let d=0;if(r){const h=i.findIndex(g=>g.documentId===r);h!==-1&&(d=h)}const l=Math.min(d+n,i.length),f=l<i.length?i[l].documentId:void 0;return{units:i.slice(d,l),nextCursor:f}}getManifest(e){return this.driveManifests[e]||(this.driveManifests[e]={documentIds:new Set}),this.driveManifests[e]}updateDriveManifest(e,n){this.driveManifests[e]=n}}class iE{constructor(){U(this,"emitter",ol())}emit(e,...n){return this.emitter.emit(e,...n)}on(e,n){return this.emitter.on(e,n)}}const De=class De{constructor(){U(this,"internalMap",new Map)}static escape(e){return e.replace(/\|/g,"\\|")}static unescape(e){return e.replace(/\\\|/g,"|")}static buildKey(e){return`${De.escape(e.documentId)}${De.keySeparator}${De.escape(e.scope)}${De.keySeparator}${De.escape(e.branch)}`}static parseKey(e){const n=e.split(new RegExp("(?<!\\\\)\\|")).map(o=>De.unescape(o)),[r,i,s]=n;return{documentId:r,scope:i,branch:s}}set(e,n){return this.internalMap.set(De.buildKey(e),n),this}get(e){return this.internalMap.get(De.buildKey(e))}has(e){return this.internalMap.has(De.buildKey(e))}delete(e){return this.internalMap.delete(De.buildKey(e))}clear(){this.internalMap.clear()}get size(){return this.internalMap.size}keys(e){const n=this.internalMap.keys();return{[Symbol.iterator](){return this},next(){for(;;){const r=n.next();if(r.done)return{done:!0,value:void 0};const i=r.value,s=De.parseKey(i);if(!(e&&(s.documentId!==e.documentId||e.scope!==void 0&&s.scope!==e.scope)))return{done:!1,value:s}}}}}values(e){const n=this.internalMap.entries();return{[Symbol.iterator](){return this},next(){for(;;){const r=n.next();if(r.done)return{done:!0,value:void 0};const[i,s]=r.value,o=De.parseKey(i);if(!(e&&(o.documentId!==e.documentId||e.scope!==void 0&&o.scope!==e.scope)))return{done:!1,value:s}}}}}entries(e){const n=this.internalMap.entries();return{[Symbol.iterator](){return this},next(){for(;;){const r=n.next();if(r.done)return{done:!0,value:void 0};const[i,s]=r.value,o=De.parseKey(i);if(!(e&&(o.documentId!==e.documentId||e.scope!==void 0&&o.scope!==e.scope)))return{done:!1,value:[o,s]}}}}}[Symbol.iterator](){return this.entries()}forEach(e,n){for(const[r,i]of this.entries())e.call(n,i,r,this)}deleteByDocumentId(e){for(const n of this.internalMap.keys())n.startsWith(e+De.keySeparator)&&this.internalMap.delete(n)}deleteByDocumentIdAndScope(e,n){const r=`${e}${De.keySeparator}${n}${De.keySeparator}`;for(const i of this.internalMap.keys())i.startsWith(r)&&this.internalMap.delete(i)}getAllByDocumentId(e){const n=[];for(const[r,i]of this.internalMap.entries())r.startsWith(e+De.keySeparator)&&n.push([De.parseKey(r),i]);return n}getAllByDocumentIdAndScope(e,n){const r=`${e}${De.keySeparator}${n}${De.keySeparator}`,i=[];for(const[s,o]of this.internalMap.entries())s.startsWith(r)&&i.push([De.parseKey(s),o]);return i}};U(De,"keySeparator","|");let _i=De;function sE(t,e=250){let n;return(r=!1,...i)=>(n&&clearTimeout(n),new Promise((s,o)=>{r?t(...i).then(s).catch(o):n=setTimeout(()=>{t(...i).then(s).catch(o)},e)}))}const Si=class Si{constructor(e,n=vi){U(this,"logger",wt(["ListenerManager",Math.floor(Math.random()*999).toString()]));U(this,"syncManager");U(this,"options");U(this,"generateJwtHandler");U(this,"listenerStateByDriveId",new Map);U(this,"triggerUpdate",sE(this._triggerUpdate.bind(this),Si.LISTENER_UPDATE_DELAY));this.syncManager=e,this.options={...vi,...n},this.logger.verbose("constructor(...)")}setGenerateJwtHandler(e){this.generateJwtHandler=e}removeJwtHandler(){this.generateJwtHandler=void 0}async initialize(e){this.logger.verbose("initialize(...)"),typeof window<"u"&&window.addEventListener("online",()=>{this.triggerUpdate(!1,{type:"local"},void 0,e).catch(n=>{this.logger.error("Non handled error updating listeners",n)})})}driveHasListeners(e){return this.listenerStateByDriveId.has(e)}async setListener(e,n){if(this.logger.verbose(`setListener(drive: ${e}, listener: ${n.listenerId})`),e!==n.driveId)throw new Error("Drive ID mismatch");let r;try{r=this.getListenerState(e,n.listenerId)}catch{r={}}this.setListenerState(e,n.listenerId,{...r,block:n.block,driveId:n.driveId,pendingTimeout:"0",listener:n,listenerStatus:"CREATED",syncUnits:new _i}),await this.triggerUpdate(!0,{type:"local"})}async removeListener(e,n){this.logger.verbose("setListener()");const r=this.listenerStateByDriveId.get(e);return r?Promise.resolve(r.delete(n)):!1}async removeSyncUnits(e,n){const r=this.listenerStateByDriveId.get(e);if(r){for(const[,i]of r)for(const s of n)i.syncUnits.delete(s);return Promise.resolve()}}async updateSynchronizationRevisions(e,n,r,i,s=!1){const o=this.listenerStateByDriveId.values(),a=[];for(const[[c,u]]of o){if(a.find(l=>l.listenerId===u.listener.listenerId))continue;const d=u.listener.transmitter;if(d!=null&&d.transmit)for(const l of e){if(!this._checkFilter(u.listener.filter,l))continue;const f=u.syncUnits.get(l);if(!f||f.listenerRev<l.revision){a.push(u.listener);break}}}return this.triggerUpdate(s,n,r,i)}async updateListenerRevision(e,n,r,i){const s=this.listenerStateByDriveId.get(n);if(!s)return;const o=s.get(e);if(!o)return;const a=new Date().toISOString();return o.syncUnits.set(r,{listenerRev:i,lastUpdated:a}),Promise.resolve()}async _triggerUpdate(e,n,r,i=500){var o,a;if(this.logger.verbose(`_triggerUpdate(source: ${e.type}, maxContinues: ${i})`,this.listenerStateByDriveId),i<0)throw new Error("Maximum retries exhausted.");const s=[];for(const[c,u]of this.listenerStateByDriveId)for(const[d,l]of u){const f=l.listener.transmitter;if(!(f!=null&&f.transmit))continue;const h=await this.getListenerSyncUnits(c,d),g=[];this.logger.verbose("syncUnits",h);const E=h.map(D=>async()=>{const P=l.syncUnits.get(D);if(P&&P.listenerRev>=D.revision){this.logger.verbose(`Abandoning push for sync unit ${JSON.stringify(D)}: already up-to-date (${P.listenerRev} >= ${D.revision})`);return}else this.logger.verbose(`Listener out-of-date for sync unit (${D.scope}, ${D.documentId}): ${P==null?void 0:P.listenerRev} < ${D.revision}`);const B=[];if(D.revision>0){try{const R=await this.syncManager.getOperationData(D,{fromRevision:P==null?void 0:P.listenerRev});B.push(...R)}catch(R){this.logger.error(R)}if(!B.length){this.logger.verbose(`Abandoning push for ${JSON.stringify(D)}: no operations found`);return}}g.push({driveId:c,documentType:D.documentType,documentId:D.documentId,branch:D.branch,operations:B,scope:D.scope})});if(this.options.sequentialUpdates){this.logger.verbose(`Collecting ${E.length} syncUnit strandUpdates in sequence`);for(const D of E)await D()}else this.logger.verbose(`Collecting ${E.length} syncUnit strandUpdates in parallel`),await Promise.all(E.map(D=>D()));if(g.length==0){this.logger.verbose(`No strandUpdates needed for listener ${d}`);continue}l.pendingTimeout=new Date(new Date().getTime()/1e3+300).toISOString(),l.listenerStatus="PENDING";try{this.logger.verbose(`_triggerUpdate(source: ${e.type}) > transmitter.transmit`);const D=await f.transmit(g,e);this.logger.verbose(`_triggerUpdate(source: ${e.type}) > transmission succeeded`,D),l.pendingTimeout="0",l.listenerStatus="PENDING";const P=new Date().toISOString();let B=!1;for(const R of D){const K=h.find(N=>R.documentId===N.documentId&&R.scope===N.scope&&R.branch===N.branch);if(K){l.syncUnits.set(K,{lastUpdated:P,listenerRev:R.revision});const N=g.find(X=>X.driveId===R.driveId&&X.documentId===R.documentId&&X.scope===R.scope&&X.branch===R.branch);if(N&&N.operations.length>0){const X=(o=N.operations.at(-1))==null?void 0:o.index;X!==R.revision?(this.logger.verbose(`Revision still out-of-date for ${N.documentId}:${N.scope}:${N.branch} ${X} <> ${R.revision}`),B=!0):this.logger.verbose(`Revision match for ${N.documentId}:${N.scope}:${N.branch} ${X}`)}}else this.logger.warn(`Received revision for untracked unit for listener ${l.listener.listenerId}`,R)}for(const R of D){const K=R.status==="ERROR";if((a=R.error)!=null&&a.includes("Missing operations"))B=!0;else if(K)throw new Ge(R.status,void 0,R.error,R.error)}if(!B)s.push({listenerId:l.listener.listenerId,listenerRevisions:D});else{const R=await this._triggerUpdate(e,n,r,i-1);s.push(...R)}l.listenerStatus="SUCCESS"}catch(D){r==null||r(D,c,l),l.listenerStatus=D instanceof Ge?D.status:"ERROR"}}return this.logger.verbose(`Returning listener updates (maxContinues: ${i})`,s),s}_checkFilter(e,n){const{branch:r,documentId:i,scope:s,documentType:o}=n;return!!((!e.branch||e.branch.includes(r)||e.branch.includes("*"))&&(!e.documentId||e.documentId.includes(i)||e.documentId.includes("*"))&&(!e.scope||e.scope.includes(s)||e.scope.includes("*"))&&(!e.documentType||e.documentType.includes(o)||e.documentType.includes("*")))}getListenerSyncUnits(e,n){var s;const r=(s=this.listenerStateByDriveId.get(e))==null?void 0:s.get(n);if(!r)return[];const i=r.listener.filter;return this.syncManager.getSynchronizationUnits(e,i.documentId??["*"],i.scope??["*"],i.branch??["*"],i.documentType??["*"])}async removeDrive(e){var r,i;const n=this.listenerStateByDriveId.get(e);if(n){this.listenerStateByDriveId.delete(e);for(const[s,o]of n)try{await((i=(r=o.listener.transmitter)==null?void 0:r.disconnect)==null?void 0:i.call(r))}catch(a){this.logger.error(a)}}}async getStrands(e,n,r){this.logger.verbose(`[SYNC DEBUG] ListenerManager.getStrands called for drive: ${e}, listener: ${n}, options: ${JSON.stringify(r||{})}`);let i;try{i=this.getListenerState(e,n),this.logger.verbose(`[SYNC DEBUG] Found listener state for drive: ${e}, listener: ${n}, status: ${i.listenerStatus}`)}catch(o){throw this.logger.error(`[SYNC DEBUG] Failed to find listener state for drive: ${e}, listener: ${n}. Error: ${o}`),o}const s=[];try{const o=await this.getListenerSyncUnits(e,n);this.logger.verbose(`[SYNC DEBUG] Retrieved ${o.length} sync units for drive: ${e}, listener: ${n}`);const a=r==null?void 0:r.limit;let c=0;const u=o.map(d=>async()=>{if(a&&c>=a)return;if(d.revision<0){this.logger.verbose(`[SYNC DEBUG] Skipping sync unit with negative revision: ${JSON.stringify(d)}, revision: ${d.revision}`);return}const l=i.syncUnits.get(d);if(l&&l.listenerRev>=d.revision){this.logger.verbose(`[SYNC DEBUG] Skipping sync unit - listener already up to date: ${JSON.stringify(d)}, listenerRev: ${l.listenerRev}, revision: ${d.revision}`);return}const{documentId:f,scope:h,branch:g}=d;let E=[];try{d.revision>0&&(this.logger.verbose(`[SYNC DEBUG] Getting operations for syncUnit: ${JSON.stringify(d)}`),E=await this.syncManager.getOperationData(d,{since:r==null?void 0:r.since,fromRevision:(r==null?void 0:r.fromRevision)??(l==null?void 0:l.listenerRev),limit:a?a-c:void 0})),this.logger.verbose(`[SYNC DEBUG] Retrieved ${E.length} operations for syncUnit: ${JSON.stringify(d)}`),c+=E.length,s.push({driveId:e,documentId:f,documentType:d.documentType,scope:h,branch:g,operations:E}),this.logger.verbose(`[SYNC DEBUG] Added strand with ${E.length} operations for syncUnit: ${JSON.stringify(d)}`)}catch(D){this.logger.error(`Error getting operations for syncUnit: ${JSON.stringify(d)}, error: ${D}`);return}});if(this.options.sequentialUpdates){this.logger.verbose(`[SYNC DEBUG] Processing ${u.length} sync units sequentially`);for(const d of u)await d()}else this.logger.verbose(`[SYNC DEBUG] Processing ${u.length} sync units in parallel`),await Promise.all(u.map(d=>d()))}catch(o){this.logger.error(`Error in getStrands: ${o}`)}return this.logger.verbose(`ListenerManager.getStrands returning ${s.length} strands for drive: ${e}, listener: ${n}`),s}getListenerState(e,n){let r=this.listenerStateByDriveId.get(e);r||(r=new Map,this.listenerStateByDriveId.set(e,r));const i=r.get(n);if(!i)throw new Error("Listener not found");return i}setListenerState(e,n,r){let i=this.listenerStateByDriveId.get(e);i||(i=new Map,this.listenerStateByDriveId.set(e,i)),i.set(n,r)}};U(Si,"LISTENER_UPDATE_DELAY",250);let Qs=Si;class oE{constructor(e){U(this,"listenerManager");this.listenerManager=e}instance(e,n,r){var i;switch(e){case"SwitchboardPush":{if(!((i=n.callInfo)!=null&&i.data))throw new Error("No call info data: "+JSON.stringify(n));return new cd(n.callInfo.data,this.listenerManager)}case"Internal":throw new Error("Internal transmitter not implemented");default:return new He(n,this.listenerManager)}}}class aE{constructor(e,n,r,i,s){U(this,"storage");U(this,"documentStorage");U(this,"cache");U(this,"documentModelModules");U(this,"eventEmitter");U(this,"syncStatus",new _i);U(this,"logger",wt(["SynchronizationManager"]));this.storage=e,this.documentStorage=n,this.cache=r,this.documentModelModules=i,this.eventEmitter=s}async getSynchronizationUnits(e,n,r,i,s){const o=await this.getSynchronizationUnitsIds(e,n,r,i,s);return this.logger.verbose(`getSynchronizationUnits query: ${JSON.stringify(o)}`),(await this.getSynchronizationUnitsRevision(o)).filter(c=>typeof c<"u")}async getSynchronizationUnitsRevision(e){const n=await this.storage.getSynchronizationUnitsRevision(e);return this.logger.verbose(`getSynchronizationUnitsRevision: ${JSON.stringify(n)}`),e.map(r=>n.find(i=>i.documentId===r.documentId&&i.scope===r.scope&&i.branch===r.branch))}async getSynchronizationUnitsIds(e,n,r,i,s){const o={parentId:e?[e]:void 0,documentId:n,documentModelType:s,scope:r,branch:i};let a;const c=[];do{const{units:u,nextCursor:d}=await this.documentStorage.findStorageUnitsBy(o,100,a);c.push(...u),a=d}while(a);return c.reduce((u,{documentModelType:d,...l})=>l.scope==="local"?u:u.concat([{...l,documentType:d}]),new Array)}async getSynchronizationUnit(e){const{scope:n,branch:r,documentId:i}=e,s=await this.getDocument(i);if(!Object.keys(s.state).includes(n))return;const o=s.operations[n]??[],a=o.at(-1);return{scope:n,branch:r,documentId:i,documentType:s.header.documentType,lastUpdated:(a==null?void 0:a.timestamp)??s.header.lastModifiedAtUtcIso,revision:Pn(o)}}async getOperationData(e,n){this.logger.verbose(`[SYNC DEBUG] SynchronizationManager.getOperationData called for syncId: ${JSON.stringify(e)}, filter: ${JSON.stringify(n)}`);const r=await this.getDocument(e.documentId);this.logger.verbose(`[SYNC DEBUG] Retrieved document ${r.header.id} with type: ${r.header.documentType}`);const i=r.operations[e.scope]??[];this.logger.verbose(`[SYNC DEBUG] Found ${i.length} total operations in scope ${e.scope}`);const s=i.filter(a=>Object.keys(n).length===0||(n.since===void 0||Yv(n.since,a.timestamp))&&(n.fromRevision===void 0||a.index>=n.fromRevision));this.logger.verbose(`[SYNC DEBUG] Filtered to ${s.length} operations based on filter criteria`+(n.fromRevision!==void 0?` (fromRevision: ${n.fromRevision})`:""));const o=n.limit?s.slice(0,n.limit):s;if(this.logger.verbose(`[SYNC DEBUG] Returning ${o.length} operations after applying limit`),o.length>0){const a=o[0],c=o[o.length-1];this.logger.verbose(`[SYNC DEBUG] First operation: index=${a.index}, type=${a.type}`),this.logger.verbose(`[SYNC DEBUG] Last operation: index=${c.index}, type=${c.type}`)}return o.map(a=>({hash:a.hash,index:a.index,timestamp:a.timestamp,type:a.type,input:a.input,skip:a.skip,context:a.context,id:a.id}))}async getDocument(e){try{const r=await this.cache.getDocument(e);if(r)return r}catch(r){this.logger.error("Error getting document from cache",r)}const n=await this.documentStorage.get(e);return this._buildDocument(n)}_buildDocument(e){const n=this.getDocumentModelModule(e.header.documentType),r=Yr(e.operations);return Zc(e.initialState,r,n.reducer,void 0,e.header,void 0,{checkHashes:!0,reuseOperationResultingState:!0})}setDocumentModelModules(e){this.documentModelModules=e}getDocumentModelModule(e){const n=this.documentModelModules.find(r=>r.documentModel.id===e);if(!n)throw new Error(`Document type ${e} not supported`);return n}getCombinedSyncUnitStatus(e){if(!e.pull&&!e.push||e.pull==="INITIAL_SYNC")return"INITIAL_SYNC";if(e.push==="INITIAL_SYNC")return e.pull||"INITIAL_SYNC";const n=["ERROR","MISSING","CONFLICT","SYNCING","SUCCESS"];return Object.values(e).sort((i,s)=>n.indexOf(i)-n.indexOf(s))[0]}getSyncStatus(e,n="global",r="main"){const i=typeof e=="string"?{documentId:e,scope:n,branch:r}:e,s=this.syncStatus.get(i);return s?this.getCombinedSyncUnitStatus(s):new Us(i)}updateSyncStatus(e,n,r,i="global",s="main"){const o=typeof e=="string"?{documentId:e,scope:i,branch:s}:e;if(n===null){this.syncStatus.delete(o);return}const a=this.syncStatus.get(o);if(!a){this.initSyncStatus(o,n);return}if(Object.entries(n).some(([u,d])=>a[u]!==d)){const u=Object.entries(n).reduce((f,[h,g])=>({...f,[h]:f[h]==="INITIAL_SYNC"&&g==="SYNCING"?"INITIAL_SYNC":g}),a),d=this.getCombinedSyncUnitStatus(a),l=this.getCombinedSyncUnitStatus(u);this.syncStatus.set(o,u),d!==l&&this.eventEmitter&&this.eventEmitter.emit("syncStatus",o.documentId,this.getCombinedSyncUnitStatus(u),r,u,o.scope,o.branch)}}initSyncStatus(e,n){const r=Object.entries(n).reduce((i,[s,o])=>({...i,[s]:o!=="SYNCING"?o:"INITIAL_SYNC"}),{});this.syncStatus.set(e,r),this.eventEmitter&&this.eventEmitter.emit("syncStatus",e.documentId,this.getCombinedSyncUnitStatus(r),void 0,r,e.scope,e.branch)}async initializeDriveSyncStatus(e,n){const r=await this.getSynchronizationUnitsIds(e),i={pull:n.state.local.triggers.length>0?"INITIAL_SYNC":void 0,push:n.state.local.listeners.length>0?"SUCCESS":void 0};if(!i.pull&&!i.push)return;const s=[{documentId:e,scope:"global",branch:"main"},...r];for(const o of s)this.initSyncStatus(o,i)}}class cE{constructor(e){U(this,"documentModelModules",[]);U(this,"storage");U(this,"cache");U(this,"queueManager");U(this,"eventEmitter");U(this,"options");U(this,"synchronizationManager");U(this,"listenerManager");U(this,"transmitterFactory");this.documentModelModules=e}withStorage(e){return this.storage=e,this}withCache(e){return this.cache=e,this}withQueueManager(e){return this.queueManager=e,this}withEventEmitter(e){return this.eventEmitter=e,this}withSynchronizationManager(e){return this.synchronizationManager=e,this}withListenerManager(e){return this.listenerManager=e,this}withTransmitterFactory(e){return this.transmitterFactory=e,this}withOptions(e){return this.options=e,this}build(){var e;if(this.storage||(this.storage=new rE),this.cache||(this.cache=new Tu),this.queueManager||(this.queueManager=new cl),this.eventEmitter||(this.eventEmitter=new iE),this.synchronizationManager||(this.synchronizationManager=new aE(this.storage,this.storage,this.cache,this.documentModelModules,this.eventEmitter)),!this.listenerManager){const n={...vi,...(e=this.options)==null?void 0:e.listenerManager};this.listenerManager=new Qs(this.synchronizationManager,n)}return this.transmitterFactory||(this.transmitterFactory=new oE(this.listenerManager)),new nE(this.documentModelModules,this.storage,this.storage,this.cache,this.queueManager,this.eventEmitter,this.synchronizationManager,this.listenerManager,this.options)}}var Ti,ud;class uE{constructor(e,n,r){et(this,Ti);U(this,"drive");U(this,"processor");U(this,"taskQueueMethod");U(this,"transmitQueue");this.drive=e,this.processor=n,this.taskQueueMethod=r===void 0?on.runAsap:r}async transmit(e,n){var i;const r=async()=>{var o;const s=[];for(const a of e){const c=await ut(this,Ti,ud).call(this,a),u=await this.drive.getDocument(a.documentId),d=((o=c.at(-1))==null?void 0:o.state)??{};s.push({...a,documentType:u.header.documentType,operations:c,state:d})}try{return await this.processor.onStrands(s),e.map(({operations:a,...c})=>({...c,status:"SUCCESS",revision:Pn(a)}))}catch(a){return pe.error(a),e.map(({operations:c,...u})=>{var d;return{...u,status:"ERROR",revision:((d=c.at(0))==null?void 0:d.index)??0}})}};return this.transmitQueue=((i=this.transmitQueue)==null?void 0:i.then(()=>r()))??r(),this.transmitQueue}async disconnect(){await this.processor.onDisconnect()}}Ti=new WeakSet,ud=async function(e){const n=[],r=new Map,i=async s=>{const o=r.get(s);if(o)return o;const a={revisions:{[e.scope]:s},checkHashes:!1},c=await(e.documentId===e.driveId?this.drive.getDrive(e.driveId,a):this.drive.getDocument(e.documentId,a));return s<0?r.set(s,c.initialState.state[e.scope]):r.set(s,c.state[e.scope]),r.get(s)};for(const s of e.operations){const o=()=>i(s.index),a=await(this.taskQueueMethod?on.runAsapAsync(o,this.taskQueueMethod):o()),c=()=>i(s.index-1),u=await(this.taskQueueMethod?on.runAsapAsync(c,this.taskQueueMethod):c());n.push({...s,state:a,previousState:u})}return n};const lE=Tn.createState;let Xr;typeof window<"u"?window.btoa?Xr=function(t){return btoa(unescape(encodeURIComponent(t)))}:Xr=function(t){const e=unescape(encodeURIComponent(t+""));let n="";for(let r,i,s=0,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";e.charAt(s|0)||(o="=",s%1);n+=o.charAt(63&r>>8-s%1*8)){if(i=e.charCodeAt(s+=3/4),i>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|i}return n}:Xr=function(t){return Buffer.from(t).toString("base64")};function Te(t,e){let n=bc(t,e);return(e&&e.fallback!==void 0?e.fallback:Te.defaults.fallback)===!0&&n===""&&(n=bc(Xr(t),e)),n}const ld={bg:{Й:"Y",й:"y",X:"H",x:"h",Ц:"Ts",ц:"ts",Щ:"Sht",щ:"sht",Ъ:"A",ъ:"a",Ь:"Y",ь:"y"},de:{Ä:"AE",ä:"ae",Ö:"OE",ö:"oe",Ü:"UE",ü:"ue"},sr:{đ:"dj",Đ:"DJ"},uk:{И:"Y",и:"y",Й:"Y",й:"y",Ц:"Ts",ц:"ts",Х:"Kh",х:"kh",Щ:"Shch",щ:"shch",Г:"H",г:"h"}};let Go={};function bc(t,e){if(typeof t!="string")throw new Error("slug() requires a string argument, received "+typeof t);if(!t.isWellFormed())throw new Error("slug() received a malformed string with lone surrogates");typeof e=="string"&&(e={replacement:e}),e=e?Object.assign({},e):{},e.mode=e.mode||Te.defaults.mode;const n=Te.defaults.modes[e.mode],r=["replacement","multicharmap","charmap","remove","lower","trim"];for(let c,u=0,d=r.length;u<d;u++)c=r[u],e[c]=c in e?e[c]:n[c];const i=ld[e.locale]||Go;let s=[];for(const c in e.multicharmap){if(!Object.prototype.hasOwnProperty.call(e.multicharmap,c))continue;const u=c.length;s.indexOf(u)===-1&&s.push(u)}s=s.sort(function(c,u){return u-c});const o=e.mode==="rfc3986"?/[^\w\s\-.~]/:/[^A-Za-z0-9\s]/;let a="";for(let c,u=0,d=t.length;u<d;u++){c=t[u];let l=!1;for(let f=0;f<s.length;f++){const h=s[f],g=t.substr(u,h);if(e.multicharmap[g]){u+=h-1,c=e.multicharmap[g],l=!0;break}}l||(i[c]?c=i[c]:e.charmap[c]?c=e.charmap[c].replace(e.replacement," "):c.includes(e.replacement)?c=c.replace(e.replacement," "):c=c.replace(o,"")),a+=c}return e.remove&&(a=a.replace(e.remove,"")),e.trim&&(a=a.trim()),a=a.replace(/\s+/g,e.replacement),e.lower&&(a=a.toLowerCase()),a}const dd={फ़:"Fi",ग़:"Ghi",ख़:"Khi",क़:"Qi",ड़:"ugDha",ढ़:"ugDhha",य़:"Yi",ज़:"Za",בִי:"i",בֵ:"e",בֵי:"e",בֶ:"e",בַ:"a",בָ:"a",בֹ:"o",וֹ:"o",בֻ:"u",וּ:"u",בּ:"b",כּ:"k",ךּ:"k",פּ:"p",שׁ:"sh",שׂ:"s",בְ:"e",חֱ:"e",חֲ:"a",חֳ:"o",בִ:"i"},fd={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Æ:"AE",Ç:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ő:"O",Ø:"O",Ō:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ű:"U",Ý:"Y",Þ:"TH",ß:"ss",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",æ:"ae",ç:"c",è:"e",é:"e",ê:"e",ë:"e",ì:"i",í:"i",î:"i",ï:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ő:"o",ø:"o",ō:"o",Œ:"OE",œ:"oe",ù:"u",ú:"u",û:"u",ü:"u",ű:"u",ý:"y",þ:"th",ÿ:"y","ẞ":"SS",α:"a",β:"b",γ:"g",δ:"d",ε:"e",ζ:"z",η:"h",θ:"th",ι:"i",κ:"k",λ:"l",μ:"m",ν:"n",ξ:"3",ο:"o",π:"p",ρ:"r",σ:"s",τ:"t",υ:"y",φ:"f",χ:"x",ψ:"ps",ω:"w",ά:"a",έ:"e",ί:"i",ό:"o",ύ:"y",ή:"h",ώ:"w",ς:"s",ϊ:"i",ΰ:"y",ϋ:"y",ΐ:"i",Α:"A",Β:"B",Γ:"G",Δ:"D",Ε:"E",Ζ:"Z",Η:"H",Θ:"Th",Ι:"I",Κ:"K",Λ:"L",Μ:"M",Ν:"N",Ξ:"3",Ο:"O",Π:"P",Ρ:"R",Σ:"S",Τ:"T",Υ:"Y",Φ:"F",Χ:"X",Ψ:"PS",Ω:"W",Ά:"A",Έ:"E",Ί:"I",Ό:"O",Ύ:"Y",Ή:"H",Ώ:"W",Ϊ:"I",Ϋ:"Y",ş:"s",Ş:"S",ı:"i",İ:"I",ğ:"g",Ğ:"G",а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"yo",ж:"zh",з:"z",и:"i",й:"j",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"h",ц:"c",ч:"ch",ш:"sh",щ:"sh",ъ:"u",ы:"y",ь:"",э:"e",ю:"yu",я:"ya",А:"A",Б:"B",В:"V",Г:"G",Д:"D",Е:"E",Ё:"Yo",Ж:"Zh",З:"Z",И:"I",Й:"J",К:"K",Л:"L",М:"M",Н:"N",О:"O",П:"P",Р:"R",С:"S",Т:"T",У:"U",Ф:"F",Х:"H",Ц:"C",Ч:"Ch",Ш:"Sh",Щ:"Sh",Ъ:"U",Ы:"Y",Ь:"",Э:"E",Ю:"Yu",Я:"Ya",Є:"Ye",І:"I",Ї:"Yi",Ґ:"G",є:"ye",і:"i",ї:"yi",ґ:"g",č:"c",ď:"d",ě:"e",ň:"n",ř:"r",š:"s",ť:"t",ů:"u",ž:"z",Č:"C",Ď:"D",Ě:"E",Ň:"N",Ř:"R",Š:"S",Ť:"T",Ů:"U",Ž:"Z",ľ:"l",ĺ:"l",ŕ:"r",Ľ:"L",Ĺ:"L",Ŕ:"R",ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ś:"s",ź:"z",ż:"z",Ą:"A",Ć:"C",Ę:"E",Ł:"L",Ń:"N",Ś:"S",Ź:"Z",Ż:"Z",ā:"a",ē:"e",ģ:"g",ī:"i",ķ:"k",ļ:"l",ņ:"n",ū:"u",Ā:"A",Ē:"E",Ģ:"G",Ī:"I",Ķ:"K",Ļ:"L",Ņ:"N",Ū:"U",أ:"a",إ:"i",ب:"b",ت:"t",ث:"th",ج:"g",ح:"h",خ:"kh",د:"d",ذ:"th",ر:"r",ز:"z",س:"s",ش:"sh",ص:"s",ض:"d",ط:"t",ظ:"th",ع:"aa",غ:"gh",ف:"f",ق:"k",ك:"k",ل:"l",م:"m",ن:"n",ه:"h",و:"o",ي:"y",ء:"aa",ة:"a",آ:"a",ا:"a",پ:"p",ژ:"zh",گ:"g",چ:"ch",ک:"k",ی:"i",ė:"e",į:"i",ų:"u",Ė:"E",Į:"I",Ų:"U",ț:"t",Ț:"T",ţ:"t",Ţ:"T",ș:"s",Ș:"S",ă:"a",Ă:"A",Ạ:"A",Ả:"A",Ầ:"A",Ấ:"A",Ậ:"A",Ẩ:"A",Ẫ:"A",Ằ:"A",Ắ:"A",Ặ:"A",Ẳ:"A",Ẵ:"A",Ẹ:"E",Ẻ:"E",Ẽ:"E",Ề:"E",Ế:"E",Ệ:"E",Ể:"E",Ễ:"E",Ị:"I",Ỉ:"I",Ĩ:"I",Ọ:"O",Ỏ:"O",Ồ:"O",Ố:"O",Ộ:"O",Ổ:"O",Ỗ:"O",Ơ:"O",Ờ:"O",Ớ:"O",Ợ:"O",Ở:"O",Ỡ:"O",Ụ:"U",Ủ:"U",Ũ:"U",Ư:"U",Ừ:"U",Ứ:"U",Ự:"U",Ử:"U",Ữ:"U",Ỳ:"Y",Ỵ:"Y",Ỷ:"Y",Ỹ:"Y",Đ:"D",ạ:"a",ả:"a",ầ:"a",ấ:"a",ậ:"a",ẩ:"a",ẫ:"a",ằ:"a",ắ:"a",ặ:"a",ẳ:"a",ẵ:"a",ẹ:"e",ẻ:"e",ẽ:"e",ề:"e",ế:"e",ệ:"e",ể:"e",ễ:"e",ị:"i",ỉ:"i",ĩ:"i",ọ:"o",ỏ:"o",ồ:"o",ố:"o",ộ:"o",ổ:"o",ỗ:"o",ơ:"o",ờ:"o",ớ:"o",ợ:"o",ở:"o",ỡ:"o",ụ:"u",ủ:"u",ũ:"u",ư:"u",ừ:"u",ứ:"u",ự:"u",ử:"u",ữ:"u",ỳ:"y",ỵ:"y",ỷ:"y",ỹ:"y",đ:"d",Ә:"AE",ә:"ae",Ғ:"GH",ғ:"gh",Қ:"KH",қ:"kh",Ң:"NG",ң:"ng",Ү:"UE",ү:"ue",Ұ:"U",ұ:"u",Һ:"H",һ:"h",Ө:"OE",ө:"oe",ђ:"dj",ј:"j",љ:"lj",њ:"nj",ћ:"c",џ:"dz",Ђ:"Dj",Ј:"j",Љ:"Lj",Њ:"Nj",Ћ:"C",Џ:"Dz",nj:"nj",lj:"lj",Nj:"NJ",Lj:"LJ",अ:"a",आ:"aa",ए:"e",ई:"ii",ऍ:"ei",ऎ:"ae",ऐ:"ai",इ:"i",ओ:"o",ऑ:"oi",ऒ:"oii",ऊ:"uu",औ:"ou",उ:"u",ब:"B",भ:"Bha",च:"Ca",छ:"Chha",ड:"Da",ढ:"Dha",फ:"Fa",ग:"Ga",घ:"Gha",ग़:"Ghi",ह:"Ha",ज:"Ja",झ:"Jha",क:"Ka",ख:"Kha",ख़:"Khi",ल:"L",ळ:"Li",ऌ:"Li",ऴ:"Lii",ॡ:"Lii",म:"Ma",न:"Na",ङ:"Na",ञ:"Nia",ण:"Nae",ऩ:"Ni",ॐ:"oms",प:"Pa",क़:"Qi",र:"Ra",ऋ:"Ri",ॠ:"Ri",ऱ:"Ri",स:"Sa",श:"Sha",ष:"Shha",ट:"Ta",त:"Ta",ठ:"Tha",द:"Tha",थ:"Tha",ध:"Thha",ड़:"ugDha",ढ़:"ugDhha",व:"Va",य:"Ya",य़:"Yi",ज़:"Za",ə:"e",Ə:"E",ა:"a",ბ:"b",გ:"g",დ:"d",ე:"e",ვ:"v",ზ:"z",თ:"t",ი:"i",კ:"k",ლ:"l",მ:"m",ნ:"n",ო:"o",პ:"p",ჟ:"zh",რ:"r",ს:"s",ტ:"t",უ:"u",ფ:"p",ქ:"k",ღ:"gh",ყ:"q",შ:"sh",ჩ:"ch",ც:"ts",ძ:"dz",წ:"ts",ჭ:"ch",ხ:"kh",ჯ:"j",ჰ:"h",ב:"v",גּ:"g",ג:"g",ד:"d",דּ:"d",ה:"h",ו:"v",ז:"z",ח:"h",ט:"t",י:"y",כ:"kh",ך:"kh",ל:"l",מ:"m",ם:"m",נ:"n",ן:"n",ס:"s",פ:"f",ף:"f",ץ:"ts",צ:"ts",ק:"k",ר:"r",תּ:"t",ת:"t"};Te.charmap=Object.assign({},fd);Te.multicharmap=Object.assign({},dd);Te.defaults={charmap:Te.charmap,mode:"pretty",modes:{rfc3986:{replacement:"-",remove:null,lower:!0,charmap:Te.charmap,multicharmap:Te.multicharmap,trim:!0},pretty:{replacement:"-",remove:null,lower:!0,charmap:Te.charmap,multicharmap:Te.multicharmap,trim:!0}},multicharmap:Te.multicharmap,fallback:!0};Te.reset=function(){Te.defaults.modes.rfc3986.charmap=Te.defaults.modes.pretty.charmap=Te.charmap=Te.defaults.charmap=Object.assign({},fd),Te.defaults.modes.rfc3986.multicharmap=Te.defaults.modes.pretty.multicharmap=Te.multicharmap=Te.defaults.multicharmap=Object.assign({},dd),Go=""};Te.extend=function(t){const e=Object.keys(t),n={},r={};for(let i=0;i<e.length;i++)e[i].length>1?n[e[i]]=t[e[i]]:r[e[i]]=t[e[i]];Object.assign(Te.charmap,r),Object.assign(Te.multicharmap,n)};Te.setLocale=function(t){Go=ld[t]||{}};function dE(t){return t?`/d/${Te(t.header.slug)}`:""}function fE(t){if(!t)return"";const e=t.name;return Te(e?`${e}-${t.id}`:t.id)}function pE(t){const e=/^\/d\/[^/]+\/([^/]+)$/.exec(t);return e?e[1]:void 0}function hE(t){if(!t)return;const n=/\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(t);return n?n[0]:void 0}function mE(t){const e=pE(t),n=hE(e);return n||e}function pd(t){const e=/^\/d\/([^/]+)/.exec(t);return e?e[1]:null}function gE(t){return t.replaceAll(/\s/g,"-")}function yE(t){const e=new CustomEvent("ph:setDrive",{detail:{driveId:t}});window.dispatchEvent(e)}function vE(t,e){const n=t.detail.driveId;if(e(n),typeof window>"u")return;if(!n){window.history.pushState(null,"","/");return}const r=window.reactor;r&&r.getDrive(n).then(i=>{const s=dE(i);window.history.pushState(null,"",s)}).catch(i=>pe.error(i))}function IS(t){const e=new CustomEvent("ph:setNode",{detail:{nodeId:t}});window.dispatchEvent(e)}function EE(t,e){const n=t.detail.nodeId;if(e(n),typeof window>"u")return;const r=window.reactor;if(!r)return;const i=pd(window.location.pathname);if(i){if(!n){window.history.pushState(null,"",`/d/${i}`);return}r.getDriveBySlug(i).then(s=>{const a=s.state.global.nodes.find(u=>u.id===n),c=fE(a);window.history.pushState(null,"",`/d/${i}/${c}`)}).catch(s=>pe.error(s))}}function Ir(){return Rt(Eu)}function ki(t){const e=Ir();if(t)return e==null?void 0:e.find(n=>n.header.id===t)}function hd(){return Rt(bu)}function DS(){return Rt(_u)}function NS(){return ce(t=>{yE(t)},[])}function md(){const t=hd();return t==null?void 0:t.header.id}function _E(t){const e=ki(t),n=bE(t);if(e){if("remoteUrl"in e.state.global){const r=e.state.global.remoteUrl;if(typeof r=="string")return r}return n}}function gd(t){const e=ki(t);return e==null?void 0:e.state.local.triggers.find(r=>r.type==="PullResponder")}function bE(t){var n;const e=gd(t);return(n=e==null?void 0:e.data)==null?void 0:n.url}function OS(t){const e=_E(t),n=gd(t);return e!==void 0||n!==void 0}function AS(t){const e=ki(t);if(e)return $s(e)}function RS(t){const e=ki(t);return e?vm(e):!1}function kn(){return window.reactor}const zo={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},yd={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},vd=new globalThis.TextEncoder;function wE(t,e){const n=zo[e];let r=yd[e];for(let i=0;i<t.length;i++)r^=BigInt(t[i]),r=BigInt.asUintN(e,r*n);return r}function SE(t,e,n){if(n.length===0)throw new Error("The `utf8Buffer` option must have a length greater than zero");const r=zo[e];let i=yd[e],s=t;for(;s.length>0;){const o=vd.encodeInto(s,n);s=s.slice(o.read);for(let a=0;a<o.written;a++)i^=BigInt(n[a]),i=BigInt.asUintN(e,i*r)}return i}function TE(t,{size:e=32,utf8Buffer:n}={}){if(!zo[e])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if(typeof t=="string"){if(n)return SE(t,e,n);t=vd.encode(t)}return wE(t,e)}const IE=[32,64,128,256,512,1024],DE=Math.log2(26);function Ed(t,e=10,n="fnv1a"){if(n==="fnv1a"){const r=Math.ceil(e*DE),i=IE.find(o=>o&&o>=r)??1024,s=TE(t,{size:i});return NE(s,e)}else throw new Error(`Unsupported hashing algorithm: ${n}`)}function NE(t,e=10){const n="abcdefghijklmnopqrstuvwxyz";let r="";for(;t>0n&&r.length<e;)r=n[Number(t%26n)]+r,t/=26n;return r.padStart(e,"a")}function CS(t,e){const n=t;return n.createNamespace=(r,i)=>OE(t,r,i??e),n.queryNamespace=(r,i)=>AE(t,r,i??e),n}async function OE(t,e,n){const i=(n==null?void 0:n.hashNamespace)??!0?Ed(e):e;return await t.schema.createSchema(i).ifNotExists().execute(),t.withSchema(i)}function AE(t,e,n){const i=(n==null?void 0:n.hashNamespace)??!0?Ed(e):e,s=t.withSchema(i);return Yo(s)}function Yo(t){return{selectFrom:t.selectFrom.bind(t),selectNoFrom:t.selectNoFrom.bind(t),with:t.with.bind(t),withRecursive:t.withRecursive.bind(t),withSchema:e=>Yo(t.withSchema(e))}}function wc(t){return _d.is(t)}const Sc=Symbol.for("ph.IS_RELATIONAL_DB_PROCESSOR");var Kc;Kc=Sc;class _d{constructor(e,n,r){U(this,"_namespace");U(this,"_filter");U(this,"relationalDb");this._namespace=e,this._filter=n,this.relationalDb=r}static is(e){var r;let n=Object.getPrototypeOf(e);for(;n;){if((r=n.constructor)!=null&&r[Sc])return!0;n=Object.getPrototypeOf(n)}return!1}static getNamespace(e){return`${this.name}_${e.replaceAll("-","_")}`}static query(e,n){return n.queryNamespace(this.getNamespace(e))}get filter(){return this._filter}get namespace(){return this._namespace}get query(){return Yo(this.relationalDb)}}U(_d,Kc,!0);class RE{constructor(e,n){U(this,"listeners");U(this,"drive");U(this,"logger",wt(["document-drive","processor-manager"]));U(this,"processorsByDrive",new Map);U(this,"idToFactory",new Map);U(this,"identifierToListeners",new Map);this.listeners=e,this.drive=n}async registerFactory(e,n){this.logger.debug(`Registering factory '${e}'.`),this.idToFactory.set(e,n);const r=await this.drive.getDrives();for(const i of r)await this.createProcessors(i,e,n)}async unregisterFactory(e){var r;const n=this.identifierToListeners.get(e)??[];for(const i of n)await this.listeners.removeListener(i.driveId,i.listenerId).catch(this.logger.error),(r=i.transmitter)!=null&&r.disconnect&&await i.transmitter.disconnect();this.identifierToListeners.set(e,[])}async registerDrive(e){this.logger.debug(`Registering drive '${e}'.`);for(const[n,r]of this.idToFactory)await this.createProcessors(e,n,r)}async createProcessors(e,n,r){let i=this.identifierToListeners.get(n);i||(i=[],this.identifierToListeners.set(n,i));let s=this.processorsByDrive.get(e);s||(s=[],this.processorsByDrive.set(e,s));let o=[];try{o=await r(e)}catch(a){this.logger.error(`Error creating processors for drive ${e}:`,a);return}for(const{filter:a,processor:c}of o){const u=wc(c);if(u&&s.some(f=>wc(f.processor)&&f.processor.namespace===c.namespace)){this.logger.warn(`Processor with namespace '${c.namespace}' already registered for drive '${e}'.`);continue}u&&await c.initAndUpgrade();const d=rt(),l={driveId:e,listenerId:d,block:!1,system:!1,filter:a,callInfo:void 0,transmitter:new uE(this.drive,c)};await this.listeners.setListener(e,l),i.push(l),s.push({filter:a,processor:c})}}}function CE(){const t=kn(),e=Rt(yu),n=un(Ri);xe(()=>{if(e||!t)return;const r=new RE(t.listeners,t);t.on("driveAdded",async i=>{await r.registerDrive(i.header.id)}),n(r)},[e,t,n])}function bd(){return un(br)}function LE(){const t=md(),e=bd();return ce(()=>{e(t).catch(n=>pe.error(n))},[e,t])}function wd(){return un(vr)}function xE(){const t=wd();return ce(()=>{t().catch(e=>pe.error(e))},[t])}function ME(t){const[e,n]=Cn(!!window.reactor),r=Rt(vu),i=Rt(bo),s=md(),o=Rt(Su),a=wd(),c=bd();xe(()=>{if(e)return;async function u(){const d=await(t==null?void 0:t());window.reactor=d,n(!0)}u().catch(pe.error)},[t,e]),xe(()=>{if(!e||r)return;async function u(){await a()}u().catch(pe.error)},[e,a,r]),xe(()=>{if(!e||!i||o)return;async function u(){await c(s)}u().catch(pe.error)},[e,o,i,s,c])}function PE(){const t=un(xn),e=un(_r),n=ce(i=>{vE(i,t)},[t]),r=ce(i=>{EE(i,e)},[e]);xe(()=>{if(!(typeof window>"u"))return window.addEventListener("ph:setDrive",n),()=>{window.removeEventListener("ph:setDrive",n)}},[n]),xe(()=>{if(!(typeof window>"u"))return window.addEventListener("ph:setNode",r),()=>{window.removeEventListener("ph:setNode",r)}},[r])}function kE(){const t=xE(),e=LE(),n=kn();xe(()=>{if(!n)return;const r=[n.on("syncStatus",(...i)=>{pe.verbose("syncStatus",...i),t(),e()}),n.on("strandUpdate",(...i)=>{pe.verbose("strandUpdate",...i),t(),e()}),n.on("defaultRemoteDrive",(...i)=>{pe.verbose("defaultRemoteDrive",...i),t(),e()}),n.on("clientStrandsError",(...i)=>{pe.verbose("clientStrandsError",...i),t(),e()}),n.on("driveAdded",(...i)=>{pe.verbose("driveAdded",...i),t(),e()}),n.on("driveDeleted",(...i)=>{pe.verbose("driveDeleted",...i),t(),e()}),n.on("documentModelModules",(...i)=>{pe.verbose("documentModelModules",...i),t(),e()}),n.on("documentOperationsAdded",(...i)=>{pe.verbose("documentOperationsAdded",...i),t(),e()}),n.on("driveOperationsAdded",(...i)=>{console.log("driveOperationsAdded",...i),pe.verbose("driveOperationsAdded",...i),t(),e()}),n.on("operationsAdded",(...i)=>{console.log("operationsAdded",...i),pe.verbose("operationsAdded",...i),t(),e()})];return()=>{r.forEach(i=>i())}},[t,e,n])}function $E(){const t=un(xn),e=un(_r),n=Rt(bo),r=Rt(wu),i=kn();xe(()=>{async function s(){if(typeof window>"u"||!i||n)return;const o=window.location.pathname,a=await UE(i,o,t);a&&(r||FE(a,o,e))}s().catch(pe.error)},[i,n,r,t,e])}async function UE(t,e,n){const r=pd(e),i=await t.getDrives(),o=(await Promise.all(i.map(a=>t.getDrive(a)))).find(a=>a.header.slug===r||a.header.id===r);return n(o==null?void 0:o.header.id),o}function FE(t,e,n){const r=mE(e),i=t==null?void 0:t.state.global.nodes,s=i==null?void 0:i.find(o=>o.id===r||gE(o.name)===r);n(s==null?void 0:s.id)}function BE(t){ME(t),kE(),PE(),CE(),$E()}const Qn=wt(["utils/document-model",Math.floor(Math.random()*999).toString()]),jE=parseInt(window.__VITE_ENVS.FILE_UPLOAD_OPERATIONS_CHUNK_SIZE||"50");function LS(t,e,n=Qn.error){const[r,i]=Cn(e),[s,o]=Cn(),a=u=>{o(u),n(u)};return xe(()=>{i(e),o(void 0)},[e]),[r,(u,d,l)=>{o(void 0),i(f=>{if(!t||!f)return f;try{const h=t(f,u),g=u.scope??"global",E=h.operations[g],D=E[E.length-1];if(D.error){const P=new Error(D.error);a(P),l==null||l(P)}return d==null||d(D,{prevState:{...f},newState:{...h}}),h}catch(h){return a(h),l==null||l(h),f}})},s]}async function VE(t,e,n,r){const i=(r==null?void 0:r.operationsLimit)||jE;Qn.verbose(`uploadDocumentOperations(documentId:${t}, ops: ${Object.keys(e.operations).join(",")}, limit:${i})`);for(const s of Object.values(e.operations))for(let o=0;o<s.length;o+=i){Qn.verbose(`uploadDocumentOperations:for(i:${o}, ops:${s.length}, limit:${i}): START`);const a=s.slice(o,o+i),c=a.at(-1);if(!c)break;const{scope:u}=c;await n(t,a),Qn.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}:${u} rev ${c.index}): NEXT`)}Qn.verbose(`uploadDocumentOperations:for:waitForUpdate(${t}): END`)}const GE=async t=>{Dp(t).generateAsync({type:"blob"}).then(n=>{const r=window.document.createElement("a");r.style.display="none",r.href=URL.createObjectURL(n),r.download=`${t.header.name||"Untitled"}.zip`,window.document.body.appendChild(r),r.click(),window.document.body.removeChild(r)}).catch(pe.error)};async function xS(t,e){var i,s;const n=e(t.header.documentType);if(!n)throw new Error(`Document model not supported: ${t.header.documentType}`);const r=n.documentModel.extension;if(!window.showSaveFilePicker){await GE(t);return}try{const o=await window.showSaveFilePicker({suggestedName:`${t.name||((i=t.state.global)==null?void 0:i.name)||"Untitled"}.${r?`${r}.`:""}zip`});await Ni(t,o);const a=(await o.getFile()).path;return typeof window<"u"&&((s=window.electronAPI)==null||s.fileSaved(t,a)),a}catch(o){if(!(o instanceof DOMException&&o.name==="AbortError"))throw o}}async function zE(t,e){const n=await Di(t,i=>i,{checkHashes:!0}),r=e(n.header.documentType);if(!r)throw new Error(`Document "${n.header.documentType}" is not supported`);return r.utils.loadFromInput(t)}function Tc(t){let e=!1;const n=Object.entries(t.operations).reduce((r,[i,s])=>{const o=i;for(const a of s){const c=YE(a);r[o].push(c),c!==a&&(e=!0)}return r},{global:[],local:[]});return e?{...t,operations:n}:t}function YE(t){var n;if(!((n=t.context)!=null&&n.signer)||t.context.signer.signatures)return t;const{signer:e}=t.context;if("signature"in e){const r=e.signature;return{...t,context:{...t.context,signer:{user:e.user,app:e.app,signatures:r!=null&&r.length?[r]:[]}}}}else return t}var Ts={exports:{}};/*!
359
- localForage -- Offline Storage, Improved
360
- Version 1.10.0
361
- https://localforage.github.io/localForage
362
- (c) 2013-2017 Mozilla, Apache License 2.0
363
- */var Ic;function qE(){return Ic||(Ic=1,function(t,e){(function(n){t.exports=n()})(function(){return function n(r,i,s){function o(u,d){if(!i[u]){if(!r[u]){var l=typeof Lr=="function"&&Lr;if(!d&&l)return l(u,!0);if(a)return a(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var h=i[u]={exports:{}};r[u][0].call(h.exports,function(g){var E=r[u][1][g];return o(E||g)},h,h.exports,n,r,i,s)}return i[u].exports}for(var a=typeof Lr=="function"&&Lr,c=0;c<s.length;c++)o(s[c]);return o}({1:[function(n,r,i){(function(s){var o=s.MutationObserver||s.WebKitMutationObserver,a;if(o){var c=0,u=new o(g),d=s.document.createTextNode("");u.observe(d,{characterData:!0}),a=function(){d.data=c=++c%2}}else if(!s.setImmediate&&typeof s.MessageChannel<"u"){var l=new s.MessageChannel;l.port1.onmessage=g,a=function(){l.port2.postMessage(0)}}else"document"in s&&"onreadystatechange"in s.document.createElement("script")?a=function(){var D=s.document.createElement("script");D.onreadystatechange=function(){g(),D.onreadystatechange=null,D.parentNode.removeChild(D),D=null},s.document.documentElement.appendChild(D)}:a=function(){setTimeout(g,0)};var f,h=[];function g(){f=!0;for(var D,P,B=h.length;B;){for(P=h,h=[],D=-1;++D<B;)P[D]();B=h.length}f=!1}r.exports=E;function E(D){h.push(D)===1&&!f&&a()}}).call(this,typeof Ft<"u"?Ft:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(n,r,i){var s=n(1);function o(){}var a={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];r.exports=l;function l(N){if(typeof N!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,N!==o&&E(this,N)}l.prototype.catch=function(N){return this.then(null,N)},l.prototype.then=function(N,X){if(typeof N!="function"&&this.state===u||typeof X!="function"&&this.state===c)return this;var b=new this.constructor(o);if(this.state!==d){var $=this.state===u?N:X;h(b,$,this.outcome)}else this.queue.push(new f(b,N,X));return b};function f(N,X,b){this.promise=N,typeof X=="function"&&(this.onFulfilled=X,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}f.prototype.callFulfilled=function(N){a.resolve(this.promise,N)},f.prototype.otherCallFulfilled=function(N){h(this.promise,this.onFulfilled,N)},f.prototype.callRejected=function(N){a.reject(this.promise,N)},f.prototype.otherCallRejected=function(N){h(this.promise,this.onRejected,N)};function h(N,X,b){s(function(){var $;try{$=X(b)}catch(A){return a.reject(N,A)}$===N?a.reject(N,new TypeError("Cannot resolve promise with itself")):a.resolve(N,$)})}a.resolve=function(N,X){var b=D(g,X);if(b.status==="error")return a.reject(N,b.value);var $=b.value;if($)E(N,$);else{N.state=u,N.outcome=X;for(var A=-1,C=N.queue.length;++A<C;)N.queue[A].callFulfilled(X)}return N},a.reject=function(N,X){N.state=c,N.outcome=X;for(var b=-1,$=N.queue.length;++b<$;)N.queue[b].callRejected(X);return N};function g(N){var X=N&&N.then;if(N&&(typeof N=="object"||typeof N=="function")&&typeof X=="function")return function(){X.apply(N,arguments)}}function E(N,X){var b=!1;function $(O){b||(b=!0,a.reject(N,O))}function A(O){b||(b=!0,a.resolve(N,O))}function C(){X(A,$)}var L=D(C);L.status==="error"&&$(L.value)}function D(N,X){var b={};try{b.value=N(X),b.status="success"}catch($){b.status="error",b.value=$}return b}l.resolve=P;function P(N){return N instanceof this?N:a.resolve(new this(o),N)}l.reject=B;function B(N){var X=new this(o);return a.reject(X,N)}l.all=R;function R(N){var X=this;if(Object.prototype.toString.call(N)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=N.length,$=!1;if(!b)return this.resolve([]);for(var A=new Array(b),C=0,L=-1,O=new this(o);++L<b;)re(N[L],L);return O;function re(oe,I){X.resolve(oe).then(k,function(q){$||($=!0,a.reject(O,q))});function k(q){A[I]=q,++C===b&&!$&&($=!0,a.resolve(O,A))}}}l.race=K;function K(N){var X=this;if(Object.prototype.toString.call(N)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=N.length,$=!1;if(!b)return this.resolve([]);for(var A=-1,C=new this(o);++A<b;)L(N[A]);return C;function L(O){X.resolve(O).then(function(re){$||($=!0,a.resolve(C,re))},function(re){$||($=!0,a.reject(C,re))})}}},{1:1}],3:[function(n,r,i){(function(s){typeof s.Promise!="function"&&(s.Promise=n(2))}).call(this,typeof Ft<"u"?Ft:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(n,r,i){var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(p){return typeof p}:function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p};function o(p,v){if(!(p instanceof v))throw new TypeError("Cannot call a class as a function")}function a(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var c=a();function u(){try{if(!c||!c.open)return!1;var p=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),v=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!p||v)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function d(p,v){p=p||[],v=v||{};try{return new Blob(p,v)}catch(_){if(_.name!=="TypeError")throw _;for(var m=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,w=new m,T=0;T<p.length;T+=1)w.append(p[T]);return w.getBlob(v.type)}}typeof Promise>"u"&&n(3);var l=Promise;function f(p,v){v&&p.then(function(m){v(null,m)},function(m){v(m)})}function h(p,v,m){typeof v=="function"&&p.then(v),typeof m=="function"&&p.catch(m)}function g(p){return typeof p!="string"&&(console.warn(p+" used as a key, but it is not a string."),p=String(p)),p}function E(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var D="local-forage-detect-blob-support",P=void 0,B={},R=Object.prototype.toString,K="readonly",N="readwrite";function X(p){for(var v=p.length,m=new ArrayBuffer(v),w=new Uint8Array(m),T=0;T<v;T++)w[T]=p.charCodeAt(T);return m}function b(p){return new l(function(v){var m=p.transaction(D,N),w=d([""]);m.objectStore(D).put(w,"key"),m.onabort=function(T){T.preventDefault(),T.stopPropagation(),v(!1)},m.oncomplete=function(){var T=navigator.userAgent.match(/Chrome\/(\d+)/),_=navigator.userAgent.match(/Edge\//);v(_||!T||parseInt(T[1],10)>=43)}}).catch(function(){return!1})}function $(p){return typeof P=="boolean"?l.resolve(P):b(p).then(function(v){return P=v,P})}function A(p){var v=B[p.name],m={};m.promise=new l(function(w,T){m.resolve=w,m.reject=T}),v.deferredOperations.push(m),v.dbReady?v.dbReady=v.dbReady.then(function(){return m.promise}):v.dbReady=m.promise}function C(p){var v=B[p.name],m=v.deferredOperations.pop();if(m)return m.resolve(),m.promise}function L(p,v){var m=B[p.name],w=m.deferredOperations.pop();if(w)return w.reject(v),w.promise}function O(p,v){return new l(function(m,w){if(B[p.name]=B[p.name]||S(),p.db)if(v)A(p),p.db.close();else return m(p.db);var T=[p.name];v&&T.push(p.version);var _=c.open.apply(c,T);v&&(_.onupgradeneeded=function(x){var G=_.result;try{G.createObjectStore(p.storeName),x.oldVersion<=1&&G.createObjectStore(D)}catch(H){if(H.name==="ConstraintError")console.warn('The database "'+p.name+'" has been upgraded from version '+x.oldVersion+" to version "+x.newVersion+', but the storage "'+p.storeName+'" already exists.');else throw H}}),_.onerror=function(x){x.preventDefault(),w(_.error)},_.onsuccess=function(){var x=_.result;x.onversionchange=function(G){G.target.close()},m(x),C(p)}})}function re(p){return O(p,!1)}function oe(p){return O(p,!0)}function I(p,v){if(!p.db)return!0;var m=!p.db.objectStoreNames.contains(p.storeName),w=p.version<p.db.version,T=p.version>p.db.version;if(w&&(p.version!==v&&console.warn('The database "'+p.name+`" can't be downgraded from version `+p.db.version+" to version "+p.version+"."),p.version=p.db.version),T||m){if(m){var _=p.db.version+1;_>p.version&&(p.version=_)}return!0}return!1}function k(p){return new l(function(v,m){var w=new FileReader;w.onerror=m,w.onloadend=function(T){var _=btoa(T.target.result||"");v({__local_forage_encoded_blob:!0,data:_,type:p.type})},w.readAsBinaryString(p)})}function q(p){var v=X(atob(p.data));return d([v],{type:p.type})}function j(p){return p&&p.__local_forage_encoded_blob}function Y(p){var v=this,m=v._initReady().then(function(){var w=B[v._dbInfo.name];if(w&&w.dbReady)return w.dbReady});return h(m,p,p),m}function V(p){A(p);for(var v=B[p.name],m=v.forages,w=0;w<m.length;w++){var T=m[w];T._dbInfo.db&&(T._dbInfo.db.close(),T._dbInfo.db=null)}return p.db=null,re(p).then(function(_){return p.db=_,I(p)?oe(p):_}).then(function(_){p.db=v.db=_;for(var x=0;x<m.length;x++)m[x]._dbInfo.db=_}).catch(function(_){throw L(p,_),_})}function ae(p,v,m,w){w===void 0&&(w=1);try{var T=p.db.transaction(p.storeName,v);m(null,T)}catch(_){if(w>0&&(!p.db||_.name==="InvalidStateError"||_.name==="NotFoundError"))return l.resolve().then(function(){if(!p.db||_.name==="NotFoundError"&&!p.db.objectStoreNames.contains(p.storeName)&&p.version<=p.db.version)return p.db&&(p.version=p.db.version+1),oe(p)}).then(function(){return V(p).then(function(){ae(p,v,m,w-1)})}).catch(m);m(_)}}function S(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function W(p){var v=this,m={db:null};if(p)for(var w in p)m[w]=p[w];var T=B[m.name];T||(T=S(),B[m.name]=T),T.forages.push(v),v._initReady||(v._initReady=v.ready,v.ready=Y);var _=[];function x(){return l.resolve()}for(var G=0;G<T.forages.length;G++){var H=T.forages[G];H!==v&&_.push(H._initReady().catch(x))}var J=T.forages.slice(0);return l.all(_).then(function(){return m.db=T.db,re(m)}).then(function(Z){return m.db=Z,I(m,v._defaultConfig.version)?oe(m):Z}).then(function(Z){m.db=T.db=Z,v._dbInfo=m;for(var ne=0;ne<J.length;ne++){var de=J[ne];de!==v&&(de._dbInfo.db=m.db,de._dbInfo.version=m.version)}})}function F(p,v){var m=this;p=g(p);var w=new l(function(T,_){m.ready().then(function(){ae(m._dbInfo,K,function(x,G){if(x)return _(x);try{var H=G.objectStore(m._dbInfo.storeName),J=H.get(p);J.onsuccess=function(){var Z=J.result;Z===void 0&&(Z=null),j(Z)&&(Z=q(Z)),T(Z)},J.onerror=function(){_(J.error)}}catch(Z){_(Z)}})}).catch(_)});return f(w,v),w}function Q(p,v){var m=this,w=new l(function(T,_){m.ready().then(function(){ae(m._dbInfo,K,function(x,G){if(x)return _(x);try{var H=G.objectStore(m._dbInfo.storeName),J=H.openCursor(),Z=1;J.onsuccess=function(){var ne=J.result;if(ne){var de=ne.value;j(de)&&(de=q(de));var _e=p(de,ne.key,Z++);_e!==void 0?T(_e):ne.continue()}else T()},J.onerror=function(){_(J.error)}}catch(ne){_(ne)}})}).catch(_)});return f(w,v),w}function ge(p,v,m){var w=this;p=g(p);var T=new l(function(_,x){var G;w.ready().then(function(){return G=w._dbInfo,R.call(v)==="[object Blob]"?$(G.db).then(function(H){return H?v:k(v)}):v}).then(function(H){ae(w._dbInfo,N,function(J,Z){if(J)return x(J);try{var ne=Z.objectStore(w._dbInfo.storeName);H===null&&(H=void 0);var de=ne.put(H,p);Z.oncomplete=function(){H===void 0&&(H=null),_(H)},Z.onabort=Z.onerror=function(){var _e=de.error?de.error:de.transaction.error;x(_e)}}catch(_e){x(_e)}})}).catch(x)});return f(T,m),T}function le(p,v){var m=this;p=g(p);var w=new l(function(T,_){m.ready().then(function(){ae(m._dbInfo,N,function(x,G){if(x)return _(x);try{var H=G.objectStore(m._dbInfo.storeName),J=H.delete(p);G.oncomplete=function(){T()},G.onerror=function(){_(J.error)},G.onabort=function(){var Z=J.error?J.error:J.transaction.error;_(Z)}}catch(Z){_(Z)}})}).catch(_)});return f(w,v),w}function Ee(p){var v=this,m=new l(function(w,T){v.ready().then(function(){ae(v._dbInfo,N,function(_,x){if(_)return T(_);try{var G=x.objectStore(v._dbInfo.storeName),H=G.clear();x.oncomplete=function(){w()},x.onabort=x.onerror=function(){var J=H.error?H.error:H.transaction.error;T(J)}}catch(J){T(J)}})}).catch(T)});return f(m,p),m}function Xe(p){var v=this,m=new l(function(w,T){v.ready().then(function(){ae(v._dbInfo,K,function(_,x){if(_)return T(_);try{var G=x.objectStore(v._dbInfo.storeName),H=G.count();H.onsuccess=function(){w(H.result)},H.onerror=function(){T(H.error)}}catch(J){T(J)}})}).catch(T)});return f(m,p),m}function St(p,v){var m=this,w=new l(function(T,_){if(p<0){T(null);return}m.ready().then(function(){ae(m._dbInfo,K,function(x,G){if(x)return _(x);try{var H=G.objectStore(m._dbInfo.storeName),J=!1,Z=H.openKeyCursor();Z.onsuccess=function(){var ne=Z.result;if(!ne){T(null);return}p===0||J?T(ne.key):(J=!0,ne.advance(p))},Z.onerror=function(){_(Z.error)}}catch(ne){_(ne)}})}).catch(_)});return f(w,v),w}function Tt(p){var v=this,m=new l(function(w,T){v.ready().then(function(){ae(v._dbInfo,K,function(_,x){if(_)return T(_);try{var G=x.objectStore(v._dbInfo.storeName),H=G.openKeyCursor(),J=[];H.onsuccess=function(){var Z=H.result;if(!Z){w(J);return}J.push(Z.key),Z.continue()},H.onerror=function(){T(H.error)}}catch(Z){T(Z)}})}).catch(T)});return f(m,p),m}function We(p,v){v=E.apply(this,arguments);var m=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||m.name,p.storeName=p.storeName||m.storeName);var w=this,T;if(!p.name)T=l.reject("Invalid arguments");else{var _=p.name===m.name&&w._dbInfo.db,x=_?l.resolve(w._dbInfo.db):re(p).then(function(G){var H=B[p.name],J=H.forages;H.db=G;for(var Z=0;Z<J.length;Z++)J[Z]._dbInfo.db=G;return G});p.storeName?T=x.then(function(G){if(G.objectStoreNames.contains(p.storeName)){var H=G.version+1;A(p);var J=B[p.name],Z=J.forages;G.close();for(var ne=0;ne<Z.length;ne++){var de=Z[ne];de._dbInfo.db=null,de._dbInfo.version=H}var _e=new l(function(we,Me){var Ce=c.open(p.name,H);Ce.onerror=function(Ze){var Bn=Ce.result;Bn.close(),Me(Ze)},Ce.onupgradeneeded=function(){var Ze=Ce.result;Ze.deleteObjectStore(p.storeName)},Ce.onsuccess=function(){var Ze=Ce.result;Ze.close(),we(Ze)}});return _e.then(function(we){J.db=we;for(var Me=0;Me<Z.length;Me++){var Ce=Z[Me];Ce._dbInfo.db=we,C(Ce._dbInfo)}}).catch(function(we){throw(L(p,we)||l.resolve()).catch(function(){}),we})}}):T=x.then(function(G){A(p);var H=B[p.name],J=H.forages;G.close();for(var Z=0;Z<J.length;Z++){var ne=J[Z];ne._dbInfo.db=null}var de=new l(function(_e,we){var Me=c.deleteDatabase(p.name);Me.onerror=function(){var Ce=Me.result;Ce&&Ce.close(),we(Me.error)},Me.onblocked=function(){console.warn('dropInstance blocked for database "'+p.name+'" until all open connections are closed')},Me.onsuccess=function(){var Ce=Me.result;Ce&&Ce.close(),_e(Ce)}});return de.then(function(_e){H.db=_e;for(var we=0;we<J.length;we++){var Me=J[we];C(Me._dbInfo)}}).catch(function(_e){throw(L(p,_e)||l.resolve()).catch(function(){}),_e})})}return f(T,v),T}var If={_driver:"asyncStorage",_initStorage:W,_support:u(),iterate:Q,getItem:F,setItem:ge,removeItem:le,clear:Ee,length:Xe,key:St,keys:Tt,dropInstance:We};function Df(){return typeof openDatabase=="function"}var xt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Nf="~~local_forage_type~",ea=/^~~local_forage_type~([^~]+)~/,Ar="__lfsc__:",zi=Ar.length,Yi="arbf",qi="blob",ta="si08",na="ui08",ra="uic8",ia="si16",sa="si32",oa="ur16",aa="ui32",ca="fl32",ua="fl64",la=zi+Yi.length,da=Object.prototype.toString;function fa(p){var v=p.length*.75,m=p.length,w,T=0,_,x,G,H;p[p.length-1]==="="&&(v--,p[p.length-2]==="="&&v--);var J=new ArrayBuffer(v),Z=new Uint8Array(J);for(w=0;w<m;w+=4)_=xt.indexOf(p[w]),x=xt.indexOf(p[w+1]),G=xt.indexOf(p[w+2]),H=xt.indexOf(p[w+3]),Z[T++]=_<<2|x>>4,Z[T++]=(x&15)<<4|G>>2,Z[T++]=(G&3)<<6|H&63;return J}function Hi(p){var v=new Uint8Array(p),m="",w;for(w=0;w<v.length;w+=3)m+=xt[v[w]>>2],m+=xt[(v[w]&3)<<4|v[w+1]>>4],m+=xt[(v[w+1]&15)<<2|v[w+2]>>6],m+=xt[v[w+2]&63];return v.length%3===2?m=m.substring(0,m.length-1)+"=":v.length%3===1&&(m=m.substring(0,m.length-2)+"=="),m}function Of(p,v){var m="";if(p&&(m=da.call(p)),p&&(m==="[object ArrayBuffer]"||p.buffer&&da.call(p.buffer)==="[object ArrayBuffer]")){var w,T=Ar;p instanceof ArrayBuffer?(w=p,T+=Yi):(w=p.buffer,m==="[object Int8Array]"?T+=ta:m==="[object Uint8Array]"?T+=na:m==="[object Uint8ClampedArray]"?T+=ra:m==="[object Int16Array]"?T+=ia:m==="[object Uint16Array]"?T+=oa:m==="[object Int32Array]"?T+=sa:m==="[object Uint32Array]"?T+=aa:m==="[object Float32Array]"?T+=ca:m==="[object Float64Array]"?T+=ua:v(new Error("Failed to get type for BinaryArray"))),v(T+Hi(w))}else if(m==="[object Blob]"){var _=new FileReader;_.onload=function(){var x=Nf+p.type+"~"+Hi(this.result);v(Ar+qi+x)},_.readAsArrayBuffer(p)}else try{v(JSON.stringify(p))}catch(x){console.error("Couldn't convert value into a JSON string: ",p),v(null,x)}}function Af(p){if(p.substring(0,zi)!==Ar)return JSON.parse(p);var v=p.substring(la),m=p.substring(zi,la),w;if(m===qi&&ea.test(v)){var T=v.match(ea);w=T[1],v=v.substring(T[0].length)}var _=fa(v);switch(m){case Yi:return _;case qi:return d([_],{type:w});case ta:return new Int8Array(_);case na:return new Uint8Array(_);case ra:return new Uint8ClampedArray(_);case ia:return new Int16Array(_);case oa:return new Uint16Array(_);case sa:return new Int32Array(_);case aa:return new Uint32Array(_);case ca:return new Float32Array(_);case ua:return new Float64Array(_);default:throw new Error("Unkown type: "+m)}}var Ji={serialize:Of,deserialize:Af,stringToBuffer:fa,bufferToString:Hi};function pa(p,v,m,w){p.executeSql("CREATE TABLE IF NOT EXISTS "+v.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],m,w)}function Rf(p){var v=this,m={db:null};if(p)for(var w in p)m[w]=typeof p[w]!="string"?p[w].toString():p[w];var T=new l(function(_,x){try{m.db=openDatabase(m.name,String(m.version),m.description,m.size)}catch(G){return x(G)}m.db.transaction(function(G){pa(G,m,function(){v._dbInfo=m,_()},function(H,J){x(J)})},x)});return m.serializer=Ji,T}function Mt(p,v,m,w,T,_){p.executeSql(m,w,T,function(x,G){G.code===G.SYNTAX_ERR?x.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[v.storeName],function(H,J){J.rows.length?_(H,G):pa(H,v,function(){H.executeSql(m,w,T,_)},_)},_):_(x,G)},_)}function Cf(p,v){var m=this;p=g(p);var w=new l(function(T,_){m.ready().then(function(){var x=m._dbInfo;x.db.transaction(function(G){Mt(G,x,"SELECT * FROM "+x.storeName+" WHERE key = ? LIMIT 1",[p],function(H,J){var Z=J.rows.length?J.rows.item(0).value:null;Z&&(Z=x.serializer.deserialize(Z)),T(Z)},function(H,J){_(J)})})}).catch(_)});return f(w,v),w}function Lf(p,v){var m=this,w=new l(function(T,_){m.ready().then(function(){var x=m._dbInfo;x.db.transaction(function(G){Mt(G,x,"SELECT * FROM "+x.storeName,[],function(H,J){for(var Z=J.rows,ne=Z.length,de=0;de<ne;de++){var _e=Z.item(de),we=_e.value;if(we&&(we=x.serializer.deserialize(we)),we=p(we,_e.key,de+1),we!==void 0){T(we);return}}T()},function(H,J){_(J)})})}).catch(_)});return f(w,v),w}function ha(p,v,m,w){var T=this;p=g(p);var _=new l(function(x,G){T.ready().then(function(){v===void 0&&(v=null);var H=v,J=T._dbInfo;J.serializer.serialize(v,function(Z,ne){ne?G(ne):J.db.transaction(function(de){Mt(de,J,"INSERT OR REPLACE INTO "+J.storeName+" (key, value) VALUES (?, ?)",[p,Z],function(){x(H)},function(_e,we){G(we)})},function(de){if(de.code===de.QUOTA_ERR){if(w>0){x(ha.apply(T,[p,H,m,w-1]));return}G(de)}})})}).catch(G)});return f(_,m),_}function xf(p,v,m){return ha.apply(this,[p,v,m,1])}function Mf(p,v){var m=this;p=g(p);var w=new l(function(T,_){m.ready().then(function(){var x=m._dbInfo;x.db.transaction(function(G){Mt(G,x,"DELETE FROM "+x.storeName+" WHERE key = ?",[p],function(){T()},function(H,J){_(J)})})}).catch(_)});return f(w,v),w}function Pf(p){var v=this,m=new l(function(w,T){v.ready().then(function(){var _=v._dbInfo;_.db.transaction(function(x){Mt(x,_,"DELETE FROM "+_.storeName,[],function(){w()},function(G,H){T(H)})})}).catch(T)});return f(m,p),m}function kf(p){var v=this,m=new l(function(w,T){v.ready().then(function(){var _=v._dbInfo;_.db.transaction(function(x){Mt(x,_,"SELECT COUNT(key) as c FROM "+_.storeName,[],function(G,H){var J=H.rows.item(0).c;w(J)},function(G,H){T(H)})})}).catch(T)});return f(m,p),m}function $f(p,v){var m=this,w=new l(function(T,_){m.ready().then(function(){var x=m._dbInfo;x.db.transaction(function(G){Mt(G,x,"SELECT key FROM "+x.storeName+" WHERE id = ? LIMIT 1",[p+1],function(H,J){var Z=J.rows.length?J.rows.item(0).key:null;T(Z)},function(H,J){_(J)})})}).catch(_)});return f(w,v),w}function Uf(p){var v=this,m=new l(function(w,T){v.ready().then(function(){var _=v._dbInfo;_.db.transaction(function(x){Mt(x,_,"SELECT key FROM "+_.storeName,[],function(G,H){for(var J=[],Z=0;Z<H.rows.length;Z++)J.push(H.rows.item(Z).key);w(J)},function(G,H){T(H)})})}).catch(T)});return f(m,p),m}function Ff(p){return new l(function(v,m){p.transaction(function(w){w.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(T,_){for(var x=[],G=0;G<_.rows.length;G++)x.push(_.rows.item(G).name);v({db:p,storeNames:x})},function(T,_){m(_)})},function(w){m(w)})})}function Bf(p,v){v=E.apply(this,arguments);var m=this.config();p=typeof p!="function"&&p||{},p.name||(p.name=p.name||m.name,p.storeName=p.storeName||m.storeName);var w=this,T;return p.name?T=new l(function(_){var x;p.name===m.name?x=w._dbInfo.db:x=openDatabase(p.name,"","",0),p.storeName?_({db:x,storeNames:[p.storeName]}):_(Ff(x))}).then(function(_){return new l(function(x,G){_.db.transaction(function(H){function J(_e){return new l(function(we,Me){H.executeSql("DROP TABLE IF EXISTS "+_e,[],function(){we()},function(Ce,Ze){Me(Ze)})})}for(var Z=[],ne=0,de=_.storeNames.length;ne<de;ne++)Z.push(J(_.storeNames[ne]));l.all(Z).then(function(){x()}).catch(function(_e){G(_e)})},function(H){G(H)})})}):T=l.reject("Invalid arguments"),f(T,v),T}var jf={_driver:"webSQLStorage",_initStorage:Rf,_support:Df(),iterate:Lf,getItem:Cf,setItem:xf,removeItem:Mf,clear:Pf,length:kf,key:$f,keys:Uf,dropInstance:Bf};function Vf(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function ma(p,v){var m=p.name+"/";return p.storeName!==v.storeName&&(m+=p.storeName+"/"),m}function Gf(){var p="_localforage_support_test";try{return localStorage.setItem(p,!0),localStorage.removeItem(p),!1}catch{return!0}}function zf(){return!Gf()||localStorage.length>0}function Yf(p){var v=this,m={};if(p)for(var w in p)m[w]=p[w];return m.keyPrefix=ma(p,v._defaultConfig),zf()?(v._dbInfo=m,m.serializer=Ji,l.resolve()):l.reject()}function qf(p){var v=this,m=v.ready().then(function(){for(var w=v._dbInfo.keyPrefix,T=localStorage.length-1;T>=0;T--){var _=localStorage.key(T);_.indexOf(w)===0&&localStorage.removeItem(_)}});return f(m,p),m}function Hf(p,v){var m=this;p=g(p);var w=m.ready().then(function(){var T=m._dbInfo,_=localStorage.getItem(T.keyPrefix+p);return _&&(_=T.serializer.deserialize(_)),_});return f(w,v),w}function Jf(p,v){var m=this,w=m.ready().then(function(){for(var T=m._dbInfo,_=T.keyPrefix,x=_.length,G=localStorage.length,H=1,J=0;J<G;J++){var Z=localStorage.key(J);if(Z.indexOf(_)===0){var ne=localStorage.getItem(Z);if(ne&&(ne=T.serializer.deserialize(ne)),ne=p(ne,Z.substring(x),H++),ne!==void 0)return ne}}});return f(w,v),w}function Wf(p,v){var m=this,w=m.ready().then(function(){var T=m._dbInfo,_;try{_=localStorage.key(p)}catch{_=null}return _&&(_=_.substring(T.keyPrefix.length)),_});return f(w,v),w}function Kf(p){var v=this,m=v.ready().then(function(){for(var w=v._dbInfo,T=localStorage.length,_=[],x=0;x<T;x++){var G=localStorage.key(x);G.indexOf(w.keyPrefix)===0&&_.push(G.substring(w.keyPrefix.length))}return _});return f(m,p),m}function Qf(p){var v=this,m=v.keys().then(function(w){return w.length});return f(m,p),m}function Xf(p,v){var m=this;p=g(p);var w=m.ready().then(function(){var T=m._dbInfo;localStorage.removeItem(T.keyPrefix+p)});return f(w,v),w}function Zf(p,v,m){var w=this;p=g(p);var T=w.ready().then(function(){v===void 0&&(v=null);var _=v;return new l(function(x,G){var H=w._dbInfo;H.serializer.serialize(v,function(J,Z){if(Z)G(Z);else try{localStorage.setItem(H.keyPrefix+p,J),x(_)}catch(ne){(ne.name==="QuotaExceededError"||ne.name==="NS_ERROR_DOM_QUOTA_REACHED")&&G(ne),G(ne)}})})});return f(T,m),T}function ep(p,v){if(v=E.apply(this,arguments),p=typeof p!="function"&&p||{},!p.name){var m=this.config();p.name=p.name||m.name,p.storeName=p.storeName||m.storeName}var w=this,T;return p.name?T=new l(function(_){p.storeName?_(ma(p,w._defaultConfig)):_(p.name+"/")}).then(function(_){for(var x=localStorage.length-1;x>=0;x--){var G=localStorage.key(x);G.indexOf(_)===0&&localStorage.removeItem(G)}}):T=l.reject("Invalid arguments"),f(T,v),T}var tp={_driver:"localStorageWrapper",_initStorage:Yf,_support:Vf(),iterate:Jf,getItem:Hf,setItem:Zf,removeItem:Xf,clear:qf,length:Qf,key:Wf,keys:Kf,dropInstance:ep},np=function(v,m){return v===m||typeof v=="number"&&typeof m=="number"&&isNaN(v)&&isNaN(m)},rp=function(v,m){for(var w=v.length,T=0;T<w;){if(np(v[T],m))return!0;T++}return!1},ga=Array.isArray||function(p){return Object.prototype.toString.call(p)==="[object Array]"},Fn={},ya={},_n={INDEXEDDB:If,WEBSQL:jf,LOCALSTORAGE:tp},ip=[_n.INDEXEDDB._driver,_n.WEBSQL._driver,_n.LOCALSTORAGE._driver],Rr=["dropInstance"],Wi=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(Rr),sp={description:"",driver:ip.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function op(p,v){p[v]=function(){var m=arguments;return p.ready().then(function(){return p[v].apply(p,m)})}}function Ki(){for(var p=1;p<arguments.length;p++){var v=arguments[p];if(v)for(var m in v)v.hasOwnProperty(m)&&(ga(v[m])?arguments[0][m]=v[m].slice():arguments[0][m]=v[m])}return arguments[0]}var ap=function(){function p(v){o(this,p);for(var m in _n)if(_n.hasOwnProperty(m)){var w=_n[m],T=w._driver;this[m]=T,Fn[T]||this.defineDriver(w)}this._defaultConfig=Ki({},sp),this._config=Ki({},this._defaultConfig,v),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return p.prototype.config=function(m){if((typeof m>"u"?"undefined":s(m))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var w in m){if(w==="storeName"&&(m[w]=m[w].replace(/\W/g,"_")),w==="version"&&typeof m[w]!="number")return new Error("Database version must be a number.");this._config[w]=m[w]}return"driver"in m&&m.driver?this.setDriver(this._config.driver):!0}else return typeof m=="string"?this._config[m]:this._config},p.prototype.defineDriver=function(m,w,T){var _=new l(function(x,G){try{var H=m._driver,J=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!m._driver){G(J);return}for(var Z=Wi.concat("_initStorage"),ne=0,de=Z.length;ne<de;ne++){var _e=Z[ne],we=!rp(Rr,_e);if((we||m[_e])&&typeof m[_e]!="function"){G(J);return}}var Me=function(){for(var Bn=function(lp){return function(){var dp=new Error("Method "+lp+" is not implemented by the current driver"),va=l.reject(dp);return f(va,arguments[arguments.length-1]),va}},Qi=0,up=Rr.length;Qi<up;Qi++){var Xi=Rr[Qi];m[Xi]||(m[Xi]=Bn(Xi))}};Me();var Ce=function(Bn){Fn[H]&&console.info("Redefining LocalForage driver: "+H),Fn[H]=m,ya[H]=Bn,x()};"_support"in m?m._support&&typeof m._support=="function"?m._support().then(Ce,G):Ce(!!m._support):Ce(!0)}catch(Ze){G(Ze)}});return h(_,w,T),_},p.prototype.driver=function(){return this._driver||null},p.prototype.getDriver=function(m,w,T){var _=Fn[m]?l.resolve(Fn[m]):l.reject(new Error("Driver not found."));return h(_,w,T),_},p.prototype.getSerializer=function(m){var w=l.resolve(Ji);return h(w,m),w},p.prototype.ready=function(m){var w=this,T=w._driverSet.then(function(){return w._ready===null&&(w._ready=w._initDriver()),w._ready});return h(T,m,m),T},p.prototype.setDriver=function(m,w,T){var _=this;ga(m)||(m=[m]);var x=this._getSupportedDrivers(m);function G(){_._config.driver=_.driver()}function H(ne){return _._extend(ne),G(),_._ready=_._initStorage(_._config),_._ready}function J(ne){return function(){var de=0;function _e(){for(;de<ne.length;){var we=ne[de];return de++,_._dbInfo=null,_._ready=null,_.getDriver(we).then(H).catch(_e)}G();var Me=new Error("No available storage method found.");return _._driverSet=l.reject(Me),_._driverSet}return _e()}}var Z=this._driverSet!==null?this._driverSet.catch(function(){return l.resolve()}):l.resolve();return this._driverSet=Z.then(function(){var ne=x[0];return _._dbInfo=null,_._ready=null,_.getDriver(ne).then(function(de){_._driver=de._driver,G(),_._wrapLibraryMethodsWithReady(),_._initDriver=J(x)})}).catch(function(){G();var ne=new Error("No available storage method found.");return _._driverSet=l.reject(ne),_._driverSet}),h(this._driverSet,w,T),this._driverSet},p.prototype.supports=function(m){return!!ya[m]},p.prototype._extend=function(m){Ki(this,m)},p.prototype._getSupportedDrivers=function(m){for(var w=[],T=0,_=m.length;T<_;T++){var x=m[T];this.supports(x)&&w.push(x)}return w},p.prototype._wrapLibraryMethodsWithReady=function(){for(var m=0,w=Wi.length;m<w;m++)op(this,Wi[m])},p.prototype.createInstance=function(m){return new p(m)},p}(),cp=new ap;r.exports=cp},{3:3}]},{},[4])(4)})}(Ts)),Ts.exports}var HE=qE();const Dc=Ii(HE),Ie=class Ie{constructor(e){U(this,"db");this.db=Dc.ready().then(()=>Dc.createInstance({name:e?`${e}:${Ie.DBName}`:Ie.DBName}))}async findStorageUnitsBy(e,n,r){const i=[],{parentId:s,documentId:o,documentModelType:a,scope:c}=Gu(e),l=(await(await this.db).keys()).filter(D=>D.startsWith(`${Ie.DOCUMENT_KEY}${Ie.SEP}`)).map(D=>D.slice(Ie.DOCUMENT_KEY.length+Ie.SEP.length));let f;if(s){const D=new Set;for(const P of s)(await this.getChildren(P)).forEach(R=>D.add(R));f=s.union(D)}else f=new Set(l);f=o?o.intersection(f):f;for(const D of f){const P=await this.get(D).catch(()=>null);if(P&&!(a&&!a.has(P.header.documentType)))for(const[B]of Object.entries(P.state))c&&!c.has(B)||i.push({documentId:D,documentModelType:P.header.documentType,scope:B,branch:"main"})}let h=0;if(r){const D=i.findIndex(P=>P.documentId===r);D!==-1&&(h=D)}const g=Math.min(h+n,i.length),E=g<i.length?i[g].documentId:void 0;return{units:i.slice(h,g),nextCursor:E}}async resolveIds(e,n){const r=await this.getSlugManifest();if(n!=null&&n.aborted)throw new Ei("Aborted");const i=[];for(const s of e){const o=r.slugToId[s];if(!o)throw new Ot(s);i.push(o)}return Promise.resolve(i)}async resolveSlugs(e,n){const r=await this.getSlugManifest();if(n!=null&&n.aborted)throw new Ei("Aborted");const i=[];for(const s of e){let o=!1;for(const[a,c]of Object.entries(r.slugToId))if(c===s){i.push(a),o=!0;break}if(!o)throw new Ot(s)}return Promise.resolve(i)}async clear(){await(await this.db).clear()}async exists(e){return!!await(await this.db).getItem(this.buildDocumentKey(e))}async create(e){const n=e.header.id;if(!di(n))throw new li(n);const r=await this.db;if(await this.exists(n))throw new Sn(n);const i=e.header.slug&&e.header.slug.length>0?e.header.slug:n;if(!Vu(i))throw new ju(i);if((await this.getSlugManifest()).slugToId[i])throw new Sn(n);if(e.header.slug=i,await r.setItem(this.buildDocumentKey(n),e),i){const o=await this.getSlugManifest();if(o.slugToId[i])throw new Error(`Document with slug ${i} already exists`);o.slugToId[i]=n,await this.updateSlugManifest(o)}e.header.documentType==="powerhouse/document-drive"&&this.updateDriveManifest(n,{documentIds:[]})}async get(e){const r=await(await this.db).getItem(this.buildDocumentKey(e));return r||Promise.reject(new Ot(e))}async getBySlug(e){const r=(await this.getSlugManifest()).slugToId[e];return r?this.get(r):Promise.reject(new Ot(e))}async findByType(e,n=100,r){const i=await this.db,o=(await i.keys()).filter(l=>l.startsWith(`${Ie.DOCUMENT_KEY}${Ie.SEP}`)),a=[];for(const l of o){const f=l.slice(Ie.DOCUMENT_KEY.length+Ie.SEP.length);try{const h=await i.getItem(l);if(!h||h.header.documentType!==e)continue;a.push({id:f,document:h})}catch{continue}}a.sort((l,f)=>{const h=new Date(l.document.header.createdAtUtcIso),g=new Date(f.document.header.createdAtUtcIso);return h.getTime()===g.getTime()?l.id.localeCompare(f.id):h.getTime()-g.getTime()});let c=0;if(r){const l=a.findIndex(({id:f})=>f===r);l!==-1&&(c=l)}const u=Math.min(c+n,a.length);let d;return u<a.length&&(d=a[u].id),{documents:a.slice(c,u).map(({id:l})=>l),nextCursor:d}}async delete(e){var o;const n=await this.db,r=await n.getItem(this.buildDocumentKey(e));if(!r)return!1;const i=((o=r.header.slug)==null?void 0:o.length)>0?r.header.slug:e;try{if(i){const a=await this.getSlugManifest();a.slugToId[i]===e&&(delete a.slugToId[i],await this.updateSlugManifest(a))}}catch{}const s=await this.getParents(e);for(const a of s)await this.removeChild(a,e);return await n.removeItem(this.buildManifestKey(e)),await n.removeItem(this.buildDocumentKey(e)),!0}async removeChild(e,n){const r=await this.getManifest(e),i=r.documentIds.indexOf(n);return i!==-1?(r.documentIds.splice(i,1),await this.updateDriveManifest(e,r),!0):!1}async addChild(e,n){if(e===n)throw new Error("Cannot associate a document with itself");if((await this.getChildren(n)).includes(e))throw new Error("Cannot associate a document with its child");const i=await this.getManifest(e);i.documentIds.includes(n)||(i.documentIds.push(n),await this.updateDriveManifest(e,i))}async getChildren(e){return(await this.getManifest(e)).documentIds}async getParents(e){const r=await(await this.db).keys(),i=[],s=r.filter(o=>o.startsWith(`${Ie.MANIFEST_KEY}${Ie.SEP}`));for(const o of s){const a=o.slice(Ie.MANIFEST_KEY.length+Ie.SEP.length);(await this.getManifest(a)).documentIds.includes(e)&&i.push(a)}return i}async getManifest(e){return await(await this.db).getItem(this.buildManifestKey(e))||{documentIds:[]}}async updateDriveManifest(e,n){await(await this.db).setItem(this.buildManifestKey(e),n)}async getSlugManifest(){return await(await this.db).getItem(Ie.SLUG_MANIFEST_KEY)||{slugToId:{}}}async updateSlugManifest(e){await(await this.db).setItem(Ie.SLUG_MANIFEST_KEY,e)}async addDocumentOperations(e,n,r){const i=await this.get(e);if(!i)throw new Error(`Document with id ${e} not found`);const s=yi(i.operations,n);await(await this.db).setItem(this.buildDocumentKey(e),{...i,...r,operations:s})}async addDriveOperations(e,n,r){const i=await this.get(e),s=yi(i.operations,n);await(await this.db).setItem(this.buildDocumentKey(e),{...i,...r,operations:s})}async getSynchronizationUnitsRevision(e){return(await Promise.allSettled(e.map(async r=>{var i;try{const s=await this.get(r.documentId);if(!s||!s.operations[r.scope])return;const o=s.operations[r.scope];return{documentId:r.documentId,documentType:r.documentType,scope:r.scope,branch:r.branch,lastUpdated:((i=o.at(-1))==null?void 0:i.timestamp)??s.header.createdAtUtcIso,revision:Pn(o)}}catch{return}}))).reduce((r,i)=>(i.status==="fulfilled"&&i.value!==void 0&&r.push(i.value),r),[])}async migrateOperationSignatures(){let e;do{const{documents:n,nextCursor:r}=await this.findByType("powerhouse/document-drive",100,e);for(const i of n){await this.migrateDrive(i);const s=await this.getChildren(i);await Promise.all(s.map(async o=>this.migrateDocument(i,o)))}e=r}while(e)}async migrateDrive(e){const n=await this.get(e),r=Tc(n);if(r!==n)return(await this.db).setItem(this.buildDocumentKey(e),r)}async migrateDocument(e,n){const r=await this.get(n),i=Tc(r);if(i!==r)return(await this.db).setItem(this.buildDocumentKey(n),i)}buildDocumentKey(e){return`${Ie.DOCUMENT_KEY}${Ie.SEP}${e}`}buildManifestKey(e){return`${Ie.MANIFEST_KEY}${Ie.SEP}${e}`}};U(Ie,"DBName","DOCUMENT_DRIVES"),U(Ie,"SEP",":"),U(Ie,"DOCUMENT_KEY","DOCUMENT"),U(Ie,"MANIFEST_KEY","MANIFEST"),U(Ie,"SLUG_MANIFEST_KEY","SLUG_MANIFEST");let Xs=Ie;const Nc=window.__VITE_ENVS.PH_CONNECT_DEFAULT_DRIVES_URL||void 0,Is=Nc?Nc.split(","):[],JE=()=>({defaultDrives:{remoteDrives:Is.map(e=>({url:e,options:{sharingType:"PUBLIC",availableOffline:!0,listeners:[{block:!0,callInfo:{data:e,name:"switchboard-push",transmitterType:"SwitchboardPush"},filter:{branch:["main"],documentId:["*"],documentType:["*"],scope:["global"]},label:"Switchboard Sync",listenerId:"1",system:!0}],triggers:[]}})),removeOldRemoteDrives:Is.length>0?{strategy:"preserve-by-url-and-detach",urls:Is}:{strategy:"preserve-all"}}});function WE(t){return new Xs(t)}function KE(t,e){return new cE(t).withStorage(e).withCache(new Tu).withQueueManager(new cl).withOptions({...JE()}).build()}async function QE(t,e,n,r,i,s){if(!s||!t.context||!t.context.signer)return t;if(!i)return pe.error(`Document model '${r.header.documentType}' does not have a reducer`),t;const o={documentId:n,signer:t.context.signer};return await Np(t,i,r,o,e)}function XE(t,e,n){return n?{context:{signer:{app:{name:"Connect",key:e||""},user:{address:n.address,networkId:n.networkId,chainId:n.chainId},signatures:[]}},...t}:t}async function $i(){if(import.meta.hot)return import.meta.hot;try{return(await jt(()=>import("../hmr.js"),[],import.meta.url)).hmr}catch{return}}async function MS(t){const e=await $i();if(!e)throw new Error("HMR not available.");return new Promise(n=>{function r(i){t===i.name&&(n(),e==null||e.off("studio:external-package-added",r))}e.on("studio:external-package-added",r),e.send("studio:add-external-package",{name:t})})}async function PS(t){const e=await $i();if(!e)throw new Error("HMR not available.");return new Promise(n=>{function r(i){t===i.name&&(n(),e==null||e.off("studio:external-package-removed",r))}e.on("studio:external-package-removed",r),e.send("studio:remove-external-package",{name:t})})}async function ZE(t){const e=await $i(),n=r=>{const i=jt(()=>import(`${r.url}?t=${r.timestamp}`),[],import.meta.url);t(i.then(s=>s.default))};return e==null||e.on("studio:external-packages-updated",n),()=>{e==null||e.off("studio:external-packages-updated",n)}}const Sd=Object.prototype.toString;function e_(t){switch(Sd.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return Ui(t,Error)}}function $n(t,e){return Sd.call(t)===`[object ${e}]`}function kS(t){return $n(t,"ErrorEvent")}function $S(t){return $n(t,"DOMError")}function US(t){return $n(t,"DOMException")}function bi(t){return $n(t,"String")}function t_(t){return typeof t=="object"&&t!==null&&"__sentry_template_string__"in t&&"__sentry_template_values__"in t}function FS(t){return t===null||t_(t)||typeof t!="object"&&typeof t!="function"}function qo(t){return $n(t,"Object")}function n_(t){return typeof Event<"u"&&Ui(t,Event)}function r_(t){return typeof Element<"u"&&Ui(t,Element)}function i_(t){return $n(t,"RegExp")}function Ho(t){return!!(t&&t.then&&typeof t.then=="function")}function s_(t){return qo(t)&&"nativeEvent"in t&&"preventDefault"in t&&"stopPropagation"in t}function o_(t){return typeof t=="number"&&t!==t}function Ui(t,e){try{return t instanceof e}catch{return!1}}function Td(t){return!!(typeof t=="object"&&t!==null&&(t.__isVue||t._isVue))}function nr(t,e=0){return typeof t!="string"||e===0||t.length<=e?t:`${t.slice(0,e)}...`}function Ds(t,e){let n=t;const r=n.length;if(r<=150)return n;e>r&&(e=r);let i=Math.max(e-60,0);i<5&&(i=0);let s=Math.min(i+140,r);return s>r-5&&(s=r),s===r&&(i=Math.max(s-140,0)),n=n.slice(i,s),i>0&&(n=`'{snip} ${n}`),s<r&&(n+=" {snip}"),n}function BS(t,e){if(!Array.isArray(t))return"";const n=[];for(let r=0;r<t.length;r++){const i=t[r];try{Td(i)?n.push("[VueViewModel]"):n.push(String(i))}catch{n.push("[value cannot be serialized]")}}return n.join(e)}function a_(t,e,n=!1){return bi(t)?i_(e)?e.test(t):bi(e)?n?t===e:t.includes(e):!1:!1}function jS(t,e=[],n=!1){return e.some(r=>a_(t,r,n))}function Br(t){return t&&t.Math==Math?t:void 0}const Je=typeof globalThis=="object"&&Br(globalThis)||typeof window=="object"&&Br(window)||typeof self=="object"&&Br(self)||typeof global=="object"&&Br(global)||function(){return this}()||{};function c_(){return Je}function Id(t,e,n){const r=n||Je,i=r.__SENTRY__=r.__SENTRY__||{};return i[t]||(i[t]=e())}const An=c_(),u_=80;function l_(t,e={}){if(!t)return"<unknown>";try{let n=t;const r=5,i=[];let s=0,o=0;const a=" > ",c=a.length;let u;const d=Array.isArray(e)?e:e.keyAttrs,l=!Array.isArray(e)&&e.maxStringLength||u_;for(;n&&s++<r&&(u=d_(n,d),!(u==="html"||s>1&&o+i.length*c+u.length>=l));)i.push(u),o+=u.length,n=n.parentNode;return i.reverse().join(a)}catch{return"<unknown>"}}function d_(t,e){const n=t,r=[];let i,s,o,a,c;if(!n||!n.tagName)return"";if(An.HTMLElement&&n instanceof HTMLElement&&n.dataset&&n.dataset.sentryComponent)return n.dataset.sentryComponent;r.push(n.tagName.toLowerCase());const u=e&&e.length?e.filter(l=>n.getAttribute(l)).map(l=>[l,n.getAttribute(l)]):null;if(u&&u.length)u.forEach(l=>{r.push(`[${l[0]}="${l[1]}"]`)});else if(n.id&&r.push(`#${n.id}`),i=n.className,i&&bi(i))for(s=i.split(/\s+/),c=0;c<s.length;c++)r.push(`.${s[c]}`);const d=["aria-label","type","name","title","alt"];for(c=0;c<d.length;c++)o=d[c],a=n.getAttribute(o),a&&r.push(`[${o}="${a}"]`);return r.join("")}function VS(){try{return An.document.location.href}catch{return""}}function GS(t){return An.document&&An.document.querySelector?An.document.querySelector(t):null}function zS(t){if(!An.HTMLElement)return null;let e=t;const n=5;for(let r=0;r<n;r++){if(!e)return null;if(e instanceof HTMLElement&&e.dataset.sentryComponent)return e.dataset.sentryComponent;e=e.parentNode}return null}const Jo=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,f_="Sentry Logger ",Oc=["debug","info","warn","error","log","assert","trace"],Ac={};function Dd(t){if(!("console"in Je))return t();const e=Je.console,n={},r=Object.keys(Ac);r.forEach(i=>{const s=Ac[i];n[i]=e[i],e[i]=s});try{return t()}finally{r.forEach(i=>{e[i]=n[i]})}}function p_(){let t=!1;const e={enable:()=>{t=!0},disable:()=>{t=!1},isEnabled:()=>t};return Jo?Oc.forEach(n=>{e[n]=(...r)=>{t&&Dd(()=>{Je.console[n](`${f_}[${n}]:`,...r)})}}):Oc.forEach(n=>{e[n]=()=>{}}),e}const it=p_();function YS(t,e,n){if(!(e in t))return;const r=t[e],i=n(r);typeof i=="function"&&h_(i,r),t[e]=i}function Nd(t,e,n){try{Object.defineProperty(t,e,{value:n,writable:!0,configurable:!0})}catch{Jo&&it.log(`Failed to add non-enumerable property "${e}" to object`,t)}}function h_(t,e){try{const n=e.prototype||{};t.prototype=e.prototype=n,Nd(t,"__sentry_original__",e)}catch{}}function qS(t){return t.__sentry_original__}function HS(t){return Object.keys(t).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&")}function Od(t){if(e_(t))return{message:t.message,name:t.name,stack:t.stack,...Cc(t)};if(n_(t)){const e={type:t.type,target:Rc(t.target),currentTarget:Rc(t.currentTarget),...Cc(t)};return typeof CustomEvent<"u"&&Ui(t,CustomEvent)&&(e.detail=t.detail),e}else return t}function Rc(t){try{return r_(t)?l_(t):Object.prototype.toString.call(t)}catch{return"<unknown>"}}function Cc(t){if(typeof t=="object"&&t!==null){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}else return{}}function JS(t,e=40){const n=Object.keys(Od(t));if(n.sort(),!n.length)return"[object has no keys]";if(n[0].length>=e)return nr(n[0],e);for(let r=n.length;r>0;r--){const i=n.slice(0,r).join(", ");if(!(i.length>e))return r===n.length?i:nr(i,e)}return""}function rn(t){return Zs(t,new Map)}function Zs(t,e){if(m_(t)){const n=e.get(t);if(n!==void 0)return n;const r={};e.set(t,r);for(const i of Object.keys(t))typeof t[i]<"u"&&(r[i]=Zs(t[i],e));return r}if(Array.isArray(t)){const n=e.get(t);if(n!==void 0)return n;const r=[];return e.set(t,r),t.forEach(i=>{r.push(Zs(i,e))}),r}return t}function m_(t){if(!qo(t))return!1;try{const e=Object.getPrototypeOf(t).constructor.name;return!e||e==="Object"}catch{return!0}}const Ad=50,Lc=/\(error: (.*)\)/,xc=/captureMessage|captureException/;function g_(...t){const e=t.sort((n,r)=>n[0]-r[0]).map(n=>n[1]);return(n,r=0)=>{const i=[],s=n.split(`
364
- `);for(let o=r;o<s.length;o++){const a=s[o];if(a.length>1024)continue;const c=Lc.test(a)?a.replace(Lc,"$1"):a;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){i.push(d);break}}if(i.length>=Ad)break}}return y_(i)}}function WS(t){return Array.isArray(t)?g_(...t):t}function y_(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(e[e.length-1].function||"")&&e.pop(),e.reverse(),xc.test(e[e.length-1].function||"")&&(e.pop(),xc.test(e[e.length-1].function||"")&&e.pop()),e.slice(0,Ad).map(n=>({...n,filename:n.filename||e[e.length-1].filename,function:n.function||"?"}))}const Ns="<anonymous>";function v_(t){try{return!t||typeof t!="function"?Ns:t.name||Ns}catch{return Ns}}function Ae(){const t=Je,e=t.crypto||t.msCrypto;let n=()=>Math.random()*16;try{if(e&&e.randomUUID)return e.randomUUID().replace(/-/g,"");e&&e.getRandomValues&&(n=()=>{const r=new Uint8Array(1);return e.getRandomValues(r),r[0]})}catch{}return("10000000100040008000"+1e11).replace(/[018]/g,r=>(r^(n()&15)>>r/4).toString(16))}function Rd(t){return t.exception&&t.exception.values?t.exception.values[0]:void 0}function KS(t){const{message:e,event_id:n}=t;if(e)return e;const r=Rd(t);return r?r.type&&r.value?`${r.type}: ${r.value}`:r.type||r.value||n||"<unknown>":n||"<unknown>"}function QS(t,e,n){const r=t.exception=t.exception||{},i=r.values=r.values||[],s=i[0]=i[0]||{};s.value||(s.value=e||""),s.type||(s.type="Error")}function E_(t,e){const n=Rd(t);if(!n)return;const r={type:"generic",handled:!0},i=n.mechanism;if(n.mechanism={...r,...i,...e},e&&"data"in e){const s={...i&&i.data,...e.data};n.mechanism.data=s}}function XS(t,e,n=5){if(e.lineno===void 0)return;const r=t.length,i=Math.max(Math.min(r-1,e.lineno-1),0);e.pre_context=t.slice(Math.max(0,i-n),i).map(s=>Ds(s,0)),e.context_line=Ds(t[Math.min(r-1,i)],e.colno||0),e.post_context=t.slice(Math.min(i+1,r),i+1+n).map(s=>Ds(s,0))}function ZS(t){if(t&&t.__sentry_captured__)return!0;try{Nd(t,"__sentry_captured__",!0)}catch{}return!1}function __(t){return Array.isArray(t)?t:[t]}function b_(){const t=typeof WeakSet=="function",e=t?new WeakSet:[];function n(i){if(t)return e.has(i)?!0:(e.add(i),!1);for(let s=0;s<e.length;s++)if(e[s]===i)return!0;return e.push(i),!1}function r(i){if(t)e.delete(i);else for(let s=0;s<e.length;s++)if(e[s]===i){e.splice(s,1);break}}return[n,r]}function Zt(t,e=100,n=1/0){try{return eo("",t,e,n)}catch(r){return{ERROR:`**non-serializable** (${r})`}}}function w_(t,e=3,n=100*1024){const r=Zt(t,e);return D_(r)>n?w_(t,e-1,n):r}function eo(t,e,n=1/0,r=1/0,i=b_()){const[s,o]=i;if(e==null||["number","boolean","string"].includes(typeof e)&&!o_(e))return e;const a=S_(t,e);if(!a.startsWith("[object "))return a;if(e.__sentry_skip_normalization__)return e;const c=typeof e.__sentry_override_normalization_depth__=="number"?e.__sentry_override_normalization_depth__:n;if(c===0)return a.replace("object ","");if(s(e))return"[Circular ~]";const u=e;if(u&&typeof u.toJSON=="function")try{const h=u.toJSON();return eo("",h,c-1,r,i)}catch{}const d=Array.isArray(e)?[]:{};let l=0;const f=Od(e);for(const h in f){if(!Object.prototype.hasOwnProperty.call(f,h))continue;if(l>=r){d[h]="[MaxProperties ~]";break}const g=f[h];d[h]=eo(h,g,c-1,r,i),l++}return o(e),d}function S_(t,e){try{if(t==="domain"&&e&&typeof e=="object"&&e._events)return"[Domain]";if(t==="domainEmitter")return"[DomainEmitter]";if(typeof global<"u"&&e===global)return"[Global]";if(typeof window<"u"&&e===window)return"[Window]";if(typeof document<"u"&&e===document)return"[Document]";if(Td(e))return"[VueViewModel]";if(s_(e))return"[SyntheticEvent]";if(typeof e=="number"&&e!==e)return"[NaN]";if(typeof e=="function")return`[Function: ${v_(e)}]`;if(typeof e=="symbol")return`[${String(e)}]`;if(typeof e=="bigint")return`[BigInt: ${String(e)}]`;const n=T_(e);return/^HTML(\w*)Element$/.test(n)?`[HTMLElement: ${n}]`:`[object ${n}]`}catch(n){return`**non-serializable** (${n})`}}function T_(t){const e=Object.getPrototypeOf(t);return e?e.constructor.name:"null prototype"}function I_(t){return~-encodeURI(t).split(/%..|./).length}function D_(t){return I_(JSON.stringify(t))}var Dt;(function(t){t[t.PENDING=0]="PENDING";const n=1;t[t.RESOLVED=n]="RESOLVED";const r=2;t[t.REJECTED=r]="REJECTED"})(Dt||(Dt={}));function eT(t){return new _t(e=>{e(t)})}function tT(t){return new _t((e,n)=>{n(t)})}class _t{constructor(e){_t.prototype.__init.call(this),_t.prototype.__init2.call(this),_t.prototype.__init3.call(this),_t.prototype.__init4.call(this),this._state=Dt.PENDING,this._handlers=[];try{e(this._resolve,this._reject)}catch(n){this._reject(n)}}then(e,n){return new _t((r,i)=>{this._handlers.push([!1,s=>{if(!e)r(s);else try{r(e(s))}catch(o){i(o)}},s=>{if(!n)i(s);else try{r(n(s))}catch(o){i(o)}}]),this._executeHandlers()})}catch(e){return this.then(n=>n,e)}finally(e){return new _t((n,r)=>{let i,s;return this.then(o=>{s=!1,i=o,e&&e()},o=>{s=!0,i=o,e&&e()}).then(()=>{if(s){r(i);return}n(i)})})}__init(){this._resolve=e=>{this._setResult(Dt.RESOLVED,e)}}__init2(){this._reject=e=>{this._setResult(Dt.REJECTED,e)}}__init3(){this._setResult=(e,n)=>{if(this._state===Dt.PENDING){if(Ho(n)){n.then(this._resolve,this._reject);return}this._state=e,this._value=n,this._executeHandlers()}}}__init4(){this._executeHandlers=()=>{if(this._state===Dt.PENDING)return;const e=this._handlers.slice();this._handlers=[],e.forEach(n=>{n[0]||(this._state===Dt.RESOLVED&&n[1](this._value),this._state===Dt.REJECTED&&n[2](this._value),n[0]=!0)})}}}const Cd=1e3;function Fi(){return Date.now()/Cd}function N_(){const{performance:t}=Je;if(!t||!t.now)return Fi;const e=Date.now()-t.now(),n=t.timeOrigin==null?e:t.timeOrigin;return()=>(n+t.now())/Cd}const Wo=N_(),nT=(()=>{const{performance:t}=Je;if(!t||!t.now)return;const e=3600*1e3,n=t.now(),r=Date.now(),i=t.timeOrigin?Math.abs(t.timeOrigin+n-r):e,s=i<e,o=t.timing&&t.timing.navigationStart,c=typeof o=="number"?Math.abs(o+n-r):e,u=c<e;return s||u?i<=c?t.timeOrigin:o:r})(),rT="baggage",Ld="sentry-",O_=/^sentry-/,A_=8192;function xd(t){if(!bi(t)&&!Array.isArray(t))return;let e={};if(Array.isArray(t))e=t.reduce((r,i)=>{const s=Mc(i);for(const o of Object.keys(s))r[o]=s[o];return r},{});else{if(!t)return;e=Mc(t)}const n=Object.entries(e).reduce((r,[i,s])=>{if(i.match(O_)){const o=i.slice(Ld.length);r[o]=s}return r},{});if(Object.keys(n).length>0)return n}function iT(t){if(!t)return;const e=Object.entries(t).reduce((n,[r,i])=>(i&&(n[`${Ld}${r}`]=i),n),{});return R_(e)}function Mc(t){return t.split(",").map(e=>e.split("=").map(n=>decodeURIComponent(n.trim()))).reduce((e,[n,r])=>(e[n]=r,e),{})}function R_(t){if(Object.keys(t).length!==0)return Object.entries(t).reduce((e,[n,r],i)=>{const s=`${encodeURIComponent(n)}=${encodeURIComponent(r)}`,o=i===0?s:`${e},${s}`;return o.length>A_?(Jo&&it.warn(`Not adding key: ${n} with val: ${r} to baggage header due to exceeding baggage size limits.`),e):o},"")}const C_=new RegExp("^[ \\t]*([0-9a-f]{32})?-?([0-9a-f]{16})?-?([01])?[ \\t]*$");function Md(t){if(!t)return;const e=t.match(C_);if(!e)return;let n;return e[3]==="1"?n=!0:e[3]==="0"&&(n=!1),{traceId:e[1],parentSampled:n,parentSpanId:e[2]}}function sT(t,e){const n=Md(t),r=xd(e),{traceId:i,parentSpanId:s,parentSampled:o}=n||{};return n?{traceparentData:n,dynamicSamplingContext:r||{},propagationContext:{traceId:i||Ae(),parentSpanId:s||Ae().substring(16),spanId:Ae().substring(16),sampled:o,dsc:r||{}}}:{traceparentData:n,dynamicSamplingContext:void 0,propagationContext:{traceId:i||Ae(),spanId:Ae().substring(16)}}}function oT(t,e){const n=Md(t),r=xd(e),{traceId:i,parentSpanId:s,parentSampled:o}=n||{};return n?{traceId:i||Ae(),parentSpanId:s||Ae().substring(16),spanId:Ae().substring(16),sampled:o,dsc:r||{}}:{traceId:i||Ae(),spanId:Ae().substring(16)}}function L_(t=Ae(),e=Ae().substring(16),n){let r="";return n!==void 0&&(r=n?"-1":"-0"),`${t}-${e}${r}`}const Rn=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__,Bi="production";function Ko(){return Id("globalEventProcessors",()=>[])}function aT(t){Ko().push(t)}function wi(t,e,n,r=0){return new _t((i,s)=>{const o=t[r];if(e===null||typeof o!="function")i(e);else{const a=o({...e},n);Rn&&o.id&&a===null&&it.log(`Event processor "${o.id}" dropped event`),Ho(a)?a.then(c=>wi(t,c,n,r+1).then(i)).then(null,s):wi(t,a,n,r+1).then(i).then(null,s)}})}function Pd(t){const e=Wo(),n={sid:Ae(),init:!0,timestamp:e,started:e,duration:0,status:"ok",errors:0,ignoreDuration:!1,toJSON:()=>x_(n)};return t&&Dr(n,t),n}function Dr(t,e={}){if(e.user&&(!t.ipAddress&&e.user.ip_address&&(t.ipAddress=e.user.ip_address),!t.did&&!e.did&&(t.did=e.user.id||e.user.email||e.user.username)),t.timestamp=e.timestamp||Wo(),e.abnormal_mechanism&&(t.abnormal_mechanism=e.abnormal_mechanism),e.ignoreDuration&&(t.ignoreDuration=e.ignoreDuration),e.sid&&(t.sid=e.sid.length===32?e.sid:Ae()),e.init!==void 0&&(t.init=e.init),!t.did&&e.did&&(t.did=`${e.did}`),typeof e.started=="number"&&(t.started=e.started),t.ignoreDuration)t.duration=void 0;else if(typeof e.duration=="number")t.duration=e.duration;else{const n=t.timestamp-t.started;t.duration=n>=0?n:0}e.release&&(t.release=e.release),e.environment&&(t.environment=e.environment),!t.ipAddress&&e.ipAddress&&(t.ipAddress=e.ipAddress),!t.userAgent&&e.userAgent&&(t.userAgent=e.userAgent),typeof e.errors=="number"&&(t.errors=e.errors),e.status&&(t.status=e.status)}function kd(t,e){let n={};t.status==="ok"&&(n={status:"exited"}),Dr(t,n)}function x_(t){return rn({sid:`${t.sid}`,init:t.init,started:new Date(t.started*1e3).toISOString(),timestamp:new Date(t.timestamp*1e3).toISOString(),status:t.status,errors:t.errors,did:typeof t.did=="number"||typeof t.did=="string"?`${t.did}`:void 0,duration:t.duration,abnormal_mechanism:t.abnormal_mechanism,attrs:{release:t.release,environment:t.environment,ip_address:t.ipAddress,user_agent:t.userAgent}})}const cT=0,M_=1;function P_(t){const{spanId:e,traceId:n}=t.spanContext(),{data:r,op:i,parent_span_id:s,status:o,tags:a,origin:c}=fr(t);return rn({data:r,op:i,parent_span_id:s,span_id:e,status:o,tags:a,trace_id:n,origin:c})}function uT(t){const{traceId:e,spanId:n}=t.spanContext(),r=$d(t);return L_(e,n,r)}function lT(t){return typeof t=="number"?Pc(t):Array.isArray(t)?t[0]+t[1]/1e9:t instanceof Date?Pc(t.getTime()):Wo()}function Pc(t){return t>9999999999?t/1e3:t}function fr(t){return k_(t)?t.getSpanJSON():typeof t.toJSON=="function"?t.toJSON():{}}function k_(t){return typeof t.getSpanJSON=="function"}function $d(t){const{traceFlags:e}=t.spanContext();return!!(e&M_)}function dT(t,e,n,r,i,s){const{normalizeDepth:o=3,normalizeMaxBreadth:a=1e3}=t,c={...e,event_id:e.event_id||n.event_id||Ae(),timestamp:e.timestamp||Fi()},u=n.integrations||t.integrations.map(D=>D.name);$_(c,t),B_(c,u),e.type===void 0&&U_(c,t.stackParser);const d=V_(r,n.captureContext);n.mechanism&&E_(c,n.mechanism);const l=i&&i.getEventProcessors?i.getEventProcessors():[],f=rb().getScopeData();if(s){const D=s.getScopeData();$c(f,D)}if(d){const D=d.getScopeData();$c(f,D)}const h=[...n.attachments||[],...f.attachments];h.length&&(n.attachments=h),jd(c,f);const g=[...l,...Ko(),...f.eventProcessors];return wi(g,c,n).then(D=>(D&&F_(D),typeof o=="number"&&o>0?j_(D,o,a):D))}function $_(t,e){const{environment:n,release:r,dist:i,maxValueLength:s=250}=e;"environment"in t||(t.environment="environment"in e?n:Bi),t.release===void 0&&r!==void 0&&(t.release=r),t.dist===void 0&&i!==void 0&&(t.dist=i),t.message&&(t.message=nr(t.message,s));const o=t.exception&&t.exception.values&&t.exception.values[0];o&&o.value&&(o.value=nr(o.value,s));const a=t.request;a&&a.url&&(a.url=nr(a.url,s))}const kc=new WeakMap;function U_(t,e){const n=Je._sentryDebugIds;if(!n)return;let r;const i=kc.get(e);i?r=i:(r=new Map,kc.set(e,r));const s=Object.keys(n).reduce((o,a)=>{let c;const u=r.get(a);u?c=u:(c=e(a),r.set(a,c));for(let d=c.length-1;d>=0;d--){const l=c[d];if(l.filename){o[l.filename]=n[a];break}}return o},{});try{t.exception.values.forEach(o=>{o.stacktrace.frames.forEach(a=>{a.filename&&(a.debug_id=s[a.filename])})})}catch{}}function F_(t){const e={};try{t.exception.values.forEach(r=>{r.stacktrace.frames.forEach(i=>{i.debug_id&&(i.abs_path?e[i.abs_path]=i.debug_id:i.filename&&(e[i.filename]=i.debug_id),delete i.debug_id)})})}catch{}if(Object.keys(e).length===0)return;t.debug_meta=t.debug_meta||{},t.debug_meta.images=t.debug_meta.images||[];const n=t.debug_meta.images;Object.keys(e).forEach(r=>{n.push({type:"sourcemap",code_file:r,debug_id:e[r]})})}function B_(t,e){e.length>0&&(t.sdk=t.sdk||{},t.sdk.integrations=[...t.sdk.integrations||[],...e])}function j_(t,e,n){if(!t)return null;const r={...t,...t.breadcrumbs&&{breadcrumbs:t.breadcrumbs.map(i=>({...i,...i.data&&{data:Zt(i.data,e,n)}}))},...t.user&&{user:Zt(t.user,e,n)},...t.contexts&&{contexts:Zt(t.contexts,e,n)},...t.extra&&{extra:Zt(t.extra,e,n)}};return t.contexts&&t.contexts.trace&&r.contexts&&(r.contexts.trace=t.contexts.trace,t.contexts.trace.data&&(r.contexts.trace.data=Zt(t.contexts.trace.data,e,n))),t.spans&&(r.spans=t.spans.map(i=>{const s=fr(i).data;return s&&(i.data=Zt(s,e,n)),i})),r}function V_(t,e){if(!e)return t;const n=t?t.clone():new Ct;return n.update(e),n}function G_(t){if(t)return z_(t)?{captureContext:t}:q_(t)?{captureContext:t}:t}function z_(t){return t instanceof Ct||typeof t=="function"}const Y_=["user","level","extra","contexts","tags","fingerprint","requestSession","propagationContext"];function q_(t){return Object.keys(t).some(e=>Y_.includes(e))}function fT(t,e){return je().captureException(t,G_(e))}function pT(t,e){const n=typeof e=="string"?e:void 0,r=typeof e!="string"?{captureContext:e}:void 0;return je().captureMessage(t,n,r)}function hT(t,e){return je().captureEvent(t,e)}function mT(t){je().configureScope(t)}function gT(t,e){je().addBreadcrumb(t,e)}function yT(t,e){je().setContext(t,e)}function vT(t){je().setExtras(t)}function ET(t,e){je().setExtra(t,e)}function _T(t){je().setTags(t)}function bT(t,e){je().setTag(t,e)}function H_(t){je().setUser(t)}function J_(...t){const e=je();if(t.length===2){const[n,r]=t;return n?e.withScope(()=>(e.getStackTop().scope=n,r(n))):e.withScope(r)}return e.withScope(t[0])}function wT(t){return ab(()=>t(Vi()))}function ST(t,e){return J_(n=>(n.setSpan(t),e(n)))}function TT(t,e){return je().startTransaction({...t},e)}async function IT(t){const e=Un();return e?e.flush(t):(Rn&&it.warn("Cannot flush events. No client defined."),Promise.resolve(!1))}async function DT(t){const e=Un();return e?e.close(t):(Rn&&it.warn("Cannot flush events and disable SDK. No client defined."),Promise.resolve(!1))}function NT(){return je().lastEventId()}function Un(){return je().getClient()}function OT(){return!!Un()}function ji(){return je().getScope()}function AT(t){const e=Un(),n=Vi(),r=ji(),{release:i,environment:s=Bi}=e&&e.getOptions()||{},{userAgent:o}=Je.navigator||{},a=Pd({release:i,environment:s,user:r.getUser()||n.getUser(),...o&&{userAgent:o},...t}),c=n.getSession();return c&&c.status==="ok"&&Dr(c,{status:"exited"}),Ud(),n.setSession(a),r.setSession(a),a}function Ud(){const t=Vi(),e=ji(),n=e.getSession()||t.getSession();n&&kd(n),Fd(),t.setSession(),e.setSession()}function Fd(){const t=Vi(),e=ji(),n=Un(),r=e.getSession()||t.getSession();r&&n&&n.captureSession&&n.captureSession(r)}function RT(t=!1){if(t){Ud();return}Fd()}function Bd(t){return t.transaction}function W_(t,e,n){const r=e.getOptions(),{publicKey:i}=e.getDsn()||{},{segment:s}=n&&n.getUser()||{},o=rn({environment:r.environment||Bi,release:r.release,user_segment:s,public_key:i,trace_id:t});return e.emit&&e.emit("createDsc",o),o}function K_(t){const e=Un();if(!e)return{};const n=W_(fr(t).trace_id||"",e,ji()),r=Bd(t);if(!r)return n;const i=r&&r._frozenDynamicSamplingContext;if(i)return i;const{sampleRate:s,source:o}=r.metadata;s!=null&&(n.sample_rate=`${s}`);const a=fr(r);return o&&o!=="url"&&(n.transaction=a.description),n.sampled=String($d(r)),e.emit&&e.emit("createDsc",n),n}function jd(t,e){const{fingerprint:n,span:r,breadcrumbs:i,sdkProcessingMetadata:s}=e;Q_(t,e),r&&eb(t,r),tb(t,n),X_(t,i),Z_(t,s)}function $c(t,e){const{extra:n,tags:r,user:i,contexts:s,level:o,sdkProcessingMetadata:a,breadcrumbs:c,fingerprint:u,eventProcessors:d,attachments:l,propagationContext:f,transactionName:h,span:g}=e;zn(t,"extra",n),zn(t,"tags",r),zn(t,"user",i),zn(t,"contexts",s),zn(t,"sdkProcessingMetadata",a),o&&(t.level=o),h&&(t.transactionName=h),g&&(t.span=g),c.length&&(t.breadcrumbs=[...t.breadcrumbs,...c]),u.length&&(t.fingerprint=[...t.fingerprint,...u]),d.length&&(t.eventProcessors=[...t.eventProcessors,...d]),l.length&&(t.attachments=[...t.attachments,...l]),t.propagationContext={...t.propagationContext,...f}}function zn(t,e,n){if(n&&Object.keys(n).length){t[e]={...t[e]};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[e][r]=n[r])}}function Q_(t,e){const{extra:n,tags:r,user:i,contexts:s,level:o,transactionName:a}=e,c=rn(n);c&&Object.keys(c).length&&(t.extra={...c,...t.extra});const u=rn(r);u&&Object.keys(u).length&&(t.tags={...u,...t.tags});const d=rn(i);d&&Object.keys(d).length&&(t.user={...d,...t.user});const l=rn(s);l&&Object.keys(l).length&&(t.contexts={...l,...t.contexts}),o&&(t.level=o),a&&(t.transaction=a)}function X_(t,e){const n=[...t.breadcrumbs||[],...e];t.breadcrumbs=n.length?n:void 0}function Z_(t,e){t.sdkProcessingMetadata={...t.sdkProcessingMetadata,...e}}function eb(t,e){t.contexts={trace:P_(e),...t.contexts};const n=Bd(e);if(n){t.sdkProcessingMetadata={dynamicSamplingContext:K_(e),...t.sdkProcessingMetadata};const r=fr(n).description;r&&(t.tags={transaction:r,...t.tags})}}function tb(t,e){t.fingerprint=t.fingerprint?__(t.fingerprint):[],e&&(t.fingerprint=t.fingerprint.concat(e)),t.fingerprint&&!t.fingerprint.length&&delete t.fingerprint}const nb=100;let Os;class Ct{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext=Uc()}static clone(e){return e?e.clone():new Ct}clone(){const e=new Ct;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._extra={...this._extra},e._contexts={...this._contexts},e._user=this._user,e._level=this._level,e._span=this._span,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._requestSession=this._requestSession,e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e}setClient(e){this._client=e}getClient(){return this._client}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,segment:void 0,username:void 0},this._session&&Dr(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}getRequestSession(){return this._requestSession}setRequestSession(e){return this._requestSession=e,this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,n){return this._tags={...this._tags,[e]:n},this._notifyScopeListeners(),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,n){return this._extra={...this._extra,[e]:n},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,n){return n===null?delete this._contexts[e]:this._contexts[e]=n,this._notifyScopeListeners(),this}setSpan(e){return this._span=e,this._notifyScopeListeners(),this}getSpan(){return this._span}getTransaction(){const e=this._span;return e&&e.transaction}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const n=typeof e=="function"?e(this):e;if(n instanceof Ct){const r=n.getScopeData();this._tags={...this._tags,...r.tags},this._extra={...this._extra,...r.extra},this._contexts={...this._contexts,...r.contexts},r.user&&Object.keys(r.user).length&&(this._user=r.user),r.level&&(this._level=r.level),r.fingerprint.length&&(this._fingerprint=r.fingerprint),n.getRequestSession()&&(this._requestSession=n.getRequestSession()),r.propagationContext&&(this._propagationContext=r.propagationContext)}else if(qo(n)){const r=e;this._tags={...this._tags,...r.tags},this._extra={...this._extra,...r.extra},this._contexts={...this._contexts,...r.contexts},r.user&&(this._user=r.user),r.level&&(this._level=r.level),r.fingerprint&&(this._fingerprint=r.fingerprint),r.requestSession&&(this._requestSession=r.requestSession),r.propagationContext&&(this._propagationContext=r.propagationContext)}return this}clear(){return this._breadcrumbs=[],this._tags={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._requestSession=void 0,this._span=void 0,this._session=void 0,this._notifyScopeListeners(),this._attachments=[],this._propagationContext=Uc(),this}addBreadcrumb(e,n){const r=typeof n=="number"?n:nb;if(r<=0)return this;const i={timestamp:Fi(),...e},s=this._breadcrumbs;return s.push(i),this._breadcrumbs=s.length>r?s.slice(-r):s,this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}getAttachments(){return this.getScopeData().attachments}clearAttachments(){return this._attachments=[],this}getScopeData(){const{_breadcrumbs:e,_attachments:n,_contexts:r,_tags:i,_extra:s,_user:o,_level:a,_fingerprint:c,_eventProcessors:u,_propagationContext:d,_sdkProcessingMetadata:l,_transactionName:f,_span:h}=this;return{breadcrumbs:e,attachments:n,contexts:r,tags:i,extra:s,user:o,level:a,fingerprint:c||[],eventProcessors:u,propagationContext:d,sdkProcessingMetadata:l,transactionName:f,span:h}}applyToEvent(e,n={},r=[]){jd(e,this.getScopeData());const i=[...r,...Ko(),...this._eventProcessors];return wi(i,e,n)}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata={...this._sdkProcessingMetadata,...e},this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,n){const r=n&&n.event_id?n.event_id:Ae();if(!this._client)return it.warn("No client configured on scope - will not capture exception!"),r;const i=new Error("Sentry syntheticException");return this._client.captureException(e,{originalException:e,syntheticException:i,...n,event_id:r},this),r}captureMessage(e,n,r){const i=r&&r.event_id?r.event_id:Ae();if(!this._client)return it.warn("No client configured on scope - will not capture message!"),i;const s=new Error(e);return this._client.captureMessage(e,n,{originalException:e,syntheticException:s,...r,event_id:i},this),i}captureEvent(e,n){const r=n&&n.event_id?n.event_id:Ae();return this._client?(this._client.captureEvent(e,{...n,event_id:r},this),r):(it.warn("No client configured on scope - will not capture event!"),r)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}}function rb(){return Os||(Os=new Ct),Os}function Uc(){return{traceId:Ae(),spanId:Ae().substring(16)}}const ib="7.120.3",Vd=parseFloat(ib),sb=100;class Gd{constructor(e,n,r,i=Vd){this._version=i;let s;n?s=n:(s=new Ct,s.setClient(e));let o;r?o=r:(o=new Ct,o.setClient(e)),this._stack=[{scope:s}],e&&this.bindClient(e),this._isolationScope=o}isOlderThan(e){return this._version<e}bindClient(e){const n=this.getStackTop();n.client=e,n.scope.setClient(e),e&&e.setupIntegrations&&e.setupIntegrations()}pushScope(){const e=this.getScope().clone();return this.getStack().push({client:this.getClient(),scope:e}),e}popScope(){return this.getStack().length<=1?!1:!!this.getStack().pop()}withScope(e){const n=this.pushScope();let r;try{r=e(n)}catch(i){throw this.popScope(),i}return Ho(r)?r.then(i=>(this.popScope(),i),i=>{throw this.popScope(),i}):(this.popScope(),r)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStack(){return this._stack}getStackTop(){return this._stack[this._stack.length-1]}captureException(e,n){const r=this._lastEventId=n&&n.event_id?n.event_id:Ae(),i=new Error("Sentry syntheticException");return this.getScope().captureException(e,{originalException:e,syntheticException:i,...n,event_id:r}),r}captureMessage(e,n,r){const i=this._lastEventId=r&&r.event_id?r.event_id:Ae(),s=new Error(e);return this.getScope().captureMessage(e,n,{originalException:e,syntheticException:s,...r,event_id:i}),i}captureEvent(e,n){const r=n&&n.event_id?n.event_id:Ae();return e.type||(this._lastEventId=r),this.getScope().captureEvent(e,{...n,event_id:r}),r}lastEventId(){return this._lastEventId}addBreadcrumb(e,n){const{scope:r,client:i}=this.getStackTop();if(!i)return;const{beforeBreadcrumb:s=null,maxBreadcrumbs:o=sb}=i.getOptions&&i.getOptions()||{};if(o<=0)return;const c={timestamp:Fi(),...e},u=s?Dd(()=>s(c,n)):c;u!==null&&(i.emit&&i.emit("beforeAddBreadcrumb",u,n),r.addBreadcrumb(u,o))}setUser(e){this.getScope().setUser(e),this.getIsolationScope().setUser(e)}setTags(e){this.getScope().setTags(e),this.getIsolationScope().setTags(e)}setExtras(e){this.getScope().setExtras(e),this.getIsolationScope().setExtras(e)}setTag(e,n){this.getScope().setTag(e,n),this.getIsolationScope().setTag(e,n)}setExtra(e,n){this.getScope().setExtra(e,n),this.getIsolationScope().setExtra(e,n)}setContext(e,n){this.getScope().setContext(e,n),this.getIsolationScope().setContext(e,n)}configureScope(e){const{scope:n,client:r}=this.getStackTop();r&&e(n)}run(e){const n=Fc(this);try{e(this)}finally{Fc(n)}}getIntegration(e){const n=this.getClient();if(!n)return null;try{return n.getIntegration(e)}catch{return Rn&&it.warn(`Cannot retrieve integration ${e.id} from the current Hub`),null}}startTransaction(e,n){const r=this._callExtensionMethod("startTransaction",e,n);return Rn&&!r&&(this.getClient()?it.warn(`Tracing extension 'startTransaction' has not been added. Call 'addTracingExtensions' before calling 'init':
365
- Sentry.addTracingExtensions();
366
- Sentry.init({...});
367
- `):it.warn("Tracing extension 'startTransaction' is missing. You should 'init' the SDK before calling 'startTransaction'")),r}traceHeaders(){return this._callExtensionMethod("traceHeaders")}captureSession(e=!1){if(e)return this.endSession();this._sendSessionUpdate()}endSession(){const n=this.getStackTop().scope,r=n.getSession();r&&kd(r),this._sendSessionUpdate(),n.setSession()}startSession(e){const{scope:n,client:r}=this.getStackTop(),{release:i,environment:s=Bi}=r&&r.getOptions()||{},{userAgent:o}=Je.navigator||{},a=Pd({release:i,environment:s,user:n.getUser(),...o&&{userAgent:o},...e}),c=n.getSession&&n.getSession();return c&&c.status==="ok"&&Dr(c,{status:"exited"}),this.endSession(),n.setSession(a),a}shouldSendDefaultPii(){const e=this.getClient(),n=e&&e.getOptions();return!!(n&&n.sendDefaultPii)}_sendSessionUpdate(){const{scope:e,client:n}=this.getStackTop(),r=e.getSession();r&&n&&n.captureSession&&n.captureSession(r)}_callExtensionMethod(e,...n){const i=Nr().__SENTRY__;if(i&&i.extensions&&typeof i.extensions[e]=="function")return i.extensions[e].apply(this,n);Rn&&it.warn(`Extension method ${e} couldn't be found, doing nothing.`)}}function Nr(){return Je.__SENTRY__=Je.__SENTRY__||{extensions:{},hub:void 0},Je}function Fc(t){const e=Nr(),n=to(e);return zd(e,t),n}function je(){const t=Nr();if(t.__SENTRY__&&t.__SENTRY__.acs){const e=t.__SENTRY__.acs.getCurrentHub();if(e)return e}return ob(t)}function Vi(){return je().getIsolationScope()}function ob(t=Nr()){return(!cb(t)||to(t).isOlderThan(Vd))&&zd(t,new Gd),to(t)}function ab(t,e={}){const n=Nr();return n.__SENTRY__&&n.__SENTRY__.acs?n.__SENTRY__.acs.runWithAsyncContext(t,e):t()}function cb(t){return!!(t&&t.__SENTRY__&&t.__SENTRY__.hub)}function to(t){return Id("hub",()=>new Gd,t)}function zd(t,e){if(!t)return!1;const n=t.__SENTRY__=t.__SENTRY__||{};return n.hub=e,!0}const ub=window.__VITE_ENVS.PH_CONNECT_RENOWN_URL||"https://www.renown.id",lb=window.__VITE_ENVS.PH_CONNECT_RENOWN_NETWORK_ID||"eip155",db=window.__VITE_ENVS.PH_CONNECT_RENOWN_CHAIN_ID||"1",hn={},fb=Symbol((hn?"production":void 0)!=="production"?"RESET":""),Yd=t=>typeof(t==null?void 0:t.then)=="function";function pb(t=()=>{try{return window.localStorage}catch(n){(hn?"production":void 0)!=="production"&&typeof window<"u"&&console.warn(n);return}},e){var n;let r,i;const s={getItem:(c,u)=>{var d,l;const f=g=>{if(g=g||"",r!==g){try{i=JSON.parse(g,void 0)}catch{return u}r=g}return i},h=(l=(d=t())==null?void 0:d.getItem(c))!=null?l:null;return Yd(h)?h.then(f):f(h)},setItem:(c,u)=>{var d;return(d=t())==null?void 0:d.setItem(c,JSON.stringify(u,void 0))},removeItem:c=>{var u;return(u=t())==null?void 0:u.removeItem(c)}},o=c=>(u,d,l)=>c(u,f=>{let h;try{h=JSON.parse(f||"")}catch{h=l}d(h)});let a;try{a=(n=t())==null?void 0:n.subscribe}catch{}return!a&&typeof window<"u"&&typeof window.addEventListener=="function"&&window.Storage&&(a=(c,u)=>{if(!(t()instanceof window.Storage))return()=>{};const d=l=>{l.storageArea===t()&&l.key===c&&u(l.newValue)};return window.addEventListener("storage",d),()=>{window.removeEventListener("storage",d)}}),a&&(s.subscribe=o(a)),s}const hb=pb();function qd(t,e,n=hb,r){const i=ke(e);return(hn?"production":void 0)!=="production"&&(i.debugPrivate=!0),i.onMount=o=>{o(n.getItem(t,e));let a;return n.subscribe&&(a=n.subscribe(t,o,e)),a},ke(o=>o(i),(o,a,c)=>{const u=typeof c=="function"?c(o(i)):c;return u===fb?(a(i,e),n.removeItem(t)):Yd(u)?u.then(d=>(a(i,d),n.setItem(t,d))):(a(i,u),n.setItem(t,u))})}const As=new WeakMap,mb=(t,e)=>(As.has(e)?As:As.set(e,t())).get(e),gb=t=>typeof(t==null?void 0:t.then)=="function",Bc={state:"loading"};function CT(t){return mb(()=>{const e=new WeakMap,n=ke(0);(hn?"production":void 0)!=="production"&&(n.debugPrivate=!0);const r=ke((i,{setSelf:s})=>{i(n);let o;try{o=i(t)}catch(d){return{state:"hasError",error:d}}if(!gb(o))return{state:"hasData",data:o};const a=o,c=e.get(a);if(c)return c;a.then(d=>{e.set(a,{state:"hasData",data:d}),s()},d=>{e.set(a,{state:"hasError",error:d}),s()});const u=e.get(a);return u||(e.set(a,Bc),Bc)},(i,s)=>{s(n,o=>o+1)});return(hn?"production":void 0)!=="production"&&(r.debugPrivate=!0),ke(i=>i(r))},t)}const jc=(t,e,n)=>(e.has(n)?e:e.set(n,t())).get(n),yb=new WeakMap,vb=(t,e,n)=>{const r=jc(()=>new WeakMap,yb,e);return jc(t,r,n)},Eb=t=>typeof(t==null?void 0:t.then)=="function",_b=()=>{};function bb(t,e=_b){return vb(()=>{const n=new WeakMap,r=new WeakMap,i=ke(0);(hn?"production":void 0)!=="production"&&(i.debugPrivate=!0);const s=ke((o,{setSelf:a})=>{o(i);const c=o(s),u=o(t);if(!Eb(u))return{v:u};if(u!==(c==null?void 0:c.p)&&u.then(d=>{r.set(u,d),a()},d=>{n.set(u,d),a()}),n.has(u))throw n.get(u);return r.has(u)?{p:u,v:r.get(u)}:c&&"v"in c?{p:u,f:e(c.v),v:c.v}:{p:u,f:e()}},(o,a)=>{a(i,c=>c+1)});return s.init=void 0,(hn?"production":void 0)!=="production"&&(s.debugPrivate=!0),ke(o=>{const a=o(s);return"f"in a?a.f:a.v},(o,a,...c)=>a(t,...c))},t,e)}function wb(t){const e=ke(void 0);return delete e.init,Object.defineProperty(e,"init",{get(){return t()}}),e}const Sb=gr.routerBasename+"external-packages.js",Tb=window.__VITE_ENVS.PROD;async function Ib(){try{return Tb?(await import(Sb)).default??[]:[]}catch(t){return console.error(t),[]}}const Hd=ke(async()=>typeof await $i()<"u");Hd.debugLabel="hmrAvailableAtom";const LT=()=>Vt(Hd),Or=wb(Ib);Or.debugLabel="externalPackagesAtomInConnect";let Vc;Or.onMount=t=>{Vc||(Vc=ZE(e=>{t(e)}))};const Db=()=>Vt(Or),Nb={id:"powerhouse/common",name:"Generic Drive Explorer",driveEditor:"GenericDriveExplorer"},Jd=ke(async t=>{const e=await t(Or);return[Nb,...e.map(n=>n.manifest.apps).filter(n=>n!==void 0).flat()]});Jd.debugLabel="appsAtomInConnect";const Ob=()=>Vt(Jd),xT=()=>{const t=Ob();return ce(e=>{if(!e)return;const n=t.find(r=>r.driveEditor===e);return n==null?void 0:n.name},[t])},MT=t=>{const e=Db();return mr(()=>{if(!t)return;const n=e.find(r=>{var i;return(i=r.manifest.apps)==null?void 0:i.find(s=>s.driveEditor===t)});return n==null?void 0:n.editors.find(r=>r.config.id===t)},[e,t])};let jr;async function Ab(){const{ConnectCrypto:t}=await jt(async()=>{const{ConnectCrypto:r}=await import("./index.BTPk1US_.js");return{ConnectCrypto:r}},__vite__mapDeps([0,1,2,3,4]),import.meta.url),{BrowserKeyStorage:e}=await jt(async()=>{const{BrowserKeyStorage:r}=await import("./index.BTPk1US_.js");return{BrowserKeyStorage:r}},__vite__mapDeps([0,1,2,3,4]),import.meta.url),n=new t(new e);return await n.did(),n}function en(){return window.connectCrypto?Promise.resolve(window.connectCrypto):jr||(jr=Ab(),jr)}function Qo(){return mr(()=>({async regenerateDid(){return(await en()).regenerateDid()},async did(){return(await en()).did()},sign:async t=>await(await en()).sign(t),async getIssuer(){return(await en()).getIssuer()},async getBearerToken(t,e,n=!1){return(await en()).getBearerToken(t,e,n)}}),[])}const Wd=ke(void 0);Wd.debugLabel="didAtomInConnect";function Rb(){const[t,e]=cn(Wd);return xe(()=>{t||en().then(n=>n.did()).then(n=>e(n)).catch(pe.error)}),t}const Kd=ke("idle");Kd.debugLabel="renownStatusAtomInConnect";const Qd=ke(window.renown?Promise.resolve(window.renown):void 0);Qd.debugLabel="renownAtomInConnect";function Gi(){const[t,e]=cn(Qd),[n,r]=cn(Kd),{did:i}=Qo();async function s(o){r("loading");try{const a=await o();if(!a){r("error");return}const{initRenownBrowser:c}=await jt(async()=>{const{initRenownBrowser:l}=await import("./index.RKFvkVvX.js").then(f=>f.b);return{initRenownBrowser:l}},__vite__mapDeps([2,1]),import.meta.url),u=c(a),d={user:function(){return Promise.resolve(u.user)},login:function(l){return u.login(l)},logout(){return Promise.resolve(u.logout())},on:{user(l){return u.on("user",l)}}};return r("finished"),d}catch(a){console.error("Error initializing renown:",a instanceof Error?a.message:"Unknown error"),r("error");return}}return!t&&n==="idle"&&e(s(i)),t}function Cb(){if(console&&console.warn){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];typeof e[0]=="string"&&(e[0]=`react-i18next:: ${e[0]}`),console.warn(...e)}}const Gc={};function no(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];typeof e[0]=="string"&&Gc[e[0]]||(typeof e[0]=="string"&&(Gc[e[0]]=new Date),Cb(...e))}const Xd=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}};function zc(t,e,n){t.loadNamespaces(e,Xd(t,n))}function Yc(t,e,n,r){typeof n=="string"&&(n=[n]),n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,Xd(t,r))}function Lb(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=e.languages[0],i=e.options?e.options.fallbackLng:!1,s=e.languages[e.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const o=(a,c)=>{const u=e.services.backendConnector.state[`${a}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&e.services.backendConnector.backend&&e.isLanguageChangingTo&&!o(e.isLanguageChangingTo,t)?!1:!!(e.hasResourceBundle(r,t)||!e.services.backendConnector.backend||e.options.resources&&!e.options.partialBundledLanguages||o(r,t)&&(!i||o(s,t)))}function xb(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!e.languages||!e.languages.length?(no("i18n.languages were undefined or empty",e.languages),!0):e.options.ignoreJSONStructure!==void 0?e.hasLoadedNamespace(t,{lng:n.lng,precheck:(i,s)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&i.services.backendConnector.backend&&i.isLanguageChangingTo&&!s(i.isLanguageChangingTo,t))return!1}}):Lb(t,e,n)}const Mb=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Pb={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},kb=t=>Pb[t],$b=t=>t.replace(Mb,kb);let ro={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:$b};function PT(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ro={...ro,...t}}function Ub(){return ro}let Zd;function kT(t){Zd=t}function Fb(){return Zd}const Bb=mo();class jb{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const Vb=(t,e)=>{const n=an();return xe(()=>{n.current=t},[t,e]),n.current};function ef(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=e,{i18n:r,defaultNS:i}=go(Bb)||{},s=n||r||Fb();if(s&&!s.reportNamespaces&&(s.reportNamespaces=new jb),!s){no("You will need to pass in an i18next instance by using initReactI18next");const R=(N,X)=>typeof X=="string"?X:X&&typeof X=="object"&&typeof X.defaultValue=="string"?X.defaultValue:Array.isArray(N)?N[N.length-1]:N,K=[R,{},!1];return K.t=R,K.i18n={},K.ready=!1,K}s.options.react&&s.options.react.wait!==void 0&&no("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const o={...Ub(),...s.options.react,...e},{useSuspense:a,keyPrefix:c}=o;let u=i||s.options&&s.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],s.reportNamespaces.addUsedNamespaces&&s.reportNamespaces.addUsedNamespaces(u);const d=(s.isInitialized||s.initializedStoreOnce)&&u.every(R=>xb(R,s,o));function l(){return s.getFixedT(e.lng||null,o.nsMode==="fallback"?u:u[0],c)}const[f,h]=Cn(l);let g=u.join();e.lng&&(g=`${e.lng}${g}`);const E=Vb(g),D=an(!0);xe(()=>{const{bindI18n:R,bindI18nStore:K}=o;D.current=!0,!d&&!a&&(e.lng?Yc(s,e.lng,u,()=>{D.current&&h(l)}):zc(s,u,()=>{D.current&&h(l)})),d&&E&&E!==g&&D.current&&h(l);function N(){D.current&&h(l)}return R&&s&&s.on(R,N),K&&s&&s.store.on(K,N),()=>{D.current=!1,R&&s&&R.split(" ").forEach(X=>s.off(X,N)),K&&s&&K.split(" ").forEach(X=>s.store.off(X,N))}},[s,g]);const P=an(!0);xe(()=>{D.current&&!P.current&&h(l),P.current=!1},[s,c]);const B=[f,s,d];if(B.t=f,B.i18n=s,B.ready=d,d||!d&&!a)return B;throw new Promise(R=>{e.lng?Yc(s,e.lng,u,()=>R()):zc(s,u,()=>R())})}const Gb="connect";function Rs(t,e){const{type:n="default",containerId:r=Gb,...i}=e||{};return Op(t,{type:n,containerId:r,...i})}const tn=gr.routerBasename,zb=(t,e,n,r)=>{const i=qd(`${tn}:${t}`,e,void 0);return i.debugLabel=`storageAtom:${tn}:${t}`,i},$T=(t,e,n)=>{const r=qd(t,e,{getItem(i,s){const o=localStorage.getItem(`${tn}:${i}`);return o?JSON.parse(o):s},setItem(i,s){localStorage.setItem(`${tn}:${i}`,JSON.stringify(s)),n(s)},removeItem(i){localStorage.removeItem(`${tn}:${i}`)},subscribe(i,s){if(typeof window.addEventListener>"u")return()=>null;function o(a){a.storageArea===localStorage&&a.key===`${tn}:${i}`&&s(a.newValue??"")}return window.addEventListener("storage",o),()=>window.removeEventListener("storage",o)}});return r.debugLabel=`storageAtomWithCallback:${tn}:${t}`,r},Yb={id:"powerhouse/package",name:"Vetra Package",extension:".phdm",description:"This document model defines the schema for PH package information.",author:{name:"Powerhouse",website:"https://powerhouse.inc"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type VetraPackageState {
368
- name: String
369
- description: String
370
- category: String
371
- author: Author!
372
- keywords: [Keyword!]!
373
- githubUrl: URL
374
- npmUrl: URL
375
- }
376
-
377
- type Author {
378
- name: String
379
- website: URL
380
- }
381
-
382
- type Keyword {
383
- id: OID!
384
- label: String!
385
- }`,initialValue:'"{\\n \\"name\\": null,\\n \\"description\\": null,\\n \\"category\\": null,\\n \\"author\\": {\\n \\"name\\": null,\\n \\"website\\": null\\n },\\n \\"keywords\\": [],\\n \\"githubUrl\\": null,\\n \\"npmUrl\\": null\\n}"',examples:[]},local:{schema:"",initialValue:'""',examples:[]}},modules:[{id:"a6156f32-8120-43a5-be8b-51c7feaa3460",name:"base_operations",description:"",operations:[{id:"33f2eab7-9e07-497f-a4e6-53e50968c3c9",name:"SET_PACKAGE_NAME",description:"",schema:`input SetPackageNameInput {
386
- name: String!
387
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"a07bee80-c2a8-40d7-891b-822ee298d7d9",name:"SET_PACKAGE_DESCRIPTION",description:"",schema:`input SetPackageDescriptionInput {
388
- description: String!
389
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"f3ad82f8-580a-4c6e-b930-e203cda998bb",name:"SET_PACKAGE_CATEGORY",description:"",schema:`input SetPackageCategoryInput {
390
- category: String!
391
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"67f43579-ce98-47e6-bf48-27c0f44818b9",name:"SET_PACKAGE_AUTHOR",description:"",schema:`input SetPackageAuthorInput {
392
- name: OID
393
- website: URL
394
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"94ba44c4-9627-405e-9ea2-34e9da1c283a",name:"SET_PACKAGE_AUTHOR_NAME",description:"",schema:`input SetPackageAuthorNameInput {
395
- name: String!
396
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"3d5c08df-6c14-480b-915b-875941979fd0",name:"SET_PACKAGE_AUTHOR_WEBSITE",description:"",schema:`input SetPackageAuthorWebsiteInput {
397
- website: URL!
398
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"ed95f841-6fd0-4552-898d-e915599b7495",name:"ADD_PACKAGE_KEYWORD",description:"",schema:`input AddPackageKeywordInput {
399
- id: String!
400
- label: String!
401
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"83c4db24-bd2f-424d-9e26-751580d6307b",name:"REMOVE_PACKAGE_KEYWORD",description:"",schema:`input RemovePackageKeywordInput {
402
- id: String!
403
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"83a90530-8535-4ea7-ab53-7865532398f7",name:"SET_PACKAGE_GITHUB_URL",description:"",schema:`input SetPackageGithubUrlInput {
404
- url: URL!
405
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"e789859a-01ee-4b60-8e7e-a3ad928a26d1",name:"SET_PACKAGE_NPM_URL",description:"",schema:`input SetPackageNpmUrlInput {
406
- url: URL!
407
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"}]}]}]},qb=t=>t!=null;oo().refine(t=>qb(t));function tf(){return ye({id:ie(),label:ie()})}function nf(){return ye({id:ie()})}function rf(){return ye({name:ie().nullish(),website:ie().url().nullish()})}function sf(){return ye({name:ie()})}function of(){return ye({website:ie().url()})}function af(){return ye({category:ie()})}function cf(){return ye({description:ie()})}function uf(){return ye({url:ie().url()})}function lf(){return ye({name:ie()})}function df(){return ye({url:ie().url()})}const vt={setPackageNameOperation(t,e,n){t.name=e.input.name},setPackageDescriptionOperation(t,e,n){t.description=e.input.description},setPackageCategoryOperation(t,e,n){t.category=e.input.category},setPackageAuthorOperation(t,e,n){t.author={name:e.input.name??null,website:e.input.website??null}},setPackageAuthorNameOperation(t,e,n){t.author.name=e.input.name},setPackageAuthorWebsiteOperation(t,e,n){t.author.website=e.input.website},addPackageKeywordOperation(t,e,n){t.keywords.push(e.input)},removePackageKeywordOperation(t,e,n){t.keywords=t.keywords.filter(r=>r.id!==e.input.id)},setPackageGithubUrlOperation(t,e,n){t.githubUrl=e.input.url},setPackageNpmUrlOperation(t,e,n){t.npmUrl=e.input.url}},Hb=(t,e,n)=>{if(co(e))return t;switch(e.type){case"SET_PACKAGE_NAME":lf().parse(e.input),vt.setPackageNameOperation(t[e.scope],e,n);break;case"SET_PACKAGE_DESCRIPTION":cf().parse(e.input),vt.setPackageDescriptionOperation(t[e.scope],e,n);break;case"SET_PACKAGE_CATEGORY":af().parse(e.input),vt.setPackageCategoryOperation(t[e.scope],e,n);break;case"SET_PACKAGE_AUTHOR":rf().parse(e.input),vt.setPackageAuthorOperation(t[e.scope],e,n);break;case"SET_PACKAGE_AUTHOR_NAME":sf().parse(e.input),vt.setPackageAuthorNameOperation(t[e.scope],e,n);break;case"SET_PACKAGE_AUTHOR_WEBSITE":of().parse(e.input),vt.setPackageAuthorWebsiteOperation(t[e.scope],e,n);break;case"ADD_PACKAGE_KEYWORD":tf().parse(e.input),vt.addPackageKeywordOperation(t[e.scope],e,n);break;case"REMOVE_PACKAGE_KEYWORD":nf().parse(e.input),vt.removePackageKeywordOperation(t[e.scope],e,n);break;case"SET_PACKAGE_GITHUB_URL":uf().parse(e.input),vt.setPackageGithubUrlOperation(t[e.scope],e,n);break;case"SET_PACKAGE_NPM_URL":df().parse(e.input),vt.setPackageNpmUrlOperation(t[e.scope],e,n);break;default:return t}},io=ao(Hb),Jb={name:null,description:null,category:null,author:{name:null,website:null},keywords:[],githubUrl:null,npmUrl:null},Wb={},Zr={fileExtension:".phdm",createState(t){return{global:{...Jb,...t==null?void 0:t.global},local:{...Wb,...t==null?void 0:t.local}}},createExtendedState(t){return po({...t},Zr.createState)},createDocument(t){const e=fo(Zr.createExtendedState(t),Zr.createState);return e.header.documentType="powerhouse/package",e.header.id=rt(),e},saveToFile(t,e,n){return lo(t,e,".phdm",n)},saveToFileHandle(t,e){return Ni(t,e)},loadFromFile(t){return uo(t,io)},loadFromInput(t){return Di(t,io)}},Kb=t=>be("SET_PACKAGE_NAME",{...t},void 0,lf,"global"),Qb=t=>be("SET_PACKAGE_DESCRIPTION",{...t},void 0,cf,"global"),Xb=t=>be("SET_PACKAGE_CATEGORY",{...t},void 0,af,"global"),Zb=t=>be("SET_PACKAGE_AUTHOR",{...t},void 0,rf,"global"),ew=t=>be("SET_PACKAGE_AUTHOR_NAME",{...t},void 0,sf,"global"),tw=t=>be("SET_PACKAGE_AUTHOR_WEBSITE",{...t},void 0,of,"global"),nw=t=>be("ADD_PACKAGE_KEYWORD",{...t},void 0,tf,"global"),rw=t=>be("REMOVE_PACKAGE_KEYWORD",{...t},void 0,nf,"global"),iw=t=>be("SET_PACKAGE_GITHUB_URL",{...t},void 0,uf,"global"),sw=t=>be("SET_PACKAGE_NPM_URL",{...t},void 0,df,"global"),ow=Object.freeze(Object.defineProperty({__proto__:null,addPackageKeyword:nw,removePackageKeyword:rw,setPackageAuthor:Zb,setPackageAuthorName:ew,setPackageAuthorWebsite:tw,setPackageCategory:Xb,setPackageDescription:Qb,setPackageGithubUrl:iw,setPackageName:Kb,setPackageNpmUrl:sw},Symbol.toStringTag,{value:"Module"})),aw=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),cw={...Zr,...aw},uw={...ho,...ow},lw={reducer:io,actions:uw,utils:cw,documentModel:Yb},dw={id:"powerhouse/document-editor",name:"Document Editor",extension:".phdm",description:"Powerhouse document editor document model",author:{name:"Powerhouse",website:"https://powerhouse.inc"},specifications:[{version:1,changeLog:[],state:{global:{schema:`type DocumentEditorState {
408
- name: String
409
- id: OID
410
- documentTypes: [DocumentTypeItem!]!
411
- }
412
-
413
- type DocumentTypeItem {
414
- id: OID!
415
- documentType: String!
416
- }`,initialValue:'"{\\n \\"name\\": null,\\n \\"id\\": null,\\n \\"documentTypes\\": []\\n}"',examples:[]},local:{schema:"",initialValue:'""',examples:[]}},modules:[{id:"14bfe34c-0d19-43d8-b15e-1deba793a739",name:"base_operations",description:"",operations:[{id:"047acd27-caa4-48e9-b628-9f970318d1a7",name:"SET_EDITOR_NAME",description:"",schema:`input SetEditorNameInput {
417
- name: String!
418
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"28a1c183-8ad5-4bd9-9893-48266961793c",name:"SET_EDITOR_ID",description:"",schema:`input SetEditorIdInput {
419
- id: OID!
420
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"bdb3a85d-c29d-4a63-8397-2e14eae8215e",name:"ADD_DOCUMENT_TYPE",description:"",schema:`input AddDocumentTypeInput {
421
- id: OID!
422
- documentType: String!
423
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"},{id:"222bf8c4-c4f1-4cf6-9e95-8aa7d703fcd2",name:"REMOVE_DOCUMENT_TYPE",description:"",schema:`input RemoveDocumentTypeInput {
424
- id: OID!
425
- }`,template:"",reducer:"",errors:[],examples:[],scope:"global"}]}]}]},fw=t=>t!=null;oo().refine(t=>fw(t));function ff(){return ye({documentType:ie(),id:ie()})}function pf(){return ye({id:ie()})}function hf(){return ye({id:ie()})}function mf(){return ye({name:ie()})}const Vr={setEditorNameOperation(t,e,n){t.name=e.input.name},setEditorIdOperation(t,e,n){t.id=e.input.id},addDocumentTypeOperation(t,e,n){t.documentTypes.push({id:e.input.id,documentType:e.input.documentType})},removeDocumentTypeOperation(t,e,n){t.documentTypes=t.documentTypes.filter(r=>r.id!==e.input.id)}},pw=(t,e,n)=>{if(co(e))return t;switch(e.type){case"SET_EDITOR_NAME":mf().parse(e.input),Vr.setEditorNameOperation(t[e.scope],e,n);break;case"SET_EDITOR_ID":hf().parse(e.input),Vr.setEditorIdOperation(t[e.scope],e,n);break;case"ADD_DOCUMENT_TYPE":ff().parse(e.input),Vr.addDocumentTypeOperation(t[e.scope],e,n);break;case"REMOVE_DOCUMENT_TYPE":pf().parse(e.input),Vr.removeDocumentTypeOperation(t[e.scope],e,n);break;default:return t}},so=ao(pw),hw={name:null,id:null,documentTypes:[]},mw={},ei={fileExtension:".phdm",createState(t){return{global:{...hw,...t==null?void 0:t.global},local:{...mw,...t==null?void 0:t.local}}},createExtendedState(t){return po({...t},ei.createState)},createDocument(t){const e=fo(ei.createExtendedState(t),ei.createState);return e.header.documentType="powerhouse/document-editor",e.header.id=rt(),e},saveToFile(t,e,n){return lo(t,e,".phdm",n)},saveToFileHandle(t,e){return Ni(t,e)},loadFromFile(t){return uo(t,so)},loadFromInput(t){return Di(t,so)}},gw=t=>be("SET_EDITOR_NAME",{...t},void 0,mf,"global"),yw=t=>be("SET_EDITOR_ID",{...t},void 0,hf,"global"),vw=t=>be("ADD_DOCUMENT_TYPE",{...t},void 0,ff,"global"),Ew=t=>be("REMOVE_DOCUMENT_TYPE",{...t},void 0,pf,"global"),_w=Object.freeze(Object.defineProperty({__proto__:null,addDocumentType:vw,removeDocumentType:Ew,setEditorId:yw,setEditorName:gw},Symbol.toStringTag,{value:"Module"})),bw=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),ww={...ei,...bw},Sw={...ho,..._w},Tw={reducer:so,actions:Sw,utils:ww,documentModel:dw},Iw=[sl,Ap,lw,Tw];function Dw(...t){const e=new Map;for(const n of t)e.set(n.documentModel.id,n);return Array.from(e.values())}function Nw(t){return t.map(e=>e.documentModels).reduce((e,n)=>e.concat(n),[])}const Xo=ke(async t=>{const e=await t(Or),n=Nw(e);return Dw(...Iw,...n)});Xo.debugLabel="documentModelsAtomInConnect";const gf=bb(Xo);gf.debugLabel="unwrappedDocumentModelsAtomInConnect";const yf=()=>Vt(gf);function Ow(t,e){return e==null?void 0:e.find(n=>n.documentModel.id===t)}const Aw=()=>{const t=yf();return e=>Ow(e,t)},UT=()=>{const t=yf(),{config:e}=Ww(),{enabledEditors:n,disabledEditors:r}=e.editors;if(!t)return;const i=t.filter(s=>s.documentModel.id!=="powerhouse/document-drive");return n==="*"?t:r==="*"?[]:r?i.filter(s=>!r.includes(s.documentModel.id)):n?i.filter(s=>n.includes(s.documentModel.id)):i};async function Rw(t,e){await Lw(t,e);const n=await t.initialize(),r=n==null?void 0:n.at(0);if(r)throw r}function Cw(){const t=gr.drives.sections.LOCAL.enabled,e=kn(),n=Ir(),r=an(!1);xe(()=>{r.current||t&&e!==void 0&&n!==void 0&&(n.length>0||(e.addDrive({id:rt(),slug:"my-local-drive",global:{name:"My Local Drive",icon:null},local:{availableOffline:!1,sharingType:"private",listeners:[],triggers:[]}}).catch(pe.error),r.current=!0))},[t,e,n])}async function Lw(t,e){const n=await(e==null?void 0:e.user()),r=await en();n!=null&&n.address&&t.setGenerateJwtHandler(async i=>r.getBearerToken(i,n.address))}async function xw(t,e,n){const r=KE(e,t);return await Rw(r,n),r}const Zo=ke(WE(gr.routerBasename));Zo.debugLabel="storageAtomInConnect";const Mw=()=>Vt(Zo);let Gr=!1;const vf=ke(void 0);vf.debugLabel="userAtomInConnect";const Ef=()=>{const[t,e]=cn(vf),n=Gi();return xe(()=>{var i;let r=null;if(t){const{credential:s,...o}=t;r={id:o.did,username:(i=o.ens)==null?void 0:i.name,...o}}H_(r)},[t]),xe(()=>{if(Gr)return;Gr=!0,n==null||n.user().then(i=>{e(i||null)}).catch(()=>{e(null)});const r=n==null?void 0:n.on.user(i=>{e(i||null)});return()=>{r==null||r(),Gr=!1}},[n,Gr]),t};async function qc(t,e){if(!t)return;const n=t.split("/");n.pop(),n.pop(),n.push("drives");const r=n.join("/");return(await(await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:`
426
- query getDriveIdBySlug($slug: String!) {
427
- driveIdBySlug(slug: $slug)
428
- }
429
- `,variables:{slug:e}})})).json()).data.driveIdBySlug}function Pw(t){return t.split("/").pop()}function kw(t){const e=t.split("/");return e.pop(),e.pop(),e.push("graphql"),e.join("/")}function $w(t){const e=sd(t,"document");return`query getDocument($documentId: PHID!, $driveId: String) {
430
- ${t.name} {
431
- getDocument(docId: $documentId, driveId: $driveId) {
432
- id
433
- created
434
- lastModified
435
- name
436
- revision
437
- state {
438
- ${e}
439
- }
440
- }
441
- }
442
- }`}function Uw(t,e,n){const r=Pw(t),i=$w(n),s={documentId:e,driveId:r};return Cp.compressToEncodedURIComponent(JSON.stringify({document:i.trim(),variables:JSON.stringify(s,null,2)}))}function FT(t,e,n){const r=kw(t),i=Rp(n.name),s=Uw(t,e,n);return`${r}/${i}?explorerURLState=${s}`}const Fw=()=>{const{t}=ef();return ri("div",{children:[Et("p",{className:"font-medium",children:t("notifications.reloadApp")}),ri("button",{onClick:()=>location.reload(),className:"underline decoration-solid underline-offset-2",children:[t("common.reloadConnect")," 🔄"]})]})},_f=ke("initial");_f.debugLabel="loginStatusAtomInConnect";const Bw=()=>{const[t,e]=cn(_f),n=Ef(),r=Gi(),{did:i,getBearerToken:s}=Qo(),o=kn(),a=ce(async()=>{var f;const d=await i(),l=new URL(ub);if(l.searchParams.set("connect",d),l.searchParams.set("network",lb),l.searchParams.set("chain",db),window.electronAPI){const h=await window.electronAPI.protocol();l.searchParams.set("deeplink",h),await window.electronAPI.openURL(l.toString())}else{const h=new URL(window.location.pathname,window.location.origin);l.searchParams.set("returnUrl",h.toJSON()),(f=window.open(l,"_self"))==null||f.focus()}},[i]),c=ce(async d=>{if(r)try{e("checking");const l=await r.user();if((l==null?void 0:l.did)===d)return e("authorized"),l;const f=await r.login(d);if(f)return e("authorized"),o==null||o.setGenerateJwtHandler(async h=>s(h,f.address)),f;e("not-authorized")}catch(l){e("not-authorized"),pe.error(l)}},[r,o,s]);xe(()=>{n&&t!=="authorized"&&e("authorized")},[n,t]);const u=ce(async()=>{e("initial"),await(r==null?void 0:r.logout()),o==null||o.removeJwtHandler()},[r,o]);return mr(()=>({openRenown:a,user:n,status:n?"authorized":t,login:r?c:void 0,logout:u}),[r,a,n,t,c,u])};function jw(){const{user:t,status:e}=Bw(),n=window.__VITE_ENVS.PH_CONNECT_ARBITRUM_ALLOW_LIST,r=window.__VITE_ENVS.PH_CONNECT_RWA_ALLOW_LIST,i=!!n&&n!=="",s=!!r&&r!=="";if(i&&s)throw new Error("Both Arbitrum and RWA allow lists are defined. Please only define one.");if(!i&&!s)return{isAllowed:!0,allowListType:"none"};if(t!==void 0){if(i){const o=n.split(",");return e!=="authorized"||!t?{isAllowed:!1,allowListType:"arbitrum"}:o.includes(t.address)?{isAllowed:!0,allowListType:"arbitrum"}:{isAllowed:!1,allowListType:"arbitrum"}}if(s){const o=r.split(",");return e!=="authorized"||!t?{isAllowed:!1,allowListType:"rwa"}:o.includes(t.address)?{isAllowed:!0,allowListType:"rwa"}:{isAllowed:!1,allowListType:"rwa"}}return{isAllowed:!0,allowListType:"none"}}}function Vw(){const t=jw();if(!t)return;const{allowListType:e,isAllowed:n}=t;return e==="arbitrum"?{isAllowedToCreateDocuments:n,isAllowedToEditDocuments:!0}:e==="rwa"?{isAllowedToCreateDocuments:n,isAllowedToEditDocuments:n}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}function Hc(t,e){const n={};for(const o of Object.keys(t))n[o]=new Set(t[o].map(a=>a.index));const r=[];for(const o of e){const a=o.scope,c=o.index;if(n[a].has(c)){const u=t[a].find(l=>l.index===c),d=r.find(l=>l.index===c);console.warn("skipping duplicate operation"),u&&console.warn("duplicate existing operation",u),d&&console.warn("duplicate new operation",d);continue}r.push(o),n[a].add(c)}const i=new Set,s=[];for(const[o,a]of Object.entries(t))for(const c of a){const u=c.hash;if(i.has(u)){console.warn("skipping existing operation with duplicate hash in scope",o,c);continue}i.add(u)}for(const o of r){const a=o.hash;if(i.has(a)){console.warn("skipping new operation with duplicate hash in scope",o.scope,o);continue}i.add(a),s.push(o)}return s}function bf(){const t=wt(["useDocumentDriveServer",Math.floor(Math.random()*999).toString()]),{isAllowedToCreateDocuments:e}=Vw()||{isAllowedToCreateDocuments:!1},n=Ef()||void 0,r=Rb(),{sign:i}=Qo(),s=kn(),o=Mw(),a=Aw(),c=Ir(),u=hd(),d=ce(async(j,Y)=>s?await s.getDocument(j,Y):void 0,[s]),l=ce(async(j,Y)=>{if(!s)return;const V=c==null?void 0:c.find(le=>le.header.id===j);if(!V)return;const ae={...V},S=cr(V,XE(Y,r,n)),W=Y.scope,Q=S.operations[W].findLast(le=>le.type===Y.type);if(!Q)throw new Error("There was an error applying the operation");const ge=await QE(Q,i,j,ae,cr,n);try{const le=await s.queueOperation(j,ge);return le.status!=="SUCCESS"&&t.error(le.error),le.document}catch(le){return t.error(le),V}},[s,c,i,n,r]),f=ce(async(j,Y)=>{if(!s)return;const V=await s.getDrive(j),ae=Hc(V.operations,Y),S=await s.queueOperations(j,ae);return S.status!=="SUCCESS"&&t.error(S.error),S.document},[s]),h=ce(async(j,Y)=>{if(!s)return;const V=await s.getDocument(j),ae=Hc(V.operations,Y),S=await s.queueOperations(j,ae);return S.status!=="SUCCESS"&&t.error(S.error),S.document},[s]),g=ce(async(j,Y,V,ae,S,W)=>{if(!s)throw new Error("Reactor is not loaded");if(!e)throw new Error("User is not allowed to create documents");if(!(c==null?void 0:c.find(Tt=>Tt.header.id===j)))return;const Q=W??rt(),ge=a(V);if(!ge)throw new Error(`Document model module for type ${V} not found`);const le=ge.utils.createDocument({...S});le.header=zr(Q,V),le.header.name=Y,await s.addDocument(le);const Ee=Ju({id:Q,name:Y,documentType:V,parentFolder:ae??null}),Xe=await l(j,Ee),St=Xe==null?void 0:Xe.state.global.nodes.find(Tt=>Tt.id===Q);if(!St||!or(St))throw new Error("There was an error adding document");return St},[l,c,e]),E=ce(async(j,Y,V,ae)=>{if(t.verbose(`addFile(drive: ${Y}, name: ${V}, folder: ${ae})`),!s)return;if(!e)throw new Error("User is not allowed to create files");const S=await zE(j,a),W={header:S.header,history:S.history,initialState:S.initialState,state:S.initialState.state,operations:{global:[],local:[]},clipboard:[]},F=await g(Y,V||(typeof j=="string"?S.header.name:j.name),S.header.documentType,ae,W);if(!F)throw new Error("There was an error adding file");c==null||c.find(Q=>Q.header.id===Y),VE(F.id,S,h,{}).catch(Q=>{throw Q})},[g,h,a,c,e,s]),D=ce(async(j,Y,V,ae,S)=>{if(!e)throw new Error("User is not allowed to update files");const W=await l(j,Qu({id:Y,name:ae||void 0,parentFolder:S,documentType:V})),F=W==null?void 0:W.state.global.nodes.find(Q=>Q.id===Y);if(!F||!or(F))throw new Error("There was an error updating document");return F},[l,e]),P=ce(async(j,Y,V)=>{if(!e)throw new Error("User is not allowed to create folders");const ae=rt(),S=await l(j,Wu({id:ae,name:Y,parentFolder:V})),W=S==null?void 0:S.state.global.nodes.find(F=>F.id===ae);if(!W||!Io(W))throw new Error("There was an error adding folder");return W},[l,e]),B=ce(async(j,Y)=>{if(!e)throw new Error("User is not allowed to delete documents");await l(j,Ku({id:Y}))},[l,e]),R=ce(async(j,Y,V)=>{if(!e)throw new Error("User is not allowed to rename documents");const ae=await l(j,Xu({id:Y,name:V})),S=ae==null?void 0:ae.state.global.nodes.find(W=>W.id===Y);if(!S)throw new Error("There was an error renaming node");return S},[l,e]),K=ce(async(j,Y)=>{if(!e)throw new Error("User is not allowed to move documents");u!=null&&u.header.id&&await l(u.header.id,el({srcFolder:j.id,targetParentFolder:Y==null?void 0:Y.id}))},[l,e,u==null?void 0:u.header.id]),N=ce(async(j,Y)=>{if(!s||!u)return;if(!e)throw new Error("User is not allowed to copy documents");const ae=Yu({srcId:j.id,targetParentFolder:Y==null?void 0:Y.id,targetName:j.name},()=>rt(),u.state.global.nodes).map(W=>Zu(W)),S=await s.addActions(u.header.id,ae);return S.status!=="SUCCESS"&&t.error(`Error copying files: ${S.status}`,S.error),S.document},[e,s,u]),X=ce(async(j,Y)=>{if(!s)return;if(!e)throw new Error("User is not allowed to create drives");const V=j.id||rt(),ae=lE(j);return await s.addDrive({global:ae.global,local:ae.local,id:V},Y)},[e,s]),b=ce(async(j,Y)=>s?await s.addRemoteDrive(j,Y):void 0,[e,s]),$=ce(async j=>{if(s){if(!e)throw new Error("User is not allowed to delete drives");await s.deleteDrive(j)}},[e,s]),A=ce(async(j,Y)=>{if(!e)throw new Error("User is not allowed to rename drives");return await l(j,tl({name:Y}))},[l,e]),C=ce(async(j,Y)=>{if(!e)throw new Error("User is not allowed to change drive availability");return await l(j,nl({availableOffline:Y}))},[l,e]),L=ce(async(j,Y)=>{if(!e)throw new Error("User is not allowed to change drive availability");return await l(j,Do({type:Y}))},[l,e]),O=ce(async(j,Y)=>{if(Y!==rr&&s)try{const V=s.getSyncStatus(j);return V instanceof Us?"INITIAL_SYNC":V}catch(V){return console.error(V),Ls}},[s]),re=ce((j,Y)=>{if(Y!==rr&&s)try{const V=s.getSyncStatus(j);return V instanceof Us?"INITIAL_SYNC":V}catch(V){return console.error(V),Ls}},[s]),oe=ce(async()=>{s&&await o.clear()},[s,o]),I=ce(async(j,Y)=>{const V=await l(j,No({triggerId:Y}));if(V==null?void 0:V.state.local.triggers.find(S=>S.id===Y))throw new Error(`There was an error removing trigger ${Y}`)},[l]),k=ce(async(j,Y,V)=>{var F,Q,ge,le;if(!s)return;const ae=rt(),S={driveId:j,listenerId:ae,block:!1,filter:{branch:((F=V.pullFilter)==null?void 0:F.branch)??[],documentId:((Q=V.pullFilter)==null?void 0:Q.documentId)??[],documentType:((ge=V.pullFilter)==null?void 0:ge.documentType)??[],scope:((le=V.pullFilter)==null?void 0:le.scope)??[]},system:!1,label:`Pullresponder #${ae}`,callInfo:{data:"",name:"PullResponder",transmitterType:"PullResponder"}},W=s.listeners;S.transmitter=new He(S,W);try{await W.setListener(j,S)}catch(Ee){throw new Error(`Listener couldn't be registered: ${Ee}`)}return{driveId:j,filter:S.filter,data:{interval:`${V.pullInterval}`||"1000",listenerId:ae,url:Y},id:ae,type:"PullResponder"}},[s]),q=ce(async(j,Y)=>{const V=await l(j,il({trigger:Y}));if(!(V==null?void 0:V.state.local.triggers.find(S=>S.id===S.id)))throw new Error(`There was an error adding the trigger ${Y.id}`)},[l]);return mr(()=>({addDocument:g,addDocumentOperations:h,addDriveOperation:l,addDriveOperations:f,addFile:E,addFolder:P,openFile:d,updateFile:D,deleteNode:B,renameNode:R,moveNode:K,copyNode:N,addDrive:X,addRemoteDrive:b,deleteDrive:$,renameDrive:A,setDriveAvailableOffline:C,setDriveSharingType:L,getSyncStatus:O,getSyncStatusSync:re,clearStorage:oe,removeTrigger:I,addTrigger:q,registerNewPullResponderTrigger:k}),[g,h,l,f,E,P,d,D,B,R,K,N,X,b,$,A,C,L,O,re,oe,I,q,k])}const Gw=1e5,zw=(t,e)=>e?t.toLocaleLowerCase().includes(`transmitter ${e} not found`):!1,Yw=()=>{const[t,e]=Cn([]),[n,r]=Cn(new Map),{addTrigger:i,removeTrigger:s,registerNewPullResponderTrigger:o,renameDrive:a,addRemoteDrive:c,setDriveSharingType:u}=bf(),d=Ir(),l=an(new Map),f=ce(async(E,D,P)=>{e(R=>[...R,P]);const B=D.data;if(B)try{let R=n.get(P);if(!R){if(R=await o(E,B.url,{pullInterval:Number(B.interval)||3e3}),!R)return;n.set(P,R),r(n)}await s(E,D.id),await i(E,R),l.current.delete(P)}catch(R){const K=l.current.get(P)||1;l.current.set(P,K===Gw?K:K*10),pe.error(R)}finally{e(R=>R.filter(K=>K!==P))}},[n,s,i,l,o]),h=ce(async(E,D,P)=>{var B;e(R=>[...R,P]);try{const R=d==null?void 0:d.find(K=>K.header.id===E);if(!R)return;if(await s(E,D.id),await a(E,R.state.global.name+` (${R.header.id})`),await u(E,rr),(B=D.data)!=null&&B.url&&R.header.slug){const K=await qc(D.data.url,R.header.slug);if(K){const N=D.data.url.split("/");N[N.length-1]=K;const X=N.join("/");await c(X,{availableOffline:!0,sharingType:"PUBLIC",listeners:[],triggers:[]})}}}catch(R){pe.error(R)}finally{e(R=>R.filter(K=>K!==P))}},[d,s,a,u,qc,c]),g=ce(async(E,D,P,B)=>{var R;switch(P){case 400:{if(zw(B,(R=D.data)==null?void 0:R.listenerId)){if(!(localStorage.getItem("AUTO_REGISTER_PULL_RESPONDER")!=="false"))return;const N=`strands:${E}:${P}`;if(t.includes(N)||!D.data)return;const X=l.current.get(N)||0;setTimeout(()=>f(E,D,N),X)}break}case 404:{const K=`strands:${E}:${P}`;if(t.includes(K))return;setTimeout(()=>h(E,D,K),0);break}}},[h,f,t]);return mr(()=>({strandsErrorHandler:g}),[g])},qw="feature-flags-config",ti=window.__VITE_ENVS.PH_CONNECT_ENABLED_EDITORS||void 0,Hw=ti==null?void 0:ti.split(","),ni=window.__VITE_ENVS.PH_CONNECT_DISABLED_EDITORS||"powerhouse/document-drive",Jw=ni==null?void 0:ni.split(","),wf={editors:{enabledEditors:ti==="*"?"*":Hw,disabledEditors:ni==="*"?"*":Jw}},Sf=zb(qw,wf);Sf.debugLabel="featureFlagAtomInConnect";const Ww=()=>{const[t,e]=cn(Sf);return{config:{...wf,...t},setConfig:e}},Jc=window.__VITE_ENVS.APP_VERSION,BT=window.navigator.userAgent.includes("Electron"),jT=window.navigator.appVersion.includes("Mac"),Wc={"staging/makerdao":"deployments/staging/makerdao","staging/arbitrum":"arb-ltip","staging/powerhouse":"staging",makerdao:"deployments/makerdao",arbitrum:"deployments/arbitrum",arbgrants:"deployments/arbitrum",localhost:"develop"},Kw=()=>{const t="https://raw.githubusercontent.com/powerhouse-inc/connect",e=window.location.href,n=Object.keys(Wc).find(i=>e.includes(i)),r=n?Wc[n]:void 0;if(r)return`${t}/${r}/package.json`},Qw=async()=>{const t=Kw();if(!t)return;const n=await(await fetch(t)).json(),{version:r}=n;return r},Xw=async()=>{const t=await Qw();return t?{isLatest:t===Jc,currentVersion:Jc,latestVersion:t}:null},Zw=()=>{const{t}=ef(),{getSyncStatusSync:e}=bf(),n=an([]),r=Ir();Yw();const[i]=qh();async function s(){const a=await Xw();if(a!==null){if(a.isLatest||a.currentVersion.includes("-"))return!0;window.__VITE_ENVS.MODE==="development"||i.studioMode||!i.warnOutdatedApp?pe.warn(`Connect is outdated:
443
- Current: ${a.currentVersion}
444
- Latest: ${a.latestVersion}`):Rs(Et(Fw,{}),{type:"connect-warning",toastId:"outdated-app",autoClose:!1})}}xe(()=>{s().catch(console.error)},[]);const o=ce(async(a,c)=>{a.forEach(u=>{const d=n.current.find(g=>g.header.id===u.header.id);if(!d)return;const l=$s(u),f=e(d.header.id,l),h=e(u.header.id,l);if(l!==rr&&h===Lp&&n.current.includes(u))return n.current=n.current.filter(g=>g.header.id!==u.header.id),Rs(c("notifications.driveSyncSuccess"),{type:"connect-success"});(h===es||h===Ls)&&h!==f&&n.current.push(u)}),n.current.length>0&&await s()&&n.current.forEach(d=>{const l=$s(d),f=e(d.header.id,l);Rs(c(`notifications.${f===es?"driveSyncConflict":"driveSyncError"}`,{drive:d.header.name}),{type:"connect-warning",toastId:`${f===es?"driveSyncConflict":"driveSyncError"}-${d.header.id}`})})},[]);xe(()=>{o(r??[],t).catch(console.error)},[r,t,o])};var eS=()=>null;function tS(){const t=Vt(Zo),e=Vt(Xo),n=Gi();BE(()=>xw(t,e,n)),Cw()}const nS=yo(()=>jt(()=>import("./useInitSentry.DBsKo0vo.js").then(t=>t.s),__vite__mapDeps([5,1,6,7]),import.meta.url)),rS=yo(()=>jt(()=>import("./cookie-banner.UvJrgFVN.js"),__vite__mapDeps([8,6,9,10,1,11,3,4]),import.meta.url).then(t=>({default:t.CookieBanner}))),iS=yo(()=>jt(()=>import("./modal.CqA_mJUN.js"),__vite__mapDeps([10,1]),import.meta.url).then(t=>({default:t.ModalManager})));function sS(){return Zw(),tS(),Gi(),null}const oS=Et(Mp,{children:ri(Vh,{children:[window.__VITE_ENVS.DEV&&Et(eS,{}),ri(wa,{fallback:Et(kp,{}),name:"AppLoader",children:[Et(sS,{}),Et(nS,{})]}),Et(wa,{name:"CookieBanner",children:Et(iS,{children:Et(rS,{})})})]})});function aS(t){hp(t).render(oS)}const Tf=document.getElementById("app");if(!Tf)throw new Error("#app element not found!");aS(Tf);const VT=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{jT as $,hd as A,$s as B,gS as C,Ef as D,Rb as E,Qo as F,Aw as G,LS as H,Vw as I,XE as J,QE as K,bf as L,OS as M,_E as N,xS as O,FT as P,UT as Q,ub as R,MT as S,sl as T,kn as U,Ir as V,DS as W,NS as X,xT as Y,Bw as Z,BT as _,Rt as a,L_ as a$,Ob as a0,Rs as a1,Nt as a2,SS as a3,Ui as a4,nr as a5,Dd as a6,Jo as a7,it as a8,v_ as a9,J_ as aA,fr as aB,Wo as aC,M_ as aD,cT as aE,Bd as aF,uT as aG,P_ as aH,o_ as aI,Nr as aJ,HS as aK,__ as aL,aT as aM,ZS as aN,FS as aO,Dr as aP,dT as aQ,W_ as aR,t_ as aS,qo as aT,ib as aU,KS as aV,jS as aW,qS as aX,nT as aY,l_ as aZ,zS as a_,Je as aa,Oc as ab,YS as ac,Ac as ad,Nd as ae,Ae as af,c_ as ag,bi as ah,_t as ai,eT as aj,tT as ak,rn as al,Zt as am,Fi as an,Md as ao,je as ap,Rn as aq,Ho as ar,Un as as,ji as at,sT as au,ab as av,lT as aw,Vi as ax,K_ as ay,$d as az,Sm as b,no as b$,iT as b0,rT as b1,oT as b2,GS as b3,h_ as b4,QS as b5,E_ as b6,fT as b7,kS as b8,$S as b9,OT as bA,NT as bB,Fc as bC,ET as bD,vT as bE,bT as bF,_T as bG,H_ as bH,TT as bI,wT as bJ,od as bK,AS as bL,RS as bM,nh as bN,Db as bO,LT as bP,zb as bQ,cn as bR,Lm as bS,Cm as bT,IS as bU,Om as bV,bm as bW,Dm as bX,Nm as bY,yS as bZ,vS as b_,US as ba,e_ as bb,n_ as bc,w_ as bd,JS as be,g_ as bf,gT as bg,BS as bh,hT as bi,VS as bj,WS as bk,AT as bl,RT as bm,yT as bn,pT as bo,XS as bp,Bi as bq,ST as br,rb as bs,Gd as bt,Ct as bu,DT as bv,mT as bw,Ud as bx,IT as by,to as bz,wt as c,Fb as c0,Ub as c1,Cb as c2,Bb as c3,ee as c4,z as c5,pt as c6,mt as c7,Be as c8,qt as c9,ze as cA,Se as cB,ue as cC,Gg as cD,wl as cE,Ln as cF,Gl as cG,Nv as cH,Dv as cI,vl as cJ,wS as cK,Mi as cL,Bt as cM,Jn as cN,Qa as cO,Xa as cP,Za as cQ,zt as cR,er as cS,bt as cT,_S as cU,Wa as cV,se as cW,Ly as cX,gy as cY,Zg as cZ,VT as c_,Oe as ca,Re as cb,ot as cc,Qe as cd,$e as ce,ES as cf,y as cg,Wn as ch,Wg as ci,bS as cj,Jg as ck,Vl as cl,vv as cm,Cl as cn,Ke as co,Le as cp,Hg as cq,qg as cr,Yt as cs,st as ct,zs as cu,Dn as cv,Ys as cw,lr as cx,Lt as cy,Ve as cz,CS as d,Vt as e,ke as f,Or as g,gr as h,kT as i,ef as j,$i as k,MS as l,ZE as m,lb as n,db as o,pe as p,zv as q,PS as r,PT as s,$T as t,qh as u,Sw as v,uw as w,bb as x,wb as y,CT as z};
445
- //# sourceMappingURL=index.COdN5sTb.js.map