• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16var __decorate = (this && this.__decorate) || function (a12, b12, c12, d12) {
17    var e12 = arguments.length,
18        f12 = e12 < 3 ? b12 : d12 === null ? d12 = Object.getOwnPropertyDescriptor(b12, c12) : d12, g12;
19    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
20        f12 = Reflect.decorate(a12, b12, c12, d12);
21    } else {
22        for (var h12 = a12.length - 1; h12 >= 0; h12--) {
23            if (g12 = a12[h12]) {
24                f12 = (e12 < 3 ? g12(f12) : e12 > 3 ? g12(b12, c12, f12) : g12(b12, c12)) || f12;
25            }
26        }
27    }
28    return e12 > 3 && f12 && Object.defineProperty(b12, c12, f12), f12;
29};
30
31if (!("finalizeConstruction" in ViewPU.prototype)) {
32    Reflect.set(ViewPU.prototype, "finalizeConstruction", () => {
33    });
34}
35const webView = requireNapi('web.webview');
36const router = requireNapi('router');
37const deviceInfo = requireNapi('deviceInfo');
38const geoLocationManager = requireNapi('geoLocationManager');
39const bundleManager = requireNapi('bundle.bundleManager');
40const abilityAccessCtrl = requireNapi('abilityAccessCtrl');
41const connection = requireNapi('net.connection');
42const request = requireNapi('request');
43const fs = requireNapi('file.fs');
44const util = requireNapi('util');
45const photoAccessHelper = requireNapi('file.photoAccessHelper');
46const filePreview = globalThis.requireNapi('filemanagement.filepreview', false, '', 'hms');
47const fileUri = requireNapi('file.fileuri');
48const picker = requireNapi('multimedia.cameraPicker');
49const filePicker = requireNapi('file.picker');
50const call = requireNapi('telephony.call');
51const atomicServiceWebNapi = requireInternal('atomicservice.AtomicServiceWeb');
52
53let atomicBasicEngine = null;
54
55function loadAtomicBasicEngine() {
56    try {
57        import('@hms:atomicservicedistribution.atomicbasicengine').then((z10) => {
58            console.log('AtomicServiceWeb loadAtomicBasicEngine success');
59            atomicBasicEngine = z10;
60        }).catch((y10) => {
61            console.error('AtomicServiceWeb loadAtomicBasicEngine error, message: ' + y10.message);
62        });
63    } catch (x10) {
64        console.error('AtomicServiceWeb loadAtomicBasicEngine error, message: ' + x10.message);
65    }
66}
67
68loadAtomicBasicEngine();
69
70class AsError {
71    constructor(m11, n11) {
72        this.code = m11;
73        this.message = n11;
74    }
75}
76
77class JsApiConfig {
78    constructor(i11, j11, k11, l11) {
79        this.apiName = i11;
80        this.minVersion = j11;
81        this.maxVersion = k11;
82        this.requiredFieldNames = l11;
83    }
84}
85
86const LOG_ENABLE = true;
87const LOG_PREFIX = '[AtomicServiceWebLog]';
88const UPLOAD_IMAGE_CACHE_DIR = '/cache/';
89const JAVA_SCRIPT_PROXY_OBJECT_NAME = 'atomicServiceProxy';
90const JAVA_SCRIPT_PROXY_API_NAME_LIST = ['invokeJsApi'];
91const ATOMIC_SERVICE_JS_API_MAP = new Map();
92const registerJsApi = (u11, v11, w11, x11, y11) => {
93    ATOMIC_SERVICE_JS_API_MAP.set(u11, new JsApiConfig(v11, w11, x11, y11));
94};
95const MAX_VERSION = '99.99.99';
96const ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION = '1.0.0';
97const PERMISSION_APPROXIMATELY_LOCATION = 'ohos.permission.APPROXIMATELY_LOCATION';
98const TEL_PROTOCOL = 'tel:';
99const MAILTO_PROTOCOL = 'mailto:';
100const WANT_ACTION_SEND_TO_DATA = 'ohos.want.action.sendToData';
101const RESOURCE_RAWFILE = 'resource://rawfile';
102const TYPE_AS_WEB = 'ASWeb';
103const WEB_PERMISSIONS = {
104    'TYPE_VIDEO_CAPTURE': 'ohos.permission.CAMERA',
105    'TYPE_AUDIO_CAPTURE': 'ohos.permission.MICROPHONE'
106};
107const SYSTEM_INTERNAL_ERROR = new AsError(500, 'System internal error.');
108const JS_API_INVALID_INVOKE_ERROR = new AsError(200001, 'Invalid invoke.');
109const PARAM_REQUIRED_ERROR_CODE = 200002;
110const PARAM_NUMBER_POSITIVE_ERROR_CODE = 200003;
111const ROUTER_PARAM_MODE_INVALID_ERROR = new AsError(200004, 'Param mode is invalid.');
112const BACK_URL_NOT_EXIST_OR_OPENED_ERROR = new AsError(200005, 'Url is not exist or opened, can not be back.');
113const NAV_PATH_STACK_NOT_EXIST_ERROR_CODE = 200006;
114const POP_PATH_NAME_NOT_EXIST_ERROR = new AsError(200007, 'Name is not exist or opened, can not be pop.');
115const POP_PATH_PARAM_INDEX_INVALID_ERROR = new AsError(200008, 'Param index is invalid.');
116const POP_PATH_INDEX_OUT_OF_RANGE_ERROR = new AsError(200009, 'The Index is out of range.');
117const UPLOAD_IMAGE_FILES_REQUIRED_ERROR = new AsError(200010, 'Param files is required.');
118const UPLOAD_IMAGE_FILE_NOT_EXIST_ERROR_CODE = 200011;
119const UPLOAD_IMAGE_FILES_URI_REQUIRED_ERROR = new AsError(200012, 'Param uri of files is required.');
120const UPLOAD_FILE_ERROR = new AsError(200013, 'Upload file error.');
121const IMAGE_CAN_NOT_PREVIEW_ERROR = new AsError(200014, 'The filePath can not preview.');
122const NETWORK_NO_ACTIVE_ERROR = new AsError(200015, 'The network is not active.');
123const PERMISSION_LOCATION_USER_REFUSED_ERROR = 200016;
124
125registerJsApi('router.pushUrl', 'pushUrl', '1.0.0', MAX_VERSION, ['url']);
126registerJsApi('router.replaceUrl', 'replaceUrl', '1.0.0', MAX_VERSION, ['url']);
127registerJsApi('router.back', 'backUrl', '1.0.0', MAX_VERSION, []);
128registerJsApi('router.clear', 'clearUrl', '1.0.0', MAX_VERSION, []);
129registerJsApi('navPathStack.pushPath', 'pushPath', '1.0.0', MAX_VERSION, ['name']);
130registerJsApi('navPathStack.replacePath', 'replacePath', '1.0.0', MAX_VERSION, ['name']);
131registerJsApi('navPathStack.pop', 'popPath', '1.0.0', MAX_VERSION, []);
132registerJsApi('navPathStack.clear', 'clearPath', '1.0.0', MAX_VERSION, []);
133registerJsApi('asWeb.postMessage', 'postMessage', '1.0.0', MAX_VERSION, ['data']);
134registerJsApi('asWeb.getEnv', 'getEnv', '1.0.0', MAX_VERSION, []);
135registerJsApi('asWeb.checkJsApi', 'checkJsApi', '1.0.0', MAX_VERSION, ['jsApiList']);
136registerJsApi('cameraPicker.pick', 'pickCamera', '1.0.0', MAX_VERSION, ['mediaTypes', 'cameraPosition']);
137registerJsApi('photoViewPicker.select', 'selectPhoto', '1.0.0', MAX_VERSION, []);
138registerJsApi('filePreview.openPreview', 'openPreview', '1.0.0', MAX_VERSION, ['uri']);
139registerJsApi('request.uploadFile', 'uploadFile', '1.0.0', MAX_VERSION, ['url', 'files']);
140registerJsApi('request.downloadFile', 'downloadFile', '1.0.0', MAX_VERSION, ['url']);
141registerJsApi('connection.getNetworkType', 'getNetworkType', '1.0.0', MAX_VERSION, []);
142registerJsApi('location.getLocation', 'getLocation', '1.0.0', MAX_VERSION, []);
143
144export class AtomicServiceWeb extends ViewPU {
145    constructor(s10, t10, u10, v10 = -1, w10 = undefined, x10) {
146        super(s10, u10, v10, x10);
147        if (typeof w10 === "function") {
148            this.paramsGenerator_ = w10;
149        }
150        this.src = undefined;
151        this.navPathStack = undefined;
152        this.__mixedMode = new SynchedPropertySimpleOneWayPU(t10.mixedMode, this, "mixedMode");
153        this.__darkMode = new SynchedPropertySimpleOneWayPU(t10.darkMode, this, "darkMode");
154        this.__forceDarkAccess = new SynchedPropertySimpleOneWayPU(t10.forceDarkAccess, this, "forceDarkAccess");
155        this.__nestedScroll = new SynchedPropertyObjectOneWayPU(t10.nestedScroll, this, 'nestedScroll');
156        this.__controller = new SynchedPropertyNesedObjectPU(t10.controller, this, "controller");
157        this.onMessage = () => {
158        };
159        this.onErrorReceive = () => {
160        };
161        this.onHttpErrorReceive = () => {
162        };
163        this.onPageBegin = () => {
164        };
165        this.onPageEnd = () => {
166        };
167        this.onProgressChange = () => {
168        };
169        this.onControllerAttached = undefined;
170        this.onLoadIntercept = undefined;
171        this.context = this.getUIContext().getHostContext();
172        this.webViewController = new webView.WebviewController();
173        this.schemeHandler = new webView.WebSchemeHandler();
174        this.atomicService = undefined;
175        this.atomicServiceProxy = undefined;
176        this.setInitiallyProvidedValue(t10);
177        this.finalizeConstruction();
178    }
179
180    setInitiallyProvidedValue(r10) {
181        if (r10.src !== undefined) {
182            this.src = r10.src;
183        }
184        if (r10.navPathStack !== undefined) {
185            this.navPathStack = r10.navPathStack;
186        }
187        this.__controller.set(r10.controller);
188        if (r10.onMessage !== undefined) {
189            this.onMessage = r10.onMessage;
190        }
191        if (r10.onErrorReceive !== undefined) {
192            this.onErrorReceive = r10.onErrorReceive;
193        }
194        if (r10.onHttpErrorReceive !== undefined) {
195            this.onHttpErrorReceive = r10.onHttpErrorReceive;
196        }
197        if (r10.onPageBegin !== undefined) {
198            this.onPageBegin = r10.onPageBegin;
199        }
200        if (r10.onPageEnd !== undefined) {
201            this.onPageEnd = r10.onPageEnd;
202        }
203        if (r10.onProgressChange !== undefined) {
204            this.onProgressChange = r10.onProgressChange;
205        }
206        if (r10.onControllerAttached !== undefined) {
207            this.onControllerAttached = r10.onControllerAttached;
208        }
209        if (r10.onLoadIntercept !== undefined) {
210            this.onLoadIntercept = r10.onLoadIntercept;
211        }
212        if (r10.context !== undefined) {
213            this.context = r10.context;
214        }
215        if (r10.webViewController !== undefined) {
216            this.webViewController = r10.webViewController;
217        }
218        if (r10.schemeHandler !== undefined) {
219            this.schemeHandler = r10.schemeHandler;
220        }
221        if (r10.atomicService !== undefined) {
222            this.atomicService = r10.atomicService;
223        }
224        if (r10.atomicServiceProxy !== undefined) {
225            this.atomicServiceProxy = r10.atomicServiceProxy;
226        }
227    }
228
229    updateStateVars(q10) {
230        this.__mixedMode.reset(q10.mixedMode);
231        this.__darkMode.reset(q10.darkMode);
232        this.__forceDarkAccess.reset(q10.forceDarkAccess);
233        this.__nestedScroll.reset(q10.nestedScroll);
234        this.__controller.set(q10.controller);
235    }
236
237    purgeVariableDependenciesOnElmtId(p10) {
238        this.__mixedMode.purgeDependencyOnElmtId(p10);
239        this.__darkMode.purgeDependencyOnElmtId(p10);
240        this.__forceDarkAccess.purgeDependencyOnElmtId(p10);
241        this.__nestedScroll.purgeDependencyOnElmtId(p10);
242        this.__controller.purgeDependencyOnElmtId(p10);
243    }
244
245    aboutToBeDeleted() {
246        this.__mixedMode.aboutToBeDeleted();
247        this.__darkMode.aboutToBeDeleted();
248        this.__forceDarkAccess.aboutToBeDeleted();
249        this.__nestedScroll.aboutToBeDeleted();
250        this.__controller.aboutToBeDeleted();
251        SubscriberManager.Get().delete(this.id__());
252        this.aboutToBeDeletedInternal();
253    }
254
255    get mixedMode() {
256        return this.__mixedMode.get();
257    }
258
259    set mixedMode(t11) {
260        this.__mixedMode.set(t11);
261    }
262
263    get darkMode() {
264        return this.__darkMode.get();
265    }
266
267    set darkMode(s11) {
268        this.__darkMode.set(s11);
269    }
270
271    get forceDarkAccess() {
272        return this.__forceDarkAccess.get();
273    }
274
275    set forceDarkAccess(r11) {
276        this.__forceDarkAccess.set(r11);
277    }
278
279    get nestedScroll() {
280        return this.__nestedScroll.get();
281    }
282
283    set nestedScroll(d9) {
284        this.__nestedScroll.set(d9);
285    }
286
287    get controller() {
288        return this.__controller.get();
289    }
290
291    aboutToAppear() {
292        if (!this.atomicService) {
293            this.atomicService = new AtomicServiceApi(this.context, this.navPathStack, this.onMessage);
294            this.atomicServiceProxy = new AtomicServiceProxy(this.atomicService);
295        }
296        try {
297            let h2 = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
298            if (h2?.appInfo?.appProvisionType === 'debug') {
299                console.log(`AtomicServiceWeb setWebDebuggingAccess`);
300                webView.WebviewController.setWebDebuggingAccess(true);
301            }
302        } catch (d2) {
303            console.error(`AtomicServiceWeb set Web Debug Mode failed, code is ${d2.code}, message is ${d2.message}`);
304        }
305        this.initDomainCheckLog();
306    }
307
308    aboutToDisappear() {
309        this.atomicService?.notifyMessage();
310    }
311
312    initialRender() {
313        this.observeComponentCreation2((g10, h10) => {
314            Web.create({ src: this.src, controller: this.webViewController });
315            Web.zoomAccess(false);
316            Web.allowWindowOpenMethod(false);
317            Web.domStorageAccess(true);
318            Web.layoutMode(WebLayoutMode.NONE);
319            Web.mixedMode(this.mixedMode);
320            Web.darkMode(this.darkMode);
321            Web.forceDarkAccess(this.forceDarkAccess);
322            Web.nestedScroll(ObservedObject.GetRawObject(this.nestedScroll));
323            Web.onErrorReceive((q11) => this.onCommonCallBack('onErrorReceive', q11, this.onErrorReceive));
324            Web.onHttpErrorReceive((p11) => this.onCommonCallBack('onHttpErrorReceive', p11, this.onHttpErrorReceive));
325            Web.onPageBegin((l10) => this.onCommonCallBack('onPageBegin', l10, this.onPageBegin));
326            Web.onPageEnd((b11) => this.onCommonCallBack('onPageEnd', b11, this.onPageEnd));
327            Web.onProgressChange((a11) => this.onCommonCallBack('onProgressChange', a11, this.onProgressChange));
328            Web.onControllerAttached(() => {
329                this.registerJavaScriptProxy();
330                this.schemeHandler.onRequestStart((z10) => {
331                    return !this.interceptUrl(z10.getRequestUrl(), z10.isMainFrame(), z10.getRequestResourceType());
332                });
333                this.webViewController.setWebSchemeHandler('http', this.schemeHandler);
334                this.webViewController.setWebSchemeHandler('https', this.schemeHandler);
335                this.initAtomicServiceWebController();
336                if (this.onControllerAttached) {
337                    try {
338                        this.onControllerAttached();
339                    } catch (y10) {
340                        console.error(`AtomicServiceWeb onControllerAttached failed, code is ${y10.code}, message is ${y10.message}`);
341                    }
342                }
343            });
344            Web.onOverrideUrlLoading((i10) => {
345                return !this.interceptOverrideUrlLoading(i10.getRequestUrl());
346            });
347            Web.onLoadIntercept(m7 => {
348                let n7 = !this.checkUrl(m7.data.getRequestUrl());
349                if (!n7 && this.onLoadIntercept) {
350                    try {
351                        return this.onLoadIntercept(m7);
352                    } catch (u7) {
353                        console.error(`AtomicServiceWeb onLoadIntercept failed, code is ${u7.code}, message is ${u7.message}`);
354                        return true;
355                    }
356                }
357                return n7;
358            });
359            Web.onPermissionRequest((c10) => { this.handleOnPermissionRequest(c10); });
360        }, Web);
361    }
362
363    onCommonCallBack(q5, e6, j6) {
364        try {
365            j6 && j6(e6);
366        } catch (k7) {
367            console.error(`AtomicServiceWeb ${q5} failed, code is ${k7.code}, message is ${k7.message}`);
368        }
369    }
370
371    registerJavaScriptProxy() {
372        try {
373            this.webViewController.registerJavaScriptProxy(this.atomicServiceProxy, JAVA_SCRIPT_PROXY_OBJECT_NAME,
374                JAVA_SCRIPT_PROXY_API_NAME_LIST);
375        } catch (d10) {
376            let e10 = d10;
377            console.error(`AtomicServiceWeb registerJavaScriptProxy failed, code is ${e10.code}, message is ${e10.message}`);
378        }
379    }
380
381    initAtomicServiceWebController() {
382        if (!this.controller) {
383            return;
384        }
385        this.controller.setWebviewController(this.webViewController);
386    }
387
388    cutUrl(b10) {
389        if (b10) {
390            let c10 = b10.indexOf('?');
391            if (c10 > -1) {
392                return b10.substring(0, c10);
393            }
394        }
395        return b10;
396    }
397
398    checkUrl(q1) {
399        if (!q1) {
400            return false;
401        }
402        if (q1.startsWith('resource://rawfile')) {
403            return true;
404        }
405        try {
406            let w1 = this.context.abilityInfo.bundleName;
407            let t1 = 'webView';
408            q1 = this.cutUrl(q1);
409            let res = atomicServiceWebNapi.checkUrl(w1, t1, q1);
410            console.debug(`AtomicServiceWeb checkUrl ret=${res === 0} url=${q1}`);
411            return res === 0;
412        } catch (j2) {
413            let n2 = j2;
414            console.error(`AtomicServiceWeb checkUrl failed, code is ${n2.code}, message is ${n2.message}`);
415            return false;
416        }
417    }
418
419    initDomainCheckLog() {
420        try {
421            let a9 = this.getAppId();
422            let b9 = this.isCheckDomainBlockListAvailable();
423            console.debug('AtomicServiceWeb initDomainCheckLog appId=' + a9 + ' checkDomainBlockListAvailable=' + b9);
424        } catch (z8) {
425            console.error('AtomicServiceWeb initDomainCheckLog error, message: ' + z8.message);
426        }
427    }
428
429    getAppId() {
430        let x8 = this.context.abilityInfo.bundleName;
431        if (!x8) {
432            return null;
433        }
434        let y8 = x8.split('.');
435        if (!y8 || y8.length <= 0) {
436            return null;
437        }
438        return y8[y8.length - 1];
439    }
440
441    isMainPageOrIframeRequest(m8, w8) {
442        if (m8) {
443            return true;
444        }
445        if (w8 === webView.WebResourceType.MAIN_FRAME ||
446            w8 === webView.WebResourceType.SUB_FRAME) {
447            return true;
448        }
449        return false;
450    }
451
452    isCheckDomainBlockListAvailable() {
453        if (!atomicBasicEngine || !atomicBasicEngine.default) {
454            return false;
455        }
456        return typeof atomicBasicEngine.default.checkDomainBlockList === 'function';
457    }
458
459    interceptUrl(s8, t8, u8) {
460        if (!s8) {
461            return false;
462        }
463        if (s8.startsWith(RESOURCE_RAWFILE)) {
464            return true;
465        }
466        if (this.isMainPageOrIframeRequest(t8, u8)) {
467            return this.checkUrl(s8);
468        }
469        if (this.isCheckDomainBlockListAvailable()) {
470            return this.checkUrlNew(s8);
471        }
472        return true;
473    }
474
475    checkUrlNew(n8) {
476        let o8 = this.getAppId();
477        if (!o8) {
478            console.error('AtomicServiceWeb checkUrlNew error, appId is invalid');
479            return false;
480        }
481        try {
482            let q8 = this.cutUrl(n8);
483            let r8 = atomicBasicEngine.default.checkDomainBlockList(q8, o8);
484            console.debug(`AtomicServiceWeb checkUrlNew ret=${!r8} url=${q8}`);
485            return !r8;
486        } catch (p8) {
487            console.error(`AtomicServiceWeb checkUrlNew error, code: ${p8.code}, message: ${p8.message}`);
488            return true;
489        }
490    }
491
492    interceptOverrideUrlLoading(m8) {
493        if (!m8) {
494            return false;
495        }
496        if (m8.startsWith(TEL_PROTOCOL)) {
497            this.openMakeCall(m8);
498            return false;
499        }
500        if (m8.startsWith(MAILTO_PROTOCOL)) {
501            this.openSendMail(m8);
502            return false;
503        }
504        return this.checkUrl(m8);
505    }
506
507    openMakeCall(i8) {
508        if (!i8 || !i8.startsWith(TEL_PROTOCOL)) {
509            return;
510        }
511        try {
512            let k8 = i8.substring(TEL_PROTOCOL.length);
513            call.makeCall(k8).catch((l8) => {
514                console.error(`AtomicServiceWeb openMakeCall error, code: ${l8.code}, message: ${l8.message}`);
515            });
516        } catch (j8) {
517            console.error(`AtomicServiceWeb openMakeCall error, code: ${j8.code}, message: ${j8.message}`);
518        }
519    }
520
521    openSendMail(f8) {
522        if (!f8 || !f8.startsWith(MAILTO_PROTOCOL)) {
523            return;
524        }
525        try {
526            this.context.startAbility({
527                action: WANT_ACTION_SEND_TO_DATA,
528                uri: f8
529            }).catch((h8) => {
530                console.error(`AtomicServiceWeb openSendMail error, code: ${h8.code}, message: ${h8.message}`);
531            });
532        } catch (g8) {
533            console.error(`AtomicServiceWeb openSendMail error, code: ${g8.code}, message: ${g8.message}`);
534        }
535    }
536
537    handleOnPermissionRequest(t8) {
538        if (this.checkPermissionRequest(t8)) {
539            t8.request.grant(t8.request.getAccessibleResource());
540        } else {
541            t8.request.deny();
542        }
543    }
544
545    checkPermissionRequest(o8) {
546        let p8 = o8.request.getAccessibleResource();
547        if (!p8 || p8.length <= 0) {
548            return false;
549        }
550        let q8 = this.getAppId();
551        if (!q8) {
552            console.error('AtomicServiceWeb checkPermissionRequest error, appId is invalid');
553            return false;
554        }
555        for (let r8 of p8) {
556            let s8 = WEB_PERMISSIONS[r8];
557            if (!s8) {
558                console.error('AtomicServiceWeb checkPermissionRequest error, permission is not support');
559                return false;
560            }
561            if (!this.isPermissionUserGranted(s8)) {
562                return false;
563            }
564            if (!this.isPermissionWhiteListAllow(q8, s8)) {
565                return false;
566            }
567        }
568        return true;
569    }
570
571    isPermissionUserGranted(j8) {
572        try {
573            let l8 = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
574            if (!l8?.appInfo?.accessTokenId) {
575                return false;
576            }
577            let m8 = l8.appInfo.accessTokenId;
578            let n8 = abilityAccessCtrl.createAtManager()
579                .checkAccessTokenSync(m8, j8);
580            if (n8 !== abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
581                console.error(`AtomicServiceWeb isPermissionGranted permission ${j8} is not grant`);
582                return false;
583            }
584            return true;
585        } catch (k8) {
586            console.error(`AtomicServiceWeb isPermissionGranted error, code: ${k8.code}, message: ${k8.message}`);
587            return false;
588        }
589    }
590
591    isPermissionWhiteListAllow(f8, g8) {
592        if (!atomicBasicEngine || !atomicBasicEngine.default ||
593            typeof atomicBasicEngine.default.checkAtomicServiceAllow !== 'function') {
594            console.error('AtomicServiceWeb isPermissionRequestAllow error, checkAtomicServiceAllow is not available');
595            return false;
596        }
597        try {
598            let i8 = atomicBasicEngine.default.checkAtomicServiceAllow(f8, g8, TYPE_AS_WEB);
599            console.debug(`AtomicServiceWeb isPermissionRequestAllow ret=${i8} permission=${g8}`);
600            return i8;
601        } catch (h8) {
602            console.error(`AtomicServiceWeb isPermissionRequestAllow error, code: ${h8.code}, message: ${h8.message}`);
603            return false;
604        }
605    }
606
607    rerender() {
608        this.updateDirtyElements();
609    }
610}
611let AtomicServiceWebController = class AtomicServiceWebController {
612    setWebviewController(l5) {
613        this.webViewController = l5;
614    }
615
616    checkWebviewController() {
617        if (!this.webViewController) {
618            const d5 = {
619                name: '',
620                message: 'Init error. The AtomicServiceWebController must be associated with a AtomicServiceWeb component.',
621                code: 17100001,
622            };
623            throw d5;
624        }
625    }
626
627    getUserAgent() {
628        this.checkWebviewController();
629        return this.webViewController?.getUserAgent();
630    }
631
632    getCustomUserAgent() {
633        this.checkWebviewController();
634        return this.webViewController?.getCustomUserAgent();
635    }
636
637    setCustomUserAgent(z4) {
638        this.checkWebviewController();
639        this.webViewController?.setCustomUserAgent(z4);
640    }
641
642    accessForward() {
643        this.checkWebviewController();
644        return this.webViewController?.accessForward();
645    }
646
647    accessBackward() {
648        this.checkWebviewController();
649        return this.webViewController?.accessBackward();
650    }
651
652    accessStep(d4) {
653        this.checkWebviewController();
654        return this.webViewController?.accessStep(d4);
655    }
656
657    forward() {
658        this.checkWebviewController();
659        this.webViewController?.forward();
660    }
661
662    backward() {
663        this.checkWebviewController();
664        this.webViewController?.backward();
665    }
666
667    refresh() {
668        this.checkWebviewController();
669        this.webViewController?.refresh();
670    }
671
672    loadUrl(t3, y3) {
673        this.checkWebviewController();
674        if (y3) {
675            this.webViewController?.loadUrl(t3, y3);
676        } else {
677            this.webViewController?.loadUrl(t3);
678        }
679    }
680};
681AtomicServiceWebController = __decorate([
682    Observed
683], AtomicServiceWebController);
684
685export { AtomicServiceWebController };
686
687class AtomicServiceProxy {
688    constructor(z9) {
689        this.atomicService = z9;
690    }
691
692    invokeJsApi(u9, v9) {
693        try {
694            v9 = v9 || {};
695            if (!u9 || !ATOMIC_SERVICE_JS_API_MAP.has(u9)) {
696                this.atomicService.errorWithCodeAndMsg(JS_API_INVALID_INVOKE_ERROR, v9);
697                return;
698            }
699            let x9 = ATOMIC_SERVICE_JS_API_MAP.get(u9);
700            if (!this.atomicService.checkRequiredFieldInOptions(x9, v9)) {
701                return;
702            }
703            let y9 = this.atomicService;
704            y9[x9?.apiName](v9);
705        } catch (w9) {
706            this.atomicService.error(w9, v9);
707        }
708    }
709}
710
711class AtomicService {
712    constructor(q9, r9, s9) {
713        this.messageDataList = [];
714        this.onMessage = () => {
715        };
716        this.context = q9;
717        this.navPathStack = r9;
718        this.onMessage = s9 ? s9 : this.onMessage;
719    }
720
721    success(o9, p9) {
722        try {
723            p9?.callback && p9?.callback(undefined, o9);
724        } catch (f3) {
725            this.consoleError(`callback error, code is ${f3.code}, message is ${f3.message}`);
726        }
727    }
728
729    error(m9, n9) {
730        try {
731            n9?.callback && n9?.callback(new AsError(m9.code ? m9.code : SYSTEM_INTERNAL_ERROR.code,
732                m9.message ? m9.message : SYSTEM_INTERNAL_ERROR.message));
733        } catch (a3) {
734            this.consoleError(`callback error, code is ${a3.code}, message is ${a3.message}`);
735        }
736    }
737
738    errorWithCodeAndMsg(k9, l9) {
739        try {
740            l9?.callback && l9?.callback(k9);
741        } catch (u2) {
742            this.consoleError(`callback error, code is ${u2.code}, message is ${u2.message}`);
743        }
744    }
745
746    consoleLog(j9) {
747        if (LOG_ENABLE) {
748            console.log(`${LOG_PREFIX} ${j9}`);
749        }
750    }
751
752    consoleError(i9) {
753        if (LOG_ENABLE) {
754            console.error(`${LOG_PREFIX} ${i9}`);
755        }
756    }
757
758    logOptions(g9, h9) {
759        this.consoleLog(`${g9} options=${JSON.stringify(h9)}`);
760    }
761
762    checkParamRequired(d9, e9, f9) {
763        if (e9 === undefined || e9 === null || e9 === '') {
764            this.errorWithCodeAndMsg(new AsError(PARAM_REQUIRED_ERROR_CODE, `Param ${d9} is required.`), f9);
765            return false;
766        }
767        return true;
768    }
769
770    checkNumberParamPositive(a9, b9, c9) {
771        if (b9 <= 0) {
772            this.errorWithCodeAndMsg(new AsError(PARAM_NUMBER_POSITIVE_ERROR_CODE,
773                `Param ${a9} must be a positive number.`), c9);
774            return false;
775        }
776        return true;
777    }
778
779    checkRequiredFieldInOptions(v8, w8) {
780        if (!v8) {
781            return false;
782        }
783        if (!v8.requiredFieldNames) {
784            return true;
785        }
786        let x8 = w8;
787        for (let y8 = 0; y8 < v8.requiredFieldNames.length; y8++) {
788            let z8 = v8.requiredFieldNames[y8];
789            if (!this.checkParamRequired(z8, x8[z8], w8)) {
790                return false;
791            }
792        }
793        return true;
794    }
795
796    checkRouterMode(t8, u8) {
797        if (!t8 || t8 === 'Single' || t8 === 'Standard') {
798            return true;
799        }
800        this.errorWithCodeAndMsg(ROUTER_PARAM_MODE_INVALID_ERROR, u8);
801        return false;
802    }
803
804    parseRouterMode(s8) {
805        return s8 === 'Single' ? router.RouterMode.Single : router.RouterMode.Standard;
806    }
807
808    getRouterIndexByDelta(o8) {
809        let p8 = Number.parseInt(router.getLength());
810        for (let q8 = p8; q8 > 0; q8--) {
811            let r8 = router.getStateByIndex(q8);
812            if (r8?.name && o8-- == 0) {
813                return q8;
814            }
815        }
816        return 1;
817    }
818
819    checkBackUrlExists(i8, j8) {
820        let k8 = Number.parseInt(router.getLength());
821        for (let l8 = k8; l8 > 0; l8--) {
822            let m8 = router.getStateByIndex(l8);
823            if (m8?.name) {
824                let n8 = m8?.path + m8?.name;
825                if (n8 === i8) {
826                    return true;
827                }
828            }
829        }
830        this.errorWithCodeAndMsg(BACK_URL_NOT_EXIST_OR_OPENED_ERROR, j8);
831        return false;
832    }
833
834    checkNavPathStack(g8, h8) {
835        if (!this.navPathStack) {
836            this.errorWithCodeAndMsg(new AsError(NAV_PATH_STACK_NOT_EXIST_ERROR_CODE,
837                `Current page is not NavDestination, not support ${g8}().`), h8);
838            return false;
839        }
840        return true;
841    }
842
843    getNavPathIndexByDelta(e8) {
844        let f8 = this.navPathStack?.getAllPathName();
845        if (!f8 || f8.length == 0) {
846            return -1;
847        }
848        return f8.length > e8 ? (f8.length - e8 - 1) : -1;
849    }
850
851    onPopHandler(c8, d8) {
852        if (!c8?.info || !d8) {
853            return;
854        }
855        d8(new OnPopEvent(c8.info.name, c8.info.param, c8.result));
856    }
857
858    getCurrentNavPathInfo() {
859        let a8 = this.navPathStack?.getAllPathName();
860        let b8 = (a8 && a8.length > 0) ?
861            new NavPathInfo(a8[a8.length - 1], a8.length - 1) : new NavPathInfo(undefined, -1);
862        if (b8.index >= 0) {
863            b8.param = this.navPathStack?.getParamByIndex(b8.index);
864        }
865        return b8;
866    }
867
868    notifyMessage() {
869        if (this.messageDataList.length <= 0) {
870            return;
871        }
872        try {
873            this.onMessage(new OnMessageEvent(this.messageDataList));
874        } catch (q2) {
875            this.consoleError(`onMessage failed, code is ${q2.code}, message is ${q2.message}`);
876        }
877        this.messageDataList = [];
878    }
879
880    isJsApiEnable(z7) {
881        if (!z7) {
882            return false;
883        }
884        if (this.compareVersion(z7.minVersion, ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION) &&
885        this.compareVersion(ATOMIC_SERVICE_JS_SDK_CURRENT_VERSION, z7.maxVersion)) {
886            return true;
887        }
888        return false;
889    }
890
891    compareVersion(p7, q7) {
892        if (!p7 || !q7) {
893            return false;
894        }
895        let r7 = p7.split('.').map(y7 => Number.parseInt(y7));
896        let s7 = q7.split('.').map(x7 => Number.parseInt(x7));
897        const t7 = Math.max(r7.length, s7.length);
898        for (let w7 = 0; w7 < t7; w7++) {
899            if (r7[w7] < s7[w7]) {
900                return true;
901            } else if (r7[w7] > s7[w7]) {
902                return false;
903            }
904        }
905        if (r7.length < s7.length) {
906            return true;
907        }
908        if (r7.length > s7.length) {
909            return false;
910        }
911        return true;
912    }
913
914    getUri(o7) {
915        if (!o7 || o7.startsWith('file://')) {
916            return o7;
917        }
918        return fileUri.getUriFromPath(o7);
919    }
920
921    async checkUploadFile(e7) {
922        if (!e7.files || e7.files.length <= 0) {
923            this.errorWithCodeAndMsg(UPLOAD_IMAGE_FILES_REQUIRED_ERROR, e7);
924            return new CheckUploadFileResult(false);
925        }
926        let f7 = new Map();
927        for (let g7 = 0; g7 < e7.files?.length; g7++) {
928            let h7 = e7.files[g7];
929            if (!h7.uri) {
930                this.errorWithCodeAndMsg(UPLOAD_IMAGE_FILES_URI_REQUIRED_ERROR, e7);
931                return new CheckUploadFileResult(false);
932            }
933            if (!h7.uri.startsWith('file://') && !fs.accessSync(h7.uri, fs.AccessModeType.EXIST)) {
934                this.errorWithCodeAndMsg(new AsError(UPLOAD_IMAGE_FILE_NOT_EXIST_ERROR_CODE,
935                    `File uri ${h7.uri} is not exist.`), e7);
936                return new CheckUploadFileResult(false);
937            }
938            let i7 = h7.uri;
939            let j7 = h7.uri;
940            if (j7.indexOf(UPLOAD_IMAGE_CACHE_DIR) < 0) {
941                let l7 = j7.startsWith('file://') ? j7 : fileUri.getUriFromPath(h7.uri);
942                j7 = this.context.cacheDir + '/' + j7.substring(j7.lastIndexOf('/') + 1);
943                try {
944                    await fs.copy(l7, fileUri.getUriFromPath(j7));
945                } catch (x1) {
946                    this.errorWithCodeAndMsg(UPLOAD_FILE_ERROR, e7);
947                    return new CheckUploadFileResult(false);
948                }
949            }
950            h7.uri = 'internal://' + j7.substring(j7.indexOf(UPLOAD_IMAGE_CACHE_DIR) + 1);
951            f7.set(j7, i7);
952        }
953        return new CheckUploadFileResult(true, f7);
954    }
955
956    convertToRequestData(a7) {
957        let b7 = [];
958        if (a7) {
959            a7.forEach(d7 => {
960                if (!d7.name || !d7.value) {
961                    return;
962                }
963                b7.push({ name: d7.name, value: d7.value });
964            });
965        }
966        return b7;
967    }
968
969    convertToFile(w6) {
970        let x6 = [];
971        if (w6) {
972            w6.forEach(z6 => {
973                x6.push({
974                    filename: z6.filename,
975                    name: z6.name,
976                    uri: z6.uri,
977                    type: z6.type
978                });
979            });
980        }
981        return x6;
982    }
983
984    handleUploadFileResult(p6, q6, r6) {
985        let s6 = [];
986        if (p6) {
987            p6.forEach(u6 => {
988                let v6 = u6.path ? q6.get(u6.path) : u6.path;
989                s6.push(new UploadFileTaskState(v6 ? v6 : u6.path, u6.responseCode, u6.message));
990            });
991        }
992        this.success(new UploadFileResult(s6), r6);
993    }
994
995    parseFileNameFromUrl(m6) {
996        if (!m6) {
997            return '';
998        }
999        let n6 = m6.split('?')[0];
1000        if (n6.indexOf('/') < 0) {
1001            return '';
1002        }
1003        let o6 = n6.lastIndexOf('/');
1004        if (o6 == (n6.length - 1)) {
1005            return '';
1006        }
1007        return n6.substring(o6 + 1);
1008    }
1009
1010    checkAccessToken(v5) {
1011        let w5 = bundleManager.getBundleInfoForSelfSync(bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION);
1012        let x5 = w5.appInfo.accessTokenId;
1013        let y5 = abilityAccessCtrl.createAtManager();
1014        return y5.checkAccessToken(x5, v5);
1015    }
1016
1017    checkPermissions(j5, k5) {
1018        this.checkAccessToken(j5).then(o5 => {
1019            if (o5 == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
1020                k5(undefined);
1021            } else {
1022                let p5 = abilityAccessCtrl.createAtManager();
1023                p5.requestPermissionsFromUser(this.context, [j5]).then(t5 => {
1024                    for (let u5 = 0; u5 < t5.authResults.length; u5++) {
1025                        if (t5.authResults[u5] != 0) {
1026                            const error = {
1027                                name: '',
1028                                message: `RequestPermissionsFromUser error. authResult: ${t5.authResults[u5]}.`,
1029                                code: PERMISSION_LOCATION_USER_REFUSED_ERROR
1030                            };
1031                            k5(error);
1032                            return;
1033                        }
1034                    }
1035                    k5(undefined);
1036                }).catch((s5) => {
1037                    k5(s5);
1038                });
1039            }
1040        }).catch((n5) => {
1041            k5(n5);
1042        });
1043    }
1044}
1045
1046class AtomicServiceApi extends AtomicService {
1047    constructor(g5, h5, i5) {
1048        super(g5, h5, i5);
1049    }
1050
1051    pushUrl(c5) {
1052        if (!this.checkRouterMode(c5.mode, c5)) {
1053            return;
1054        }
1055        router.pushUrl({ url: c5.url, params: c5.params }, this.parseRouterMode(c5.mode)).then(() => {
1056            this.success(new PushUrlResult(), c5);
1057        }).catch((f5) => {
1058            this.error(f5, c5);
1059        });
1060    }
1061
1062    replaceUrl(y4) {
1063        if (!this.checkRouterMode(y4.mode, y4)) {
1064            return;
1065        }
1066        router.replaceUrl({ url: y4.url, params: y4.params }, this.parseRouterMode(y4.mode)).then(() => {
1067            this.success(new ReplaceUrlResult(), y4);
1068        }).catch((b5) => {
1069            this.error(b5, y4);
1070        });
1071    }
1072
1073    backUrl(x4) {
1074        if (x4.url) {
1075            if (!this.checkBackUrlExists(x4.url, x4)) {
1076                return;
1077            }
1078            router.back({ url: x4.url, params: x4.params });
1079            this.success(new BackUrlResult(), x4);
1080        } else if (x4.index || x4.index === 0) {
1081            if (!this.checkNumberParamPositive('index', x4.index, x4)) {
1082                return;
1083            }
1084            router.back(x4.index, x4.params);
1085            this.success(new BackUrlResult(), x4);
1086        } else if (x4.delta || x4.delta === 0) {
1087            if (!this.checkNumberParamPositive('delta', x4.delta, x4)) {
1088                return;
1089            }
1090            router.back(this.getRouterIndexByDelta(x4.delta), x4.params);
1091            this.success(new BackUrlResult(), x4);
1092        } else {
1093            router.back();
1094            this.success(new BackUrlResult(), x4);
1095        }
1096    }
1097
1098    clearUrl(w4) {
1099        router.clear();
1100        this.success(new ClearUrlResult(), w4);
1101    }
1102
1103    pushPath(u4) {
1104        if (!this.checkNavPathStack('navPathStack.pushPath', u4)) {
1105            return;
1106        }
1107        this.navPathStack?.pushPath({
1108            name: u4.name,
1109            param: u4.param,
1110            onPop: v4 => this.onPopHandler(v4, u4.onPop)
1111        }, u4.animated);
1112        this.success(new PushPathResult(), u4);
1113    }
1114
1115    replacePath(s4) {
1116        if (!this.checkNavPathStack('navPathStack.replacePath', s4)) {
1117            return;
1118        }
1119        this.navPathStack?.replacePath({
1120            name: s4.name,
1121            param: s4.param,
1122            onPop: t4 => this.onPopHandler(t4, s4.onPop)
1123        }, s4.animated);
1124        this.success(new ReplacePathResult(), s4);
1125    }
1126
1127    popPath(p4) {
1128        if (!this.checkNavPathStack('navPathStack.pop', p4)) {
1129            return;
1130        }
1131        if (p4.name) {
1132            let r4 = this.navPathStack?.popToName(p4.name, p4.result, p4.animated);
1133            if (r4 === undefined || r4 === -1) {
1134                this.errorWithCodeAndMsg(POP_PATH_NAME_NOT_EXIST_ERROR, p4);
1135                return;
1136            }
1137        } else if (p4.index || p4.index === 0) {
1138            if (p4.index < -1) {
1139                this.errorWithCodeAndMsg(POP_PATH_PARAM_INDEX_INVALID_ERROR, p4);
1140                return;
1141            }
1142            if (p4.index > this.getCurrentNavPathInfo().index) {
1143                this.errorWithCodeAndMsg(POP_PATH_INDEX_OUT_OF_RANGE_ERROR, p4);
1144                return;
1145            }
1146            this.navPathStack?.popToIndex(p4.index, p4.result, p4.animated);
1147        } else if (p4.delta || p4.delta === 0) {
1148            if (!this.checkNumberParamPositive('delta', p4.delta, p4)) {
1149                return;
1150            }
1151            this.navPathStack?.popToIndex(this.getNavPathIndexByDelta(p4.delta), p4.result, p4.animated);
1152        } else {
1153            this.navPathStack?.pop(p4.result, p4.animated);
1154        }
1155        let q4 = this.getCurrentNavPathInfo();
1156        this.success(new PopPathResult(q4.name, q4.index, q4.param), p4);
1157    }
1158
1159    clearPath(o4) {
1160        if (!this.checkNavPathStack('navPathStack.clear', o4)) {
1161            return;
1162        }
1163        this.navPathStack?.clear(o4.animated);
1164        this.success(new ClearPathResult(), o4);
1165    }
1166
1167    postMessage(n4) {
1168        n4.data && this.messageDataList.push(n4.data);
1169        this.success(new PostMessageResult(), n4);
1170    }
1171
1172    getEnv(l4) {
1173        let m4 = new GetEnvResult();
1174        m4.deviceType = deviceInfo.deviceType;
1175        m4.brand = deviceInfo.brand;
1176        m4.productModel = deviceInfo.productModel;
1177        m4.osFullName = deviceInfo.osFullName;
1178        this.success(m4, l4);
1179    }
1180
1181    checkJsApi(h4) {
1182        let i4 = new Map();
1183        h4.jsApiList?.forEach(k4 => {
1184            i4[k4] = this.isJsApiEnable(ATOMIC_SERVICE_JS_API_MAP.get(k4));
1185        });
1186        this.success(new CheckJsApiResult(i4), h4);
1187    }
1188
1189    pickCamera(c4) {
1190        picker.pick(this.context, c4.mediaTypes, {
1191            cameraPosition: c4.cameraPosition,
1192            saveUri: c4.saveUri,
1193            videoDuration: c4.videoDuration
1194        }).then((g4) => {
1195            this.success(new PickCameraResult(g4.resultCode, g4.resultUri, g4.mediaType), c4);
1196        }).catch((f4) => {
1197            this.error(f4, c4);
1198        });
1199    }
1200
1201    selectPhoto(w3) {
1202        let x3 = new photoAccessHelper.PhotoViewPicker();
1203        x3.select({
1204            MIMEType: w3.mimeType,
1205            maxSelectNumber: w3.maxSelectNumber,
1206            isPhotoTakingSupported: w3.isPhotoTakingSupported,
1207            isEditSupported: w3.isEditSupported,
1208            isSearchSupported: w3.isSearchSupported,
1209            recommendationOptions: {
1210                recommendationType: w3.recommendationType
1211            },
1212            preselectedUris: w3.preselectedUris
1213        }).then((b4) => {
1214            this.success(new SelectPhotoResult(b4.photoUris, b4.isOriginalPhoto), w3);
1215        }).catch((a4) => {
1216            this.error(a4, w3);
1217        });
1218    }
1219
1220    openPreview(n3) {
1221        let o3 = this.getUri(n3.uri);
1222        filePreview.openPreview(this.context, {
1223            uri: o3,
1224            mimeType: n3.mimeType,
1225            title: n3.title
1226        }).then(() => {
1227            this.success(new OpenPreviewResult(), n3);
1228        }).catch((v3) => {
1229            this.error(v3, n3);
1230        });
1231    }
1232
1233    uploadFile(z2) {
1234        this.checkUploadFile(z2).then(d3 => {
1235            if (!d3.checkResult) {
1236                return;
1237            }
1238            let e3 = {
1239                url: z2.url,
1240                header: z2.header,
1241                method: z2.method,
1242                files: this.convertToFile(z2.files),
1243                data: this.convertToRequestData(z2.data)
1244            };
1245            request.uploadFile(this.context, e3).then((i3) => {
1246                i3.on('complete', (m3) => {
1247                    this.handleUploadFileResult(m3, d3.uriMap, z2);
1248                });
1249                i3.on('fail', (l3) => {
1250                    this.handleUploadFileResult(l3, d3.uriMap, z2);
1251                });
1252            }).catch((h3) => {
1253                this.error(h3, z2);
1254            });
1255        }).catch((c3) => {
1256            this.error(c3, z2);
1257        });
1258    }
1259
1260    downloadFile(m2) {
1261        let o2 = `${util.generateRandomUUID().replaceAll('-', '')}`;
1262        let p2 = `${this.context.cacheDir}/${o2}`;
1263        request.downloadFile(this.context, {
1264            url: m2.url,
1265            header: m2.header ? m2.header : new Object(),
1266            filePath: p2,
1267            enableMetered: m2.enableMetered,
1268            enableRoaming: m2.enableRoaming,
1269            networkType: m2.networkType,
1270            background: false
1271        }).then((t2) => {
1272            t2.on('complete', () => {
1273                this.success(new DownloadFileResult(p2), m2);
1274            });
1275            t2.on('fail', w2 => {
1276                this.errorWithCodeAndMsg(new AsError(w2, 'File download fail.'), m2);
1277            });
1278        }).catch((s2) => {
1279            this.error(s2, m2);
1280        });
1281    }
1282
1283    getNetworkType(c2) {
1284        connection.getDefaultNet().then(g2 => {
1285            if (!g2 || g2.netId === 0) {
1286                this.errorWithCodeAndMsg(NETWORK_NO_ACTIVE_ERROR, c2);
1287                return;
1288            }
1289            connection.getNetCapabilities(g2).then(k2 => {
1290                let l2 = new GetNetworkTypeResult(k2.bearerTypes, k2.networkCap, k2.linkUpBandwidthKbps,
1291                    k2.linkDownBandwidthKbps);
1292                this.success(l2, c2);
1293            }).catch((j2) => {
1294                this.error(j2, c2);
1295            });
1296        }).catch((f2) => {
1297            this.error(f2, c2);
1298        });
1299    }
1300
1301    getLocation(u1) {
1302        this.checkPermissions(PERMISSION_APPROXIMATELY_LOCATION, w1 => {
1303            if (w1) {
1304                this.error(w1, u1);
1305                return;
1306            }
1307            geoLocationManager.getCurrentLocation({
1308                priority: u1.priority,
1309                scenario: u1.scenario,
1310                maxAccuracy: u1.maxAccuracy,
1311                timeoutMs: u1.timeoutMs
1312            }).then(a2 => {
1313                let b2 =
1314                    new GetLocationResult(a2.latitude, a2.longitude, a2.altitude, a2.accuracy, a2.speed, a2.timeStamp,
1315                        a2.direction, a2.timeSinceBoot, a2.additions, a2.additionSize);
1316                this.success(b2, u1);
1317            }).catch((z1) => {
1318                this.error(z1, u1);
1319            });
1320        });
1321    }
1322}
1323
1324class NavPathInfo {
1325    constructor(s1, t1) {
1326        this.name = s1;
1327        this.index = t1;
1328    }
1329}
1330
1331class CheckUploadFileResult {
1332    constructor(q1, r1) {
1333        this.checkResult = q1;
1334        this.uriMap = r1;
1335    }
1336}
1337
1338class BaseOptions {
1339}
1340
1341class PushUrlOptions extends BaseOptions {
1342}
1343
1344class PushUrlResult {
1345}
1346
1347class ReplaceUrlOptions extends BaseOptions {
1348}
1349
1350class ReplaceUrlResult {
1351}
1352
1353class BackUrlOptions extends BaseOptions {
1354}
1355
1356class BackUrlResult {
1357}
1358
1359class ClearUrlOptions extends BaseOptions {
1360}
1361
1362class ClearUrlResult {
1363}
1364
1365class OnPopEvent {
1366    constructor(n1, o1, p1) {
1367        this.name = n1;
1368        this.param = o1;
1369        this.result = p1;
1370    }
1371}
1372
1373class PushPathOptions extends BaseOptions {
1374}
1375
1376class PushPathResult {
1377}
1378
1379class ReplacePathOptions extends BaseOptions {
1380}
1381
1382class ReplacePathResult {
1383}
1384
1385class PopPathOptions extends BaseOptions {
1386}
1387
1388class PopPathResult {
1389    constructor(k1, l1, m1) {
1390        this.name = k1;
1391        this.index = l1;
1392        this.param = m1;
1393    }
1394}
1395
1396class ClearPathOptions extends BaseOptions {
1397}
1398
1399class ClearPathResult {
1400}
1401
1402class PostMessageOptions extends BaseOptions {
1403}
1404
1405class PostMessageResult {
1406}
1407
1408export class OnMessageEvent {
1409    constructor(j1) {
1410        this.data = j1;
1411    }
1412}
1413
1414export class OnErrorReceiveEvent {
1415    constructor(h1, i1) {
1416        this.request = h1;
1417        this.error = i1;
1418    }
1419}
1420
1421export class OnHttpErrorReceiveEvent {
1422    constructor(f1, g1) {
1423        this.request = f1;
1424        this.response = g1;
1425    }
1426}
1427
1428export class OnPageBeginEvent {
1429    constructor(e1) {
1430        this.url = e1;
1431    }
1432}
1433
1434export class OnPageEndEvent {
1435    constructor(d1) {
1436        this.url = d1;
1437    }
1438}
1439
1440export class WebHeader {
1441    constructor(j3, p3) {
1442        this.headerKey = j3;
1443        this.headerValue = p3;
1444    }
1445}
1446
1447class GetEnvOptions extends BaseOptions {
1448}
1449
1450class GetEnvResult {
1451}
1452
1453class CheckJsApiOptions extends BaseOptions {
1454}
1455
1456class CheckJsApiResult {
1457    constructor(c1) {
1458        this.checkResult = c1;
1459    }
1460}
1461
1462class PickCameraOptions extends BaseOptions {
1463}
1464
1465class PickCameraResult {
1466    constructor(z, a1, b1) {
1467        this.resultCode = z;
1468        this.resultUri = a1;
1469        this.mediaType = b1;
1470    }
1471}
1472
1473class SelectPhotoOptions extends BaseOptions {
1474}
1475
1476class SelectPhotoResult {
1477    constructor(x, y) {
1478        this.photoUris = x;
1479        this.isOriginalPhoto = y;
1480    }
1481}
1482
1483class OpenPreviewOptions extends BaseOptions {
1484}
1485
1486class OpenPreviewResult {
1487}
1488
1489class UploadFileOptions extends BaseOptions {
1490}
1491
1492class UploadFile {
1493    constructor(t, u, v, w) {
1494        this.filename = t;
1495        this.name = u;
1496        this.uri = v;
1497        this.type = w;
1498    }
1499}
1500
1501class UploadRequestData {
1502}
1503
1504class UploadFileResult {
1505    constructor(s) {
1506        this.taskStates = s;
1507    }
1508}
1509
1510class UploadFileTaskState {
1511    constructor(p, q, r) {
1512        this.path = p;
1513        this.responseCode = q;
1514        this.message = r;
1515    }
1516}
1517
1518class DownloadFileOptions extends BaseOptions {
1519}
1520
1521class DownloadFileResult {
1522    constructor(o) {
1523        this.uri = o;
1524    }
1525}
1526
1527class GetNetworkTypeOptions extends BaseOptions {
1528}
1529
1530class GetNetworkTypeResult {
1531    constructor(k, l, m, n) {
1532        this.bearerTypes = k;
1533        this.networkCap = l;
1534        this.linkUpBandwidthKbps = m;
1535        this.linkDownBandwidthKbps = n;
1536    }
1537}
1538
1539class GetLocationOptions extends BaseOptions {
1540}
1541
1542class GetLocationResult {
1543    constructor(a, b, c, d, e, f, g, h, i, j) {
1544        this.latitude = a;
1545        this.longitude = b;
1546        this.altitude = c;
1547        this.accuracy = d;
1548        this.speed = e;
1549        this.timeStamp = f;
1550        this.direction = g;
1551        this.timeSinceBoot = h;
1552        this.additions = i;
1553        this.additionSize = j;
1554    }
1555}
1556
1557export default {
1558    AtomicServiceWeb,
1559    AtomicServiceWebController
1560}
1561