/**************************************************************************
 *                                                                        *
 *  Copyright 2014 Adobe Systems Incorporated                             *
 *  All Rights Reserved.                                                  *
 *                                                                        *
 * NOTICE:  All information contained herein is, and remains the property *
 * of Adobe Systems Incorporated and its suppliers, if any.               *
 * The intellectual and technical concepts contained herein are           *
 * proprietary to Adobe Systems Incorporated and its suppliers and may be *
 * covered by U.S. and Foreign Patents, patents in process, and are       *
 * protected by trade secret or copyright law.                            *
 * Dissemination of this information or reproduction of this material     *
 * strictly forbidden unless prior written permission is obtained from    *
 * Adobe Systems Incorporated.                                            *
 *                                                                        *
 **************************************************************************/

/* ShareOnBehance 2.0.0.29 */
function CSXSWindowType(){}function Version(e,t,n,r){this.major=e,this.minor=t,this.micro=n,this.special=r}function VersionBound(e,t){this.version=e,this.inclusive=t}function VersionRange(e,t){this.lowerBound=e,this.upperBound=t}function Runtime(e,t){this.name=e,this.versionRange=t}function Extension(e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v){this.id=e,this.name=t,this.mainPath=n,this.basePath=r,this.windowType=i,this.width=s,this.height=o,this.minWidth=u,this.minHeight=a,this.maxWidth=f,this.maxHeight=l,this.defaultExtensionDataXml=c,this.specialExtensionDataXml=h,this.requiredRuntimeList=p,this.isAutoVisible=d,this.isPluginExtension=v}function CSEvent(e,t,n,r){this.type=e,this.scope=t,this.appId=n,this.extensionId=r}function SystemPath(){}function ColorType(){}function RGBColor(e,t,n,r){this.red=e,this.green=t,this.blue=n,this.alpha=r}function Direction(e,t){this.x=e,this.y=t}function GradientStop(e,t){this.offset=e,this.rgbColor=t}function GradientColor(e,t,n,r){this.type=e,this.direction=t,this.numStops=n,this.arrGradientStop=r}function UIColor(e,t,n){this.type=e,this.antialiasLevel=t,this.color=n}function AppSkinInfo(e,t,n,r,i,s,o){this.baseFontFamily=e,this.baseFontSize=t,this.appBarBackgroundColor=n,this.panelBackgroundColor=r,this.appBarBackgroundColorSRGB=i,this.panelBackgroundColorSRGB=s,this.systemHighlightColor=o}function HostEnvironment(e,t,n,r,i,s,o){this.appName=e,this.appVersion=t,this.appLocale=n,this.appUILocale=r,this.appId=i,this.isAppOnline=s,this.appSkinInfo=o}function HostCapabilities(e,t,n,r,i){this.EXTENDED_PANEL_MENU=e,this.EXTENDED_PANEL_ICONS=t,this.DELEGATE_APE_ENGINE=n,this.SUPPORT_HTML_EXTENSIONS=r,this.DISABLE_FLASH_EXTENSIONS=i}function ApiVersion(e,t,n){this.major=e,this.minor=t,this.micro=n}function MenuItemStatus(e,t,n){this.menuItemLabel=e,this.enabled=t,this.checked=n}function ContextMenuItemStatus(e,t,n){this.menuItemID=e,this.enabled=t,this.checked=n}function CSInterface(){}function AAMStatus(e,t,n){this.status=e,this.callerId=t,this.payload=n}function IMSInterface(){}define("lib/CEPGlobals",[],function(){return window.cep}),define("window",[],function(){return window}),define("config",["window"],function(e){var t="c2hhcmUtb24tYmVoYW5jZQ==",n="NmExODlhOGItY2JjOC00ODgyLWFhZGUtMDBkNzUxODYyYTFk",r="aHR0cHM6Ly9vb2JlLmFkb2JlLmNvbS8=",i="QmVoYW5jZVdlYlN1c2kx";return{aameeServiceName:"ShareOnBehance",behanceDomain:"https://www.behance.net",behanceIFrameUrl:"https://www.behance.net/portfolio/wips/load/iframe?isa0=1",behanceHelpUrl:"https://www.behance.net/faq",behancePingUrl:"https://www.behance.net/xd.php",imsCi:e.atob(t),imsCs:e.atob(n),imsRu:e.atob(r),imsJci:e.atob(i),logging:!0,timeout:3e4,version:"2.0.0",whiteListedDomains:["adobe.com","behance.net","prosite.com","be.net"],fetchAccessTokenTimeout:6e4}}),define("log",["config"],function(e){var t=(new Date).getTime();return{error:function(n){e.logging&&console.log("ERROR ("+((new Date).getTime()-t)+"): "+n)},info:function(n){e.logging&&console.log("INFO ("+((new Date).getTime()-t)+"): "+n)},stringify:function(t){if(!e.logging)return"";try{return JSON.stringify(t)}catch(n){return t+""}}}}),CSXSWindowType._PANEL="Panel",CSXSWindowType._MODELESS="Modeless",CSXSWindowType._MODAL_DIALOG="ModalDialog",EvalScript_ErrMessage="EvalScript error.",Version.MAX_NUM=999999999,CSEvent.prototype.data="",SystemPath.USER_DATA="userData",SystemPath.COMMON_FILES="commonFiles",SystemPath.MY_DOCUMENTS="myDocuments",SystemPath.APPLICATION="application",SystemPath.EXTENSION="extension",SystemPath.HOST_APPLICATION="hostApplication",ColorType.RGB="rgb",ColorType.GRADIENT="gradient",ColorType.NONE="none",CSInterface.THEME_COLOR_CHANGED_EVENT="com.adobe.csxs.events.ThemeColorChanged",CSInterface.prototype.hostEnvironment=JSON.parse(window.__adobe_cep__.getHostEnvironment()),CSInterface.prototype.getHostEnvironment=function(){return this.hostEnvironment=JSON.parse(window.__adobe_cep__.getHostEnvironment()),this.hostEnvironment},CSInterface.prototype.closeExtension=function(){window.__adobe_cep__.closeExtension()},CSInterface.prototype.getSystemPath=function(e){var t=decodeURI(window.__adobe_cep__.getSystemPath(e)),n=this.getOSInformation();return n.indexOf("Windows")>=0?t=t.replace("file:///",""):n.indexOf("Mac")>=0&&(t=t.replace("file://","")),t},CSInterface.prototype.evalScript=function(e,t){if(t==null||t==undefined)t=function(e){};window.__adobe_cep__.evalScript(e,t)},CSInterface.prototype.getApplicationID=function(){var e=this.hostEnvironment.appId;return e},CSInterface.prototype.getHostCapabilities=function(){var e=JSON.parse(window.__adobe_cep__.getHostCapabilities());return e},CSInterface.prototype.dispatchEvent=function(e){typeof e.data=="object"&&(e.data=JSON.stringify(e.data)),window.__adobe_cep__.dispatchEvent(e)},CSInterface.prototype.addEventListener=function(e,t,n){window.__adobe_cep__.addEventListener(e,t,n)},CSInterface.prototype.removeEventListener=function(e,t,n){window.__adobe_cep__.removeEventListener(e,t,n)},CSInterface.prototype.requestOpenExtension=function(e,t){window.__adobe_cep__.requestOpenExtension(e,t)},CSInterface.prototype.getExtensions=function(e){var t=JSON.stringify(e),n=window.__adobe_cep__.getExtensions(t),r=JSON.parse(n);return r},CSInterface.prototype.getNetworkPreferences=function(){var e=window.__adobe_cep__.getNetworkPreferences(),t=JSON.parse(e);return t},CSInterface.prototype.initResourceBundle=function(){var e=JSON.parse(window.__adobe_cep__.initResourceBundle()),t=document.querySelectorAll("[data-locale]");for(var n=0;n<t.length;n++){var r=t[n],i=r.getAttribute("data-locale");if(i)for(var s in e)if(s.indexOf(i)==0){var o=e[s];if(s.length==i.length)r.innerHTML=o;else if("."==s.charAt(i.length)){var u=s.substring(i.length+1);r[u]=o}}}return e},CSInterface.prototype.dumpInstallationInfo=function(){return window.__adobe_cep__.dumpInstallationInfo()},CSInterface.prototype.getOSInformation=function(){var e=navigator.userAgent;if(navigator.platform=="Win32"||navigator.platform=="Windows"){var t="Windows",n="";return e.indexOf("Windows")>-1&&(e.indexOf("Windows NT 5.0")>-1?t="Windows 2000 ":e.indexOf("Windows NT 5.1")>-1?t="Windows XP ":e.indexOf("Windows NT 5.2")>-1?t="Windows Server 2003 ":e.indexOf("Windows NT 6.0")>-1?t="Windows Vista ":e.indexOf("Windows NT 6.1")>-1?t="Windows 7 ":e.indexOf("Windows NT 6.2")>-1&&(t="Windows 8 "),e.indexOf("WOW64")>-1?n="64-bit":n="32-bit"),t+n}if(navigator.platform=="MacIntel"||navigator.platform=="Macintosh"){var r="Mac OS X",i=new String;i=e;if(i.indexOf("Mac OS X")>-1){var s=i.indexOf(")")-i.indexOf("Mac OS X"),o=i.substr(i.indexOf("Mac OS X"),s);r=o.replace("_","."),r=r.replace("_",".")}return r}return"Unknown Operation System"},CSInterface.prototype.openURLInDefaultBrowser=function(e){return cep.util.openURLInDefaultBrowser(e)},CSInterface.prototype.getExtensionID=function(){return window.__adobe_cep__.getExtensionId()},CSInterface.prototype.getScaleFactor=function(){return window.__adobe_cep__.getScaleFactor()},CSInterface.prototype.setScaleFactorChangedHandler=function(e){window.__adobe_cep__.setScaleFactorChangedHandler(e)},CSInterface.prototype.getCurrentApiVersion=function(){var e=JSON.parse(window.__adobe_cep__.getCurrentApiVersion());return e},CSInterface.prototype.setPanelFlyoutMenu=function(e){if("string"!=typeof e)return;window.__adobe_cep__.invokeSync("setPanelFlyoutMenu",e)},CSInterface.prototype.updatePanelMenuItem=function(e,t,n){var r=!1;if(this.getHostCapabilities().EXTENDED_PANEL_MENU){var i=new MenuItemStatus(e,t,n);r=window.__adobe_cep__.invokeSync("updatePanelMenuItem",JSON.stringify(i))}return r},CSInterface.prototype.setContextMenu=function(e,t){if("string"!=typeof e)return;window.__adobe_cep__.invokeAsync("setContextMenu",e,t)},CSInterface.prototype.updateContextMenuItem=function(e,t,n){var r=new ContextMenuItemStatus(e,t,n);ret=window.__adobe_cep__.invokeSync("updateContextMenuItem",JSON.stringify(r))},define("lib/CSInterface-latest",function(){}),define("lib/CSInterface",["lib/CSInterface-latest"],function(e){var t=new CSInterface;return t.resourceBundle=t.initResourceBundle(),t.SystemPath=SystemPath,t.EvalScript_ErrMessage=EvalScript_ErrMessage,t}),define("localize",["lib/CSInterface","log"],function(e,t){return function(t){if(e.resourceBundle[t]){var n=e.resourceBundle[t],r=1;while(n.indexOf("$"+r)!==-1)n=n.replace("$"+r,arguments[r]),r++;return n}return""}}),define("utils",["lib/CEPGlobals","lib/CSInterface","config","localize","log","window"],function(e,t,n,r,i,s){var o="Photoshop";t.hostEnvironment.appName==="ILST"?o="Illustrator":t.hostEnvironment.appName==="IDSN"&&(o="InDesign"),i.info("Application name is: "+o);var u=s.navigator.platform.toLowerCase().indexOf("win")>-1;i.info("Platform is: "+(u?"Windows":"Mac"));var a=t.getSystemPath(t.SystemPath.EXTENSION);i.info("Extension directory is: "+a);var f="/";u&&(f=t.getSystemPath(t.SystemPath.COMMON_FILES).substring(0,3)),i.info("Root directory is: "+f);var l="com.adobe.behance.shareonbehance.html.extension",c="/tmp/"+l;u&&(c=t.getSystemPath(t.SystemPath.USER_DATA)+"/../Local/Temp/"+l),e.fs.makedir(c),e.fs.chmod(c,511);var h=!1,p=function(e){h=!1,i.info("Pinging "+n.behancePingUrl+" to check internet connection");var t=new s.XMLHttpRequest;t.open("GET",n.behancePingUrl,!0),t.onerror=function(){i.error("Failed to connect to internet"),h=!0},t.send()},d=function(e){i.info("Getting network preferences");var n=t.getNetworkPreferences();i.info("Found network preferences: "+i.stringify(n));if(n&&n.isAppOnline===!1){e.recoverableError(r("Recoverable_error_network_permissions"),r("Recoverable_error_network_permissions_fix_permissions"));return}p(e)},v=function(e){var t=s.document.createElement("a");t.href=e;var n=t.hostname.split(".");return n=n.slice(n.length-2,n.length),{protocol:t.protocol,domain:n.join(".")}},m=function(t){if(!t){i.error("URL is null");return}var r=v(t);if(r.protocol!=="http:"&&r.protocol!=="https:"){i.error("Invalid protocol: "+r.protocol);return}var s=!1;for(var o=0;o<n.whiteListedDomains.length;o++){var a=n.whiteListedDomains[o];if(a===r.domain){s=!0;break}}if(!s){i.error("Invalid domain: "+r.domain);return}var l="/usr/bin/open";u&&(l=f+"Windows/explorer.exe"),i.info("Opening browser to url: "+t),e.process.createProcess(l,t)},g=function(){return h};return{applicationName:o,checkInternetConnection:d,extensionDir:a,isWindows:u,openInDefaultBrowser:m,rootDir:f,tempDir:c,failedToConnectToInternet:g}}),define("aamee",["lib/CEPGlobals","config","log","utils","window"],function(e,t,n,r,i){return{isExtensionEnabled:function(){n.info("Checking to see if AAMEE has the extension enabled or disabled");var s="/Library/Application Support/Adobe/CDI/override.xml";r.isWindows&&(s=r.rootDir+"ProgramData/Adobe/CDI/override.xml");var o=e.fs.readFile(s);if(!o||!o.data||o.data.length===0||o.err!==0)return n.info("Unable to read override.xml, assuming extension should be enabled"),!0;var u=null;try{var a=new i.DOMParser;u=a.parseFromString(o.data,"text/xml")}catch(f){return n.error("Error parsing override file, assuming extension is enabled"),!0}var l=u.documentElement.getAttribute("suppress");if(l==="true")return n.info("Global suppression is turned on, disable"),!1;var c=u.getElementsByTagName("Service");for(var h=0;h<c.length;h++){var p=c[h];if(p.getAttribute("name")===t.aameeServiceName&&p.getAttribute("suppress")==="true")return n.info("Found service specific suppression, disable"),!1}return n.info("Unable to find an entry that suppresses this extension, assuming enabled"),!0}}}),IMSInterface.prototype.addEventListener=function(e,t){window.__adobe_cep__.addEventListener(e,t)},IMSInterface.prototype.removeEventListener=function(e,t){window.__adobe_cep__.removeEventListener(e,t)},IMSInterface.prototype.imsConnect=function(){var e=window.__adobe_cep__.imsConnect();return e},IMSInterface.prototype.imsDisconnect=function(e){window.__adobe_cep__.imsDisconnect(e)},IMSInterface.prototype.imsFetchAccounts=function(e,t){var n=window.__adobe_cep__.imsFetchAccounts(e,t);return n},IMSInterface.prototype.imsFetchAccessToken=function(e,t,n,r,i,s){return window.__adobe_cep__.imsFetchAccessToken(e,t,n,r,i,s)},IMSInterface.prototype.imsRevokeDeviceToken=function(e,t,n,r,i){return window.__adobe_cep__.imsFetchAccessToken(e,t,n,r,i,"REVOKE")},IMSInterface.prototype.imsSetProxyCredentials=function(e,t){window.__adobe_cep__.imsSetProxyCredentials(e,t)},IMSInterface.prototype.showAAM=function(e,t,n,r,i,s){return window.__adobe_cep__.showAAM(e,t,n,r,i,s)},IMSInterface.prototype.imsGetCurrentUserId=function(){var e=window.__adobe_cep__.getCurrentImsUserId();return e},IMSInterface.prototype.imsGetCurrentUserIdHelper=function(e){var t=JSON.parse(window.__adobe_cep__.getHostEnvironment()),n=t.appName;if(n==="ILST")window.__adobe_cep__.evalScript("app.userGUID",function(t){e(t)});else if(n==="IDSN")window.__adobe_cep__.evalScript("app.userGuid",function(t){e(t)});else if(n==="PHSP"||n==="PHXS")window.__adobe_cep__.evalScript("var getUserIdPhotoshop = function() {var userId = '';try {var bhnc = app.charIDToTypeID('bhnc');var ref = new ActionReference();ref.putProperty(app.charIDToTypeID('Prpr'), bhnc);ref.putEnumerated(app.charIDToTypeID('capp'), app.charIDToTypeID('Ordn'), app.charIDToTypeID('Trgt'));var appDesc = app.executeActionGet(ref);if (appDesc.hasKey(bhnc)) {userId = appDesc.getString(bhnc);}} catch (e) {}return userId;};",function(t){window.__adobe_cep__.evalScript("getUserIdPhotoshop()",function(t){e(t)})});else{var r=window.__adobe_cep__.getCurrentImsUserId();e(r)}},IMSInterface.prototype.imsConnectWithEndpoint=function(e){var t={};return t.imsEndpoint=e==undefined||e==null||e==""?"undefined":e,JSON.parse(window.__adobe_cep__.invokeSync("imsConnectWithEndpoint",JSON.stringify(t))).result},IMSInterface.prototype.imsFetchContinueToken=function(e,t,n,r,i,s,o){if(r==undefined||r==null)r="";if(i==undefined||i==null)i="";if(s==undefined||s==null)s="";if(o==undefined||o==null)o="";var u={};return u.imsRef=e,u.bearerToken=t,u.targetClientId=n,u.redirectUri=r,u.scope=i,u.responseType=s,u.locale=o,JSON.parse(window.__adobe_cep__.invokeSync("imsFetchContinueToken",JSON.stringify(u))).result},IMSInterface.prototype.events={imsFetchAccessTokenWithStatus:"com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",imsFetchAccessToken:"com.adobe.csxs.events.internal.ims.FetchAccessToken",imsRevokeAccessToken:"com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",imsFetchContinueToken:"com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",imsAAMIMSStatus:"vulcan.SuiteMessage.com.adobe.aam.AAMIMSStatus"},define("lib/IMSInterface-latest",function(){}),define("lib/IMSInterface",["lib/IMSInterface-latest"],function(e){return new IMSInterface}),define("host",["lib/CSInterface","localize","log"],function(e,t,n){var r=t("Error_generic_scripting");return{evalScript:function(i,s){n.info("Evaling script: "+i),e.evalScript(i,function(i){n.info("Received result from eval script: "+i);if(!i||i.length===0||i===e.EvalScript_ErrMessage){s.error(r);return}var o=JSON.parse(i);switch(o.status){case"success":s.success(o.value);break;case"error":s.error(t(o.message));break;case"recoverableError":s.recoverableError(t(o.message),t(o.subMessage));break;case"cancel":e.closeExtension();break;default:s.error(r)}})}}}),define("ui",["lib/CSInterface","lib/spin","config","localize","log","utils","window"],function(e,t,n,r,i,s,o){var u=!1,a=!1,f=!1,l=!1,c=o.document.getElementsByTagName("body")[0],h=o.document.getElementsByClassName("close-button")[0],p=o.document.getElementsByClassName("proxy-close-button")[0],d=o.document.getElementsByClassName("error")[0],v=o.document.getElementsByClassName("error-message")[0],m=o.document.getElementsByClassName("error-sub-message")[0],g=o.document.getElementsByClassName("help")[0],y=o.document.getElementsByClassName("behance-iframe")[0],b=o.document.getElementsByClassName("loading")[0],w=o.document.getElementsByClassName("loading-message")[0],E=o.document.getElementsByClassName("proxy")[0],S=o.document.getElementsByClassName("proxy-message")[0],x=o.document.getElementsByClassName("proxy-sub-message")[0],T=o.document.getElementsByClassName("proxy-username-label")[0],N=o.document.getElementsByClassName("proxy-password-label")[0],C=function(){return y.contentWindow},k=function(){i.info("generating jump url");var t=e.hostEnvironment,r=n.behanceIFrameUrl;return r+="&extVersion="+n.version,r+="&appId="+t.appName,r+="&appVersion="+t.appVersion,r+="&appLocale="+t.appUILocale,i.info("Initial iframe url before jump "+r),r},L=function(e){i.info("Initializing iframe and pointing iframe to "+e),y.src=e,u=!0},A=function(){i.info("About to display proxy credentials prompt"),f?i.info("Already displaying proxy"):(f=!0,M(),E.style.display="block",i.info("Successfully displayed proxy"))},O=function(){i.info("Starting timeout countdown"),setTimeout(function(){i.info("Checking to see if iframe has been shown: "+l),l||P(r("Error_connection_timeout"))},n.timeout)},M=function(){d.style.display="none",y.style.display="none",b.style.display="none",E.style.display="none"},_=function(){i.info("Attempting to display iframe"),a?i.info("Already displaying error"):(l=!0,M(),y.style.display="block",i.info("Successfully displayed iframe"))},D=function(e,t,n){n=typeof n=="undefined"?"true":n,i.info("ShowFooter: "+n),i.error("Attempting to display recoverable error: "+e),a?i.info("Already displaying error"):(a=!0,M(),v.innerHTML=e,t&&(m.innerHTML=t),n!="false"?(g.innerHTML=r("UI_recoverable_error_footer"),I()):g.innerHTML="",i.info("Successfully displayed recoverable error"),d.style.display="block")},P=function(e){i.info("About to display error"),setTimeout(function(){i.error("Attempting to display error: "+e),a?i.info("Already displaying error"):(a=!0,M(),g.innerHTML=r("UI_error_footer",e),I(),d.style.display="block",i.info("Successfully displayed error"))},100)},H=function(t){t.keyCode===27?(i.info("Caught esc key, attempting to close extension"),e.closeExtension()):t.keyCode===13&&a&&(i.info("Caught enter key while displaying error, attempting to close extension"),e.closeExtension())},B=function(){i.info("Help link clicked, opening browser to help url"),s.openInDefaultBrowser(n.behanceHelpUrl)},j=function(){i.info("Close button clicked, closing extension"),e.closeExtension()},F=function(){var e={lines:30,length:0,width:2,radius:9,corners:0,color:"#1769ff",speed:2,trail:100,hwaccel:!0,className:"spinner",zIndex:2e9,top:"19px",left:"20px"};return(new t(e)).spin(w)},I=function(){var e=o.document.getElementsByClassName("help-link")[0];typeof e!="undefined"&&e.addEventListener("click",B)},q=function(){v.innerHTML=r("UI_error_title_message"),m.innerHTML=r("UI_error_subtitle_message");var t=e.hostEnvironment;t.appUILocale.indexOf("en_")!=0?w.innerHTML=r("UI_loading")+"<br>"+r("UI_entering_english_only_site"):w.innerHTML=r("UI_loading"),h.innerHTML=r("UI_close"),p.innerHTML=r("UI_close"),S.innerHTML=r("UI_proxy_title_message"),x.innerHTML=r("UI_proxy_sub_message"),T.innerHTML=r("UI_proxy_username"),N.innerHTML=r("UI_proxy_password");var n=r("Error_unknown");g.innerHTML=r("UI_error_footer",n)},R=function(){i.info("Initializing UI"),q(),F(),o.document.addEventListener("keydown",H),I(),h.addEventListener("click",j),p.addEventListener("click",j),i.info("Done initializing UI")};return R(),{getIFrameWindow:C,hasInitializedIFrame:function(){return u},hasShownIFrame:function(){return l},initIFrame:L,showIFrame:_,showRecoverableError:D,showError:P,showProxy:A,hideAll:M,startTimeoutCountdown:O,getIFrameUrl:k}}),define("response",["log","ui"],function(e,t){return{create:function(n){return n||(n={}),n.success||(n.success=function(){e.info("Generic success callback triggered")}),n.recoverableError||(n.recoverableError=function(e,n,r){t.showRecoverableError(e,n,r)}),n.error||(n.error=function(e){t.showError(e)}),n}}}),define("ims",["lib/IMSInterface","config","host","localize","log","response","utils","ui"],function(e,t,n,r,i,s,o,u){var a="com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",f="com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus",l="openid,AdobeID,creative_cloud,sao.behance",c="openid,AdobeID,sao.behance,gnav",h=t.imsCi,p=t.imsCs,d=t.imsRu,v=t.imsJci,m=!1,g,y,b,w,E=window.document.getElementsByClassName("proxy-login-button")[0],S=function(e){var t=!1;return e&&e.data&&e.data!=""&&(t=!0),t},x=function(e){var t=!1;if(S(e)&&e.data.status){var n=e.data.status;["20","21","22","23"].indexOf(n)>=0&&(t=!0,i.info("HTTPError: "+n))}return t},T=function(e){var t=!1;if(S(e)&&e.data.status){var n=e.data.status;["24","25"].indexOf(n)>=0&&(t=!0,i.info("ProxyError: "+n))}return t},N=function(e){var t=!1;if(S(e)&&e.data.status){var n=e.data.status;["80","120","122","123","124","125","126","127"].indexOf(n)>=0&&(t=!0)}return t},C=function(e){var t="sso_inbound=1";return e.indexOf("?")==-1?e+="?"+t:e+="&"+t,e},k=function(){i.info("cleanUp");try{e.imsDisconnect(y),i.info("Successfully cleaned up IMS")}catch(t){i.error("Error cleaning up IMS: "+i.stringify(t))}},L=function(t){i.info("Handling fetch continue token callback: "+i.stringify(t)),e.removeEventListener(f,L),m=!0,S(t)&&t.data.details.jump?g.success(t.data.details.jump):g.error(r("Error_fetching_continue_token")),k()},A=function(t,n){i.info("createFetchContinueTokenCall attempting SSO workflows"),e.addEventListener(f,n),e.imsFetchContinueToken(y,b,v,encodeURIComponent(t),c,"","")},O=function(t){i.info("Handling fetch access token callback: "+i.stringify(t)),e.removeEventListener(a,O),S(t)&&t.data.details.access_token?(b=t.data.details.access_token,A(u.getIFrameUrl(),L)):T(t)?(u.showProxy(),k()):!S(t)&&o.failedToConnectToInternet()||x(t)?(g.recoverableError(r("Recoverable_error_connecting_to_Behance"),r("Recoverable_error_connecting_to_Behance_check_internet")),k()):(N(t)?w.toLowerCase().indexOf("adobeid")==-1?g.recoverableError(r("Recoverable_error_connecting_to_Behance"),r("Error_ims_access_denied_enterprise"),"false"):g.error(r("Error_ims_access_denied")):g.error(r("Error_fetching_access_token")),k())},M=function(n){i.info("Connecting to IMS"),y=e.imsConnect(h),i.info("Connected to IMS, with ims reference: "+y),e.addEventListener(a,O),i.info("Getting current user id"),e.imsGetCurrentUserIdHelper(function(s){i.info("Received userId: "+s),s===null||s.length===0?(k(),n.recoverableError(r("Recoverable_error_not_signed_in"),r("Recoverable_error_not_signed_in_therefore_sign_in",o.applicationName))):(i.info("Found a user, fetch access token"),g=n,w=s,e.imsFetchAccessToken(y,h,p,s,"",l),setTimeout(function(){m||n.error(r("Error_fetching_access_token"))},t.fetchAccessTokenTimeout))})},_=function(t,n){i.info("Setting Proxy Credentials"),y=e.imsConnect(h),e.imsSetProxyCredentials(t,n),k()},D=function(n){if(n.indexOf(t.behanceDomain)==-1||!m&&b===null&&b.length===0)o.openInDefaultBrowser(n);else{y=e.imsConnect(h);var r=function(t){i.info("Handling fetch continue token: "+i.stringify(t)),e.removeEventListener(f,r),S(t)&&t.data.details.jump?o.openInDefaultBrowser(t.data.details.jump):o.openInDefaultBrowser(n),k()};new_url=C(n),i.info("attempting SSO workflows for url "+new_url),A(new_url,r)}},P=function(){i.info("Login button clicked, retrieving credentials and passing to IMS");var e=window.document.getElementById("proxy-username").value,t=window.document.getElementById("proxy-password").value;_(e,t),u.hideAll(),document.title=r("UI_share_on_Behance"),window.document.getElementsByClassName("loading")[0].style.display="block",M(g),cleanup()},H=function(){E.innerHTML=r("UI_login"),E.addEventListener("click",P)};return H(),{getAccessToken:M,setProxyCredentials:_,getSSOUrl:D}}),define("message",["lib/CSInterface","config","log","ui","utils","window","ims"],function(e,t,n,r,i,s,o){var u=!1,a=[],f=function(e){n.info("Attempting to send message of type: "+e.type);if(u){n.info("Behance iframe is ready, sending message");var i=r.getIFrameWindow();i.postMessage(JSON.stringify(e),t.behanceDomain)}else n.info("Behance iframe is not ready, queueing message"),a.push(e)},l=function(){n.info("Flushing queued messages");for(var e=0;e<a.length;e++)f(a[e]);a=[]};return s.onmessage=function(i){if(t.behanceDomain!==i.origin){n.info("Unable to respond to message from domain: "+i.origin);return}if(i.source!==r.getIFrameWindow()){n.info("Unable to respond to message from different iframe window");return}var s=JSON.parse(i.data);if(s){n.info("Received message: "+n.stringify(s)+", from origin: "+i.origin);switch(s.type){case"close":e.closeExtension();break;case"openBrowser":o.getSSOUrl(s.url);break;case"ready":r.showIFrame();break;case"readyAcceptImage":u=!0,l()}}},{sendWip:function(e){f({type:"wip",image:e})}}}),define("wip",["lib/CEPGlobals","host","localize","log","response","utils"],function(e,t,n,r,i,s){var o={},u=function(e){var t=e.split(".");return t.length>1&&t[t.length-1].length>0&&t.pop(),t.join(".")},a=function(t){var n=null;try{r.info("Reading file: "+t),n=e.fs.readFile(t,e.encoding.Base64).data.replace(/\s/g,""),r.info("Successfully read file")}catch(i){r.error("Error reading file")}return n},f=function(t){try{r.info("Deleting file: "+t);var n=e.fs.deleteFile(t);!n||n.err!==0?r.error("Error deleting file"):r.info("Successfully deleted file")}catch(i){r.error("Error deleting file: "+r.stringify(i))}};return o.isLoaded=function(){return o.value&&o.value.length>0},o.load=function(e){r.info("Loading wip module");var l=s.tempDir+"/wip.jpg";r.info("Saving temporary image to "+l),t.evalScript("saveActiveDocument('"+l+"')",i.create({success:function(t){r.info("Received callback from evalScript: "+t);if(t===null){e.error(n("Error_saving_document"));return}r.info("Successfully saved active document"),o.mime="image/jpeg",o.encoding="base64",o.title=u(t),o.value=a(l),f(l),o.value&&o.value.length>0?(r.info("Successfully read WIP, sending to iframe"),e.success()):e.error(n("Error_reading_document"))}}))},o}),require(["aamee","ims","localize","log","message","response","ui","utils","wip"],function(e,t,n,r,i,s,o,u,a){var f=function(){a.load(s.create({success:function(){i.sendWip(a),o.hasInitializedIFrame()&&o.startTimeoutCountdown()}}))},l=function(){r.info("Starting Behance extension"),document.title=n("UI_share_on_Behance");if(!e.isExtensionEnabled()){o.showError(n("Error_extension_disabled"));return}u.checkInternetConnection(s.create()),t.getAccessToken(s.create({success:function(e){r.info("Successful retrieval of iframe url"),o.initIFrame(e),a.isLoaded()&&o.startTimeoutCountdown()}})),setTimeout(f,100)};l()}),define("main",function(){});