@react-pdf-kit/viewer 2.0.0-beta.0 → 2.0.0-beta.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 (201) hide show
  1. package/dist/{LayoutWrapper-a871c161.js → LayoutWrapper-6224491f.js} +1 -1
  2. package/dist/{RotateTool.module-03987eba.js → RotateTool.module-67946714.js} +1 -1
  3. package/dist/{SearchCloseButton-cbf182aa.js → SearchCloseButton-08d57275.js} +1 -1
  4. package/dist/ToolbarLayout.module-3a77cc37.js +3556 -0
  5. package/dist/assets/style.css +1 -0
  6. package/dist/assets/style.js +74 -0
  7. package/dist/components/RPConfig.js +14 -1489
  8. package/dist/components/RPController.js +175 -61
  9. package/dist/components/RPDropFileZone.js +26 -12
  10. package/dist/components/RPPages.js +82 -8
  11. package/dist/components/RPProvider.js +173 -19
  12. package/dist/components/RPTheme.js +6 -5
  13. package/dist/components/icons/DualPageIcon.js +6 -6
  14. package/dist/components/icons/LoaderIcon.js +1 -1
  15. package/dist/components/icons/SinglePageIcon.js +6 -6
  16. package/dist/components/layout/Container.js +1 -1
  17. package/dist/components/layout/LayoutContainer.js +87 -7
  18. package/dist/components/layout/LayoutWrapper.js +2 -1
  19. package/dist/components/layout/RPDefaultLayout.js +127 -3
  20. package/dist/components/layout/RPLayout.js +108 -20
  21. package/dist/components/layout/WrapperLayout.js +22 -9
  22. package/dist/components/layout/sidebar/RPSidebar.js +127 -2
  23. package/dist/components/layout/sidebar/RPSplitter.js +1 -1
  24. package/dist/components/layout/sidebar/Thumbnail.js +89 -8
  25. package/dist/components/layout/sidebar/Thumbnails.js +134 -2
  26. package/dist/components/layout/toolbar/DarkModeTool.js +22 -13
  27. package/dist/components/layout/toolbar/DocumentDialog.js +89 -8
  28. package/dist/components/layout/toolbar/DocumentProperties.js +18 -8
  29. package/dist/components/layout/toolbar/FileDownloadTool.js +127 -2
  30. package/dist/components/layout/toolbar/FileUploadTool.js +31 -10
  31. package/dist/components/layout/toolbar/FullScreenTool.js +39 -27
  32. package/dist/components/layout/toolbar/MenuItem.js +12 -8
  33. package/dist/components/layout/toolbar/MenuSeparator.js +8 -4
  34. package/dist/components/layout/toolbar/MostPageTool.js +89 -9
  35. package/dist/components/layout/toolbar/OtherTool.js +119 -3
  36. package/dist/components/layout/toolbar/Paginate.js +123 -2
  37. package/dist/components/layout/toolbar/PrintTool.js +127 -2
  38. package/dist/components/layout/toolbar/PropertyItem.js +1 -1
  39. package/dist/components/layout/toolbar/RPMenuItem.js +20 -13
  40. package/dist/components/layout/toolbar/RPMoreOptions.js +169 -44
  41. package/dist/components/layout/toolbar/RPToolbar.js +133 -3
  42. package/dist/components/layout/toolbar/RPToolbarEnd.js +133 -2
  43. package/dist/components/layout/toolbar/RotateTool.js +39 -18
  44. package/dist/components/layout/toolbar/ScrollModeTool.js +27 -18
  45. package/dist/components/layout/toolbar/SearchCloseButton.js +11 -2
  46. package/dist/components/layout/toolbar/SearchResultNavigator.js +133 -3
  47. package/dist/components/layout/toolbar/SearchTool.js +87 -8
  48. package/dist/components/layout/toolbar/SelectionModeTool.js +19 -10
  49. package/dist/components/layout/toolbar/ThumbnailTool.js +139 -10
  50. package/dist/components/layout/toolbar/ToolbarCustom.js +104 -23
  51. package/dist/components/layout/toolbar/ToolbarDefault.js +113 -31
  52. package/dist/components/layout/toolbar/ToolbarLayout.js +145 -6
  53. package/dist/components/layout/toolbar/ViewModeTool.js +28 -19
  54. package/dist/components/layout/toolbar/ZoomTool.js +138 -128
  55. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +137 -7
  56. package/dist/components/layout/toolbar/tools/DualPageTool.js +144 -0
  57. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +140 -9
  58. package/dist/components/layout/toolbar/tools/FileUploadTool.js +27 -8
  59. package/dist/components/layout/toolbar/tools/FullScreenTool.js +23 -13
  60. package/dist/components/layout/toolbar/tools/InputPageTool.js +157 -26
  61. package/dist/components/layout/toolbar/tools/NextPageTool.js +89 -9
  62. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +142 -11
  63. package/dist/components/layout/toolbar/tools/PrintTool.js +138 -7
  64. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +29 -8
  65. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +32 -11
  66. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +29 -0
  67. package/dist/components/layout/toolbar/tools/SinglePageTool.js +144 -0
  68. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +15 -6
  69. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +142 -11
  70. package/dist/components/layout/toolbar/tools/ZoomInTool.js +47 -20
  71. package/dist/components/layout/toolbar/tools/ZoomLevelDisplay.js +140 -0
  72. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +158 -29
  73. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +45 -18
  74. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +104 -19
  75. package/dist/components/layout/toolbar/tools/defaults/RPVerticalBar.js +144 -11
  76. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +15 -5
  77. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +141 -11
  78. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +90 -9
  79. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +21 -9
  80. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +90 -10
  81. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +137 -7
  82. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +33 -12
  83. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +23 -14
  84. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +22 -13
  85. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +27 -18
  86. package/dist/components/page/AnnotationLayer.js +87 -9
  87. package/dist/components/page/CanvasLayer.js +90 -8
  88. package/dist/components/page/CustomElement.js +49 -18
  89. package/dist/components/page/DualPage.js +136 -2
  90. package/dist/components/page/RPPage.js +88 -8
  91. package/dist/components/page/SinglePage.js +136 -2
  92. package/dist/components/page/TextHighlightLayer.js +88 -8
  93. package/dist/components/page/TextLayer.js +89 -9
  94. package/dist/components/ui/Button.js +9 -8
  95. package/dist/components/ui/Checkbox.js +6 -5
  96. package/dist/components/ui/DropDown.js +18 -14
  97. package/dist/components/ui/Input.js +10 -9
  98. package/dist/components/ui/LoadingIndicator.js +135 -2
  99. package/dist/components/ui/PasswordModal.js +18 -15
  100. package/dist/components/ui/RPTooltip.js +202 -415
  101. package/dist/contexts/DimensionPagesContext.js +35 -17
  102. package/dist/contexts/DropFileZoneContext.js +32 -22
  103. package/dist/contexts/ElementPageContext.js +114 -51
  104. package/dist/contexts/EventCallbackContext.js +30 -0
  105. package/dist/contexts/FileInputContext.js +32 -22
  106. package/dist/contexts/GlobalCurrentPage.js +13 -10
  107. package/dist/contexts/HighlightContext.js +24 -11
  108. package/dist/contexts/LicenseContext.js +1 -0
  109. package/dist/contexts/LoaderContext.js +10 -9
  110. package/dist/contexts/LocalizationContext.js +11 -10
  111. package/dist/contexts/PagesRotateContext.js +36 -18
  112. package/dist/contexts/PaginationContext.js +135 -4
  113. package/dist/contexts/PrintContext.js +138 -4
  114. package/dist/contexts/RPDocumentContext.js +46 -28
  115. package/dist/contexts/RenderQueueProvider.js +136 -4
  116. package/dist/contexts/RotationContext.js +25 -15
  117. package/dist/contexts/ScrollModeContext.js +7 -6
  118. package/dist/contexts/SearchContext.js +138 -4
  119. package/dist/contexts/SelectionModeContext.js +5 -4
  120. package/dist/contexts/ThumbnailsContext.js +138 -4
  121. package/dist/contexts/ViewModeContext.js +10 -9
  122. package/dist/contexts/ZoomContext.js +34 -24
  123. package/dist/index-808ea7bf.js +1685 -0
  124. package/dist/index-a48ec088.js +1672 -0
  125. package/dist/{index-35c7f4a2.js → index-c9a2990a.js} +3 -3
  126. package/dist/libInjectCss.js +9 -0
  127. package/dist/main.js +222 -84
  128. package/dist/types/assets/style.d.ts +1 -0
  129. package/dist/types/components/icons/DualPageIcon.d.ts +1 -1
  130. package/dist/types/components/icons/SinglePageIcon.d.ts +1 -1
  131. package/dist/types/components/layout/toolbar/tools/DualPageTool.d.ts +3 -0
  132. package/dist/types/components/layout/toolbar/tools/SelectionModeSwitcherTool.d.ts +3 -0
  133. package/dist/types/components/layout/toolbar/tools/SinglePageTool.d.ts +3 -0
  134. package/dist/types/components/layout/toolbar/tools/ZoomLevelDisplay.d.ts +7 -0
  135. package/dist/types/contexts/EventCallbackContext.d.ts +5 -0
  136. package/dist/types/contexts/RenderQueueProvider.d.ts +2 -2
  137. package/dist/types/libInjectCss.d.ts +1 -0
  138. package/dist/types/main.d.ts +5 -5
  139. package/dist/types/utils/annotations.d.ts +1 -2
  140. package/dist/types/utils/approximateFragtion.d.ts +9 -0
  141. package/dist/types/utils/getElementPositionInPage.d.ts +5 -0
  142. package/dist/types/utils/hooks/useCopyText.d.ts +1 -0
  143. package/dist/types/utils/hooks/usePrint.d.ts +3 -2
  144. package/dist/types/utils/hooks/useSearch.d.ts +1 -2
  145. package/dist/types/utils/injectPrintCSS.d.ts +1 -0
  146. package/dist/types/utils/link_service.d.ts +11 -1
  147. package/dist/types/utils/renderPage.d.ts +2 -2
  148. package/dist/types/utils/types.d.ts +38 -5
  149. package/dist/types/utils/zoom.d.ts +2 -0
  150. package/dist/utils/annotations.js +48 -58
  151. package/dist/utils/approximateFragtion.js +22 -0
  152. package/dist/utils/getElementPositionInPage.js +84 -0
  153. package/dist/utils/getWordPositionInPage.js +5 -5
  154. package/dist/utils/getZoomLevel.js +9 -8
  155. package/dist/utils/highlight.js +72 -72
  156. package/dist/utils/hooks/useCopyText.js +36 -0
  157. package/dist/utils/hooks/useDarkModeProps.js +3 -2
  158. package/dist/utils/hooks/useFileDownload.js +90 -8
  159. package/dist/utils/hooks/useHighlight.js +13 -12
  160. package/dist/utils/hooks/useLicense.js +1 -1
  161. package/dist/utils/hooks/useLoadPdf.js +44 -36
  162. package/dist/utils/hooks/useLoadWorker.js +8 -8
  163. package/dist/utils/hooks/usePageRotateContext.js +33 -17
  164. package/dist/utils/hooks/usePaginate.js +88 -8
  165. package/dist/utils/hooks/usePinch.js +62 -41
  166. package/dist/utils/hooks/usePresentPage.js +88 -8
  167. package/dist/utils/hooks/usePrint.js +90 -9
  168. package/dist/utils/hooks/useRotate.js +21 -7
  169. package/dist/utils/hooks/useScrollToPage.js +86 -8
  170. package/dist/utils/hooks/useSearch.js +86 -8
  171. package/dist/utils/hooks/useThumbnail.js +89 -8
  172. package/dist/utils/hooks/useVirtualReactWindow.js +88 -8
  173. package/dist/utils/hooks/useWatermark.js +18 -15
  174. package/dist/utils/injectPrintCSS.js +22 -0
  175. package/dist/utils/link_service.js +49 -9
  176. package/dist/utils/renderPage.js +13 -10
  177. package/dist/utils/zoom.js +6 -0
  178. package/package.json +5 -6
  179. package/dist/ToolbarLayout.module-c588d36b.js +0 -3411
  180. package/dist/ZoomTool.module-6c5eabbb.js +0 -12
  181. package/dist/assets/Button.css +0 -1
  182. package/dist/assets/Checkbox.css +0 -1
  183. package/dist/assets/Container.css +0 -1
  184. package/dist/assets/DropDown.css +0 -1
  185. package/dist/assets/Input.css +0 -1
  186. package/dist/assets/LayoutWrapper.css +0 -1
  187. package/dist/assets/LoaderIcon.css +0 -1
  188. package/dist/assets/MenuItem.css +0 -1
  189. package/dist/assets/MenuSeparator.css +0 -1
  190. package/dist/assets/PasswordModal.css +0 -1
  191. package/dist/assets/PropertyItem.css +0 -1
  192. package/dist/assets/RPDropFileZone.css +0 -1
  193. package/dist/assets/RPSplitter.css +0 -1
  194. package/dist/assets/RPTooltip.css +0 -1
  195. package/dist/assets/RotateTool.css +0 -1
  196. package/dist/assets/SearchCloseButton.css +0 -1
  197. package/dist/assets/ToolbarLayout.css +0 -1
  198. package/dist/assets/WrapperLayout.css +0 -1
  199. package/dist/assets/ZoomTool.css +0 -1
  200. package/dist/floating-ui.react-dom-6b2fe0df.js +0 -1474
  201. package/dist/index-f563c6f0.js +0 -1889
@@ -1,1492 +1,17 @@
1
- var St = (e, t, s) => {
2
- if (!t.has(e))
3
- throw TypeError("Cannot " + s);
4
- };
5
- var i = (e, t, s) => (St(e, t, "read from private field"), s ? s.call(e) : t.get(e)), c = (e, t, s) => {
6
- if (t.has(e))
7
- throw TypeError("Cannot add the same private member more than once");
8
- t instanceof WeakSet ? t.add(e) : t.set(e, s);
9
- }, o = (e, t, s, r) => (St(e, t, "write to private field"), r ? r.call(e, s) : t.set(e, s), s);
10
- var bt = (e, t, s, r) => ({
11
- set _(n) {
12
- o(e, t, n, s);
13
- },
14
- get _() {
15
- return i(e, t, r);
16
- }
17
- }), F = (e, t, s) => (St(e, t, "access private method"), s);
18
- import { jsx as dt } from "react/jsx-runtime";
19
- import { RPTheme as ee } from "./RPTheme.js";
20
- import { ConfigContextProvider as se } from "../contexts/ConfigContext.js";
21
- import { useLoadWorker as re } from "../utils/hooks/useLoadWorker.js";
22
- import * as Jt from "react";
23
- import { LicenseProvider as ie } from "../contexts/LicenseContext.js";
24
- var Ct = class {
25
- constructor() {
26
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
27
- }
28
- subscribe(e) {
29
- return this.listeners.add(e), this.onSubscribe(), () => {
30
- this.listeners.delete(e), this.onUnsubscribe();
31
- };
32
- }
33
- hasListeners() {
34
- return this.listeners.size > 0;
35
- }
36
- onSubscribe() {
37
- }
38
- onUnsubscribe() {
39
- }
40
- }, ne = {
41
- // We need the wrapper function syntax below instead of direct references to
42
- // global setTimeout etc.
43
- //
44
- // BAD: `setTimeout: setTimeout`
45
- // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
46
- //
47
- // If we use direct references here, then anything that wants to spy on or
48
- // replace the global setTimeout (like tests) won't work since we'll already
49
- // have a hard reference to the original implementation at the time when this
50
- // file was imported.
51
- setTimeout: (e, t) => setTimeout(e, t),
52
- clearTimeout: (e) => clearTimeout(e),
53
- setInterval: (e, t) => setInterval(e, t),
54
- clearInterval: (e) => clearInterval(e)
55
- }, x, W, Nt, ae = (Nt = class {
56
- constructor() {
57
- // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
58
- // type at app boot; and if we leave that type, then any new timer provider
59
- // would need to support ReturnType<typeof setTimeout>, which is infeasible.
60
- //
61
- // We settle for type safety for the TimeoutProvider type, and accept that
62
- // this class is unsafe internally to allow for extension.
63
- c(this, x, ne);
64
- c(this, W, !1);
65
- }
66
- setTimeoutProvider(e) {
67
- process.env.NODE_ENV !== "production" && i(this, W) && e !== i(this, x) && console.error(
68
- "[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",
69
- { previous: i(this, x), provider: e }
70
- ), o(this, x, e), process.env.NODE_ENV !== "production" && o(this, W, !1);
71
- }
72
- setTimeout(e, t) {
73
- return process.env.NODE_ENV !== "production" && o(this, W, !0), i(this, x).setTimeout(e, t);
74
- }
75
- clearTimeout(e) {
76
- i(this, x).clearTimeout(e);
77
- }
78
- setInterval(e, t) {
79
- return process.env.NODE_ENV !== "production" && o(this, W, !0), i(this, x).setInterval(e, t);
80
- }
81
- clearInterval(e) {
82
- i(this, x).clearInterval(e);
83
- }
84
- }, x = new WeakMap(), W = new WeakMap(), Nt), Et = new ae();
85
- function oe(e) {
86
- setTimeout(e, 0);
87
- }
88
- var Ft = typeof window > "u" || "Deno" in globalThis;
89
- function R() {
90
- }
91
- function ue(e, t) {
92
- return typeof e == "function" ? e(t) : e;
93
- }
94
- function he(e) {
95
- return typeof e == "number" && e >= 0 && e !== 1 / 0;
96
- }
97
- function ce(e, t) {
98
- return Math.max(e + (t || 0) - Date.now(), 0);
99
- }
100
- function qt(e, t) {
101
- return typeof e == "function" ? e(t) : e;
102
- }
103
- function le(e, t) {
104
- return typeof e == "function" ? e(t) : e;
105
- }
106
- function Tt(e, t) {
107
- const {
108
- type: s = "all",
109
- exact: r,
110
- fetchStatus: n,
111
- predicate: a,
112
- queryKey: l,
113
- stale: u
114
- } = e;
115
- if (l) {
116
- if (r) {
117
- if (t.queryHash !== Mt(l, t.options))
118
- return !1;
119
- } else if (!yt(t.queryKey, l))
120
- return !1;
121
- }
122
- if (s !== "all") {
123
- const f = t.isActive();
124
- if (s === "active" && !f || s === "inactive" && f)
125
- return !1;
126
- }
127
- return !(typeof u == "boolean" && t.isStale() !== u || n && n !== t.state.fetchStatus || a && !a(t));
128
- }
129
- function Rt(e, t) {
130
- const { exact: s, status: r, predicate: n, mutationKey: a } = e;
131
- if (a) {
132
- if (!t.options.mutationKey)
133
- return !1;
134
- if (s) {
135
- if (ft(t.options.mutationKey) !== ft(a))
136
- return !1;
137
- } else if (!yt(t.options.mutationKey, a))
138
- return !1;
139
- }
140
- return !(r && t.state.status !== r || n && !n(t));
141
- }
142
- function Mt(e, t) {
143
- return ((t == null ? void 0 : t.queryKeyHashFn) || ft)(e);
144
- }
145
- function ft(e) {
146
- return JSON.stringify(
147
- e,
148
- (t, s) => At(s) ? Object.keys(s).sort().reduce((r, n) => (r[n] = s[n], r), {}) : s
149
- );
150
- }
151
- function yt(e, t) {
152
- return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? Object.keys(t).every((s) => yt(e[s], t[s])) : !1;
153
- }
154
- var de = Object.prototype.hasOwnProperty;
155
- function Dt(e, t) {
156
- if (e === t)
157
- return e;
158
- const s = It(e) && It(t);
159
- if (!s && !(At(e) && At(t)))
160
- return t;
161
- const n = (s ? e : Object.keys(e)).length, a = s ? t : Object.keys(t), l = a.length, u = s ? new Array(l) : {};
162
- let f = 0;
163
- for (let O = 0; O < l; O++) {
164
- const v = s ? O : a[O], C = e[v], g = t[v];
165
- if (C === g) {
166
- u[v] = C, (s ? O < n : de.call(e, v)) && f++;
167
- continue;
168
- }
169
- if (C === null || g === null || typeof C != "object" || typeof g != "object") {
170
- u[v] = g;
171
- continue;
172
- }
173
- const D = Dt(C, g);
174
- u[v] = D, D === C && f++;
175
- }
176
- return n === l && f === n ? e : u;
177
- }
178
- function It(e) {
179
- return Array.isArray(e) && e.length === Object.keys(e).length;
180
- }
181
- function At(e) {
182
- if (!jt(e))
183
- return !1;
184
- const t = e.constructor;
185
- if (t === void 0)
186
- return !0;
187
- const s = t.prototype;
188
- return !(!jt(s) || !s.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(e) !== Object.prototype);
189
- }
190
- function jt(e) {
191
- return Object.prototype.toString.call(e) === "[object Object]";
192
- }
193
- function fe(e) {
194
- return new Promise((t) => {
195
- Et.setTimeout(t, e);
196
- });
197
- }
198
- function ye(e, t, s) {
199
- if (typeof s.structuralSharing == "function")
200
- return s.structuralSharing(e, t);
201
- if (s.structuralSharing !== !1) {
202
- if (process.env.NODE_ENV !== "production")
203
- try {
204
- return Dt(e, t);
205
- } catch (r) {
206
- throw console.error(
207
- `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${r}`
208
- ), r;
209
- }
210
- return Dt(e, t);
211
- }
212
- return t;
213
- }
214
- function pe(e, t, s = 0) {
215
- const r = [...e, t];
216
- return s && r.length > s ? r.slice(1) : r;
217
- }
218
- function me(e, t, s = 0) {
219
- const r = [t, ...e];
220
- return s && r.length > s ? r.slice(0, -1) : r;
221
- }
222
- var Pt = Symbol();
223
- function Wt(e, t) {
224
- return process.env.NODE_ENV !== "production" && e.queryFn === Pt && console.error(
225
- `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`
226
- ), !e.queryFn && (t != null && t.initialPromise) ? () => t.initialPromise : !e.queryFn || e.queryFn === Pt ? () => Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)) : e.queryFn;
227
- }
228
- var Z, G, rt, Ht, ve = (Ht = class extends Ct {
229
- constructor() {
230
- super();
231
- c(this, Z, void 0);
232
- c(this, G, void 0);
233
- c(this, rt, void 0);
234
- o(this, rt, (t) => {
235
- if (!Ft && window.addEventListener) {
236
- const s = () => t();
237
- return window.addEventListener("visibilitychange", s, !1), () => {
238
- window.removeEventListener("visibilitychange", s);
239
- };
240
- }
241
- });
242
- }
243
- onSubscribe() {
244
- i(this, G) || this.setEventListener(i(this, rt));
245
- }
246
- onUnsubscribe() {
247
- var t;
248
- this.hasListeners() || ((t = i(this, G)) == null || t.call(this), o(this, G, void 0));
249
- }
250
- setEventListener(t) {
251
- var s;
252
- o(this, rt, t), (s = i(this, G)) == null || s.call(this), o(this, G, t((r) => {
253
- typeof r == "boolean" ? this.setFocused(r) : this.onFocus();
254
- }));
255
- }
256
- setFocused(t) {
257
- i(this, Z) !== t && (o(this, Z, t), this.onFocus());
258
- }
259
- onFocus() {
260
- const t = this.isFocused();
261
- this.listeners.forEach((s) => {
262
- s(t);
263
- });
264
- }
265
- isFocused() {
266
- var t;
267
- return typeof i(this, Z) == "boolean" ? i(this, Z) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden";
268
- }
269
- }, Z = new WeakMap(), G = new WeakMap(), rt = new WeakMap(), Ht), Zt = new ve();
270
- function ge() {
271
- let e, t;
272
- const s = new Promise((n, a) => {
273
- e = n, t = a;
274
- });
275
- s.status = "pending", s.catch(() => {
276
- });
277
- function r(n) {
278
- Object.assign(s, n), delete s.resolve, delete s.reject;
279
- }
280
- return s.resolve = (n) => {
281
- r({
282
- status: "fulfilled",
283
- value: n
284
- }), e(n);
285
- }, s.reject = (n) => {
286
- r({
287
- status: "rejected",
288
- reason: n
289
- }), t(n);
290
- }, s;
291
- }
292
- var be = oe;
293
- function we() {
294
- let e = [], t = 0, s = (u) => {
295
- u();
296
- }, r = (u) => {
297
- u();
298
- }, n = be;
299
- const a = (u) => {
300
- t ? e.push(u) : n(() => {
301
- s(u);
302
- });
303
- }, l = () => {
304
- const u = e;
305
- e = [], u.length && n(() => {
306
- r(() => {
307
- u.forEach((f) => {
308
- s(f);
309
- });
310
- });
311
- });
312
- };
313
- return {
314
- batch: (u) => {
315
- let f;
316
- t++;
317
- try {
318
- f = u();
319
- } finally {
320
- t--, t || l();
321
- }
322
- return f;
323
- },
324
- /**
325
- * All calls to the wrapped function will be batched.
326
- */
327
- batchCalls: (u) => (...f) => {
328
- a(() => {
329
- u(...f);
330
- });
331
- },
332
- schedule: a,
333
- /**
334
- * Use this method to set a custom notify function.
335
- * This can be used to for example wrap notifications with `React.act` while running tests.
336
- */
337
- setNotifyFunction: (u) => {
338
- s = u;
339
- },
340
- /**
341
- * Use this method to set a custom function to batch notifications together into a single tick.
342
- * By default React Query will use the batch function provided by ReactDOM or React Native.
343
- */
344
- setBatchNotifyFunction: (u) => {
345
- r = u;
346
- },
347
- setScheduler: (u) => {
348
- n = u;
349
- }
350
- };
351
- }
352
- var q = we(), it, _, nt, Lt, Pe = (Lt = class extends Ct {
353
- constructor() {
354
- super();
355
- c(this, it, !0);
356
- c(this, _, void 0);
357
- c(this, nt, void 0);
358
- o(this, nt, (t) => {
359
- if (!Ft && window.addEventListener) {
360
- const s = () => t(!0), r = () => t(!1);
361
- return window.addEventListener("online", s, !1), window.addEventListener("offline", r, !1), () => {
362
- window.removeEventListener("online", s), window.removeEventListener("offline", r);
363
- };
364
- }
365
- });
366
- }
367
- onSubscribe() {
368
- i(this, _) || this.setEventListener(i(this, nt));
369
- }
370
- onUnsubscribe() {
371
- var t;
372
- this.hasListeners() || ((t = i(this, _)) == null || t.call(this), o(this, _, void 0));
373
- }
374
- setEventListener(t) {
375
- var s;
376
- o(this, nt, t), (s = i(this, _)) == null || s.call(this), o(this, _, t(this.setOnline.bind(this)));
377
- }
378
- setOnline(t) {
379
- i(this, it) !== t && (o(this, it, t), this.listeners.forEach((r) => {
380
- r(t);
381
- }));
382
- }
383
- isOnline() {
384
- return i(this, it);
385
- }
386
- }, it = new WeakMap(), _ = new WeakMap(), nt = new WeakMap(), Lt), Ot = new Pe();
387
- function Oe(e) {
388
- return Math.min(1e3 * 2 ** e, 3e4);
389
- }
390
- function Xt(e) {
391
- return (e ?? "online") === "online" ? Ot.isOnline() : !0;
392
- }
393
- var Qt = class extends Error {
394
- constructor(e) {
395
- super("CancelledError"), this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
396
- }
397
- };
398
- function Yt(e) {
399
- let t = !1, s = 0, r;
400
- const n = ge(), a = () => n.status !== "pending", l = (d) => {
401
- var b;
402
- if (!a()) {
403
- const m = new Qt(d);
404
- g(m), (b = e.onCancel) == null || b.call(e, m);
405
- }
406
- }, u = () => {
407
- t = !0;
408
- }, f = () => {
409
- t = !1;
410
- }, O = () => Zt.isFocused() && (e.networkMode === "always" || Ot.isOnline()) && e.canRun(), v = () => Xt(e.networkMode) && e.canRun(), C = (d) => {
411
- a() || (r == null || r(), n.resolve(d));
412
- }, g = (d) => {
413
- a() || (r == null || r(), n.reject(d));
414
- }, D = () => new Promise((d) => {
415
- var b;
416
- r = (m) => {
417
- (a() || O()) && d(m);
418
- }, (b = e.onPause) == null || b.call(e);
419
- }).then(() => {
420
- var d;
421
- r = void 0, a() || (d = e.onContinue) == null || d.call(e);
422
- }), Q = () => {
423
- if (a())
424
- return;
425
- let d;
426
- const b = s === 0 ? e.initialPromise : void 0;
427
- try {
428
- d = b ?? e.fn();
429
- } catch (m) {
430
- d = Promise.reject(m);
431
- }
432
- Promise.resolve(d).then(C).catch((m) => {
433
- var T;
434
- if (a())
435
- return;
436
- const A = e.retry ?? (Ft ? 0 : 3), p = e.retryDelay ?? Oe, h = typeof p == "function" ? p(s, m) : p, S = A === !0 || typeof A == "number" && s < A || typeof A == "function" && A(s, m);
437
- if (t || !S) {
438
- g(m);
439
- return;
440
- }
441
- s++, (T = e.onFail) == null || T.call(e, s, m), fe(h).then(() => O() ? void 0 : D()).then(() => {
442
- t ? g(m) : Q();
443
- });
444
- });
445
- };
446
- return {
447
- promise: n,
448
- status: () => n.status,
449
- cancel: l,
450
- continue: () => (r == null || r(), n),
451
- cancelRetry: u,
452
- continueRetry: f,
453
- canStart: v,
454
- start: () => (v() ? Q() : D().then(Q), n)
455
- };
456
- }
457
- var X, Gt, te = (Gt = class {
458
- constructor() {
459
- c(this, X, void 0);
460
- }
461
- destroy() {
462
- this.clearGcTimeout();
463
- }
464
- scheduleGc() {
465
- this.clearGcTimeout(), he(this.gcTime) && o(this, X, Et.setTimeout(() => {
466
- this.optionalRemove();
467
- }, this.gcTime));
468
- }
469
- updateGcTime(e) {
470
- this.gcTime = Math.max(
471
- this.gcTime || 0,
472
- e ?? (Ft ? 1 / 0 : 5 * 60 * 1e3)
473
- );
474
- }
475
- clearGcTimeout() {
476
- i(this, X) && (Et.clearTimeout(i(this, X)), o(this, X, void 0));
477
- }
478
- }, X = new WeakMap(), Gt), Y, at, M, tt, P, pt, et, I, N, _t, Ce = (_t = class extends te {
479
- constructor(t) {
480
- super();
481
- c(this, I);
482
- c(this, Y, void 0);
483
- c(this, at, void 0);
484
- c(this, M, void 0);
485
- c(this, tt, void 0);
486
- c(this, P, void 0);
487
- c(this, pt, void 0);
488
- c(this, et, void 0);
489
- o(this, et, !1), o(this, pt, t.defaultOptions), this.setOptions(t.options), this.observers = [], o(this, tt, t.client), o(this, M, i(this, tt).getQueryCache()), this.queryKey = t.queryKey, this.queryHash = t.queryHash, o(this, Y, kt(this.options)), this.state = t.state ?? i(this, Y), this.scheduleGc();
490
- }
491
- get meta() {
492
- return this.options.meta;
493
- }
494
- get promise() {
495
- var t;
496
- return (t = i(this, P)) == null ? void 0 : t.promise;
497
- }
498
- setOptions(t) {
499
- if (this.options = { ...i(this, pt), ...t }, this.updateGcTime(this.options.gcTime), this.state && this.state.data === void 0) {
500
- const s = kt(this.options);
501
- s.data !== void 0 && (this.setState(
502
- xt(s.data, s.dataUpdatedAt)
503
- ), o(this, Y, s));
504
- }
505
- }
506
- optionalRemove() {
507
- !this.observers.length && this.state.fetchStatus === "idle" && i(this, M).remove(this);
508
- }
509
- setData(t, s) {
510
- const r = ye(this.state.data, t, this.options);
511
- return F(this, I, N).call(this, {
512
- data: r,
513
- type: "success",
514
- dataUpdatedAt: s == null ? void 0 : s.updatedAt,
515
- manual: s == null ? void 0 : s.manual
516
- }), r;
517
- }
518
- setState(t, s) {
519
- F(this, I, N).call(this, { type: "setState", state: t, setStateOptions: s });
520
- }
521
- cancel(t) {
522
- var r, n;
523
- const s = (r = i(this, P)) == null ? void 0 : r.promise;
524
- return (n = i(this, P)) == null || n.cancel(t), s ? s.then(R).catch(R) : Promise.resolve();
525
- }
526
- destroy() {
527
- super.destroy(), this.cancel({ silent: !0 });
528
- }
529
- reset() {
530
- this.destroy(), this.setState(i(this, Y));
531
- }
532
- isActive() {
533
- return this.observers.some(
534
- (t) => le(t.options.enabled, this) !== !1
535
- );
536
- }
537
- isDisabled() {
538
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === Pt || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
539
- }
540
- isStatic() {
541
- return this.getObserversCount() > 0 ? this.observers.some(
542
- (t) => qt(t.options.staleTime, this) === "static"
543
- ) : !1;
544
- }
545
- isStale() {
546
- return this.getObserversCount() > 0 ? this.observers.some(
547
- (t) => t.getCurrentResult().isStale
548
- ) : this.state.data === void 0 || this.state.isInvalidated;
549
- }
550
- isStaleByTime(t = 0) {
551
- return this.state.data === void 0 ? !0 : t === "static" ? !1 : this.state.isInvalidated ? !0 : !ce(this.state.dataUpdatedAt, t);
552
- }
553
- onFocus() {
554
- var s;
555
- const t = this.observers.find((r) => r.shouldFetchOnWindowFocus());
556
- t == null || t.refetch({ cancelRefetch: !1 }), (s = i(this, P)) == null || s.continue();
557
- }
558
- onOnline() {
559
- var s;
560
- const t = this.observers.find((r) => r.shouldFetchOnReconnect());
561
- t == null || t.refetch({ cancelRefetch: !1 }), (s = i(this, P)) == null || s.continue();
562
- }
563
- addObserver(t) {
564
- this.observers.includes(t) || (this.observers.push(t), this.clearGcTimeout(), i(this, M).notify({ type: "observerAdded", query: this, observer: t }));
565
- }
566
- removeObserver(t) {
567
- this.observers.includes(t) && (this.observers = this.observers.filter((s) => s !== t), this.observers.length || (i(this, P) && (i(this, et) ? i(this, P).cancel({ revert: !0 }) : i(this, P).cancelRetry()), this.scheduleGc()), i(this, M).notify({ type: "observerRemoved", query: this, observer: t }));
568
- }
569
- getObserversCount() {
570
- return this.observers.length;
571
- }
572
- invalidate() {
573
- this.state.isInvalidated || F(this, I, N).call(this, { type: "invalidate" });
574
- }
575
- async fetch(t, s) {
576
- var f, O, v, C, g, D, Q, d, b, m, A, p;
577
- if (this.state.fetchStatus !== "idle" && // If the promise in the retyer is already rejected, we have to definitely
578
- // re-start the fetch; there is a chance that the query is still in a
579
- // pending state when that happens
580
- ((f = i(this, P)) == null ? void 0 : f.status()) !== "rejected") {
581
- if (this.state.data !== void 0 && (s != null && s.cancelRefetch))
582
- this.cancel({ silent: !0 });
583
- else if (i(this, P))
584
- return i(this, P).continueRetry(), i(this, P).promise;
585
- }
586
- if (t && this.setOptions(t), !this.options.queryFn) {
587
- const h = this.observers.find((S) => S.options.queryFn);
588
- h && this.setOptions(h.options);
589
- }
590
- process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
591
- "As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
592
- ));
593
- const r = new AbortController(), n = (h) => {
594
- Object.defineProperty(h, "signal", {
595
- enumerable: !0,
596
- get: () => (o(this, et, !0), r.signal)
597
- });
598
- }, a = () => {
599
- const h = Wt(this.options, s), T = (() => {
600
- const B = {
601
- client: i(this, tt),
602
- queryKey: this.queryKey,
603
- meta: this.meta
604
- };
605
- return n(B), B;
606
- })();
607
- return o(this, et, !1), this.options.persister ? this.options.persister(
608
- h,
609
- T,
610
- this
611
- ) : h(T);
612
- }, u = (() => {
613
- const h = {
614
- fetchOptions: s,
615
- options: this.options,
616
- queryKey: this.queryKey,
617
- client: i(this, tt),
618
- state: this.state,
619
- fetchFn: a
620
- };
621
- return n(h), h;
622
- })();
623
- (O = this.options.behavior) == null || O.onFetch(u, this), o(this, at, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((v = u.fetchOptions) == null ? void 0 : v.meta)) && F(this, I, N).call(this, { type: "fetch", meta: (C = u.fetchOptions) == null ? void 0 : C.meta }), o(this, P, Yt({
624
- initialPromise: s == null ? void 0 : s.initialPromise,
625
- fn: u.fetchFn,
626
- onCancel: (h) => {
627
- h instanceof Qt && h.revert && this.setState({
628
- ...i(this, at),
629
- fetchStatus: "idle"
630
- }), r.abort();
631
- },
632
- onFail: (h, S) => {
633
- F(this, I, N).call(this, { type: "failed", failureCount: h, error: S });
634
- },
635
- onPause: () => {
636
- F(this, I, N).call(this, { type: "pause" });
637
- },
638
- onContinue: () => {
639
- F(this, I, N).call(this, { type: "continue" });
640
- },
641
- retry: u.options.retry,
642
- retryDelay: u.options.retryDelay,
643
- networkMode: u.options.networkMode,
644
- canRun: () => !0
645
- }));
646
- try {
647
- const h = await i(this, P).start();
648
- if (h === void 0)
649
- throw process.env.NODE_ENV !== "production" && console.error(
650
- `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
651
- ), new Error(`${this.queryHash} data is undefined`);
652
- return this.setData(h), (D = (g = i(this, M).config).onSuccess) == null || D.call(g, h, this), (d = (Q = i(this, M).config).onSettled) == null || d.call(
653
- Q,
654
- h,
655
- this.state.error,
656
- this
657
- ), h;
658
- } catch (h) {
659
- if (h instanceof Qt) {
660
- if (h.silent)
661
- return i(this, P).promise;
662
- if (h.revert) {
663
- if (this.state.data === void 0)
664
- throw h;
665
- return this.state.data;
666
- }
667
- }
668
- throw F(this, I, N).call(this, {
669
- type: "error",
670
- error: h
671
- }), (m = (b = i(this, M).config).onError) == null || m.call(
672
- b,
673
- h,
674
- this
675
- ), (p = (A = i(this, M).config).onSettled) == null || p.call(
676
- A,
677
- this.state.data,
678
- h,
679
- this
680
- ), h;
681
- } finally {
682
- this.scheduleGc();
683
- }
684
- }
685
- }, Y = new WeakMap(), at = new WeakMap(), M = new WeakMap(), tt = new WeakMap(), P = new WeakMap(), pt = new WeakMap(), et = new WeakMap(), I = new WeakSet(), N = function(t) {
686
- const s = (r) => {
687
- switch (t.type) {
688
- case "failed":
689
- return {
690
- ...r,
691
- fetchFailureCount: t.failureCount,
692
- fetchFailureReason: t.error
693
- };
694
- case "pause":
695
- return {
696
- ...r,
697
- fetchStatus: "paused"
698
- };
699
- case "continue":
700
- return {
701
- ...r,
702
- fetchStatus: "fetching"
703
- };
704
- case "fetch":
705
- return {
706
- ...r,
707
- ...Fe(r.data, this.options),
708
- fetchMeta: t.meta ?? null
709
- };
710
- case "success":
711
- const n = {
712
- ...r,
713
- ...xt(t.data, t.dataUpdatedAt),
714
- dataUpdateCount: r.dataUpdateCount + 1,
715
- ...!t.manual && {
716
- fetchStatus: "idle",
717
- fetchFailureCount: 0,
718
- fetchFailureReason: null
719
- }
720
- };
721
- return o(this, at, t.manual ? n : void 0), n;
722
- case "error":
723
- const a = t.error;
724
- return {
725
- ...r,
726
- error: a,
727
- errorUpdateCount: r.errorUpdateCount + 1,
728
- errorUpdatedAt: Date.now(),
729
- fetchFailureCount: r.fetchFailureCount + 1,
730
- fetchFailureReason: a,
731
- fetchStatus: "idle",
732
- status: "error"
733
- };
734
- case "invalidate":
735
- return {
736
- ...r,
737
- isInvalidated: !0
738
- };
739
- case "setState":
740
- return {
741
- ...r,
742
- ...t.state
743
- };
744
- }
745
- };
746
- this.state = s(this.state), q.batch(() => {
747
- this.observers.forEach((r) => {
748
- r.onQueryUpdate();
749
- }), i(this, M).notify({ query: this, type: "updated", action: t });
750
- });
751
- }, _t);
752
- function Fe(e, t) {
753
- return {
754
- fetchFailureCount: 0,
755
- fetchFailureReason: null,
756
- fetchStatus: Xt(t.networkMode) ? "fetching" : "paused",
757
- ...e === void 0 && {
758
- error: null,
759
- status: "pending"
760
- }
761
- };
762
- }
763
- function xt(e, t) {
764
- return {
765
- data: e,
766
- dataUpdatedAt: t ?? Date.now(),
767
- error: null,
768
- isInvalidated: !1,
769
- status: "success"
770
- };
771
- }
772
- function kt(e) {
773
- const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, s = t !== void 0, r = s ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
774
- return {
775
- data: t,
776
- dataUpdateCount: 0,
777
- dataUpdatedAt: s ? r ?? Date.now() : 0,
778
- error: null,
779
- errorUpdateCount: 0,
780
- errorUpdatedAt: 0,
781
- fetchFailureCount: 0,
782
- fetchFailureReason: null,
783
- fetchMeta: null,
784
- isInvalidated: !1,
785
- status: s ? "success" : "pending",
786
- fetchStatus: "idle"
787
- };
788
- }
789
- function Kt(e) {
790
- return {
791
- onFetch: (t, s) => {
792
- var v, C, g, D, Q;
793
- const r = t.options, n = (g = (C = (v = t.fetchOptions) == null ? void 0 : v.meta) == null ? void 0 : C.fetchMore) == null ? void 0 : g.direction, a = ((D = t.state.data) == null ? void 0 : D.pages) || [], l = ((Q = t.state.data) == null ? void 0 : Q.pageParams) || [];
794
- let u = { pages: [], pageParams: [] }, f = 0;
795
- const O = async () => {
796
- let d = !1;
797
- const b = (p) => {
798
- Object.defineProperty(p, "signal", {
799
- enumerable: !0,
800
- get: () => (t.signal.aborted ? d = !0 : t.signal.addEventListener("abort", () => {
801
- d = !0;
802
- }), t.signal)
803
- });
804
- }, m = Wt(t.options, t.fetchOptions), A = async (p, h, S) => {
805
- if (d)
806
- return Promise.reject();
807
- if (h == null && p.pages.length)
808
- return Promise.resolve(p);
809
- const B = (() => {
810
- const J = {
811
- client: t.client,
812
- queryKey: t.queryKey,
813
- pageParam: h,
814
- direction: S ? "backward" : "forward",
815
- meta: t.options.meta
816
- };
817
- return b(J), J;
818
- })(), gt = await m(B), { maxPages: lt } = t.options, w = S ? me : pe;
819
- return {
820
- pages: w(p.pages, gt, lt),
821
- pageParams: w(p.pageParams, h, lt)
822
- };
823
- };
824
- if (n && a.length) {
825
- const p = n === "backward", h = p ? Se : Ut, S = {
826
- pages: a,
827
- pageParams: l
828
- }, T = h(r, S);
829
- u = await A(S, T, p);
830
- } else {
831
- const p = e ?? a.length;
832
- do {
833
- const h = f === 0 ? l[0] ?? r.initialPageParam : Ut(r, u);
834
- if (f > 0 && h == null)
835
- break;
836
- u = await A(u, h), f++;
837
- } while (f < p);
838
- }
839
- return u;
840
- };
841
- t.options.persister ? t.fetchFn = () => {
842
- var d, b;
843
- return (b = (d = t.options).persister) == null ? void 0 : b.call(
844
- d,
845
- O,
846
- {
847
- client: t.client,
848
- queryKey: t.queryKey,
849
- meta: t.options.meta,
850
- signal: t.signal
851
- },
852
- s
853
- );
854
- } : t.fetchFn = O;
855
- }
856
- };
857
- }
858
- function Ut(e, { pages: t, pageParams: s }) {
859
- const r = t.length - 1;
860
- return t.length > 0 ? e.getNextPageParam(
861
- t[r],
862
- t,
863
- s[r],
864
- s
865
- ) : void 0;
866
- }
867
- function Se(e, { pages: t, pageParams: s }) {
868
- var r;
869
- return t.length > 0 ? (r = e.getPreviousPageParam) == null ? void 0 : r.call(e, t[0], t, s[0], s) : void 0;
870
- }
871
- var mt, k, E, st, K, L, Vt, Ee = (Vt = class extends te {
872
- constructor(t) {
873
- super();
874
- c(this, K);
875
- c(this, mt, void 0);
876
- c(this, k, void 0);
877
- c(this, E, void 0);
878
- c(this, st, void 0);
879
- o(this, mt, t.client), this.mutationId = t.mutationId, o(this, E, t.mutationCache), o(this, k, []), this.state = t.state || qe(), this.setOptions(t.options), this.scheduleGc();
880
- }
881
- setOptions(t) {
882
- this.options = t, this.updateGcTime(this.options.gcTime);
883
- }
884
- get meta() {
885
- return this.options.meta;
886
- }
887
- addObserver(t) {
888
- i(this, k).includes(t) || (i(this, k).push(t), this.clearGcTimeout(), i(this, E).notify({
889
- type: "observerAdded",
890
- mutation: this,
891
- observer: t
892
- }));
893
- }
894
- removeObserver(t) {
895
- o(this, k, i(this, k).filter((s) => s !== t)), this.scheduleGc(), i(this, E).notify({
896
- type: "observerRemoved",
897
- mutation: this,
898
- observer: t
899
- });
900
- }
901
- optionalRemove() {
902
- i(this, k).length || (this.state.status === "pending" ? this.scheduleGc() : i(this, E).remove(this));
903
- }
904
- continue() {
905
- var t;
906
- return ((t = i(this, st)) == null ? void 0 : t.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
907
- this.execute(this.state.variables);
908
- }
909
- async execute(t) {
910
- var l, u, f, O, v, C, g, D, Q, d, b, m, A, p, h, S, T, B, gt, lt;
911
- const s = () => {
912
- F(this, K, L).call(this, { type: "continue" });
913
- }, r = {
914
- client: i(this, mt),
915
- meta: this.options.meta,
916
- mutationKey: this.options.mutationKey
917
- };
918
- o(this, st, Yt({
919
- fn: () => this.options.mutationFn ? this.options.mutationFn(t, r) : Promise.reject(new Error("No mutationFn found")),
920
- onFail: (w, J) => {
921
- F(this, K, L).call(this, { type: "failed", failureCount: w, error: J });
922
- },
923
- onPause: () => {
924
- F(this, K, L).call(this, { type: "pause" });
925
- },
926
- onContinue: s,
927
- retry: this.options.retry ?? 0,
928
- retryDelay: this.options.retryDelay,
929
- networkMode: this.options.networkMode,
930
- canRun: () => i(this, E).canRun(this)
931
- }));
932
- const n = this.state.status === "pending", a = !i(this, st).canStart();
933
- try {
934
- if (n)
935
- s();
936
- else {
937
- F(this, K, L).call(this, { type: "pending", variables: t, isPaused: a }), await ((u = (l = i(this, E).config).onMutate) == null ? void 0 : u.call(
938
- l,
939
- t,
940
- this,
941
- r
942
- ));
943
- const J = await ((O = (f = this.options).onMutate) == null ? void 0 : O.call(
944
- f,
945
- t,
946
- r
947
- ));
948
- J !== this.state.context && F(this, K, L).call(this, {
949
- type: "pending",
950
- context: J,
951
- variables: t,
952
- isPaused: a
953
- });
954
- }
955
- const w = await i(this, st).start();
956
- return await ((C = (v = i(this, E).config).onSuccess) == null ? void 0 : C.call(
957
- v,
958
- w,
959
- t,
960
- this.state.context,
961
- this,
962
- r
963
- )), await ((D = (g = this.options).onSuccess) == null ? void 0 : D.call(
964
- g,
965
- w,
966
- t,
967
- this.state.context,
968
- r
969
- )), await ((d = (Q = i(this, E).config).onSettled) == null ? void 0 : d.call(
970
- Q,
971
- w,
972
- null,
973
- this.state.variables,
974
- this.state.context,
975
- this,
976
- r
977
- )), await ((m = (b = this.options).onSettled) == null ? void 0 : m.call(
978
- b,
979
- w,
980
- null,
981
- t,
982
- this.state.context,
983
- r
984
- )), F(this, K, L).call(this, { type: "success", data: w }), w;
985
- } catch (w) {
986
- try {
987
- throw await ((p = (A = i(this, E).config).onError) == null ? void 0 : p.call(
988
- A,
989
- w,
990
- t,
991
- this.state.context,
992
- this,
993
- r
994
- )), await ((S = (h = this.options).onError) == null ? void 0 : S.call(
995
- h,
996
- w,
997
- t,
998
- this.state.context,
999
- r
1000
- )), await ((B = (T = i(this, E).config).onSettled) == null ? void 0 : B.call(
1001
- T,
1002
- void 0,
1003
- w,
1004
- this.state.variables,
1005
- this.state.context,
1006
- this,
1007
- r
1008
- )), await ((lt = (gt = this.options).onSettled) == null ? void 0 : lt.call(
1009
- gt,
1010
- void 0,
1011
- w,
1012
- t,
1013
- this.state.context,
1014
- r
1015
- )), w;
1016
- } finally {
1017
- F(this, K, L).call(this, { type: "error", error: w });
1018
- }
1019
- } finally {
1020
- i(this, E).runNext(this);
1021
- }
1022
- }
1023
- }, mt = new WeakMap(), k = new WeakMap(), E = new WeakMap(), st = new WeakMap(), K = new WeakSet(), L = function(t) {
1024
- const s = (r) => {
1025
- switch (t.type) {
1026
- case "failed":
1027
- return {
1028
- ...r,
1029
- failureCount: t.failureCount,
1030
- failureReason: t.error
1031
- };
1032
- case "pause":
1033
- return {
1034
- ...r,
1035
- isPaused: !0
1036
- };
1037
- case "continue":
1038
- return {
1039
- ...r,
1040
- isPaused: !1
1041
- };
1042
- case "pending":
1043
- return {
1044
- ...r,
1045
- context: t.context,
1046
- data: void 0,
1047
- failureCount: 0,
1048
- failureReason: null,
1049
- error: null,
1050
- isPaused: t.isPaused,
1051
- status: "pending",
1052
- variables: t.variables,
1053
- submittedAt: Date.now()
1054
- };
1055
- case "success":
1056
- return {
1057
- ...r,
1058
- data: t.data,
1059
- failureCount: 0,
1060
- failureReason: null,
1061
- error: null,
1062
- status: "success",
1063
- isPaused: !1
1064
- };
1065
- case "error":
1066
- return {
1067
- ...r,
1068
- data: void 0,
1069
- error: t.error,
1070
- failureCount: r.failureCount + 1,
1071
- failureReason: t.error,
1072
- isPaused: !1,
1073
- status: "error"
1074
- };
1075
- }
1076
- };
1077
- this.state = s(this.state), q.batch(() => {
1078
- i(this, k).forEach((r) => {
1079
- r.onMutationUpdate(t);
1080
- }), i(this, E).notify({
1081
- mutation: this,
1082
- type: "updated",
1083
- action: t
1084
- });
1085
- });
1086
- }, Vt);
1087
- function qe() {
1088
- return {
1089
- context: void 0,
1090
- data: void 0,
1091
- error: null,
1092
- failureCount: 0,
1093
- failureReason: null,
1094
- isPaused: !1,
1095
- status: "idle",
1096
- variables: void 0,
1097
- submittedAt: 0
1098
- };
1099
- }
1100
- var H, j, vt, $t, De = ($t = class extends Ct {
1101
- constructor(t = {}) {
1102
- super();
1103
- c(this, H, void 0);
1104
- c(this, j, void 0);
1105
- c(this, vt, void 0);
1106
- this.config = t, o(this, H, /* @__PURE__ */ new Set()), o(this, j, /* @__PURE__ */ new Map()), o(this, vt, 0);
1107
- }
1108
- build(t, s, r) {
1109
- const n = new Ee({
1110
- client: t,
1111
- mutationCache: this,
1112
- mutationId: ++bt(this, vt)._,
1113
- options: t.defaultMutationOptions(s),
1114
- state: r
1115
- });
1116
- return this.add(n), n;
1117
- }
1118
- add(t) {
1119
- i(this, H).add(t);
1120
- const s = wt(t);
1121
- if (typeof s == "string") {
1122
- const r = i(this, j).get(s);
1123
- r ? r.push(t) : i(this, j).set(s, [t]);
1124
- }
1125
- this.notify({ type: "added", mutation: t });
1126
- }
1127
- remove(t) {
1128
- if (i(this, H).delete(t)) {
1129
- const s = wt(t);
1130
- if (typeof s == "string") {
1131
- const r = i(this, j).get(s);
1132
- if (r)
1133
- if (r.length > 1) {
1134
- const n = r.indexOf(t);
1135
- n !== -1 && r.splice(n, 1);
1136
- } else
1137
- r[0] === t && i(this, j).delete(s);
1138
- }
1139
- }
1140
- this.notify({ type: "removed", mutation: t });
1141
- }
1142
- canRun(t) {
1143
- const s = wt(t);
1144
- if (typeof s == "string") {
1145
- const r = i(this, j).get(s), n = r == null ? void 0 : r.find(
1146
- (a) => a.state.status === "pending"
1147
- );
1148
- return !n || n === t;
1149
- } else
1150
- return !0;
1151
- }
1152
- runNext(t) {
1153
- var r;
1154
- const s = wt(t);
1155
- if (typeof s == "string") {
1156
- const n = (r = i(this, j).get(s)) == null ? void 0 : r.find((a) => a !== t && a.state.isPaused);
1157
- return (n == null ? void 0 : n.continue()) ?? Promise.resolve();
1158
- } else
1159
- return Promise.resolve();
1160
- }
1161
- clear() {
1162
- q.batch(() => {
1163
- i(this, H).forEach((t) => {
1164
- this.notify({ type: "removed", mutation: t });
1165
- }), i(this, H).clear(), i(this, j).clear();
1166
- });
1167
- }
1168
- getAll() {
1169
- return Array.from(i(this, H));
1170
- }
1171
- find(t) {
1172
- const s = { exact: !0, ...t };
1173
- return this.getAll().find(
1174
- (r) => Rt(s, r)
1175
- );
1176
- }
1177
- findAll(t = {}) {
1178
- return this.getAll().filter((s) => Rt(t, s));
1179
- }
1180
- notify(t) {
1181
- q.batch(() => {
1182
- this.listeners.forEach((s) => {
1183
- s(t);
1184
- });
1185
- });
1186
- }
1187
- resumePausedMutations() {
1188
- const t = this.getAll().filter((s) => s.state.isPaused);
1189
- return q.batch(
1190
- () => Promise.all(
1191
- t.map((s) => s.continue().catch(R))
1192
- )
1193
- );
1194
- }
1195
- }, H = new WeakMap(), j = new WeakMap(), vt = new WeakMap(), $t);
1196
- function wt(e) {
1197
- var t;
1198
- return (t = e.options.scope) == null ? void 0 : t.id;
1199
- }
1200
- var U, zt, Ae = (zt = class extends Ct {
1201
- constructor(t = {}) {
1202
- super();
1203
- c(this, U, void 0);
1204
- this.config = t, o(this, U, /* @__PURE__ */ new Map());
1205
- }
1206
- build(t, s, r) {
1207
- const n = s.queryKey, a = s.queryHash ?? Mt(n, s);
1208
- let l = this.get(a);
1209
- return l || (l = new Ce({
1210
- client: t,
1211
- queryKey: n,
1212
- queryHash: a,
1213
- options: t.defaultQueryOptions(s),
1214
- state: r,
1215
- defaultOptions: t.getQueryDefaults(n)
1216
- }), this.add(l)), l;
1217
- }
1218
- add(t) {
1219
- i(this, U).has(t.queryHash) || (i(this, U).set(t.queryHash, t), this.notify({
1220
- type: "added",
1221
- query: t
1222
- }));
1223
- }
1224
- remove(t) {
1225
- const s = i(this, U).get(t.queryHash);
1226
- s && (t.destroy(), s === t && i(this, U).delete(t.queryHash), this.notify({ type: "removed", query: t }));
1227
- }
1228
- clear() {
1229
- q.batch(() => {
1230
- this.getAll().forEach((t) => {
1231
- this.remove(t);
1232
- });
1233
- });
1234
- }
1235
- get(t) {
1236
- return i(this, U).get(t);
1237
- }
1238
- getAll() {
1239
- return [...i(this, U).values()];
1240
- }
1241
- find(t) {
1242
- const s = { exact: !0, ...t };
1243
- return this.getAll().find(
1244
- (r) => Tt(s, r)
1245
- );
1246
- }
1247
- findAll(t = {}) {
1248
- const s = this.getAll();
1249
- return Object.keys(t).length > 0 ? s.filter((r) => Tt(t, r)) : s;
1250
- }
1251
- notify(t) {
1252
- q.batch(() => {
1253
- this.listeners.forEach((s) => {
1254
- s(t);
1255
- });
1256
- });
1257
- }
1258
- onFocus() {
1259
- q.batch(() => {
1260
- this.getAll().forEach((t) => {
1261
- t.onFocus();
1262
- });
1263
- });
1264
- }
1265
- onOnline() {
1266
- q.batch(() => {
1267
- this.getAll().forEach((t) => {
1268
- t.onOnline();
1269
- });
1270
- });
1271
- }
1272
- }, U = new WeakMap(), zt), y, V, $, ot, ut, z, ht, ct, Bt, Qe = (Bt = class {
1273
- constructor(e = {}) {
1274
- c(this, y, void 0);
1275
- c(this, V, void 0);
1276
- c(this, $, void 0);
1277
- c(this, ot, void 0);
1278
- c(this, ut, void 0);
1279
- c(this, z, void 0);
1280
- c(this, ht, void 0);
1281
- c(this, ct, void 0);
1282
- o(this, y, e.queryCache || new Ae()), o(this, V, e.mutationCache || new De()), o(this, $, e.defaultOptions || {}), o(this, ot, /* @__PURE__ */ new Map()), o(this, ut, /* @__PURE__ */ new Map()), o(this, z, 0);
1283
- }
1284
- mount() {
1285
- bt(this, z)._++, i(this, z) === 1 && (o(this, ht, Zt.subscribe(async (e) => {
1286
- e && (await this.resumePausedMutations(), i(this, y).onFocus());
1287
- })), o(this, ct, Ot.subscribe(async (e) => {
1288
- e && (await this.resumePausedMutations(), i(this, y).onOnline());
1289
- })));
1290
- }
1291
- unmount() {
1292
- var e, t;
1293
- bt(this, z)._--, i(this, z) === 0 && ((e = i(this, ht)) == null || e.call(this), o(this, ht, void 0), (t = i(this, ct)) == null || t.call(this), o(this, ct, void 0));
1294
- }
1295
- isFetching(e) {
1296
- return i(this, y).findAll({ ...e, fetchStatus: "fetching" }).length;
1297
- }
1298
- isMutating(e) {
1299
- return i(this, V).findAll({ ...e, status: "pending" }).length;
1300
- }
1301
- /**
1302
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
1303
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1304
- *
1305
- * Hint: Do not use this function inside a component, because it won't receive updates.
1306
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1307
- */
1308
- getQueryData(e) {
1309
- var s;
1310
- const t = this.defaultQueryOptions({ queryKey: e });
1311
- return (s = i(this, y).get(t.queryHash)) == null ? void 0 : s.state.data;
1312
- }
1313
- ensureQueryData(e) {
1314
- const t = this.defaultQueryOptions(e), s = i(this, y).build(this, t), r = s.state.data;
1315
- return r === void 0 ? this.fetchQuery(e) : (e.revalidateIfStale && s.isStaleByTime(qt(t.staleTime, s)) && this.prefetchQuery(t), Promise.resolve(r));
1316
- }
1317
- getQueriesData(e) {
1318
- return i(this, y).findAll(e).map(({ queryKey: t, state: s }) => {
1319
- const r = s.data;
1320
- return [t, r];
1321
- });
1322
- }
1323
- setQueryData(e, t, s) {
1324
- const r = this.defaultQueryOptions({ queryKey: e }), n = i(this, y).get(
1325
- r.queryHash
1326
- ), a = n == null ? void 0 : n.state.data, l = ue(t, a);
1327
- if (l !== void 0)
1328
- return i(this, y).build(this, r).setData(l, { ...s, manual: !0 });
1329
- }
1330
- setQueriesData(e, t, s) {
1331
- return q.batch(
1332
- () => i(this, y).findAll(e).map(({ queryKey: r }) => [
1333
- r,
1334
- this.setQueryData(r, t, s)
1335
- ])
1336
- );
1337
- }
1338
- getQueryState(e) {
1339
- var s;
1340
- const t = this.defaultQueryOptions({ queryKey: e });
1341
- return (s = i(this, y).get(
1342
- t.queryHash
1343
- )) == null ? void 0 : s.state;
1344
- }
1345
- removeQueries(e) {
1346
- const t = i(this, y);
1347
- q.batch(() => {
1348
- t.findAll(e).forEach((s) => {
1349
- t.remove(s);
1350
- });
1351
- });
1352
- }
1353
- resetQueries(e, t) {
1354
- const s = i(this, y);
1355
- return q.batch(() => (s.findAll(e).forEach((r) => {
1356
- r.reset();
1357
- }), this.refetchQueries(
1358
- {
1359
- type: "active",
1360
- ...e
1361
- },
1362
- t
1363
- )));
1364
- }
1365
- cancelQueries(e, t = {}) {
1366
- const s = { revert: !0, ...t }, r = q.batch(
1367
- () => i(this, y).findAll(e).map((n) => n.cancel(s))
1368
- );
1369
- return Promise.all(r).then(R).catch(R);
1370
- }
1371
- invalidateQueries(e, t = {}) {
1372
- return q.batch(() => (i(this, y).findAll(e).forEach((s) => {
1373
- s.invalidate();
1374
- }), (e == null ? void 0 : e.refetchType) === "none" ? Promise.resolve() : this.refetchQueries(
1375
- {
1376
- ...e,
1377
- type: (e == null ? void 0 : e.refetchType) ?? (e == null ? void 0 : e.type) ?? "active"
1378
- },
1379
- t
1380
- )));
1381
- }
1382
- refetchQueries(e, t = {}) {
1383
- const s = {
1384
- ...t,
1385
- cancelRefetch: t.cancelRefetch ?? !0
1386
- }, r = q.batch(
1387
- () => i(this, y).findAll(e).filter((n) => !n.isDisabled() && !n.isStatic()).map((n) => {
1388
- let a = n.fetch(void 0, s);
1389
- return s.throwOnError || (a = a.catch(R)), n.state.fetchStatus === "paused" ? Promise.resolve() : a;
1390
- })
1391
- );
1392
- return Promise.all(r).then(R);
1393
- }
1394
- fetchQuery(e) {
1395
- const t = this.defaultQueryOptions(e);
1396
- t.retry === void 0 && (t.retry = !1);
1397
- const s = i(this, y).build(this, t);
1398
- return s.isStaleByTime(
1399
- qt(t.staleTime, s)
1400
- ) ? s.fetch(t) : Promise.resolve(s.state.data);
1401
- }
1402
- prefetchQuery(e) {
1403
- return this.fetchQuery(e).then(R).catch(R);
1404
- }
1405
- fetchInfiniteQuery(e) {
1406
- return e.behavior = Kt(e.pages), this.fetchQuery(e);
1407
- }
1408
- prefetchInfiniteQuery(e) {
1409
- return this.fetchInfiniteQuery(e).then(R).catch(R);
1410
- }
1411
- ensureInfiniteQueryData(e) {
1412
- return e.behavior = Kt(e.pages), this.ensureQueryData(e);
1413
- }
1414
- resumePausedMutations() {
1415
- return Ot.isOnline() ? i(this, V).resumePausedMutations() : Promise.resolve();
1416
- }
1417
- getQueryCache() {
1418
- return i(this, y);
1419
- }
1420
- getMutationCache() {
1421
- return i(this, V);
1422
- }
1423
- getDefaultOptions() {
1424
- return i(this, $);
1425
- }
1426
- setDefaultOptions(e) {
1427
- o(this, $, e);
1428
- }
1429
- setQueryDefaults(e, t) {
1430
- i(this, ot).set(ft(e), {
1431
- queryKey: e,
1432
- defaultOptions: t
1433
- });
1434
- }
1435
- getQueryDefaults(e) {
1436
- const t = [...i(this, ot).values()], s = {};
1437
- return t.forEach((r) => {
1438
- yt(e, r.queryKey) && Object.assign(s, r.defaultOptions);
1439
- }), s;
1440
- }
1441
- setMutationDefaults(e, t) {
1442
- i(this, ut).set(ft(e), {
1443
- mutationKey: e,
1444
- defaultOptions: t
1445
- });
1446
- }
1447
- getMutationDefaults(e) {
1448
- const t = [...i(this, ut).values()], s = {};
1449
- return t.forEach((r) => {
1450
- yt(e, r.mutationKey) && Object.assign(s, r.defaultOptions);
1451
- }), s;
1452
- }
1453
- defaultQueryOptions(e) {
1454
- if (e._defaulted)
1455
- return e;
1456
- const t = {
1457
- ...i(this, $).queries,
1458
- ...this.getQueryDefaults(e.queryKey),
1459
- ...e,
1460
- _defaulted: !0
1461
- };
1462
- return t.queryHash || (t.queryHash = Mt(
1463
- t.queryKey,
1464
- t
1465
- )), t.refetchOnReconnect === void 0 && (t.refetchOnReconnect = t.networkMode !== "always"), t.throwOnError === void 0 && (t.throwOnError = !!t.suspense), !t.networkMode && t.persister && (t.networkMode = "offlineFirst"), t.queryFn === Pt && (t.enabled = !1), t;
1466
- }
1467
- defaultMutationOptions(e) {
1468
- return e != null && e._defaulted ? e : {
1469
- ...i(this, $).mutations,
1470
- ...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey),
1471
- ...e,
1472
- _defaulted: !0
1473
- };
1474
- }
1475
- clear() {
1476
- i(this, y).clear(), i(this, V).clear();
1477
- }
1478
- }, y = new WeakMap(), V = new WeakMap(), $ = new WeakMap(), ot = new WeakMap(), ut = new WeakMap(), z = new WeakMap(), ht = new WeakMap(), ct = new WeakMap(), Bt), Me = Jt.createContext(
1479
- void 0
1480
- ), Te = ({
1481
- client: e,
1482
- children: t
1483
- }) => (Jt.useEffect(() => (e.mount(), () => {
1484
- e.unmount();
1485
- }), [e]), /* @__PURE__ */ dt(Me.Provider, { value: e, children: t }));
1486
- const Re = new Qe(), Ne = (e) => {
1487
- const { children: t, customVariables: s, customDarkVariables: r, workerUrl: n, licenseKey: a, ...l } = e, { workerUrlAdded: u } = re(n);
1488
- return /* @__PURE__ */ dt(Te, { client: Re, children: /* @__PURE__ */ dt(ie, { licenseKey: a, children: /* @__PURE__ */ dt(se, { workerUrlAdded: u, ...l, children: /* @__PURE__ */ dt(ee, { customDarkVariables: r, customVariables: s, children: t }) }) }) });
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { RPTheme as s } from "./RPTheme.js";
3
+ import { ConfigContextProvider as d } from "../contexts/ConfigContext.js";
4
+ import { useLoadWorker as f } from "../utils/hooks/useLoadWorker.js";
5
+ import { LicenseProvider as l } from "../contexts/LicenseContext.js";
6
+ import "../contexts/ThemeContext.js";
7
+ import "react";
8
+ import "pdfjs-dist";
9
+ import "../utils/hooks/useLicense.js";
10
+ import "../utils/appConsole.js";
11
+ const w = (o) => {
12
+ const { children: e, customVariables: i, customDarkVariables: t, workerUrl: m, licenseKey: n, ...c } = o, { workerUrlAdded: p } = f(m);
13
+ return /* @__PURE__ */ r(l, { licenseKey: n, children: /* @__PURE__ */ r(d, { workerUrlAdded: p, ...c, children: /* @__PURE__ */ r(s, { customDarkVariables: t, customVariables: i, children: e }) }) });
1489
14
  };
1490
15
  export {
1491
- Ne as RPConfig
16
+ w as RPConfig
1492
17
  };