!function e(t,n,r){function i(u,s){if(!n[u]){if(!t[u]){var p="function"==typeof require&&require;if(!s&&p)return p(u,!0);if(o)return o(u,!0);throw new Error("Cannot find module '"+u+"'")}var l=n[u]={exports:{}};t[u][0].call(l.exports,function(e){var n=t[u][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;ur;r++)t=e[r],n[t.user]=t.state;return n},p=function(){return o(n.getOperationCounter())},s=function(e){var t,r;return r=u(e),t={hb:n._encode(r),state_vector:o(n.getOperationCounter())}},i=function(e){return n.renewStateVector(u(e.state_vector)),t.applyOpsCheckDouble(e.hb)},e.whenSyncing(p,s,i),e.whenReceiving(function(e,r){return r.uid.creator!==n.getUserId()?t.applyOp(r):void 0}),null!=e._whenBoundToYatta?e._whenBoundToYatta():void 0},t.exports=n},{}],2:[function(e,t){var n;"undefined"!=typeof window&&null!==window&&(window.unprocessed_counter=0),"undefined"!=typeof window&&null!==window&&(window.unprocessed_exec_counter=0),"undefined"!=typeof window&&null!==window&&(window.unprocessed_types=[]),n=function(){function e(e,t){this.HB=e,this.types=t,this.unprocessed_ops=[]}return e.prototype.parseOperation=function(e){var t;if(t=this.types[e.type],null!=(null!=t?t.parse:void 0))return t.parse(e);throw new Error("You forgot to specify a parser for type "+e.type+". The message is "+JSON.stringify(e)+".")},e.prototype.applyOpsCheckDouble=function(e){var t,n,r,i;for(i=[],n=0,r=e.length;r>n;n++)t=e[n],null==this.HB.getOperation(t.uid)?i.push(this.applyOp(t)):i.push(void 0);return i},e.prototype.applyOps=function(e){return this.applyOp(e)},e.prototype.applyOp=function(e){var t,n,r,i;for(e.constructor!==Array&&(e=[e]),r=0,i=e.length;i>r;r++)n=e[r],t=this.parseOperation(n),null!=this.HB.getOperation(t)||this.HB.isExpectedOperation(t)&&t.execute()||(this.unprocessed_ops.push(t),"undefined"!=typeof window&&null!==window&&window.unprocessed_types.push(t.type));return this.tryUnprocessed()},e.prototype.tryUnprocessed=function(){for(var e,t,n,r,i,o;;){for(e=this.unprocessed_ops.length,n=[],o=this.unprocessed_ops,r=0,i=o.length;i>r;r++)t=o[r],null!=this.HB.getOperation(t)||this.HB.isExpectedOperation(t)&&t.execute()||n.push(t);if(this.unprocessed_ops=n,this.unprocessed_ops.length===e)break}return 0!==this.unprocessed_ops.length?this.HB.invokeSync():void 0},e}(),t.exports=n},{}],3:[function(e,t){var n,r=function(e,t){return function(){return e.apply(t,arguments)}};n=function(){function e(e){this.user_id=e,this.emptyGarbage=r(this.emptyGarbage,this),this.operation_counter={},this.buffer={},this.change_listeners=[],this.garbage=[],this.trash=[],this.performGarbageCollection=!0,this.garbageCollectTimeout=2e4,this.reserved_identifier_counter=0,setTimeout(this.emptyGarbage,this.garbageCollectTimeout)}return e.prototype.resetUserId=function(e){var t,n,r;if(r=this.buffer[this.user_id],null!=r){for(n in r)t=r[n],t.uid.creator=e;if(null!=this.buffer[e])throw new Error("You are re-assigning an old user id - this is not (yet) possible!");this.buffer[e]=r,delete this.buffer[this.user_id]}return this.operation_counter[e]=this.operation_counter[this.user_id],delete this.operation_counter[this.user_id],this.user_id=e},e.prototype.emptyGarbage=function(){var e,t,n,r;for(r=this.garbage,t=0,n=r.length;n>t;t++)e=r[t],"function"==typeof e.cleanup&&e.cleanup();return this.garbage=this.trash,this.trash=[],-1!==this.garbageCollectTimeout&&(this.garbageCollectTimeoutId=setTimeout(this.emptyGarbage,this.garbageCollectTimeout)),void 0},e.prototype.getUserId=function(){return this.user_id},e.prototype.addToGarbageCollector=function(){var e,t,n,r;if(this.performGarbageCollection){for(r=[],t=0,n=arguments.length;n>t;t++)e=arguments[t],null!=e?r.push(this.garbage.push(e)):r.push(void 0);return r}},e.prototype.stopGarbageCollection=function(){return this.performGarbageCollection=!1,this.setManualGarbageCollect(),this.garbage=[],this.trash=[]},e.prototype.setManualGarbageCollect=function(){return this.garbageCollectTimeout=-1,clearTimeout(this.garbageCollectTimeoutId),this.garbageCollectTimeoutId=void 0},e.prototype.setGarbageCollectTimeout=function(e){this.garbageCollectTimeout=e},e.prototype.getReservedUniqueIdentifier=function(){return{creator:"_",op_number:"_"+this.reserved_identifier_counter++,doSync:!1}},e.prototype.getOperationCounter=function(e){var t,n,r,i;if(null==e){n={},i=this.operation_counter;for(r in i)t=i[r],n[r]=t;return n}return this.operation_counter[e]},e.prototype.isExpectedOperation=function(e){var t,n;return null==(t=this.operation_counter)[n=e.uid.creator]&&(t[n]=0),e.uid.op_number<=this.operation_counter[e.uid.creator]},e.prototype._encode=function(e){var t,n,r,i,o,u,s,p,l,a;null==e&&(e={}),t=[],p=function(t,n){if(null==t||null==n)throw new Error("dah!");return null==e[t]||e[t]<=n},a=this.buffer;for(s in a){l=a[s];for(o in l)if(n=l[o],n.uid.doSync&&p(s,o)){if(r=n._encode(),null!=n.next_cl){for(i=n.next_cl;null!=i.next_cl&&p(i.uid.creator,i.uid.op_number);)i=i.next_cl;r.next=i.getUid()}else if(null!=n.prev_cl){for(u=n.prev_cl;null!=u.prev_cl&&p(u.uid.creator,u.uid.op_number);)u=u.prev_cl;r.prev=u.getUid()}t.push(r)}}return t},e.prototype.getNextOperationIdentifier=function(e){var t;return null==e&&(e=this.user_id),null==this.operation_counter[e]&&(this.operation_counter[e]=0),t={creator:e,op_number:this.operation_counter[e],doSync:!0},this.operation_counter[e]++,t},e.prototype.getOperation=function(e){var t,n;return null!=e.uid&&(e=e.uid),t=null!=(n=this.buffer[e.creator])?n[e.op_number]:void 0,null!=e.sub&&null!=t?t.retrieveSub(e.sub):t},e.prototype.addOperation=function(e){if(null==this.buffer[e.uid.creator]&&(this.buffer[e.uid.creator]={}),null!=this.buffer[e.uid.creator][e.uid.op_number])throw new Error("You must not overwrite operations!");if(e.uid.op_number.constructor!==String&&!this.isExpectedOperation(e))throw new Error("this operation was not expected!");return this.addToCounter(e),this.buffer[e.uid.creator][e.uid.op_number]=e,e},e.prototype.removeOperation=function(e){var t;return null!=(t=this.buffer[e.uid.creator])?delete t[e.uid.op_number]:void 0},e.prototype.setInvokeSyncHandler=function(e){return this.invokeSync=e},e.prototype.invokeSync=function(){},e.prototype.renewStateVector=function(e){var t,n,r;r=[];for(n in e)t=e[n],null==this.operation_counter[n]||this.operation_counter[n]i;i++)t=u[i],s.push(t.call.apply(t,[r].concat(n.call(e))));return s},r.prototype.isDeleted=function(){return this.is_deleted},r.prototype.applyDelete=function(t){return null==t&&(t=!0),!this.garbage_collected&&(this.is_deleted=!0,t)?(this.garbage_collected=!0,e.addToGarbageCollector(this)):void 0},r.prototype.cleanup=function(){return e.removeOperation(this),this.deleteAllObservers()},r.prototype.setParent=function(e){this.parent=e},r.prototype.getParent=function(){return this.parent},r.prototype.getUid=function(){return null==this.uid.noOperation?this.uid:this.uid.alt},r.prototype.cloneUid=function(){var e,t,n,r;t={},r=this.getUid();for(e in r)n=r[e],t[e]=n;return t},r.prototype.dontSync=function(){return this.uid.doSync=!1},r.prototype.execute=function(){var n,r,i;if(this.is_executed=!0,null==this.uid&&(this.uid=e.getNextOperationIdentifier()),null==this.uid.noOperation)for(e.addOperation(this),r=0,i=t.length;i>r;r++)n=t[r],n(this._encode());return this},r.prototype.saveOperation=function(e,t){return null!=(null!=t?t.execute:void 0)?this[e]=t:null!=t?(null==this.unchecked&&(this.unchecked={}),this.unchecked[e]=t):void 0},r.prototype.validateSavedOperations=function(){var t,n,r,i,o,u;o={},i=this,u=this.unchecked;for(t in u)r=u[t],n=e.getOperation(r),n?this[t]=n:(o[t]=r,i=!1);return delete this.unchecked,i||(this.unchecked=o),i},r}(),r.Delete=function(e){function t(e,n){this.saveOperation("deletes",n),t.__super__.constructor.call(this,e)}return i(t,e),t.prototype.type="Delete",t.prototype._encode=function(){return{type:"Delete",uid:this.getUid(),deletes:this.deletes.getUid()}},t.prototype.execute=function(){var e;return this.validateSavedOperations()?(e=t.__super__.execute.apply(this,arguments),e&&this.deletes.applyDelete(this),e):!1},t}(r.Operation),r.Delete.parse=function(e){var t,n;return n=e.uid,t=e.deletes,new this(n,t)},r.Insert=function(e){function t(e,n,r,i,o){this.saveOperation("parent",o),this.saveOperation("prev_cl",n),this.saveOperation("next_cl",r),null!=i?this.saveOperation("origin",i):this.saveOperation("origin",n),t.__super__.constructor.call(this,e)}return i(t,e),t.prototype.type="Insert",t.prototype.applyDelete=function(e){var n,r,i;return null==this.deleted_by&&(this.deleted_by=[]),n=!1,null==this.parent||this.isDeleted()||null==e||(n=!0),null!=e&&this.deleted_by.push(e),r=!1,this.next_cl.isDeleted()&&(r=!0),t.__super__.applyDelete.call(this,r),n&&this.callOperationSpecificDeleteEvents(e),(null!=(i=this.prev_cl)?i.isDeleted():void 0)?this.prev_cl.applyDelete():void 0},t.prototype.cleanup=function(){var e,n,r,i,o;if(this.next_cl.isDeleted()){for(o=this.deleted_by,r=0,i=o.length;i>r;r++)e=o[r],e.cleanup();for(n=this.next_cl;"Delimiter"!==n.type;)n.origin===this&&(n.origin=this.prev_cl),n=n.next_cl;return this.prev_cl.next_cl=this.next_cl,this.next_cl.prev_cl=this.prev_cl,t.__super__.cleanup.apply(this,arguments)}},t.prototype.getDistanceToOrigin=function(){var e,t;for(e=0,t=this.prev_cl;;){if(this.origin===t)break;e++,t=t.prev_cl}return e},t.prototype.execute=function(){var e,n,r;if(this.validateSavedOperations()){if(null!=this.parent&&(null==this.prev_cl&&(this.prev_cl=this.parent.beginning),null==this.origin&&(this.origin=this.parent.beginning),null==this.next_cl&&(this.next_cl=this.parent.end)),null!=this.prev_cl){for(e=this.getDistanceToOrigin(),r=this.prev_cl.next_cl,n=e;;){if(r===this.next_cl)break;if(r.getDistanceToOrigin()===n)r.uid.creatorn;n++)t=e[n],null!=t.changedBy||"add"!==t.type&&!(t.type="update")?i.push(void 0):i.push(s.val(t.name,t.object[t.name]));return i}),this.observe(function(t){var r,i,o,u,p,l;for(l=[],u=0,p=t.length;p>u;u++)r=t[u],r.created_!==e.getUserId()?(i=n.getNotifier(s.bound_json),o=s.bound_json[r.name],null!=o?(i.performChange("update",function(){return s.bound_json[r.name]=s.val(r.name)},s.bound_json),l.push(i.notify({object:s.bound_json,type:"update",name:r.name,oldValue:o,changedBy:r.changedBy}))):(i.performChange("add",function(){return s.bound_json[r.name]=s.val(r.name)},s.bound_json),l.push(i.notify({object:s.bound_json,type:"add",name:r.name,oldValue:o,changedBy:r.changedBy})))):l.push(void 0);return l})),this.bound_json},n.prototype.val=function(e,t){var i,o,u,s,p,l;if(null!=e&&arguments.length>1){if(null!=t&&null!=t.constructor){if(s=r[t.constructor.name],null!=s&&null!=s.create){for(i=[],o=p=1,l=arguments.length;l>=1?l>p:p>l;o=l>=1?++p:--p)i.push(arguments[o]);return u=s.create.apply(null,i),n.__super__.val.call(this,e,u)}throw new Error("The "+t.constructor.name+"-type is not (yet) supported in Yatta.")}return n.__super__.val.call(this,e,new r.ImmutableObject(void 0,t).execute())}return n.__super__.val.call(this,e)},n.prototype._encode=function(){return{type:this.type,uid:this.getUid()}},n}(r.MapManager),r.Object.parse=function(e){var t;return t=e.uid,new this(t)},r.Object.create=function(e,t){var n,i,o;n=(new r.Object).execute();for(i in e)o=e[i],n.val(i,o,t);return n},r.Number={},r.Number.create=function(e){return new r.ImmutableObject(void 0,e).execute()},t}},{"./TextTypes":7}],6:[function(e,t){var n,r={}.hasOwnProperty,i=function(e,t){function n(){this.constructor=e}for(var i in t)r.call(t,i)&&(e[i]=t[i]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e};n=e("./BasicTypes"),t.exports=function(e){var t,r;return t=n(e),r=t.types,r.MapManager=function(e){function t(e){this.map={},t.__super__.constructor.call(this,e)}return i(t,e),t.prototype.type="MapManager",t.prototype.applyDelete=function(){var e,n,r;r=this.map;for(e in r)n=r[e],n.applyDelete();return t.__super__.applyDelete.call(this)},t.prototype.cleanup=function(){return t.__super__.cleanup.call(this)},t.prototype.val=function(e,t){var n,i,o,u,s;if(null!=t)return this.retrieveSub(e).replace(t),this;if(null!=e)return o=this.map[e],null==o||o.isContentDeleted()?void 0:(i=o.val(),i instanceof r.ImmutableObject?i.val():i);u={},s=this.map;for(e in s)n=s[e],n.isContentDeleted()||(i=n.val(),i instanceof r.ImmutableObject&&(i=i.val()),u[e]=i);return u},t.prototype["delete"]=function(e){var t;return null!=(t=this.map[e])&&t.deleteContent(),this},t.prototype.retrieveSub=function(e){var t,n,i,o,u;return null==this.map[e]&&(t={name:e},n=this,i=this.cloneUid(),i.sub=e,u={noOperation:!0,alt:i},o=new r.ReplaceManager(t,n,u),this.map[e]=o,o.setParent(this,e),o.execute()),this.map[e]},t}(r.Operation),r.ListManager=function(e){function t(e){this.beginning=new r.Delimiter(void 0,void 0),this.end=new r.Delimiter(this.beginning,void 0),this.beginning.next_cl=this.end,this.beginning.execute(),this.end.execute(),t.__super__.constructor.call(this,e)}return i(t,e),t.prototype.type="ListManager",t.prototype.execute=function(){return this.validateSavedOperations()?(this.beginning.setParent(this),this.end.setParent(this),t.__super__.execute.apply(this,arguments)):!1},t.prototype.getLastOperation=function(){return this.end.prev_cl},t.prototype.getFirstOperation=function(){return this.beginning.next_cl},t.prototype.toArray=function(){var e,t;for(e=this.beginning.next_cl,t=[];e!==this.end;)t.push(e),e=e.next_cl;return t},t.prototype.getOperationByPosition=function(e){var t;for(t=this.beginning;;){if(t instanceof r.Delimiter&&null!=t.prev_cl){for(t=t.prev_cl;t.isDeleted()||!(t instanceof r.Delimiter);)t=t.prev_cl;break}if(0>=e&&!t.isDeleted())break;t=t.next_cl,t.isDeleted()||(e-=1)}return t},t}(r.Operation),r.ReplaceManager=function(e){function t(e,n,r,i,o){this.event_properties=e,this.event_this=n,null==this.event_properties.object&&(this.event_properties.object=this.event_this),t.__super__.constructor.call(this,r,i,o)}return i(t,e),t.prototype.type="ReplaceManager",t.prototype.applyDelete=function(){var e;for(e=this.beginning;null!=e;)e.applyDelete(),e=e.next_cl;return t.__super__.applyDelete.call(this)},t.prototype.cleanup=function(){return t.__super__.cleanup.call(this)},t.prototype.callEventDecorator=function(e){var t,n,r,i,o,u;if(!this.isDeleted()){for(i=0,o=e.length;o>i;i++){t=e[i],u=this.event_properties;for(n in u)r=u[n],t[n]=r}this.event_this.callEvent(e)}return void 0},t.prototype.replace=function(e,t){var n,i;return n=this.getLastOperation(),i=new r.Replaceable(e,this,t,n,n.next_cl).execute(),void 0},t.prototype.isContentDeleted=function(){return this.getLastOperation().isDeleted()},t.prototype.deleteContent=function(){return new r.Delete(void 0,this.getLastOperation().uid).execute(),void 0},t.prototype.val=function(){var e;return e=this.getLastOperation(),"function"==typeof e.val?e.val():void 0},t.prototype._encode=function(){var e;return e={type:this.type,uid:this.getUid(),beginning:this.beginning.getUid(),end:this.end.getUid()}},t}(r.ListManager),r.Replaceable=function(e){function t(e,n,r,i,o,u,s){this.saveOperation("content",e),this.saveOperation("parent",n),t.__super__.constructor.call(this,r,i,o,u),this.is_deleted=s}return i(t,e),t.prototype.type="Replaceable",t.prototype.val=function(){return this.content},t.prototype.applyDelete=function(){var e;return e=t.__super__.applyDelete.apply(this,arguments),null!=this.content&&("Delimiter"!==this.next_cl.type&&this.content.deleteAllObservers(),this.content.applyDelete(),this.content.dontSync()),this.content=null,e},t.prototype.cleanup=function(){return t.__super__.cleanup.apply(this,arguments)},t.prototype.callOperationSpecificInsertEvents=function(){var e;return"Delimiter"===this.next_cl.type&&"Delimiter"!==this.prev_cl.type?(this.is_deleted||(e=this.prev_cl.content,this.parent.callEventDecorator([{type:"update",changedBy:this.uid.creator,oldValue:e}])),this.prev_cl.applyDelete()):"Delimiter"!==this.next_cl.type?this.applyDelete():this.parent.callEventDecorator([{type:"add",changedBy:this.uid.creator}]),void 0},t.prototype.callOperationSpecificDeleteEvents=function(e){return"Delimiter"===this.next_cl.type?this.parent.callEventDecorator([{type:"delete",changedBy:e.uid.creator,oldValue:this.content}]):void 0},t.prototype._encode=function(){var e,t;return e={type:this.type,content:null!=(t=this.content)?t.getUid():void 0,parent:this.parent.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),origin:this.origin.getUid(),uid:this.getUid(),is_deleted:this.is_deleted}},t}(r.Insert),r.Replaceable.parse=function(e){var t,n,r,i,o,u,s;return t=e.content,o=e.parent,s=e.uid,u=e.prev,r=e.next,i=e.origin,n=e.is_deleted,new this(t,o,s,u,r,i,n)},t}},{"./BasicTypes":4}],7:[function(e,t){var n,r={}.hasOwnProperty,i=function(e,t){function n(){this.constructor=e}for(var i in t)r.call(t,i)&&(e[i]=t[i]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e};n=e("./StructuredTypes"),t.exports=function(e){var t,r,o;return r=n(e),o=r.types,t=r.parser,o.TextInsert=function(e){function t(e,n,r,i,o,u){var s;(null!=e?null!=(s=e.uid)?s.creator:void 0:void 0)?this.saveOperation("content",e):this.content=e,t.__super__.constructor.call(this,n,r,i,o,u)}return i(t,e),t.prototype.type="TextInsert",t.prototype.getLength=function(){return this.isDeleted()?0:this.content.length},t.prototype.applyDelete=function(){return t.__super__.applyDelete.apply(this,arguments),this.content instanceof o.Operation&&this.content.applyDelete(),this.content=null},t.prototype.execute=function(){return this.validateSavedOperations()?(this.content instanceof o.Operation&&(this.content.insert_parent=this),t.__super__.execute.call(this)):!1},t.prototype.val=function(){return this.isDeleted()||null==this.content?"":this.content},t.prototype._encode=function(){var e,t;return e={type:this.type,uid:this.getUid(),prev:this.prev_cl.getUid(),next:this.next_cl.getUid(),origin:this.origin.getUid(),parent:this.parent.getUid()},e.content=null!=(null!=(t=this.content)?t.getUid:void 0)?this.content.getUid():this.content,e},t}(o.Insert),o.TextInsert.parse=function(e){var t,n,r,i,u,s;return t=e.content,s=e.uid,u=e.prev,n=e.next,r=e.origin,i=e.parent,new o.TextInsert(t,s,u,n,r,i)},o.Array=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return i(t,e),t.prototype.type="Array",t.prototype.applyDelete=function(){var e;for(e=this.end;null!=e;)e.applyDelete(),e=e.prev_cl;return t.__super__.applyDelete.call(this)},t.prototype.cleanup=function(){return t.__super__.cleanup.call(this)},t.prototype.val=function(){var e,t;for(e=this.beginning.next_cl,t=[];e!==this.end;)t.push(e.val()),e=e.next_cl;return t},t.prototype.push=function(e){return this.insertAfter(this.end.prev_cl,e)},t.prototype.insertAfter=function(e,t){var n,r,i,u,s;for(r=e.next_cl;r.isDeleted();)r=r.next_cl;if(e=r.prev_cl,null!=t.type)new o.TextInsert(t,void 0,e,r).execute();else for(u=0,s=t.length;s>u;u++)n=t[u],i=new o.TextInsert(n,void 0,e,r).execute(),e=i;return this},t.prototype.insert=function(e,t){var n;return n=this.getOperationByPosition(e),this.insertAfter(n,t)},t.prototype["delete"]=function(e,t){var n,r,i,u,s;for(u=this.getOperationByPosition(e+1),r=[],i=s=0;(t>=0?t>s:s>t)&&!(u instanceof o.Delimiter);i=t>=0?++s:--s){for(n=new o.Delete(void 0,u).execute(),u=u.next_cl;!(u instanceof o.Delimiter)&&u.isDeleted();)u=u.next_cl;r.push(n._encode())}return this},t.prototype._encode=function(){var e;return e={type:this.type,uid:this.getUid()}},t}(o.ListManager),o.Array.parse=function(e){var t;return t=e.uid,new this(t)},o.Array.create=function(e,t){var n;if("mutable"===t)return n=(new o.Array).execute(),n.insert(0,e),n;if(null==t||"immutable"===t)return new o.ImmutableObject(void 0,e).execute();throw new Error('Specify either "mutable" or "immutable"!!')},o.String=function(e){function t(e){this.textfields=[],t.__super__.constructor.call(this,e)}return i(t,e),t.prototype.type="String",t.prototype.val=function(){var e,t;return e=function(){var e,n,r,i;for(r=this.toArray(),i=[],e=0,n=r.length;n>e;e++)t=r[e],null!=t.val?i.push(t.val()):i.push("");return i}.call(this),e.join("")},t.prototype.toString=function(){return this.val()},t.prototype.bind=function(e){var n;return n=this,e.value=this.val(),this.textfields.push(e),this.observe(function(t){var r,i,o,u,s,p,l,a;for(a=[],p=0,l=t.length;l>p;p++)r=t[p],"insert"===r.type?(u=r.position,i=function(e){return u>=e?e:e+=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=n.val(),a.push(e.setSelectionRange(o,s))):"delete"===r.type?(u=r.position,i=function(e){return u>e?e:e-=1},o=i(e.selectionStart),s=i(e.selectionEnd),e.value=n.val(),a.push(e.setSelectionRange(o,s))):a.push(void 0);return a}),e.onkeypress=function(r){var i,o,u,s;return n.is_deleted?(e.onkeypress=null,!0):(i=null,i=null!=r.key?32===r.charCode?" ":13===r.keyCode?"\n":r.key:t.fromCharCode(r.keyCode),i.length>0?(s=Math.min(e.selectionStart,e.selectionEnd),o=Math.abs(e.selectionEnd-e.selectionStart),n["delete"](s,o),n.insert(s,i),u=s+i.length,e.setSelectionRange(u,u),r.preventDefault()):r.preventDefault())},e.onpaste=function(t){return n.is_deleted?(e.onpaste=null,!0):t.preventDefault()},e.oncut=function(t){return n.is_deleted?(e.oncut=null,!0):t.preventDefault()},e.onkeydown=function(t){var r,i,o,u,s;if(n.is_deleted)return e.onkeydown=null,!0;if(u=Math.min(e.selectionStart,e.selectionEnd),i=Math.abs(e.selectionEnd-e.selectionStart),null!=t.keyCode&&8===t.keyCode){if(i>0)n["delete"](u,i),e.setSelectionRange(u,u);else if(null!=t.ctrlKey&&t.ctrlKey){for(s=e.value,o=u,r=0,u>0&&(o--,r++);o>0&&" "!==s[o]&&"\n"!==s[o];)o--,r++;n["delete"](o,u-o),e.setSelectionRange(o,o)}else n["delete"](u-1,1);return t.preventDefault()}return null!=t.keyCode&&46===t.keyCode?(i>0?(n["delete"](u,i),e.setSelectionRange(u,u)):(n["delete"](u,1),e.setSelectionRange(u,u)),t.preventDefault()):void 0}},t.prototype._encode=function(){var e;return e={type:this.type,uid:this.getUid()}},t}(o.Array),o.String.parse=function(e){var t;return t=e.uid,new this(t)},o.String.create=function(e,t){var n;if("mutable"===t)return n=(new o.String).execute(),n.insert(0,e),n;if(null==t||"immutable"===t)return new o.ImmutableObject(void 0,e).execute();throw new Error('Specify either "mutable" or "immutable"!!')},r}},{"./StructuredTypes":6}],8:[function(e,t){var n,r,i,o,u,s={}.hasOwnProperty,p=function(e,t){function n(){this.constructor=e}for(var r in t)s.call(t,r)&&(e[r]=t[r]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e};u=e("./Types/JsonTypes"),r=e("./HistoryBuffer"),n=e("./Engine"),i=e("./ConnectorAdapter"),o=function(e){var t,o,s,l,a;return a=null,null!=e.id?a=e.id:(a="_temp",e.whenUserIdSet(function(e){return a=e,t.resetUserId(e)})),t=new r(a),s=u(t),l=s.types,o=function(r){function o(){this.connector=e,this.HB=t,this.types=l,this.engine=new n(this.HB,s.types),i(this.connector,this.engine,this.HB,s.execution_listener),o.__super__.constructor.apply(this,arguments)}return p(o,r),o.prototype.getConnector=function(){return this.connector},o}(l.Object),new o(t.getReservedUniqueIdentifier()).execute()},t.exports=o,"undefined"!=typeof window&&null!==window&&null==window.Yatta&&(window.Yatta=o)},{"./ConnectorAdapter":1,"./Engine":2,"./HistoryBuffer":3,"./Types/JsonTypes":5}]},{},[8]);