// Your Script Configurations
var script_name = "Flash Rush";    // Change this to your script name.
var script_setting_name = "flash_rush_license_data";    // Change this to the application setting name where you want to save the license data.

// LicenseBox Configurations
var lb_server_url = "http://mikesreda.net/licensebox/";     // Change this to your LicenseBox server url e.g http://example.com/license/ (don't forget the ending slash and only use http://)
var lb_product_id = "623BF422";    // Change this to your product id, you can find it in the manage products page of your LicenseBox admin panel
var lb_api_key = "384382496BAD0275D071";    // Change this to any of the available LicenseBox client/external API keys

// JSON Library Start (Don't Edit)
if(typeof JSON!=="object"){JSON={}}(function(){"use strict";var rx_one=/^[\],:{}\s]*$/;var rx_two=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;var rx_three=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;var rx_four=/(?:^|:|,)(?:\s*\[)+/g;var rx_escapable=/[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;var rx_dangerous=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;function f(n){return(n<10)?"0"+n:n}
function this_value(){return this.valueOf()}
if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?(this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"):null};Boolean.prototype.toJSON=this_value;Number.prototype.toJSON=this_value;String.prototype.toJSON=this_value}
var gap;var indent;var meta;var rep;function quote(string){rx_escapable.lastIndex=0;return rx_escapable.test(string)?"\""+string.replace(rx_escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+"\"":"\""+string+"\""}
function str(key,holder){var i;var k;var v;var length;var mind=gap;var partial;var value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}
if(typeof rep==="function"){value=rep.call(holder,key,value)}
switch(typeof value){case "string":return quote(value);case "number":return(isFinite(value))?String(value):"null";case "boolean":case "null":return String(value);case "object":if(!value){return"null"}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}
v=partial.length===0?"[]":gap?("[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]"):"["+partial.join(",")+"]";gap=mind;return v}
if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==="string"){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+((gap)?": ":":")+v)}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+((gap)?": ":":")+v)}}}}
v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}
if(typeof JSON.stringify!=="function"){meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\"":"\\\"","\\":"\\\\"};JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else if(typeof space==="string"){indent=space}
rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}
return str("",{"":value})}}
if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k;var v;var value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}
return reviver.call(holder,key,value)}
text=String(text);rx_dangerous.lastIndex=0;if(rx_dangerous.test(text)){text=text.replace(rx_dangerous,function(a){return("\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4))})}
if(rx_one.test(text.replace(rx_two,"@").replace(rx_three,"]").replace(rx_four,""))){j=eval("("+text+")");return(typeof reviver==="function")?walk({"":j},""):j}
throw new SyntaxError("JSON.parse")}}}())
// JSON Library End

// JSON Parse Library Start (Don't Edit)
var json_parse=(function(){"use strict";var at;var ch;var escapee={"\"":"\"","\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};var text;var error=function(m){throw{name:"SyntaxError",message:m,at:at,text:text}};var next=function(c){if(c&&c!==ch){error("Expected '"+c+"' instead of '"+ch+"'")}
ch=text.charAt(at);at+=1;return ch};var number=function(){var value;var string="";if(ch==="-"){string="-";next("-")}
while(ch>="0"&&ch<="9"){string+=ch;next()}
if(ch==="."){string+=".";while(next()&&ch>="0"&&ch<="9"){string+=ch}}
if(ch==="e"||ch==="E"){string+=ch;next();if(ch==="-"||ch==="+"){string+=ch;next()}
while(ch>="0"&&ch<="9"){string+=ch;next()}}
value=+string;if(!isFinite(value)){error("Bad number")}else{return value}};var string=function(){var hex;var i;var value="";var uffff;if(ch==="\""){while(next()){if(ch==="\""){next();return value}
if(ch==="\\"){next();if(ch==="u"){uffff=0;for(i=0;i<4;i+=1){hex=parseInt(next(),16);if(!isFinite(hex)){break}
uffff=uffff*16+hex}
value+=String.fromCharCode(uffff)}else if(typeof escapee[ch]==="string"){value+=escapee[ch]}else{break}}else{value+=ch}}}
error("Bad string")};var white=function(){while(ch&&ch<=" "){next()}};var word=function(){switch(ch){case "t":next("t");next("r");next("u");next("e");return!0;case "f":next("f");next("a");next("l");next("s");next("e");return!1;case "n":next("n");next("u");next("l");next("l");return null}
error("Unexpected '"+ch+"'")};var value;var array=function(){var arr=[];if(ch==="["){next("[");white();if(ch==="]"){next("]");return arr}
while(ch){arr.push(value());white();if(ch==="]"){next("]");return arr}
next(",");white()}}
error("Bad array")};var object=function(){var key;var obj={};if(ch==="{"){next("{");white();if(ch==="}"){next("}");return obj}
while(ch){key=string();white();next(":");if(Object.hasOwnProperty.call(obj,key)){error("Duplicate key '"+key+"'")}
obj[key]=value();white();if(ch==="}"){next("}");return obj}
next(",");white()}}
error("Bad object")};value=function(){white();switch(ch){case "{":return object();case "[":return array();case "\"":return string();case "-":return number();default:return(ch>="0"&&ch<="9")?number():word()}};return function(source,reviver){var result;text=source;at=0;ch=" ";result=value();white();if(ch){error("Syntax error")}
return(typeof reviver==="function")?(function walk(holder,key){var k;var v;var val=holder[key];if(val&&typeof val==="object"){for(k in val){if(Object.prototype.hasOwnProperty.call(val,k)){v=walk(val,k);if(v!==undefined){val[k]=v}else{delete val[k]}}}}
return reviver.call(holder,key,val)}({"":result},"")):result}}())
// JSON Parse Library End

// Adobe JS-HTTP Library Start (Don't Edit)
var $http=(function(){return function(config){var url=(/^(.*):\/\/([A-Za-z0-9\-\.]+):?([0-9]+)?(.*)$/).exec(config.url);if(url==null){throw "unable to parse URL"}
url={scheme:url[1],host:url[2],port:url[3]||(url[1]=="https"?443:80),path:url[4]};if(url.scheme!="http"){throw "non-http url's not supported yet!"}
var s=new Socket();if(!s.open(url.host+':'+url.port,'binary')){throw 'can\'t connect to '+url.host+':'+url.port}
var method=config.method||'GET';var request=method+' '+url.path+" HTTP/1.0\r\nConnection: close\r\nHost: "+url.host;var header;if(config.payload){if(typeof config.payload==='object'){config.payload=JSON.stringify(config.payload);(config.headers=config.headers||{})["Content-Type"]="application/json"}(config.headers=config.headers||{})["Content-Length"]=config.payload.length}
for(header in(config.headers||{})){request+="\r\n"+header+': '+config.headers[header]}
s.write(request+"\r\n\r\n");if(config.payload){s.write(config.payload)}
var data,response,payload,http={};data=s.read();while(!s.eof){data+=s.read()}
var response=data.indexOf("\r\n\r\n");if(response==-1){throw "No HTTP payload found in the response!"}
payload=data.substr(response+4);response=data.substr(0,response);var http=/^HTTP\/([\d\.?]+) (\d+) (.*)\r/.exec(response),header;if(http==null){throw "No HTTP payload found in the response!"}
http={ver:Number(http[1]),status:Number(http[2]),statusMessage:http[3],headers:{}};var httpregex=/(.*): (.*)\r/g;while(header=httpregex.exec(response)){http.headers[header[1]]=header[2]}
http.payload=json_parse(payload);return http}})()
// Adobe JS-HTTP Library End

// Calculate HWID Function Start
function calc_hwid(_data){
    var b64 = "bcdefghijklmnopqrstuvwxyz123456789";
    var o1, o2, o3, h1, h2, h3, h4, bits, i=0, enc='';
    function encode( __data ) {
        do {
            o1 = __data.charCodeAt(i++);
            o2 = __data.charCodeAt(i++);
            o3 = __data.charCodeAt(i++);
    
            bits = o1<<16 | o2<<8 | o3;
            h1 = bits>>18 & 0x3f;
            h2 = bits>>12 & 0x3f;
            h3 = bits>>6 & 0x3f;
            h4 = bits & 0x3f;
    
            enc += b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
        } while (i < __data.length);
    
        switch( __data.length % 3 ){
            case 1:
                enc = enc.slice(0, -2) + 'aa';
            break;
            case 2:
                enc = enc.slice(0, -1) + 'a';
            break;
        }
        return enc;
    };
    return encode(_data).replace(/[^A-Za-z0-9]/g, '');
};
// Calculate HWID Function End

test_network();   

function test_network(){
    var mac = "Please allow scripts to access network:\nAfter Effects -> Preferences -> General -> Allow scripts to write files and access to network";
    var win = "Please allow scripts to access network:\nEdit -> Preferences -> General -> Allow scripts to write files and access to network";
    var temp, ret;
    try{
    temp = new Socket();
    ret = true;
    }catch(err){
    alert((($.os.indexOf('Windows')>=0)?(win):(mac)), script_name + " - Network Error");
    ret = false;
    };
    temp = 0;
    return ret;
};


function activation_dialog() {

    var licenseWin=new Window("dialog", script_name + " - License Verification",[0,0,318,400]);
    MainPanel=licenseWin.add("panel",[0,0,318,400]);
    downloadsImgImage="\u0089PNG\r\n\x1A\n\x00\x00\x00\rIHDR\x00\x00\x01\x16\x00\x00\x00\u00A9\b\x03\x00\x00\x00\u00D9x\u00E2i\x00\x00\x02\u00FAPLTE\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\u00FF\u00FF\u00FF\u00F5\u00F5\u00F5z\u00A9<\u00E0\u00E0\u00E0\u00D4\u00D4\u00D4o\u009A7\u00FF\u00E8\u00B4\u00EB\u00FF\u00FF\u00E7\u00FF\u00FF\u0080\u0080\u0080\u00FF\u00FF\u00CF\u008F\u008F\u00B3\u00CF\u00FF\u00FF\u00FF\u00EA\u00ADcc\u00AD\u009F\u0080\u009F&&'\u00FF\u00FF\u00E1\u00F8\u00FF\u00FF\u00FF\u00FE\u00E8\x03\x06\x1A\u00FE\u00FE\u00FC\u00B4\u00E6\u00FF\u0084&\u0084\u00F6\u00E9\u0091\u00CC\u00AA<z\u00A9\u00B5\u00D7\u00FF\u00FF\u00FF\u00FF\u00F1\u00E8\u00E8\u00E9\u00FF\u00F8\u00CB\u00DC\u00F7\u00FF\u00AD\u00E9\u00FF\u00BA\u00E2\u00FE\u008E\u0085\u009F\u00EB\u00B8\u0090\u00D0\u00E0\u00BB\u0080\u008E\u00B3\u00E3\u00FF\u00FF\u00C8\u00F8\u00FF\u00F0\u00D5\u00A8\u00F1\u00BBr\u00AD\u00DD\u00F9\u00FD\u00D5\u00A1\u0080\u0081\u008E\u0090\u00B5\u00E9\u00FF\u00DF\u00AF\u0080\u008A\u0099\u00EB\u00B4d\u00FF\u00FF\u00F8\u00FF\u00FF\u00D8\u00E7\u00B3\u008F\u008F\u0083\u0080\u00F2\u00FF\u00FF\u00B3\u00DF\u00F8\u00CD\u00F4\u00FFk2c\u0081\u009F\u00CD\u00FF\u00E2\u00A6\u00F2\u00CD\u009F\u00EA\u00ADcc:,\u00FA\u00FA\u00FA\u0084\u0091\u00B1\u00EF\u00BB\u0093\u00DF\u00B2\u008F\u00EF\u00FF\u00FF\u00C1\u00F8\u00FF\u00EE\u00EF\u00EF\u00CA\u00CB\u00CE\u0081\u009C\u00C7\u00FF\u00F2\u00BB\u00FF\u00EC\u00BB'c\u00AEW@\u00821S|GIW\u00EB\u00F3\u00E2\u0081\u00A4\u00D4\u00E3\u00B8\u0095'&c\u00AC\u00E5\u00E9\u0087\u00B2\u00E0\u00ED\u00C4\u0099\u00B0\u008F\u0081\u00E3\u00B3q\u00ACae\u00C0\u0081M$'6;,)\u00BC\u00F0\u00FF\u00A1\u00D2\u00FA\u00F1\u00F1\u00F1c\u00AE\u00EA3~\u00C8\u00D5\u00F5\u00FF\u00CA\u00F1\u00FE\u009C\u00C8\u00F4\u00D3\u00E8\u00EF\u0081\u00DF\u00E1S\u00A4\u00DA\u00FF\u00F2\u00D6,\u008B\u00CF\u00AA\u0087\u009DcE\u0099\u00B2\u008E\u008F\u0093\u0080\u008F\u008F\u0080\u008Dz\u00B4\u008C\u009D\u008E\u0086+;t\u00E1\u00FD\u00FF|\u00D4\u00D5*\u0082\u00CC\u00F3\u00D4\u00AC\u008F\u0089\u00A7\u008A\u0082\u0080\u00B4\u00AA<\u00B1\u00CF\u00B1?c\u00A9\u0080\u0083\u0093\u009F\u0080\u0080\u00C5\u009D\x7F\u0082*t\u00E3\u00ADb\u00DA\u00C9<\u008A\u00A9<\u00AAc+Q6*3&&\u00A5\u00D8\u00FF\u00E2\u00E2\u00E2\u00DA\u00DA\u00DA\u00AA\u00D0\u00D9C\u0083\u00C6\u00FE\u00F1\u00C4\u0081\u0093\u00BB\u008D\u0080\u00A8z\u00AA\u00A2\u00D5\u00A9\u0086\u00F8\u00C8\u0084z\u00AAt\u00E0\u00A8a\u00D5\u00CAZ\u00EB\u00F8\u00FF\u0081\u00C7\u00F6\u00B3\u00E9\u00F2\u00F8\u00EC\u00D5\u00F2\u00E0\u00C3:p\u00A6\u009D\u0080\u0093\u00CA\u009F\u0088\u00ED\u00E3\u0087\u00E7\u00BB\u0080\u0099A~\u00D3\u00FF\u00FF\u00AB\u00CF\u00EF\u00AA\u00B5\u00B1\u00A0\u0080\u009A\u00AD\u00A1\u008B\u00BB\u009B\u008B\u00E1\u00B1\u008Ad^\u0084uw\u0081\u00EC\u00E0l\u008F\u00AEf\u00D9\u009FPv\u00A3=\u008F\u00A4\u00CE\u00AC\u00C3\u00CA\u0080\u00CB\u00C3\u0089\u009E\u00B6\u00A0\u0095\u00B3\u0082\u008E\u00A8\u009A\u0088\u00A6\u0088\u0086\u0096\u00FD\u00CF\u008524bz\u00A9`ACQ\u0098\u00A9<\u00C3\u00EB\u00FEs\u00BC\u00EF\u00DA\u00E9\u00E5\u009B\u00B9\u00E1\u00D5\u00E1\u00C6\u0093\u0095\u00BB,p\u00BB\u008A\u00C1\u00ADPc\u00AD\u00D5\u00B3\u00A2\u0095\u0097\u00A2\u0080\u0080\u009E\u00AD\\\u0099\u00E3\u00B3\u0097l,\u0088\u00A6\u008A\u0086\u00DD\u00D9\x7F\u0098\u00BBi&3U\u008DtR|\u00ABNc&L\u00A5\u00A9<\u0099\u00D4\u00FD\u0086\u00CF\u00FD\u009C\u00E4\u00E6d\u00AE\u00E4A\u0099\u00D6\u00B1\u00E0\u00C8\u00C2\u00C2\u00C7ox\u00BBW\u0082\u00B4\u00FC\u00E7\u00AD\u00AF\u00A3\u00A3\u009D\u00AF\u00A1\u0082L\u0092\u00D1\u00DB\u0091OJ\u0080\u00B6\u0094\\\u00ED\u00E0T\u00BCz/o'+\u0088b*\u00C0\u00DA\u00CE\u00E7\u00F9\u00CDz\u00BE\u00BCpp\u00B4\u00E7\u00E7\u00AE:U\u00A0\u00F7\u00C7\u009B\u008A\u009F\u00910f\u008E\u009Da9\u00CF\u00FF\u00DF\u00DD\u00D1\u00B5\u00CF\u00DF\u00AF\u00FA\u00EC\u00A3pU\u0099cww\u00BBp\\wUGB\u00EC\u00BA\u0082\x00\x00\x00\ftRNS\x03\b\x12\x1FK\x00.D;\f\x19*\u00E8GU\x18\x00\x00\x0B\u00BDIDATx\u00DA\u00EC\u00DAIh\x13Q\x18\u00C0\u00F1\u00A4\u00E2!\u00F2\u00CDh\u0096\u00A9\u0091\u0092\t\u0095Fc\u0082m\u00A2\u00E2J\u00E3\u0086xP\u0083\u00A8\x17\u0091hOzH\u00AB\x14A#\x067TH\x0FBq#(*\x1AP\\\u00C0P7\x14\u00A4R\u0095\u00A2\"Z(\u0082\u00E0E(xP\x11\x0F.7\u00BF7\u0099\u00CE4\u00E5E\u008D#tf\u00F2\u00FD\u00A1\u009D\u0092y\u0097\u00F7\u00EB{o\u00E6\x10\u00C7xL\u00A0\u00F4\u00C6\u00B3\u0088\u00A5\x12\u008B\u00C3!Pz\x0E\x07cA\x15\u00A7@\u00E99\u00D1\u0085\u00B18]\x02\u00A5\u00E7r*;\u00C8\u00E1\u00AA\x13(\u00BD:\u0097C\u00D9B\u00AE\t\x02\u00A57\u00C1\u00E5TX\u00EA\u0088\u00A5\u008C\u00A5Ne\x19'Pz\u00E38,\u00B1\u0081A\u00D1\\\r<\x11\ff\u009C%&\u009A0\u00A3.\u00C6Y\x06D\x136 \x18\u00CB8\u008Bh\u00CA\u0084?G,\u00DC\u0088\u0085\x1B\u00B1p#\x16n\u00C4\u00C2\u008DX\u00B8\u008D!\u00CB4/`\u00E1B\u00AF\u00F8\u0087a\u0081\u0090\u00C8m\x074\u00D9\u0096\x05\u00A0\u00A9\u00EB\u00FF\u00B0dbjC\u00BD\u00D6f\u00C1\u00F9\u00E6Sr0'f\u00B6\u00CB\x10|\u00DD\u0095\u008F\u00E2\u00DF\u00E7`}\u00D7\u00A9\u00BD\u0081g\u00DE`\u009F\f\u00C7\x0F\u0096\u0086\u00A9\x03\u00C4\u00C1n\x19 pF\x14\u00EF\u009C\u0085@_9\u00CBg\u0095\x19\u00D6[\u009FE\x1Cl\u0087\x0F\u00F9v\u00C0Zo\"\u00C9\u0087|\x1A\x12\u00A1\u00AC\u00BC\u00FEni\u00927\u0095a\u00DA\u0080;K\x01;\u00DE{j/`\u00A36\u00D1[P\n\u00E6,\u00BE\u0089\x18\x0BR4e\u00E5\u00E0\u0099\u0087)\u0088\x1C\u00CC\u00CASpk\u0085s)\u00B8\u0089\u00D7Bq94)\u00C3\u00B4\x01\u00CA\u00DE\u0091q .\u0099Lt\x14\x0B~\u00C0*X\u00FDl\x19fI\u00B1\u00F9\u00E1\u00C6\t\u009D\u00F2%>\u00CA\x1B\u00E5\u00C2\u00F2`N\u00B9\u00BBCe\u00D1\x06\u0088\u0099\u008F3d\u00E4\u00C1\x0F8G.[Kx\u00D3\x0E,l\x13\u00BD\u00D5f\u00FD(\u00BC6\u00FC\u00DD\u00DB\u00E9\u008B\x1C,c\u00D1\x06\u00DCY\u00DA9\u00D4-\u00F3Y\x14b\b\u009F\u00B1\u00FC\u0093\b'\u00FE\u00B0\x1B\u008F\u00DC\u00E1=\u00F2\x06g\n\u0089\u00A3iP54\x16m\x00.\u00ADb\n8\u009BH\u00DBF?\u00BB,\u00CF2\u00FC\u0080\u00CE\u00A7\u00D5\x13U\u00FC\u009C\u00C4\u00E7\u00D09h\u00CD\u0095\u00B3h\x03R\u0080!\x0B\u00F7\u00C8\u00C5\u00B2\u0089\u0090=\u00DE[\u0082\u00F8:\u00A7=\x7F\u00C5|\x14\nbVN\u0084\u00CAY\u00B4\x01\u00994\u0084\x0B\u00E9`\u008E=\u00A0\u0083}\u00B6|\u009D\u00FB\u00BF\u00F5\u00F7m\u00D4\u00FB\u00F2F\u00ACXm\u00B1\u00B4\u0083\x1E\u00DB\u0084\x15\u00AB-\u0096\u00FE\u00D8\u0088\u0086h\u00B5\u00F0#\x16b!\x16=b\u00E1f?\u0096\x1E\u00D1\u0084\u00F5\b\u00C62\u00CE\u00E2\x16M\u00D8\u00D8\u00B3\x14\u00DD\u00A6[/=\u00EE\u00A2`,\u00E3,1\u00B7\t\x1B\u00FBo,\b\u00B1b\u008F\u00DB\\\x15M\u00F0\u00FD\u0096I5\u00DB\u00EFY\u00A0F#\x16b\u00A9\u0082e\u00E2\u00C4\u0089\u00C4B,\u00C4B,\u00C4\u00C2\u008BX\u00B8\x11\x0B7b\u00E1F,\u00DC\u0088\u0085\x1B\u00B1p#\x16nc\u00C7R\u00BF\u00F3\n`s\u00EE\u00FB\u00A1\u0094g\u00B2o\u00C4\u00DD#\x12\x16\u00FF2\u00D97\u00F2\u00E3\u0097\u00DB@)ro\x16X\u00AB\u00BFg\u00B9\u00F8\u00FC2\u00FE\u00DE\u00D3\u00EC\x07N\u00F5\r\x1C-\u00CFS/\u0094jY\x00\u00D6\u00EA\u00EFY\x1A\u00AE\u00E1\u00FF\u00FEk\x7F\u0083\u00BFq\u00D3\x01i\u00FE\x156\x7FO\u00F35\u00E9\u00F02\u0095E5a,\u00FB\u0096H\u00AB\u00A2\x00\u00A7\u00B7A\u00E0\u00BA4\u00FF1@\u00E4\u00FEe\u00B0TU\u00B0\u00FC\u00B8\x05\u00AD\u0097\u00DE5\u00F8\x176\u00B77\u00AE\u0089{\x19\u00C1\u00EE\u008E\u00C65'\u0092\u00A3Y6\u00ECZ\u00D6\u00B8f\u009D\\\x7Fu6\u00AC^\u0091<~q+\u00B4\x1E=\x06\u0096\u00AA\n\u0096o;gG\u00EE}*\u00CD\x7F^\u00DC\u00C7\bNNg\x12\u00C3g\u00CB\x0B\x7F\u0089\u00A5e\x05@b\u00E7l\u00CF\u00E4Y\u00B0eQ\u00F7Y\u00C0nXl\x17U\u00C1\u00E2?\u00DD\u00B1z3^\u00E0\u00C2\u00FB=\u0092\u00C2\u00C2H\u00F0g\u00F4jY,a\u00F3\u00A7.\u00C4;\u00E1g\x07\u00A4\u00BBQ\u0080\u00C56f\u0099w\u00B7m.\u00BB<\u00B8\u00BD}\u00E5\u00EFXZ6\x03\u008B\u00AD\x16\u00EC|\u00DB\x02{\u00AF\u0096\u00FAW\u00F1\u00BDxiY\u0091\u00ECl\u008B\u00CF\u00AA\u00CC\u00E2\u00D9\u00BD\f\u00E6\u00EC\u009F\u00CE\u00CE\u0096\u00C5\u00EB\u0092\u00E1\u00A3\x1D\u00B6>[\u00FCpi3\u00BBt\u00B6I\u008B\x0E5\u00FB+\u00B3\u00C0\u009C%\u00D2\u00A2\u0099\x00\u00A7;\u00D8\u0093H\u00BA\u00E5\u00B5\u00F1\u0093\u00E8\x1F\u00DAP\x03\u00EF-UTKo\u00B9\u00B5\x15\u00B1\x10\x0B\u00B1\x10\x0BF,\u00DC\u0088\u0085\x1B\u00B1p#\x16n\u00C4\u00C2\u008DX\u00B8\x11\x0B7b\u00E1F,\u00DC\u0088\u0085\x1B\u00B1\u00FCb\u00D7\u00CAZ\u009B\n\u00A2\u00F0\x1F\u00B8\"$\u008D\u00A6z\u00D3\u0090\u00F8\u00D0\u00A0Q1\u00DA\u00C5\u00DA\u0088!.\x15\u0097\u00E2\u00D2\u008Ak\u00B5\u00B5)\u00AE\u00B8C+jiE\u00856>TE\x11\u00C4\u008D\u00BA \u00FA\x10\x14\x14\u00ED\u0083\u00BE\u00A8\u00E0\x06-b\u00A9\u00A2E\u00B1X\u00F1\u00C1\u00ED\u00C5\x05<s\u00E7K&\u008Cc\u00B1ID\ns\u00C0{\u00CD\u009C\u00F3\u009D3\u00F3\u00E5\u00DC\u0099\u00B6\u00F7S\u009A\u00A6Ei\u009A\x16\u00A5iZ\u0094\u00F6\u00FFh\x11\x7F\u00DBO\u00A9\u008Ek\u00AB\u0093A\u00E78&\u00D1Ur\x18\u00C2|G\x1D7\u00C2}\u00A4\u00E9\u00EF\x04\u00E4\u00F0G5\\[q5d\u00DD\u00F7^H\u0088->\\\x0F\u00A4JK\u00EA\x06\u00B8{{\u00BE\u00CA!\u00AC`V\u00E0\u00F2\u0092\x7FC\x0B4\x14V\u00BD\u00CDO\x0EZ\u00F7S\u00B55\u0098\x00\u00DEN\u00A4\u00D3-K\u00D9[ \u00C8\x12\u00B8h\x01\u00CA\x04\u008C\u0091I1\u00B5\x0Fj\x1D\u0085\rC\x17\u00AFt8.\u00C6\x13p\u00E1\u0083{%\u00BD\u0096\x05\u008C\u00BF\u00DB\x1E\u00CBi\u00B1\u00ED\u00B9\u00C4\u00A2\u00F0*\u008A\u00A5p2\u00985\u00BE7\u008E\u00EE\u00A3\u00EE\u008Du\u0086QQ_\u00F8\u009A\u00F0\u00C2{\x14,\u00D0[N~/8<\u0097\u00FF\x07\u00AA\u008A4h)\x1A\x13\u00AE\u0098\u009F\x03Y\x02D\x0B\\\u0099\u00801\n\u0093b\u00F2=\x04'\u00A8{\u00BB7\u0091\x00\u00C2\x07r\b\u0098\u00E1Z\u00F9yO\u0098\u00D32e\u0085\u00A7b\u00DCN\u00D0\u00C2Rp\u0098m\u008AU\x10\u00E8?\u00D6\r\u00CE9l\u00B7\u008D\u00B9\u00ED\u00DE7.Kx\u00E9='_\u00C7\u00A1Z\u00D6-\u008C\u008B\u00E1N,\fo>S\u00A7e\u00B6\u00F5uB\u0096\x00\u00D1\x02W&`\u008C\u00BC\u00BF\u00C5$\u00D1\u0082\x04h\x0Er\b\u0098\u00B1\u00BB\u00D6\u00B1\x01\u00FDN\u00FA\"\u0097\x15n@\x1B\u00C1a(\b\u00B4\u00BA\u00EE\u00ECiL\u00A6\x14a}W4+\x0B^\u00BC\x15g[\tuX\u0088\u00AF\u0087\u00AE\x10[\u00B0\x0EJ\u008B\x16\u00AE>\u0080,\x01\u00D3\u00E6\u00CA\x04\u008C\u0091W\u008EI\u00A6\x05\t | \u0087\u0080\u00D1\u00F7;\u00A3\u00F0\u00C5\u0099\u00F5xZy8^\u00E1\"'\x06\u0080V\u00D4\u00C5\u0095\u00B0tc\u00A1\u00C2[D\u00B8xsH\u00DD\x02T\u00DA\u00DD\x02Y\x02f\u00C9\u0095\t4\x06\u0093c\x14\u00DD\x02\u00E1\x039x\x18\u00DA\u008B\u00B8\u009C\u0096cu\u00C5y\u00DE-\x01\u00F6\u008D\x13\n9Q\x10h\u00A9\u00AE\u00B2[\u0084\u0097\u0092I\u00B4|\x12{\x0B\u00BA%\u009D\u00BDe\u00C6\u00AC\u00B8,\x01\u00B3\u00E4\u00CA\x04\u008CQ\u0098\x1CC\u008Fu)h\u0089'\u0080\u00F0\u00819\x04\u00EC\u00A67XQ?ng|o9l_\u00B8#\u00DFw\u00D6R\u008D '\n\x02\u00AD\u00AE\u008B\u00BD\u0085n\f\x0B/\u00F6\u0096dZ<8\u0089R\u00DF[p\u00BC\u00D7\u00F0\u0093\u0088\u008E\x02\u00C8\x120K\u00AEL\u00C0\x1839\u00C6}\u00B6\u00B0\x01\u00B4 \x01\u0084\x0F\u00E4\u00F0\nXE\u00BD\u00E3\u00C6\u00C6\u00B3\u00B4\u00BD\u00B0#\u00CE:M\u0096\u00D6\x17^\u00E4\x0F\x11\u0087\u00A1 \u00D0\u00EA\u00BA8\u0089h\u0098a\u0085\u00974\x14`\x01\u00EB\u0099t\u0081\u00F3\u0083\u0093h\x00\u00FC\u0094\u00CB\u0096\u009Fi\u0083\u0086Bmc'\x0E\u0084\x1F\u00FE3O\x0B4\x14\n\u0083\u00AAb \u00D0\u00D2o\u00D3\u00BF*\u00FEf\u009A\x16\u00A5iZ\u0094\u00A6iQ\u009A\u00A6Ei\u009A\x16\u00A5iZ\u0094\u00A6iQ\u009A\u00A6Ei\u009A\x16\u00A5iZ\u0094\u00A6iQ\u009A\u00A6Ei\u009A\x16\u00A5iZ\u0094\u00A6iQ\u009A\u00A6Ei\u009A\u0096\u00F4,\u00F3\u008A\u0085\x11Nv\u00CB\x1EfOM\u00B1\u00F0\u00D0\u00C9\u00A0\u00C7\u00A3_\u00E8*9\fa\u00C1X\u00F4c\x1F\u008A\u0085~O@\x0E_\u00D5I\u00F5\u00E4\u00FA#\u008F\x04\u00D2\u00A2%u\x03\u00DC]\u00E9W9\u0084\x154\x06b[\u00FE\x1D-\u00B6\u0097!QO\u00D4\u00CF\u00BB\u0093\u0089nYU\u00BDh4\u00AD`\u00A6yz\u0094\u0091}\u00A5#Z\u0097o\u00B8\u00AA\u00A2\u00ED+\u00E2cdR\u00CC\u00FB\u00BA\u00F7\u00E6\u00B2\u0086a\u008B\u009BL\u00F3^\"Ak\u00B3\u00D9V\u00E3n2\u0097\u00F9\x05\u00ECV\u0099\u00BD\u00F89\u00D6\u00D3\x13\u00A5(\u00AA\u00C7\u00FE\u00B1\x14a\x06\u00A3d=\u00D1:/\u00D0}\u00D4m\\\u00C7b\u00DA?\x13^xc\u009DI\u00F5\u008A\u00BB\f\u00DF\u008F\u00E5\u00EC\u00F3\u00C87\u00B9\x7FC\u00CB\u00E0\u00B8)i\u0099^>>om\u00CE\u0082\u00A9\u00F9\u00C6\u0081\u00B59\u00D9OO\x18\u00C7\u00EF\u0086\u00F2ZB\u0087\u00F6G0FaR\u00CCA\x06'(uK\"\u00C1\u00F4\u00F2\u00F5\u00C6\u00F12;9\x04\u00CCp5}\x7F\x1B\u00E6\u00B4\u00F4v\x19\u00AD\x1F\x03\u00A0\u0085R '\n\x02\u00FD\u00C7\u00BAA\u008A\u00C9.\u008F\u00B8\u00AB\u00CA\u00EC\u00F0Zk(5D=W\u00A5\u00FF\u00D8&k]\u00C1\u00AAg2-\u00F3\u00E6\u00CD\x03\x07\x7F\u00DB-yV\u0097\x17\u00EF\"\x1D\u00C0\u00B9\u00D2\u00ECm\u00B9\u00D6X\x1DS\x0E`\u008C\u00BCrL2-H\u0080\u00E6 \u0087\u0080\x19E?\u00ABO\u00A0\u00FB\x1F\u0093b\u00A1\u00D2\x0BZ(\x05r\u00A2 \u00D0\u00EA\u00BAy\u00F4y\u00C8\u00FE\b\u00EB\u00BB\u00E9\u00F7\u00ED\t/\u00E1\x02FR\u00BD\u00A2+\u00DFr\u00F9\u00BA\x0E\u00ACI\u00FF!*\u00B1r\u0094\u0098d\u00CB\u00FC\u0098\u00B6\u00EFh\u00F3\u00EAW\u00A30F^9F\u00D0\u0082\x04d\u00A7\u009Et4[\u00B4\b\u0098\u00AD\u00FC\u00F6\u00AD\u00B6\x17\u00FB#xZ)\x1C\u00F9\u00D9\u008D\u00C30\x00\u00B4\u00A2.\u00AE\u0084\u00A5\x1B\x0B\x15^\u00E2\u00C8H\u00AA\u00E7{\u00B7\t\u00EB*\u00C9\x00-\u00E8\x04J)f\u00C9\u0094\x03Mkh\f&\u00C7(\u00BA\u00A5\u00E0\u00ED\u00B5\u008D\u00C7,Z\x10\u0086\u00F6:`\u00B6\u00E4\u00A0[&Wz\u00BB\u0087\x05\u00D8j\b\u0085\u009C(\b\u00B4TW\u00DD-\u00F0\u008An\u00C1\u00C0\u00ADW\u0095\x11\u00BE\u00AEX\u009A\u00B4`o9\u00D6h\u00B7\u00D1\x03:a[.fY\u00D2\x12\u00F2\u00BD;\u00811\n\u0093ch\u0096\u00A5\u00A0\x05\t\u00B2\u008A[B'\u009B\u00CA\x02\u00E4H\u0086y\u0083\u00AD\u00D5e\u00EC\u00BC\u00EC\u00EE\u00ED\u00F2\u00B4\u00B6\u0084\x16N\u00F5\u00B3\u00FD\u0081P\u00C8\u0089\u0082\u0084\u00DELhu]\u00EC-\x0B\u00A6\u00FA}\u0084\u0085\x17{\u008B\u00A87\u00F2\u00CDx:\u0099\u00E83\u00F6\u0096\u00D4h\u00E95\u00C9:\u00F9I\u00C4\u008E\u0082\x193\u00CDE^\x03\u00B3\u00A4\x13a\u00F5&;\u00C6\u0098\u00C91\u00BE*:\u0089@\u008B\u00879='\u00BF\u009A\u008B\x1A\x1E;}Um~\x01\u00A3\u00F3\u00E5\u00CB\u00C6\x1E:/=\u00DDW:\u00AA\x1B\u00C3\u009EA\u00AB\u009A\u00DB^\u00B3\u0087(\x0B9Qp3G\u00AB\u00EB\u00E2$\u00A2\u00E1v\u00C2&yc\u00BF\u00DA\u00B3c\u00D4\u0086a(\u008C\u00E3\u00C1n\u0095X\u00B6I\u00A0\x17\u0090G\x1D\u00A3k&\u008Bv\u00D0Z\u00D0\u0090\u00DB\u00B4s\u00A1\x07\u00C8\u00E4\x03t0t\u00CD\x05:\u00A5G\u00C8\x15\u00FA^+\u00E2\u0084\b\u0085Pw\u0089\u00BE?&`\u00F3 \u00E1\u0087Ld\u00FC\u00C6?\u00C4\x7F\x1F\u009DT\u00AF\x1Ft\u00CE\u00FFD\u00FF\u00B9\u00CBm\u00C6|5\u00BF\u00BB\u00ABF\u00EFaw\x1F\u00B8z\u00F9\u00BE\u00E52\u00951Y\x1E\u00BF\u0088e\u00F4\u009E>\x03\x17i\u0097\u008Bg\"<*\u0082\x05,cd\u00AC5`9\u00C9\u00D2\x01\u0096\u0093\x14\x1D`\x01\x0BX\u00FE\u00C8\u00A2\u00AC\x01K`\u00B5\x18K2`9b\u00F12\u00CAj\u00B0\u009C\u00B04jk5X8\u00BEu<K\u00B3T\u00F5\u00D6\u0082\u0085SZ[Uq\u00CDr\u00A9V\u00AD\u00BA\u0094\u00A5]\\c\u00BD&\x1A\u00AFR\u00AFZ\u00AD\x023Q\u0096\u00D5\u00FC\x1A[\u0093K7\u00A8h\x15\u009CJ\u008Ee\u00FE\u00DEWfPy\x06\u008B\u00CF\x1D\u00AA\u00AC]p&\u00C4r\u00E5m\u00EC\u00A02\u00EF\u00BA\u00D8hJ,\u00AD3{\u0095\x17gb\u00A3)\u00B1\u00D0r\u00D9\u00AB\u00AC]t2)\u0096\u00D6m\u00BD\u00CA\u00CB\u0099{()\u0096z\u00D3y\u0095\u00C5\u0099{(-\u0096\u00D6y\u0095\u0085\u008B\x0F\u00A6\u00C5R\u00F7\u00CA\u00D7\u00C7\u00E7\x12c\x19\x02\x0BX\u00C0r\x1CX\u00E2\u008D\u00CF\"f\u00D3\x1B\u00C4Mg\u00E2\u0088\x05.\u00DC\u00F4\u0090E\u0096\u00E4\u0082(R)\u00A5g)d.\u00C4\fqB\u00E4\u00B2\u00F8a\u0099\x14Y\u009E\u0097\x02qe\u009Eg\u00C5\u0084Xni\u00B9dR\u00E6\u0088\u00932\u00E3\u00C5\u00C2,\u00E4Rd\u00E8\u00B7\u0082T\u0088\u0085\x0F\u0082A\x1C7!\x15f\u00E1\x0F4D\x1E\u00CC\u0082\x02}\x03\x1E\u0086\u00B7\u00C9a\u00EC\u00FBd\x00\x00\x00\x00IEND\u00AEB`\u0082";
    downloadsImg=MainPanel.add("image",[20,20,298,189] ,ScriptUI.newImage (createFile ("licenseLinkEnvato.png", downloadsImgImage, getUFolder())) );
    openGraphicRiver=MainPanel.add("button",[20,200,288,230] ,"Open GraphicRiver \"Downloads\" page");
    openGraphicRiver.graphics.foregroundColor = openGraphicRiver.graphics.newPen (openGraphicRiver.graphics.PenType.SOLID_COLOR,[0.3,0.79,0.98], 1);
    text=MainPanel.add("statictext",[20,247,460,267] ,"Your envato purchase code:");
    text2=MainPanel.add("statictext",[20,297,460,315] ,"Your envato username:");
    licenseTxt=MainPanel.add("edittext",[20,265,288,290] ,"");
    clientTxt=MainPanel.add("edittext",[20,315,288,340] ,"");
    Verify=MainPanel.add("button",[70,355,140,385],"Ok",{name: "ok"});
    Cancel=MainPanel.add("button",[178,355,248,385],"Cancel");

    function OpenWebLink(url){
        
        var cmd =($.os.indexOf("Win") != -1) ? "explorer " + String(url) : (("open \"" + String(url)) + "\"");
        try { app.system(cmd); }catch (e){ alert(e+"\n"+e.line); }
        
    };

    openGraphicRiver.onClick = function () { OpenWebLink("http://graphicriver.net/downloads"); }
    Cancel.onClick = function(){ licenseWin.close(); licenseWin.return = false; };

    Verify.onClick = function(){
    try{
        
        var _key = licenseTxt.text;
        var _user = clientTxt.text;
        if(_key == ""){ alert("Please, enter your envato purchase code.", script_name + " - License Verification"); return false; }
        if(_user == ""){ alert("Please, enter your envato username.", script_name + " - License Verification"); return false; }
        var ch = activate_license(_key,_user);
        if(ch) { 
        createFile(script_setting_name + "_license_file", ch, getUFolder()); 
        createFile(script_setting_name + "_username", _user, getUFolder()); 
        licenseWin.return = true; licenseWin.close(); }else{ return false; }
        
    }catch(e){ licenseWin.return = false; }
    };

    licenseWin.center();
    licenseWin.show();
    return licenseWin.return;

}

function getUFolder(a) {
  var userDataFolder = Folder.userData;
  var adobeFolder = Folder(userDataFolder.toString() + "/Adobe");
  var envatoFolder = Folder(adobeFolder.toString() + "/SR_LB");


  if (!adobeFolder.exists) {
      var checkFolder = adobeFolder.create();
      if (!checkFolder) {
          alert("Error creating user folder " + adobeFolder.fsName, script_name + " - Error");
          adobeFolder = Folder.temp;
      }
  }

  if (!envatoFolder.exists) {
      var checkFolder = envatoFolder.create();
      if (!checkFolder) {
          alert("Error creating user folder " + envatoFolder.fsName, script_name + " - Error");
          envatoFolder = Folder.temp;
      }
  }


  if (a != undefined) {
      envatoFolder = Folder(envatoFolder.toString() + "/" + a);
  }

  if (!envatoFolder.exists) {
      var checkFolder = envatoFolder.create();
      if (!checkFolder) {
          alert("Error creating user folder " + a, script_name + " - Error");
          envatoFolder = Folder.temp;
      }
  }

  return envatoFolder.fsName.toString();
};

function readFile(filename, resourceFolder) {

  if (!(isSecurityPrefSet())) {

  alert("This script requires access to write files. Go to the  General  panel of the application preferences and make sure 'Allow Scripts to Write Files and Access Network' is checked.", script_name + " - Permission Required");
  try {
    // app.executeCommand(2359);
    (parseFloat(app.version) >= 16.1) ? app.executeCommand(3131) : app.executeCommand(2359);
  } catch (e) {
    alert(e);
  }

    if (!isSecurityPrefSet()) return null;
  }

  var read_file = File(resourceFolder + "/" + filename);
  read_file.open('r', undefined, undefined);
  if (read_file !== '') {
    var res_lic = read_file.read();
    read_file.close();
  }

  return res_lic;
};

function createFile(filename, binaryString, resourceFolder) {

  var myFile = new File(resourceFolder + "/" + filename);

  if (!File(myFile).exists) {

      if (!(isSecurityPrefSet())) {

          alert("This script requires access to write files. Go to the  General  panel of the application preferences and make sure 'Allow Scripts to Write Files and Access Network' is checked.", script_name + " - Permission Required");
          try {
              // app.executeCommand(2359);
              (parseFloat(app.version) >= 16.1) ? app.executeCommand(3131) : app.executeCommand(2359);
          } catch (e) {
              alert(e);
          }

          if (!isSecurityPrefSet()) return null;
      }

      myFile.encoding = "BINARY";
      myFile.open("w");
      myFile.write(binaryString);
      myFile.close();
  }

  return myFile;
};

function activate_license(license, client) {
    /* activate_license() function will create a activation log in LicenseBox server, this function should run once so that the new license/purchase code can be added to on the server. After that, verify_license() function can be used for doing background license checks. */
    var system_user = (system.userName ? system.userName : "user");
    var system_os = ($.os ? $.os : "os");
    var system_name = (system.machineName ? system.machineName : "pc");
    var data = $http({
        method: 'POST',
        payload: {
            'product_id': lb_product_id,
            'license_code': license,
            'client_name': client,
            'verify_type': 'envato'
        },
        url: lb_server_url + 'api/activate_license',
        headers: {
            'LB-API-KEY': lb_api_key,
            'LB-URL': 'http://' + encodeURI(calc_hwid(system_user + system_os + system_name)).toLowerCase() + '.hwid',
            'LB-IP': '127.0.0.1'
        }
    });
    if (data.payload.status == true) {
        alert((data.payload.message ? data.payload.message : data.payload.error), script_name + " - License Verification");
        return data.payload.lic_response;
    } else {
        alert((data.payload.message ? data.payload.message : data.payload.error), script_name + " - License Verification");
        return false;
    }
}

function isSecurityPrefSet() {
  try {
      var securitySetting = app.preferences.getPrefAsLong("Main Pref Section", "Pref_SCRIPTING_FILE_NETWORK_SECURITY");
      return (securitySetting == 1);
  } catch (e) {
      return (securitySetting = 1);
  }
};

function getPref(_sectionName, _keyName){
    var argt = [_sectionName, _keyName];
    if(typeof PREFType!=="undefined" && typeof PREFType.PREF_Type_MACHINE_SPECIFIC !=="undefined"){argt.push(PREFType.PREF_Type_MACHINE_SPECIFIC)};
    if(app.preferences.havePref.apply(app.preferences ,argt)){
        return app.preferences.getPrefAsString.apply(app.preferences, argt);
    };
    return "";
};

function savePref(_sectionName, _keyName, _value){
    var argt = [_sectionName, _keyName, _value];
    if(typeof PREFType!=="undefined" && typeof PREFType.PREF_Type_MACHINE_SPECIFIC !=="undefined"){argt.push(PREFType.PREF_Type_MACHINE_SPECIFIC)};
    return app.preferences.savePrefAsString.apply(app.preferences, argt);
  };

activation_dialog()