@devvit/ui-renderer 0.10.23-next-2024-06-24-057510192.0 → 0.10.23-next-2024-06-25-a383d60f1.0
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.
- package/client/devvit-surface.d.ts.map +1 -1
- package/client/devvit-surface.js +15 -4
- package/client/formbuilder/devvit-form-dialog.d.ts.map +1 -1
- package/client/formbuilder/devvit-form-dialog.js +6 -1
- package/client/webDispatcher.d.ts +2 -1
- package/client/webDispatcher.d.ts.map +1 -1
- package/client/webDispatcher.js +19 -12
- package/devvit-surface-meta.min.json +14 -9
- package/devvit-surface.min.js +77 -77
- package/devvit-surface.min.js.map +3 -3
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devvit-surface.d.ts","sourceRoot":"","sources":["../../library/src/client/devvit-surface.ts"],"names":[],"mappings":"AAAA,OAAO,kEAAkE,CAAC;AAE1E,OAAO,KAAK,EAEV,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,OAAO,EAEP,UAAU,EACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAyC,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,kDAAkD,CAAC;AAGxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAKvC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"devvit-surface.d.ts","sourceRoot":"","sources":["../../library/src/client/devvit-surface.ts"],"names":[],"mappings":"AAAA,OAAO,kEAAkE,CAAC;AAE1E,OAAO,KAAK,EAEV,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,OAAO,EAEP,UAAU,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ivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
18
18
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
19
19
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
20
20
|
};
|
|
21
|
-
var _DevvitSurface_rootHeight, _DevvitSurface_resizeObserver, _DevvitSurface_intersectionObserver, _DevvitSurface_dispatcher, _DevvitSurface_newRenderContext, _DevvitSurface_onRender;
|
|
21
|
+
var _DevvitSurface_instances, _DevvitSurface_rootHeight, _DevvitSurface_resizeObserver, _DevvitSurface_intersectionObserver, _DevvitSurface_dispatcher, _DevvitSurface_newRenderContext, _DevvitSurface_onRender, _DevvitSurface_bubble, _DevvitSurface_onUserActionEffect;
|
|
22
22
|
import '@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js';
|
|
23
23
|
import { BlockConfig_Root, BlockStackDirection, UIDimensions } from '@devvit/protos';
|
|
24
24
|
import { throttle } from '@devvit/shared-types/throttle.js';
|
|
@@ -28,6 +28,7 @@ import { customElement, property, state } from 'lit/decorators.js';
|
|
|
28
28
|
import { DEFAULT_ROOT_HEIGHT } from '../blocks/templates/renderBlock.js';
|
|
29
29
|
import { styles } from '../styles.js';
|
|
30
30
|
import { WebDispatcher } from './webDispatcher.js';
|
|
31
|
+
import { customEvent } from '@reddit/faceplate/lib/custom-event.js';
|
|
31
32
|
import '../blocks/components/devvit-blocks-renderer.js';
|
|
32
33
|
import '../blocks/components/devvit-blocks-webview.js';
|
|
33
34
|
import './devvit-animation-player.js';
|
|
@@ -47,6 +48,7 @@ let DevvitSurface = class DevvitSurface extends LitElement {
|
|
|
47
48
|
}
|
|
48
49
|
constructor() {
|
|
49
50
|
super();
|
|
51
|
+
_DevvitSurface_instances.add(this);
|
|
50
52
|
/** Enables debug logging for the local runtime */
|
|
51
53
|
this.runtimeDebugLogging = false;
|
|
52
54
|
/** Enable the use of experimental blocks that are not production ready */
|
|
@@ -60,9 +62,6 @@ let DevvitSurface = class DevvitSurface extends LitElement {
|
|
|
60
62
|
_DevvitSurface_intersectionObserver.set(this, void 0);
|
|
61
63
|
/** The orchestrates events for blocks */
|
|
62
64
|
_DevvitSurface_dispatcher.set(this, void 0);
|
|
63
|
-
// #bubble<T>(type: string, detail: T): void {
|
|
64
|
-
// this.dispatchEvent(customEvent(type, detail));
|
|
65
|
-
// }
|
|
66
65
|
_DevvitSurface_newRenderContext.set(this, () => ({
|
|
67
66
|
experimental: this.useExperimentalBlocks,
|
|
68
67
|
webViewEnabled: this.allowWebView,
|
|
@@ -98,6 +97,12 @@ let DevvitSurface = class DevvitSurface extends LitElement {
|
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
99
|
});
|
|
100
|
+
_DevvitSurface_onUserActionEffect.set(this, (fx) => {
|
|
101
|
+
__classPrivateFieldGet(this, _DevvitSurface_instances, "m", _DevvitSurface_bubble).call(this, 'devvit-ui-effect', {
|
|
102
|
+
effect: fx,
|
|
103
|
+
onEvent: (ev) => __classPrivateFieldGet(this, _DevvitSurface_dispatcher, "f")?.submit([ev]),
|
|
104
|
+
});
|
|
105
|
+
});
|
|
101
106
|
if (devvit?.debug.surface)
|
|
102
107
|
console.debug(`[surface] Using devvit-surface and KMP!`);
|
|
103
108
|
}
|
|
@@ -113,6 +118,7 @@ let DevvitSurface = class DevvitSurface extends LitElement {
|
|
|
113
118
|
}, {
|
|
114
119
|
useSpeculativeExecution: this.useSpeculativeExecution,
|
|
115
120
|
}), "f");
|
|
121
|
+
__classPrivateFieldGet(this, _DevvitSurface_dispatcher, "f").onUserAction = __classPrivateFieldGet(this, _DevvitSurface_onUserActionEffect, "f");
|
|
116
122
|
__classPrivateFieldGet(this, _DevvitSurface_dispatcher, "f").subscribe((params) => {
|
|
117
123
|
__classPrivateFieldGet(this, _DevvitSurface_onRender, "f").call(this, {
|
|
118
124
|
request: params.request,
|
|
@@ -225,6 +231,11 @@ _DevvitSurface_intersectionObserver = new WeakMap();
|
|
|
225
231
|
_DevvitSurface_dispatcher = new WeakMap();
|
|
226
232
|
_DevvitSurface_newRenderContext = new WeakMap();
|
|
227
233
|
_DevvitSurface_onRender = new WeakMap();
|
|
234
|
+
_DevvitSurface_onUserActionEffect = new WeakMap();
|
|
235
|
+
_DevvitSurface_instances = new WeakSet();
|
|
236
|
+
_DevvitSurface_bubble = function _DevvitSurface_bubble(type, detail) {
|
|
237
|
+
this.dispatchEvent(customEvent(type, detail));
|
|
238
|
+
};
|
|
228
239
|
__decorate([
|
|
229
240
|
property({ attribute: false }),
|
|
230
241
|
__metadata("design:type", Object)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devvit-form-dialog.d.ts","sourceRoot":"","sources":["../../../library/src/client/formbuilder/devvit-form-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AACtF,OAAO,kEAAkE,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,kCAAkC,CAAC;AAI7F,OAAO,KAAK,EAAE,IAAI,EAAa,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAiC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAKxE,OAAO,kDAAkD,CAAC;AAC1D,OAAO,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"devvit-form-dialog.d.ts","sourceRoot":"","sources":["../../../library/src/client/formbuilder/devvit-form-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;AAIvC,OAAO,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AACtF,OAAO,kEAAkE,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,kCAAkC,CAAC;AAI7F,OAAO,KAAK,EAAE,IAAI,EAAa,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAiC,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAKxE,OAAO,kDAAkD,CAAC;AAC1D,OAAO,gDAAgD,CAAC;AAKxD,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,0BAA0B,CAAC,GAAG;IAC/E,MAAM,EAAE;QACN,IAAI,CAAC,EAAE,OAAO,CAAC;KAChB,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,qBACa,gBAAiB,SAAQ,UAAU;;IAE9C,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IAGvB,OAAO,CAAC,EAAE,eAAe,CAAC;IAG1B,KAAK,CAAC,EAAE,aAAa,CAAC;IAKtB,WAAoB,MAAM,8BAEzB;IAED,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAkHpD,MAAM;CAuDhB"}
|
|
@@ -33,6 +33,7 @@ import { styles } from '../../styles.js';
|
|
|
33
33
|
import { renderFormFields } from './fields/index.js';
|
|
34
34
|
import '@reddit/faceplate-ui/components/faceplate-dialog';
|
|
35
35
|
import '@reddit/faceplate/components/faceplate-form.js';
|
|
36
|
+
import { formKeyToHookId } from '@devvit/shared-types/useForm.js';
|
|
36
37
|
/**
|
|
37
38
|
* Devvit form dialog.
|
|
38
39
|
*
|
|
@@ -97,9 +98,13 @@ let DevvitFormDialog = class DevvitFormDialog extends LitElement {
|
|
|
97
98
|
if (!invalidFields || invalidFields.length > 0) {
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
101
|
+
if (!this.form?.id) {
|
|
102
|
+
throw new Error(`Cannot submit form due to missing form id. If you are using 'useForm' please make sure that it is not called conditionally inside of your component.`);
|
|
103
|
+
}
|
|
100
104
|
__classPrivateFieldGet(this, _DevvitFormDialog_onEvent, "f").call(this, UIEvent.fromPartial({
|
|
105
|
+
hook: formKeyToHookId(this.form.id),
|
|
101
106
|
formSubmitted: {
|
|
102
|
-
formId: this.form
|
|
107
|
+
formId: this.form.id,
|
|
103
108
|
results: __classPrivateFieldGet(this, _DevvitFormDialog_collectValues, "f").call(this),
|
|
104
109
|
},
|
|
105
110
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Dispatcher, SubscribeCallbackParams } from '@devvit/multiplatform/ui-shared-shared.js';
|
|
2
2
|
import { JsDispatcherImpl } from '@devvit/multiplatform/ui-shared-shared.js';
|
|
3
|
-
import type { UIRequest } from '@devvit/protos';
|
|
3
|
+
import type { Effect, UIRequest } from '@devvit/protos';
|
|
4
4
|
import { type Metadata, type UIEnvironment, type UIEvent } from '@devvit/protos';
|
|
5
5
|
import type { ReplayUIResponse, UIProps, UIState } from './runtimes.js';
|
|
6
6
|
import { LocalRuntime, RemoteRuntime } from './runtimes.js';
|
|
@@ -15,6 +15,7 @@ export declare class WebDispatcher {
|
|
|
15
15
|
* render events.
|
|
16
16
|
*/
|
|
17
17
|
hasRendered: boolean;
|
|
18
|
+
onUserAction?: ((fx: Effect) => void) | undefined;
|
|
18
19
|
get state(): KMPDispatcher['state'];
|
|
19
20
|
constructor(initialState: Record<string, unknown>, env: UIEnvironment, config: {
|
|
20
21
|
useSpeculativeExecution: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webDispatcher.d.ts","sourceRoot":"","sources":["../../library/src/client/webDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAGV,uBAAuB,EAExB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,2CAA2C,CAAC;AAC9F,OAAO,KAAK,EAAE,SAA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I,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI;IAIlF,WAAW,IAAI,IAAI;IAInB,IAAI,IAAI,IAAI;IAIZ,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAUjC,aAAa,IAAI,IAAI;IAKrB,MAAM,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAIhC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI9B,UAAU,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI;IAItD,SAAS,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzE,eAAe,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI;CAGxE"}
|
package/client/webDispatcher.js
CHANGED
|
@@ -18,16 +18,16 @@ import { Timers } from './timers.js';
|
|
|
18
18
|
class Logger {
|
|
19
19
|
debug(messages) {
|
|
20
20
|
if (devvit?.debug.runtime)
|
|
21
|
-
console.debug(...messages);
|
|
21
|
+
console.debug('[kmp-dispatcher]', ...messages);
|
|
22
22
|
}
|
|
23
23
|
error(messages) {
|
|
24
|
-
console.error(...messages);
|
|
24
|
+
console.error('[kmp-dispatcher]', ...messages);
|
|
25
25
|
}
|
|
26
26
|
info(messages) {
|
|
27
|
-
console.info(...messages);
|
|
27
|
+
console.info('[kmp-dispatcher]', ...messages);
|
|
28
28
|
}
|
|
29
29
|
warn(messages) {
|
|
30
|
-
console.warn(...messages);
|
|
30
|
+
console.warn('[kmp-dispatcher]', ...messages);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
@@ -58,6 +58,8 @@ const makeMillisecondsFromDuration = ({ nanos, seconds, }) => {
|
|
|
58
58
|
const nanosInMillis = nanos / 1000000;
|
|
59
59
|
return Math.floor(secondsInMillis + nanosInMillis);
|
|
60
60
|
};
|
|
61
|
+
// Effects that can only be fired as the result of a user action
|
|
62
|
+
const userActionEffects = ['showToast', 'showForm', 'navigateToUrl'];
|
|
61
63
|
export class WebDispatcher {
|
|
62
64
|
get state() {
|
|
63
65
|
return __classPrivateFieldGet(this, _WebDispatcher_dispatcher, "f").state;
|
|
@@ -118,16 +120,21 @@ export class WebDispatcher {
|
|
|
118
120
|
console.debug(`[runtime] dispatcher got a new event from subscribe`, args[0]);
|
|
119
121
|
const [{ response }] = args;
|
|
120
122
|
response.effects.forEach((effect) => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
if (userActionEffects.some((type) => effect[type])) {
|
|
124
|
+
this.onUserAction?.(effect);
|
|
123
125
|
return;
|
|
124
|
-
const entries = Object.entries(effect.interval.intervals);
|
|
125
|
-
if (entries.length === 0) {
|
|
126
|
-
__classPrivateFieldGet(this, _WebDispatcher_timers, "f").clear();
|
|
127
126
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
if (effect.interval) {
|
|
128
|
+
const entries = Object.entries(effect.interval.intervals);
|
|
129
|
+
if (entries.length === 0) {
|
|
130
|
+
__classPrivateFieldGet(this, _WebDispatcher_timers, "f").clear();
|
|
131
|
+
}
|
|
132
|
+
__classPrivateFieldGet(this, _WebDispatcher_timers, "f").apply(entries.map(([id, meta]) =>
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
+
new TimerDefinition(id, makeMillisecondsFromDuration(meta.duration))));
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
console.warn(`Received an effect that is not implemented! Please add an effect handler to the web dispatcher. Effect: ${JSON.stringify(effect, null, 2)}`);
|
|
131
138
|
});
|
|
132
139
|
cb(...args);
|
|
133
140
|
}), "f");
|
|
@@ -10194,7 +10194,7 @@
|
|
|
10194
10194
|
"format": "esm"
|
|
10195
10195
|
},
|
|
10196
10196
|
"library/src/client/webDispatcher.ts": {
|
|
10197
|
-
"bytes":
|
|
10197
|
+
"bytes": 7938,
|
|
10198
10198
|
"imports": [
|
|
10199
10199
|
{
|
|
10200
10200
|
"path": "../../node_modules/@devvit/multiplatform/kotlin/ui-shared-shared.js",
|
|
@@ -10835,7 +10835,7 @@
|
|
|
10835
10835
|
"format": "esm"
|
|
10836
10836
|
},
|
|
10837
10837
|
"library/src/client/devvit-surface.ts": {
|
|
10838
|
-
"bytes":
|
|
10838
|
+
"bytes": 11323,
|
|
10839
10839
|
"imports": [
|
|
10840
10840
|
{
|
|
10841
10841
|
"path": "../../node_modules/@reddit/faceplate-ui/templateRenderingStrategy/clientStrategy.js",
|
|
@@ -10887,6 +10887,11 @@
|
|
|
10887
10887
|
"kind": "import-statement",
|
|
10888
10888
|
"original": "./webDispatcher.js"
|
|
10889
10889
|
},
|
|
10890
|
+
{
|
|
10891
|
+
"path": "../../node_modules/@reddit/faceplate/lib/custom-event.js",
|
|
10892
|
+
"kind": "import-statement",
|
|
10893
|
+
"original": "@reddit/faceplate/lib/custom-event.js"
|
|
10894
|
+
},
|
|
10890
10895
|
{
|
|
10891
10896
|
"path": "library/src/blocks/components/devvit-blocks-renderer.ts",
|
|
10892
10897
|
"kind": "import-statement",
|
|
@@ -10916,7 +10921,7 @@
|
|
|
10916
10921
|
"imports": [],
|
|
10917
10922
|
"exports": [],
|
|
10918
10923
|
"inputs": {},
|
|
10919
|
-
"bytes":
|
|
10924
|
+
"bytes": 12137137
|
|
10920
10925
|
},
|
|
10921
10926
|
"dist/devvit-surface.min.js": {
|
|
10922
10927
|
"imports": [
|
|
@@ -11564,7 +11569,7 @@
|
|
|
11564
11569
|
"bytesInOutput": 38
|
|
11565
11570
|
},
|
|
11566
11571
|
"../shared-types/dist/tid.js": {
|
|
11567
|
-
"bytesInOutput":
|
|
11572
|
+
"bytesInOutput": 284
|
|
11568
11573
|
},
|
|
11569
11574
|
"../../node_modules/@lit/reactive-element/decorators/custom-element.js": {
|
|
11570
11575
|
"bytesInOutput": 186
|
|
@@ -11573,7 +11578,7 @@
|
|
|
11573
11578
|
"bytesInOutput": 0
|
|
11574
11579
|
},
|
|
11575
11580
|
"../../node_modules/@lit/reactive-element/decorators/property.js": {
|
|
11576
|
-
"bytesInOutput":
|
|
11581
|
+
"bytesInOutput": 425
|
|
11577
11582
|
},
|
|
11578
11583
|
"../../node_modules/@lit/reactive-element/decorators/state.js": {
|
|
11579
11584
|
"bytesInOutput": 42
|
|
@@ -11600,7 +11605,7 @@
|
|
|
11600
11605
|
"bytesInOutput": 0
|
|
11601
11606
|
},
|
|
11602
11607
|
"../../node_modules/@reddit/faceplate-ui/templates/_buttonBaseInternalsDoNotUse.js": {
|
|
11603
|
-
"bytesInOutput":
|
|
11608
|
+
"bytesInOutput": 2672
|
|
11604
11609
|
},
|
|
11605
11610
|
"../../node_modules/@reddit/faceplate-ui/templates/button.js": {
|
|
11606
11611
|
"bytesInOutput": 108
|
|
@@ -11732,7 +11737,7 @@
|
|
|
11732
11737
|
"bytesInOutput": 1178
|
|
11733
11738
|
},
|
|
11734
11739
|
"library/src/client/webDispatcher.ts": {
|
|
11735
|
-
"bytesInOutput":
|
|
11740
|
+
"bytesInOutput": 2511
|
|
11736
11741
|
},
|
|
11737
11742
|
"../../node_modules/@lit/localize/internal/str-tag.js": {
|
|
11738
11743
|
"bytesInOutput": 131
|
|
@@ -11792,10 +11797,10 @@
|
|
|
11792
11797
|
"bytesInOutput": 1710
|
|
11793
11798
|
},
|
|
11794
11799
|
"library/src/client/devvit-surface.ts": {
|
|
11795
|
-
"bytesInOutput":
|
|
11800
|
+
"bytesInOutput": 4372
|
|
11796
11801
|
}
|
|
11797
11802
|
},
|
|
11798
|
-
"bytes":
|
|
11803
|
+
"bytes": 4388512
|
|
11799
11804
|
}
|
|
11800
11805
|
}
|
|
11801
11806
|
}
|