<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">// Copyright 2023 Esri
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//   http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.â€‹
var __decorate = (this &amp;&amp; this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c &lt; 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" &amp;&amp; typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i &gt;= 0; i--) if (d = decorators[i]) r = (c &lt; 3 ? d(r) : c &gt; 3 ? d(target, key, r) : d(target, key)) || r;
    return c &gt; 3 &amp;&amp; r &amp;&amp; Object.defineProperty(target, key, r), r;
};
var __importDefault = (this &amp;&amp; this.__importDefault) || function (mod) {
    return (mod &amp;&amp; mod.__esModule) ? mod : { "default": mod };
};
define(["require", "exports", "esri/core/accessorSupport/decorators", "esri/core/reactiveUtils", "esri/widgets/Widget", "esri/widgets/support/widget", "../../functionality/configurationSettings", "../../functionality/coverPage"], function (require, exports, decorators_1, reactiveUtils_1, Widget_1, widget_1, configurationSettings_1, coverPage_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    Widget_1 = __importDefault(Widget_1);
    const KEYS = [
        "coverPage",
        "landingPage",
        "coverPageConfig",
        "landingPageConfig",
    ];
    const CSS = {
        backgroundColor: "--instant-apps-landing-page-background-color",
        textColor: "--instant-apps-landing-page-text-color",
        entryButtonColor: "--instant-apps-landing-page-entry-button-color",
    };
    let LandingPage = class LandingPage extends Widget_1.default {
        constructor(params) {
            super(params);
        }
        postInitialize() {
            this._handleDeprecatedCoverPage();
            document.body.prepend(this.container);
            this.addLandingPageHandles();
        }
        render() {
            const { coverPage, landingPage } = this.configurationSettings;
            return ((0, widget_1.tsx)("div", null, landingPage === undefined
                ? coverPage
                    ? this._renderLandingPage()
                    : null
                : landingPage
                    ? this._renderLandingPage()
                    : null));
        }
        _renderLandingPage() {
            const config = this._getConfig();
            const styles = this._getStyles();
            const token = this._getToken();
            const backgroundImageSrcUrl = config?.backgroundImageSrc
                ? new URL(config?.backgroundImageSrc)
                : null;
            const iconImageUrl = config?.iconImage ? new URL(config?.iconImage) : null;
            if (token) {
                if (backgroundImageSrcUrl)
                    backgroundImageSrcUrl.searchParams.set("token", token);
                if (iconImageUrl)
                    iconImageUrl.searchParams.set("token", token);
            }
            return ((0, widget_1.tsx)("instant-apps-landing-page", { bind: this, afterCreate: widget_1.storeNode, "data-node-ref": "landingPageEl", style: styles, key: "esri-attachment-viewer-landing-page", fontFamily: this?.configurationSettings?.customTheme?.appFont, titleText: config?.titleText, subtitleText: config?.subtitleText, descriptionText: config?.descriptionText, entryButtonText: config?.entryButtonText, alignment: config?.alignment, iconImage: iconImageUrl ? iconImageUrl?.href : "", iconImageScale: config?.iconImageScale, backgroundImageSrc: config?.backgroundType === "image"
                    ? backgroundImageSrcUrl
                        ? backgroundImageSrcUrl?.href
                        : ""
                    : "" }));
        }
        addLandingPageHandles() {
            this.handles.add([
                (0, reactiveUtils_1.watch)(() =&gt; this.configurationSettings?.landingPage, () =&gt; this.scheduleRender(), { initial: true }),
                (0, reactiveUtils_1.watch)(() =&gt; this.configurationSettings?.landingPageConfig, () =&gt; this.scheduleRender(), { initial: true }),
            ]);
        }
        _getStyles() {
            const config = this._getConfig();
            const backgroundColor = config?.backgroundColor;
            const textColor = config?.textColor;
            const entryButtonColor = config?.entryButtonColor;
            const isImage = config?.backgroundType === "image";
            const backgroundImageSrc = config?.backgroundImageSrc;
            return `
      ${CSS.backgroundColor}: ${isImage &amp;&amp; backgroundImageSrc
                ? "var(--calcite-ui-foreground-1)"
                : backgroundColor
                    ? backgroundColor
                    : "var(--calcite-ui-brand)"};
      ${CSS.textColor}: ${textColor ? textColor : "var(--calcite-ui-text-inverse)"};
      ${CSS.entryButtonColor}: ${entryButtonColor ? entryButtonColor : "var(--calcite-ui-brand)"};
    `;
        }
        _getToken() {
            return this.portal?.["credential"]?.["token"] ?? "";
        }
        _getConfig() {
            const landingPageConfig = this.configurationSettings?.landingPageConfig;
            const coverPageConfig = this.configurationSettings?.coverPageConfig;
            return (0, coverPage_1.getLandingPageValues)(landingPageConfig, coverPageConfig);
        }
        _handleDeprecatedCoverPage() {
            const values = this.base.results.applicationData?.value?.values;
            KEYS.forEach((key) =&gt; this._handleUndefined(values, key, this.configurationSettings));
        }
        _handleUndefined(values, key, config) {
            if ((0, configurationSettings_1.isWithinConfigurationExperience)()) {
                this._setUndefinedForDraft(values, key, config);
            }
            else {
                this._setUndefinedForPublish(values, key, config);
            }
        }
        _setUndefinedForDraft(values, key, config) {
            if (!values?.draft?.hasOwnProperty(key) &amp;&amp; !values.hasOwnProperty(key)) {
                config[key] = undefined;
            }
        }
        _setUndefinedForPublish(values, key, config) {
            if (!values?.hasOwnProperty(key)) {
                config[key] = undefined;
            }
        }
    };
    __decorate([
        (0, decorators_1.property)()
    ], LandingPage.prototype, "configurationSettings", void 0);
    __decorate([
        (0, decorators_1.property)()
    ], LandingPage.prototype, "handles", void 0);
    __decorate([
        (0, decorators_1.property)()
    ], LandingPage.prototype, "portal", void 0);
    __decorate([
        (0, decorators_1.property)()
    ], LandingPage.prototype, "base", void 0);
    __decorate([
        (0, decorators_1.property)()
    ], LandingPage.prototype, "landingPageEl", void 0);
    __decorate([
        (0, decorators_1.property)()
    ], LandingPage.prototype, "postInitialize", null);
    LandingPage = __decorate([
        (0, decorators_1.subclass)("LandingPage")
    ], LandingPage);
    exports.default = LandingPage;
});
</pre></body></html>