forked from zlovatt/zl_Scriptlets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmistikaVRToAENull.jsx
104 lines (79 loc) · 94.6 KB
/
mistikaVRToAENull.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
(function mistikaVRToAENull () {
/* aequery */
var aeq=function(){var aeq=function(selector,context){if(aeq.isNullOrUndefined(selector))return selector;var result;if(aeq.isAeq(selector))result=selector;else if(aeq.isString(selector))result=aeq.select(selector,context);else if(aeq.isArray(selector))result=aeq.arrayEx(selector);else if(aeq.isApp(selector))result=aeq.app;else if(aeq.isComp(selector))result=new aeq.Comp(selector);else if(aeq.isLayer(selector))result=new aeq.Layer(selector);else if(aeq.isProperty(selector))result=new aeq.Property(selector);result.aeq=true;return result};aeq.version="0.4.0";aeq.thisObj=this;if("object"===typeof module)module.exports=aeq;aeq.extend=function(){var options,name,src,copy,copyIsArray,clone,target=setDefault(arguments[0],{}),i=1,length=arguments.length,deep=false;if("boolean"===typeof target){deep=target;target=setDefault(arguments[i],{});i++}if("object"!==typeof target&&!aeq.isFunction(target))target={};if(i===length){target=this;i--}for(;i<length;i++)if(null!==(options=arguments[i]))for(name in options){src=target[name];copy=options[name];if(target===copy)continue;if(deep&©&&(aeq.isPlainObject(copy)||(copyIsArray=aeq.isArray(copy)))){if(copyIsArray){copyIsArray=false;clone=src&&aeq.isArray(src)?src:[]}else clone=src&&aeq.isPlainObject(src)?src:{};target[name]=aeq.extend(deep,clone,copy)}else if(void 0!==copy)target[name]=copy}return target};aeq.forEach=function(obj,callback,fromIndex){var length,i;if(obj&&"[object Array]"===Object.prototype.toString.call(obj)){length=obj.length;i=void 0!==fromIndex?fromIndex:0;for(;i<length;i++)if(false===callback(obj[i],i,obj))break}else for(i in obj)if(obj.hasOwnProperty(i))if(false===callback(i,obj[i],obj))break;return obj};aeq.filter=function(obj,callback){var filteredArr=[],length,i;if(obj&&"[object Array]"===Object.prototype.toString.call(obj)){length=obj.length;i=0;for(;i<length;i++)if(callback(obj[i],i,obj))filteredArr.push(obj[i])}else for(i in obj)if(obj.hasOwnProperty(i))if(callback(i,obj[i],obj))filteredArr.push(obj[i]);return filteredArr};aeq.setDefault=function(value,defaultVal){return"undefined"==typeof value?defaultVal:value};var setDefault=aeq.setDefault;aeq.extend({assertIsNull:function(o,err){if(aeq.isNullOrUndefined(o))return true;throw new Error(err)},assertIsNotNull:function(o,err){if(!aeq.isNullOrUndefined(o))return true;throw new Error(err)},assertIsTrue:function(o,err){if(true===o)return true;throw new Error(err)},assertIsFalse:function(o,err){if(false===o)return true;throw new Error(err)},assertIsEmpty:function(o,err){if(aeq.isEmpty(o))return true;throw new Error(err)},assertIsNotEmpty:function(o,err){if(!aeq.isEmpty(o))return true;throw new Error(err)}});aeq.attr=function(array,attributeName,newValue){var i,il;if(1===arguments.length)throw new Error("Only one argument given to attr, must be 2 or 3");else if(2===arguments.length){if(void 0!==array[0]&&null!==array[0])return getAttr(array[0],attributeName);return}else{for(i=0,il=array.length;i<il;i++)setAttr(array[i],attributeName,newValue);return array}};function getAttr(object,attributeName){if(object[attributeName]instanceof Function)return object[attributeName]();return object[attributeName]}function setAttr(object,attributeName,newValue){var attrSetters,setter;attrSetters=attr.setters[object.toString()];if(void 0!==attrSetters){setter=attrSetters[attributeName];if(void 0!==setter)attributeName=setter}if(object[attributeName]instanceof Function)object[attributeName](newValue);else object[attributeName]=newValue;return object}var attr={setters:{"[object Property]":{value:"setValue"}}};aeq.extend({getItems:function(folder,deep){if(void 0===folder)return aeq.normalizeCollection(app.project.items);deep=setDefault(deep,true);folder=aeq.project.getFolder(folder);if(null===folder)return aeq.arrayEx();if(deep)return aeq.getItemsDeep(folder);return aeq.normalizeCollection(folder.items)},getItemsDeep:function(folder,returnArrayEx){var item,items=[],len=folder.items.length;for(var i=1;i<=len;i++){item=folder.items[i];if(aeq.isFolderItem(item))items.push.apply(items,aeq.getItemsDeep(item,false));items.push(item)}if(false===returnArrayEx)return items;return aeq.arrayEx(items)},getItemInComps:function(item){var layers=[];aeq.forEach(item.usedIn,function(comp){aeq.forEachLayer(comp,function(layer){if(layer.source===item)layers.push(layer)})});return aeq.arrayEx(layers)},getCompositions:function(folder,deep){var items=aeq.getItems(folder,deep);return items.filter(aeq.isComp)},getActiveComposition:function(){var activeItem=app.project.activeItem;if(aeq.isComp(activeItem))return activeItem;return null},getComposition:function(name){var length=app.project.items.length;for(var i=1;i<=length;i++){var item=app.project.item(i);if(item.name===name&&aeq.isComp(item))return item}return null},getLayers:function(comps){aeq.assertIsNotNull(comps,"comps is null");var arr=[];if(aeq.isComp(comps))comps=[comps];for(var c=0;c<comps.length;c++){var comp=comps[c];arr=arr.concat(aeq.normalizeCollection(comp.layers))}return aeq.arrayEx(arr)},getSelectedLayers:function(comp){if(!aeq.isComp(comp))comp=aeq.getActiveComp();if(comp)return aeq.arrayEx(comp.selectedLayers);return aeq.arrayEx()},getSelectedLayersOrAll:function(comp){if(!aeq.isComp(comp)){comp=aeq.getActiveComp();if(null===comp)return aeq.arrayEx()}var layers=aeq.getSelectedLayers(comp);if(0===layers.length)return aeq.getLayers(comp);return layers},getSelectedProperties:function(obj){if(!obj)obj=aeq.getActiveComp();if(obj)return aeq.arrayEx(obj.selectedProperties);return aeq.arrayEx()},getProperties:function(layers,options){aeq.assertIsNotNull(layers,"layer is null");options=setDefault(options,{separate:true});var arr=[];for(var l=0;l<layers.length;l++){var layer=layers[l];arr=arr.concat(aeq.getPropertyChildren(layer,options))}return aeq.arrayEx(arr)},getPropertyChildren:function(propertyParent,options){var arr=[];var property;var len=propertyParent.numProperties;options=setDefault(options,{separate:false});for(var i=1;i<=len;i++){property=propertyParent.property(i);switch(property.propertyType){case PropertyType.PROPERTY:if(options.separate)property=normalizeProperty(propertyParent,property);if(false!==options.props)arr.push(property);break;case PropertyType.INDEXED_GROUP:case PropertyType.NAMED_GROUP:if(true===options.groups)arr.push(property);arr=arr.concat(aeq.getPropertyChildren(property,options))}}return arr},getEffects:function(layers){aeq.assertIsNotNull(layers,"layers is null");if(aeq.isLayer(layers))layers=[layers];var arr=[];var len=layers.length;var effects,effectslen;for(var l=0;l<len;l++){effects=layers[l].property("ADBE Effect Parade");if(null===effects)return aeq.arrayEx();effectslen=effects.numProperties;for(var e=1;e<=effectslen;e++)arr.push(effects.property(e))}return aeq.arrayEx(arr)},getMarkerGroup:function(obj){if(!obj)obj=aeq.getActiveComp();if(aeq.isLayer(obj))return obj.property("ADBE Marker");if(aeq.isComp(obj)&&aeq.app.version>=14)return obj.markerProperty;return null},getKeys:function(property){var arr=[],i,len;if(aeq.isArray(property)){for(i=0,len=property.length;i<len;i++)arr=arr.concat(aeq.getKeys(property[i]));return aeq.arrayEx(arr)}for(i=1,len=property.numKeys;i<=len;i++)arr.push(aeq.Key(property,i));return aeq.arrayEx(arr)},getChildren:function(obj){var ret;if(aeq.isComp(obj))return aeq.normalizeCollection(obj.layers);if(aeq.isLayer(obj)||aeq.isPropertyGroup(obj))return aeq.getPropertyChildren(obj,{});if(aeq.isArray(obj)){ret=aeq.arrayEx();aeq.forEach(obj,function(item){ret.push.call(ret,aeq.getChildren(item))});return ret}},normalizeCollection:function(collection){var ret=Array.prototype.slice.call(collection,1);var len=collection.length;if(0!==len)ret.push(collection[len]);return aeq.arrayEx(ret)},framesToTime:function(frames,frameRate){return frames/frameRate},timeToFrames:function(time,frameRate){return time*frameRate}});aeq.getComp=aeq.getComposition;aeq.getComps=aeq.getCompositions;aeq.getActiveComp=aeq.activeComp=aeq.activeComposition=aeq.getActiveComposition;aeq.getSelectedProps=aeq.getSelectedProperties;aeq.getSelectedOrAllLayers=aeq.getSelectedLayersOrAll;function normalizeProperty(propertyParent,property){switch(property.name){case"X Position":case"Y Position":case"Z Position":property=propertyParent.property("Position");property.dimensionsSeparated=true;return property.propertyGroup().property(property.name);default:return property}}aeq.extend({forEachLayer:function(obj,callback){if(aeq.isComp(obj)){var length=obj.numLayers,i=1;for(;i<=length;i++)if(false===callback(obj.layer(i),i,obj))break}else if(aeq.isArray(obj))aeq.forEach(obj,function(obj){aeq.forEachLayer(obj,callback)});else if(aeq.isFunction(obj)){callback=obj;aeq.forEachComp(function(comp){aeq.forEachLayer(comp,callback)})}return aeq},forEachProperty:function(obj,callback){if(aeq.isLayer(obj)||aeq.isPropertyGroup(obj)){var properties=aeq.getPropertyChildren(obj,{});aeq.forEach(properties,callback)}else if(aeq.isComp(obj))aeq.forEachLayer(obj,function(layer){var properties=aeq.getPropertyChildren(layer,{});aeq.forEach(properties,callback)});else if(aeq.isArray(obj))aeq.forEach(obj,function(obj){aeq.forEachProperty(obj,callback)});else if(aeq.isFunction(obj)){callback=obj;aeq.forEachLayer(function(layer){aeq.forEachProperty(layer,callback)})}return aeq},forEachEffect:function(obj,callback){var i,length,effects;if(aeq.isLayer(obj)){effects=obj.property("ADBE Effect Parade");length=effects.numProperties;for(i=1;i<=length;i++)if(false===callback(effects.property(i),i,effects))break}else if(aeq.isComp(obj))aeq.forEachLayer(obj,function(layer){aeq.forEachEffect(layer,callback)});else if(aeq.isArray(obj))aeq.forEach(obj,function(obj){aeq.forEachEffect(obj,callback)});else if(aeq.isFunction(obj)){callback=obj;aeq.forEachLayer(function(layer){aeq.forEachEffect(layer,callback)})}return aeq},forEachComp:function(callback){aeq.forEach(aeq.getCompositions(),callback)},forEachItem:function(callback){var project=app.project;var items=project.items;var length=items.length;for(var i=1;i<=length;i++)if(false===callback(items[i],i,project))break;return aeq},forEachRenderQueueItem:function(callback){var renderQueue=app.project.renderQueue;var renderQueueItems=renderQueue.items;var length=renderQueueItems.length;for(var i=1;i<=length;i++)if(false===callback(renderQueueItems[i],i,renderQueue))break;return aeq},forEachOutputModule:function(callback){aeq.forEachRenderQueueItem(function(item){var length=item.outputModules.length;for(var i=1;i<=length;i++)if(false===callback(item.outputModules[i],i,item))break});return aeq}});aeq.forEachProp=aeq.forEachProperty;aeq.forEachComposition=aeq.forEachComp;aeq.forEachRQItem=aeq.forEachRenderQueueItem;aeq.forEachOM=aeq.forEachOutputModule;aeq.select=function(selector,context){var results=[];var parsedSelector=cssselector.parse(selector);var parts=parsedSelector;if(void 0!==context)if(aeq.isString(context))results=aeq.select(context);else if(aeq.isArray(context))results=context;else results=[context];while(parts.length>0){var part=parts[0];var unshifted=false;switch(part.type){case"activecomp":results=filterResults(aeq.arrayEx([aeq.getActiveComposition()]));results.type="comp";break;case"composition":case"comp":results=filterResults(aeq.getCompositions());results.type="comp";break;case"layer":if("comp"===results.type||aeq.isComp(results[0])){results=filterResults(aeq.getLayers(results));results.type="layer"}else if("comp"!==results.type){parts.unshift({type:"comp"});unshifted=true}break;case"propertygroup":case"propgrp":case"propgroup":if("layer"===results.type||"propertygroup"===results.type||aeq.isLayer(results[0])||aeq.isPropertyGroup(results[0])){results=filterResults(aeq.getProperties(results,{separate:false,groups:true,props:false}));results.type="propertygroup"}else if("layer"!==results.type){parts.unshift({type:"layer"});unshifted=true}break;case"property":case"prop":if("layer"===results.type||"propertygroup"===results.type||aeq.isLayer(results[0])||aeq.isPropertyGroup(results[0])){results=filterResults(aeq.getProperties(results,{separate:false}));results.type="property"}else if("layer"!==results.type){parts.unshift({type:"layer"});unshifted=true}break;case"effect":if("layer"===results.type||aeq.isLayer(results[0])){results=filterResults(aeq.getEffects(results));results.type="effect"}else if("layer"!==results.type){parts.unshift({type:"layer"});unshifted=true}break;case"key":case"keys":if("property"===results.type||aeq.isProperty(results[0])){results=filterResults(aeq.getKeys(results));results.type="key"}else if("property"!==results.type){parts.unshift({type:"property"});unshifted=true}break;case"item":results=filterResults(aeq.getItems());results.type="item";break;default:throw new Error("Unrecognized token "+part.type)}if(!unshifted)parts.shift()}function filterResults(arr){if(part.props||part.pseudo)return arr.filter(filter);return arr}function filter(obj){var ret=true,len,pseudo;if(null!==part.props)if(!hasAllAttributes(obj,part.props,false))return false;if(!part.pseudo)return true;len=part.pseudo.length;for(var i=0;i<len;i++){pseudo=part.pseudo[i];if("not"===pseudo.type||"isnot"===pseudo.type)ret=hasAllAttributes(obj,pseudo.props,true);else if("is"===pseudo.type||"has"===pseudo.type)ret=hasAllAttributes(obj,pseudo.props,false);if(false===ret)return false}return true}return aeq.arrayEx(results)};function hasAllAttributes(obj,attributes,not){var attributeValue;for(var attribute in attributes){if(!attributes.hasOwnProperty(attribute))continue;attributeValue=attributes[attribute];if(!obj.hasOwnProperty(attribute))throw new Error("The attribute "+attribute+" does not exist on a "+typeof obj);var isSame=compare(attributeValue,obj[attribute]);if(isSame&¬||!isSame&&false===not)return false}return true}function compare(value,attribute){if("Array"===value.type)return valueInArray(value,attribute);else if("RegExp"===value.type)return value.value.test(attribute);else return value.value.toString()===attribute.toString()}function valueInArray(value,attribute){for(var i=0,il=value.value.length;i<il;i++)if(compare(value.value[i],attribute))return true;return false}aeq.extend({isNullOrUndefined:function(o){return null==o},isBoolean:function(o){return"boolean"===typeof o},isNumber:function(o){return"number"===typeof o},isString:function(o){return"string"===typeof o},isObject:function(o){return o instanceof Object},isPlainObject:function(obj){if(void 0===obj||null===obj)return false;if("[object Object]"!==obj.toString())return false;if(obj.constructor&&!obj.constructor.prototype.hasOwnProperty("isPrototypeOf"))return false;return true},isArray:function(o){return o instanceof Array},isEmpty:function(o){return void 0===o.length||0===o.length},isFunc:function(o){return o instanceof Function},isAeq:function(o){return o instanceof Object&&true===o.isAeq},isApp:function(o){return o instanceof Application},isFolder:function(o){return o instanceof Folder},isFile:function(o){return o instanceof File},isFolderItem:function(o){return o instanceof FolderItem},isFootageItem:function(o){return o instanceof FootageItem},isComp:function(o){return o instanceof CompItem},isAVLayer:function(o){return o instanceof AVLayer},isShapeLayer:function(o){return o instanceof ShapeLayer},isTextLayer:function(o){return o instanceof TextLayer},isCameraLayer:function(o){return o instanceof CameraLayer},isLightLayer:function(o){return o instanceof LightLayer},isPrecomp:function(o){if(!aeq.isLayer(o))return false;return aeq.isComp(o.source)},isLayer:function(o){return aeq.isAVLayer(o)||aeq.isShapeLayer(o)||aeq.isTextLayer(o)||aeq.isCamera(o)||aeq.isLight(o)},isProperty:function(o){return o instanceof Property},isPropertyGroup:function(o){return o instanceof PropertyGroup},isPanel:function(o){return o instanceof Panel},isWindow:function(o){return o instanceof Window},reflect:function(obj){var str=[];for(var m in obj)if(obj.hasOwnProperty(m))str.push(obj[m].constructor.name+" "+m+"="+obj[m]);return str.join()}});aeq.isBool=aeq.isBoolean;aeq.isNum=aeq.isNumber;aeq.isStr=aeq.isString;aeq.isObj=aeq.isObject;aeq.isArr=aeq.isArray;aeq.isFunction=aeq.isFunc;aeq.isComposition=aeq.isComp;aeq.isProp=aeq.isProperty;aeq.isDir=aeq.isDirectory=aeq.isFolder;aeq.isCamera=aeq.isCameraLayer;aeq.isLight=aeq.isLightLayer;aeq.error=function(err,args){var callingFunction=/\s*function\s*([^\(]*)/i.exec(err.source);callingFunction=null!==callingFunction&&""!==callingFunction[1]?callingFunction[1]:"anonymous";alert(err.toString()+"\n"+"Script File: "+File.decode(err.fileName).replace(/^.*[\\|\/]/,"")+"\nFunction: "+(void 0===args?callingFunction:args.callee.name)+(void 0===args||0===args.length?"":"\nArguments: "+Array.prototype.toString.call(args))+"\nError on Line: "+err.line.toString())};aeq.getModifiers=function(){return{meta:ScriptUI.environment.keyboardState.metaKey,ctrl:ScriptUI.environment.keyboardState.ctrlKey,alt:ScriptUI.environment.keyboardState.altKey,shift:ScriptUI.environment.keyboardState.shiftKey}};aeq.extend({createResourceFiles:function(resources,folder,extension){if(!aeq.app.securityPrefEnabled())return false;folder=aeq.getFolderObject(folder);extension=setDefault(extension,"");if(""!==extension&&"."!==extension.charAt(0))extension="."+extension;aeq.file.ensureFolderExists(folder);if(!folder.exists)throw new Error("Could not create resource folder: "+folder.fsname);var resourceFiles={};aeq.forEach(resources,function(name,contents){var filePath=aeq.file.joinPath(folder.fsName,name+extension);var file=new File(filePath);resourceFiles[name]=file;if(!file.exists||contents.length!==file.length){file.encoding="BINARY";file.open("w");var success=file.write(contents);if(!success)if(""===file.error)resourceFiles[name]=null;else resourceFiles[name]=new Error(file.error,file.fsName,void 0);file.close()}});return resourceFiles},getBinaryString:function(filePath){var file=aeq.getFileObject(filePath);file.encoding="BINARY";file.open("r");var fileData=file.read();file.close();var binaryString=fileData.toSource();binaryString=binaryString.replace(/^\(new String\(\"/,"");binaryString=binaryString.replace(/\"\)\)$/,"");return binaryString}});aeq.extend({isMac:$.os.indexOf("Windows")===-1,isWindows:$.os.indexOf("Windows")!==-1,getSystemInfo:function(){return $.os+" AE "+app.version+"/"+app.isoLanguage}});aeq.isWin=aeq.isWindows;aeq.extend({createUndoGroup:function(name,callback,args){app.beginUndoGroup(name);if(!aeq.isArray(args))args=[args];var value=callback.apply(null,args);app.endUndoGroup();return value}});aeq.undoGroup=aeq.createUndoGroup;aeq.extend({valueInObject:function(value,obj){for(var key in obj)if(obj.hasOwnProperty(key))if(value===obj[key])return key;return},propertyType:function(property){return aeq.valueInObject(property.propertyType||property,PropertyType)}});aeq.app=aeq.extend({},{toString:function(){return"[object aeq.App]"},extend:aeq.extend,version:parseFloat(app.version),securityPrefEnabled:function(){return 1==app.preferences.getPrefAsLong("Main Pref Section","Pref_SCRIPTING_FILE_NETWORK_SECURITY")},getUserDataFolder:function(){return Folder.userData},getScriptFile:function(){return aeq.getFile($.fileName)},getAEP:function(){return app.project.file},getAEPDir:function(){var aepFile=aeq.app.getAEP();if(!aepFile)return null;return aeq.getFolder(aepFile.path)},getAEPName:function(){var aepFile=aeq.app.getAEP();if(!aepFile)return null;return aeq.file.stripExtension(aepFile.displayName)},getPresetsPaths:function(){var appVersion=aeq.app.version;var versionPrettyName="";if(11==parseInt(appVersion))versionPrettyName="CS6";else if(12==parseInt(appVersion))versionPrettyName="CC";else if(appVersion>=13&&appVersion<13.5)versionPrettyName="CC 2014";else if(appVersion>=13.5&&appVersion<14)versionPrettyName="CC 2015";else if(appVersion>=14)versionPrettyName="CC 2017";return[Folder.current.fullName+"/Presets/",Folder.myDocuments.fullName+"/Adobe/After Effects "+versionPrettyName+"/User Presets/"]},ensureSecurityPrefEnabled:function(){if(!aeq.app.securityPrefEnabled()){if(confirm("This script requires access to write files.\n"+'Go to the "General" panel of the application preferences and ensure\n'+'"Allow Scripts to Write Files and Access Network" is checked.\n\nOpen prefs now?'))app.executeCommand(2359);if(!aeq.app.securityPrefEnabled())throw new Error("Security preference is not enabled! Can't continue.")}},open:function(filePath){var file=aeq.getFile(filePath);if(file)return app.open(file);return app.open()}});aeq.open=aeq.app.open;aeq.AEversion=aeq.app.version;aeq.command=aeq.extend({},{toString:function(){return"[object aeq.command]"},extend:aeq.extend,call:function(windows,mac,arg){if(aeq.isObject(arguments[0])){var args=arguments[0];windows=setDefault(args.win,args.windows);mac=setDefault(args.mac,args.osx);arg=args.arg}var command=mac;if(aeq.isWindows)command=windows;arg=void 0!==arg?" "+arg:"";return system.callSystem(command+arg)},openURL:function(URL){try{if(null===URL.match(/^https?:\/\//))URL="http://"+URL;aeq.command.call({win:'cmd /c "explorer',mac:"open",arg:URL})}catch(err){alert("Error in openURL function\n"+err.toString())}},revealFile:function(filePath){if(aeq.isFile(filePath))filePath=filePath.fsName;return aeq.command.call("Explorer /select,","open -R",'"'+filePath+'"')},copyToClipboard:function(text){aeq.command.call('cmd.exe /c cmd.exe /c "echo '+text+' | clip"','echo "'+text+'" | pbcopy')}});aeq.callSystem=aeq.command.call;aeq.openURL=aeq.command.openURL;aeq.revealFile=aeq.command.revealFile;aeq.copyToClipboard=aeq.command.copyToClipboard;aeq.comp=aeq.extend({},{toString:function(){return"[object aeq.comp]"},extend:aeq.extend,create:function(folder,options){if(!aeq.isFolderItem(folder)){options=setDefault(folder,{});folder=setDefault(options.folder,app.project)}var defaultOptions={name:"Comp",width:1920,height:1080,pixelAspect:1,duration:1,frameRate:24};options=aeq.extend(defaultOptions,options);return folder.items.addComp(options.name,options.width,options.height,options.pixelAspect,options.duration,options.frameRate)},getCompInQueue:function(comp,queuedOnly){if(aeq.isNullOrUndefined(queuedOnly))queuedOnly=true;var queuedItems;if(queuedOnly)queuedItems=aeq.renderqueue.getQueuedItems();else queuedItems=aeq.renderqueue.getRQItems();return aeq.filter(queuedItems,function(item){return item.comp.id==comp.id})},isInQueue:function(comp){if(!aeq.isComp(comp))return null;var items=aeq.renderqueue.getRQItems();return items.exists(function(item){return item.comp.id==comp.id})},isQueued:function(comp){return aeq.comp.getCompInQueue(comp,true).length>0}});aeq.file=aeq.extend({},{toString:function(){return"[object aeq.file]"},extend:aeq.extend,pathSeparatorSymbol:$.os.indexOf("Windows")>-1?"\\":"/",normalizePathArray:function(parts,allowAboveRoot){var up=0;for(var i=parts.length-1;i>=0;i--){var last=parts[i];if("."===last)parts.splice(i,1);else if(".."===last){parts.splice(i,1);up++}else if(up){parts.splice(i,1);up--}}if(allowAboveRoot)for(;up--;up)parts.unshift("..");return parts},pathIsAbsolute:function(path){return path.charAt(0)===aeq.file.pathSeparatorSymbol},normalizePath:function(path){var pathIsAbsolute=aeq.file.pathIsAbsolute(path),trailingSlash=path.substr(-1)===aeq.file.pathSeparatorSymbol;path=aeq.file.normalizePathArray(aeq.filter(path.split(aeq.file.pathSeparatorSymbol),function(p){return!!p}),!pathIsAbsolute).join(aeq.file.pathSeparatorSymbol);if(!path&&!pathIsAbsolute)path=".";if(path&&trailingSlash)path+=aeq.file.pathSeparatorSymbol;return(pathIsAbsolute?aeq.file.pathSeparatorSymbol:"")+path},joinPath:function(){var paths=Array.prototype.slice.call(arguments,0);return aeq.file.normalizePath(aeq.filter(paths,function(p,index){if(p&&"string"===typeof p.fsName){p=p.fsName;paths[index]=p}if("string"!==typeof p)throw new TypeError("Arguments to path.join must be strings, Files or Folders");return p}).join(aeq.file.pathSeparatorSymbol))},getExtension:function(filePath){var filePathStr=aeq.isFile(filePath)?filePath.name:filePath;return filePathStr.substr(filePathStr.lastIndexOf(".")+1,filePathStr.length)},stripExtension:function(filePath){var filePathStr=aeq.isFile(filePath)?filePath.name:filePath;return filePathStr.substr(0,filePathStr.lastIndexOf("."))},getFileObject:function(filePath){return aeq.isFile(filePath)?filePath:new File(filePath)},getFile:function(filePath){var file=aeq.getFileObject(filePath);if(!file.exists)return null;return file},getFiles:function(folderPath,filter){filter=setDefault(filter,"");var folder=aeq.getFolder(folderPath),files;files=folder.getFiles(filter);if(null===files||0===files.length)return null;return aeq.arrayEx(files)},getFolderObject:function(folderPath){return aeq.isFolder(folderPath)?folderPath:new Folder(folderPath)},getFolder:function(folderPath){var folder=aeq.getFolderObject(folderPath);if(!folder.exists)return null;return folder},ensureFolderExists:function(folderPath){var folder=aeq.getFolderObject(folderPath);if(!folder.exists)folder.create();return folder},readFile:function(filePath,encoding){var file=aeq.getFileObject(filePath),contents;encoding=setDefault(encoding,"UTF-8");if(file.exists){if(File.isEncodingAvailable(encoding))file.encoding=encoding;file.open();contents=file.read();file.close();return contents}return null},writeFile:function(filePath,contents,options){var file=aeq.getFileObject(filePath);options=aeq.setDefault(options,{});if(file.exists&&false===options.overwrite)return null;if(!file.exists)aeq.file.ensureFolderExists(file.path);if(!aeq.isNullOrUndefined(options.encoding)&&File.isEncodingAvailable(options.encoding))file.encoding=options.encoding;file.open("w");var success=file.write(contents);file.close();if(success)return file;return null}});aeq.pathSeparatorSymbol=aeq.file.pathSeparatorSymbol;aeq.getFileObject=aeq.file.getFileObject;aeq.getFolderObject=aeq.file.getFolderObject;aeq.getFile=aeq.file.get=aeq.file.getFile;aeq.getFiles=aeq.file.getFiles;aeq.getFolder=aeq.file.getFolder;aeq.readFile=aeq.file.readFile;aeq.writeFile=aeq.file.writeFile;aeq.layer=aeq.extend({},{toString:function(){return"[object aeq.layer]"},extend:aeq.extend,setLayerToggles:function(sourceLayer,destLayer){var switches="enabled solo shy quality effectsActive motionBlur "+"adjustmentLayer threeDLayer blendingMode preserveTransparency "+"parent inPoint stretch startTime outPoint label guideLayer "+"name comment autoOrient";switches=switches.split(" ");aeq.forEach(switches,function(switchName){destLayer[switchName]=sourceLayer[switchName]})},children:function(parentLayer){var layers=aeq.getLayers(parentLayer.containingComp);return layers.filter(function(layer){return layer.parent===parentLayer})},allChildren:function(parentLayer){var allChildren=[];var children=aeq.layer.children(parentLayer);aeq.forEach(children,function(layer){allChildren.push(layer);allChildren=allChildren.concat(aeq.layer.allChildren(layer))});return aeq.arrayEx(allChildren)},parents:function(childLayer){var parents=aeq.arrayEx();var layer=childLayer;while(null!==layer.parent){parents.push(layer.parent);layer=layer.parent}return parents},relatedLayers:function(root){var parents=aeq.layer.parents(root);var children=aeq.layer.allChildren(root);var all=parents.push.apply(parents,children);return aeq.arrayEx(all)}});aeq.project=aeq.extend({},{toString:function(){return"[object aeq.project]"},extend:aeq.extend,getFootage:function(){var items=aeq.getItems();return aeq.filter(items,aeq.isFootageItem)},getFolders:function(parentFolder){var folders=aeq.getItems(parentFolder);return folders.filter(aeq.isFolderItem)},findFolder:function(name,parentFolder){var folders=aeq.project.getFolders(parentFolder);var folder=aeq.filter(folders,function(folder){return folder.name==name});if(folder.length)return folder[0];return null},getFolder:function(folder,parentFolder){if(aeq.isFolderItem(folder))return folder;if(aeq.isString(folder))return aeq.project.findFolder(folder,parentFolder);return null},getSelectedFolders:function(){return aeq.filter(app.project.selection,aeq.isFolderItem)},getSelectedComps:function(){return aeq.filter(app.project.selection,aeq.isComp)},getSelectedFootage:function(){return aeq.filter(app.project.selection,aeq.isFootageItem)},getOrCreateFolder:function(folder,parentFolder){if(aeq.isNullOrUndefined(parentFolder))parentFolder=app.project.rootFolder;else parentFolder=aeq.project.getOrCreateFolder(parentFolder);var foundFolder=aeq.project.getFolder(folder,parentFolder);if(aeq.isNullOrUndefined(foundFolder))return parentFolder.items.addFolder(folder);return foundFolder},getFolderOrRoot:function(folder){folder=aeq.project.getFolder(folder);if(aeq.isNullOrUndefined(folder))return app.project.rootFolder;return folder},save:function(path){if(!path)return app.project.save();var file=aeq.getFileObject(path);if(file.exists)if(!confirm("File exists! Overwrite?"))return null;return app.project.save(file)},quickSave:function(){var file=aeq.app.getAEP();return app.project.save(file)},importFile:function(file,folder,options){var proj=app.project,newItem;var newFile=aeq.getFile(file);if(!aeq.isFile(newFile))throw new Error(file+" is not a valid file!");if(aeq.isNullOrUndefined(folder))folder=app.project.rootFolder;else folder=aeq.project.getOrCreateFolder(folder);options=setDefault(options,{});var iO=new ImportOptions(newFile);if(true===options.sequence)iO.sequence=true;try{newItem=proj.importFile(iO)}catch(e){throw new Error("Can't import file "+newFile.name+"\n"+String(e))}if(newItem.duration*newItem.frameRate==1)newItem.replace(file);newItem.parentFolder=folder;newItem.selected=false;return newItem},simpleImportFile:function(file,options){var iO=new ImportOptions(file);options=setDefault(options,{});if(true===options.sequence)iO.sequence=true;try{newItem=app.project.importFile(iO)}catch(e){throw new Error("Can't import file "+file.name+"\n"+String(e))}return newItem},importSequence:function(file,folder){return aeq.importFile(file,folder,{sequence:true})},importFiles:function(fileArray,folder,options){var importedItems=aeq.arrayEx();aeq.forEach(fileArray,function(file){var item=aeq.importFile(file,folder,options);importedItems.push(item)});return importedItems},moveToFolder:function(items,folder){folder=aeq.project.getFolder(folder);if(!aeq.isArray(items))items=[items];aeq.forEach(items,function(item){item.parentFolder=folder;item.selected=false})},reduceToQueuedComps:function(){var queuedComps=aeq.renderqueue.getQueuedComps();if(0===queuedComps.length)return null;app.project.reduceProject(queuedComps);return queuedComps}});aeq.save=aeq.project.save;aeq.quickSave=aeq.project.quickSave;aeq.importFile=aeq.project.importFile;aeq.importFiles=aeq.project.importFiles;aeq.importSequence=aeq.project.importSequence;aeq.property=aeq.extend({},{toString:function(){return"[object aeq.property]"},extend:aeq.extend,valueType:function(property){return aeq.valueInObject(property.propertyValueType||property,PropertyValueType)},type:function(property){return aeq.valueInObject(property.propertyType||property,PropertyType)},getLayer:function(property){var depth=property.propertyDepth;return property.propertyGroup(depth)}});aeq.prop=aeq.property;aeq.renderqueue=aeq.extend({},{toString:function(){return"[object aeq.RenderQueue]"},extend:aeq.extend,queue:function(item){return app.project.renderQueue.items.add(item)},unqueue_all:function(){var items=aeq.renderqueue.getRQItems();items.forEach(function(item){if(item.status!=RQItemStatus.USER_STOPPED&&item.status!=RQItemStatus.ERR_STOPPED&&item.status!=RQItemStatus.RENDERING&&item.status!=RQItemStatus.DONE)item.render=false})},clear:function(){var items=aeq.renderqueue.getRQItems();items=items.reverse();items.forEach(function(item){item.remove()})},isQueued:function(rqItem){return rqItem.status==RQItemStatus.QUEUED},getQueuedItems:function(){var items=aeq.renderqueue.getRQItems();return item.filter(function(item){return aeq.renderqueue.isQueued(item)})},getQueuedComps:function(){var queuedItems=aeq.renderqueue.getQueuedItems();var compIDs={};var comps=[];queuedItems.forEach(function(item){var comp=item.comp;var compID=comp.id;if(void 0===compIDs[compID]){
compIDs[compID]=true;comps.push(comp)}});return aeq.arrayEx(comps)},getRQItems:function(){return aeq.arrayEx(aeq.normalizeCollection(app.project.renderQueue.items))},getRQComps:function(){var rqItems=aeq.renderqueue.getRQItems();var compIDs={};var comps=[];rqItems.forEach(function(item){var comp=item.comp;var compID=comp.id;if(void 0===compIDs[compID]){compIDs[compID]=true;comps.push(comp)}});return aeq.arrayEx(comps)},getSettings:function(renderItem){return renderItem.getSettings(GetSettingsFormat.STRING)},ensureRenderPathExists:function(outputModule){aeq.app.ensureSecurityPrefEnabled();aeq.file.ensureFolderExists(outputModule.file.parent)},omTemplateExists:function(templateName){var tempComp=aeq.comp.create();var tempRQItem=aeq.renderqueue.queue(tempComp);var templates=aeq.arrayEx(tempRQItem.outputModule(1).templates);var templateExists=templates.exists(function(template){return template==templateName});tempRQItem.remove();tempComp.remove();return templateExists},rqTemplateExists:function(templateName){var tempComp=aeq.comp.create();var tempRQItem=aeq.renderqueue.queue(tempComp);var templates=aeq.arrayEx(tempRQItem.templates);var templateExists=templates.exists(function(template){return template==templateName});tempRQItem.remove();tempComp.remove();return templateExists}});aeq.settings=aeq.extend({},{toString:function(){return"[object aeq.settings]"},extend:aeq.extend,setting:function(sectionName,keyName,value){if(void 0!==value){aeq.settings.save(sectionName,keyName,value);return aeq}return aeq.settings.get(sectionName,keyName)},initSetting:function(sectionName,keyName,value,overwrite){overwrite=setDefault(overwrite,false);if(!aeq.settings.have(sectionName,keyName)||overwrite)aeq.settings.save(sectionName,keyName,value);return aeq.settings.get(sectionName,keyName)},get:function(sectionName,keyName){if(aeq.settings.have(sectionName,keyName))return app.settings.getSetting(sectionName,keyName);return},getAsBool:function(sectionName,keyName){var value=aeq.settings.get(sectionName,keyName);if("true"===value)return true;else if("false"===value)return false;return},getAsArray:function(sectionName,keyName){return aeq.settings.get(sectionName,keyName).split(",")},getAsFloat:function(sectionName,keyName){return parseFloat(aeq.settings.get(sectionName,keyName))},getAsInt:function(sectionName,keyName){return parseInt(aeq.settings.get(sectionName,keyName))},have:function(sectionName,keyName){return app.settings.haveSetting(sectionName,keyName)},save:function(sectionName,keyName,value){app.settings.saveSetting(sectionName,keyName,value)},unpack:function(sectionName,keyNames){var ret;ret=aeq.isObject(keyNames)?keyNames:{};aeq.forEach(keyNames,function(keyName){if(app.settings.haveSetting(sectionName,keyName))ret[keyName]=app.settings.getSetting(sectionName,keyName)});return ret}});aeq.saveSetting=aeq.setSetting=aeq.settings.set=aeq.settings.save;aeq.getSetting=aeq.settings.get;aeq.getSettingAsBool=aeq.settings.getAsBool;aeq.getSettingAsArray=aeq.settings.getAsArray;aeq.getSettingAsFloat=aeq.settings.getAsFloat;aeq.getSettingAsInt=aeq.settings.getAsInt;aeq.haveSetting=aeq.settings.have;aeq.unpackSettings=aeq.loadSettings=aeq.settings.load=aeq.settings.unpack;aeq.snippet=aeq.extend({},{toString:function(){return"[object aeq.snippet]"},extend:aeq.extend,activeComp:function(undoGroup,callback){var comp=getCompWithAlert();if(null===comp)return false;return aeq.createUndoGroup(undoGroup,callback,[comp])},selectedLayers:function(undoGroup,callback){var comp=getCompWithAlert();if(null===comp)return false;var layers=getSelectedLayersWithAlert(comp);if(null===layers)return false;layers=aeq.arrayEx(layers);return aeq.createUndoGroup(undoGroup,callback,[layers,comp])},selectedLayersOrAll:function(undoGroup,callback){var comp=getCompWithAlert();if(null===comp)return false;var layers=aeq.getSelectedLayersOrAll(comp);layers=aeq.arrayEx(layers);return aeq.createUndoGroup(undoGroup,callback,[layers,comp])},selectedProperties:function(undoGroup,callback){var comp=getCompWithAlert();if(null===comp)return false;var props=getSelectedPropertiesWithAlert(comp);if(null===props)return false;props=aeq.arrayEx(props);return aeq.createUndoGroup(undoGroup,callback,[props,comp])},forEachSelectedLayer:function(undoGroup,callback){return aeq.snippet.selectedLayers(undoGroup,function(layers){layers.forEach(callback);return layers})},forEachSelectedLayerOrAll:function(undoGroup,callback){return aeq.snippet.selectedLayersOrAll(undoGroup,function(layers){layers.forEach(callback);return layers})},forEachSelectedProperty:function(undoGroup,callback){return aeq.snippet.selectedProperties(undoGroup,function(props){props.forEach(callback);return props})}});function getCompWithAlert(){var comp=aeq.getActiveComp();if(null===comp)alert("No Comp selected");return comp}function getSelectedLayersWithAlert(comp){if(0===comp.selectedLayers.length){alert("No layers selected");return null}return comp.selectedLayers}function getSelectedPropertiesWithAlert(comp){if(0===comp.selectedProperties.length){alert("No properties selected");return null}return comp.selectedProperties}aeq.arrayEx=function(arr){arr=setDefault(arr,[]);if(arr._init)return arr;arr._init=true;arr.isAeq=true;aeq.extend(arr,arrayEx);return arr};var arrayEx={forEach:function(callback){var len=this.length;for(var i=0;i<len;i++)callback(this[i],i,this)},exists:function(callback){var len=this.length;for(var i=0;i<len;i++)if(callback(this[i],i,this))return true;return false},isTrueForAll:function(callback){var len=this.length;for(var i=0;i<len;i++)if(!callback(this[i],i,this))return false;return true},first:function(){if(0===this.length)throw new Error("There are no items in this array");return this[0]},find:function(callback,def){var len=this.length;for(var i=0;i<len;i++)if(callback(this[i],i,this))return this[i];return def},filter:function(callback){var filteredArr=[];var len=this.length;for(var i=0;i<len;i++)if(callback(this[i],i,this))filteredArr.push(this[i]);return aeq.arrayEx(filteredArr)},indexOf:function(searchElement,fromIndex){var k;if(null===this)throw new TypeError('"this" is null or not defined');var o=Object(this);var len=o.length>>>0;if(0===len)return-1;var n=+fromIndex||0;if(Math.abs(n)===1/0)n=0;if(n>=len)return-1;k=Math.max(n>=0?n:len-Math.abs(n),0);while(k<len){if(k in o&&o[k]===searchElement)return k;k++}return-1},select:function(callback){var selectedArr=[];var len=this.length;for(var i=0;i<len;i++)selectedArr.push(callback(this[i],i,this));return aeq.arrayEx(selectedArr)},map:function(callback){var obj={};var len=this.length;for(var i=0;i<len;i++){var o=callback(this[i],i,this);obj[o.key]=o.value}return obj},insertAt:function(insert,index){this.splice(index,0,insert)},attr:function(){[].unshift.call(arguments,this);return aeq.attr.apply(this,arguments)}};aeq.Comp=function(comp){if(comp instanceof aeq.Comp)return comp;if(this instanceof aeq.Comp)this.comp=comp;else return new aeq.Comp(comp)};aeq.Comp.prototype={isAeq:true,toString:function(){return"[object aeq.Comp]"},extend:aeq.extend,get:function(){return this.comp},forEachLayer:function(callback){var length=this.comp.numLayers,i=1;for(;i<=length;i++)callback(this.comp.layer(i),i,this)}};aeq.Key=function(property,index){if(this instanceof aeq.Key){if(property instanceof aeq.Property)property=property.get();if(index<=0||index>property.numKeys)throw new Error("Index "+index+" out of range 1-"+property.numKeys);this.property=property;this.index=index;this.originalTime=this.getTime()}else return new aeq.Key(property,index)};aeq.Key.prototype={isAeq:true,toString:function(){return"[object aeq.Key]"},extend:aeq.extend,checkKey:function(){if(this.index<=this.property.numKeys&&this.getTime()===this.originalTime)return;var newIndex=this.property.nearestKeyIndex(this.originalTime);if(this.property.keyTime(newIndex)===this.originalTime)this.index=newIndex;else throw new Error("Original key has been deleted/moved")},getTime:function(){return this.property.keyTime(this.index)},interpolationType:function(inType,outType){this.checkKey();if(0===arguments.length)return{inType:this.property.keyInInterpolationType(this.index),outType:this.property.keyOutInterpolationType(this.index)};if(void 0===outType&&inType.outType)outType=inType.outType;if(inType.inType)inType=inType.inType;if(aeq.isString(inType))inType=KeyframeInterpolationType[inType];if(outType&&aeq.isString(outType))outType=KeyframeInterpolationType[outType];else if(void 0===outType)outType=inType;if(!this.property.isInterpolationTypeValid(inType)||outType&&!this.property.isInterpolationTypeValid(outType))return false;this.property.setInterpolationTypeAtKey(this.index,inType,outType);return true},spatialTangent:function(inType,outType){this.checkKey();if(0===arguments.length)return{inTangent:this.property.keyInSpatialTangent(this.index),outTangent:this.property.keyOutSpatialTangent(this.index)};if(void 0===outType&&inType.outTangent)outType=inType.outTangent;if(inType.inTangent)inType=inType.inTangent;this.property.setSpatialTangentsAtKey(this.index,inType,outType)},temporalEase:function(inType,outType){this.checkKey();if(0===arguments.length)return{inEase:this.property.keyInTemporalEase(this.index),outEase:this.property.keyOutTemporalEase(this.index)};if(void 0===outType&&inType.outEase)outType=inType.outEase;if(inType.inEase)inType=inType.inEase;if(!aeq.isArray(inType))if(this.valueTypeIs("TwoD"))inType=[inType,inType];else if(this.valueTypeIs("ThreeD"))inType=[inType,inType,inType];else inType=[inType];if(outType&&!aeq.isArray(outType))if(this.valueTypeIs("TwoD"))outType=[outType,outType];else if(this.valueTypeIs("ThreeD"))outType=[outType,outType,outType];else outType=[outType];this.property.setTemporalEaseAtKey(this.index,inType,outType)},time:function(){this.checkKey();return this.originalTime},remove:function(){this.checkKey();this.property.removeKey(this.index)},getKeyinfo:function(){this.checkKey();var keyInfo={property:this.property,interpolationType:this.interpolationType(),value:this.value(),time:this.time()};if(keyInfo.interpolationType.inType===KeyframeInterpolationType.BEZIER&&keyInfo.interpolationType.outType===KeyframeInterpolationType.BEZIER){keyInfo.temporalAutoBezier=this.temporalAutoBezier();keyInfo.temporalContinuous=this.temporalContinuous()}if(keyInfo.interpolationType.outType!==KeyframeInterpolationType.HOLD)keyInfo.temporalEase=this.temporalEase();if(this.valueTypeIs("TwoD_SPATIAL")||this.valueTypeIs("ThreeD_SPATIAL")){keyInfo.spatialAutoBezier=this.spatialAutoBezier();keyInfo.spatialContinuous=this.spatialContinuous();keyInfo.spatialTangent=this.spatialTangent();keyInfo.roving=this.roving()}return keyInfo},copyTo:function(targetProp,time){var keyInfo=this.getKeyinfo();keyInfo.time=void 0!==time?time:keyInfo.time;if(targetProp.isAeq)targetProp=targetProp.get();keyInfo.property=targetProp;return aeq.pasteKey(keyInfo)},moveTo:function(time){var thisTime=this.time();if(time===thisTime)return;var newKey=this.copyTo(this.property,time);this.remove();this.index=this.property.nearestKeyIndex(newKey.time());this.originalTime=time},valueTypeIs:function valueTypeIs(type){return this.property.propertyValueType===PropertyValueType[type]}};aeq.forEach(["roving","selected","spatialAutoBezier","spatialContinuous","temporalAutoBezier","temporalContinuous","value"],function(type){var typeCapitalized=type.charAt(0).toUpperCase()+type.slice(1);var getter="key"+typeCapitalized;var setter="set"+typeCapitalized+"AtKey";aeq.Key.prototype[type]=function(){this.checkKey();if(0===arguments.length)return this.property[getter](this.index);[].unshift.call(arguments,this.index);this.property[setter].apply(this.property,arguments)}});aeq.pasteKey=function(keyInfo){var keyIndex=keyInfo.property.addKey(keyInfo.time);var key=new aeq.Key(keyInfo.property,keyIndex);if(2===keyInfo.property.value.length&&aeq.isArray(keyInfo.value)&&3===keyInfo.value.length){keyInfo.value=[keyInfo.value[0],keyInfo.value[1]];keyInfo.spatialTangent.inTangent=[keyInfo.spatialTangent.inTangent[0],keyInfo.spatialTangent.inTangent[1]];keyInfo.spatialTangent.outTangent=[keyInfo.spatialTangent.outTangent[0],keyInfo.spatialTangent.outTangent[1]]}key.value(keyInfo.value);if(void 0!==keyInfo.temporalEase)key.temporalEase(keyInfo.temporalEase);key.interpolationType(keyInfo.interpolationType);if(void 0!==keyInfo.temporalAutoBezier&&void 0!==keyInfo.temporalContinuous){key.temporalAutoBezier(keyInfo.temporalAutoBezier);key.temporalContinuous(keyInfo.temporalContinuous)}if(void 0!==keyInfo.spatialAutoBezier&&void 0!==keyInfo.spatialContinuous){key.spatialAutoBezier(keyInfo.spatialAutoBezier);key.spatialContinuous(keyInfo.spatialContinuous);key.spatialTangent(keyInfo.spatialTangent);key.roving(keyInfo.roving)}return key};aeq.Layer=function(layer){if(layer instanceof aeq.Layer)return layer;if(this instanceof aeq.Layer)this.layer=layer;else return new aeq.Layer(layer)};aeq.Layer.prototype={isAeq:true,toString:function(){return"[object aeq.Layer]"},extend:aeq.extend,get:function(){return this.layer},parent:function(selector){if(0===arguments.length)return this.layer.parent;if(null===selector){this.layer.parent=null;return null}var layer=getLayer(this.layer,selector);if(null===layer)return null;this.layer.parent=layer;return layer},copyToComp:function(comp){if(!aeq.isComp(comp))if(comp instanceof aeq.Comp)comp=comp.comp;else if(aeq.isString(comp))comp=aeq.getComp(comp);this.layer.copyToComp(comp);return this},removeParent:function(){this.layer.parent=null;return this},forEachEffect:function(callback){var effects=this.layer.property("ADBE Effect Parade"),length=effects.numProperties,i=1;for(;i<=length;i++)callback(effects.property(i),i,effects);return this},addEffect:function(effectName){var effects=this.layer.property("ADBE Effect Parade");if(effects.canAddProperty(effectName))effects.addProperty(effectName);else throw new Error('Can not add effect "'+effectName+'" to this layer')},children:function(){return aeq.layer.children(this.layer)},allChildren:function(){return aeq.layer.allChildren(this.layer)},parents:function(){return aeq.layer.parents(this.layer)},relatedLayers:function(){return aeq.layer.relatedLayers(this.layer)}};aeq.forEach(["active","index","isNameSet","selectedProperties","time","containingComp","hasVideo"],function(attribute){aeq.Layer.prototype[attribute]=function(){return this.layer[attribute]}});aeq.forEach(["comment","enabled","inPoint","locked","name","outPoint","shy","solo","startTime","stretch"],function(attribute){aeq.Layer.prototype[attribute]=function(newValue){if(0===arguments.length)return this.layer[attribute];this.layer[attribute]=newValue;return this}});aeq.forEach(["activeAtTime","applyPreset","duplicate","remove","moveToBeginning","moveToEnd"],function(method){aeq.Layer.prototype[method]=function(newValue){this.layer[method](newValue);return this}});aeq.forEach(["setParentWithJump","moveAfter","moveBefore"],function(method){aeq.Layer.prototype[method]=function(selector){var layer=getLayer(this.layer,selector);if(null===layer)return null;this.layer[method](layer);return layer}});var regexRelativeIndex=/^(\+|-)=/;function getLayer(baseLayer,selector){var index,offset;if(selector instanceof aeq.Layer)return selector.layer;if(aeq.isLayer(selector))return selector;if(aeq.isNumber(selector))return baseLayer.containingComp.layer(selector);if(aeq.isString(selector)){if(regexRelativeIndex.test(selector)){offset=getRelativeIndex(selector);if(offset){index=baseLayer.index+offset;if(0===index||index>baseLayer.containingComp.numLayers)return null;return baseLayer.containingComp.layer(index)}}return baseLayer.containingComp.layer(selector)}return null}function getRelativeIndex(str){var offset=str.charAt(0)+str.substr(2);offset=parseInt(offset,10);if(isNaN(offset))return false;return offset}aeq.Property=function(property){if(property instanceof aeq.Property)return property;if(this instanceof aeq.Property)this.property=property;else return new aeq.Property(property)};aeq.Property.prototype={isAeq:true,toString:function(){return"[object aeq.Property]"},extend:aeq.extend,get:function(){return this.property},expression:function(newValue){if(!this.property.canSetExpression)return false;if(0===arguments.length)return this.property.expression;this.property.expression=newValue;if(""===this.property.expressionError&&(this.property.expressionEnabled||""===newValue))return true;return this.property.expressionError},selectedKeys:function(){var selectedKeys=[];for(var i=1;i<=this.property.selectedKeys.length;i++)selectedKeys.push(this.key(i));return selectedKeys},addKey:function(time){var keyIndex=this.property.addKey(time);return this.key(keyIndex)},separationFollower:function(dim){return this.property.getSeparationFollower(dim)},nearestKeyIndex:function(time){var keyIndex=this.property.nearestKeyIndex(time);return this.key(keyIndex)},removeKey:function(keyIndex){if(aeq.isNumber(keyIndex))this.property.removeKey(keyIndex);else if("[object aeq.Key]"===keyIndex.toString())keyIndex.remove()},separationLeader:function(){if(this.property.isSeparationFollower)return this.property.separationLeader;return null},separationDimension:function(){if(this.property.isSeparationFollower)return this.property.separationDimension;return null},maxValue:function(){if(this.property.hasMax)return this.property.maxValue;return null},minValue:function(){if(this.property.hasMin)return this.property.minValue;return null},value:function(newValue){if(0===arguments.length)return this.property.value;this.property.setValue(newValue)},valueAtTime:function(time,value){if(1===arguments.length)return this.property.valueAtTime(time);this.property.setValueAtTime(time,value);return this.nearestKeyIndex(time)},valuesAtTimes:function(times,values){var result=[],i=0,il=times.length;if(1===arguments.length){for(;i<il;i++)result.push(this.property.valueAtTime(times[i]));return result}this.property.setValuesAtTimes(times,values);for(;i<il;i++)result.push(this.nearestKeyIndex(times[i]));return result},forEachKey:function(callback){var keys=this.getKeys();var length=keys.length,i=0;for(;i<length;i++)callback(keys[i],keys[i].index,this.property)},key:function(keyIndex){return new aeq.Key(this.property,keyIndex)},getKeys:function(){var keys=[];var length=this.property.numKeys,i=1;for(;i<=length;i++)keys.push(this.key(i));return aeq.arrayEx(keys)}};aeq.forEach(["expressionError","isTimeVarying","numKeys","canSetExpression","canVaryOverTime","isSpatial","isSeparationFollower","isSeparationLeader","propertyIndex","propertyValueType","unitsText"],function(attribute){aeq.Property.prototype[attribute]=function(){return this.property[attribute]}});return aeq}();var cssselector=function(){"use strict";function peg$subclass(child,parent){function ctor(){this.constructor=child}ctor.prototype=parent.prototype;child.prototype=new ctor}function peg$SyntaxError(message,expected,found,location){this.message=message;this.expected=expected;this.found=found;this.location=location;this.name="SyntaxError";if("function"===typeof Error.captureStackTrace)Error.captureStackTrace(this,peg$SyntaxError)}peg$subclass(peg$SyntaxError,Error);function peg$parse(input){var options=arguments.length>1?arguments[1]:{},parser=this,peg$FAILED={},peg$startRuleFunctions={Start:peg$parseStart},peg$startRuleFunction=peg$parseStart,peg$c0="[",peg$c1={type:"literal",value:"[",description:'"["'},peg$c2="]",peg$c3={type:"literal",value:"]",description:'"]"'},peg$c4=function(props){return mergeProps(props)},peg$c5="(",peg$c6={type:"literal",value:"(",description:'"("'},peg$c7=")",peg$c8={type:"literal",value:")",description:'")"'},peg$c9=/^[a-zA-Z]/,peg$c10={type:"class",value:"[a-zA-Z]",description:"[a-zA-Z]"},peg$c11=function(name){var o={};var key=name.join("");o[key]={type:"Bool",value:true};return o},peg$c12="=",peg$c13={type:"literal",value:"=",description:'"="'},peg$c14=function(name,value){var o={};var key=name.join("");o[key]=value;return o},peg$c15=function(type,props,pseudo){return{type:type.join("").toLowerCase(),props:props,pseudo:pseudo}},peg$c16=":",peg$c17={type:"literal",value:":",description:'":"'},peg$c18=function(type,props){return{type:type.join("").toLowerCase(),props:props}},peg$c19=function(literal){return literal},peg$c20=function(){return{type:"Bool",value:true}},peg$c21=function(){return{type:"Bool",value:false}},peg$c22="0",peg$c23={type:"literal",value:"0",description:'"0"'},peg$c24=/^[0-9]/,peg$c25={type:"class",value:"[0-9]",description:"[0-9]"},peg$c26=/^[1-9]/,peg$c27={type:"class",value:"[1-9]",description:"[1-9]"},peg$c28=".",peg$c29={type:"literal",value:".",description:'"."'},peg$c30=function(){return{type:"Number",value:parseFloat(text())}},peg$c31=function(){return{type:"Integer",value:parseFloat(text())}},peg$c32="0x",peg$c33={type:"literal",value:"0x",description:'"0x"'},peg$c34=function(digits){return{type:"Hex",value:parseInt(digits,16)}},peg$c35=/^[0-9a-f]/i,peg$c36={type:"class",value:"[0-9a-f]i",description:"[0-9a-f]i"},peg$c37='"',peg$c38={type:"literal",value:'"',description:'"\\""'},peg$c39=function(chars){return{type:"String",value:chars.join("")}},peg$c40="'",peg$c41={type:"literal",value:"'",description:'"\'"'},peg$c42="\\",peg$c43={type:"literal",value:"\\",description:'"\\\\"'},peg$c44={type:"any",description:"any character"},peg$c45=function(){return text()},peg$c46=function(sequence){return sequence},peg$c47=function(){return""},peg$c48=function(){return"\0"},peg$c49="b",peg$c50={type:"literal",value:"b",description:'"b"'},peg$c51=function(){return"\b"},peg$c52="f",peg$c53={type:"literal",value:"f",description:'"f"'},peg$c54=function(){return"\f"},peg$c55="n",peg$c56={type:"literal",value:"n",description:'"n"'},peg$c57=function(){return"\n"},peg$c58="r",peg$c59={type:"literal",value:"r",description:'"r"'},peg$c60=function(){return"\r"},peg$c61="t",peg$c62={type:"literal",value:"t",description:'"t"'},peg$c63=function(){return"\t"},peg$c64="v",peg$c65={type:"literal",value:"v",description:'"v"'},peg$c66=function(){return"\v"},peg$c67="x",peg$c68={type:"literal",value:"x",description:'"x"'},peg$c69="u",peg$c70={type:"literal",value:"u",description:'"u"'},peg$c71=function(digits){return String.fromCharCode(parseInt(digits,16))},peg$c72=/^[\n\r\u2028\u2029]/,peg$c73={type:"class",value:"[\\n\\r\\u2028\\u2029]",description:"[\\n\\r\\u2028\\u2029]"},peg$c74={type:"other",description:"end of line"},peg$c75="\n",peg$c76={type:"literal",value:"\n",description:'"\\n"'},peg$c77="\r\n",peg$c78={type:"literal",value:"\r\n",description:'"\\r\\n"'},peg$c79="\r",peg$c80={type:"literal",value:"\r",description:'"\\r"'},peg$c81="\u2028",peg$c82={type:"literal",value:"\u2028",description:'"\\u2028"'},peg$c83="\u2029",peg$c84={type:"literal",value:"\u2029",description:'"\\u2029"'},peg$c85=function(head,tail){head.push(tail);return{type:"Array",value:head}},peg$c86=",",peg$c87={type:"literal",value:",",description:'","'},peg$c88=function(value){return value},peg$c89="true",peg$c90={type:"literal",value:"true",description:'"true"'},peg$c91="false",peg$c92={type:"literal",value:"false",description:'"false"'},peg$c93={type:"other",description:"whitespace"},peg$c94=/^[ \t\n\r]/,peg$c95={type:"class",value:"[ \\t\\n\\r]",description:"[ \\t\\n\\r]"},peg$c96={type:"other",description:"regular expression"},peg$c97="/",peg$c98={type:"literal",value:"/",description:'"/"'},peg$c99=function(body,flags){return{type:"RegExp",body:body,flags:flags,value:new RegExp(body,flags)}},peg$c100=function(char_,chars){return char_+chars},peg$c101=function(chars){return chars.join("")},peg$c102=/^[*\\\/[]/,peg$c103={type:"class",value:"[*\\\\/[]",description:"[*\\\\/[]"},peg$c104=function(char_){return char_},peg$c105=/^[\\\/[]/,peg$c106={type:"class",value:"[\\\\/[]",description:"[\\\\/[]"},peg$c107=function(char_){return"\\"+char_},peg$c108=function(chars){return"["+chars+"]"},peg$c109=/^[\]\\]/,peg$c110={type:"class",value:"[\\]\\\\]",description:"[\\]\\\\]"},peg$c111=/^[gimuy]/,peg$c112={type:"class",value:"[gimuy]",description:"[gimuy]"},peg$c113=function(parts){return parts.join("")},peg$currPos=0,peg$savedPos=0,peg$posDetailsCache=[{line:1,column:1,seenCR:false}],peg$maxFailPos=0,peg$maxFailExpected=[],peg$silentFails=0,peg$result;if("startRule"in options){if(!(options.startRule in peg$startRuleFunctions))throw new Error("Can't start parsing from rule \""+options.startRule+'".');peg$startRuleFunction=peg$startRuleFunctions[options.startRule]}function text(){return input.substring(peg$savedPos,peg$currPos)}function location(){return peg$computeLocation(peg$savedPos,peg$currPos)}function expected(description){throw peg$buildException(null,[{type:"other",description:description}],input.substring(peg$savedPos,peg$currPos),peg$computeLocation(peg$savedPos,peg$currPos))}function error(message){throw peg$buildException(message,null,input.substring(peg$savedPos,peg$currPos),peg$computeLocation(peg$savedPos,peg$currPos))}function peg$computePosDetails(pos){var details=peg$posDetailsCache[pos],p,ch;if(details)return details;else{p=pos-1;while(!peg$posDetailsCache[p])p--;details=peg$posDetailsCache[p];details={line:details.line,column:details.column,seenCR:details.seenCR};while(p<pos){ch=input.charAt(p);if("\n"===ch){if(!details.seenCR)details.line++;details.column=1;details.seenCR=false}else if("\r"===ch||"\u2028"===ch||"\u2029"===ch){details.line++;details.column=1;details.seenCR=true}else{details.column++;details.seenCR=false}p++}peg$posDetailsCache[pos]=details;return details}}function peg$computeLocation(startPos,endPos){var startPosDetails=peg$computePosDetails(startPos),endPosDetails=peg$computePosDetails(endPos);return{start:{offset:startPos,line:startPosDetails.line,column:startPosDetails.column},end:{offset:endPos,line:endPosDetails.line,column:endPosDetails.column}}}function peg$fail(expected){if(peg$currPos<peg$maxFailPos)return;if(peg$currPos>peg$maxFailPos){peg$maxFailPos=peg$currPos;peg$maxFailExpected=[]}peg$maxFailExpected.push(expected)}function peg$buildException(message,expected,found,location){function cleanupExpected(expected){var i=1;expected.sort(function(a,b){if(a.description<b.description)return-1;else if(a.description>b.description)return 1;else return 0});while(i<expected.length)if(expected[i-1]===expected[i])expected.splice(i,1);else i++}function buildMessage(expected,found){function stringEscape(s){function hex(ch){return ch.charCodeAt(0).toString(16).toUpperCase()}return s.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,function(ch){return"\\x0"+hex(ch)}).replace(/[\x10-\x1F\x80-\xFF]/g,function(ch){return"\\x"+hex(ch)}).replace(/[\u0100-\u0FFF]/g,function(ch){return"\\u0"+hex(ch)}).replace(/[\u1000-\uFFFF]/g,function(ch){return"\\u"+hex(ch)})}var expectedDescs=new Array(expected.length),expectedDesc,foundDesc,i;for(i=0;i<expected.length;i++)expectedDescs[i]=expected[i].description;expectedDesc=expected.length>1?expectedDescs.slice(0,-1).join(", ")+" or "+expectedDescs[expected.length-1]:expectedDescs[0];foundDesc=found?'"'+stringEscape(found)+'"':"end of input";return"Expected "+expectedDesc+" but "+foundDesc+" found."}if(null!==expected)cleanupExpected(expected);return new peg$SyntaxError(null!==message?message:buildMessage(expected,found),expected,found,location)}function peg$parseStart(){var s0;s0=peg$parseSelectors();return s0}function peg$parsePropertiesBrackets(){var s0,s1,s2,s3;s0=peg$currPos;if(91===input.charCodeAt(peg$currPos)){s1=peg$c0;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c1)}if(s1!==peg$FAILED){s2=[];s3=peg$parseProperty();while(s3!==peg$FAILED){s2.push(s3);s3=peg$parseProperty()}if(s2!==peg$FAILED){if(93===input.charCodeAt(peg$currPos)){s3=peg$c2;peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c3)}if(s3!==peg$FAILED){peg$savedPos=s0;s1=peg$c4(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parsePropertiesParentheses(){var s0,s1,s2,s3;s0=peg$currPos;if(40===input.charCodeAt(peg$currPos)){s1=peg$c5;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c6)}if(s1!==peg$FAILED){s2=[];s3=peg$parseProperty();while(s3!==peg$FAILED){s2.push(s3);s3=peg$parseProperty()}if(s2!==peg$FAILED){if(41===input.charCodeAt(peg$currPos)){s3=peg$c7;peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c8)}if(s3!==peg$FAILED){peg$savedPos=s0;s1=peg$c4(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseProperty(){var s0;s0=peg$parseValuePair();if(s0===peg$FAILED)s0=peg$parseValueSingle();return s0}function peg$parseValueSingle(){var s0,s1,s2;s0=peg$currPos;s1=[];if(peg$c9.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}if(s2!==peg$FAILED)while(s2!==peg$FAILED){s1.push(s2);if(peg$c9.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}}else s1=peg$FAILED;if(s1!==peg$FAILED){s2=peg$parse_();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c11(s1);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseValuePair(){var s0,s1,s2,s3,s4;s0=peg$currPos;s1=[];if(peg$c9.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}if(s2!==peg$FAILED)while(s2!==peg$FAILED){s1.push(s2);if(peg$c9.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}}else s1=peg$FAILED;if(s1!==peg$FAILED){if(61===input.charCodeAt(peg$currPos)){s2=peg$c12;peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c13)}if(s2!==peg$FAILED){s3=peg$parseValue();if(s3!==peg$FAILED){s4=peg$parse_();if(s4===peg$FAILED)s4=null;if(s4!==peg$FAILED){peg$savedPos=s0;s1=peg$c14(s1,s3);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseSelector(){var s0,s1,s2,s3,s4;s0=peg$currPos;s1=[];if(peg$c9.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}if(s2!==peg$FAILED)while(s2!==peg$FAILED){s1.push(s2);if(peg$c9.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}}else s1=peg$FAILED;if(s1!==peg$FAILED){s2=peg$parsePropertiesBrackets();if(s2===peg$FAILED)s2=null;if(s2!==peg$FAILED){s3=[];s4=peg$parsePseudo();while(s4!==peg$FAILED){s3.push(s4);s4=peg$parsePseudo()}if(s3!==peg$FAILED){s4=peg$parse_();if(s4===peg$FAILED)s4=null;if(s4!==peg$FAILED){peg$savedPos=s0;s1=peg$c15(s1,s2,s3);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseSelectors(){var s0,s1;s0=[];s1=peg$parseSelector();if(s1!==peg$FAILED)while(s1!==peg$FAILED){s0.push(s1);s1=peg$parseSelector()}else s0=peg$FAILED;return s0}function peg$parsePseudo(){var s0,s1,s2,s3;s0=peg$currPos;if(58===input.charCodeAt(peg$currPos)){s1=peg$c16;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c17)}if(s1!==peg$FAILED){s2=[];if(peg$c9.test(input.charAt(peg$currPos))){s3=input.charAt(peg$currPos);peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}while(s3!==peg$FAILED){s2.push(s3);if(peg$c9.test(input.charAt(peg$currPos))){s3=input.charAt(peg$currPos);peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c10)}}if(s2!==peg$FAILED){s3=peg$parsePropertiesParentheses();if(s3===peg$FAILED)s3=null;if(s3!==peg$FAILED){peg$savedPos=s0;s1=peg$c18(s2,s3);s0=s1}else{peg$currPos=s0;
s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseValue(){var s0;s0=peg$parseBooleanLiteral();if(s0===peg$FAILED){s0=peg$parseNumericLiteral();if(s0===peg$FAILED){s0=peg$parseStringLiteral();if(s0===peg$FAILED){s0=peg$parseArrayLiteral();if(s0===peg$FAILED)s0=peg$parseRegularExpressionLiteral()}}}return s0}function peg$parseNumericLiteral(){var s0,s1,s2,s3;s0=peg$currPos;s1=peg$parseHexIntegerLiteral();if(s1!==peg$FAILED){s2=peg$currPos;peg$silentFails++;s3=peg$parseDecimalDigit();peg$silentFails--;if(s3===peg$FAILED)s2=void 0;else{peg$currPos=s2;s2=peg$FAILED}if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c19(s1);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$currPos;s1=peg$parseDecimalLiteral();if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c19(s1)}s0=s1}return s0}function peg$parseBooleanLiteral(){var s0,s1;s0=peg$currPos;s1=peg$parseTrueToken();if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c20()}s0=s1;if(s0===peg$FAILED){s0=peg$currPos;s1=peg$parseFalseToken();if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c21()}s0=s1}return s0}function peg$parseDecimalIntegerLiteral(){var s0,s1,s2,s3;if(48===input.charCodeAt(peg$currPos)){s0=peg$c22;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c23)}if(s0===peg$FAILED){s0=peg$currPos;s1=peg$parseNonZeroDigit();if(s1!==peg$FAILED){s2=[];s3=peg$parseDecimalDigit();while(s3!==peg$FAILED){s2.push(s3);s3=peg$parseDecimalDigit()}if(s2!==peg$FAILED){s1=[s1,s2];s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}return s0}function peg$parseDecimalDigit(){var s0;if(peg$c24.test(input.charAt(peg$currPos))){s0=input.charAt(peg$currPos);peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c25)}return s0}function peg$parseNonZeroDigit(){var s0;if(peg$c26.test(input.charAt(peg$currPos))){s0=input.charAt(peg$currPos);peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c27)}return s0}function peg$parseDecimalLiteral(){var s0,s1,s2,s3,s4;s0=peg$currPos;s1=peg$parseDecimalIntegerLiteral();if(s1!==peg$FAILED){if(46===input.charCodeAt(peg$currPos)){s2=peg$c28;peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c29)}if(s2!==peg$FAILED){s3=[];s4=peg$parseDecimalDigit();while(s4!==peg$FAILED){s3.push(s4);s4=peg$parseDecimalDigit()}if(s3!==peg$FAILED){peg$savedPos=s0;s1=peg$c30();s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$currPos;if(46===input.charCodeAt(peg$currPos)){s1=peg$c28;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c29)}if(s1!==peg$FAILED){s2=[];s3=peg$parseDecimalDigit();if(s3!==peg$FAILED)while(s3!==peg$FAILED){s2.push(s3);s3=peg$parseDecimalDigit()}else s2=peg$FAILED;if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c30();s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$currPos;s1=peg$parseDecimalIntegerLiteral();if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c31()}s0=s1}}return s0}function peg$parseHexIntegerLiteral(){var s0,s1,s2,s3,s4;s0=peg$currPos;if(input.substr(peg$currPos,2).toLowerCase()===peg$c32){s1=input.substr(peg$currPos,2);peg$currPos+=2}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c33)}if(s1!==peg$FAILED){s2=peg$currPos;s3=[];s4=peg$parseHexDigit();if(s4!==peg$FAILED)while(s4!==peg$FAILED){s3.push(s4);s4=peg$parseHexDigit()}else s3=peg$FAILED;if(s3!==peg$FAILED)s2=input.substring(s2,peg$currPos);else s2=s3;if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c34(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseHexDigit(){var s0;if(peg$c35.test(input.charAt(peg$currPos))){s0=input.charAt(peg$currPos);peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c36)}return s0}function peg$parseStringLiteral(){var s0,s1,s2,s3;s0=peg$currPos;if(34===input.charCodeAt(peg$currPos)){s1=peg$c37;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c38)}if(s1!==peg$FAILED){s2=[];s3=peg$parseDoubleStringCharacter();while(s3!==peg$FAILED){s2.push(s3);s3=peg$parseDoubleStringCharacter()}if(s2!==peg$FAILED){if(34===input.charCodeAt(peg$currPos)){s3=peg$c37;peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c38)}if(s3!==peg$FAILED){peg$savedPos=s0;s1=peg$c39(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$currPos;if(39===input.charCodeAt(peg$currPos)){s1=peg$c40;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c41)}if(s1!==peg$FAILED){s2=[];s3=peg$parseSingleStringCharacter();while(s3!==peg$FAILED){s2.push(s3);s3=peg$parseSingleStringCharacter()}if(s2!==peg$FAILED){if(39===input.charCodeAt(peg$currPos)){s3=peg$c40;peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c41)}if(s3!==peg$FAILED){peg$savedPos=s0;s1=peg$c39(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}return s0}function peg$parseDoubleStringCharacter(){var s0,s1,s2;s0=peg$currPos;s1=peg$currPos;peg$silentFails++;if(34===input.charCodeAt(peg$currPos)){s2=peg$c37;peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c38)}if(s2===peg$FAILED){if(92===input.charCodeAt(peg$currPos)){s2=peg$c42;peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c43)}if(s2===peg$FAILED)s2=peg$parseLineTerminator()}peg$silentFails--;if(s2===peg$FAILED)s1=void 0;else{peg$currPos=s1;s1=peg$FAILED}if(s1!==peg$FAILED){if(input.length>peg$currPos){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c44)}if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c45();s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$currPos;if(92===input.charCodeAt(peg$currPos)){s1=peg$c42;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c43)}if(s1!==peg$FAILED){s2=peg$parseEscapeSequence();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c46(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED)s0=peg$parseLineContinuation()}return s0}function peg$parseSingleStringCharacter(){var s0,s1,s2;s0=peg$currPos;s1=peg$currPos;peg$silentFails++;if(39===input.charCodeAt(peg$currPos)){s2=peg$c40;peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c41)}if(s2===peg$FAILED){if(92===input.charCodeAt(peg$currPos)){s2=peg$c42;peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c43)}if(s2===peg$FAILED)s2=peg$parseLineTerminator()}peg$silentFails--;if(s2===peg$FAILED)s1=void 0;else{peg$currPos=s1;s1=peg$FAILED}if(s1!==peg$FAILED){if(input.length>peg$currPos){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c44)}if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c45();s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$currPos;if(92===input.charCodeAt(peg$currPos)){s1=peg$c42;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c43)}if(s1!==peg$FAILED){s2=peg$parseEscapeSequence();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c46(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED)s0=peg$parseLineContinuation()}return s0}function peg$parseLineContinuation(){var s0,s1,s2;s0=peg$currPos;if(92===input.charCodeAt(peg$currPos)){s1=peg$c42;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c43)}if(s1!==peg$FAILED){s2=peg$parseLineTerminatorSequence();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c47();s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseEscapeSequence(){var s0,s1,s2,s3;s0=peg$parseCharacterEscapeSequence();if(s0===peg$FAILED){s0=peg$currPos;if(48===input.charCodeAt(peg$currPos)){s1=peg$c22;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c23)}if(s1!==peg$FAILED){s2=peg$currPos;peg$silentFails++;s3=peg$parseDecimalDigit();peg$silentFails--;if(s3===peg$FAILED)s2=void 0;else{peg$currPos=s2;s2=peg$FAILED}if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c48();s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$parseHexEscapeSequence();if(s0===peg$FAILED)s0=peg$parseUnicodeEscapeSequence()}}return s0}function peg$parseCharacterEscapeSequence(){var s0;s0=peg$parseSingleEscapeCharacter();if(s0===peg$FAILED)s0=peg$parseNonEscapeCharacter();return s0}function peg$parseSingleEscapeCharacter(){var s0,s1;if(39===input.charCodeAt(peg$currPos)){s0=peg$c40;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c41)}if(s0===peg$FAILED){if(34===input.charCodeAt(peg$currPos)){s0=peg$c37;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c38)}if(s0===peg$FAILED){if(92===input.charCodeAt(peg$currPos)){s0=peg$c42;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c43)}if(s0===peg$FAILED){s0=peg$currPos;if(98===input.charCodeAt(peg$currPos)){s1=peg$c49;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c50)}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c51()}s0=s1;if(s0===peg$FAILED){s0=peg$currPos;if(102===input.charCodeAt(peg$currPos)){s1=peg$c52;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c53)}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c54()}s0=s1;if(s0===peg$FAILED){s0=peg$currPos;if(110===input.charCodeAt(peg$currPos)){s1=peg$c55;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c56)}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c57()}s0=s1;if(s0===peg$FAILED){s0=peg$currPos;if(114===input.charCodeAt(peg$currPos)){s1=peg$c58;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c59)}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c60()}s0=s1;if(s0===peg$FAILED){s0=peg$currPos;if(116===input.charCodeAt(peg$currPos)){s1=peg$c61;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c62)}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c63()}s0=s1;if(s0===peg$FAILED){s0=peg$currPos;if(118===input.charCodeAt(peg$currPos)){s1=peg$c64;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c65)}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c66()}s0=s1}}}}}}}}return s0}function peg$parseNonEscapeCharacter(){var s0,s1,s2;s0=peg$currPos;s1=peg$currPos;peg$silentFails++;s2=peg$parseEscapeCharacter();if(s2===peg$FAILED)s2=peg$parseLineTerminator();peg$silentFails--;if(s2===peg$FAILED)s1=void 0;else{peg$currPos=s1;s1=peg$FAILED}if(s1!==peg$FAILED){if(input.length>peg$currPos){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c44)}if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c45();s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseEscapeCharacter(){var s0;s0=peg$parseSingleEscapeCharacter();if(s0===peg$FAILED){s0=peg$parseDecimalDigit();if(s0===peg$FAILED){if(120===input.charCodeAt(peg$currPos)){s0=peg$c67;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c68)}if(s0===peg$FAILED)if(117===input.charCodeAt(peg$currPos)){s0=peg$c69;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c70)}}}return s0}function peg$parseHexEscapeSequence(){var s0,s1,s2,s3,s4,s5;s0=peg$currPos;if(120===input.charCodeAt(peg$currPos)){s1=peg$c67;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c68)}if(s1!==peg$FAILED){s2=peg$currPos;s3=peg$currPos;s4=peg$parseHexDigit();if(s4!==peg$FAILED){s5=peg$parseHexDigit();if(s5!==peg$FAILED){s4=[s4,s5];s3=s4}else{peg$currPos=s3;s3=peg$FAILED}}else{peg$currPos=s3;s3=peg$FAILED}if(s3!==peg$FAILED)s2=input.substring(s2,peg$currPos);else s2=s3;if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c71(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseUnicodeEscapeSequence(){var s0,s1,s2,s3,s4,s5,s6,s7;s0=peg$currPos;if(117===input.charCodeAt(peg$currPos)){s1=peg$c69;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c70)}if(s1!==peg$FAILED){s2=peg$currPos;s3=peg$currPos;s4=peg$parseHexDigit();if(s4!==peg$FAILED){s5=peg$parseHexDigit();if(s5!==peg$FAILED){s6=peg$parseHexDigit();if(s6!==peg$FAILED){s7=peg$parseHexDigit();if(s7!==peg$FAILED){s4=[s4,s5,s6,s7];s3=s4}else{peg$currPos=s3;s3=peg$FAILED}}else{peg$currPos=s3;s3=peg$FAILED}}else{peg$currPos=s3;s3=peg$FAILED}}else{peg$currPos=s3;s3=peg$FAILED}if(s3!==peg$FAILED)s2=input.substring(s2,peg$currPos);else s2=s3;if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c71(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseLineTerminator(){var s0;if(peg$c72.test(input.charAt(peg$currPos))){s0=input.charAt(peg$currPos);peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c73)}return s0}function peg$parseLineTerminatorSequence(){var s0,s1;peg$silentFails++;if(10===input.charCodeAt(peg$currPos)){s0=peg$c75;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c76)}if(s0===peg$FAILED){if(input.substr(peg$currPos,2)===peg$c77){s0=peg$c77;peg$currPos+=2}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c78)}if(s0===peg$FAILED){if(13===input.charCodeAt(peg$currPos)){s0=peg$c79;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c80)}if(s0===peg$FAILED){if(8232===input.charCodeAt(peg$currPos)){s0=peg$c81;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c82)}if(s0===peg$FAILED)if(8233===input.charCodeAt(peg$currPos)){s0=peg$c83;peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c84)}}}}peg$silentFails--;if(s0===peg$FAILED){s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c74)}return s0}function peg$parseArrayLiteral(){var s0,s1,s2,s3,s4,s5,s6,s7;s0=peg$currPos;if(91===input.charCodeAt(peg$currPos)){s1=peg$c0;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c1)}if(s1!==peg$FAILED){s2=peg$parse_();if(s2!==peg$FAILED){s3=[];s4=peg$parseArrayValue();while(s4!==peg$FAILED){s3.push(s4);s4=peg$parseArrayValue()}if(s3!==peg$FAILED){s4=peg$parse_();if(s4!==peg$FAILED){s5=peg$parseValue();if(s5!==peg$FAILED){s6=peg$parse_();if(s6!==peg$FAILED){if(93===input.charCodeAt(peg$currPos)){s7=peg$c2;peg$currPos++}else{s7=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c3)}if(s7!==peg$FAILED){peg$savedPos=s0;s1=peg$c85(s3,s5);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseArrayValue(){var s0,s1,s2,s3,s4;s0=peg$currPos;s1=peg$parseValue();if(s1!==peg$FAILED){s2=peg$parse_();if(s2!==peg$FAILED){if(44===input.charCodeAt(peg$currPos)){s3=peg$c86;peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c87)}if(s3!==peg$FAILED){s4=peg$parse_();if(s4!==peg$FAILED){peg$savedPos=s0;s1=peg$c88(s1);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseTrueToken(){var s0,s1,s2;s0=peg$currPos;if(input.substr(peg$currPos,4)===peg$c89){s1=peg$c89;peg$currPos+=4}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c90)}if(s1!==peg$FAILED){s2=peg$parse_();if(s2===peg$FAILED)s2=null;if(s2!==peg$FAILED){s1=[s1,s2];s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseFalseToken(){var s0,s1,s2;s0=peg$currPos;if(input.substr(peg$currPos,5)===peg$c91){s1=peg$c91;peg$currPos+=5}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c92)}if(s1!==peg$FAILED){s2=peg$parse_();if(s2===peg$FAILED)s2=null;if(s2!==peg$FAILED){s1=[s1,s2];s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parse_(){var s0,s1;peg$silentFails++;s0=[];if(peg$c94.test(input.charAt(peg$currPos))){s1=input.charAt(peg$currPos);peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c95)}while(s1!==peg$FAILED){s0.push(s1);if(peg$c94.test(input.charAt(peg$currPos))){s1=input.charAt(peg$currPos);peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c95)}}peg$silentFails--;if(s0===peg$FAILED){s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c93)}return s0}function peg$parseRegularExpressionLiteral(){var s0,s1,s2,s3,s4;peg$silentFails++;s0=peg$currPos;if(47===input.charCodeAt(peg$currPos)){s1=peg$c97;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c98)}if(s1!==peg$FAILED){s2=peg$parseRegularExpressionBody();if(s2!==peg$FAILED){if(47===input.charCodeAt(peg$currPos)){s3=peg$c97;peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c98)}if(s3!==peg$FAILED){s4=peg$parseRegularExpressionFlags();if(s4!==peg$FAILED){peg$savedPos=s0;s1=peg$c99(s2,s4);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}peg$silentFails--;if(s0===peg$FAILED){s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c96)}return s0}function peg$parseRegularExpressionBody(){var s0,s1,s2;s0=peg$currPos;s1=peg$parseRegularExpressionFirstChar();if(s1!==peg$FAILED){s2=peg$parseRegularExpressionChars();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c100(s1,s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseRegularExpressionChars(){var s0,s1,s2;s0=peg$currPos;s1=[];s2=peg$parseRegularExpressionChar();while(s2!==peg$FAILED){s1.push(s2);s2=peg$parseRegularExpressionChar()}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c101(s1)}s0=s1;return s0}function peg$parseRegularExpressionFirstChar(){var s0,s1,s2;s0=peg$currPos;s1=peg$currPos;peg$silentFails++;if(peg$c102.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c103)}peg$silentFails--;if(s2===peg$FAILED)s1=void 0;else{peg$currPos=s1;s1=peg$FAILED}if(s1!==peg$FAILED){s2=peg$parseRegularExpressionNonTerminator();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c104(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$parseRegularExpressionBackslashSequence();if(s0===peg$FAILED)s0=peg$parseRegularExpressionClass()}return s0}function peg$parseRegularExpressionChar(){var s0,s1,s2;s0=peg$currPos;s1=peg$currPos;peg$silentFails++;if(peg$c105.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c106)}peg$silentFails--;if(s2===peg$FAILED)s1=void 0;else{peg$currPos=s1;s1=peg$FAILED}if(s1!==peg$FAILED){s2=peg$parseRegularExpressionNonTerminator();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c104(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED){s0=peg$parseRegularExpressionBackslashSequence();if(s0===peg$FAILED)s0=peg$parseRegularExpressionClass()}return s0}function peg$parseRegularExpressionBackslashSequence(){var s0,s1,s2;s0=peg$currPos;if(92===input.charCodeAt(peg$currPos)){s1=peg$c42;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c43)}if(s1!==peg$FAILED){s2=peg$parseRegularExpressionNonTerminator();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c107(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseRegularExpressionNonTerminator(){var s0,s1,s2;s0=peg$currPos;s1=peg$currPos;peg$silentFails++;s2=peg$parseLineTerminator();peg$silentFails--;if(s2===peg$FAILED)s1=void 0;else{peg$currPos=s1;s1=peg$FAILED}if(s1!==peg$FAILED){s2=peg$parseSourceCharacter();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c104(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseRegularExpressionClass(){var s0,s1,s2,s3;s0=peg$currPos;if(91===input.charCodeAt(peg$currPos)){s1=peg$c0;peg$currPos++}else{s1=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c1)}if(s1!==peg$FAILED){s2=peg$parseRegularExpressionClassChars();if(s2!==peg$FAILED){if(93===input.charCodeAt(peg$currPos)){s3=peg$c2;peg$currPos++}else{s3=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c3)}if(s3!==peg$FAILED){peg$savedPos=s0;s1=peg$c108(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}return s0}function peg$parseRegularExpressionClassChars(){var s0,s1,s2;s0=peg$currPos;s1=[];s2=peg$parseRegularExpressionClassChar();while(s2!==peg$FAILED){s1.push(s2);s2=peg$parseRegularExpressionClassChar()}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c101(s1)}s0=s1;return s0}function peg$parseRegularExpressionClassChar(){var s0,s1,s2;s0=peg$currPos;s1=peg$currPos;peg$silentFails++;if(peg$c109.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c110)}peg$silentFails--;if(s2===peg$FAILED)s1=void 0;else{peg$currPos=s1;s1=peg$FAILED}if(s1!==peg$FAILED){s2=peg$parseRegularExpressionNonTerminator();if(s2!==peg$FAILED){peg$savedPos=s0;s1=peg$c104(s2);s0=s1}else{peg$currPos=s0;s0=peg$FAILED}}else{peg$currPos=s0;s0=peg$FAILED}if(s0===peg$FAILED)s0=peg$parseRegularExpressionBackslashSequence();return s0}function peg$parseRegularExpressionFlags(){var s0,s1,s2;s0=peg$currPos;s1=[];if(peg$c111.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c112)}while(s2!==peg$FAILED){s1.push(s2);if(peg$c111.test(input.charAt(peg$currPos))){s2=input.charAt(peg$currPos);peg$currPos++}else{s2=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c112)}}if(s1!==peg$FAILED){peg$savedPos=s0;s1=peg$c113(s1)}s0=s1;return s0}function peg$parseSourceCharacter(){var s0;if(input.length>peg$currPos){s0=input.charAt(peg$currPos);peg$currPos++}else{s0=peg$FAILED;if(0===peg$silentFails)peg$fail(peg$c44)}return s0}function mergeProps(array){var merged={};for(var i=0;i<array.length;i++){var pair=array[i];for(var key in pair)if(pair.hasOwnProperty(key))merged[key]=pair[key]}return merged}peg$result=peg$startRuleFunction();if(peg$result!==peg$FAILED&&peg$currPos===input.length)return peg$result;else{if(peg$result!==peg$FAILED&&peg$currPos<input.length)peg$fail({type:"end",description:"end of input"});throw peg$buildException(null,peg$maxFailExpected,peg$maxFailPos<input.length?input.charAt(peg$maxFailPos):null,peg$maxFailPos<input.length?peg$computeLocation(peg$maxFailPos,peg$maxFailPos+1):peg$computeLocation(peg$maxFailPos,peg$maxFailPos))}}return{SyntaxError:peg$SyntaxError,parse:peg$parse}}();aeq.ui=function(ui){ui.Container=function(obj){this.obj=obj};ui.Container.prototype={toString:function(){return"[object aeq.ui.Container]"},extend:aeq.extend,get:function(){return this.obj},set:function(options){ui.set(this.obj,options)},_add:function(type,options){if(aeq.isObject(options.arg1)&&!aeq.isArray(options.arg1)){options=options.arg1;options.arg1=options.items||options.text}var obj=this.obj.add(type,options.bounds,options.arg1,options.properties);ui.set(obj,options);return obj},addButton:function(arg1,onClick,properties){return this._add("button",{arg1:arg1,properties:properties,onClick:onClick})},addCheckbox:function(arg1,onClick,properties){return this._add("checkbox",{arg1:arg1,properties:properties,onClick:onClick})},addDropdownList:function(arg1,onChange,properties){return this._add("dropdownlist",{arg1:arg1,properties:properties,onChange:onChange})},addEditText:function(arg1,onChange,onChanging,properties){return this._add("edittext",{arg1:arg1,properties:properties,onChange:onChange,onChanging:onChanging})},addGroup:function(options){var group=this.obj.add("group");group=new ui.Container(group);if(options)group.set(options);return group},addIconButton:function(arg1,onClick,properties){var options={arg1:arg1,onClick:onClick,properties:properties};if(aeq.isObject(options.arg1)&&!aeq.isArray(options.arg1)&&!aeq.isFile(options.arg1)&&void 0===options.arg1.format){options=options.arg1;options.arg1=options.image||void 0}var obj=this.obj.add("iconbutton",options.bounds,options.arg1,options.properties);ui.set(obj,options);return obj},addImage:function(arg1,onClick,properties){var options={arg1:arg1,onClick:onClick,properties:properties};if(aeq.isObject(options.arg1)&&!aeq.isArray(options.arg1)&&!aeq.isFile(options.arg1)&&void 0===options.arg1.format){options=options.arg1;options.arg1=options.image||void 0}var obj=this.obj.add("image",options.bounds,options.arg1,options.properties);ui.set(obj,options);return obj},addListBox:function(arg1,onChange,onDoubleClick,properties){return this._add("listbox",{arg1:arg1,properties:properties,onChange:onChange,onDoubleClick:onDoubleClick})},addPanel:function(arg1,properties){var panel=this._add("panel",{arg1:arg1,properties:properties});return new ui.Container(panel)},addProgressbar:function(value,maxValue){return this.obj.add("progressbar",void 0,value,maxValue)},addRadioButton:function(arg1,onClick,properties){return this._add("radiobutton",{arg1:arg1,properties:properties,onClick:onClick})},addScrollbar:function(value,maxValue,onChange,onChanging){var scrollbar=this.obj.add("scrollbar",void 0,value,maxValue);scrollbar.onChange=onChange;scrollbar.onChanging=onChanging;return scrollbar},addSlider:function(value,minValue,maxValue,onChange,onChanging){var slider=this.obj.add("slider",void 0,value,minValue,maxValue);slider.onChange=onChange;slider.onChanging=onChanging;return slider},addStaticText:function(arg1,properties){return this._add("statictext",{arg1:arg1,properties:properties})},addTab:function(text){var tab=this.obj.add("tab",void 0,text);return new ui.Container(tab)},addTabbedPanel:function(){var tabbedpanel=this.obj.add("tabbedpanel");return new ui.Container(tabbedpanel)},addTreeView:function(arg1,onChange,properties){return this._add("treeview",{arg1:arg1,properties:properties,onChange:onChange})},update:function(){this.obj.layout.layout(true);this.obj.layout.resize()},remove:function(obj){if(obj instanceof ui.Container)obj=obj.obj;this.obj.remove(obj)},removeChildren:function(obj){if(obj instanceof ui.Container)obj=obj.obj;for(var i=obj.children.length-1;i>=0;i--)obj.remove(obj.children[i])},removeAll:function(){for(var i=this.obj.children.length-1;i>=0;i--)this.obj.remove(this.obj.children[i])}};ui.Container.prototype.addListbox=ui.Container.prototype.addListBox;ui.Container.prototype.addStatictext=ui.Container.prototype.addStaticText;ui.Container.prototype.addTreeview=ui.Container.prototype.addTreeView;(function createControllerSetters(){var oneParameters=["enabled","helpTip","orientation","text","visible"],twoParameters=["alignChildren","alignment","location","maximumSize","minimumSize","preferredSize","size"],fourParameters=["bounds","margins"];aeq.forEach(oneParameters,function(type){ui.Container.prototype[type]=function(newValue){if(void 0===newValue)return this.obj[type];this.obj[type]=newValue}});function multiParameter(type,numParameters){return function(newValue){if(void 0===newValue)return this.obj[type];newValue=arguments.length===numParameters?Array.apply(null,arguments):arguments[0];this.obj[type]=newValue}}aeq.forEach(twoParameters,function(type){ui.Container.prototype[type]=multiParameter(type,2)});aeq.forEach(fourParameters,function(type){ui.Container.prototype[type]=multiParameter(type,4)})})();return ui}(aeq.ui||{});aeq.ui=function(ui){ui.createMainWindow=function(thisObj,title,opt){if(aeq.isPanel(thisObj))return new ui.Window(thisObj);if(aeq.isString(thisObj)){opt=title;title=thisObj}opt=aeq.setDefault(opt,{resizeable:true});var root=new Window("palette",title,void 0,opt);aeq.ui.root=root;return new ui.Window(root)};ui.createWindow=function(title,options){options=aeq.setDefault(options,{resizeable:true});var newWindow=new Window("palette",title,void 0,options);return new ui.Window(newWindow)};ui.createDialog=function(title,options){options=aeq.setDefault(options,{resizeable:true});var newWindow=new Window("dialog",title,void 0,options);return new ui.Window(newWindow)};ui.ready=function(callback){callback()};ui.set=function(obj,options){for(var option in options)if(options.hasOwnProperty(option)&&"properties"!==option&&"arg1"!==option)obj[option]=options[option]};return ui}(aeq.ui||{});aeq.ui=function(ui){ui.Window=function(obj){this.obj=obj};ui.Window.prototype=ui.Container.prototype;ui.Window.prototype.show=function(){this.layout();if(aeq.isWindow(this.obj))return this.obj.show()};ui.Window.prototype.hide=function(){if(aeq.isWindow(this.obj))this.obj.hide()};ui.Window.prototype.close=function(value){if(aeq.isWindow(this.obj))this.obj.close(value)};ui.Window.prototype.layout=function(){this.obj.layout.layout(true);this.obj.layout.resize();this.obj.onResizing=this.obj.onResize=function(){this.layout.resize()}};return ui}(aeq.ui||{});
/* aequery */
/**
* Gets data from file contents starting at specified sectionHeader
*
* @param {String} fileContents File contents to search in
* @param {String} sectionHeader Name of section header to find
* @returns {{"times": Number[], "values": Number[]}} Object containing times and values arrays
*/
function getSectionData (fileContents, sectionHeader) {
var start = fileContents.indexOf(sectionHeader);
var end = fileContents.indexOf("\t)", start);
var section = fileContents.substring(start, end);
var sectionSplit = aeq.arrayEx(section.split("\n"));
sectionSplit.shift();
sectionSplit.pop();
var times = [];
var values = [];
var firstTime = aeq.framesToTime(sectionSplit[0].match(/t\((.*?)\)/)[1], rootComp.frameRate);
sectionSplit.forEach(function (chunk) {
var time = aeq.framesToTime(chunk.match(/t\((.*?)\)/)[1], rootComp.frameRate);
var value = chunk.match(/v\((.*?)\)/)[1];
times.push(time - firstTime);
values.push(value);
});
return {
"times" : times,
"values" : values
}
}
var yawHeader = "c(n(S-Yaw$NL) m(-100000) M(100000) d(0)";
var pitchHeader = "c(n(S-Pitch) m(-100000) M(100000) d(0)";
var rollHeader = "c(n(S-Roll) m(-100000) M(100000) d(0)";
var scriptFile = File.openDialog("Select your .grp file", "*.grp", false);
if (aeq.isNullOrUndefined(scriptFile))
return;
var fileContents = aeq.file.readFile(scriptFile);
if (aeq.isNullOrUndefined(fileContents))
return;
app.beginUndoGroup("Mistika to AE");
var rootComp = aeq.comp.create();
rootComp.frameRate = 60;
var yaw = getSectionData(fileContents, yawHeader);
var pitch = getSectionData(fileContents, pitchHeader);
var roll = getSectionData(fileContents, rollHeader);
// Set up comp info
rootComp.name = aeq.file.stripExtension(scriptFile.displayName);
rootComp.displayStartTime = yaw.times[0];
rootComp.duration = yaw.times[yaw.times.length - 1] - yaw.times[0];
// Build controller null
var controller = rootComp.layers.addNull();
controller.name = "Stabilization Controller";
var yawSliderControl = controller.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
yawSliderControl.name = "Yaw";
var pitchSliderControl = controller.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
pitchSliderControl.name = "Pitch";
var rollSliderControl = controller.property("ADBE Effect Parade").addProperty("ADBE Slider Control");
rollSliderControl.name = "Roll";
var yawSlider = controller.property("ADBE Effect Parade").property(1).property("ADBE Slider Control-0001");
var pitchSlider = controller.property("ADBE Effect Parade").property(2).property("ADBE Slider Control-0001");
var rollSlider = controller.property("ADBE Effect Parade").property(3).property("ADBE Slider Control-0001");
var numValues = yaw.times.length;
var start = 0;
var current = 0;
while (current < numValues) {
start = current;
current += 1000;
current = Math.min(current, numValues);
yawSlider.setValuesAtTimes(yaw.times.slice(start, current), yaw.values.slice(start, current));
pitchSlider.setValuesAtTimes(pitch.times.slice(start, current), pitch.values.slice(start, current));
rollSlider.setValuesAtTimes(roll.times.slice(start, current), roll.values.slice(start, current));
}
rootComp.openInViewer();
app.endUndoGroup();
})();