dojo.provide("parus.embeddedMode");dojo.require("dojo.dom-style");dojo.require("parus.parus8");if(!parus){parus={}}if(!parus.embeddedMode){dojo.mixin(parus,{embeddedMode:{}})}dojo.mixin(parus.embeddedMode,{tabId:"",_onClose:null,_onShow:null,version:null,startup:function(b){parus.parus8._embeddedMode=true;var a=new URLSearchParams(window.location.search);this.tabId=a.get("tab_id");window.addEventListener("message",this._windowEventListener);if(!this.tabId){this.tabId=Date.now()+Math.floor(Math.random()*100);this.postMessage("register",this.tabId,{url:document.URL})}setTimeout(dojo.hitch(this,function(){this.postMessage("ready",this.tabId,{})}),100)},_windowEventListener:function(a){if(a.data.hasOwnProperty("action")){if(a.data.action=="onTabCloseConfirm"){if(parus.embeddedMode.onTabCloseConfirm()){parus.embeddedMode.closeTab()}}else{if(a.data.action=="onShowTab"){parus.embeddedMode.onShowTab()}else{if(a.data.action=="onGlobalChanged"){parus.embeddedMode.handleGlobalChanged(a.data.params.identifier,a.data.params.value)}else{if(a.data.action=="onGetVersion"){parus.embeddedMode.handleGetVersion(a.data.params.version)}}}}}},postMessage:function(b,c,a){window.top.postMessage({action:b,id:c||"",params:a||{}},"*")},onTabCloseConfirm:function(){if(this._onClose&&typeof this._onClose==="function"){this._onClose(this.tabId);return false}return true},onShowTab:function(){if(this._onShow&&typeof this._onShow==="function"){this._onShow(this.tabId)}var a=[];dojo.query("*[widgetId]",document.body).forEach(function(c){var b=dijit.byNode(c);if(b&&b.dialogObject&&dojo.isFunction(b.dialogObject._startupResize)){if(dojo.indexOf(a,b.dialogObject.id)<0){b.dialogObject._activateResize()}a.push(b.dialogObject.id)}else{if(b&&b.isInstanceOf&&dojo.isFunction(b.isInstanceOf)&&(b.isInstanceOf(dijit.Dialog)||b.isInstanceOf(dijit.DialogUnderlay))){return}if(b&&b.layout&&dojo.isFunction(b.layout)){b.layout()}if(b&&b.resize&&dojo.isFunction(b.resize)){b.resize()}}});return true},openTab:function(e,b,a,d){var c=location.pathname.split("/");c.pop();if(a.startsWith("..")){a=a.substring(2);c.pop()}a=location.origin+(c.length?c.join("/"):"")+a;d=(d==null)?true:(d===true);this.postMessage("openTab",e,{title:b,url:a,confirmClose:d})},registerOnCloseCallback:function(a){this._onClose=a},registerOnShowCallback:function(a){this._onShow=a},changeTabTitle:function(a){this.postMessage("changeTabTitle",this.tabId,{title:a})},changeTabState:function(a){this.postMessage("changeTabState",this.tabId,{modified:a})},closeTab:function(){this.postMessage("closeTab",this.tabId)},handleGlobalChanged:function(_10,_11){eval(_10+"=("+((_11&&dojo.isObject(_11)&&Object.keys(_11).length)?dojo.toJson(_11):"null")+")")},globalChanged:function(b,a){this.postMessage("globalChanged",this.tabId,{identifier:b,value:a})},handleGetVersion:function(a){this.version=dojo.clone(a)}});if(dojo.isFF>50){require(["dojo/dom-style","dojo/_base/window","dojo/dom"],function(b,d,e){var a=b.get;var c={getComputedStyle:function(h){var g=h.ownerDocument.defaultView,f=g.opener?g:d.global.window;return h.nodeType==1?f.getComputedStyle(h,null):{}},get:function(g,f){if((arguments.length==2)&&(f=="opacity")){return this.getComputedStyle(e.byId(g)).opacity}return a.apply(this,arguments)}};dojo.mixin(b,c);dojo.getComputedStyle=b.getComputedStyle})}if(!parus.aboutBoxWindow){dojo.mixin(parus,{aboutBoxWindow:{}})}dojo.mixin(parus.aboutBoxWindow,{startup:function(){(function(){if(!parus.embeddedMode.version){setTimeout(arguments.callee,100)}else{loadingDiv.style.display="none";parus.parus8.aboutBox(function(){parus.embeddedMode.closeTab()})}})()}});