text: /**
   * skylark-osjsv2-client - A version of osjs-client that ported to running on skylarkjs
   * @author Hudaokeji, Inc.
   * @version v0.9.0
   * @link https://github.com/skylark-integration/skylark-osjsv2-client/
   * @license MIT
   */
  define(["../core/mount-manager","./service-notification-icon","../utils/preloader","../core/locales","../core/config"],function(o,s,i,n,e){"use strict";const t=window.location.href.replace(/\/$/,"")+"/windows-live-oauth.html";let c=null;class l{constructor(o){this.hasSession=!1,this.clientId=o,this.loaded=!1,this.inited=!1,this.accessToken=null,this.lastScope=null,this.preloads=[{type:"javascript",src:"//js.live.net/v5.0/wl.js"}]}destroy(){}init(o){o=o||function(){},this.loaded?o(!1,!0):i.preload(this.preloads).then(s=>{s.failed.length||(this.loaded=!0),o(s.failed.join("\n"))}).catch(()=>o())}load(o,s){console.debug("WindowsLiveAPI::load()",o);let i=window.WL||{};const e=()=>{const i=(this.lastScope||[]).sort(),n=(o||[]).sort();this.hasSession&&i.toString()===n.toString()?s(!1,!0):this.login(o,(o,i)=>{o?s(o):setTimeout(()=>{s(!1,!0)},10)})};this.init(o=>{o?s(o):window.WL?(i=window.WL||{},this.inited?e():(this.inited=!0,i.Event.subscribe("auth.login",(o,s,i,n)=>{this.onLogin(o,s,i,n)}),i.Event.subscribe("auth.logout",(o,s,i,n)=>{this.onLogout(o,s,i,n)}),i.Event.subscribe("wl.log",(o,s,i,n)=>{this.onLog(o,s,i,n)}),i.Event.subscribe("auth.sessionChange",(o,s,i,n)=>{this.onSessionChange(o,s,i,n)}),i.init({client_id:this.clientId,display:"popup",redirect_uri:t}).then(o=>{console.debug("WindowsLiveAPI::load()","=>",o),o.session&&(this.accessToken=o.session.access_token||null),"connected"===o.status?s(!1,!0):"success"===o.status?e():s(n._("WLAPI_INIT_FAILED_FMT",o.status.toString()))},o=>{console.error("WindowsLiveAPI::load()","init() error",o),s(o.error_description)}))):s(n._("WLAPI_LOAD_FAILURE"))})}_removeRing(){s.remove("Windows Live API")}logout(s){s=s||function(){};const i=window.WL||{};this.hasSession&&s(!1,!1),i.Event.unsubscribe("auth.logout"),i.Event.subscribe("auth.logout",()=>{this._removeRing(),i.Event.unsubscribe("auth.logout"),s(!1,!0)}),i.logout(),o.remove("OneDrive")}login(o,s){const i=window.WL||{};this.hasSession?s(!1,!0):i.login({scope:o,redirect_uri:t}).then(o=>{"connected"===o.status?s(!1,!0):s(n._("WLAPI_LOGIN_FAILED"))},o=>{s(n._("WLAPI_LOGIN_FAILED_FMT",o.error_description))})}onSessionChange(){console.warn("WindowsLiveAPI::onSessionChange()",arguments);const o=(window.WL||{}).getSession();this.hasSession=!!o}onLogin(){console.warn("WindowsLiveAPI::onLogin()",arguments),this.hasSession=!0,s.add("Windows Live API",[{title:n._("WLAPI_SIGN_OUT"),onClick:()=>{this.logout()}}])}onLogout(){console.warn("WindowsLiveAPI::onLogout()",arguments),this.hasSession=!1,this._removeRing()}onLog(){console.debug("WindowsLiveAPI::onLog()",arguments)}}return{instance:function(){return c},create:function(o,s){function i(){const i=o.scope;c.load(i,o=>{s(o||!1,c)})}if(o=o||{},c)return void i();let t=null;try{t=e.getConfig("WindowsLiveAPI.ClientId")}catch(o){console.warn("getWindowsLiveAPI()",o,o.stack)}t?(c=new l(t),i()):s(n._("WLAPI_DISABLED"))}}});
  //# sourceMappingURL=../sourcemaps/helpers/windows-live-api.js.map
  