define([
    'uiComponent',
    'uiLayout',
    'uiRegistry',
    'mage/translate',
    'mage/template',
    'jquery',
    'ko',
    'Magento_Ui/js/modal/modal'
], function(
    Component,
    layout,
    registry,
    $t,
    mageTemplate,
    $,
    ko,
    modal
) {
    'use strict';
    return Component.extend({
        defaults: {
            template: "Webkul_MpPayPal/onboard.html",
            inputType: false,
            productIds: '',
            secureWindowMsg: $t("Don't see the secure PayPal browser? We'll help you re-launch the window to complete your flow. You might need to enable pop-ups in your browser in order to continue"),
            secureBtnMsg: $t("Continue")
        },

        /**
         * @extends
         */
        initialize: function () {
            var self = this;
            this._super();
            $.ajaxSetup({
                showLoader: true
            });
            (function(d, s, id) {
                var js, ref = d.getElementsByTagName(s)[0];
                if (!d.getElementById(id)) {
                  js = d.createElement(s);
                  js.id = id;
                  js.async = true;
                  js.src = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
                  ref.parentNode.insertBefore(js, ref);
                }
            }(document, "script", "partner-js"));
            (function(d, s, id) {
                var js, ref = d.getElementsByTagName(s)[0];
                if (!d.getElementById(id)) {
                  js = d.createElement(s);
                  js.id = id;
                  js.async = true;
                  js.src = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/signup.js";
                  ref.parentNode.insertBefore(js, ref);
                }
            }(document, "script", "signup-js"));
            (function(d, s, id) {
                var js, ref = d.getElementsByTagName(s)[0];
                if (!d.getElementById(id)) {
                  js = d.createElement(s);
                  js.id = id;
                  js.async = true;
                  js.src = "https://www.paypalobjects.com/js/external/dg.js";
                  ref.parentNode.insertBefore(js, ref);
                }
            }(document, "script", "dg-js"));
        },

        /**
         * initialize observers
         */
        initObservable: function () {
            this._super().observe('');
            return this;
        },
    })
});