moi-computer 0.13.1-next.1 → 0.13.1-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/client/api/app-config.ts +12 -1
  2. package/client/api/http.ts +11 -1
  3. package/client/app/app-router.tsx +3 -2
  4. package/client/app/routes/home-route.tsx +1 -1
  5. package/client/app/routes/workspace-registration.tsx +68 -0
  6. package/client/app/routes/workspace-route.tsx +33 -6
  7. package/client/app/shell/sidebar-layout.tsx +10 -5
  8. package/client/components/shared/workspace-icon.tsx +8 -17
  9. package/client/features/account/account-test-utils.tsx +15 -9
  10. package/client/features/account/api.ts +6 -6
  11. package/client/features/account/profile-actions.ts +5 -7
  12. package/client/features/app-settings/settings-page.tsx +2 -1
  13. package/client/features/applets/api.ts +6 -6
  14. package/client/features/applets/applet-cache.ts +6 -5
  15. package/client/features/applets/applet-log.ts +2 -1
  16. package/client/features/applets/applet-runtime.ts +2 -1
  17. package/client/features/applets/use-applet.ts +73 -18
  18. package/client/features/applets/widget-shell.tsx +4 -2
  19. package/client/features/chat/applet-chat-intents.ts +5 -13
  20. package/client/features/chat/chat-popup.tsx +8 -4
  21. package/client/features/chat/chat-send.ts +2 -2
  22. package/client/features/chat/composer/model-order.ts +4 -4
  23. package/client/features/chat/composer/model-picker.tsx +12 -10
  24. package/client/features/chat/composer/use-workspace-composer-state.tsx +1 -1
  25. package/client/features/chat/sessions/api.ts +11 -28
  26. package/client/features/chat/sessions/use-selected-session.ts +18 -100
  27. package/client/features/chat/use-chat.ts +8 -12
  28. package/client/features/collab/members/api.ts +4 -10
  29. package/client/features/collab/members/hooks.ts +32 -38
  30. package/client/features/collab/members/store.ts +96 -71
  31. package/client/features/collab/members/types.ts +5 -3
  32. package/client/features/collab/presence/client.ts +2 -3
  33. package/client/features/collab/presence/hooks.tsx +1 -1
  34. package/client/features/collab/proxy-user.ts +1 -3
  35. package/client/features/collab/sharing/workspace-members.tsx +0 -8
  36. package/client/features/dev/chat-states-page.tsx +3 -1
  37. package/client/features/dev/harness-debug-page.tsx +7 -7
  38. package/client/features/dev/workspace-setup-mocks.ts +1 -1
  39. package/client/features/dev/workspace-setup-preview.tsx +6 -4
  40. package/client/features/harness/api.ts +13 -10
  41. package/client/features/harness/harness-login-panel.tsx +9 -5
  42. package/client/features/harness/harness-presentation.ts +4 -4
  43. package/client/features/harness/harness-selector.tsx +13 -13
  44. package/client/features/harness/use-harness-login.ts +5 -5
  45. package/client/features/home/api.ts +38 -2
  46. package/client/features/home/home-page.tsx +43 -13
  47. package/client/features/home/shared-workspaces.tsx +70 -0
  48. package/client/features/home/workspace-invitations.tsx +101 -0
  49. package/client/features/identity/host-api.ts +3 -2
  50. package/client/features/identity/store.ts +1 -7
  51. package/client/features/onboarding/agent-setup-step.tsx +8 -8
  52. package/client/features/onboarding/onboarding-page.tsx +3 -2
  53. package/client/features/onboarding/workspace-setup-step.tsx +1 -1
  54. package/client/features/overview/api.ts +3 -5
  55. package/client/features/overview/default/registry.tsx +1 -1
  56. package/client/features/overview/default/views-widget.tsx +2 -2
  57. package/client/features/overview/hidden-panel.tsx +7 -5
  58. package/client/features/overview/overview.tsx +18 -16
  59. package/client/features/overview/workspace-name.tsx +2 -2
  60. package/client/features/scratchpad/scratchpad.tsx +9 -7
  61. package/client/features/scratchpad/use-scratchpad-snapshot.tsx +13 -5
  62. package/client/features/views/api.ts +34 -16
  63. package/client/features/views/use-view-actions.ts +10 -20
  64. package/client/features/views/view-manager.tsx +1 -1
  65. package/client/features/views/view-submission.ts +2 -21
  66. package/client/features/workspace/add/api.ts +5 -4
  67. package/client/features/workspace/add/create-workspace-dialog.tsx +12 -9
  68. package/client/features/workspace/add/import-workspace-dialog.tsx +7 -7
  69. package/client/features/workspace/add/use-workspace-import.ts +10 -10
  70. package/client/features/workspace/add/workspace-agent-options.ts +21 -20
  71. package/client/features/workspace/add/workspace-agent-selector.tsx +11 -11
  72. package/client/features/workspace/api.ts +60 -13
  73. package/client/features/workspace/harness-transition.ts +7 -13
  74. package/client/features/workspace/remote.ts +25 -0
  75. package/client/features/workspace/settings/api.ts +7 -12
  76. package/client/features/workspace/settings/connectors-settings.tsx +3 -3
  77. package/client/features/workspace/settings/general-settings.tsx +8 -8
  78. package/client/features/workspace/setup/workspace-login-state.tsx +4 -4
  79. package/client/features/workspace/setup/workspace-recovery-states.tsx +43 -14
  80. package/client/features/workspace/setup/workspace-setup.tsx +6 -6
  81. package/client/features/workspace/tab-resolution.ts +2 -2
  82. package/client/features/workspace/use-workspace-navigation.ts +7 -4
  83. package/client/features/workspace/workspace-content.tsx +22 -20
  84. package/client/features/workspace/workspace-frame.tsx +13 -26
  85. package/client/features/workspace/workspace-layout-context.tsx +45 -12
  86. package/client/features/workspace/workspace-menu.tsx +2 -2
  87. package/client/features/workspace/workspace-pane.tsx +22 -0
  88. package/client/features/workspace/workspace-pending-screen.tsx +1 -1
  89. package/client/features/workspace/workspace-preferences.ts +34 -0
  90. package/client/features/workspace/workspace-presentation.tsx +12 -16
  91. package/client/features/workspace/workspace-screen.tsx +2 -2
  92. package/client/features/workspace/workspace-state.ts +2 -1
  93. package/client/features/workspace/workspace-tabs.tsx +1 -1
  94. package/client/features/workspace/workspace-test-utils.ts +23 -0
  95. package/client/runtime/use-workspace-events.ts +14 -0
  96. package/client/runtime/workspace-events.ts +9 -9
  97. package/client/store/ui.ts +29 -9
  98. package/dist/chunk-44khk4sp.js +2 -0
  99. package/dist/chunk-ba6mz56s.js +72 -0
  100. package/dist/chunk-ec5ennpv.js +1 -0
  101. package/dist/chunk-ectsnw81.js +2 -0
  102. package/dist/chunk-en7w5ypg.js +1 -0
  103. package/dist/chunk-f695wcx5.js +5 -0
  104. package/dist/chunk-kffcah9w.css +1 -0
  105. package/dist/{chunk-th91xfnp.js → chunk-n0fawy9x.js} +1 -1
  106. package/dist/chunk-pdt9hxfw.js +2 -0
  107. package/dist/chunk-rmd0ctfx.js +546 -0
  108. package/dist/chunk-zv22wv0g.js +1 -0
  109. package/dist/index.html +1 -1
  110. package/lib/harness-instructions.ts +4 -4
  111. package/lib/harness-types.ts +13 -0
  112. package/lib/types.ts +34 -49
  113. package/lib/workspace-config.ts +48 -0
  114. package/lib/workspace-layout.ts +2 -4
  115. package/package.json +4 -2
  116. package/server/README.md +29 -27
  117. package/server/api/harnesses.ts +5 -5
  118. package/server/api/index.ts +170 -68
  119. package/server/applets/index.ts +15 -9
  120. package/server/applets/views.ts +2 -17
  121. package/server/applets/widgets.ts +3 -2
  122. package/server/cli/commands/config.ts +8 -20
  123. package/server/cli/commands/hermes.ts +2 -2
  124. package/server/cli/commands/init.ts +96 -53
  125. package/server/cli/commands/openclaw.ts +2 -2
  126. package/server/cli/commands/refresh.ts +10 -1
  127. package/server/cli/commands/remote.ts +228 -0
  128. package/server/cli/commands/skill.ts +4 -4
  129. package/server/cli/commands/tabs.ts +5 -12
  130. package/server/cli/control.ts +35 -4
  131. package/server/cli/index.ts +10 -6
  132. package/server/cli/remote-command.ts +77 -0
  133. package/server/cli/remote-control.ts +70 -0
  134. package/server/cli/remote-operations.ts +244 -0
  135. package/server/collab/config.ts +3 -3
  136. package/server/collab/skill/index.ts +3 -3
  137. package/server/control.ts +38 -11
  138. package/server/harness/acp/session.ts +4 -4
  139. package/server/harness/auth.ts +26 -31
  140. package/server/harness/claude-code/index.ts +1 -1
  141. package/server/harness/codex/discovery.ts +1 -1
  142. package/server/harness/codex/session.ts +1 -1
  143. package/server/harness/detect.ts +14 -19
  144. package/server/harness/executable.ts +10 -10
  145. package/server/harness/hermes/NOTES.md +2 -2
  146. package/server/harness/hermes/index.ts +1 -1
  147. package/server/harness/install.ts +11 -11
  148. package/server/harness/openclaw/index.ts +1 -1
  149. package/server/harness/registry.ts +7 -6
  150. package/server/harness/types.ts +4 -4
  151. package/server/onboarding/jobs.ts +1 -1
  152. package/server/operations/commands.ts +46 -0
  153. package/server/operations/files.ts +148 -0
  154. package/server/operations/server.ts +206 -0
  155. package/server/remote/agent.ts +103 -0
  156. package/server/remote/client.ts +665 -0
  157. package/server/remote/workspace.ts +34 -0
  158. package/server/scratchpad/document.ts +32 -12
  159. package/server/scratchpad/executor.ts +16 -7
  160. package/server/sessions/config.ts +8 -5
  161. package/server/sessions/pending-views.ts +16 -0
  162. package/server/sessions/view-sessions.ts +10 -12
  163. package/server/skills/locations.ts +4 -4
  164. package/server/skills/update.ts +11 -11
  165. package/server/skills/version.ts +7 -7
  166. package/server/skills/workspace.ts +13 -11
  167. package/server/web.ts +11 -8
  168. package/server/workspace-state/file.ts +2 -0
  169. package/server/workspace-state/index.ts +0 -4
  170. package/server/workspaces/api.ts +28 -0
  171. package/server/workspaces/change-harness.ts +15 -26
  172. package/server/workspaces/import.ts +4 -4
  173. package/server/workspaces/init.ts +15 -13
  174. package/server/workspaces/layout.ts +60 -66
  175. package/server/workspaces/registry.ts +43 -18
  176. package/server/workspaces/shared.ts +74 -0
  177. package/server/workspaces/tabs.ts +6 -12
  178. package/skill/SKILL.md +24 -4
  179. package/client/api/app-ui-keys.ts +0 -6
  180. package/client/features/chat/sessions/browser-tab-state.ts +0 -43
  181. package/client/features/collab/members/keys.ts +0 -6
  182. package/client/features/workspace/browser-tab-state.ts +0 -51
  183. package/client/features/workspace/layout-save.ts +0 -13
  184. package/dist/chunk-3smkkcfw.js +0 -546
  185. package/dist/chunk-47h9c2qy.js +0 -2
  186. package/dist/chunk-8qed2gqp.js +0 -75
  187. package/dist/chunk-8zy3vesm.js +0 -1
  188. package/dist/chunk-a47zy276.js +0 -2
  189. package/dist/chunk-g4c1nte9.css +0 -1
  190. package/dist/chunk-kcactdr4.js +0 -2
  191. package/dist/chunk-m8bhx6tw.js +0 -1
  192. package/dist/chunk-pf19zcrn.js +0 -2
  193. package/dist/chunk-ygzxah0e.js +0 -1
  194. package/lib/workspace-types.ts +0 -13
  195. package/server/workspace-state/legacy-migration.ts +0 -79
@@ -1 +0,0 @@
1
- import{dt}from"/chunk-a47zy276.js";import{p}from"/chunk-pf19zcrn.js";async function r(){try{let e=await p("/api/proxy-user");if(!e||typeof e!=="object"||Array.isArray(e)||e.provider!==void 0&&e.provider!=="cloudflare-access"||e.provider===void 0&&e.profile!==void 0)return;return dt(e),e}catch{}}async function n(){return r()}export{n as loadProxyUser};
@@ -1,2 +0,0 @@
1
- var oa=Object.create;var{getPrototypeOf:ia,defineProperty:nr,getOwnPropertyNames:na}=Object;var br=Object.prototype.hasOwnProperty;function sa(r){return this[r]}var ca,la,e=(r,a,t)=>{var o=r!=null&&typeof r==="object";if(o){var i=a?ca??=new WeakMap:la??=new WeakMap,c=i.get(r);if(c)return c}t=r!=null?oa(ia(r)):{};let n=a||!r||!r.__esModule||!br.call(r,"default")?nr(t,"default",{value:r,enumerable:!0}):t;if(r&&typeof r==="object"||typeof r==="function"){for(let s of na(r))if(!br.call(n,s))nr(n,s,{get:sa.bind(r,s),enumerable:!0})}if(o)i.set(r,n);return n};var x=(r,a)=>()=>(a||r((a={exports:{}}).exports,a),a.exports);var da=(r)=>r;function pa(r,a){this[r]=da.bind(null,a)}var ve=(r,a)=>{for(var t in a)nr(r,t,{get:a[t],enumerable:!0,configurable:!0,set:pa.bind(a,t)})};var ct=((r)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(a,t)=>(typeof require<"u"?require:a)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var xr,sr,L,Z=(r,a)=>{for(var[t,o,i]of xr||[])for(var c=[r],n=globalThis,s=n.document,l,d,h,p,g;d=c.pop();)if(!sr[d]&&(h=o[d])){sr[d]=1;for(p=1;p<h.length;p++)c.push(i[h[p]]);if(!a&&d!==r&&(l=s&&s.head)){if(L===void 0)L=(p=s.querySelector("meta[property=csp-nonce]"))&&(p.nonce||p.getAttribute("nonce"))||"";if(g=s.createElement("link"),g.rel="modulepreload",g.crossOrigin="",L)g.nonce=L;g.href=new n.URL(h[0],t),l.appendChild(g)}}},ha=(r,a,t,o)=>{for(var i={},c=0;c<a.length;c++)i[a[c]]=t[c];(xr||=[]).push([r,i,a]),sr||={},Z(a[o],1)};ha(import.meta.url,["a47zy276","8qed2gqp","ygzxah0e","8zy3vesm","nf2wkvf9","3smkkcfw","47h9c2qy","kcactdr4","pf19zcrn","m8bhx6tw","th91xfnp"],[["/chunk-a47zy276.js"],["/chunk-8qed2gqp.js",6,7,0,8],["/chunk-ygzxah0e.js",7],["/chunk-8zy3vesm.js",0,8],["/chunk-nf2wkvf9.js"],["/chunk-3smkkcfw.js",10,6,0,7],["/chunk-47h9c2qy.js",0,7],["/chunk-kcactdr4.js",0,8],["/chunk-pf19zcrn.js"],["/chunk-m8bhx6tw.js",10],["/chunk-th91xfnp.js"]],0);
2
- if(typeof globalThis.structuredClone==="function")globalThis.structuredClone=globalThis.structuredClone.bind(globalThis);var ga={setTimeout:(r,a)=>setTimeout(r,a),clearTimeout:(r)=>clearTimeout(r),setInterval:(r,a)=>setInterval(r,a),clearInterval:(r)=>clearInterval(r)},ua=class{#r=ga;#a=!1;setTimeoutProvider(r){this.#r=r}setTimeout(r,a){return this.#r.setTimeout(r,a)}clearTimeout(r){this.#r.clearTimeout(r)}setInterval(r,a){return this.#r.setInterval(r,a)}clearInterval(r){this.#r.clearInterval(r)}},J=new ua;function yr(r){setTimeout(r,0)}var lr=typeof window>"u"||"Deno"in globalThis;function A(){}function _r(r,a){return typeof r==="function"?r(a):r}function ze(r){return typeof r==="number"&&r>=0&&r!==1/0}function He(r,a){return Math.max(r+(a||0)-Date.now(),0)}function P(r,a){return typeof r==="function"?r(a):r}function we(r,a){let{type:t="all",exact:o,fetchStatus:i,predicate:c,queryKey:n,stale:s}=r;if(n){if(o){if(a.queryHash!==U(n,a.options))return!1}else if(!_(a.queryKey,n))return!1}if(t!=="all"){let l=a.isActive();if(t==="active"&&!l)return!1;if(t==="inactive"&&l)return!1}if(typeof s==="boolean"&&a.isStale()!==s)return!1;if(i&&i!==a.state.fetchStatus)return!1;if(c&&!c(a))return!1;return!0}function N(r,a){let{exact:t,status:o,predicate:i,mutationKey:c}=r;if(c){if(!a.options.mutationKey)return!1;if(t){if(Q(a.options.mutationKey)!==Q(c))return!1}else if(!_(a.options.mutationKey,c))return!1}if(o&&a.state.status!==o)return!1;if(i&&!i(a))return!1;return!0}function U(r,a){return(a?.queryKeyHashFn||Q)(r)}function Q(r){return JSON.stringify(r,(a,t)=>cr(t)?Object.keys(t).sort().reduce((o,i)=>(o[i]=t[i],o),{}):t)}function _(r,a){if(r===a)return!0;if(typeof r!==typeof a)return!1;if(r&&a&&typeof r==="object"&&typeof a==="object"){if(Array.isArray(r)&&Array.isArray(a)){for(let o=0;o<a.length;o++)if(!_(r[o],a[o]))return!1;return!0}let t=Object.keys(a);for(let o of t)if(!_(r[o],a[o]))return!1;return!0}return!1}var va=Object.prototype.hasOwnProperty;function Ae(r,a,t=0){if(r===a)return r;if(t>500)return a;let o=kr(r)&&kr(a);if(!o&&!(cr(r)&&cr(a)))return a;let i=(o?r:Object.keys(r)).length,c=o?a:Object.keys(a),n=c.length,s=o?Array(n):{},l=0;for(let d=0;d<n;d++){let h=o?d:c[d],p=r[h],g=a[h];if(p===g){if(s[h]=p,o?d<i:va.call(r,h))l++;continue}if(p===null||g===null||typeof p!=="object"||typeof g!=="object"){s[h]=g;continue}let b=Ae(p,g,t+1);if(s[h]=b,b===p)l++}return i===n&&l===i?r:s}function Se(r,a){if(!a||Object.keys(r).length!==Object.keys(a).length)return!1;for(let t in r)if(r[t]!==a[t])return!1;return!0}function kr(r){return Array.isArray(r)&&r.length===Object.keys(r).length}function cr(r){if(!zr(r))return!1;let a=r.constructor;if(a===void 0)return!0;let t=a.prototype;if(!zr(t))return!1;if(!t.hasOwnProperty("isPrototypeOf"))return!1;if(Object.getPrototypeOf(r)!==Object.prototype)return!1;return!0}function zr(r){return Object.prototype.toString.call(r)==="[object Object]"}function Cr(r){return new Promise((a)=>{J.setTimeout(a,r)})}function _e(r,a,t){if(typeof t.structuralSharing==="function")return t.structuralSharing(r,a);else if(t.structuralSharing!==!1)return Ae(r,a);return a}function Er(r,a,t=0){let o=[...r,a];return t&&o.length>t?o.slice(1):o}function Sr(r,a,t=0){let o=[a,...r];return t&&o.length>t?o.slice(0,-1):o}var j=Symbol();function V(r,a){if(!r.queryFn&&a?.initialPromise)return()=>a.initialPromise;if(!r.queryFn||r.queryFn===j)return()=>Promise.reject(Error(`Missing queryFn: '${r.queryHash}'`));return r.queryFn}function Ie(r,a){if(typeof r==="function")return r(...a);return!!r}function Ar(r,a,t){let o=!1,i;return Object.defineProperty(r,"signal",{enumerable:!0,get:()=>{if(i??=a(),o)return i;if(o=!0,i.aborted)t();else i.addEventListener("abort",t,{once:!0});return i}}),r}var wa=()=>lr,Ce=()=>wa();var K=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(r){return this.listeners.add(r),this.onSubscribe(),()=>{this.listeners.delete(r),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var ma=class extends K{#r;#a;#t;constructor(){super();this.#t=(r)=>{if(typeof window<"u"&&window.addEventListener){let a=()=>r();return window.addEventListener("visibilitychange",a,!1),()=>{window.removeEventListener("visibilitychange",a)}}}}onSubscribe(){if(!this.#a)this.setEventListener(this.#t)}onUnsubscribe(){if(!this.hasListeners())this.#a?.(),this.#a=void 0}setEventListener(r){this.#t=r,this.#a?.(),this.#a=r((a)=>{if(typeof a==="boolean")this.setFocused(a);else this.onFocus()})}setFocused(r){if(this.#r!==r)this.#r=r,this.onFocus()}onFocus(){let r=this.isFocused();this.listeners.forEach((a)=>{a(r)})}isFocused(){if(typeof this.#r==="boolean")return this.#r;return globalThis.document?.visibilityState!=="hidden"}},ke=new ma;var jr=yr;function fa(){let r=[],a=0,t=(s)=>{s()},o=(s)=>{s()},i=jr,c=(s)=>{if(a)r.push(s);else i(()=>{t(s)})},n=()=>{let s=r;if(r=[],s.length)i(()=>{o(()=>{s.forEach((l)=>{t(l)})})})};return{batch:(s)=>{let l;a++;try{l=s()}finally{if(a--,!a)n()}return l},batchCalls:(s)=>(...l)=>{c(()=>{s(...l)})},schedule:c,setNotifyFunction:(s)=>{t=s},setBatchNotifyFunction:(s)=>{o=s},setScheduler:(s)=>{i=s}}}var k=fa();var ba=class extends K{#r=!0;#a;#t;constructor(){super();this.#t=(r)=>{if(typeof window<"u"&&window.addEventListener){let a=()=>r(!0),t=()=>r(!1);return window.addEventListener("online",a,!1),window.addEventListener("offline",t,!1),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",t)}}}}onSubscribe(){if(!this.#a)this.setEventListener(this.#t)}onUnsubscribe(){if(!this.hasListeners())this.#a?.(),this.#a=void 0}setEventListener(r){this.#t=r,this.#a?.(),this.#a=r(this.setOnline.bind(this))}setOnline(r){if(this.#r!==r)this.#r=r,this.listeners.forEach((a)=>{a(r)})}isOnline(){return this.#r}},O=new ba;function xa(r){return Math.min(1000*2**r,30000)}function dr(r){return(r??"online")==="online"?O.isOnline():!0}var Y=class extends Error{constructor(r){super("CancelledError");this.revert=r?.revert,this.silent=r?.silent}};function X(r){let a=!1,t=0,o,i="pending",c,n,s=new Promise((u,m)=>{c=u,n=m});s.catch(A);let l=()=>i!=="pending",d=(u)=>{if(!l()){let m=new Y(u);w(m),r.onCancel?.(m)}},h=()=>{a=!0},p=()=>{a=!1},g=()=>ke.isFocused()&&(r.networkMode==="always"||O.isOnline())&&r.canRun(),b=()=>dr(r.networkMode)&&r.canRun(),v=(u)=>{if(!l())o?.(),i="resolved",c(u)},w=(u)=>{if(!l())o?.(),i="rejected",n(u)},y=()=>new Promise((u)=>{o=(m)=>{if(l()||g())u(m)},r.onPause?.()}).then(()=>{if(o=void 0,!l())r.onContinue?.()}),R=()=>{if(l())return;let u,m=t===0?r.initialPromise:void 0;try{u=m??r.fn()}catch(f){u=Promise.reject(f)}Promise.resolve(u).then(v).catch((f)=>{if(l())return;let z=r.retry??(Ce()?0:3),S=r.retryDelay??xa,ta=typeof S==="function"?S(t,f):S,ea=z===!0||typeof z==="number"&&t<z||typeof z==="function"&&z(t,f);if(a||!ea){w(f);return}t++,r.onFail?.(t,f),Cr(ta).then(()=>g()?void 0:y()).then(()=>{if(a)w(f);else R()})})};return{promise:s,status:()=>i,cancel:d,continue:()=>(o?.(),s),cancelRetry:h,continueRetry:p,canStart:b,start:()=>{if(b())R();else y().then(R);return s}}}var rr=class{#r;destroy(){this.clearGcTimeout()}scheduleGc(){if(this.clearGcTimeout(),ze(this.gcTime))this.#r=J.setTimeout(()=>{this.optionalRemove()},this.gcTime)}updateGcTime(r){this.gcTime=Math.max(this.gcTime||0,r??(Ce()?1/0:300000))}clearGcTimeout(){if(this.#r!==void 0)J.clearTimeout(this.#r),this.#r=void 0}};function Or(r){return{onFetch:(a,t)=>{let o=a.options,i=a.fetchOptions?.meta?.fetchMore?.direction,c=a.state.data?.pages||[],n=a.state.data?.pageParams||[],s={pages:[],pageParams:[]},l=0,d=async()=>{let h=!1,p=(v)=>{Ar(v,()=>a.signal,()=>h=!0)},g=V(a.options,a.fetchOptions),b=async(v,w,y)=>{if(h)return Promise.reject(a.signal.reason);if(w==null&&v.pages.length)return Promise.resolve(v);let u=(()=>{let S={client:a.client,queryKey:a.queryKey,pageParam:w,direction:y?"backward":"forward",meta:a.options.meta};return p(S),S})(),m=await g(u),{maxPages:f}=a.options,z=y?Sr:Er;return{pages:z(v.pages,m,f),pageParams:z(v.pageParams,w,f)}};if(i&&c.length){let v=i==="backward",w=v?ya:Pr,y={pages:c,pageParams:n};s=await b(y,w(o,y),v)}else{let v=r??c.length;do{let w=l===0?n[0]??o.initialPageParam:Pr(o,s);if(l>0&&w==null)break;s=await b(s,w),l++}while(l<v)}return s};if(a.options.persister)a.fetchFn=()=>a.options.persister?.(d,{client:a.client,queryKey:a.queryKey,meta:a.options.meta,signal:a.signal},t);else a.fetchFn=d}}}function Pr(r,{pages:a,pageParams:t}){let o=a.length-1;return a.length>0?r.getNextPageParam(a[o],a,t[o],t):void 0}function ya(r,{pages:a,pageParams:t}){return a.length>0?r.getPreviousPageParam?.(a[0],a,t[0],t):void 0}var qr=class extends rr{#r;#a;#t;#o;#i;#e;#c;#n;constructor(r){super();this.#n=!1,this.#c=r.defaultOptions,this.setOptions(r.options),this.observers=[],this.#i=r.client,this.#o=this.#i.getQueryCache(),this.queryKey=r.queryKey,this.queryHash=r.queryHash,this.#a=Ir(this.options),this.state=r.state??this.#a,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#r}get promise(){return this.#e?.promise}setOptions(r){if(this.options={...this.#c,...r},r?._type)this.#r=r._type;if(this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let a=Ir(this.options);if(a.data!==void 0)this.setState(Mr(a.data,a.dataUpdatedAt)),this.#a=a}}optionalRemove(){if(!this.observers.length&&this.state.fetchStatus==="idle")this.#o.remove(this)}setData(r,a){let t=_e(this.state.data,r,this.options);return this.#s({data:t,type:"success",dataUpdatedAt:a?.updatedAt,manual:a?.manual}),t}setState(r){this.#s({type:"setState",state:r})}cancel(r){let a=this.#e?.promise;return this.#e?.cancel(r),a?a.then(A).catch(A):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#a}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some((r)=>P(r.options.enabled,this)!==!1)}isDisabled(){if(this.getObserversCount()>0)return!this.isActive();return this.options.queryFn===j||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){if(this.getObserversCount()>0)return this.observers.some((r)=>P(r.options.staleTime,this)==="static");return!1}isStale(){if(this.getObserversCount()>0)return this.observers.some((r)=>r.getCurrentResult().isStale);return this.state.data===void 0||this.state.isInvalidated}isStaleByTime(r=0){if(this.state.data===void 0)return!0;if(r==="static")return!1;if(this.state.isInvalidated)return!0;return!He(this.state.dataUpdatedAt,r)}onFocus(){this.observers.find((r)=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#e?.continue()}onOnline(){this.observers.find((r)=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#e?.continue()}addObserver(r){if(!this.observers.includes(r))this.observers.push(r),this.clearGcTimeout(),this.#o.notify({type:"observerAdded",query:this,observer:r})}removeObserver(r){let a=this.observers.indexOf(r);if(a!==-1){if(this.observers.splice(a,1),!this.observers.length){if(this.#e)if(this.#n||this.state.fetchStatus==="paused"&&this.state.status==="pending")this.#e.cancel({revert:!0});else this.#e.cancelRetry();this.scheduleGc()}this.#o.notify({type:"observerRemoved",query:this,observer:r})}}getObserversCount(){return this.observers.length}invalidate(){if(!this.state.isInvalidated)this.#s({type:"invalidate"})}async fetch(r,a){if(this.state.fetchStatus!=="idle"&&this.#e?.status()!=="rejected"){if(this.state.data!==void 0&&a?.cancelRefetch)this.cancel({silent:!0});else if(this.#e)return this.#e.continueRetry(),this.#e.promise}if(r)this.setOptions(r);if(!this.options.queryFn){let l=this.observers.find((d)=>d.options.queryFn);if(l)this.setOptions(l.options)}let t=new AbortController,o=(l)=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(this.#n=!0,t.signal)})},i=()=>{let l=V(this.options,a),h=(()=>{let p={client:this.#i,queryKey:this.queryKey,meta:this.meta};return o(p),p})();if(this.#n=!1,this.options.persister)return this.options.persister(l,h,this);return l(h)},n=(()=>{let l={fetchOptions:a,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return o(l),l})();if((this.#r==="infinite"?Or(this.options.pages):this.options.behavior)?.onFetch(n,this),this.#t=this.state,this.state.fetchStatus==="idle"||this.state.fetchMeta!==n.fetchOptions?.meta)this.#s({type:"fetch",meta:n.fetchOptions?.meta});let s=this.#e=X({initialPromise:a?.initialPromise,fn:n.fetchFn,onCancel:(l)=>{if(l instanceof Y&&l.revert)this.setState({...this.#t,fetchStatus:"idle"});t.abort()},onFail:(l,d)=>{this.#s({type:"failed",failureCount:l,error:d})},onPause:()=>{this.#s({type:"pause"})},onContinue:()=>{this.#s({type:"continue"})},retry:n.options.retry,retryDelay:n.options.retryDelay,networkMode:n.options.networkMode,canRun:()=>!0});try{let l=await s.start();if(l===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(l),this.#o.config.onSuccess?.(l,this),this.#o.config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Y){if(l.silent)return this.#e.promise;else if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw this.#s({type:"error",error:l}),this.#o.config.onError?.(l,this),this.#o.config.onSettled?.(this.state.data,l,this),l}finally{if(this.#e===s)this.#e=void 0;this.scheduleGc()}}#s(r){let a=(t)=>{switch(r.type){case"failed":return{...t,fetchFailureCount:r.failureCount,fetchFailureReason:r.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...Qe(t.data,this.options),fetchMeta:r.meta??null};case"success":let o={...t,...Mr(r.data,r.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!r.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=r.manual?o:void 0,o;case"error":let i=r.error;return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...r.state}}};this.state=a(this.state),k.batch(()=>{this.observers.slice().forEach((t)=>{t.onQueryUpdate()}),this.#o.notify({query:this,type:"updated",action:r})})}};function Qe(r,a){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:dr(a.networkMode)?"fetching":"paused",...r===void 0&&{error:null,status:"pending"}}}function Mr(r,a){return{data:r,dataUpdatedAt:a??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Ir(r){let a=typeof r.initialData==="function"?r.initialData():r.initialData,t=a!==void 0,o=t?typeof r.initialDataUpdatedAt==="function"?r.initialDataUpdatedAt():r.initialDataUpdatedAt:0;return{data:a,dataUpdateCount:0,dataUpdatedAt:t?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var Dr=class extends rr{#r;#a;#t;#o;constructor(r){super();this.#r=r.client,this.mutationId=r.mutationId,this.#t=r.mutationCache,this.#a=[],this.state=r.state||et(),this.setOptions(r.options),this.scheduleGc()}setOptions(r){this.options=r,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(r){if(!this.#a.includes(r))this.#a.push(r),this.clearGcTimeout(),this.#t.notify({type:"observerAdded",mutation:this,observer:r})}removeObserver(r){this.#a=this.#a.filter((a)=>a!==r),this.scheduleGc(),this.#t.notify({type:"observerRemoved",mutation:this,observer:r})}optionalRemove(){if(!this.#a.length)if(this.state.status==="pending")this.scheduleGc();else this.#t.remove(this)}continue(){return this.#o?.continue()??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(r){let a=()=>{this.#i({type:"continue"})},t={client:this.#r,meta:this.options.meta,mutationKey:this.options.mutationKey},o=this.#o=X({fn:()=>{if(!this.options.mutationFn)return Promise.reject(Error("No mutationFn found"));return this.options.mutationFn(r,t)},onFail:(n,s)=>{this.#i({type:"failed",failureCount:n,error:s})},onPause:()=>{this.#i({type:"pause"})},onContinue:a,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)}),i=this.state.status==="pending",c=!o.canStart();try{if(i)a();else{if(this.#i({type:"pending",variables:r,isPaused:c}),this.#t.config.onMutate)await this.#t.config.onMutate(r,this,t);let s=await this.options.onMutate?.(r,t);if(s!==this.state.context)this.#i({type:"pending",context:s,variables:r,isPaused:c})}let n=await o.start();return await this.#t.config.onSuccess?.(n,r,this.state.context,this,t),await this.options.onSuccess?.(n,r,this.state.context,t),await this.#t.config.onSettled?.(n,null,this.state.variables,this.state.context,this,t),await this.options.onSettled?.(n,null,r,this.state.context,t),this.#i({type:"success",data:n}),n}catch(n){try{await this.#t.config.onError?.(n,r,this.state.context,this,t)}catch(s){Promise.reject(s)}try{await this.options.onError?.(n,r,this.state.context,t)}catch(s){Promise.reject(s)}try{await this.#t.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,t)}catch(s){Promise.reject(s)}try{await this.options.onSettled?.(void 0,n,r,this.state.context,t)}catch(s){Promise.reject(s)}throw this.#i({type:"error",error:n}),n}finally{if(this.#o===o)this.#o=void 0;this.#t.runNext(this)}}#i(r){let a=(t)=>{switch(r.type){case"failed":return{...t,failureCount:r.failureCount,failureReason:r.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:r.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:r.isPaused,status:"pending",variables:r.variables,submittedAt:Date.now()};case"success":return{...t,data:r.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:r.error,failureCount:t.failureCount+1,failureReason:r.error,isPaused:!1,status:"error"}}};this.state=a(this.state),k.batch(()=>{this.#a.forEach((t)=>{t.onMutationUpdate(r)}),this.#t.notify({mutation:this,type:"updated",action:r})})}};function et(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ur=class extends K{#r;#a;#t;constructor(r={}){super();this.config=r,this.#r=new Set,this.#a=new Map,this.#t=0}build(r,a,t){let o=new Dr({client:r,mutationCache:this,mutationId:++this.#t,options:r.defaultMutationOptions(a),state:t});return this.add(o),o}add(r){this.#r.add(r);let a=ar(r);if(typeof a==="string"){let t=this.#a.get(a);if(t)t.push(r);else this.#a.set(a,[r])}this.notify({type:"added",mutation:r})}remove(r){if(this.#r.delete(r)){let a=ar(r);if(typeof a==="string"){let t=this.#a.get(a);if(t){if(t.length>1){let o=t.indexOf(r);if(o!==-1)t.splice(o,1)}else if(t[0]===r)this.#a.delete(a)}}}this.notify({type:"removed",mutation:r})}canRun(r){let a=ar(r);if(typeof a==="string"){let t=this.#a.get(a)?.find((o)=>o.state.status==="pending");return!t||t===r}else return!0}runNext(r){let a=ar(r);if(typeof a==="string")return this.#a.get(a)?.find((t)=>t!==r&&t.state.isPaused)?.continue()??Promise.resolve();else return Promise.resolve()}clear(){k.batch(()=>{this.#r.forEach((r)=>{this.notify({type:"removed",mutation:r})}),this.#r.clear(),this.#a.clear()})}getAll(){return Array.from(this.#r)}find(r){let a={exact:!0,...r};return this.getAll().find((t)=>N(a,t))}findAll(r={}){return this.getAll().filter((a)=>N(r,a))}notify(r){k.batch(()=>{this.listeners.forEach((a)=>{a(r)})})}resumePausedMutations(){let r=this.getAll().filter((a)=>a.state.isPaused);return k.batch(()=>Promise.all(r.map((a)=>a.continue().catch(A))))}};function ar(r){return r.options.scope?.id}var Fr=class extends K{#r;constructor(r={}){super();this.config=r,this.#r=new Map}build(r,a,t){let o=a.queryKey,i=a.queryHash??U(o,a),c=this.get(i);if(!c)c=new qr({client:r,queryKey:o,queryHash:i,options:r.defaultQueryOptions(a),state:t,defaultOptions:r.getQueryDefaults(o)}),this.add(c);return c}add(r){if(!this.#r.has(r.queryHash))this.#r.set(r.queryHash,r),this.notify({type:"added",query:r})}remove(r){let a=this.#r.get(r.queryHash);if(a){if(r.destroy(),a===r)this.#r.delete(r.queryHash);this.notify({type:"removed",query:r})}}clear(){k.batch(()=>{this.getAll().forEach((r)=>{this.remove(r)})})}get(r){return this.#r.get(r)}getAll(){return[...this.#r.values()]}find(r){let a={exact:!0,...r};return this.getAll().find((t)=>we(a,t))}findAll(r={}){let a=this.getAll();return Object.keys(r).length>0?a.filter((t)=>we(r,t)):a}notify(r){k.batch(()=>{this.listeners.forEach((a)=>{a(r)})})}onFocus(){k.batch(()=>{this.getAll().forEach((r)=>{r.onFocus()})})}onOnline(){k.batch(()=>{this.getAll().forEach((r)=>{r.onOnline()})})}};var pr=class{#r;#a;#t;#o;#i;#e;#c;#n;constructor(r={}){this.#r=r.queryCache||new Fr,this.#a=r.mutationCache||new Ur,this.#t=r.defaultOptions||{},this.#o=new Map,this.#i=new Map,this.#e=0}mount(){if(this.#e++,this.#e!==1)return;this.#c=ke.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onFocus()}),this.#n=O.subscribe(async(r)=>{if(r)await this.resumePausedMutations(),this.#r.onOnline()})}unmount(){if(this.#e--,this.#e!==0)return;this.#c?.(),this.#c=void 0,this.#n?.(),this.#n=void 0}isFetching(r){return this.#r.findAll({...r,fetchStatus:"fetching"}).length}isMutating(r){return this.#a.findAll({...r,status:"pending"}).length}getQueryData(r){let a=this.defaultQueryOptions({queryKey:r});return this.#r.get(a.queryHash)?.state.data}ensureQueryData(r){let a=this.defaultQueryOptions(r),t=this.#r.build(this,a),o=t.state.data;if(o===void 0)return this.fetchQuery(r);if(r.revalidateIfStale&&t.isStaleByTime(P(a.staleTime,t)))this.prefetchQuery(a);return Promise.resolve(o)}getQueriesData(r){return this.#r.findAll(r).map(({queryKey:a,state:t})=>[a,t.data])}setQueryData(r,a,t){let o=this.defaultQueryOptions({queryKey:r}),i=this.#r.get(o.queryHash)?.state.data,c=_r(a,i);if(c===void 0)return;return this.#r.build(this,o).setData(c,{...t,manual:!0})}setQueriesData(r,a,t){return k.batch(()=>this.#r.findAll(r).map(({queryKey:o})=>[o,this.setQueryData(o,a,t)]))}getQueryState(r){let a=this.defaultQueryOptions({queryKey:r});return this.#r.get(a.queryHash)?.state}removeQueries(r){let a=this.#r;k.batch(()=>{a.findAll(r).forEach((t)=>{a.remove(t)})})}resetQueries(r,a){let t=this.#r;return k.batch(()=>{let o=t.findAll(r),i=new Set(o);return o.forEach((c)=>{c.reset()}),this.refetchQueries({type:"active",predicate:(c)=>i.has(c)},a)})}cancelQueries(r,a={}){let t={revert:!0,...a},o=k.batch(()=>this.#r.findAll(r).map((i)=>i.cancel(t)));return Promise.all(o).then(A).catch(A)}invalidateQueries(r,a={}){return k.batch(()=>{if(this.#r.findAll(r).forEach((t)=>{t.invalidate()}),r?.refetchType==="none")return Promise.resolve();return this.refetchQueries({...r,type:r?.refetchType??r?.type??"active"},a)})}refetchQueries(r,a={}){let t={...a,cancelRefetch:a.cancelRefetch??!0},o=k.batch(()=>this.#r.findAll(r).filter((i)=>!i.isDisabled()&&!i.isStatic()).map((i)=>{let c=i.fetch(void 0,t);if(!t.throwOnError)c=c.catch(A);return i.state.fetchStatus==="paused"?Promise.resolve():c}));return Promise.all(o).then(A)}async query(r){let a=this.defaultQueryOptions(r);if(a.retry===void 0)a.retry=!1;let t=this.#r.build(this,a),o=t.isStaleByTime(P(a.staleTime,t))?await t.fetch(a):t.state.data,i=a.select;if(i)return i(o);return o}fetchQuery(r){let a=this.defaultQueryOptions(r);if(a.retry===void 0)a.retry=!1;let t=this.#r.build(this,a);return t.isStaleByTime(P(a.staleTime,t))?t.fetch(a):Promise.resolve(t.state.data)}prefetchQuery(r){return this.fetchQuery(r).then(A).catch(A)}infiniteQuery(r){return r._type="infinite",this.query(r)}fetchInfiniteQuery(r){return r._type="infinite",this.fetchQuery(r)}prefetchInfiniteQuery(r){return this.fetchInfiniteQuery(r).then(A).catch(A)}ensureInfiniteQueryData(r){return r._type="infinite",this.ensureQueryData(r)}resumePausedMutations(){if(O.isOnline())return this.#a.resumePausedMutations();return Promise.resolve()}getQueryCache(){return this.#r}getMutationCache(){return this.#a}getDefaultOptions(){return this.#t}setDefaultOptions(r){this.#t=r}setQueryDefaults(r,a){this.#o.set(Q(r),{queryKey:r,defaultOptions:a})}getQueryDefaults(r){let a=[...this.#o.values()],t={};return a.forEach((o)=>{if(_(r,o.queryKey))Object.assign(t,o.defaultOptions)}),t}setMutationDefaults(r,a){this.#i.set(Q(r),{mutationKey:r,defaultOptions:a})}getMutationDefaults(r){let a=[...this.#i.values()],t={};return a.forEach((o)=>{if(_(r,o.mutationKey))Object.assign(t,o.defaultOptions)}),t}defaultQueryOptions(r){if(r._defaulted)return r;let a={...this.#t.queries,...this.getQueryDefaults(r.queryKey),...r,_defaulted:!0};if(!a.queryHash)a.queryHash=U(a.queryKey,a);if(a.refetchOnReconnect===void 0)a.refetchOnReconnect=a.networkMode!=="always";if(a.throwOnError===void 0)a.throwOnError=!!a.suspense;if(!a.networkMode&&a.persister)a.networkMode="offlineFirst";if(a.queryFn===j)a.enabled=!1;return a}defaultMutationOptions(r){if(r?._defaulted)return r;return{...this.#t.mutations,...r?.mutationKey&&this.getMutationDefaults(r.mutationKey),...r,_defaulted:!0}}clear(){this.#r.clear(),this.#a.clear()}};var M=new pr;var D={all:["workspace-members"],account:(r)=>[...D.all,r??"unknown"],workspace:(r,a)=>[...D.account(r),a]};var I=["pink","orange","amber","lime","emerald","cyan","blue","violet"];function tr(r){return typeof r==="string"&&I.includes(r)}function Ue(r){let a=2166136261;for(let t=0;t<r.length;t++)a^=r.charCodeAt(t),a=Math.imul(a,16777619);return I[(a>>>0)%I.length]??I[0]}var ut=1;var ka=8192,za=320;function ee(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)}function er(r,a=256){return typeof r==="string"&&r.length>0&&!r.includes("\x00")&&new TextEncoder().encode(r).length<=a}function Tr(r){return ee(r)&&er(r.id,240)&&r.id.trim().length>0&&(r.name===void 0||er(r.name)&&r.name.trim().length>0)&&tr(r.color)&&(r.avatar===void 0||er(r.avatar,ka))&&(r.email===void 0||er(r.email,za))}function or(r,a){return typeof r==="string"&&r.length<=a&&!r.includes("\x00")}function _a(r){if(!or(r,2048))return!1;try{return["http:","https:"].includes(new URL(r).protocol)}catch{return!1}}function ie(r){if(!ee(r)||!or(r.id,240)||!r.id.trim()||r.id!==r.id.trim()||!or(r.name,256)||r.avatar!==void 0&&!_a(r.avatar))throw Error("Invalid identity");let a={id:r.id,name:r.name,...r.avatar!==void 0?{avatar:r.avatar}:{}};if(r.type==="agent")return{...a,type:"agent"};if(r.type==="user"&&or(r.email,320)&&typeof r.isAnonymous==="boolean")return{...a,type:"user",email:r.email,isAnonymous:r.isAnonymous};throw Error("Invalid identity")}var B=(r)=>`${r.type}:${r.id}`,ce=(r)=>r.type==="agent"?`agent:${r.id}`:r.id;var ir,Qr=0,Rr=0,hr=new Set,W=()=>ir,Me=()=>Rr,F=()=>Qr;function We(r){return hr.add(r),()=>{hr.delete(r)}}function ue(r){let a=r===null?null:ie(r);if((ir&&B(ir))!==(a&&B(a)))Qr++,M.cancelQueries({queryKey:D.all}),M.removeQueries({queryKey:D.all});Rr++,ir=a,hr.forEach((o)=>o())}var Ca=["Curious Kiwi","Cheerful Cherry","Sleepy Peach","Excited Banana","Cosmic Mango","Velvet Lemon","Electric Plum","Wandering Pear","Dramatic Papaya","Suspicious Pineapple","Confused Coconut","Sneaky Tangerine","Gentle Fig","Quiet Apricot","Mellow Melon","Dreamy Guava"];function Lr(r,a){let t=r.filter((o)=>o!==a);return t[Math.floor(Math.random()*t.length)]??r[0]}function Ea(r){return{name:Lr(Ca,r?.name),color:Lr(I,r?.color)}}function Sa(r,a){let t=a.name.trim();return{id:r,...t?{name:t}:{},color:a.color}}function Nr(){return Sa(`local-${crypto.randomUUID().slice(0,8)}`,Ea())}var ur="moi:local-profile",C,E,T=new Set;function vr(r,a){return JSON.stringify(r)===JSON.stringify(a)}function q(r){if(!r||typeof r.id!=="string"||!r.id.trim())throw Error("A user profile needs an id.");if(r.name!==void 0&&typeof r.name!=="string")throw Error("A user profile name must be a string when provided.");if(r.color!==void 0&&!tr(r.color))throw Error("A user profile color must be one of the user palette names.");let a=r.id.trim(),t=r.name?.trim(),o={id:a,...t?{name:t}:{},color:r.color??Ue(a),...r.avatar!==void 0?{avatar:r.avatar}:{},...r.email!==void 0?{email:r.email}:{}};if(!Tr(o))throw Error("Invalid user profile.");return Object.freeze(o)}var gr,Kr;function H(){let r=W();if(r===void 0)return C;if(r!==Kr){Kr=r;let a=!r||r.type==="user"&&r.isAnonymous?void 0:q({id:ce(r),name:r.name||void 0,avatar:r.avatar,email:r.type==="user"?r.email||void 0:void 0});if(!vr(gr,a))gr=a}return gr}function de(r){let a=H(),t=G(),o=()=>{let c=H(),n=G();if(a===c&&t===n)return;a=c,t=n,r()};T.add(o);let i=We(o);return()=>{T.delete(o),i()}}function G(){return W()!==void 0?"external":E}function dt({provider:r,profile:a}){if(G()==="external")return;if(r===void 0){if(E===void 0||E==="local")return;E=void 0,C=void 0}else{let t=a===void 0?void 0:q(a);if(E===r&&vr(C,t))return;E=r,C=t}T.forEach((t)=>t())}function Aa(){try{localStorage.setItem(ur,JSON.stringify(C))}catch{}}function $e(r){if(G()!==void 0&&G()!=="local")return;let a=q(r);E="local",C=a,Aa(),T.forEach((t)=>t())}function Hr(r,a){if(!r||!a||a.provider!==void 0||G()!==void 0)return;try{let t=localStorage.getItem(ur);if(t){$e(JSON.parse(t));return}}catch{}$e(Nr())}function Br(r){if(r.key!==ur||!r.newValue||G()!=="local")return;try{let a=q(JSON.parse(r.newValue));if(vr(a,C))return;C=a,T.forEach((t)=>t())}catch{}}function Wr(){return window.addEventListener("storage",Br),()=>window.removeEventListener("storage",Br)}function De(r){if(!ee(r)||!Array.isArray(r.members)||!Array.isArray(r.invitations))throw Error("Invalid workspace members");let a=r.members.map((o)=>{let i=ie(o);if(ee(o)&&o.membershipId!==void 0){if(typeof o.membershipId!=="string"||!o.membershipId||o.membershipId.length>240)throw Error("Invalid membership id");return{...i,membershipId:o.membershipId}}return i}),t=r.invitations.map((o)=>{if(!ee(o)||typeof o.id!=="string"||!o.id||typeof o.email!=="string"||!o.email||typeof o.expiresAt!=="string"||!Number.isFinite(Date.parse(o.expiresAt)))throw Error("Invalid invitation");return{id:o.id,email:o.email,expiresAt:o.expiresAt}});if(new Set(a.map(B)).size!==a.length||new Set(t.map((o)=>o.id)).size!==t.length)throw Error("Duplicate workspace member or invitation");return{members:a,invitations:t}}function Te(r){if(!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(r))throw Error("Invalid workspace id");return r}M.setQueryDefaults(D.all,{gcTime:1/0});var mr=0,Yr,wr=new Set,Vr=new WeakMap;M.getQueryCache().subscribe((r)=>{if(r.query.queryKey[0]!==D.all[0])return;if(r.type==="removed"||r.type==="updated"&&r.action.type==="success")mr++});var Xr=()=>mr,$r=new WeakMap;function Ve(){let r=W();if(Yr!==F()||r?.type!=="user"||r.isAnonymous)return;let a=Vr.get(r);if(!a)a={members:[r],invitations:[]},Vr.set(r,a);return a}function Jr(r,a){let t=W(),o=D.workspace(t?B(t):void 0,r);Te(r);let i=De(a);M.cancelQueries({queryKey:o,exact:!0}),M.setQueryData(o,i)}function Zr(r){if(!Array.isArray(r))throw Error("Invalid workspace members");let a=r.map((n)=>({id:Te(n.id),data:De(n)})),t=new Set(a.map((n)=>n.id));if(t.size!==a.length)throw Error("Duplicate workspace id");Yr=F();let o=W(),i=o?B(o):void 0,c=D.account(i);M.cancelQueries({queryKey:c});for(let n of M.getQueryCache().findAll({queryKey:c}))if(!t.has(n.queryKey[2]))fr(n.queryKey);for(let n of a)M.setQueryData(D.workspace(i,n.id),n.data);mr++,wr.forEach((n)=>n())}function Gr(r){let a=W(),t=D.workspace(a?B(a):void 0,r);Te(r),M.cancelQueries({queryKey:t,exact:!0}),fr(t)}function ra(){M.cancelQueries({queryKey:D.all});for(let r of M.getQueryCache().findAll({queryKey:D.all}))fr(r.queryKey)}function fr(r){M.setQueryData(r,Ve()??{members:[],invitations:[]})}function pt(r){let a=W(),t=D.workspace(a?B(a):void 0,r),o=M.getQueryData(t)??Ve();if(!o)return;let i=$r.get(o);if(!i)i=o.members.map((c)=>q({id:ce(c),name:c.name||void 0,avatar:c.avatar,email:c.type==="user"?c.email||void 0:void 0})),$r.set(o,i);return i}function tt(r){wr.add(r);let a=M.getQueryCache().subscribe((t)=>{if(t.query.queryKey[0]===D.all[0])r()});return()=>{wr.delete(r),a()}}function aa(){if(typeof window>"u")return;let r=window;r.moi??={},r.moi.identity={set:ue,getRevision:Me},r.moi.workspaceMembers={set:Jr,setAll:Zr,remove:Gr,clear:ra,getRevision:Xr}}aa();Wr();async function ja(r){let[{mount:a},t,o]=await Promise.all([(Z("8qed2gqp"),import("/chunk-8qed2gqp.js")),(Z("ygzxah0e"),import("/chunk-ygzxah0e.js")).then((i)=>i.loadAppConfig()),(Z("8zy3vesm"),import("/chunk-8zy3vesm.js")).then((i)=>i.loadProxyUser())]);Hr(t?.environment==="local"&&!t.demo,o),a(r)}globalThis.__init=ja;export{e,x,ve,ct,Z,J,A,ze,He,P,we,Q,Ae,Se,_e,Ie,Ce,K,ke,k,Qe,et,M,D,Ue,ut,ee,ie,B,ce,W,Me,F,We,ue,H,de,G,dt,$e,De,Te,Ve,pt,tt};