/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@luuan/daff@1.3.50/lib/daff.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t,e){"use strict";t.coopy=t.coopy||{};var n,i=function(){return xt.__string_rec(this,"")},r=r||{};function s(t,e){var n=Object.create(t);for(var i in e)n[i]=e[i];return e.toString!==Object.prototype.toString&&(n.toString=e.toString),n}var l=function(){};l.__name__=!0,l.dateStr=function(t){var e=t.getMonth()+1,n=t.getDate(),i=t.getHours(),r=t.getMinutes(),s=t.getSeconds();return t.getFullYear()+"-"+(e<10?"0"+e:""+e)+"-"+(n<10?"0"+n:""+n)+" "+(i<10?"0"+i:""+i)+":"+(r<10?"0"+r:""+r)+":"+(s<10?"0"+s:""+s)},l.cca=function(t,e){var n=t.charCodeAt(e);if(n==n)return n},l.substr=function(t,e,n){if(null==n)n=t.length;else if(n<0){if(0!=e)return"";n=t.length+n}return t.substr(e,n)},l.remove=function(t,e){var n=t.indexOf(e);return-1!=n&&(t.splice(n,1),!0)},l.now=function(){return Date.now()};var o=function(){};o.__name__=!0,o.array=function(t){for(var e=[],n=Rt(t);n.hasNext();){var i=n.next();e.push(i)}return e},o.has=function(t,e){for(var n=Rt(t);n.hasNext();){if(n.next()==e)return!0}return!1},Math.__name__=!0;var a=function(){};a.__name__=!0,a.field=function(t,e){try{return t[e]}catch(t){return null}},a.fields=function(t){var e=[];if(null!=t){var n=Object.prototype.hasOwnProperty;for(var i in t)"__id__"!=i&&"hx__closures__"!=i&&n.call(t,i)&&e.push(i)}return e},a.isFunction=function(t){return"function"==typeof t&&!(t.__name__||t.__ename__)},a.compare=function(t,e){return t==e?0:t>e?1:-1};var h=function(){};h.__name__=!0,h.string=function(t){return xt.__string_rec(t,"")},h.parseInt=function(t){var e=parseInt(t);return isNaN(e)?null:e};var u=function(){this.b=""};u.__name__=!0,u.prototype={b:null,__class__:u};var c=function(){};c.__name__=!0,c.htmlEscape=function(t,e){for(var n="",i=0,r=t;i<r.length;){var s=i++,l=(t=r).charCodeAt(s);l>=55296&&l<=56319&&(l=l-55232<<10|1023&t.charCodeAt(s+1));l>=65536&&++i;var o=l;switch(o){case 34:n+=e?"&quot;":String.fromCodePoint(o);break;case 38:n+="&amp;";break;case 39:n+=e?"&#039;":String.fromCodePoint(o);break;case 60:n+="&lt;";break;case 62:n+="&gt;";break;default:n+=String.fromCodePoint(o)}}return n},c.isSpace=function(t,e){var n=l.cca(t,e);return n>8&&n<14||32==n},c.ltrim=function(t){for(var e=t.length,n=0;n<e&&c.isSpace(t,n);)++n;return n>0?l.substr(t,n,e-n):t},c.rtrim=function(t){for(var e=t.length,n=0;n<e&&c.isSpace(t,e-n-1);)++n;return n>0?l.substr(t,0,e-n):t},c.trim=function(t){return c.ltrim(c.rtrim(t))},c.lpad=function(t,e,n){if(e.length<=0)return t;var i="";for(n-=t.length;i.length<n;)i+=null==e?"null":""+e;return i+=null==t?"null":""+t},c.replace=function(t,e,n){return t.split(e).join(n)};var f=r.ValueType={__ename__:!0,__constructs__:null,TNull:{_hx_name:"TNull",_hx_index:0,__enum__:"ValueType",toString:i},TInt:{_hx_name:"TInt",_hx_index:1,__enum__:"ValueType",toString:i},TFloat:{_hx_name:"TFloat",_hx_index:2,__enum__:"ValueType",toString:i},TBool:{_hx_name:"TBool",_hx_index:3,__enum__:"ValueType",toString:i},TObject:{_hx_name:"TObject",_hx_index:4,__enum__:"ValueType",toString:i},TFunction:{_hx_name:"TFunction",_hx_index:5,__enum__:"ValueType",toString:i},TClass:(n=function(t){return{_hx_index:6,c:t,__enum__:"ValueType",toString:i}},n._hx_name="TClass",n.__params__=["c"],n),TEnum:(n=function(t){return{_hx_index:7,e:t,__enum__:"ValueType",toString:i}},n._hx_name="TEnum",n.__params__=["e"],n),TUnknown:{_hx_name:"TUnknown",_hx_index:8,__enum__:"ValueType",toString:i}};f.__constructs__=[f.TNull,f.TInt,f.TFloat,f.TBool,f.TObject,f.TFunction,f.TClass,f.TEnum,f.TUnknown];var _=function(){};_.__name__=!0,_.getInstanceFields=function(t){var e=[];for(var n in t.prototype)e.push(n);return l.remove(e,"__class__"),l.remove(e,"__properties__"),e},_.typeof=function(t){switch(typeof t){case"boolean":return f.TBool;case"function":return t.__name__||t.__ename__?f.TObject:f.TFunction;case"number":return Math.ceil(t)==t%2147483648?f.TInt:f.TFloat;case"object":if(null==t)return f.TNull;var e=t.__enum__;if(null!=e)return f.TEnum(r[e]);var n=xt.getClass(t);return null!=n?f.TClass(n):f.TObject;case"string":return f.TClass(String);case"undefined":return f.TNull;default:return f.TUnknown}};var d=function(){this.map_a2b=new wt,this.map_b2a=new wt,this.ha=this.hb=0,this.map_count=0,this.reference=null,this.meta=null,this.comp=null,this.order_cache_has_reference=!1,this.ia=-1,this.ib=-1,this.marked_as_identical=!1};d.__name__=!0,d.prototype={map_a2b:null,map_b2a:null,ha:null,hb:null,ta:null,tb:null,ia:null,ib:null,map_count:null,order_cache:null,order_cache_has_reference:null,index_columns:null,marked_as_identical:null,reference:null,meta:null,comp:null,has_addition:null,has_removal:null,range:function(t,e){this.ha=t,this.hb=e},tables:function(t,e){this.ta=t,this.tb=e},headers:function(t,e){this.ia=t,this.ib=e},setRowlike:function(t){},link:function(t,e){-1!=t?this.map_a2b.h[t]=e:this.has_addition=!0,-1!=e?this.map_b2a.h[e]=t:this.has_removal=!0,this.map_count++},addIndexColumns:function(t){null==this.index_columns&&(this.index_columns=[]),this.index_columns.push(t)},getIndexColumns:function(){return this.index_columns},a2b:function(t){return this.map_a2b.h[t]},b2a:function(t){return this.map_b2a.h[t]},count:function(){return this.map_count},toString:function(){var t=(null==this.map_a2b?"null":this.map_a2b.toString())+" // "+(null==this.map_b2a?"null":this.map_b2a.toString());return null!=this.reference&&(t+=" ("+h.string(this.reference)+")"),t},toOrder:function(){return null!=this.order_cache&&null!=this.reference&&(this.order_cache_has_reference||(this.order_cache=null)),null==this.order_cache&&(this.order_cache=this.toOrder3()),null!=this.reference&&(this.order_cache_has_reference=!0),this.order_cache},addToOrder:function(t,e,n){null==n&&(n=-2),null==this.order_cache&&(this.order_cache=new B),this.order_cache.add(t,e,n),this.order_cache_has_reference=-2!=n},getSource:function(){return this.ta},getTarget:function(){return this.tb},getSourceHeader:function(){return this.ia},getTargetHeader:function(){return this.ib},toOrder3:function(){var t=[];if(null==this.reference){for(var e=this.map_a2b.keys();e.hasNext();){var n=e.next();(i=new dt).l=n,i.r=this.a2b(n),t.push(i)}for(e=this.map_b2a.keys();e.hasNext();){n=e.next();if(-1==this.b2a(n))(i=new dt).l=-1,i.r=n,t.push(i)}}else{for(e=this.map_a2b.keys();e.hasNext();){n=e.next();(i=new dt).p=n,i.l=this.reference.a2b(n),i.r=this.a2b(n),t.push(i)}for(e=this.reference.map_b2a.keys();e.hasNext();){n=e.next();if(-1==this.reference.b2a(n))(i=new dt).p=-1,i.l=n,i.r=-1,t.push(i)}for(e=this.map_b2a.keys();e.hasNext();){var i;n=e.next();if(-1==this.b2a(n))(i=new dt).p=-1,i.l=-1,i.r=n,t.push(i)}}for(var r=t.length,s=[],l=[],o=0,a=r;o<a;){var h=o++;t[h].r>=0?s.push(h):l.push(h)}var u=function(e,n){return t[e].r-t[n].r},c=function(e,n){return e==n?0:t[e].l>=0&&t[n].l>=0?t[e].l-t[n].l:t[e].l>=0?1:t[n].l>=0?-1:e-n};null!=this.reference&&(u=function(e,n){if(e==n)return 0;var i=t[e].r-t[n].r;return t[e].p>=0&&t[n].p>=0?i*(t[e].p-t[n].p)<0?i:t[e].l-t[n].l:i},c=function(e,n){if(e==n)return 0;if(t[e].l>=0&&t[n].l>=0){var i=t[e].l-t[n].l;if(t[e].p>=0&&t[n].p>=0){var r=t[e].p-t[n].p;return i*r<0?i:r}}return t[e].l>=0?1:t[n].l>=0?-1:e-n}),s.sort(u),l.sort(c);var f=[],_=0,d=0;for(o=0,a=r;o<a;){h=o++;if(_<s.length&&d<l.length){var g=t[s[_]],p=t[l[d]];if(-1==p.l&&p.p>=0&&g.p>=0){if(g.p>p.p){f.push(p),++d;continue}}else if(g.l>p.l){f.push(p),++d;continue}f.push(g),++_}else if(_<s.length){var m=t[s[_]];f.push(m),++_}else if(d<l.length){var v=t[l[d]];f.push(v),++d}else;}t=f;var w=new B;return w.setList(t),null==this.reference&&w.ignoreParent(),w},markIdentical:function(){this.marked_as_identical=!0},isMarkedAsIdentical:function(){return this.marked_as_identical},__class__:d};var g=function(){};g.__name__=!0,g.prototype={needSeparator:null,setSeparator:null,setConflictSeparator:null,setView:null,update:null,conflict:null,marker:null,links:null,__class__:g};var p=t.coopy.CellInfo=function(){};p.__name__=!0,p.prototype={raw:null,value:null,pretty_value:null,category:null,category_given_tr:null,separator:null,pretty_separator:null,updated:null,conflicted:null,pvalue:null,lvalue:null,rvalue:null,meta:null,toString:function(){return this.updated?this.conflicted?this.pvalue+"||"+this.lvalue+"::"+this.rvalue:this.lvalue+"::"+this.rvalue:this.value},__class__:p};var m=t.coopy.ColumnChange=function(){};m.__name__=!0,m.prototype={prevName:null,name:null,props:null,__class__:m};var v=function(){};v.__name__=!0,v.prototype={getCell:null,setCell:null,getCellView:null,isResizable:null,resize:null,clear:null,insertOrDeleteRows:null,insertOrDeleteColumns:null,trimBlank:null,get_width:null,get_height:null,getData:null,clone:null,create:null,getMeta:null,__class__:v};var w=t.coopy.CombinedTable=function(t){if(this.t=t,this.dx=0,this.dy=0,this.core=t,this.head=null,!(t.get_width()<1||t.get_height()<1)){var e=t.getCellView();if("@@"==e.toString(t.getCell(0,0))){this.dx=1,this.dy=0;for(var n=0,i=t.get_height();n<i;){var r=n++,s=e.toString(t.getCell(0,r));if(null==s||""==s||"null"==s)break;this.dy++}this.head=new y(this,this.dx,this.dy),this.body=new b(this,this.dx,this.dy),this.core=this.body,this.meta=new G(this.head)}}};w.__name__=!0,w.__interfaces__=[v],w.prototype={t:null,body:null,head:null,dx:null,dy:null,core:null,meta:null,all:function(){return this.t},getTable:function(){return this},get_width:function(){return this.core.get_width()},get_height:function(){return this.core.get_height()},getCell:function(t,e){return this.core.getCell(t,e)},setCell:function(t,e,n){this.core.setCell(t,e,n)},toString:function(){return Y.tableToString(this)},getCellView:function(){return this.t.getCellView()},isResizable:function(){return this.core.isResizable()},resize:function(t,e){return this.core.resize(e,t)},clear:function(){this.core.clear()},insertOrDeleteRows:function(t,e){return this.core.insertOrDeleteRows(t,e)},insertOrDeleteColumns:function(t,e){return this.core.insertOrDeleteColumns(t,e)},trimBlank:function(){return this.core.trimBlank()},getData:function(){return null},clone:function(){return this.core.clone()},create:function(){return this.t.create()},getMeta:function(){return this.meta},__class__:w};var b=function(t,e,n){this.parent=t,this.dx=e,this.dy=n,this.all=t.all()};b.__name__=!0,b.__interfaces__=[v],b.prototype={parent:null,dx:null,dy:null,all:null,meta:null,getTable:function(){return this},get_width:function(){return this.all.get_width()-1},get_height:function(){return this.all.get_height()-this.dy+1},getCell:function(t,e){return 0==e?(null==this.meta&&(this.meta=this.parent.getMeta().asTable()),this.meta.getCell(t+this.dx,0)):this.all.getCell(t+this.dx,e+this.dy-1)},setCell:function(t,e,n){0!=e?this.all.setCell(t+this.dx,e+this.dy-1,n):this.all.setCell(t+this.dx,0,n)},toString:function(){return Y.tableToString(this)},getCellView:function(){return this.all.getCellView()},isResizable:function(){return this.all.isResizable()},resize:function(t,e){return this.all.resize(t+1,e+this.dy)},clear:function(){this.all.clear(),this.dx=0,this.dy=0},insertOrDeleteRows:function(t,e){for(var n=[],i=0,r=this.dy;i<r;){var s=i++;n.push(s)}var l=!0;for(i=0;i<t.length;){var o=t[i];++i,l?l=!1:n.push(o>=0?o+this.dy-1:o)}return this.all.insertOrDeleteRows(n,e+this.dy-1)},insertOrDeleteColumns:function(t,e){for(var n=[],i=0,r=this.dx+1;i<r;){var s=i++;n.push(s)}for(i=0;i<t.length;){var l=t[i];++i,n.push(l>=0?l+this.dx+1:l)}return this.all.insertOrDeleteColumns(n,e+this.dx)},trimBlank:function(){return this.all.trimBlank()},getData:function(){return null},clone:function(){return new w(this.all.clone())},create:function(){return new w(this.all.create())},getMeta:function(){return this.parent.getMeta()},__class__:b};var y=function(t,e,n){this.parent=t,this.dx=e,this.dy=n,this.all=t.all()};y.__name__=!0,y.__interfaces__=[v],y.prototype={parent:null,dx:null,dy:null,all:null,getTable:function(){return this},get_width:function(){return this.all.get_width()},get_height:function(){return this.dy},getCell:function(t,e){if(0==t){var n=this.getCellView().toString(this.all.getCell(t,e));if("@"==n.charAt(0))return l.substr(n,1,n.length)}return this.all.getCell(t,e)},setCell:function(t,e,n){this.all.setCell(t,e,n)},toString:function(){return Y.tableToString(this)},getCellView:function(){return this.all.getCellView()},isResizable:function(){return!1},resize:function(t,e){return!1},clear:function(){},insertOrDeleteRows:function(t,e){return!1},insertOrDeleteColumns:function(t,e){return this.all.insertOrDeleteColumns(t,e)},trimBlank:function(){return!1},getData:function(){return null},clone:function(){return null},create:function(){return null},getMeta:function(){return null},__class__:y};var C=t.coopy.CompareFlags=function(){this.ordered=!0,this.show_unchanged=!1,this.unchanged_context=1,this.always_show_order=!1,this.never_show_order=!0,this.show_unchanged_columns=!1,this.unchanged_column_context=1,this.always_show_header=!0,this.acts=null,this.ids=null,this.columns_to_ignore=null,this.allow_nested_cells=!1,this.warnings=null,this.diff_strategy=null,this.show_meta=!0,this.show_unchanged_meta=!1,this.tables=null,this.parent=null,this.count_like_a_spreadsheet=!0,this.ignore_whitespace=!1,this.ignore_case=!1,this.ignore_epsilon=-1,this.terminal_format=null,this.use_glyphs=!0,this.quote_html=!0};C.__name__=!0,C.prototype={ordered:null,show_unchanged:null,unchanged_context:null,always_show_order:null,never_show_order:null,show_unchanged_columns:null,unchanged_column_context:null,always_show_header:null,acts:null,ids:null,columns_to_ignore:null,tables:null,allow_nested_cells:null,warnings:null,diff_strategy:null,padding_strategy:null,show_meta:null,show_unchanged_meta:null,parent:null,count_like_a_spreadsheet:null,ignore_whitespace:null,ignore_case:null,ignore_epsilon:null,terminal_format:null,use_glyphs:null,quote_html:null,filter:function(t,e){return null==this.acts&&(this.acts=new bt,this.acts.h.update=!e,this.acts.h.insert=!e,this.acts.h.delete=!e,this.acts.h.column=!e),!!Object.prototype.hasOwnProperty.call(this.acts.h,t)&&(this.acts.h[t]=e,!0)},allowUpdate:function(){return null==this.acts||!!Object.prototype.hasOwnProperty.call(this.acts.h,"update")&&this.acts.h.update},allowInsert:function(){return null==this.acts||!!Object.prototype.hasOwnProperty.call(this.acts.h,"insert")&&this.acts.h.insert},allowDelete:function(){return null==this.acts||!!Object.prototype.hasOwnProperty.call(this.acts.h,"delete")&&this.acts.h.delete},allowColumn:function(){return null==this.acts||!!Object.prototype.hasOwnProperty.call(this.acts.h,"column")&&this.acts.h.column},getIgnoredColumns:function(){if(null==this.columns_to_ignore)return null;for(var t=new bt,e=0,n=this.columns_to_ignore.length;e<n;){var i=e++;t.h[this.columns_to_ignore[i]]=!0}return t},addPrimaryKey:function(t){null==this.ids&&(this.ids=[]),this.ids.push(t)},ignoreColumn:function(t){null==this.columns_to_ignore&&(this.columns_to_ignore=[]),this.columns_to_ignore.push(t)},addTable:function(t){null==this.tables&&(this.tables=[]),this.tables.push(t)},addWarning:function(t){null==this.warnings&&(this.warnings=[]),this.warnings.push(t)},getWarning:function(){return this.warnings.join("\n")},getNameByRole:function(t,e){var n=t.split(":");return n.length<=1?t:"parent"==e?n[0]:"local"==e?n[n.length-2]:n[n.length-1]},getCanonicalName:function(t){return this.getNameByRole(t,"local")},getIdsByRole:function(t){var e=[];if(null==this.ids)return e;for(var n=0,i=this.ids;n<i.length;){var r=i[n];++n,e.push(this.getNameByRole(r,t))}return e},__class__:C};var S=t.coopy.CompareTable=function(t){this.comp=t,null!=t.compare_flags&&null!=t.compare_flags.parent&&(t.p=t.compare_flags.parent)};S.__name__=!0,S.prototype={comp:null,indexes:null,run:function(){if(this.useSql())return this.comp.completed=!0,!1;for(var t=this.compareCore();t&&this.comp.run_to_completion;)t=this.compareCore();return!t},align:function(){for(;!this.comp.completed;)this.run();var t=new d;return this.alignCore(t),t.comp=this.comp,this.comp.alignment=t,t},getComparisonState:function(){return this.comp},alignCore:function(t){if(this.useSql()){var e=null,n=null,i=null;null==this.comp.p?(e=this.comp.a,n=this.comp.b):(t.reference=new d,e=this.comp.p,n=this.comp.b,i=this.comp.a);var r=null;return null!=e&&(r=e.getDatabase()),null==r&&null!=n&&(r=n.getDatabase()),null==r&&null!=i&&(r=i.getDatabase()),new tt(r,e,n,i,t,this.comp.compare_flags).apply(),void(null!=this.comp.p&&(t.meta.reference=t.reference.meta))}null!=this.comp.p?(t.reference=new d,this.alignCore2(t,this.comp.p,this.comp.b),this.alignCore2(t.reference,this.comp.p,this.comp.a),t.meta.reference=t.reference.meta):this.alignCore2(t,this.comp.a,this.comp.b)},alignCore2:function(t,e,n){null==t.meta&&(t.meta=new d),this.alignColumns(t.meta,e,n);var i=t.meta.toOrder();t.range(e.get_height(),n.get_height()),t.tables(e,n),t.setRowlike(!0);e.get_width();var r=e.get_height(),s=n.get_height(),l=e.getCellView(),a=null,h=null;null!=this.comp.compare_flags&&(a=this.comp.compare_flags.ids,h=this.comp.compare_flags.getIgnoredColumns(),this.comp.compare_flags.ordered);for(var u=[],c=t.getSourceHeader(),f=t.getSourceHeader(),_=0,g=i.getList();_<g.length;){var p=g[_];if(++_,p.l>=0&&p.r>=0&&-1!=p.p){if(null!=h){if(p.l>=0&&c>=0&&c<e.get_height()){var m=l.toString(e.getCell(p.l,c));if(Object.prototype.hasOwnProperty.call(h.h,m))continue}if(p.r>=0&&f>=0&&f<n.get_height()){var v=l.toString(n.getCell(p.r,f));if(Object.prototype.hasOwnProperty.call(h.h,v))continue}}u.push(p)}}var w=null,b=r,y=s,C={},S={};if(null!=a){w=new j(this.comp.compare_flags);var x=Object.create(null);for(_=0;_<a.length;){var R=a[_];++_,x[R]=!0}for(_=0;_<u.length;){p=u[_];++_;var T=l.toString(e.getCell(p.l,0)),O=l.toString(n.getCell(p.r,0));(Object.prototype.hasOwnProperty.call(x,T)||Object.prototype.hasOwnProperty.call(x,O))&&(w.addColumns(p.l,p.r),t.addIndexColumns(p))}w.indexTables(e,n,1),null!=this.indexes&&this.indexes.push(w);for(_=0,g=r;_<g;){var k=_++,N=(ut=w.queryLocal(k)).spot_a,P=ut.spot_b;if(1==N&&1==P){var I=ut.item_b.lst[0];t.link(k,I),C[I]=1,S.hasOwnProperty(k)||--y,S[k]=1}}}else{var D=[];if(u.length>5){var q=[];for(_=0,g=u.length;_<g;){for(var A=_++,M=0,E=Object.create(null),F=Object.create(null),L=u[A].l,V=u[A].r,U=0,H=r;U<H;){k=U++;var z=l.toString(e.getCell(L,k));Object.prototype.hasOwnProperty.call(E,z)||(E[z]=1,++M)}for(var B=0,K=s;B<K;){var Q=B++,W=l.toString(n.getCell(V,Q));Object.prototype.hasOwnProperty.call(F,W)||(F[W]=1,++M)}q.push([A,M])}q.sort((function(t,e){return t[1]<e[1]?1:t[1]>e[1]?-1:t[0]>e[0]?1:t[0]<e[0]?-1:0}));_=[];for(var G=0,Y=q;G<Y.length;){var J=Y[G++];_.push(J[0])}D=(D=o.array(_)).slice(0,5)}else for(_=0,g=u.length;_<g;){A=_++;D.push(A)}var $=Math.round(Math.pow(2,D.length)),X=new wt;for(_=0,g=r;_<g;){k=_++;X.h[k]=k}var Z={},tt=0;for(_=0,g=$;_<g;){var et=_++;if(0!=et){if(0==b)break;for(var nt=[],it=et,rt=0;it>0;)it%2==1&&nt.push(D[rt]),it>>=1,++rt;var st=new j(this.comp.compare_flags);for(U=0,H=nt.length;U<H;){var lt=nt[U++];p=u[lt];st.addColumns(p.l,p.r),Z.hasOwnProperty(lt)||(t.addIndexColumns(p),Z[lt]=!0)}st.indexTables(e,n,1),et==$-1&&(w=st);var ot=e.get_height();n.get_height()>ot&&(ot=n.get_height()),ot<1&&(ot=1);var at=st.getTopFreq();if(!((at/=ot+20)>=.1&&(tt>0||et<$-1))){++tt,null!=this.indexes&&this.indexes.push(st);var ht=[];for(k=X.keys();k.hasNext();){var ut;Q=k.next(),N=(ut=st.queryLocal(Q)).spot_a,P=ut.spot_b;if(1==N&&1==P){var ct=ut.item_b.lst[0];C.hasOwnProperty(ct)||(ht.push(Q),t.link(Q,ct),C[ct]=1,S.hasOwnProperty(Q)||--y,S[Q]=1)}}for(B=0,K=ht.length;B<K;){var ft=B++;X.remove(ht[ft]),--b}}}}}if(null!=w){var _t=0,dt=1;for(_=0;_<2;){_++;if(b>0){var gt=null;-1==dt&&s>0&&(gt=s-1);for(g=0,U=r;g<U;){var pt=g++*dt+_t,mt=t.a2b(pt);if(null==mt){if(null!=gt)if(w.localKey(pt)==w.remoteKey(gt)&&!C.hasOwnProperty(gt)){if(t.link(pt,gt),C[gt]=1,S[pt]=1,--b,(gt+=dt)>=s||gt<0)break;if(0==b)break}}else if((gt=mt+dt)>=s||gt<0)break}}_t=r-1,dt=-1}_t=0,dt=1;for(_=0;_<2;){_++;if(y>0){pt=null;-1==dt&&r>0&&(pt=r-1);for(g=0,U=s;g<U;){gt=g++*dt+_t;var vt=t.b2a(gt);if(null==vt){if(null!=pt)if(w.localKey(pt)==w.remoteKey(gt)&&!S.hasOwnProperty(pt)){if(t.link(pt,gt),C[gt]=1,S[pt]=1,--y,(pt+=dt)>=r||pt<0)break;if(0==y)break}}else if((pt=vt+dt)>=r||pt<0)break}}_t=s-1,dt=-1}}for(_=1,g=r;_<g;){A=_++;S.hasOwnProperty(A)||t.link(A,-1)}for(_=1,g=s;_<g;){A=_++;C.hasOwnProperty(A)||t.link(-1,A)}r>0&&s>0&&(t.link(0,0),t.headers(0,0))},alignColumns:function(t,e,n){t.range(e.get_width(),n.get_width()),t.tables(e,n),t.setRowlike(!1);for(var i=e.getCellView(),r=n.getCellView(),s=-1,l=null,o=null,a=0,h=0,u=0,c=0,f=0;f<5;)for(var _=f++,d=0;d<5;){var g=d++,p=new bt,m=new bt,v=0,w=0;if(_<e.get_height()){for(var b=0,y=e.get_width();b<y;){var C=b++,S=i.toString(e.getCell(C,_));Object.prototype.hasOwnProperty.call(p.h,S)?(p.h[S]=-1,--w):(p.h[S]=C,++w)}w>u&&(a=_,u=w)}if(w=0,g<n.get_height()){for(var x=0,R=n.get_width();x<R;){var T=x++,O=r.toString(n.getCell(T,g));Object.prototype.hasOwnProperty.call(m.h,O)?(m.h[O]=-1,--w):(m.h[O]=T,++w)}w>c&&(h=g,c=w)}q=p.h;for(var k=(A=Object.keys(q)).length,N=0;N<k;){var P=A[N++],I=p.h[P];null!=(D=m.h[P])&&D>=0&&I>=0&&++v}v>s&&(s=v,l=p,o=m,g)}if(null!=l){for(q=l.h,k=(A=Object.keys(q)).length,N=0;N<k;){S=A[N++],I=l.h[S];var D=o.h[S];null!=I&&null!=D?t.link(I,D):null!=I?t.link(I,-1):null!=D&&t.link(-1,D)}var q,A;for(q=o.h,k=(A=Object.keys(q)).length,N=0;N<k;){S=A[N++],I=l.h[S],D=o.h[S];null==I&&null!=D&&t.link(-1,D)}t.headers(a,h)}else e.get_height()>0&&0==n.get_height()?t.headers(0,-1):0==e.get_height()&&n.get_height()>0&&t.headers(-1,0)},testHasSameColumns:function(){var t=this.comp.p,e=this.comp.a,n=this.comp.b,i=this.hasSameColumns2(e,n);return i&&null!=t&&(i=this.hasSameColumns2(t,e)),this.comp.has_same_columns=i,this.comp.has_same_columns_known=!0,!0},hasSameColumns2:function(t,e){if(t.get_width()!=e.get_width())return!1;if(0==t.get_height()||0==e.get_height())return!0;for(var n=t.getCellView(),i=0,r=t.get_width();i<r;){for(var s=i++,l=s+1,o=t.get_width();l<o;){var a=l++;if(n.equals(t.getCell(s,0),t.getCell(a,0)))return!1}if(!n.equals(t.getCell(s,0),e.getCell(s,0)))return!1}return!0},testIsEqual:function(){var t=this.comp.p,e=this.comp.a,n=this.comp.b;this.comp.getMeta();var i=!1;if(null!=this.comp.p_meta&&this.comp.p_meta.isNested()&&(i=!0),null!=this.comp.a_meta&&this.comp.a_meta.isNested()&&(i=!0),null!=this.comp.b_meta&&this.comp.b_meta.isNested()&&(i=!0),i)return this.comp.is_equal=!1,this.comp.is_equal_known=!0,!0;var r=this.isEqual2(e,n);return r&&null!=t&&(r=this.isEqual2(t,e)),this.comp.is_equal=r,this.comp.is_equal_known=!0,!0},isEqual2:function(t,e){if(t.get_width()!=e.get_width()||t.get_height()!=e.get_height())return!1;for(var n=t.getCellView(),i=0,r=t.get_height();i<r;)for(var s=i++,l=0,o=t.get_width();l<o;){var a=l++;if(!n.equals(t.getCell(a,s),e.getCell(a,s)))return!1}return!0},compareCore:function(){return!this.comp.completed&&(this.comp.is_equal_known?this.comp.has_same_columns_known?(this.comp.completed=!0,!1):this.testHasSameColumns():this.testIsEqual())},storeIndexes:function(){this.indexes=[]},getIndexes:function(){return this.indexes},useSql:function(){if(null==this.comp.compare_flags)return!1;this.comp.getMeta();var t=!0;return null!=this.comp.p_meta&&(this.comp.p_meta.isSql()||(t=!1)),null!=this.comp.a_meta&&(this.comp.a_meta.isSql()||(t=!1)),null!=this.comp.b_meta&&(this.comp.b_meta.isSql()||(t=!1)),null!=this.comp.p&&null==this.comp.p_meta&&(t=!1),null!=this.comp.a&&null==this.comp.a_meta&&(t=!1),null!=this.comp.b&&null==this.comp.b_meta&&(t=!1),t},__class__:S};var x=function(t,e,n,i,r){this.row=t,this.col=e,this.pvalue=n,this.lvalue=i,this.rvalue=r};x.__name__=!0,x.prototype={row:null,col:null,pvalue:null,lvalue:null,rvalue:null,__class__:x};var R=t.coopy.Coopy=function(t){this.init(),this.io=t};R.__name__=!0,R.diffAsHtml=function(t,e,n){var i=new ot,r=R.align(t,e,n,i),s=R.getBlankTable(r,i);null!=i.a&&(s=i.a.create()),null==s&&null!=i.b&&(s=i.b.create()),null==s&&(s=new Y(0,0));var l=new ft(s);return r.hiliteWithNesting(l),(new k).renderTables(l).html()},R.diffAsAnsi=function(t,e,n){var i=new R(new ht);return i.cache_txt="",null==n&&(n=new C),i.output_format="csv",i.runDiff(n.parent,t,e,n,null),i.cache_txt},R.diff=function(t,e,n){var i=new ot,r=R.align(t,e,n,i),s=R.getBlankTable(r,i);return null!=i.a&&(s=i.a.create()),null==s&&null!=i.b&&(s=i.b.create()),null==s&&(s=new Y(0,0)),r.hilite(s),s},R.getBlankTable=function(t,e){var n=null;return null!=e.a&&(n=e.a.create()),null==n&&null!=e.b&&(n=e.b.create()),null==n&&(n=new Y(0,0)),n},R.align=function(t,e,n,i){i.a=R.tablify(t),i.b=R.tablify(e),null==n&&(n=new C),i.compare_flags=n;var r=new S(i).align();return new at(r,n)},R.patch=function(t,e,n){return new D(R.tablify(t),R.tablify(e)).apply()},R.compareTables=function(t,e,n){var i=new ot;return i.a=R.tablify(t),i.b=R.tablify(e),i.compare_flags=n,new S(i)},R.compareTables3=function(t,e,n,i){var r=new ot;return r.p=R.tablify(t),r.a=R.tablify(e),r.b=R.tablify(n),r.compare_flags=i,new S(r)},R.keepAround=function(){new Y(1,1),new gt,new at(null,null);var t=new C;new A(t),new k,new D(null,null),new O,new ut(null),new tt(null,null,null,null,null),new lt,new G(null),new w(null);return 0},R.cellFor=function(t){return t},R.main=function(){},R.show=function(t){for(var e=t.get_width(),n="",i=0,r=t.get_height();i<r;){for(var s=i++,l=0,o=e;l<o;){var a=l++;n+=h.string(t.getCell(a,s)),n+=" "}n+="\n"}console.log("coopy/Coopy.hx:1191:",n)},R.jsonify=function(t){for(var e=new bt,n=[],i=t.get_width(),r=0,s=t.get_height();r<s;){for(var l=r++,o=[],a=0,h=i;a<h;){var u=a++,c=t.getCell(u,l);o.push(c)}n.push(o)}return e.h.sheet=n,e},R.tablify=function(t){return null==t||null!=a.field(t,"getCellView")?t:new daff.TableView(t)},R.prototype={format_preference:null,delim_preference:null,csv_eol_preference:null,extern_preference:null,output_format:null,output_format_set:null,nested_output:null,order_set:null,order_preference:null,io:null,strategy:null,css_output:null,fragment:null,flags:null,cache_txt:null,fail_if_diff:null,diffs_found:null,mv:null,init:function(){this.extern_preference=!1,this.format_preference=null,this.delim_preference=null,this.csv_eol_preference=null,this.output_format="copy",this.output_format_set=!1,this.nested_output=!1,this.order_set=!1,this.order_preference=!1,this.strategy=null,this.css_output=null,this.fragment=!1,this.flags=null,this.cache_txt=null,this.fail_if_diff=!1,this.diffs_found=!1},checkFormat:function(t){if(this.extern_preference)return this.format_preference;var e="";if(null!=t){var n=t.lastIndexOf(".");if(n>=0)switch(e=l.substr(t,n+1,null).toLowerCase()){case"csv":this.format_preference="csv",this.delim_preference=",";break;case"htm":case"html":this.format_preference="html";break;case"json":this.format_preference="json";break;case"ndjson":this.format_preference="ndjson";break;case"psv":this.format_preference="csv",this.delim_preference=String.fromCharCode(55357,56489);break;case"sqlite":case"sqlite3":this.format_preference="sqlite";break;case"ssv":this.format_preference="csv",this.delim_preference=";",this.format_preference="csv";break;case"tsv":this.format_preference="csv",this.delim_preference="\t";break;case"www":this.format_preference="www";break;default:e=""}}return this.nested_output="json"==this.format_preference||"ndjson"==this.format_preference,this.order_preference=!this.nested_output,e},setFormat:function(t){this.extern_preference=!1,this.checkFormat("."+t),this.extern_preference=!0},getRenderer:function(){var t=new k;return t.usePrettyArrows(this.flags.use_glyphs),t.quoteHtml(this.flags.quote_html),t},applyRenderer:function(t,e){return this.fragment||e.completeHtml(),"www"==this.format_preference?this.io.sendToBrowser(e.html()):this.saveText(t,e.html()),null!=this.css_output&&this.saveText(this.css_output,e.sampleCss()),!0},renderTable:function(t,e){var n=this.getRenderer();return n.render(e),this.applyRenderer(t,n)},renderTables:function(t,e){var n=this.getRenderer();return n.renderTables(e),this.applyRenderer(t,n)},saveTable:function(t,e,n){var i=this.encodeTable(t,e,n);return null==i||this.saveText(t,i)},encodeTable:function(t,e,n){"copy"!=this.output_format&&this.setFormat(this.output_format);var i="";if(this.checkFormat(t),"sqlite"!=this.format_preference||this.extern_preference||(this.format_preference="csv"),null==n)if("csv"==this.format_preference)i=new O(this.delim_preference,this.csv_eol_preference).renderTable(e);else if("ndjson"==this.format_preference)i=new H(e).render();else{if("html"==this.format_preference||"www"==this.format_preference)return this.renderTable(t,e),null;if("sqlite"==this.format_preference)return this.io.writeStderr("! Cannot yet output to sqlite, aborting\n"),"";i=Ct.print(R.jsonify(e),null,"  ")}else i=n.render(e);return i},saveTables:function(t,e,n,i){"copy"!=this.output_format&&this.setFormat(this.output_format);var r="";this.checkFormat(t);var s=null;n&&(s=new _t(this.flags,this.delim_preference,i));var l=e.getOrder();if(1==l.length)return this.saveTable(t,e.one(),s);if("html"==this.format_preference||"www"==this.format_preference)return this.renderTables(t,e);var o=!1;if((0==l.length||e.hasInsDel())&&(r+=this.encodeTable(t,e.one(),s),o=!0),l.length>1)for(var a=1,h=l.length;a<h;){var u=a++;if(null!=e.get(l[u])){o&&(r+="\n"),o=!0,r+=l[u]+"\n";for(var c="",f=0,_=l[u].length;f<_;){f++;c+="="}r+=c+"\n",r+=this.encodeTable(t,e.get(l[u]),s)}}return this.saveText(t,r)},saveText:function(t,e){return null==t?this.cache_txt+=e:"-"!=t?this.io.saveContent(t,e):this.io.writeStdout(e),!0},jsonToTables:function(t){return null==a.field(t,"tables")?this.jsonToTable(t):new L(t,this.flags)},jsonToTable:function(t){for(var e=null,n=0,i=a.fields(t);n<i.length;){var r=i[n];++n;var s=a.field(t,r),l=a.field(s,"columns");if(null!=l){var o=a.field(s,"rows");if(null!=o){e=new Y(l.length,o.length);for(var h=!1,u=!1,c=0,f=o.length;c<f;){var _=c++,d=o[_];if(u||(a.fields(d).length==l.length&&(h=!0),u=!0),h)for(var g=0,p=l.length;g<p;){var m=g++,v=a.field(d,l[m]);e.setCell(m,_,R.cellFor(v))}else for(var w=d,b=0,y=l.length;b<y;){var C=b++,S=w[C];e.setCell(C,_,R.cellFor(S))}}}}}return null!=e&&e.trimBlank(),e},useColor:function(t,e){var n="ansi"==t.terminal_format;return null==t.terminal_format&&(null!=e&&"-"!=e||"copy"!=this.output_format&&"csv"!=this.output_format&&"psv"!=this.output_format||null!=this.io&&this.io.isTtyKnown()&&(n=this.io.isTty())),n},runDiff:function(t,e,n,i,r){var s=R.compareTables3(t,e,n,i).align(),l=new at(s,i),o=new Y(0,0),a=new ft(o);l.hiliteWithNesting(a);var h=this.useColor(i,r);(this.saveTables(r,a,h,!0),this.fail_if_diff)&&(l.getSummary().different&&(this.diffs_found=!0))},loadTable:function(t,e){var n=this.checkFormat(t);if("sqlite"==n){var i=this.io.openSqliteDatabase(t);return null==i?(this.io.writeStderr("! Cannot open database, aborting\n"),null):new st(i,this.flags,e)}var r=this.io.getContent(t);if("ndjson"==n){var s=new Y(0,0);return new H(s).parse(r),s}if("json"==n||""==n)try{var l=new yt(r).doParse();if(this.format_preference="json",null==(s=this.jsonToTables(l)))throw mt.thrown("JSON failed");return s}catch(t){var o=mt.caught(t).unwrap();if("json"==n)throw mt.thrown(o)}this.format_preference="csv";var a=new O(this.delim_preference),h=new Y(0,0);return a.parseTable(r,h),null==this.csv_eol_preference&&(this.csv_eol_preference=a.getDiscoveredEol()),null!=h&&h.trimBlank(),h},status:null,daff_cmd:null,command:function(t,e,n){var i=0;if(t.hasAsync()&&(i=t.command(e,n)),999!=i){t.writeStdout("$ "+e);for(var r=0;r<n.length;){var s=n[r];++r,t.writeStdout(" ");var l=s.indexOf(" ")>=0;l&&t.writeStdout('"'),t.writeStdout(s),l&&t.writeStdout('"')}t.writeStdout("\n")}return t.hasAsync()||(i=t.command(e,n)),i},installGitDriver:function(t,e){var n=0;null==this.status&&(this.status=new bt,this.daff_cmd="");var i="hello";if(!Object.prototype.hasOwnProperty.call(this.status.h,i)){t.writeStdout("Setting up git to use daff on");for(var r=0;r<e.length;){var s=e[r];++r,t.writeStdout(" *."+s)}t.writeStdout(" files\n"),this.status.h[i]=n}if(i="can_run_git",!Object.prototype.hasOwnProperty.call(this.status.h,i)){if(999==(n=this.command(t,"git",["--version"])))return n;if(this.status.h[i]=n,0!=n)return t.writeStderr("! Cannot run git, aborting\n"),1;t.writeStdout("- Can run git\n")}var l=["daff","daff.rb","daff.py"];if(""==this.daff_cmd){for(r=0;r<l.length;){var o=l[r];++r;var a="can_run_"+o;if(!Object.prototype.hasOwnProperty.call(this.status.h,a)){if(999==(n=this.command(t,o,["version"])))return n;if(this.status.h[a]=n,0==n){this.daff_cmd=o,t.writeStdout("- Can run "+o+' as "'+o+'"\n');break}}}if(""==this.daff_cmd)return t.writeStderr("! Cannot find daff, is it in your path?\n"),1}for(r=0;r<e.length;){s=e[r];if(++r,i="have_diff_driver_"+s,!Object.prototype.hasOwnProperty.call(this.status.h,i)){if(999==(n=this.command(t,"git",["config","--global","--get","diff.daff-"+s+".command"])))return n;this.status.h[i]=n}var h=0==this.status.h[i];if(i="add_diff_driver_"+s,!Object.prototype.hasOwnProperty.call(this.status.h,i)){if(999==(n=this.command(t,"git",["config","--global","diff.daff-"+s+".command",this.daff_cmd+" diff --git"])))return n;h&&t.writeStdout("- Cleared existing daff diff driver for "+s+"\n"),t.writeStdout("- Added diff driver for "+s+"\n"),this.status.h[i]=n}if(i="have_merge_driver_"+s,!Object.prototype.hasOwnProperty.call(this.status.h,i)){if(999==(n=this.command(t,"git",["config","--global","--get","merge.daff-"+s+".driver"])))return n;this.status.h[i]=n}var u=0==this.status.h[i];if(i="name_merge_driver_"+s,!Object.prototype.hasOwnProperty.call(this.status.h,i)){if(u)n=0;else if(999==(n=this.command(t,"git",["config","--global","merge.daff-"+s+".name","daff tabular "+s+" merge"])))return n;this.status.h[i]=n}if(i="add_merge_driver_"+s,!Object.prototype.hasOwnProperty.call(this.status.h,i)){if(999==(n=this.command(t,"git",["config","--global","merge.daff-"+s+".driver",this.daff_cmd+" merge --output %A %O %A %B"])))return n;u&&t.writeStdout("- Cleared existing daff merge driver for "+s+"\n"),t.writeStdout("- Added merge driver for "+s+"\n"),this.status.h[i]=n}}if(!t.exists(".git/config"))return t.writeStderr("! This next part needs to happen in a git repository.\n"),t.writeStderr("! Please run again from the root of a git repository.\n"),1;var c=".gitattributes",f="",_="";t.exists(c)?(t.writeStdout("- You have a .gitattributes file\n"),f=t.getContent(c)):t.writeStdout("- No .gitattributes file\n");var d=!1;for(r=0;r<e.length;){s=e[r];++r,f.indexOf("*."+s)>=0?t.writeStderr("- Your .gitattributes file already mentions *."+s+"\n"):(_+="*."+s+" diff=daff-"+s+"\n",_+="*."+s+" merge=daff-"+s+"\n",t.writeStdout("- Placing the following lines in .gitattributes:\n"),t.writeStdout(_),""==f||d||(f+="\n"),f+=_,d=!0)}return d&&t.saveContent(c,f),t.writeStdout("- Done!\n"),0},run:function(t,e){if(null==e)return console.log("coopy/Coopy.hx:725:","No system interface available"),1;this.init(),this.io=e;var n=!0,i=null,r=!1,s=!1,l=!1;for(this.flags=new C,this.flags.always_show_header=!0;n;){n=!1;for(var a=0,u=t.length;a<u;){var c=a++,f=t[c];if("--output"==f){n=!0,i=t[c+1],t.splice(c,2);break}if("--css"==f){n=!0,this.fragment=!0,this.css_output=t[c+1],t.splice(c,2);break}if("--fragment"==f){n=!0,this.fragment=!0,t.splice(c,1);break}if("--plain"==f){n=!0,this.flags.use_glyphs=!1,t.splice(c,1);break}if("--unquote"==f){n=!0,this.flags.quote_html=!1,t.splice(c,1);break}if("--all"==f){n=!0,this.flags.show_unchanged=!0,this.flags.show_unchanged_columns=!0,t.splice(c,1);break}if("--all-rows"==f){n=!0,this.flags.show_unchanged=!0,t.splice(c,1);break}if("--all-columns"==f){n=!0,this.flags.show_unchanged_columns=!0,t.splice(c,1);break}if("--act"==f){n=!0,null==this.flags.acts&&(this.flags.acts=new bt),this.flags.acts.h[t[c+1]]=!0,t.splice(c,2);break}if("--context"==f){n=!0;var _=h.parseInt(t[c+1]);_>=0&&(this.flags.unchanged_context=_),t.splice(c,2);break}if("--context-columns"==f){n=!0;var d=h.parseInt(t[c+1]);d>=0&&(this.flags.unchanged_column_context=d),t.splice(c,2);break}if("--inplace"==f){n=!0,r=!0,t.splice(c,1);break}if("--git"==f){n=!0,s=!0,t.splice(c,1);break}if("--unordered"==f){n=!0,this.flags.ordered=!1,this.flags.unchanged_context=0,this.order_set=!0,t.splice(c,1);break}if("--ordered"==f){n=!0,this.flags.ordered=!0,this.order_set=!0,t.splice(c,1);break}if("--color"==f){n=!0,this.flags.terminal_format="ansi",t.splice(c,1);break}if("--no-color"==f){n=!0,this.flags.terminal_format="plain",t.splice(c,1);break}if("--input-format"==f){n=!0,this.setFormat(t[c+1]),t.splice(c,2);break}if("--output-format"==f){n=!0,this.output_format=t[c+1],this.output_format_set=!0,t.splice(c,2);break}if("--id"==f){n=!0,null==this.flags.ids&&(this.flags.ids=[]),this.flags.ids.push(t[c+1]),t.splice(c,2);break}if("--ignore"==f){n=!0,this.flags.ignoreColumn(t[c+1]),t.splice(c,2);break}if("--index"==f){n=!0,this.flags.always_show_order=!0,this.flags.never_show_order=!1,t.splice(c,1);break}if("--www"==f)n=!0,this.output_format="www",this.output_format_set=!0,t.splice(c,1);else{if("--table"==f){n=!0,this.flags.addTable(t[c+1]),t.splice(c,2);break}if("-w"==f||"--ignore-whitespace"==f){n=!0,this.flags.ignore_whitespace=!0,t.splice(c,1);break}if("-i"==f||"--ignore-case"==f){n=!0,this.flags.ignore_case=!0,t.splice(c,1);break}if("-d"==f||"--ignore-epsilon"==f){n=!0;var g=t[c+1];this.flags.ignore_epsilon=parseFloat(g);var p=this.flags.ignore_epsilon;if(isNaN(p))return e.writeStderr("Epsilon for numeric comparison must be numeric\n"),1;t.splice(c,2);break}if("--padding"==f){n=!0,this.flags.padding_strategy=t[c+1],t.splice(c,2);break}if("-e"==f||"--eol"==f){n=!0;var m=t[c+1];if("crlf"==m)m="\r\n";else if("lf"==m)m="\n";else if("cr"==m)m="\r";else{if("auto"!=m)return e.writeStderr("Expected line ending of either 'crlf' or 'lf' but got "+m+"\n"),1;m=null}this.csv_eol_preference=m,t.splice(c,2);break}if("--fail-if-diff"==f){n=!0,this.fail_if_diff=!0,t.splice(c,1);break}if("help"==f||"-h"==f||"--help"==f){n=!0,t.splice(c,1),l=!0;break}}}}var v=t[0],w=!0;l&&(v="",t=[]);try{if(t.length<2){if("version"==v)return e.writeStdout(R.VERSION+"\n"),0;if("git"==v)return e.writeStdout("You can use daff to improve git's handling of csv files, by using it as a\ndiff driver (for showing what has changed) and as a merge driver (for merging\nchanges between multiple versions).\n"),e.writeStdout("\n"),e.writeStdout("Automatic setup\n"),e.writeStdout("---------------\n\n"),e.writeStdout("Run:\n"),e.writeStdout("  daff git csv\n"),e.writeStdout("\n"),e.writeStdout("Manual setup\n"),e.writeStdout("------------\n\n"),e.writeStdout("Create and add a file called .gitattributes in the root directory of your\nrepository, containing:\n\n"),e.writeStdout("  *.csv diff=daff-csv\n"),e.writeStdout("  *.csv merge=daff-csv\n"),e.writeStdout("\nCreate a file called .gitconfig in your home directory (or alternatively\nopen .git/config for a particular repository) and add:\n\n"),e.writeStdout('  [diff "daff-csv"]\n'),e.writeStdout("  command = daff diff --git\n"),e.writeStderr("\n"),e.writeStdout('  [merge "daff-csv"]\n'),e.writeStdout("  name = daff tabular merge\n"),e.writeStdout("  driver = daff merge --output %A %O %A %B\n\n"),e.writeStderr('Make sure you can run daff from the command-line as just "daff" - if not,\nreplace "daff" in the driver and command lines above with the correct way\nto call it. Add --no-color if your terminal does not support ANSI colors.'),e.writeStderr("\n"),0;if(t.length<1)return e.writeStderr("daff can produce and apply tabular diffs.\n"),e.writeStderr("Call as:\n"),e.writeStderr("  daff a.csv b.csv\n"),e.writeStderr("  daff [--color] [--no-color] [--output OUTPUT.csv] a.csv b.csv\n"),e.writeStderr("  daff [--output OUTPUT.html] a.csv b.csv\n"),e.writeStderr("  daff [--www] a.csv b.csv\n"),e.writeStderr("  daff parent.csv a.csv b.csv\n"),e.writeStderr("  daff --input-format sqlite a.db b.db\n"),e.writeStderr("  daff patch [--inplace] a.csv patch.csv\n"),e.writeStderr("  daff merge [--inplace] parent.csv a.csv b.csv\n"),e.writeStderr("  daff trim [--output OUTPUT.csv] source.csv\n"),e.writeStderr("  daff render [--output OUTPUT.html] diff.csv\n"),e.writeStderr("  daff copy in.csv out.tsv\n"),e.writeStderr("  daff in.csv\n"),e.writeStderr("  daff git\n"),e.writeStderr("  daff version\n"),e.writeStderr("\n"),e.writeStderr("The --inplace option to patch and merge will result in modification of a.csv.\n"),e.writeStderr("\n"),e.writeStderr("If you need more control, here is the full list of flags:\n"),e.writeStderr("  daff diff [--output OUTPUT.csv] [--context NUM] [--all] [--act ACT] a.csv b.csv\n"),e.writeStderr("     --act ACT:     show only a certain kind of change (update, insert, delete, column)\n"),e.writeStderr("     --all:         do not prune unchanged rows or columns\n"),e.writeStderr("     --all-rows:    do not prune unchanged rows\n"),e.writeStderr("     --all-columns: do not prune unchanged columns\n"),e.writeStderr("     --color:       highlight changes with terminal colors (default in terminals)\n"),e.writeStderr("     --context NUM: show NUM rows of context (0=none)\n"),e.writeStderr("     --context-columns NUM: show NUM columns of context (0=none)\n"),e.writeStderr("     --fail-if-diff: return status is 0 if equal, 1 if different, 2 if problem\n"),e.writeStderr("     --id:          specify column name to use as primary key (repeat for multi-column key)\n"),e.writeStderr("     --ignore:      specify column name to ignore completely (can repeat)\n"),e.writeStderr("     --index:       include row/columns numbers from original tables\n"),e.writeStderr("     --input-format [csv|tsv|ssv|psv|json|sqlite]: set format to expect for input\n"),e.writeStderr("     --eol [crlf|lf|cr|auto]: separator between rows of csv output.\n"),e.writeStderr("     --no-color:    make sure terminal colors are not used\n"),e.writeStderr("     --ordered:     assume row order is meaningful (default for CSV)\n"),e.writeStderr("     --output-format [csv|tsv|ssv|psv|json|copy|html]: set format for output\n"),e.writeStderr("     --padding [dense|sparse|smart]: set padding method for aligning columns\n"),e.writeStderr("     --table NAME:  compare the named table, used with SQL sources. If name changes, use 'n1:n2'\n"),e.writeStderr("     --unordered:   assume row order is meaningless (default for json formats)\n"),e.writeStderr("     -w / --ignore-whitespace: ignore changes in leading/trailing whitespace\n"),e.writeStderr("     -i / --ignore-case: ignore differences in case\n"),e.writeStderr("     -d EPS / --ignore-epsilon EPS: ignore small floating point differences\n"),e.writeStderr("\n"),e.writeStderr("  daff render [--output OUTPUT.html] [--css CSS.css] [--fragment] [--plain] diff.csv\n"),e.writeStderr("     --css CSS.css: generate a suitable css file to go with the html\n"),e.writeStderr("     --fragment:    generate just a html fragment rather than a page\n"),e.writeStderr("     --plain:       do not use fancy utf8 characters to make arrows prettier\n"),e.writeStderr("     --unquote:     do not quote html characters in html diffs\n"),e.writeStderr("     --www:         send output to a browser\n"),1}v=t[0];var b=1;if(o.has(["diff","patch","merge","trim","render","git","version","copy"],v)||(0==v.indexOf("--")?(v="diff",b=0):-1!=v.indexOf(".")&&(2==t.length?(v="diff",b=0):1==t.length&&(v="copy",b=0))),"git"==v){var y=t.splice(b,t.length-b);return this.installGitDriver(e,y)}if(s){var S=t.length-b;if(7!=S&&9!=S)return e.writeStderr("Expected 7 or 9 parameters from git, but got "+S+"\n"),1;var x=t.splice(b,S);t.splice(0,t.length),b=0;var T=x[0],O=x[0],k=x[1],N=x[4];9==S&&(e.writeStdout(x[8]),O=x[7]),e.writeStdout("--- a/"+T+"\n"),e.writeStdout("+++ b/"+O+"\n"),t.push(k),t.push(N)}var P=null;t.length-b>=3&&(P=this.loadTable(t[b],"parent"),++b);var I=t[b],q=this.loadTable(I,"local"),A=null;if(t.length-b>=2&&("copy"!=v?A=this.loadTable(t[1+b],"remote"):i=t[1+b]),this.flags.diff_strategy=this.strategy,r)return null!=i&&e.writeStderr("Please do not use --inplace when specifying an output.\n"),i=I,1;if(null==i&&(i="-"),"diff"==v)if(this.order_set||(this.flags.ordered=this.order_preference,this.flags.ordered||(this.flags.unchanged_context=0)),this.flags.allow_nested_cells=this.nested_output,this.fail_if_diff){try{this.runDiff(P,q,A,this.flags,i)}catch(a){return 2}if(this.diffs_found)return 1}else this.runDiff(P,q,A,this.flags,i);else if("patch"==v){new D(q,A).apply(),this.saveTable(i,q)}else if("merge"==v){var M=new V(P,q,A,this.flags).apply();w=0==M,M>0&&e.writeStderr(M+" conflict"+(M>1?"s":"")+"\n"),this.saveTable(i,q)}else if("trim"==v)this.saveTable(i,q);else if("render"==v)this.renderTable(i,q);else if("copy"==v){var j=new ft(q);j.add("untitled"),this.saveTables(i,j,this.useColor(this.flags,i),!1)}}catch(a){var E=mt.caught(a).unwrap();if(!this.fail_if_diff)throw mt.thrown(E);return 2}return w?0:this.fail_if_diff?2:1},coopyhx:function(t){var e=t.args();return"--keep"==e[0]?R.keepAround():this.run(e,t)},__class__:R};var T=function(){};T.__name__=!0,T.prototype={spot_a:null,spot_b:null,item_a:null,item_b:null,__class__:T};var O=t.coopy.Csv=function(t,e){null==t&&(t=","),this.cursor=0,this.row_ended=!1,this.delim=null==t?",":t,this.discovered_eol=null,this.preferred_eol=e};O.__name__=!0,O.prototype={cursor:null,row_ended:null,has_structure:null,delim:null,discovered_eol:null,preferred_eol:null,renderTable:function(t){var e=this.preferred_eol;null==e&&(e="\r\n");for(var n=t.getCellView(),i=new ct(t),r=i.width(),s=[];i.fetch();){for(var l=0,o=r;l<o;){var a=l++;a>0&&s.push(this.delim),s.push(this.renderCell(n,i.getCell(a)))}s.push(e)}return s.join("")},renderCell:function(t,e,n){if(null==n&&(n=!1),null==e)return"NULL";var i=t.toString(e),r=n;if(r||i.length>0&&(" "!=i.charAt(0)&&" "!=i.charAt(i.length-1)||(r=!0)),!r)for(var s=0,l=i.length;s<l;){var o=s++;if('"'==(d=i.charAt(o))||"\r"==d||"\n"==d||"\t"==d){r=!0;break}if(d==this.delim.charAt(0)){if(1==this.delim.length){r=!0;break}if(o+this.delim.length<=i.length){for(var a=!0,h=1,u=this.delim.length;h<u;){var c=h++;if(i.charAt(o+c)!=this.delim.charAt(c)){a=!1;break}}if(a){r=!0;break}}}}var f="";r&&(f+='"');var _="";for(s=0,l=i.length;s<l;){var d;o=s++;'"'==(d=i.charAt(o))&&(f+='"'),"\r"!=d&&"\n"!=d?(_.length>0&&(f+=_,_=""),f+=d):_+=d}return _.length>0&&(f+=_),r&&(f+='"'),f},parseTable:function(t,e){if(!e.isResizable())return!1;this.cursor=0,this.row_ended=!1,this.has_structure=!0,e.resize(0,0);for(var n=0,i=0,r=0,s=0;this.cursor<t.length;){var l=this.parseCellPart(t);if(s>=i&&(i=s+1,e.resize(n,i)),r>=n)if(s>0){if(""!=l&&null!=l){for(var o="",a=0,u=n;a<u;){var c=a++;c>0&&(o+=","),o+=h.string(e.getCell(c,s))}console.log("coopy/Csv.hx:179:","Ignored overflowing row "+s+" with cell '"+l+"' after: "+o)}}else n=r+1,e.resize(n,i);e.setCell(r,i-1,l),++r,this.row_ended&&(r=0,++s),this.cursor++}return!0},makeTable:function(t){var e=new Y(0,0);return this.parseTable(t,e),e},parseCellPart:function(t){if(null==t)return null;this.row_ended=!1;for(var e=t.length,n=0,i=!1,r=0,s="",o=this.cursor,a=this.cursor,h=t.length;a<h;){var u=a++,c=l.cca(t,u);if(n=u,95!=c&&u<e&&(e=u),this.has_structure){if(!i){if(c==l.cca(this.delim,0)){if(1==this.delim.length)break;if(u+this.delim.length<=t.length){for(var f=!0,_=1,d=this.delim.length;_<d;){var g=_++;if(t.charAt(u+g)!=this.delim.charAt(g)){f=!1;break}}if(f){n+=this.delim.length-1;break}}}if(13==c||10==c){var p=l.cca(t,u+1);null!=p&&p!=c&&(13!=p&&10!=p||(null==this.discovered_eol&&(this.discovered_eol=String.fromCodePoint(c)+String.fromCodePoint(p)),++n)),null==this.discovered_eol&&(this.discovered_eol=String.fromCodePoint(c)),this.row_ended=!0;break}if(34==c){if(u==this.cursor){i=!0,r=c,u!=o&&(s+=String.fromCodePoint(c));continue}c==r&&(i=!0)}s+=String.fromCodePoint(c);continue}if(c==r){i=!1;continue}}s+=String.fromCodePoint(c)}if(this.cursor=n,0==r){if("NULL"==s)return null;if(e>o)if("NULL"==l.substr(s,e-o,null))return l.substr(s,1,null)}return s},parseCell:function(t){return this.cursor=0,this.row_ended=!1,this.has_structure=!1,this.parseCellPart(t)},getDiscoveredEol:function(){return this.discovered_eol},setPreferredEol:function(t){this.preferred_eol=t},__class__:O};var k=t.coopy.DiffRender=function(){this.text_to_insert=[],this.open=!1,this.pretty_arrows=!0,this.quote_html=!0};k.__name__=!0,k.examineCell=function(t,e,n,i,r,s,o,a,h){null==h&&(h=0);var u=n.isHash(i);if(a.category="",a.category_given_tr="",a.separator="",a.pretty_separator="",a.conflicted=!1,a.updated=!1,a.meta=a.pvalue=a.lvalue=a.rvalue=null,a.value=i,a.pretty_value=a.value,null==s&&(s=""),null==r&&(r=""),s.length>=3&&"@"==s.charAt(0)&&"@"!=s.charAt(1)){var c=s.indexOf("@",1);c>=0&&(a.meta=l.substr(s,1,c-1),s=l.substr(s,c+1,s.length),a.category="meta")}var f=!1;if(":"==s&&(a.category="move"),""==s&&1==h&&0==e&&(a.category="index"),r.indexOf("+++")>=0?a.category_given_tr=a.category="add":r.indexOf("---")>=0&&(a.category_given_tr=a.category="remove",f=!0),"!"==s)a.category="spec";else if("@@"==s)a.category="header";else if("..."==s)a.category="gap";else if("+++"==s)f||(a.category="add");else if("---"==s)a.category="remove";else if(s.indexOf("->")>=0&&!f){var _=s.split("!"),d=s,g=_[1];null==g&&(g=d);var p=n.toString(a.value);if(null==p&&(p=""),u||p.indexOf(g)>=0){var m="modify",v=g;g!=d&&(a.conflicted=u?n.hashExists(i,"theirs"):p.indexOf(d)>=0,a.conflicted&&(v=d,m="conflict")),a.updated=!0,a.separator=v,a.pretty_separator=v,u?_=a.conflicted?[n.hashGet(i,"before"),n.hashGet(i,"ours"),n.hashGet(i,"theirs")]:[n.hashGet(i,"before"),n.hashGet(i,"after")]:(a.pretty_value=n.toString(a.pretty_value),null==a.pretty_value&&(a.pretty_value=""),_=a.pretty_value==v?["",""]:a.pretty_value.split(v));var w=_;if(_.length>=2&&(w[0]=k.markSpaces(_[0],_[1]),w[1]=k.markSpaces(_[1],_[0])),_.length>=3){var b=w[0];w[0]=k.markSpaces(b,_[2]),w[2]=k.markSpaces(_[2],b)}a.pretty_separator=String.fromCodePoint(8594),a.pretty_value=w.join(a.pretty_separator),a.category_given_tr=a.category=m;var y=a.conflicted?1:0;a.lvalue=_[y],a.rvalue=_[y+1],a.conflicted&&(a.pvalue=_[0])}}0==t&&h>0&&(a.category_given_tr=a.category="index")},k.markSpaces=function(t,e){if(t==e)return t;if(null==t||null==e)return t;if(c.replace(t," ","")!=c.replace(e," ",""))return t;for(var n=new String(""),i=0,r=0;i<t.length;){var s=t.charAt(i),l="";r<e.length&&(l=e.charAt(r)),s==l?(n+=s,++i,++r):" "==l?++r:(n+=String.fromCodePoint(9251),++i)}return n},k.renderCell=function(t,e,n,i){var r=new p,s=e.toString(t.getCell(0,0)),l="@:@"==s?1:0;return k.examineCell(n,i,e,t.getCell(n,i),e.toString(t.getCell(n,l)),e.toString(t.getCell(l,i)),s,r,l),r},k.prototype={text_to_insert:null,td_open:null,td_close:null,open:null,pretty_arrows:null,quote_html:null,section:null,usePrettyArrows:function(t){this.pretty_arrows=t},quoteHtml:function(t){this.quote_html=t},insert:function(t){this.text_to_insert.push(t)},beginTable:function(){this.insert("<table>\n"),this.section=null},setSection:function(t){t!=this.section&&(null!=this.section&&(this.insert("</t"),this.insert(this.section),this.insert(">\n")),this.section=t,null!=this.section&&(this.insert("<t"),this.insert(this.section),this.insert(">\n")))},beginRow:function(t){this.td_open="<td",this.td_close="</td>";var e;"header"==t&&(this.td_open="<th",this.td_close="</th>");var n="<tr>";""!=(e=t)&&(n='<tr class="'+e+'">'),this.insert(n)},insertCell:function(t,e){var n="";""!=e&&(n=' class="'+e+'"'),this.insert(this.td_open+n+">"),null!=t?this.insert(t):this.insert("null"),this.insert(this.td_close)},endRow:function(){this.insert("</tr>\n")},endTable:function(){this.setSection(null),this.insert("</table>\n")},html:function(){return this.text_to_insert.join("")},toString:function(){return this.html()},render:function(t){if(0==(t=R.tablify(t)).get_width()||0==t.get_height())return this;var e=this;e.beginTable();var n=-1,i=new p,r=t.getCellView(),s=r.toString(t.getCell(0,0)),l="@:@"==s?1:0;if(l>0&&(t.get_width()<=1||t.get_height()<=1))return this;for(var o=0,a=t.get_height();o<a;){var h=o++,u=r.toString(t.getCell(l,h));null==u&&(u=""),k.examineCell(l,h,r,u,"",u,s,i,l);var f=i.category;"spec"==f&&(n=h),"header"==f||"spec"==f||"index"==f||"meta"==f?this.setSection("head"):this.setSection("body"),e.beginRow(f);for(var _=0,d=t.get_width();_<d;){var g=_++;k.examineCell(g,h,r,t.getCell(g,h),n>=0?r.toString(t.getCell(g,n)):"",u,s,i,l);var m=this.pretty_arrows?i.pretty_value:i.value;this.quote_html&&(m=c.htmlEscape(r.toString(m))),e.insertCell(m,i.category_given_tr)}e.endRow()}return e.endTable(),this},renderTables:function(t){var e=t.getOrder(),n=0;(e.length<=1||t.hasInsDel())&&(this.render(t.one()),n=1);for(var i=n,r=e.length;i<r;){var s=e[i++],l=t.get(s);l.get_height()<=1||(this.insert("<h3>"),this.insert(s),this.insert("</h3>\n"),this.render(l))}return this},sampleCss:function(){return".highlighter .add { \n  background-color: #7fff7f;\n}\n\n.highlighter .remove { \n  background-color: #ff7f7f;\n}\n\n.highlighter td.modify { \n  background-color: #7f7fff;\n}\n\n.highlighter td.conflict { \n  background-color: #f00;\n}\n\n.highlighter .spec { \n  background-color: #aaa;\n}\n\n.highlighter .move { \n  background-color: #ffa;\n}\n\n.highlighter .null { \n  color: #888;\n}\n\n.highlighter table { \n  border-collapse:collapse;\n}\n\n.highlighter td, .highlighter th {\n  border: 1px solid #2D4068;\n  padding: 3px 7px 2px;\n}\n\n.highlighter th, .highlighter .header, .highlighter .meta {\n  background-color: #aaf;\n  font-weight: bold;\n  padding-bottom: 4px;\n  padding-top: 5px;\n  text-align:left;\n}\n\n.highlighter tr.header th {\n  border-bottom: 2px solid black;\n}\n\n.highlighter tr.index td, .highlighter .index, .highlighter tr.header th.index {\n  background-color: white;\n  border: none;\n}\n\n.highlighter .gap {\n  color: #888;\n}\n\n.highlighter td {\n  empty-cells: show;\n  white-space: pre-wrap;\n}\n"},completeHtml:function(){this.text_to_insert.splice(0,0,"<!DOCTYPE html>\n<html>\n<head>\n<meta charset='utf-8'>\n<style TYPE='text/css'>\n");var t=this.text_to_insert,e=this.sampleCss();t.splice(1,0,e),this.text_to_insert.splice(2,0,"</style>\n</head>\n<body>\n<div class='highlighter'>\n"),this.text_to_insert.push("</div>\n</body>\n</html>\n")},__class__:k};var N=t.coopy.DiffSummary=function(){};N.__name__=!0,N.prototype={row_deletes:null,row_inserts:null,row_updates:null,row_reorders:null,col_deletes:null,col_inserts:null,col_updates:null,col_renames:null,col_reorders:null,row_count_initial_with_header:null,row_count_final_with_header:null,row_count_initial:null,row_count_final:null,col_count_initial:null,col_count_final:null,different:null,__class__:N};var P=function(t){this.flags=t};P.__name__=!0,P.__interfaces__=[g],P.quoteForDiff=function(t,e){var n="NULL";if(t.equals(e,null))return n;for(var i=t.toString(e),r=0,s=0,o=i.length;s<o;){s++;if(95!=l.cca(i,r))break;++r}return l.substr(i,r,null)==n&&(i="_"+i),i},P.prototype={view:null,separator:null,conflict_separator:null,flags:null,needSeparator:function(){return!0},setSeparator:function(t){this.separator=t},setConflictSeparator:function(t){this.conflict_separator=t},setView:function(t){this.view=t},update:function(t,e){return this.view.toDatum(P.quoteForDiff(this.view,t)+this.separator+P.quoteForDiff(this.view,e))},conflict:function(t,e,n){return this.view.toString(t)+this.conflict_separator+this.view.toString(e)+this.conflict_separator+this.view.toString(n)},marker:function(t){return this.view.toDatum(t)},links:function(t,e){return this.flags.count_like_a_spreadsheet&&!e?this.view.toDatum(t.toBase26String()):this.view.toDatum(t.toString())},__class__:P};var I=function(){};I.__name__=!0,I.prototype={getRowString:null,isPreamble:null,__class__:I};var D=t.coopy.HighlightPatch=function(t,e,n){this.source=t,this.patch=e,this.flags=n,null==n&&(this.flags=new C),this.view=e.getCellView(),this.sourceView=t.getCellView(),this.meta=t.getMeta()};D.__name__=!0,D.__interfaces__=[I],D.prototype={source:null,patch:null,view:null,sourceView:null,csv:null,header:null,headerPre:null,headerPost:null,headerRename:null,headerMove:null,modifier:null,currentRow:null,payloadCol:null,payloadTop:null,mods:null,cmods:null,rowInfo:null,cellInfo:null,rcOffset:null,indexes:null,sourceInPatchCol:null,patchInSourceCol:null,destInPatchCol:null,patchInDestCol:null,patchInSourceRow:null,lastSourceRow:null,actions:null,rowPermutation:null,rowPermutationRev:null,colPermutation:null,colPermutationRev:null,haveDroppedColumns:null,headerRow:null,preambleRow:null,flags:null,meta_change:null,process_meta:null,prev_meta:null,next_meta:null,finished_columns:null,meta:null,reset:function(){this.header=new wt,this.headerPre=new bt,this.headerPost=new bt,this.headerRename=new bt,this.headerMove=null,this.modifier=new wt,this.mods=[],this.cmods=[],this.csv=new O,this.rcOffset=0,this.currentRow=-1,this.rowInfo=new p,this.cellInfo=new p,this.sourceInPatchCol=this.patchInSourceCol=this.patchInDestCol=null,this.patchInSourceRow=new wt,this.indexes=null,this.lastSourceRow=-1,this.actions=[],this.rowPermutation=null,this.rowPermutationRev=null,this.colPermutation=null,this.colPermutationRev=null,this.haveDroppedColumns=!1,this.headerRow=0,this.preambleRow=0,this.meta_change=!1,this.process_meta=!1,this.prev_meta=null,this.next_meta=null,this.finished_columns=!1},processMeta:function(){this.process_meta=!0},apply:function(){if(this.reset(),this.patch.get_width()<2)return!0;if(this.patch.get_height()<1)return!0;this.payloadCol=1+this.rcOffset,this.payloadTop=this.patch.get_width();var t=this.patch.getCellView().toString(this.patch.getCell(0,0));this.rcOffset="@:@"==t?1:0;for(var e=0,n=this.patch.get_height();e<n;){var i=e++,r=this.view.toString(this.patch.getCell(this.rcOffset,i));this.actions.push(null!=r?r:"")}this.preambleRow=this.headerRow=this.rcOffset;for(e=0,n=this.patch.get_height();e<n;){i=e++;this.applyRow(i)}return this.finishColumns(),this.finishRows(),!0},needSourceColumns:function(){if(null==this.sourceInPatchCol){this.sourceInPatchCol=new wt,this.patchInSourceCol=new wt;for(var t=this.source.getCellView(),e=0,n=this.source.get_width();e<n;){var i=e++,r=t.toString(this.source.getCell(i,0)),s=this.headerPre.h[r];null!=s&&(this.sourceInPatchCol.h[i]=s,this.patchInSourceCol.h[s]=i)}}},needDestColumns:function(){if(null==this.patchInDestCol){this.patchInDestCol=new wt,this.destInPatchCol=new wt;for(var t=0,e=this.cmods;t<e.length;){var n=e[t];++t,-1!=n.patchRow&&(this.patchInDestCol.h[n.patchRow]=n.destRow,this.destInPatchCol.h[n.destRow]=n.patchRow)}}},needSourceIndex:function(){if(null==this.indexes){var t=new ot;t.a=this.source,t.b=this.source;var e=new S(t);e.storeIndexes(),e.run(),e.align(),this.indexes=e.getIndexes(),this.needSourceColumns()}},setMetaProp:function(t,e,n,i){if(null!=e&&null!=n){if(!Object.prototype.hasOwnProperty.call(t.h,e)){t.h[e]=[]}var r=new K;r.prevName=n,r.name=n,""==i&&(i=null),r.val=i,t.h[e].push(r)}},applyMetaRow:function(t){this.needSourceColumns();var e=t.split("@"),n="";e.length>1&&(n=e[e.length-2]),e.length>0&&(t=e[e.length-1]),null==this.prev_meta&&(this.prev_meta=new bt),null==this.next_meta&&(this.next_meta=new bt);for(var i=this.payloadCol,r=this.payloadTop;i<r;){var s=i++,l=this.getDatum(s),o=s,a=this.patchInSourceCol.h.hasOwnProperty(o)?this.patchInSourceCol.h[o]:-1,h=null,u=null;-1!=a&&(h=this.source.getCell(a,0)),this.header.h.hasOwnProperty(o)&&(u=this.header.h[o]),k.examineCell(0,0,this.view,l,"",t,"",this.cellInfo),this.cellInfo.updated?(this.setMetaProp(this.prev_meta,h,n,this.cellInfo.lvalue),this.setMetaProp(this.next_meta,u,n,this.cellInfo.rvalue)):(this.setMetaProp(this.prev_meta,h,n,this.cellInfo.value),this.setMetaProp(this.next_meta,u,n,this.cellInfo.value))}},applyRow:function(t){this.currentRow=t;var e=this.actions[t],n=!1;if(0==t&&this.rcOffset>0)n=!0;else if("@@"==e)this.preambleRow=this.headerRow=t,this.applyHeader(),this.applyAction("@@"),n=!0;else if("!"==e)this.preambleRow=this.headerRow=t,this.applyMeta(),n=!0;else if(0==e.indexOf("@")){if(this.flags.addWarning("cannot usefully apply diffs with metadata yet: '"+e+"'"),this.preambleRow=t,this.applyMetaRow(e),this.process_meta){var i=e.split("@");i.length>0&&(e=i[i.length-1])}else this.meta_change=!0,n=!0;this.meta_change=!0,n=!0}this.process_meta||n||(this.finishColumns(),"+++"==e||"---"==e||"+"==e||":"==e?this.applyAction(e):e.indexOf("->")>=0?this.applyAction("->"):this.lastSourceRow=-1)},getDatum:function(t){return this.patch.getCell(t,this.currentRow)},getString:function(t){return this.view.toString(this.getDatum(t))},getStringNull:function(t){var e=this.getDatum(t);return null==e?null:this.view.toString(e)},applyMeta:function(){for(var t=this.payloadCol,e=this.payloadTop;t<e;){var n=t++,i=this.getString(n);""!=i&&(this.modifier.h[n]=i)}},applyHeader:function(){for(var t=this.payloadCol,e=this.payloadTop;t<e;){var n=t++,i=this.getString(n);if("..."!=i){var r=this.modifier.h[n],s=!1;if(null!=r&&58==l.cca(r,0)&&(s=!0,r=l.substr(r,1,r.length)),this.header.h[n]=i,null==r||40!=l.cca(r,0))"+++"!=r&&(this.headerPre.h[i]=n),"---"!=r&&(this.headerPost.h[i]=n),s&&(null==this.headerMove&&(this.headerMove=new bt),this.headerMove.h[i]=1);else{var o=l.substr(r,1,r.length-2);this.headerPre.h[o]=n,this.headerPost.h[i]=n,this.headerRename.h[o]=i}}else this.modifier.h[n]="...",this.haveDroppedColumns=!0}this.useMetaForRowChanges()||0==this.source.get_height()&&this.applyAction("+++")},lookUp:function(t){if(null==t&&(t=0),this.patchInSourceRow.h.hasOwnProperty(this.currentRow+t))return this.patchInSourceRow.h[this.currentRow+t];var e=-1;if(this.currentRow+=t,this.currentRow>=0&&this.currentRow<this.patch.get_height())for(var n=0,i=this.indexes;n<i.length;){var r=i[n];++n;var s=r.queryByContent(this);if(0!=s.spot_a){if(1==s.spot_a){e=s.item_a.lst[0];break}if(this.currentRow>0){var l=this.patchInSourceRow.h[this.currentRow-1];if(null!=l)for(var o=s.item_a.lst,a=0;a<o.length;){var h=o[a];if(++a,h==l+1){e=h;break}}}}}return this.patchInSourceRow.h[this.currentRow]=e,this.currentRow-=t,e},applyActionExternal:function(t){if("@@"!=t){var e=new Q;e.action=t,this.checkAct(),"+++"!=t&&(e.cond=new bt),"---"!=t&&(e.val=new bt);for(var n=!1,i=this.payloadCol,r=this.payloadTop;i<r;){var s=i++,l=this.header.h[s],o=l;Object.prototype.hasOwnProperty.call(this.headerRename.h,l)&&(o=this.headerRename.h[l]);var a=this.modifier.h[s];if("..."!=a&&(null!=o&&""!=o)){var h=this.csv.parseCell(this.getStringNull(s)),u=!1;if(this.rowInfo.updated&&(this.getPreString(h),u=this.cellInfo.updated),"+++"==a&&"---"!=t&&null!=h&&""!=h&&(null==e.val&&(e.val=new bt),e.val.h[o]=h,n=!0),u){var c=e.cond,f=this.csv.parseCell(this.cellInfo.lvalue);c.h[o]=f;var _=e.val,d=this.csv.parseCell(this.cellInfo.rvalue);_.h[o]=d}else"+++"==t?"---"!=a&&(e.val.h[o]=h):"+++"!=a&&"---"!=a&&(e.cond.h[o]=h)}}if("+"==e.action){if(!n)return;e.action="->"}this.meta.changeRow(e)}},applyAction:function(t){if(this.useMetaForRowChanges())this.applyActionExternal(t);else{var e=new q;e.code=t,e.add="+++"==t,e.rem="---"==t,e.update="->"==t,this.needSourceIndex(),-1==this.lastSourceRow&&(this.lastSourceRow=this.lookUp(-1)),e.sourcePrevRow=this.lastSourceRow;var n=this.actions[this.currentRow+1];"+++"!=n&&"..."!=n&&(e.sourceNextRow=this.lookUp(1)),e.add?("+++"!=this.actions[this.currentRow-1]&&("@@"==this.actions[this.currentRow-1]?(e.sourcePrevRow=0,this.lastSourceRow=0):e.sourcePrevRow=this.lookUp(-1)),e.sourceRow=e.sourcePrevRow,-1!=e.sourceRow&&(e.sourceRowOffset=1)):e.sourceRow=this.lastSourceRow=this.lookUp(),""==this.actions[this.currentRow+1]&&(this.lastSourceRow=e.sourceNextRow),e.patchRow=this.currentRow,"@@"==t&&(e.sourceRow=0),this.mods.push(e)}},checkAct:function(){var t=this.getString(this.rcOffset);this.rowInfo.value!=t&&k.examineCell(0,0,this.view,t,"",t,"",this.rowInfo)},getPreString:function(t){return this.checkAct(),this.rowInfo.updated?(k.examineCell(0,0,this.view,t,"",this.rowInfo.value,"",this.cellInfo),this.cellInfo.updated?this.cellInfo.lvalue:t):t},getRowString:function(t){var e=this.sourceInPatchCol.h[t];return null==e?"NOT_FOUND":this.getPreString(this.getString(e))},isPreamble:function(){return this.currentRow<=this.preambleRow},sortMods:function(t,e){return"@@"==e.code&&"@@"!=t.code?1:"@@"==t.code&&"@@"!=e.code?-1:-1!=t.sourceRow||t.add||-1==e.sourceRow?-1==t.sourceRow||e.add||-1!=e.sourceRow?t.sourceRow+t.sourceRowOffset>e.sourceRow+e.sourceRowOffset?1:t.sourceRow+t.sourceRowOffset<e.sourceRow+e.sourceRowOffset?-1:t.patchRow>e.patchRow?1:t.patchRow<e.patchRow?-1:0:-1:1},processMods:function(t,n,i){t.sort(function(t,n){if(null==n)return null;null==n.__id__&&(n.__id__=e.$haxeUID++);var i;null==t.hx__closures__?t.hx__closures__={}:i=t.hx__closures__[n.__id__];null==i&&(i=n.bind(t),t.hx__closures__[n.__id__]=i);return i}(this,this.sortMods));var r=0,s=-1,l=0;t.length>0&&-1==t[0].sourcePrevRow&&(s=0);for(var o=0;o<t.length;){var a=t[o];if(++o,-1!=s)for(var h=s,u=a.sourceRow+a.sourceRowOffset;h<u;){var c=h++;n.push(c+r),++l,++s}a.rem?(n.push(-1),--r):a.add?(a.destRow=l,++l,++r):a.destRow=l,a.sourceRow>=0?(s=a.sourceRow+a.sourceRowOffset,a.rem&&++s):a.add&&-1!=a.sourceNextRow?s=a.sourceNextRow+a.sourceRowOffset:(a.rem||a.add)&&(s=-1)}if(-1!=s)for(o=s,h=i;o<h;){c=o++;n.push(c+r),++l,++s}return i+r},useMetaForColumnChanges:function(){return null!=this.meta&&this.meta.useForColumnChanges()},useMetaForRowChanges:function(){return null!=this.meta&&this.meta.useForRowChanges()},computeOrdering:function(t,e,n,i){for(var r={},s={},l={},o=0,a=0;a<t.length;){var h=t[a];if(++a,!(h.add||h.rem||h.sourceRow<0)){if(h.sourcePrevRow>=0){var u=h.sourceRow;r[h.sourcePrevRow]=u;var c=h.sourcePrevRow;s[h.sourceRow]=c,h.sourcePrevRow+1!=h.sourceRow&&++o}if(h.sourceNextRow>=0){var f=h.sourceNextRow;r[h.sourceRow]=f;var _=h.sourceRow;s[h.sourceNextRow]=_,h.sourceRow+1!=h.sourceNextRow&&++o}}}if(o>0){for(var d=null,g=null,p=[],m=(a=0,i);a<m;){var v=s[b=a++];null!=v?l[v]=b:p.push(b)}var w={};for(a=0,m=i;a<m;){var b=a++;if(null==(d=null!=g&&l.hasOwnProperty(g)?l[g]:null))d=u=p.shift(),g=u;for(null==d&&(d=0);w.hasOwnProperty(d);)d=(d+1)%i;g=d,n.push(d),w[d]=1}for(a=0,m=n.length;a<m;){e[b=a++]=-1}for(a=0,m=e.length;a<m;){e[n[b=a++]]=b}}},permuteRows:function(){this.rowPermutation=[],this.rowPermutationRev=[],this.computeOrdering(this.mods,this.rowPermutation,this.rowPermutationRev,this.source.get_height())},fillInNewColumns:function(){for(var t=0,e=this.cmods;t<e.length;){var n=e[t];if(++t,!n.rem&&n.add){for(var i=0,r=this.mods;i<r.length;){var s=r[i];if(++i,-1!=s.patchRow&&-1!=s.destRow){var l=this.patch.getCell(n.patchRow,s.patchRow);this.source.setCell(n.destRow,s.destRow,l)}}var o=this.header.h[n.patchRow];this.source.setCell(n.destRow,0,this.view.toDatum(o))}}},finishRows:function(){if(!this.useMetaForRowChanges())if(0!=this.source.get_width()){var t=[];if(this.permuteRows(),this.rowPermutation.length>0)for(var e=0,n=this.mods;e<n.length;){var i=n[e];++e,i.sourceRow>=0&&(i.sourceRow=this.rowPermutation[i.sourceRow])}this.rowPermutation.length>0&&this.source.insertOrDeleteRows(this.rowPermutation,this.rowPermutation.length);var r=this.processMods(this.mods,t,this.source.get_height());this.source.insertOrDeleteRows(t,r),this.needDestColumns();for(e=0,n=this.mods;e<n.length;){i=n[e];if(++e,!i.rem)if(i.add)for(var s=this.headerPost.h,l=s,o=Object.keys(s),a=o.length,h=0;h<a;){var u=l[o[h++]],c=this.patchInDestCol.h[u];null!=c&&c>=0&&this.source.setCell(c,i.destRow,this.patch.getCell(u,i.patchRow))}else if(i.update){if(this.currentRow=i.patchRow,this.checkAct(),!this.rowInfo.updated)continue;for(var f=this.headerPre.h,_=f,d=Object.keys(f),g=d.length,p=0;p<g;){var m=_[d[p++]],v=this.view.toString(this.patch.getCell(m,i.patchRow));if(k.examineCell(0,0,this.view,v,"",this.rowInfo.value,"",this.cellInfo),this.cellInfo.updated&&!this.cellInfo.conflicted){var w=this.view.toDatum(this.csv.parseCell(this.cellInfo.rvalue)),b=this.patchInDestCol.h[m];null!=b&&b>=0&&this.source.setCell(this.patchInDestCol.h[m],i.destRow,w)}}}}this.fillInNewColumns();for(e=0,n=this.source.get_width();e<n;){var y=e++,C=this.view.toString(this.source.getCell(y,0)),S=this.headerRename.h[C];null!=S&&this.source.setCell(y,0,this.view.toDatum(S))}}else 0!=this.source.get_height()&&this.source.resize(0,0)},permuteColumns:function(){null!=this.headerMove&&(this.colPermutation=[],this.colPermutationRev=[],this.computeOrdering(this.cmods,this.colPermutation,this.colPermutationRev,this.source.get_width()),this.colPermutation.length)},finishColumns:function(){if(!this.finished_columns){this.finished_columns=!0,this.needSourceColumns();for(var t=this.payloadCol,e=this.payloadTop;t<e;){var n=t++,i=this.modifier.h[n];this.header.h[n];if(null==i&&(i=""),"---"==i){var r=-1;this.patchInSourceCol.h.hasOwnProperty(n)&&(r=this.patchInSourceCol.h[n]),(_=new q).code=i,_.rem=!0,_.sourceRow=r,_.patchRow=n,this.cmods.push(_)}else if("+++"==i){var s=new q;s.code=i,s.add=!0;s.sourceRow=-1,this.cmods.length>0&&(s.sourceRow=this.cmods[this.cmods.length-1].sourceRow),-1!=s.sourceRow&&(s.sourceRowOffset=1),s.patchRow=n,this.cmods.push(s)}else if("..."!=i){var l=-1;this.patchInSourceCol.h.hasOwnProperty(n)&&(l=this.patchInSourceCol.h[n]);var o=new q;o.code=i,o.patchRow=n,o.sourceRow=l,this.cmods.push(o)}}r=-1;var a=-1;for(t=0,e=this.cmods.length-1;t<e;){n=t++;var h=this.cmods[n].code;"+++"!=h&&"---"!=h&&(r=this.cmods[n].sourceRow),this.cmods[n+1].sourcePrevRow=r;var u=this.cmods.length-1-n,c=this.cmods[u].code;"+++"!=c&&"---"!=c&&(a=this.cmods[u].sourceRow),this.cmods[u-1].sourceNextRow=a}var f=[];if(this.permuteColumns(),null!=this.headerMove&&this.colPermutation.length>0){for(t=0,e=this.cmods;t<e.length;){var _=e[t];++t,_.sourceRow>=0&&(_.sourceRow=this.colPermutation[_.sourceRow])}this.useMetaForColumnChanges()||this.source.insertOrDeleteColumns(this.colPermutation,this.colPermutation.length)}var d=this.processMods(this.cmods,f,this.source.get_width());if(this.useMetaForColumnChanges()){var g=!1;for(t=0,e=this.cmods;t<e.length;){_=e[t];if(++t,""!=_.code){g=!0;break}}if(g){var p,v=[],w={};for(t=0,e=f.length;t<e;){w[n=t++]=(p=f[n])<0?p:p+1}this.needSourceColumns(),this.needDestColumns();for(t=1,e=this.patch.get_width();t<e;){var b=t++,y=new m,C=this.patchInSourceCol.h.hasOwnProperty(b)?this.patchInSourceCol.h[b]:-1,S=null,x=null;-1!=C&&(S=this.source.getCell(C,0)),"---"!=this.modifier.h[b]&&this.header.h.hasOwnProperty(b)&&(x=this.header.h[b]),y.prevName=S,y.name=x,null!=this.next_meta&&Object.prototype.hasOwnProperty.call(this.next_meta.h,x)&&(y.props=this.next_meta.h[x]),v.push(y)}this.meta.alterColumns(v)}}else this.source.insertOrDeleteColumns(f,d)}},__class__:D};var q=t.coopy.HighlightPatchUnit=function(){this.add=!1,this.rem=!1,this.update=!1,this.sourceRow=-1,this.sourceRowOffset=0,this.sourcePrevRow=-1,this.sourceNextRow=-1,this.destRow=-1,this.patchRow=-1,this.code=""};q.__name__=!0,q.prototype={add:null,rem:null,update:null,code:null,sourceRow:null,sourceRowOffset:null,sourcePrevRow:null,sourceNextRow:null,destRow:null,patchRow:null,toString:function(){return"("+this.code+" patch "+this.patchRow+" source "+this.sourcePrevRow+":"+this.sourceRow+":"+this.sourceNextRow+"+"+this.sourceRowOffset+" dest "+this.destRow+")"},__class__:q};var A=function(t){this.items=new bt,this.cols=[],this.keys=[],this.top_freq=0,this.height=0,this.hdr=0,this.ignore_whitespace=!1,this.ignore_case=!1,null!=t&&(this.ignore_whitespace=t.ignore_whitespace,this.ignore_case=t.ignore_case)};A.__name__=!0,A.prototype={items:null,keys:null,top_freq:null,height:null,cols:null,v:null,indexed_table:null,hdr:null,ignore_whitespace:null,ignore_case:null,addColumn:function(t){this.cols.push(t)},indexTable:function(t,e){this.indexed_table=t,this.hdr=e,this.keys.length!=t.get_height()&&t.get_height()>0&&(this.keys[t.get_height()-1]=null);for(var n=0,i=t.get_height();n<i;){var r=n++,s=this.keys[r];null==s&&(s=this.toKey(t,r),this.keys[r]=s);var l=this.items.h[s];null==l&&(l=new M,this.items.h[s]=l),null==l.lst&&(l.lst=[]),l.lst.push(r);var o=l.lst.length;o>this.top_freq&&(this.top_freq=o)}this.height=t.get_height()},toKey:function(t,e){var n=e<this.hdr?"_":"";null==this.v&&(this.v=t.getCellView());for(var i=0,r=this.cols.length;i<r;){var s=i++,l=t.getCell(this.cols[s],e),o=this.v.toString(l);this.ignore_whitespace&&(o=c.trim(o)),this.ignore_case&&(o=o.toLowerCase()),s>0&&(n+=" // "),null!=o&&""!=o&&"null"!=o&&"undefined"!=o&&(n+=o)}return n},toKeyByContent:function(t){for(var e=t.isPreamble()?"_":"",n=0,i=this.cols.length;n<i;){var r=n++,s=t.getRowString(this.cols[r]);this.ignore_whitespace&&(s=c.trim(s)),this.ignore_case&&(s=s.toLowerCase()),r>0&&(e+=" // "),null!=s&&""!=s&&"null"!=s&&"undefined"!=s&&(e+=s)}return e},getTable:function(){return this.indexed_table},__class__:A};var M=function(){};M.__name__=!0,M.prototype={lst:null,add:function(t){return null==this.lst&&(this.lst=[]),this.lst.push(t),this.lst.length},length:function(){return this.lst.length},value:function(){return this.lst[0]},asList:function(){return this.lst},__class__:M};var j=function(t){this.flags=t,this.ia=new A(t),this.ib=new A(t),this.quality=0,this.hdr=0};j.__name__=!0,j.prototype={ia:null,ib:null,hdr:null,quality:null,flags:null,addColumns:function(t,e){this.ia.addColumn(t),this.ib.addColumn(e)},indexTables:function(t,e,n){this.ia.indexTable(t,n),this.ib.indexTable(e,n),this.hdr=n;for(var i=0,r=this.ia.items.h,s=Object.keys(r),l=s.length,o=0;o<l;){var a=s[o++],h=this.ia.items.h[a].lst.length,u=this.ib.items.h[a],c=0;null!=u&&(c=u.lst.length),1==h&&1==c&&++i}this.quality=i/Math.max(1,t.get_height())},queryByKey:function(t){var e=new T;return e.item_a=this.ia.items.h[t],e.item_b=this.ib.items.h[t],e.spot_a=e.spot_b=0,""!=t&&(null!=e.item_a&&(e.spot_a=e.item_a.lst.length),null!=e.item_b&&(e.spot_b=e.item_b.lst.length)),e},queryByContent:function(t){new T;var e=this.ia.toKeyByContent(t);return this.queryByKey(e)},queryLocal:function(t){var e=this.ia.toKey(this.ia.getTable(),t);return this.queryByKey(e)},localKey:function(t){return this.ia.toKey(this.ia.getTable(),t)},remoteKey:function(t){return this.ib.toKey(this.ib.getTable(),t)},getTopFreq:function(){return this.ib.top_freq>this.ia.top_freq?this.ib.top_freq:this.ia.top_freq},getQuality:function(){return this.quality},__class__:j};var E=function(){};E.__name__=!0,E.prototype={alterColumns:null,changeRow:null,applyFlags:null,asTable:null,cloneMeta:null,useForColumnChanges:null,useForRowChanges:null,getRowStream:null,isNested:null,isSql:null,getName:null,__class__:E};var F=function(t,e){this.data=t,this.columns=a.field(t,"columns"),this.rows=a.field(t,"rows"),this.w=this.columns.length,this.h=this.rows.length,this.idx2col=new wt;for(var n=0,i=this.columns.length;n<i;){var r=n++,s=this.columns[r];this.idx2col.h[r]=s}this.name=e};F.__name__=!0,F.__interfaces__=[E,v],F.prototype={w:null,h:null,columns:null,rows:null,data:null,idx2col:null,name:null,getTable:function(){return this},get_width:function(){return this.w},get_height:function(){return this.h+1},getCell:function(t,e){return 0==e?this.idx2col.h[t]:a.field(this.rows[e-1],this.idx2col.h[t])},setCell:function(t,e,n){console.log("coopy/JsonTable.hx:52:","JsonTable is read-only")},toString:function(){return""},getCellView:function(){return new $},isResizable:function(){return!1},resize:function(t,e){return!1},clear:function(){},insertOrDeleteRows:function(t,e){return!1},insertOrDeleteColumns:function(t,e){return!1},trimBlank:function(){return!1},getData:function(){return null},clone:function(){return null},setMeta:function(t){},getMeta:function(){return this},create:function(){return null},alterColumns:function(t){return!1},changeRow:function(t){return!1},applyFlags:function(t){return!1},asTable:function(){return null},cloneMeta:function(t){return null},useForColumnChanges:function(){return!1},useForRowChanges:function(){return!1},getRowStream:function(){return null},isNested:function(){return!1},isSql:function(){return!1},getName:function(){return this.name},__class__:F};var L=function(t,e){this.db=t;var n=a.field(t,"names"),i=null,r=n.length;if(null!=e&&null!=e.tables){i=new bt;for(var s=0,l=e.tables;s<l.length;){var o=l[s];++s,i.h[o]=!0}r=0;for(s=0;s<n.length;){o=n[s];++s,Object.prototype.hasOwnProperty.call(i.h,o)&&++r}}this.t=new Y(2,r+1),this.t.setCell(0,0,"name"),this.t.setCell(1,0,"table");var h=this.t.getCellView(),u=1;for(s=0;s<n.length;){o=n[s];if(++s,null==i||Object.prototype.hasOwnProperty.call(i.h,o)){this.t.setCell(0,u,o);var c=a.field(this.db,"tables");c=a.field(c,o),this.t.setCell(1,u,h.wrapTable(new F(c,o))),++u}}};L.__name__=!0,L.__interfaces__=[v],L.prototype={db:null,t:null,flags:null,getCell:function(t,e){return this.t.getCell(t,e)},setCell:function(t,e,n){},getCellView:function(){return this.t.getCellView()},isResizable:function(){return!1},resize:function(t,e){return!1},clear:function(){},insertOrDeleteRows:function(t,e){return!1},insertOrDeleteColumns:function(t,e){return!1},trimBlank:function(){return!1},get_width:function(){return this.t.get_width()},get_height:function(){return this.t.get_height()},getData:function(){return null},clone:function(){return null},getMeta:function(){return new G(this,!0,!0)},create:function(){return null},__class__:L};var V=t.coopy.Merger=function(t,e,n,i){this.parent=t,this.local=e,this.remote=n,this.flags=i};V.__name__=!0,V.makeConflictedCell=function(t,e,n,i){return t.toDatum("((( "+t.toString(e)+" ))) "+t.toString(n)+" /// "+t.toString(i))},V.prototype={parent:null,local:null,remote:null,flags:null,order:null,units:null,column_order:null,column_units:null,row_mix_local:null,row_mix_remote:null,column_mix_local:null,column_mix_remote:null,conflicts:null,conflict_infos:null,shuffleDimension:function(t,e,n,i,r){for(var s=0,l=0;l<t.length;){var o=t[l];++l,o.p<0?o.l<0?o.r>=0&&(r.h[o.r]=s,++s):(i.h[o.l]=s,++s):o.l>=0&&o.r>=0&&(i.h[o.l]=s,++s)}l=0;for(var a=e;l<a;){var h=l++,u=i.h[h];null==u?n.push(-1):n.push(u)}return s},shuffleColumns:function(){this.column_mix_local=new wt,this.column_mix_remote=new wt;var t=[],e=this.shuffleDimension(this.column_units,this.local.get_width(),t,this.column_mix_local,this.column_mix_remote);this.local.insertOrDeleteColumns(t,e)},shuffleRows:function(){this.row_mix_local=new wt,this.row_mix_remote=new wt;var t=[],e=this.shuffleDimension(this.units,this.local.get_height(),t,this.row_mix_local,this.row_mix_remote);this.local.insertOrDeleteRows(t,e)},apply:function(){this.conflicts=0,this.conflict_infos=[];var t=R.compareTables3(this.parent,this.local,this.remote).align();this.order=t.toOrder(),this.units=this.order.getList(),this.column_order=t.meta.toOrder(),this.column_units=this.column_order.getList();this.flags.allowInsert(),this.flags.allowDelete(),this.flags.allowUpdate();for(var e=this.parent.getCellView(),n=0,i=this.units;n<i.length;){var r=i[n];if(++n,r.l>=0&&r.r>=0&&r.p>=0)for(var s=0,l=this.column_units;s<l.length;){var o=l[s];if(++s,o.l>=0&&o.r>=0&&o.p>=0){var a=this.parent.getCell(o.p,r.p),h=this.remote.getCell(o.r,r.r);if(!e.equals(a,h)){var u=this.local.getCell(o.l,r.l);e.equals(a,u)?this.local.setCell(o.l,r.l,h):e.equals(h,u)||(this.local.setCell(o.l,r.l,V.makeConflictedCell(e,a,u,h)),this.conflicts++,this.addConflictInfo(r.l,o.l,e,a,u,h))}}}}this.shuffleColumns(),this.shuffleRows();for(var c=this.column_mix_remote.keys();c.hasNext();){var f=c.next(),_=this.column_mix_remote.h[f];for(n=0,i=this.units;n<i.length;){var d=i[n];++n,d.l>=0&&d.r>=0?this.local.setCell(_,this.row_mix_local.h[d.l],this.remote.getCell(f,d.r)):d.p<0&&d.r>=0&&this.local.setCell(_,this.row_mix_remote.h[d.r],this.remote.getCell(f,d.r))}}for(var g=this.row_mix_remote.keys();g.hasNext();){var p=g.next(),m=this.row_mix_remote.h[p];for(n=0,i=this.column_units;n<i.length;){d=i[n];++n,d.l>=0&&d.r>=0&&this.local.setCell(this.column_mix_local.h[d.l],m,this.remote.getCell(d.r,p))}}return this.conflicts},getConflictInfos:function(){return this.conflict_infos},addConflictInfo:function(t,e,n,i,r,s){this.conflict_infos.push(new x(t,e,n.toString(i),n.toString(r),n.toString(s)))},__class__:V};var U=t.coopy.Mover=function(){};U.__name__=!0,U.moveUnits=function(t){for(var e,n=[],i=[],r=-1,s=-1,l={},o={},a=0,h=t.length;a<h;){var u=t[c=a++];u.l>=0&&u.r>=0&&(r<u.l&&(r=u.l),s<u.r&&(s=u.r),l[u.l]=c,o[u.r]=c)}for(a=0,h=r+1;a<h;){null!=(e=l[c=a++])&&n.push(e)}for(a=0,h=s+1;a<h;){var c;null!=(e=o[c=a++])&&i.push(e)}return U.moveWithoutExtras(n,i)},U.move=function(t,e){for(var n=t.length,i=e.length,r={},s={},l=0,o=n;l<o;){r[t[c=l++]]=c}for(l=0,o=i;l<o;){s[e[c=l++]]=c}var a,h=[],u=[];for(l=0,o=n;l<o;){a=t[c=l++],s.hasOwnProperty(a)&&h.push(a)}for(l=0,o=i;l<o;){var c;a=e[c=l++],r.hasOwnProperty(a)&&u.push(a)}return U.moveWithoutExtras(h,u)},U.moveWithoutExtras=function(t,e){if(t.length!=e.length)return null;if(t.length<=1)return[];for(var n=t.length,i={},r=new wt,s={},l={},o=0,a=n;o<a;){i[t[C=o++]]=C}for(var h,u,c=0,f=-2,_=0,d=-1;_<n;)(h=i[u=e[_]])!=f+1?(c=1,s[d=u]=h,l[d]=_):++c,r.h[d]=c,f=h,++_;for(var g=[],p=r.keys();p.hasNext();){var m=p.next();g.push(m)}g.sort((function(t,e){var n=r.h[e]-r.h[t];return 0==n&&(n=t-e),n}));for(var v=[];g.length>0;){d=g.shift();for(var w=g.length,b=s[d],y=l[d],C=w-1;C>=0;){var S=g[C],x=s[S];if(x<b!=l[S]<y){for(o=0,a=c=r.h[S];o<a;){o++;v.push(t[x]),++x}g.splice(C,1)}--C}}return v};var H=t.coopy.Ndjson=function(t){this.tab=t,this.view=t.getCellView(),this.header_row=0};H.__name__=!0,H.prototype={tab:null,view:null,columns:null,header_row:null,renderRow:function(t){for(var e=new bt,n=0,i=this.tab.get_width();n<i;){var r=n++,s=this.view.toString(this.tab.getCell(r,this.header_row));0==r&&1==this.header_row&&(s="@:@");var l=this.tab.getCell(r,t);e.h[s]=l}return Ct.print(e,null,null)},render:function(){var t="",e=0;if(0==this.tab.get_height())return t;if(0==this.tab.get_width())return t;"@:@"==this.tab.getCell(0,0)&&(e=1),this.header_row=e;for(var n=this.header_row+1,i=this.tab.get_height();n<i;){var r=n++;t+=this.renderRow(r),t+="\n"}return t},addRow:function(t,e){var n=new yt(e).doParse();null==this.columns&&(this.columns=new bt);for(var i=this.tab.get_width(),r=this.tab.get_height(),s=!1,l=0,o=a.fields(n);l<o.length;){var h=o[l];++l,Object.prototype.hasOwnProperty.call(this.columns.h,h)||(this.columns.h[h]=i,++i,s=!0)}t>=r&&(r=t+1,s=!0),s&&this.tab.resize(i,r);for(l=0,o=a.fields(n);l<o.length;){h=o[l];++l;var u=a.field(n,h),c=this.columns.h[h];this.tab.setCell(c,t,u)}},addHeaderRow:function(t){for(var e=this.columns.h,n=Object.keys(e),i=n.length,r=0;r<i;){var s=n[r++];this.tab.setCell(this.columns.h[s],t,this.view.toDatum(s))}},parse:function(t){this.columns=null;var e=t.split("\n"),n=e.length;if(0!=n){""==e[n-1]&&--n;for(var i=0,r=n;i<r;){var s=n-i++-1;this.addRow(s+1,e[s])}this.addHeaderRow(0)}else this.tab.clear()},__class__:H};var z=function(){};z.__name__=!0,z.__interfaces__=[g],z.prototype={view:null,needSeparator:function(){return!1},setSeparator:function(t){},setConflictSeparator:function(t){},setView:function(t){this.view=t},update:function(t,e){var n=this.view.makeHash();return this.view.hashSet(n,"before",t),this.view.hashSet(n,"after",e),n},conflict:function(t,e,n){var i=this.view.makeHash();return this.view.hashSet(i,"before",t),this.view.hashSet(i,"ours",e),this.view.hashSet(i,"theirs",n),i},marker:function(t){return this.view.toDatum(t)},negToNull:function(t){return t<0?null:t},links:function(t,e){var n=this.view.makeHash();return t.p>=-1?(this.view.hashSet(n,"before",this.negToNull(t.p)),this.view.hashSet(n,"ours",this.negToNull(t.l)),this.view.hashSet(n,"theirs",this.negToNull(t.r)),n):(this.view.hashSet(n,"before",this.negToNull(t.l)),this.view.hashSet(n,"after",this.negToNull(t.r)),n)},__class__:z};var B=function(){this.order=[],this.ignore_parent=!1};B.__name__=!0,B.prototype={order:null,ignore_parent:null,add:function(t,e,n){null==n&&(n=-2),this.ignore_parent&&(n=-2),this.order.push(new dt(t,e,n))},getList:function(){return this.order},setList:function(t){this.order=t},toString:function(){for(var t="",e=0,n=this.order.length;e<n;){var i=e++;i>0&&(t+=", "),t+=h.string(this.order[i])}return t},ignoreParent:function(){this.ignore_parent=!0},__class__:B};var K=function(){};K.__name__=!0,K.prototype={prevName:null,name:null,val:null,__class__:K};var Q=t.coopy.RowChange=function(){};Q.__name__=!0,Q.prototype={cond:null,val:null,conflicting_val:null,conflicting_parent_val:null,conflicted:null,is_key:null,action:null,showMap:function(t){if(null==t)return"{}";for(var e="",n=t.h,i=Object.keys(n),r=i.length,s=0;s<r;){var l=i[s++];""!=e&&(e+=", ");var o=t.h[l];e+=l+"="+h.string(o)}return"{ "+e+" }"},toString:function(){return this.action+" "+this.showMap(this.cond)+" : "+this.showMap(this.val)},__class__:Q};var W=function(){};W.__name__=!0,W.prototype={fetchColumns:null,fetchRow:null,__class__:W};var G=t.coopy.SimpleMeta=function(t,e,n){null==n&&(n=!1),null==e&&(e=!0),this.t=t,this.rowChange(),this.colChange(),this.has_properties=e,this.may_be_nested=n,this.metadata=null,this.keys=null,this.row_active=!1,this.row_change_cache=null};G.__name__=!0,G.__interfaces__=[E],G.prototype={t:null,name2row:null,name2col:null,has_properties:null,metadata:null,keys:null,row_active:null,row_change_cache:null,may_be_nested:null,storeRowChanges:function(t){this.row_change_cache=t,this.row_active=!0},rowChange:function(){this.name2row=null},colChange:function(){this.name2col=null},col:function(t){if(this.t.get_height()<1)return-1;if(null==this.name2col){this.name2col=new bt;for(var e=0,n=this.t.get_width();e<n;){var i=e++,r=this.name2col,s=this.t.getCell(i,0);r.h[s]=i}}return Object.prototype.hasOwnProperty.call(this.name2col.h,t)?this.name2col.h[t]:-1},row:function(t){if(this.t.get_width()<1)return-1;if(null==this.name2row){this.name2row=new bt;for(var e=1,n=this.t.get_height();e<n;){var i=e++,r=this.name2row,s=this.t.getCell(0,i);r.h[s]=i}}return Object.prototype.hasOwnProperty.call(this.name2row.h,t)?this.name2row.h[t]:-1},alterColumns:function(t){var e=Object.create(null),n=0;this.has_properties&&(e["@"]=n,++n);for(var i=0,r=t.length;i<r;){null!=(c=t[l=i++]).prevName&&(e[c.prevName]=n),null!=c.name&&++n}var s=[];for(i=0,r=this.t.get_width();i<r;){var l=i++,o=-1,a=this.t.getCell(l,0);Object.prototype.hasOwnProperty.call(e,a)&&(o=e[a]),s.push(o)}this.t.insertOrDeleteColumns(s,n);var h=this.has_properties?1:0,u=h;for(i=0,r=t.length;i<r;){null!=(c=t[l=i++]).name&&c.name!=c.prevName&&this.t.setCell(u,0,c.name),null!=c.name&&++u}if(!this.has_properties)return!0;this.colChange(),u=h;for(i=0,r=t.length;i<r;){var c;if(null!=(c=t[l=i++]).name)for(var f=0,_=c.props;f<_.length;){var d=_[f];++f,this.setCell(c.name,d.name,d.val)}null!=c.name&&++u}return!0},setCell:function(t,e,n){var i=this.row(e);if(-1==i)return!1;var r=this.col(t);return-1!=r&&(this.t.setCell(r,i,n),!0)},addMetaData:function(t,e,n){if(null==this.metadata&&(this.metadata=new bt,this.keys=new bt),!Object.prototype.hasOwnProperty.call(this.metadata.h,t)){var i=this.metadata,r=new bt;i.h[t]=r}this.metadata.h[t].h[e]=n,this.keys.h[e]=!0},asTable:function(){if(this.has_properties&&null==this.metadata)return this.t;if(null==this.metadata)return null;for(var t=this.t.get_width(),e=[],n=this.keys.h,i=Object.keys(n),r=i.length,s=0;s<r;){var l=i[s++];e.push(l)}e.sort(a.compare);var o=new Y(t+1,e.length+1);o.setCell(0,0,"@");for(var h=0,u=t;h<u;){var c=h++,f=this.t.getCell(c,0);if(o.setCell(1+c,0,f),Object.prototype.hasOwnProperty.call(this.metadata.h,f))for(var _=this.metadata.h[f],d=0,g=e.length;d<g;){var p=d++;Object.prototype.hasOwnProperty.call(_.h,e[p])&&o.setCell(1+c,p+1,_.h[e[p]])}}for(h=0,u=e.length;h<u;){var m=h++;o.setCell(0,m+1,e[m])}return o},cloneMeta:function(t){var e=new G(t);if(null!=this.metadata){e.keys=new bt;l=this.keys.h;for(var n=(s=Object.keys(l)).length,i=0;i<n;){var r=s[i++];e.keys.h[r]=!0}e.metadata=new bt;var s;for(l=this.metadata.h,n=(s=Object.keys(l)).length,i=0;i<n;){r=s[i++];if(Object.prototype.hasOwnProperty.call(this.metadata.h,r)){for(var l,o=this.metadata.h[r],a=new bt,h=(l=o.h,Object.keys(l)),u=h.length,c=0;c<u;){var f=h[c++];a.h[f]=o.h[f]}e.metadata.h[r]=a}}}return e},useForColumnChanges:function(){return!0},useForRowChanges:function(){return this.row_active},changeRow:function(t){return this.row_change_cache.push(t),!1},applyFlags:function(t){return!1},getRowStream:function(){return new ct(this.t)},isNested:function(){return this.may_be_nested},isSql:function(){return!1},getName:function(){return null},__class__:G};var Y=t.coopy.SimpleTable=function(t,e){this.data=new wt,this.w=t,this.h=e,this.meta=null};Y.__name__=!0,Y.__interfaces__=[v],Y.tableToString=function(t){var e=t.getMeta();if(null!=e){var n=e.getRowStream();if(null!=n){for(var i="",r=n.fetchColumns(),s=0,l=r.length;s<l;){(a=s++)>0&&(i+=","),i+=r[a]}i+="\n";for(var o=n.fetchRow();null!=o;){for(s=0,l=r.length;s<l;){(a=s++)>0&&(i+=","),i+=h.string(o.h[r[a]])}i+="\n",o=n.fetchRow()}return i}}for(i="",s=0,l=t.get_height();s<l;){for(var a=s++,u=0,c=t.get_width();u<c;){var f=u++;f>0&&(i+=","),i+=h.string(t.getCell(f,a))}i+="\n"}return i},Y.tableIsSimilar=function(t,e){if(-1==t.get_height()||-1==e.get_height())return Y.tableToString(t)==Y.tableToString(e);if(t.get_width()!=e.get_width())return!1;if(t.get_height()!=e.get_height())return!1;for(var n=t.getCellView(),i=0,r=t.get_height();i<r;)for(var s=i++,l=0,o=t.get_width();l<o;){var a=l++;if(!n.equals(t.getCell(a,s),e.getCell(a,s)))return!1}return!0},Y.prototype={data:null,w:null,h:null,meta:null,getTable:function(){return this},get_width:function(){return this.w},get_height:function(){return this.h},getCell:function(t,e){return this.data.h[t+e*this.w]},setCell:function(t,e,n){this.data.h[t+e*this.w]=n},toString:function(){return Y.tableToString(this)},getCellView:function(){return new $},isResizable:function(){return!0},resize:function(t,e){return this.w=t,this.h=e,!0},clear:function(){this.data=new wt},insertOrDeleteRows:function(t,e){for(var n=new wt,i=0,r=t.length;i<r;){var s=i++,l=t[s];if(-1!=l)for(var o=0,a=this.w;o<a;){var h=o++,u=s*this.w+h;this.data.h.hasOwnProperty(u)&&(n.h[l*this.w+h]=this.data.h[u])}}return this.h=e,this.data=n,!0},insertOrDeleteColumns:function(t,e){for(var n=new wt,i=0,r=t.length;i<r;){var s=i++,l=t[s];if(-1!=l)for(var o=0,a=this.h;o<a;){var h=o++,u=h*this.w+s;this.data.h.hasOwnProperty(u)&&(n.h[h*e+l]=this.data.h[u])}}return this.w=e,this.data=n,!0},trimBlank:function(){if(0==this.h)return!0;var t=this.h;t>=3&&(t=3);for(var e=this.getCellView(),n=e.toDatum(""),i=!0;i;){for(var r=0,s=this.get_width();r<s;){var l=r++,o=this.getCell(l,this.h-1);if(!e.equals(o,n)&&null!=o){i=!1;break}}i&&this.h--}i=!0;for(var a=this.w;i&&0!=this.w;){for(r=0,s=t;r<s;){l=r++,o=this.getCell(a-1,l);if(!e.equals(o,n)&&null!=o){i=!1;break}}i&&--a}if(a==this.w)return!0;var h=new wt;for(r=0,s=a;r<s;){l=r++;for(var u=0,c=this.h;u<c;){var f=u++,_=f*this.w+l;this.data.h.hasOwnProperty(_)&&(h.h[f*a+l]=this.data.h[_])}}return this.w=a,this.data=h,!0},getData:function(){return null},clone:function(){for(var t=new Y(this.get_width(),this.get_height()),e=0,n=this.get_height();e<n;)for(var i=e++,r=0,s=this.get_width();r<s;){var l=r++;t.setCell(l,i,this.getCell(l,i))}return null!=this.meta&&(t.meta=this.meta.cloneMeta(t)),t},create:function(){return new Y(this.get_width(),this.get_height())},setMeta:function(t){this.meta=t},getMeta:function(){return this.meta},__class__:Y};var J=function(){};J.__name__=!0,J.prototype={toString:null,equals:null,toDatum:null,makeHash:null,hashSet:null,isHash:null,hashExists:null,hashGet:null,isTable:null,getTable:null,wrapTable:null,__class__:J};var $=t.coopy.SimpleView=function(){};$.__name__=!0,$.__interfaces__=[J],$.prototype={toString:function(t){return null==t?"":""+h.string(t)},equals:function(t,e){return null==t&&null==e||null!=t&&null!=e&&""+h.string(t)==""+h.string(e)},toDatum:function(t){return t},makeHash:function(){return new bt},hashSet:function(t,e,n){t.h[e]=n},hashExists:function(t,e){var n=t;return Object.prototype.hasOwnProperty.call(n.h,e)},hashGet:function(t,e){return t.h[e]},isHash:function(t){return t instanceof bt},isTable:function(t){return xt.__implements(t,v)},getTable:function(t){return t},wrapTable:function(t){return t},__class__:$};var X=function(){this.h=this.w=0};X.__name__=!0,X.prototype={h:null,w:null,row:null,zero:null,resize:function(t,e,n){this.row=new wt,this.nonDestructiveResize(t,e,n)},nonDestructiveResize:function(t,e,n){this.w=t,this.h=e,this.zero=n},get:function(t,e){var n=this.row.h[e];if(null==n)return this.zero;var i=n.h[t];return null==i?this.zero:i},set:function(t,e,n){var i=this.row.h[e];null==i&&(i=new wt,this.row.h[e]=i),i.h[t]=n},__class__:X};var Z=t.coopy.SqlColumn=function(){this.name="",this.primary=!1,this.type_value=null,this.type_family=null};Z.__name__=!0,Z.prototype={name:null,primary:null,type_value:null,type_family:null,setName:function(t){this.name=t},setPrimaryKey:function(t){this.primary=t},setType:function(t,e){this.type_value=t,this.type_family=e},getName:function(){return this.name},isPrimaryKey:function(){return this.primary},toString:function(){return(this.primary?"*":"")+this.name},__class__:Z};var tt=t.coopy.SqlCompare=function(t,e,n,i,r,s){this.db=t,this.local=e,this.remote=n,this.alt=i,this.align=r,this.flags=s,null==this.flags&&(this.flags=new C),this.peered=!1,this.alt_peered=!1,null!=e&&null!=n&&null!=this.remote.getDatabase().getNameForAttachment()&&this.remote.getDatabase().getNameForAttachment()!=this.local.getDatabase().getNameForAttachment()&&(e.getDatabase().getHelper().attach(t,"__peer__",this.remote.getDatabase().getNameForAttachment()),this.peered=!0),null!=this.alt&&null!=e&&null!=this.alt.getDatabase().getNameForAttachment()&&this.alt.getDatabase().getNameForAttachment()!=this.local.getDatabase().getNameForAttachment()&&(e.getDatabase().getHelper().attach(t,"__alt__",this.alt.getDatabase().getNameForAttachment()),this.alt_peered=!0)};tt.__name__=!0,tt.prototype={db:null,local:null,remote:null,alt:null,at0:null,at1:null,at2:null,diff_ct:null,align:null,peered:null,alt_peered:null,needed:null,flags:null,equalArray:function(t,e){if(t.length!=e.length)return!1;for(var n=0,i=t.length;n<i;){var r=n++;if(t[r]!=e[r])return!1}return!0},validateSchema:function(){var t=[],e=[],n=!1,i=!1;null!=this.local&&(t=this.local.getColumnNames(),e=this.local.getPrimaryKey(),0==t.length&&(n=!0),null!=this.flags.ids&&(e=this.flags.getIdsByRole("local")),0==e.length&&(i=!0));var r=[],s=[];null!=this.remote&&(r=this.remote.getColumnNames(),s=this.remote.getPrimaryKey(),0==r.length&&(n=!0),null!=this.flags.ids&&(s=this.flags.getIdsByRole("remote")),0==s.length&&(i=!0));var l=r,o=s;if(null!=this.alt&&(l=this.alt.getColumnNames(),o=this.alt.getPrimaryKey(),0==l.length&&(n=!0),null!=this.flags.ids&&(o=this.flags.getIdsByRole("parent")),0==o.length&&(i=!0)),n)throw mt.thrown("Error accessing SQL table");if(i)throw mt.thrown("sql diff not possible when primary key not available");var a=!1;if(null!=this.local&&null!=this.remote&&(this.equalArray(e,s)||(a=!0)),null!=this.local&&null!=this.alt&&(this.equalArray(e,o)||(a=!0)),a)throw mt.thrown("sql diff not possible when primary key changes: "+h.string([e,s,o]));return!0},denull:function(t){return null==t?-1:t},link:function(){this.diff_ct++;var t=this.db.get(0),e=this.denull(this.db.get(1)),n=this.denull(this.db.get(2)),i=this.denull(this.db.get(3));-3==e&&(e=this.at0,this.at0++),-3==n&&(n=this.at1,this.at1++),-3==i&&(i=this.at2,this.at2++);var r=4;if(e>=0){for(var s=0,l=this.local.get_width();s<l;){var o=s++;this.local.setCellCache(o,e,this.db.get(o+r))}r+=this.local.get_width()}if(n>=0){for(s=0,l=this.remote.get_width();s<l;){o=s++;this.remote.setCellCache(o,n,this.db.get(o+r))}r+=this.remote.get_width()}if(i>=0)for(s=0,l=this.alt.get_width();s<l;){o=s++;this.alt.setCellCache(o,i,this.db.get(o+r))}0!=t&&2!=t||(this.align.link(e,n),this.align.addToOrder(e,n)),null!=this.alt&&(1!=t&&2!=t||(this.align.reference.link(e,i),this.align.reference.addToOrder(e,i)))},linkQuery:function(t,e){if(this.db.begin(t,null,e)){for(;this.db.read();)this.link();this.db.end()}},where:function(t){return""==t?" WHERE 1 = 0":" WHERE "+t},scanColumns:function(t,e,n,i,r,s){s.meta=new d;for(var l=0,o=t.length;l<o;){var a=t[h=l++];Object.prototype.hasOwnProperty.call(r.h,a)?s.meta.link(h,r.h[a]):s.meta.link(h,-1)}for(l=0,o=e.length;l<o;){var h;a=e[h=l++];Object.prototype.hasOwnProperty.call(i.h,a)||s.meta.link(-1,h)}s.meta.range(t.length,e.length);for(l=0;l<n.length;){a=n[l];++l;var u=new dt(i.h[a],r.h[a]);s.addIndexColumns(u)}},apply:function(){if(null==this.db)return null;if(null==this.align&&(this.align=new d),!this.validateSchema())return null;var t=this.db.rowid(),e=[],n=[],i=[],r=[],s=[],l=[],o=this.local;if(null!=this.local&&(e=this.local.getPrimaryKey(),n=this.local.getAllButPrimaryKey(),i=this.local.getColumnNames(),r=this.local.getColumnNames(),null!=this.flags.ids)){e=this.flags.getIdsByRole("local"),n=[];for(var a=Object.create(null),h=0;h<e.length;){var u=e[h];++h,a[u]=!0}for(h=0;h<i.length;){u=i[h];++h,Object.prototype.hasOwnProperty.call(a,u)||n.push(u)}}null!=this.remote&&(s=this.remote.getColumnNames(),null==o&&(o=this.remote)),null!=this.alt?(l=this.alt.getColumnNames(),null==o&&(o=this.alt)):l=s;for(var c=[],f=[],_=new bt,g=new bt,p=new bt,m=Object.create(null),v=(h=0,e.length);h<v;){m[e[I=h++]]=I}for(h=0,v=r.length;h<v;){var w=r[I=h++];_.h[w]=I}for(h=0,v=s.length;h<v;){w=s[I=h++];Object.prototype.hasOwnProperty.call(_.h,w)||!0,g.h[w]=I}for(h=0,v=l.length;h<v;){w=l[I=h++];Object.prototype.hasOwnProperty.call(_.h,w)||!0,p.h[w]=I,Object.prototype.hasOwnProperty.call(_.h,w)&&Object.prototype.hasOwnProperty.call(g.h,w)&&(c.push(w),Object.prototype.hasOwnProperty.call(m,w)||f.push(w))}this.align.meta=new d;for(h=0,v=r.length;h<v;){w=r[I=h++];Object.prototype.hasOwnProperty.call(g.h,w)?this.align.meta.link(I,g.h[w]):this.align.meta.link(I,-1)}for(h=0,v=s.length;h<v;){w=s[I=h++];Object.prototype.hasOwnProperty.call(_.h,w)||this.align.meta.link(-1,I)}this.scanColumns(r,s,e,_,g,this.align),this.align.tables(this.local,this.remote),null!=this.alt&&(this.scanColumns(r,l,e,_,p,this.align.reference),this.align.reference.tables(this.local,this.alt));var b="",y="",C="";null!=this.local&&(b=this.local.getQuotedTableName()),null!=this.remote&&(y=this.remote.getQuotedTableName()),null!=this.alt&&(C=this.alt.getQuotedTableName()),this.peered&&(b="main."+b,y="__peer__."+y),this.alt_peered&&(y="__alt__."+C);for(h=0,v=e.length;h<v;){(I=h++)>0&&",",o.getQuotedColumnName(e[I])}for(h=0,v=c.length;h<v;){(I=h++)>0&&",",o.getQuotedColumnName(c[I])}var S="";for(h=0,v=r.length;h<v;){(I=h++)>0&&(S+=","),S+=b+"."+this.local.getQuotedColumnName(r[I])}var x="";for(h=0,v=s.length;h<v;){(I=h++)>0&&(x+=","),x+=y+"."+this.remote.getQuotedColumnName(s[I])}var R="";if(null!=this.alt)for(h=0,v=l.length;h<v;){(I=h++)>0&&(R+=","),R+=C+"."+this.alt.getQuotedColumnName(l[I])}var T="";for(h=0,v=e.length;h<v;){(I=h++)>0&&(T+=" AND "),T+=b+"."+(M=o.getQuotedColumnName(e[I]))+" IS NULL"}var O="";for(h=0,v=e.length;h<v;){(I=h++)>0&&(O+=" AND "),O+=y+"."+(M=o.getQuotedColumnName(e[I]))+" IS NULL"}var k="";for(h=0,v=e.length;h<v;){(I=h++)>0&&(k+=" AND "),k+=b+"."+(M=o.getQuotedColumnName(e[I]))+" IS "+y+"."+M}var N="";if(null!=this.alt)for(h=0,v=e.length;h<v;){(I=h++)>0&&(N+=" AND "),N+=b+"."+(M=o.getQuotedColumnName(e[I]))+" IS "+C+"."+M}var P="";for(h=0,v=f.length;h<v;){(I=h++)>0&&(P+=" OR "),P+=b+"."+(M=o.getQuotedColumnName(f[I]))+" IS NOT "+y+"."+M}for(h=0,v=s.length;h<v;){w=s[I=h++];if(!Object.prototype.hasOwnProperty.call(_.h,w))""!=P&&(P+=" OR "),P+=y+"."+(M=o.getQuotedColumnName(w))+" IS NOT NULL"}if(null!=this.alt){for(h=0,v=f.length;h<v;){var I=h++;P.length>0&&(P+=" OR "),P+=b+"."+(M=o.getQuotedColumnName(f[I]))+" IS NOT "+C+"."+M}for(h=0,v=l.length;h<v;){w=l[I=h++];if(!Object.prototype.hasOwnProperty.call(_.h,w))""!=P&&(P+=" OR "),P+=C+"."+(M=o.getQuotedColumnName(w))+" IS NOT NULL"}}var D="",q=[];for(h=0,v=r.length;h<v;){""!=D&&(D+=",");var A="__coopy_"+(I=h++);D+=b+"."+(M=o.getQuotedColumnName(r[I]))+" AS "+A,q.push(A)}for(h=0,v=s.length;h<v;){""!=D&&(D+=",");A="__coopy_"+(I=h++)+"b";D+=y+"."+(M=o.getQuotedColumnName(s[I]))+" AS "+A,q.push(A)}if(null!=this.alt)for(h=0,v=l.length;h<v;){""!=D&&(D+=",");A="__coopy_"+(I=h++)+"c";D+=C+"."+(M=o.getQuotedColumnName(l[I]))+" AS "+A,q.push(A)}for(h=0,v=e.length;h<v;){var M;(I=h++)>0&&",",M=o.getQuotedColumnName(e[I])}var j="-3",E="-3",F="-3";if(null!=t&&(null!=this.local&&(j=b+"."+t),null!=this.remote&&(E=y+"."+t),null!=this.alt&&(F=C+"."+t)),this.at0=1,this.at1=1,this.at2=1,this.diff_ct=0,null!=this.remote){var L="SELECT DISTINCT 0 AS __coopy_code, NULL, "+E+" AS rowid, NULL, "+x+" FROM "+y;if(null!=this.local&&(L+=" LEFT JOIN "+b,L+=" ON "+k+this.where(T)),b!=y){var V=["__coopy_code","NULL","rowid","NULL"].concat(s);this.linkQuery(L,V)}}if(null!=this.alt){L="SELECT DISTINCT 0 AS __coopy_code, NULL, NULL, "+F+" AS rowid, "+R+" FROM "+C;if(null!=this.local&&(L+=" LEFT JOIN "+b,L+=" ON "+N+this.where(T)),b!=C){V=["__coopy_code","NULL","NULL","rowid"].concat(l);this.linkQuery(L,V)}}if(null!=this.local&&null!=this.remote){var U="SELECT DISTINCT 2 AS __coopy_code, "+j+" AS __coopy_rowid0, "+E+" AS __coopy_rowid1, ";null!=this.alt?U+=F+" AS __coopy_rowid2,":U+=" NULL,",U+=D+" FROM "+b,b!=y&&(U+=" INNER JOIN "+y+" ON "+k),null!=this.alt&&b!=C&&(U+=" INNER JOIN "+C+" ON "+N),U+=this.where(P);var H=["__coopy_code","__coopy_rowid0","__coopy_rowid1","__coopy_rowid2"].concat(q);this.linkQuery(U,H)}if(null==this.alt&&null!=this.local){var z="SELECT DISTINCT 0 AS __coopy_code, "+j+" AS rowid, NULL, NULL, "+S+" FROM "+b;if(null!=this.remote&&(z+=" LEFT JOIN "+y,z+=" ON "+k+this.where(O)),b!=y){var B=["__coopy_code","rowid","NULL","NULL"].concat(r);this.linkQuery(z,B)}}if(null!=this.alt){z="SELECT 2 AS __coopy_code, "+j+" AS __coopy_rowid0, "+E+" AS __coopy_rowid1, ";z+=F+" AS __coopy_rowid2, ",z+=D,z+=" FROM "+b,null!=this.remote&&(z+=" LEFT OUTER JOIN "+y+" ON "+k),z+=" LEFT OUTER JOIN "+C+" ON "+N,z+=" WHERE __coopy_rowid1 IS NULL OR __coopy_rowid2 IS NULL";B=["__coopy_code","__coopy_rowid0","__coopy_rowid1","__coopy_rowid2"].concat(q);this.linkQuery(z,B)}return 0==this.diff_ct&&this.align.markIdentical(),this.align},__class__:tt};var et=function(){};et.__name__=!0,et.prototype={getColumns:null,getQuotedTableName:null,getQuotedColumnName:null,begin:null,beginRow:null,read:null,get:null,end:null,width:null,rowid:null,getHelper:null,getNameForAttachment:null,__class__:et};var nt=function(){};nt.__name__=!0,nt.prototype={getTableNames:null,countRows:null,getRowIDs:null,insert:null,delete:null,update:null,attach:null,alterColumns:null,__class__:nt};var it=t.coopy.SqlTable=function(t,e,n){this.db=t,this.name=e,this.helper=n,null==n&&(this.helper=t.getHelper()),this.cache=new wt,this.h=-1,this.id2rid=null,this.getColumns()};it.__name__=!0,it.__interfaces__=[W,E,v],it.prototype={db:null,columns:null,name:null,quotedTableName:null,cache:null,columnNames:null,h:null,helper:null,id2rid:null,getColumns:function(){if(null==this.columns&&null!=this.db){this.columns=this.db.getColumns(this.name),this.columnNames=[];for(var t=0,e=this.columns;t<e.length;){var n=e[t];++t,this.columnNames.push(n.getName())}}},getPrimaryKey:function(){this.getColumns();for(var t=[],e=0,n=this.columns;e<n.length;){var i=n[e];++e,i.isPrimaryKey()&&t.push(i.getName())}return t},getAllButPrimaryKey:function(){this.getColumns();for(var t=[],e=0,n=this.columns;e<n.length;){var i=n[e];++e,i.isPrimaryKey()||t.push(i.getName())}return t},getColumnNames:function(){return this.getColumns(),this.columnNames},getQuotedTableName:function(){return null!=this.quotedTableName||(this.quotedTableName=this.db.getQuotedTableName(this.name)),this.quotedTableName},getQuotedColumnName:function(t){return this.db.getQuotedColumnName(t)},getCell:function(t,e){if(this.h>=0?--e>=0&&(e=this.id2rid[e]):0==e&&(e=-1),e<0)return this.getColumns(),this.columns[t].name;var n=this.cache.h[e];if(null==n){for(n=new wt,this.getColumns(),this.db.beginRow(this.name,e,this.columnNames);this.db.read();)for(var i=0,r=this.get_width();i<r;){var s=i++,l=this.db.get(s);n.h[s]=l}this.db.end(),this.cache.h[e]=n}return this.cache.h[e].h[t]},setCellCache:function(t,e,n){var i=this.cache.h[e];null==i&&(i=new wt,this.getColumns(),this.cache.h[e]=i);var r=n;i.h[t]=r},setCell:function(t,e,n){console.log("coopy/SqlTable.hx:115:","SqlTable cannot set cells yet")},getCellView:function(){return new $},isResizable:function(){return!1},resize:function(t,e){return!1},clear:function(){},insertOrDeleteRows:function(t,e){return!1},insertOrDeleteColumns:function(t,e){return!1},trimBlank:function(){return!1},get_width:function(){return this.getColumns(),this.columns.length},get_height:function(){return this.h>=0?this.h:-1},getData:function(){return null},clone:function(){return null},create:function(){return null},getMeta:function(){return this},alterColumns:function(t){var e=this.helper.alterColumns(this.db,this.name,t);return this.columns=null,e},changeRow:function(t){return null==this.helper?(console.log("coopy/SqlTable.hx:183:","No sql helper"),!1):"+++"==t.action?this.helper.insert(this.db,this.name,t.val):"---"==t.action?this.helper.delete(this.db,this.name,t.cond):"->"==t.action&&this.helper.update(this.db,this.name,t.cond,t.val)},asTable:function(){this.getColumns();var t=this.columnNames.length,e=new Y(t+1,3);e.setCell(0,0,"@"),e.setCell(0,1,"type"),e.setCell(0,2,"key");for(var n=0,i=t;n<i;){var r=n++,s=r+1;e.setCell(s,0,this.columnNames[r]),e.setCell(s,1,this.columns[r].type_value),e.setCell(s,2,this.columns[r].primary?"primary":"")}return e},useForColumnChanges:function(){return!0},useForRowChanges:function(){return!0},cloneMeta:function(t){return null},applyFlags:function(t){return!1},getDatabase:function(){return this.db},getRowStream:function(){return this.getColumns(),this.db.begin("SELECT * FROM "+this.getQuotedTableName()+" ORDER BY ?",[this.db.rowid()],this.columnNames),this},isNested:function(){return!1},isSql:function(){return!0},fetchRow:function(){if(this.db.read()){for(var t=new bt,e=0,n=this.columnNames.length;e<n;){var i=e++,r=this.columnNames[i],s=this.db.get(i);t.h[r]=s}return t}return this.db.end(),null},fetchColumns:function(){return this.getColumns(),this.columnNames},getName:function(){return this.name.toString()},__class__:it};var rt=t.coopy.SqlTableName=function(t,e){null==e&&(e=""),null==t&&(t=""),this.name=t,this.prefix=e};rt.__name__=!0,rt.prototype={name:null,prefix:null,toString:function(){return""==this.prefix?this.name:this.prefix+"."+this.name},__class__:rt};var st=t.coopy.SqlTables=function(t,e,n){this.db=t;var i=this.db.getHelper().getTableNames(t),r=null,s=i.length;if(null!=e.tables){r=new bt;for(var l=0,o=e.tables;l<o.length;){var a=o[l];++l;var h=e.getNameByRole(a,n),u=e.getCanonicalName(a);r.h[h]=u}s=0;for(l=0;l<i.length;){a=i[l];++l,Object.prototype.hasOwnProperty.call(r.h,a)&&++s}}this.t=new Y(2,s+1),this.t.setCell(0,0,"name"),this.t.setCell(1,0,"table");var c=this.t.getCellView(),f=1;for(l=0;l<i.length;){a=i[l];++l;var _=a;if(null!=r){if(!Object.prototype.hasOwnProperty.call(r.h,a))continue;_=r.h[a]}this.t.setCell(0,f,_),this.t.setCell(1,f,c.wrapTable(new it(t,new rt(a)))),++f}};st.__name__=!0,st.__interfaces__=[v],st.prototype={db:null,t:null,flags:null,getCell:function(t,e){return this.t.getCell(t,e)},setCell:function(t,e,n){},getCellView:function(){return this.t.getCellView()},isResizable:function(){return!1},resize:function(t,e){return!1},clear:function(){},insertOrDeleteRows:function(t,e){return!1},insertOrDeleteColumns:function(t,e){return!1},trimBlank:function(){return!1},get_width:function(){return this.t.get_width()},get_height:function(){return this.t.get_height()},getData:function(){return null},clone:function(){return null},create:function(){return null},getMeta:function(){return new G(this,!0,!0)},__class__:st};var lt=t.coopy.SqliteHelper=function(){};lt.__name__=!0,lt.__interfaces__=[nt],lt.prototype={getTableNames:function(t){if(!t.begin("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name",null,["name"]))return null;for(var e=[];t.read();)e.push(t.get(0));return t.end(),e},countRows:function(t,e){var n="SELECT COUNT(*) AS ct FROM "+t.getQuotedTableName(e);if(!t.begin(n,null,["ct"]))return-1;for(var i=-1;t.read();)i=t.get(0);return t.end(),i},getRowIDs:function(t,e){var n=[],i="SELECT ROWID AS r FROM "+t.getQuotedTableName(e)+" ORDER BY ROWID";if(!t.begin(i,null,["r"]))return null;for(;t.read();){var r=t.get(0);n.push(r)}return t.end(),n},update:function(t,e,n,i){for(var r="UPDATE "+t.getQuotedTableName(e)+" SET ",s=[],l=(u=i.h,(c=Object.keys(u)).length),o=0;o<l;){var a=c[o++];s.length>0&&(r+=", "),r+=t.getQuotedColumnName(a),r+=" = ?",s.push(i.h[a])}var h=s.length;r+=" WHERE ";var u,c;for(u=n.h,l=(c=Object.keys(u)).length,o=0;o<l;){a=c[o++];s.length>h&&(r+=" and "),r+=t.getQuotedColumnName(a),r+=" IS ?",s.push(n.h[a])}return t.begin(r,s,[])?(t.end(),!0):(console.log("coopy/SqliteHelper.hx:71:","Problem with database update"),!1)},delete:function(t,e,n){for(var i="DELETE FROM "+t.getQuotedTableName(e)+" WHERE ",r=[],s=n.h,l=Object.keys(s),o=l.length,a=0;a<o;){var h=l[a++];r.length>0&&(i+=" and "),i+=t.getQuotedColumnName(h),i+=" = ?",r.push(n.h[h])}return t.begin(i,r,[])?(t.end(),!0):(console.log("coopy/SqliteHelper.hx:90:","Problem with database delete"),!1)},insert:function(t,e,n){for(var i="INSERT INTO "+t.getQuotedTableName(e)+" (",r=[],s=(a=n.h,(h=Object.keys(a)).length),l=0;l<s;){var o=h[l++];r.length>0&&(i+=","),i+=t.getQuotedColumnName(o),r.push(n.h[o])}i+=") VALUES(";var a,h,u=!1;for(a=n.h,s=(h=Object.keys(a)).length,l=0;l<s;){o=h[l++];u&&(i+=","),i+="?",u=!0}return i+=")",t.begin(i,r,[])?(t.end(),!0):(console.log("coopy/SqliteHelper.hx:118:","Problem with database insert"),!1)},attach:function(t,e,n){var i=!1,r=!1;if(!t.begin("PRAGMA database_list",null,["seq","name","file"]))return!1;for(;t.read();){if(t.get(1)==e)i=!0,t.get(2)==n&&(r=!0)}if(t.end(),i){if(r)return!0;if(!t.begin("DETACH `"+e+"`",null,[]))return console.log("coopy/SqliteHelper.hx:147:","Failed to detach "+e),!1;t.end()}return t.begin("ATTACH ? AS `"+e+"`",[n],[])?(t.end(),!0):(console.log("coopy/SqliteHelper.hx:154:","Failed to attach "+n+" as "+e),!1)},columnListSql:function(t){return t.join(",")},fetchSchema:function(t,e){var n=t.getQuotedTableName(e),i="select sql from sqlite_master where name = "+n;if(!t.begin(i,null,["sql"]))return console.log("coopy/SqliteHelper.hx:169:","Cannot find schema for table "+n),null;var r="";return t.read()&&(r=t.get(0)),t.end(),r},splitSchema:function(t,e,n){for(var i="",r=[],s=!1,o=!1,a="",h=0,u=0,c=n.length;u<c;){var f=u++,_=n.charAt(f);if(s||o)s&&'"'==_&&(s=!1),o&&"'"==_&&(o=!1),a+=_;else{var d=!1;if("("==_?1==++h&&(d=!0):")"==_&&0==--h&&(d=!0),","==_){d=!0}d?(" "==a.charAt(0)&&(a=l.substr(a,1,a.length)),""==i?i=a:r.push(a),a=""):a+=_}}var g=t.getColumns(e),p=new bt,m=new bt;for(u=0,c=g.length;u<c;){var v=g[f=u++];p.h[v.name]=r[f],m.h[v.name]=g[f]}return{preamble:i,parts:r,name2part:p,columns:g,name2column:m}},exec:function(t,e){return t.begin(e)?(t.end(),!0):(console.log("coopy/SqliteHelper.hx:250:","database problem"),!1)},alterColumns:function(t,e,n){for(var i,r=this.fetchSchema(t,e),s=this.splitSchema(t,e,r),l=(s.parts,[]),o=[],a=[],u=[],c=(s.columns,0),f=n.length;c<f;){var _=n[c++];if(null!=_.name){null!=_.prevName&&(u.push(_.prevName),a.push(_.name));var d="",g=!1;if(Object.prototype.hasOwnProperty.call(s.name2column.h,_.name)){var p=s.name2column.h[_.name];d=p.type_value,g=p.primary}var m=d,v=g;if(null!=_.props)for(var w=0,b=_.props;w<b.length;){var y=b[w];++w,"type"==y.name&&(m=y.val),"key"==y.name&&(v=""+h.string(y.val)=="primary")}var C=""+_.name;null!=(i=m)&&""!=i&&"null"!=i&&(C+=" "+m),v&&(C+=" PRIMARY KEY"),l.push(C),o.push(_.name)}}if(!this.exec(t,"BEGIN TRANSACTION"))return!1;var S=this.columnListSql(a),x=t.getQuotedTableName(e);return!!this.exec(t,"CREATE TEMPORARY TABLE __coopy_backup("+S+")")&&(!!this.exec(t,"INSERT INTO __coopy_backup ("+S+") SELECT "+S+" FROM "+x)&&(!!this.exec(t,"DROP TABLE "+x)&&(!!this.exec(t,s.preamble+"("+l.join(", ")+")")&&(!!this.exec(t,"INSERT INTO "+x+" ("+S+") SELECT "+S+" FROM __coopy_backup")&&(!!this.exec(t,"DROP TABLE __coopy_backup")&&!!this.exec(t,"COMMIT"))))))},__class__:lt};var ot=t.coopy.TableComparisonState=function(){this.reset()};ot.__name__=!0,ot.prototype={p:null,a:null,b:null,completed:null,run_to_completion:null,is_equal:null,is_equal_known:null,has_same_columns:null,has_same_columns_known:null,compare_flags:null,p_meta:null,a_meta:null,b_meta:null,alignment:null,children:null,child_order:null,reset:function(){this.completed=!1,this.run_to_completion=!0,this.is_equal_known=!1,this.is_equal=!1,this.has_same_columns=!1,this.has_same_columns_known=!1,this.compare_flags=null,this.alignment=null,this.children=null,this.child_order=null},getMeta:function(){null!=this.p&&null==this.p_meta&&(this.p_meta=this.p.getMeta()),null!=this.a&&null==this.a_meta&&(this.a_meta=this.a.getMeta()),null!=this.b&&null==this.b_meta&&(this.b_meta=this.b.getMeta())},__class__:ot};var at=t.coopy.TableDiff=function(t,e){this.align=t,this.flags=e,this.builder=null,this.preserve_columns=!1};at.__name__=!0,at.prototype={align:null,flags:null,builder:null,row_map:null,col_map:null,has_parent:null,a:null,b:null,p:null,rp_header:null,ra_header:null,rb_header:null,is_index_p:null,is_index_a:null,is_index_b:null,order:null,row_units:null,column_units:null,show_rc_numbers:null,row_moves:null,col_moves:null,active_row:null,active_column:null,allow_insert:null,allow_delete:null,allow_update:null,allow_column:null,v:null,sep:null,conflict_sep:null,schema:null,have_schema:null,top_line_done:null,have_addition:null,act:null,publish:null,diff_found:null,schema_diff_found:null,preserve_columns:null,row_deletes:null,row_inserts:null,row_updates:null,row_reorders:null,col_deletes:null,col_inserts:null,col_updates:null,col_renames:null,col_reorders:null,column_units_updated:null,nested:null,nesting_present:null,setCellBuilder:function(t){this.builder=t},getSeparator:function(t,e,n){for(var i=n,r=t.get_width(),s=t.get_height(),l=t.getCellView(),o=0,a=s;o<a;)for(var h=o++,u=0,c=r;u<c;){var f=u++;if(null!=(_=l.toString(t.getCell(f,h))))for(;_.indexOf(i)>=0;)i="-"+i}if(null!=e){r=e.get_width();for(o=0,a=s=e.get_height();o<a;)for(h=o++,u=0,c=r;u<c;){var _;f=u++;if(null!=(_=l.toString(e.getCell(f,h))))for(;_.indexOf(i)>=0;)i="-"+i}}return i},isReordered:function(t,e){for(var n=!1,i=-1,r=-1,s=0,l=e;s<l;){var o=s++,a=t.h[o];if(null!=a){if(a.l>=0){if(a.l<i){n=!0;break}i=a.l}if(a.r>=0){if(a.r<r){n=!0;break}r=a.r}}}return n},spreadContext:function(t,e,n){if(e>0&&null!=n){for(var i=-e-1,r=0,s=0,l=t.length;s<l;){-3!=n[o=s++]?0==n[o]||3==n[o]?o-i<=e+r?n[o]=2:o-i==e+1+r&&(n[o]=3):1==n[o]&&(i=o,r=0):++r}i=t.length+e+1,r=0;for(s=0,l=t.length;s<l;){var o,a=s++;-3!=n[o=t.length-1-a]?0==n[o]||3==n[o]?i-o<=e+r?n[o]=2:i-o==e+1+r&&(n[o]=3):1==n[o]&&(i=o,r=0):++r}}},setIgnore:function(t,e,n,i){var r=n.getCellView();if(n.get_height()>=i)for(var s=0,l=n.get_width();s<l;){var o=s++,a=r.toString(n.getCell(o,i));Object.prototype.hasOwnProperty.call(t.h,a)&&(e.h[o]=!0)}},countActive:function(t){for(var e=0,n=!1,i=0,r=t.length;i<r;){var s=i++,l=t[s]>0,o=3==t[s];o&&n||l&&(n=o,++e)}return e},reset:function(){this.has_parent=!1,this.rp_header=this.ra_header=this.rb_header=0,this.is_index_p=new wt,this.is_index_a=new wt,this.is_index_b=new wt,this.row_map=new wt,this.col_map=new wt,this.show_rc_numbers=!1,this.row_moves=null,this.col_moves=null,this.allow_insert=this.allow_delete=this.allow_update=this.allow_column=!0,this.sep="",this.conflict_sep="",this.top_line_done=!1,this.diff_found=!1,this.schema_diff_found=!1,this.row_deletes=0,this.row_inserts=0,this.row_updates=0,this.row_reorders=0,this.col_deletes=0,this.col_inserts=0,this.col_updates=0,this.col_renames=0,this.col_reorders=0,this.column_units_updated=new wt},setupTables:function(){if(this.order=this.align.toOrder(),this.row_units=this.order.getList(),this.has_parent=null!=this.align.reference,this.has_parent){if(this.p=this.align.getSource(),this.a=this.align.reference.getTarget(),this.b=this.align.getTarget(),this.rp_header=this.align.reference.meta.getSourceHeader(),this.ra_header=this.align.reference.meta.getTargetHeader(),this.rb_header=this.align.meta.getTargetHeader(),null!=this.align.getIndexColumns())for(var t=0,e=this.align.getIndexColumns();t<e.length;){var n=e[t];++t,n.l>=0&&(this.is_index_p.h[n.l]=!0),n.r>=0&&(this.is_index_b.h[n.r]=!0)}if(null!=this.align.reference.getIndexColumns())for(t=0,e=this.align.reference.getIndexColumns();t<e.length;){var i=e[t];++t,i.l>=0&&(this.is_index_p.h[i.l]=!0),i.r>=0&&(this.is_index_a.h[i.r]=!0)}}else if(this.a=this.align.getSource(),this.b=this.align.getTarget(),this.p=this.a,this.ra_header=this.align.meta.getSourceHeader(),this.rp_header=this.ra_header,this.rb_header=this.align.meta.getTargetHeader(),null!=this.align.getIndexColumns())for(t=0,e=this.align.getIndexColumns();t<e.length;){var r=e[t];++t,r.l>=0&&(this.is_index_a.h[r.l]=!0),r.r>=0&&(this.is_index_b.h[r.r]=!0)}this.allow_insert=this.flags.allowInsert(),this.allow_delete=this.flags.allowDelete(),this.allow_update=this.flags.allowUpdate(),this.allow_column=this.flags.allowColumn();var s=this.a;null==s&&(s=this.b),null==s&&(s=this.p),this.v=s.getCellView(),this.builder.setView(this.v),this.nested=!1;var l=s.getMeta();null!=l&&(this.nested=l.isNested()),this.nesting_present=!1},scanActivity:function(){if(this.active_row=[],this.active_column=null,!this.flags.show_unchanged)for(var t=0,e=this.row_units.length;t<e;){var n=t++;this.active_row[this.row_units.length-1-n]=0}if(!this.flags.show_unchanged_columns){this.active_column=[];for(t=0,e=this.column_units.length;t<e;){n=t++;var i=0,r=this.column_units[n];r.l>=0&&this.is_index_a.h[r.l]&&(i=1),r.r>=0&&this.is_index_b.h[r.r]&&(i=1),r.p>=0&&this.is_index_p.h[r.p]&&(i=1),this.active_column[n]=i}}},setupColumns:function(){var t=this.align.meta.toOrder();this.column_units=t.getList();var e=this.flags.getIgnoredColumns();if(null!=e){var n=new wt,i=new wt,r=new wt;this.setIgnore(e,n,this.p,this.rp_header),this.setIgnore(e,i,this.a,this.ra_header),this.setIgnore(e,r,this.b,this.rb_header);for(var s=[],l=0,o=this.column_units.length;l<o;){var a=l++,h=this.column_units[a];n.h.hasOwnProperty(h.p)||i.h.hasOwnProperty(h.l)||r.h.hasOwnProperty(h.r)||s.push(h)}this.column_units=s}},setupMoves:function(){if(this.flags.ordered){this.row_moves=new wt;for(var t=U.moveUnits(this.row_units),e=0,n=t.length;e<n;){var i=e++;this.row_moves.h[t[i]]=i}this.col_moves=new wt;for(e=0,n=(t=U.moveUnits(this.column_units)).length;e<n;){i=e++;this.col_moves.h[t[i]]=i}}},scanSchema:function(){this.schema=[],this.have_schema=!1;for(var t=0,e=this.column_units.length;t<e;){var n=t++,i=this.column_units[n],r=!1;this.flags.ordered&&(this.col_moves.h.hasOwnProperty(n)&&(r=!0),r&&(this.show_rc_numbers=!0));var s="";if(i.r>=0&&-1==i.lp()&&(this.have_schema=!0,s="+++",null!=this.active_column&&this.allow_column&&(this.active_column[n]=1),this.allow_column&&this.col_inserts++),i.r<0&&i.lp()>=0&&(this.have_schema=!0,s="---",null!=this.active_column&&this.allow_column&&(this.active_column[n]=1),this.allow_column&&this.col_deletes++),i.r>=0&&i.lp()>=0&&this.p.get_height()>=this.rp_header&&this.b.get_height()>=this.rb_header){var l=this.p.getCell(i.lp(),this.rp_header),o=this.b.getCell(i.r,this.rb_header);this.isEqual(this.v,l,o)||(this.have_schema=!0,s="(",s+=this.v.toString(l),s+=")",null!=this.active_column&&(this.active_column[n]=1,this.col_renames++))}r&&(s=":"+s,this.have_schema=!0,null!=this.active_column&&(this.active_column=null),this.col_reorders++),this.schema.push(s)}},checkRcNumbers:function(t,e){this.show_rc_numbers||(this.flags.always_show_order?this.show_rc_numbers=!0:this.flags.ordered&&(this.show_rc_numbers=this.isReordered(this.row_map,e),this.show_rc_numbers||(this.show_rc_numbers=this.isReordered(this.col_map,t))))},addRcNumbers:function(t){var e=1;if(this.show_rc_numbers&&!this.flags.never_show_order){++e;for(var n=[],i=0,r=t.get_width();i<r;){var s=i++;n.push(s+1)}t.insertOrDeleteColumns(n,t.get_width()+1);for(i=0,r=t.get_height();i<r;){s=i++;null!=(l=this.row_map.h[s])?t.setCell(0,s,this.builder.links(l,!0)):t.setCell(0,s,"")}n=[];for(i=0,r=t.get_height();i<r;){s=i++;n.push(s+1)}t.insertOrDeleteRows(n,t.get_height()+1);for(i=1,r=t.get_width();i<r;){var l;s=i++;null!=(l=this.col_map.h[s-1])?t.setCell(s,0,this.builder.links(l,!1)):t.setCell(s,0,"")}t.setCell(0,0,this.builder.marker("@:@"))}return e},elideColumns:function(t,e){if(null!=this.active_column){for(var n=!0,i=0,r=this.active_column.length;i<r;){var s=i++;if(0==this.active_column[s]){n=!1;break}}if(!n){var l=[];for(i=0,r=e;i<r;){s=i++;l.push(s)}var o=e,a=0,h=[];for(i=0,r=this.active_column.length;i<r;){s=i++;var u=0==this.active_column[s];u?++a:a=0,u&&a>1?l.push(-1):(u&&h.push(o),l.push(o),++o)}t.insertOrDeleteColumns(l,o);for(i=0;i<h.length;){var c=h[i];++i;r=0;for(var f=t.get_height();r<f;){var _=r++;t.setCell(c,_,this.builder.marker("..."))}}}}},addSchema:function(t){if(this.have_schema){var e=t.get_height();t.resize(this.column_units.length+1,e+1),t.setCell(0,e,this.builder.marker("!"));for(var n=0,i=this.column_units.length;n<i;){var r=n++;t.setCell(r+1,e,this.v.toDatum(this.schema[r]))}this.schema_diff_found=!0}},addHeader:function(t){if(this.flags.always_show_header){var e=t.get_height();t.resize(this.column_units.length+1,e+1),t.setCell(0,e,this.builder.marker("@@"));for(var n=0,i=this.column_units.length;n<i;){var r=n++,s=this.column_units[r];s.r>=0?0!=this.b.get_height()&&t.setCell(r+1,e,this.b.getCell(s.r,this.rb_header)):s.l>=0?0!=this.a.get_height()&&t.setCell(r+1,e,this.a.getCell(s.l,this.ra_header)):s.lp()>=0&&0!=this.p.get_height()&&t.setCell(r+1,e,this.p.getCell(s.lp(),this.rp_header)),this.col_map.h[r+1]=s}this.top_line_done=!0}},checkMeta:function(t,e){return null!=e&&(null==t?1==e.get_width()&&1==e.get_height():e.get_width()==t.get_width()+1&&(0!=e.get_width()&&0!=e.get_height()))},getMetaTable:function(t){if(null==t){var e=new Y(1,1);return e.setCell(0,0,"@"),e}var n=t.getMeta();return null==n?null:n.asTable()},addMeta:function(t){if(null==this.a&&null==this.b&&null==this.p)return!1;if(!this.flags.show_meta)return!1;var e=this.getMetaTable(this.a),n=this.getMetaTable(this.b),i=this.getMetaTable(this.p);if(!this.checkMeta(this.a,e))return!1;if(!this.checkMeta(this.b,n))return!1;if(!this.checkMeta(this.p,i))return!1;var r=new Y(0,0),s=new C;s.addPrimaryKey("@@"),s.addPrimaryKey("@"),s.unchanged_column_context=65536,s.unchanged_context=0;var l=R.compareTables3(e==i?null:i,e,n,s).align(),o=new at(l,s);if(o.preserve_columns=!0,o.hilite(r),o.hasDifference()||o.hasSchemaDifference()){var a=t.get_height(),h=r.get_height(),u=o.hasSchemaDifference()?2:1;t.resize(t.get_width(),a+h-u);for(var c=r.getCellView(),f=u,_=h;f<_;)for(var d=f++,g=1,p=r.get_width();g<p;){var m=g++,v=r.getCell(m,d);1==m&&(v="@"+c.toString(v)+"@"+c.toString(r.getCell(0,d))),t.setCell(m-1,a+d-u,v)}if(null!=this.active_column&&o.active_column.length==r.get_width())for(f=1,_=r.get_width();f<_;){var w=f++;o.active_column[w]>=0&&(this.active_column[w-1]=1)}}return!1},refineActivity:function(){if(this.spreadContext(this.row_units,this.flags.unchanged_context,this.active_row),this.spreadContext(this.column_units,this.flags.unchanged_column_context,this.active_column),null!=this.active_column)for(var t=0,e=this.column_units.length;t<e;){var n=t++;3==this.active_column[n]&&(this.active_column[n]=0)}},normalizeString:function(t,e){if(null==e)return e;if(!this.flags.ignore_whitespace&&!this.flags.ignore_case)return e;var n=t.toString(e);return this.flags.ignore_whitespace&&(n=c.trim(n)),this.flags.ignore_case&&(n=n.toLowerCase()),n},isEqual:function(t,e,n){if(this.flags.ignore_epsilon>0){var i=parseFloat(e);if(!isNaN(i)){var r=parseFloat(n);if(!isNaN(r)&&Math.abs(i-r)<this.flags.ignore_epsilon)return!0}}return this.flags.ignore_whitespace||this.flags.ignore_case?this.normalizeString(t,e)==this.normalizeString(t,n):t.equals(e,n)},checkNesting:function(t,e,n,i,r,s,l,o,a){var h=!0;if(e&&(h=h&&t.isTable(n)),i&&(h=h&&t.isTable(r)),s&&(h=h&&t.isTable(l)),!h)return[n,r,l];var u=null,c=null,f=null;e&&(u=t.getTable(n)),i&&(c=t.getTable(r)),s&&(f=t.getTable(l));var _=!1,d=new ot;d.a=u,d.b=c,d.p=f,d.compare_flags=this.flags,d.getMeta();var g=null;(null!=d.a_meta&&(g=d.a_meta.getName()),null==g&&null!=d.b_meta&&(g=d.b_meta.getName()),null==g&&(g=o+"_"+a),null!=this.align.comp&&(null==this.align.comp.children?(this.align.comp.children=new bt,this.align.comp.child_order=[],_=!0):_=!Object.prototype.hasOwnProperty.call(this.align.comp.children.h,g)),_)?(this.nesting_present=!0,this.align.comp.children.h[g]=d,this.align.comp.child_order.push(g),new S(d).align()):d=this.align.comp.children.h[g];var p=null,m=null,v=null;return d.alignment.isMarkedAsIdentical()||e&&!i||i&&!e?(m=p="["+g+"]",v=p):(null!=n&&(p="[a."+g+"]"),null!=r&&(m="[b."+g+"]"),null!=l&&(v="[p."+g+"]")),[p,m,v]},scanRow:function(t,e,n,i,r){for(var s=!1,l=0,o=this.column_units.length;l<o;){var a=l++,h=this.column_units[a],u=null,c=null,f=null,_=null,d=null,g=!1,p=null,m=!1,v=!1,w=!1,b=!1;if(h.p>=0&&t.p>=0&&(u=this.p.getCell(h.p,t.p),v=!0),h.l>=0&&t.l>=0&&(c=this.a.getCell(h.l,t.l),w=!0),h.r>=0&&t.r>=0&&(f=this.b.getCell(h.r,t.r),b=!0,(v?h.p:h.l)<0&&null!=f&&""!=this.v.toString(f)&&this.allow_column&&(this.have_addition=!0)),this.nested){var y=this.checkNesting(this.v,w,c,b,f,v,u,i,a);c=y[0],f=y[1],u=y[2]}v?b?this.isEqual(this.v,u,f)?_=c:(_=u,d=f,g=!0,this.isEqual(this.v,u,c)||this.isEqual(this.v,u,f)||(p=c,m=!0)):_=u:w?b?this.isEqual(this.v,c,f)?_=c:(_=c,d=f,g=!0):_=c:_=f;var C=_;if(g&&(null!=_&&this.allow_update||this.allow_column)){s||(0==r&&this.row_updates++,s=!0),null!=this.active_column&&(this.active_column[a]=1),""==this.sep&&(this.builder.needSeparator()?(this.sep=this.getSeparator(this.a,this.b,"->"),this.builder.setSeparator(this.sep)):this.sep="->");var S=!1;m&&(this.isEqual(this.v,d,p)||(S=!0)),S?(""==this.conflict_sep&&(this.builder.needSeparator()?(this.conflict_sep=this.getSeparator(this.p,this.a,"!")+this.sep,this.builder.setConflictSeparator(this.conflict_sep)):this.conflict_sep="!->"),C=this.builder.conflict(_,p,d),this.act=this.conflict_sep):(C=this.builder.update(_,d),this.sep.length>this.act.length&&(this.act=this.sep)),this.column_units_updated.h.hasOwnProperty(a)||(this.column_units_updated.h[a]=!0,this.col_updates++)}""==this.act&&this.have_addition&&(this.act="+"),"+++"==this.act&&b&&null!=this.active_column&&(this.active_column[a]=1),this.publish&&(null==this.active_column||this.active_column[a]>0)&&e.setCell(a+1,n,C)}this.publish&&(e.setCell(0,n,this.builder.marker(this.act)),this.row_map.h[n]=t),""!=this.act&&(this.diff_found=!0,this.publish||null!=this.active_row&&(this.active_row[i]=1))},hilite:function(t){return t=R.tablify(t),this.hiliteSingle(t)},hiliteSingle:function(t){if(!t.isResizable())return!1;null==this.builder&&(this.flags.allow_nested_cells?this.builder=new z:this.builder=new P(this.flags)),t.resize(0,0),t.clear(),this.reset(),this.setupTables(),this.setupColumns(),this.setupMoves(),this.scanActivity(),this.scanSchema(),this.addSchema(t),this.addHeader(t),this.addMeta(t);for(var e=this.flags.show_unchanged&&this.flags.show_unchanged_columns?1:2,n=t.get_height(),i=t.get_height(),r=0,s=e;r<s;){var l=r++;if(1==l){this.refineActivity();var o=this.countActive(this.active_row)+i;this.top_line_done&&--o,n=i,o>t.get_height()&&t.resize(this.column_units.length+1,o)}for(var a=!1,h=0,u=this.row_units.length;h<u;){var c=h++,f=this.row_units[c],_=!1;if(this.flags.ordered&&(this.row_moves.h.hasOwnProperty(c)&&(_=!0),_&&(this.show_rc_numbers=!0)),!(f.r<0&&f.l<0||0==f.r&&f.lp()<=0&&this.top_line_done)){this.publish=this.flags.show_unchanged;var d=!1;if(1==l){var g=this.active_row[c];if(this.publish=null!=g&&g>0,(d=null!=g&&3==g)&&a)continue;if(!this.publish)continue}d||(a=!1);var p=n;if(this.publish&&(++n,t.get_height()<n&&t.resize(this.column_units.length+1,n)),d){for(var m=0,v=this.column_units.length+1;m<v;){var w=m++;t.setCell(w,p,this.v.toDatum("..."))}a=!0}else{this.have_addition=!1;var b=!1;this.act="",_&&(this.act=":",0==l&&this.row_reorders++),f.p<0&&f.l<0&&f.r>=0&&(this.allow_insert||(b=!0),this.act="+++",0!=l||b||this.row_inserts++),(f.p>=0||!this.has_parent)&&f.l>=0&&f.r<0&&(this.allow_delete||(b=!0),this.act="---",0!=l||b||this.row_deletes++),b?this.publish||null!=this.active_row&&(this.active_row[c]=-3):this.scanRow(f,t,p,c,l)}}}}this.checkRcNumbers(t.get_width(),t.get_height());var y=this.addRcNumbers(t);return this.preserve_columns||this.elideColumns(t,y),!0},hiliteWithNesting:function(t){var e=t.add("base"),n=this.hiliteSingle(e);if(!n)return!1;if(null==this.align.comp)return!0;var i=this.align.comp.child_order;if(null==i)return!0;t.alignment=this.align;for(var r=0;r<i.length;){var s=i[r];++r;var l=this.align.comp.children.h[s].alignment;if(l.isMarkedAsIdentical())this.align.comp.children.h[s]=null;else{var o=new at(l,this.flags),a=t.add(s);n=n&&o.hiliteSingle(a)}}return n},hasDifference:function(){return this.diff_found},hasSchemaDifference:function(){return this.schema_diff_found},isNested:function(){return this.nesting_present},getComparisonState:function(){return null==this.align?null:this.align.comp},getSummary:function(){var t=new N;return t.row_deletes=this.row_deletes,t.row_inserts=this.row_inserts,t.row_updates=this.row_updates,t.row_reorders=this.row_reorders,t.col_deletes=this.col_deletes,t.col_inserts=this.col_inserts,t.col_updates=this.col_updates,t.col_renames=this.col_renames,t.col_reorders=this.col_reorders,t.row_count_initial_with_header=this.align.getSource().get_height(),t.row_count_final_with_header=this.align.getTarget().get_height(),t.row_count_initial=this.align.getSource().get_height()-this.align.getSourceHeader()-1,t.row_count_final=this.align.getTarget().get_height()-this.align.getTargetHeader()-1,t.col_count_initial=this.align.getSource().get_width(),t.col_count_final=this.align.getTarget().get_width(),t.different=this.row_deletes+this.row_inserts+this.row_updates+this.row_reorders+this.col_deletes+this.col_inserts+this.col_updates+this.col_renames+this.col_reorders>0,t},__class__:at};var ht=t.coopy.TableIO=function(){};ht.__name__=!0,ht.prototype={valid:function(){return!1},getContent:function(t){return""},saveContent:function(t,e){return!1},args:function(){return[]},writeStdout:function(t){},writeStderr:function(t){},command:function(t,e){return 1},hasAsync:function(){return!1},exists:function(t){return!1},isTtyKnown:function(){return!1},isTty:function(){return!0},openSqliteDatabase:function(t){return null},sendToBrowser:function(t){console.log("coopy/TableIO.hx:200:","do not know how to send to browser in this language")},__class__:ht};var ut=t.coopy.TableModifier=function(t){this.t=t};ut.__name__=!0,ut.prototype={t:null,removeColumn:function(t){for(var e=[],n=0,i=this.t.get_width();n<i;){var r=n++;r<t?e.push(r):r>t?e.push(r-1):e.push(-1)}return this.t.insertOrDeleteColumns(e,this.t.get_width()-1)},__class__:ut};var ct=function(t){if(this.t=t,this.at=-1,this.h=t.get_height(),this.src=null,this.h<0){var e=t.getMeta();if(null==e)throw mt.thrown("Cannot get meta information for table");if(this.src=e.getRowStream(),null==this.src)throw mt.thrown("Cannot iterate table")}};ct.__name__=!0,ct.__interfaces__=[W],ct.prototype={t:null,at:null,h:null,src:null,columns:null,row:null,fetchColumns:function(){if(null!=this.columns)return this.columns;if(null!=this.src)return this.columns=this.src.fetchColumns(),this.columns;this.columns=[];for(var t=0,e=this.t.get_width();t<e;){var n=t++;this.columns.push(this.t.getCell(n,0))}return this.columns},fetchRow:function(){if(null!=this.src)return this.src.fetchRow();if(this.at>=this.h)return null;for(var t=new bt,e=0,n=this.columns.length;e<n;){var i=e++,r=this.columns[i],s=this.t.getCell(i,this.at);t.h[r]=s}return t},fetch:function(){return-1==this.at?(this.at++,null!=this.src&&this.fetchColumns(),!0):null!=this.src?(this.at=1,this.row=this.fetchRow(),null!=this.row):(this.at++,this.at<this.h)},getCell:function(t){return 0==this.at?this.columns[t]:null!=this.row?this.row.h[this.columns[t]]:this.t.getCell(t,this.at)},width:function(){return this.fetchColumns(),this.columns.length},__class__:ct};var ft=t.coopy.Tables=function(t){this.template=t,this.tables=new bt,this.table_order=[]};ft.__name__=!0,ft.prototype={template:null,tables:null,table_order:null,alignment:null,add:function(t){var e=this.template.clone();return this.tables.h[t]=e,this.table_order.push(t),e},getOrder:function(){return this.table_order},get:function(t){return this.tables.h[t]},one:function(){return this.tables.h[this.table_order[0]]},hasInsDel:function(){return null!=this.alignment&&(!!this.alignment.has_addition||!!this.alignment.has_removal)},__class__:ft};var _t=t.coopy.TerminalDiffRender=function(t,e,n){null==n&&(n=!0),this.align_columns=!0,this.wide_columns=!1,this.use_glyphs=!0,this.flags=t,null!=t&&("dense"==t.padding_strategy&&(this.align_columns=!1),"sparse"==t.padding_strategy&&(this.wide_columns=!0),this.use_glyphs=t.use_glyphs),this.delim=null!=e?e:",",this.diff=n};_t.__name__=!0,_t.prototype={codes:null,t:null,csv:null,v:null,align_columns:null,wide_columns:null,use_glyphs:null,flags:null,delim:null,diff:null,alignColumns:function(t){this.align_columns=t},render:function(t){this.csv=new O;var e=t.get_width(),n=t.get_height();this.t=t,this.v=t.getCellView(),this.codes=new bt,this.codes.h.header="[0;1m",this.codes.h.minor="[33m",this.codes.h.done="[0m",this.codes.h.meta="[0;1m",this.codes.h.spec="[35;1m",this.codes.h.add="[32;1m",this.codes.h.conflict="[33;1m",this.codes.h.modify="[34;1m",this.codes.h.remove="[31;1m";var i=null;this.align_columns&&(i=this.pickSizes(t));for(var r=[],s=0,l=n;s<l;){for(var o=s++,a=0,h=0,u=0,c=e;u<c;){var f=u++;if(null!=i)for(var _=0,d=a-h;_<d;){_++;r.push(" "),++h}if(f>0&&(r.push(this.codes.h.minor),r.push(this.delim),r.push(this.codes.h.done)),r.push(this.getText(f,o,!0)),null!=i)h+=this.getText(f,o,!1).length,a+=i[f]}r.push("\r\n")}return this.t=null,this.v=null,this.csv=null,this.codes=null,r.join("")},getText:function(t,e,n){var i=this.t.getCell(t,e),r=k.renderCell(this.t,this.v,t,e);if(n&&this.diff){var s=null;if(null!=r.category&&(s=this.codes.h[r.category]),null!=r.category_given_tr){var l=this.codes.h[r.category_given_tr];null!=l&&(s=l)}if(null!=s){var o=this.use_glyphs?r.pretty_separator:r.separator;null!=r.rvalue?(i=this.codes.h.remove+r.lvalue+this.codes.h.modify+o+this.codes.h.add+r.rvalue+this.codes.h.done,null!=r.pvalue&&(i=this.codes.h.conflict+r.pvalue+this.codes.h.modify+o+h.string(i))):(i=this.use_glyphs?r.pretty_value:r.value,i=s+h.string(i)+this.codes.h.done)}}else n&&!this.diff?0==e&&(i=this.codes.h.header+h.string(i)+this.codes.h.done):i=this.use_glyphs?r.pretty_value:r.value;return this.csv.renderCell(this.v,i)},pickSizes:function(t){for(var e=t.get_width(),n=t.get_height(),i=(t.getCellView(),new O,[]),r=-1,s=e-1,l=0,o=e;l<o;){for(var a=l++,h=0,u=0,c=0,f=0,_=-1,d=0,g=n;d<g;){var p=d++,m=this.getText(a,p,!1);"@@"==m&&-1==r&&this.diff&&(r=p),-1!=r||this.diff||(r=p);var v=m.length;p==r&&(_=v),h+=v,u+=v*v,v>c&&(c=v)}for(var w=h/n,b=w+2*Math.sqrt(u/n-w*w)+.5|0,y=0,C=n;y<C;){var S=y++,x=this.getText(a,S,!1).length;x<=b&&x>f&&(f=x)}var R=c;b=f,-1!=_&&b<_&&(b=_),this.wide_columns&&(b=R),i.push(b),s+=b}return s>130&&!this.wide_columns?null:i},__class__:_t};var dt=function(t,e,n){null==n&&(n=-2),null==e&&(e=-2),null==t&&(t=-2),this.l=t,this.r=e,this.p=n};dt.__name__=!0,dt.describe=function(t){return t>=0?""+t:"-"},dt.prototype={l:null,r:null,p:null,lp:function(){return-2==this.p?this.l:this.p},toString:function(){return this.p>=-1?dt.describe(this.p)+"|"+dt.describe(this.l)+":"+dt.describe(this.r):dt.describe(this.l)+":"+dt.describe(this.r)},fromString:function(t){for(var e=0,n=0,i=(t+="]").length;n<i;){var r=n++,s=l.cca(t,r);if(s>=48&&s<=57)e*=10,e+=s-48;else if(45==s)e=-1;else if(124==s)this.p=e,e=0;else if(58==s)this.l=e,e=0;else if(93==s)return this.r=e,!0}return!1},base26:function(t){if(t<0)return"-";var e="";do{e+="ABCDEFGHIJKLMNOPQRSTUVWXYZ".charAt(t%26),t=Math.floor(t/26)-1}while(t>=0);return e},toBase26String:function(){return this.p>=-1?this.base26(this.p)+"|"+this.base26(this.l)+":"+this.base26(this.r):this.base26(this.l)+":"+this.base26(this.r)},__class__:dt};var gt=t.coopy.Viterbi=function(){this.K=this.T=0,this.reset(),this.cost=new X,this.src=new X,this.path=new X};gt.__name__=!0,gt.prototype={K:null,T:null,index:null,mode:null,path_valid:null,best_cost:null,cost:null,src:null,path:null,reset:function(){this.index=0,this.mode=0,this.path_valid=!1,this.best_cost=0},setSize:function(t,e){this.K=t,this.T=e,this.cost.resize(this.K,this.T,0),this.src.resize(this.K,this.T,-1),this.path.resize(1,this.T,-1)},assertMode:function(t){0==t&&1==this.mode&&this.index++,this.mode=t},addTransition:function(t,e,n){var i=!1;t>=this.K&&(this.K=t+1,i=!0),e>=this.K&&(this.K=e+1,i=!0),i&&(this.cost.nonDestructiveResize(this.K,this.T,0),this.src.nonDestructiveResize(this.K,this.T,-1),this.path.nonDestructiveResize(1,this.T,-1)),this.path_valid=!1,this.assertMode(1),this.index>=this.T&&(this.T=this.index+1,this.cost.nonDestructiveResize(this.K,this.T,0),this.src.nonDestructiveResize(this.K,this.T,-1),this.path.nonDestructiveResize(1,this.T,-1));var r=!1;this.index>0?(n+=this.cost.get(t,this.index-1),r=-1!=this.src.get(t,this.index-1)):r=!0,r&&(n<this.cost.get(e,this.index)||-1==this.src.get(e,this.index))&&(this.cost.set(e,this.index,n),this.src.set(e,this.index,t))},endTransitions:function(){this.path_valid=!1,this.assertMode(0)},beginTransitions:function(){this.path_valid=!1,this.assertMode(1)},calculatePath:function(){if(!this.path_valid){this.endTransitions();var t=0,e=-1;if(this.index<=0)this.path_valid=!0;else{for(var n=0,i=this.K;n<i;){var r=n++;(this.cost.get(r,this.index-1)<t||-1==e)&&-1!=this.src.get(r,this.index-1)&&(t=this.cost.get(r,this.index-1),e=r)}this.best_cost=t;for(n=0,i=this.index;n<i;){r=n++;var s=this.index-1-r;this.path.set(0,s,e),-1!=e&&e>=0&&e<this.K||console.log("coopy/Viterbi.hx:167:","Problem in Viterbi"),e=this.src.get(e,s)}this.path_valid=!0}}},toString:function(){this.calculatePath();for(var t="",e=0,n=this.index;e<n;){var i=e++;-1==this.path.get(0,i)?t+="*":t+=this.path.get(0,i),this.K>=10&&(t+=" ")}return t+=" costs "+this.getCost()},length:function(){return this.index>0&&this.calculatePath(),this.index},get:function(t){return this.calculatePath(),this.path.get(0,t)},getCost:function(){return this.calculatePath(),this.best_cost},__class__:gt};var pt=function(){};pt.__name__=!0;var mt=function(t,e,n){Error.call(this,t),this.message=t,this.__previousException=e,this.__nativeException=null!=n?n:this};mt.__name__=!0,mt.caught=function(t){return t instanceof mt?t:t instanceof Error?new mt(t.message,null,t):new vt(t,null,t)},mt.thrown=function(t){return t instanceof mt?t.get_native():t instanceof Error?t:new vt(t)},mt.__super__=Error,mt.prototype=s(Error.prototype,{__skipStack:null,__nativeException:null,__previousException:null,unwrap:function(){return this.__nativeException},get_native:function(){return this.__nativeException},__class__:mt});var vt=function(t,e,n){mt.call(this,String(t),e,n),this.value=t};vt.__name__=!0,vt.__super__=mt,vt.prototype=s(mt.prototype,{value:null,unwrap:function(){return this.value},__class__:vt});var wt=function(){this.h={}};wt.__name__=!0,wt.__interfaces__=[pt],wt.prototype={h:null,remove:function(t){return!!this.h.hasOwnProperty(t)&&(delete this.h[t],!0)},keys:function(){var t=[];for(var e in this.h)this.h.hasOwnProperty(e)&&t.push(+e);return new St(t)},toString:function(){var t="";t+="[";for(var e=this.keys(),n=e;n.hasNext();){var i=n.next();t+=null==i?"null":""+i,t+=" => ",t+=h.string(h.string(this.h[i])),e.hasNext()&&(t+=", ")}return t+="]"},__class__:wt};var bt=function(){this.h=Object.create(null)};bt.__name__=!0,bt.__interfaces__=[pt],bt.prototype={h:null,__class__:bt};var yt=function(t){this.str=t,this.pos=0};yt.__name__=!0,yt.prototype={str:null,pos:null,doParse:function(){for(var t,e=this.parseRec();;){t=this.str.charCodeAt(this.pos++);if(t!=t)break;switch(t){case 9:case 10:case 13:case 32:break;default:this.invalidChar()}}return e},parseRec:function(){for(;;){var t=this.str.charCodeAt(this.pos++);switch(t){case 9:case 10:case 13:case 32:break;case 34:return this.parseString();case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:var e=t,n=this.pos-1,i=45==e,r=!i,s=48==e,o=!1,a=!1,h=!1,u=!1;do{switch(e=this.str.charCodeAt(this.pos++)){case 43:case 45:a&&!h||this.invalidNumber(n),r=!1,h=!0;break;case 46:(i||o||a)&&this.invalidNumber(n),r=!1,o=!0;break;case 48:s&&!o&&this.invalidNumber(n),i&&(i=!1,s=!0),r=!0;break;case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:s&&!o&&this.invalidNumber(n),i&&(i=!1),r=!0,s=!1;break;case 69:case 101:(i||s||a)&&this.invalidNumber(n),r=!1,a=!0;break;default:r||this.invalidNumber(n),this.pos--,u=!0}}while(!u);var c=parseFloat(l.substr(this.str,n,this.pos-n));if(o)return c;var f=0|c;return f==c?f:c;case 91:for(var _=[],d=null;;){switch(this.str.charCodeAt(this.pos++)){case 9:case 10:case 13:case 32:break;case 44:d?d=!1:this.invalidChar();break;case 93:return 0==d&&this.invalidChar(),_;default:d&&this.invalidChar(),this.pos--,_.push(this.parseRec()),d=!0}}break;case 102:var g=this.pos;return 97==this.str.charCodeAt(this.pos++)&&108==this.str.charCodeAt(this.pos++)&&115==this.str.charCodeAt(this.pos++)&&101==this.str.charCodeAt(this.pos++)||(this.pos=g,this.invalidChar()),!1;case 110:var p=this.pos;return 117==this.str.charCodeAt(this.pos++)&&108==this.str.charCodeAt(this.pos++)&&108==this.str.charCodeAt(this.pos++)||(this.pos=p,this.invalidChar()),null;case 116:var m=this.pos;return 114==this.str.charCodeAt(this.pos++)&&117==this.str.charCodeAt(this.pos++)&&101==this.str.charCodeAt(this.pos++)||(this.pos=m,this.invalidChar()),!0;case 123:for(var v={},w=null,b=null;;){switch(this.str.charCodeAt(this.pos++)){case 9:case 10:case 13:case 32:break;case 34:(null!=w||b)&&this.invalidChar(),w=this.parseString();break;case 44:b?b=!1:this.invalidChar();break;case 58:null==w&&this.invalidChar(),v[w]=this.parseRec(),w=null,b=!0;break;case 125:return null==w&&0!=b||this.invalidChar(),v;default:this.invalidChar()}}break;default:this.invalidChar()}}},parseString:function(){for(var t=this.pos,e=null,n=-1;;){var i=this.str.charCodeAt(this.pos++);if(34==i)break;if(92==i){null==e&&(e=new u);var r=this.str,s=this.pos-t-1;switch(e.b+=l.substr(r,t,null==s?null:s),117!=(i=this.str.charCodeAt(this.pos++))&&-1!=n&&(e.b+=String.fromCodePoint(65533),n=-1),i){case 34:case 47:case 92:e.b+=String.fromCodePoint(i);break;case 98:e.b+=String.fromCodePoint(8);break;case 102:e.b+=String.fromCodePoint(12);break;case 110:e.b+=String.fromCodePoint(10);break;case 114:e.b+=String.fromCodePoint(13);break;case 116:e.b+=String.fromCodePoint(9);break;case 117:var o=h.parseInt("0x"+l.substr(this.str,this.pos,4));this.pos+=4,-1!=n?o<56320||o>57343?(e.b+=String.fromCodePoint(65533),n=-1):(e.b+=String.fromCodePoint(o-56320+(n-55296<<10)+65536),n=-1):o>=55296&&o<=56319?n=o:e.b+=String.fromCodePoint(o);break;default:throw mt.thrown("Invalid escape sequence \\"+String.fromCodePoint(i)+" at position "+(this.pos-1))}t=this.pos}else if(i!=i)throw mt.thrown("Unclosed string")}if(-1!=n&&(e.b+=String.fromCodePoint(65533),n=-1),null==e)return l.substr(this.str,t,this.pos-t-1);r=this.str,s=this.pos-t-1;return e.b+=l.substr(r,t,null==s?null:s),e.b},invalidChar:function(){throw this.pos--,mt.thrown("Invalid char "+this.str.charCodeAt(this.pos)+" at position "+this.pos)},invalidNumber:function(t){throw mt.thrown("Invalid number at position "+t+": "+l.substr(this.str,t,this.pos-t))},__class__:yt};var Ct=function(t,e){this.replacer=t,this.indent=e,this.pretty=null!=e,this.nind=0,this.buf=new u};Ct.__name__=!0,Ct.print=function(t,e,n){var i=new Ct(e,n);return i.write("",t),i.buf.b},Ct.prototype={buf:null,replacer:null,indent:null,pretty:null,nind:null,write:function(t,e){null!=this.replacer&&(e=this.replacer(t,e));var n=_.typeof(e);switch(n._hx_index){case 0:this.buf.b+="null";break;case 1:case 3:this.buf.b+=h.string(e);break;case 2:var i=isFinite(e)?h.string(e):"null";this.buf.b+=h.string(i);break;case 4:this.fieldsString(e,a.fields(e));break;case 5:this.buf.b+='"<fun>"';break;case 6:var r=n.c;if(r==String)this.quote(e);else if(r==Array){i=e;this.buf.b+=String.fromCodePoint(91);for(var s=i.length,o=s-1,u=0,f=s;u<f;){if((y=u++)>0?this.buf.b+=String.fromCodePoint(44):this.nind++,this.pretty&&(this.buf.b+=String.fromCodePoint(10)),this.pretty){var d=c.lpad("",this.indent,this.nind*this.indent.length);this.buf.b+=h.string(d)}if(this.write(y,i[y]),y==o&&(this.nind--,this.pretty&&(this.buf.b+=String.fromCodePoint(10)),this.pretty)){var g=c.lpad("",this.indent,this.nind*this.indent.length);this.buf.b+=h.string(g)}}this.buf.b+=String.fromCodePoint(93)}else if(r==bt){for(var p={},m=(i=e).h,v=Object.keys(m),w=v.length,b=0;b<w;){p[t=v[b++]]=i.h[t]}i=p;this.fieldsString(i,a.fields(i))}else if(r==Date){i=e;this.quote(l.dateStr(i))}else this.classString(e);break;case 7:u=n.e;var y=e._hx_index;this.buf.b+=h.string(null==y?"null":""+y);break;case 8:this.buf.b+='"???"'}},classString:function(t){this.fieldsString(t,_.getInstanceFields(xt.getClass(t)))},fieldsString:function(t,e){this.buf.b+=String.fromCodePoint(123);for(var n=!0,i=0,r=e.length;i<r;){var s=e[i++],l=a.field(t,s);if(!a.isFunction(l)){if(n?(this.nind++,n=!1):this.buf.b+=String.fromCodePoint(44),this.pretty&&(this.buf.b+=String.fromCodePoint(10)),this.pretty){var o=c.lpad("",this.indent,this.nind*this.indent.length);this.buf.b+=h.string(o)}this.quote(s),this.buf.b+=String.fromCodePoint(58),this.pretty&&(this.buf.b+=String.fromCodePoint(32)),this.write(s,l)}}if(!n&&(this.nind--,this.pretty&&(this.buf.b+=String.fromCodePoint(10)),this.pretty)){t=c.lpad("",this.indent,this.nind*this.indent.length);this.buf.b+=h.string(t)}this.buf.b+=String.fromCodePoint(125)},quote:function(t){this.buf.b+=String.fromCodePoint(34);for(var e=0,n=t.length;e<n;){var i=t.charCodeAt(e++);switch(i){case 8:this.buf.b+="\\b";break;case 9:this.buf.b+="\\t";break;case 10:this.buf.b+="\\n";break;case 12:this.buf.b+="\\f";break;case 13:this.buf.b+="\\r";break;case 34:this.buf.b+='\\"';break;case 92:this.buf.b+="\\\\";break;default:this.buf.b+=String.fromCodePoint(i)}}this.buf.b+=String.fromCodePoint(34)},__class__:Ct};var St=function(t){this.current=0,this.array=t};St.__name__=!0,St.prototype={array:null,current:null,hasNext:function(){return this.current<this.array.length},next:function(){return this.array[this.current++]},__class__:St};var xt=function(){};function Rt(t){return t instanceof Array?new St(t):t.iterator()}xt.__name__=!0,xt.getClass=function(t){if(null==t)return null;if(t instanceof Array)return Array;var e=t.__class__;if(null!=e)return e;var n=xt.__nativeClassName(t);return null!=n?xt.__resolveNativeClass(n):null},xt.__string_rec=function(t,e){if(null==t)return"null";if(e.length>=5)return"<...>";var n=typeof t;switch("function"==n&&(t.__name__||t.__ename__)&&(n="object"),n){case"function":return"<function>";case"object":if(t.__enum__){var i=r[t.__enum__].__constructs__[t._hx_index],s=i._hx_name;return i.__params__?(e+="\t",s+"("+function(){for(var n=[],r=0,s=i.__params__;r<s.length;){var l=s[r];r+=1,n.push(xt.__string_rec(t[l],e))}return n}().join(",")+")"):s}if(t instanceof Array){var l="[";e+="\t";for(var o=0,a=t.length;o<a;){var h=o++;l+=(h>0?",":"")+xt.__string_rec(t[h],e)}return l+="]"}var u;try{u=t.toString}catch(o){return"???"}if(null!=u&&u!=Object.toString&&"function"==typeof u){var c=t.toString();if("[object Object]"!=c)return c}l="{\n";e+="\t";var f=null!=t.hasOwnProperty,_=null;for(_ in t)f&&!t.hasOwnProperty(_)||"prototype"!=_&&"__class__"!=_&&"__super__"!=_&&"__interfaces__"!=_&&"__properties__"!=_&&(2!=l.length&&(l+=", \n"),l+=e+_+" : "+xt.__string_rec(t[_],e));return l+="\n"+(e=e.substring(1))+"}";case"string":return t;default:return String(t)}},xt.__interfLoop=function(t,e){if(null==t)return!1;if(t==e)return!0;var n=t.__interfaces__;if(null!=n)for(var i=0,r=n.length;i<r;){var s=n[i++];if(s==e||xt.__interfLoop(s,e))return!0}return xt.__interfLoop(t.__super__,e)},xt.__implements=function(t,e){return xt.__interfLoop(xt.getClass(t),e)},xt.__nativeClassName=function(t){var e=xt.__toStr.call(t).slice(8,-1);return"Object"==e||"Function"==e||"Math"==e||"JSON"==e?null:e},xt.__resolveNativeClass=function(t){return e[t]},e.$haxeUID|=0,"undefined"!=typeof performance&&"function"==typeof performance.now&&(l.now=performance.now.bind(performance)),null==String.fromCodePoint&&(String.fromCodePoint=function(t){return t<65536?String.fromCharCode(t):String.fromCharCode(55232+(t>>10))+String.fromCharCode(56320+(1023&t))}),Object.defineProperty(String.prototype,"__class__",{value:String,enumerable:!1,writable:!0}),String.__name__=!0,Array.__name__=!0,Date.prototype.__class__=Date,Date.__name__="Date",xt.__toStr={}.toString,R.VERSION="1.3.50",R.main()}("undefined"!=typeof exports?exports:"undefined"!=typeof window?window:"undefined"!=typeof self?self:this,"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this);let daff=null;if("undefined"!=typeof exports&&exports.coopy){for(const t in exports.coopy)exports.coopy.hasOwnProperty(t)&&(exports[t]=exports.coopy[t]);for(const e in exports.Coopy)exports.Coopy.hasOwnProperty(e)&&(exports[e]=exports.Coopy[e]);daff=exports}else{for(const n in coopy.Coopy)coopy.Coopy.hasOwnProperty(n)&&(coopy[n]=coopy.Coopy[n]);window.daff=daff=coopy}if(function(){var t=function(){};t.prototype.toString=function(t){return""+t},t.prototype.equals=function(t,e){return t==e},t.prototype.toDatum=function(t){return t},t.prototype.makeHash=function(){return{}},t.prototype.hashSet=function(t,e,n){t[e]=n},t.prototype.hashGet=function(t,e){return t[e]},t.prototype.hashExists=function(t,e){return e in t},t.prototype.isHash=function(t){return t&&"object"==typeof t};var e=function(t){if(2==arguments.length){for(var e=[],n=0;n<arguments[1];n++){for(var i=[],r=0;r<arguments[0];r++)i.push(null);e.push(i)}t=e}this.data=t,this.height=t.length,this.width=0,this.height>0&&(this.width=t[0].length)};e.prototype.get_width=function(){return this.width},e.prototype.get_height=function(){return this.height},e.prototype.getCell=function(t,e){return this.data[e][t]},e.prototype.setCell=function(t,e,n){this.data[e][t]=n},e.prototype.toString=function(){return daff.SimpleTable.tableToString(this)},e.prototype.getCellView=function(){return new t},e.prototype.isResizable=function(){return!0},e.prototype.resize=function(t,e){this.width=t,this.height=e;for(var n=0;n<this.data.length;n++){for(null==(i=this.data[n])&&(i=this.data[n]=[]);i.length<this.width;)i.push(null)}if(this.data.length<this.height)for(;this.data.length<this.height;){var i=[];for(n=0;n<this.width;n++)i.push(null);this.data.push(i)}return!0},e.prototype.clear=function(){for(var t=0;t<this.data.length;t++)for(var e=this.data[t],n=0;n<e.length;n++)e[n]=null},e.prototype.trim=function(){var t=this.trimRows();return t=t||this.trimColumns()},e.prototype.trimRows=function(){for(var t=!1;;){if(0==this.height)return t;for(var e=this.data[this.height-1],n=0;n<this.width;n++){var i=e[n];if(null!=i&&""!=i)return t}this.height--}},e.prototype.trimColumns=function(){for(var t=0,e=0;e<this.height&&!(t>=this.width);e++)for(var n=this.data[e],i=0;i<this.width;i++){var r=n[i];null!=r&&""!=r&&i>t&&(t=i)}return 0!=this.height&&t+1!=this.width&&(this.width=t+1,!0)},e.prototype.getData=function(){return this.data},e.prototype.clone=function(){for(var t=[],n=0;n<this.get_height();n++)t[n]=this.data[n].slice();return new e(t)},e.prototype.create=function(){return new e([])},e.prototype.insertOrDeleteRows=function(t,e){for(var n=[],i=0;i<t.length;i++){var r=t[i];-1!=r&&(n[r]=this.data[i])}this.data.length=0;for(i=0;i<n.length;i++)this.data[i]=n[i];return this.resize(this.width,e),!0},e.prototype.insertOrDeleteColumns=function(t,e){if(e==this.width&&e==t.length){for(var n=!0,i=0;i<e;i++)if(t[i]!=i){n=!1;break}if(n)return!0}for(i=0;i<this.height;i++){for(var r=this.data[i],s=[],l=0;l<this.width;l++)-1!=t[l]&&(s[t[l]]=r[l]);for(;s.length<e;)s.push(null);this.data[i]=s}return this.width=e,!0},e.prototype.isSimilar=function(t){if(t.get_width()!=this.get_width())return!1;if(t.get_height()!=this.get_height())return!1;for(var e=0;e<this.width;e++)for(var n=0;n<this.height;n++){var i=""+this.getCell(e,n),r=""+t.getCell(e,n);if(i!=r)return console.log("MISMATCH "+i+" "+r),!1}return!0},e.prototype.getMeta=function(){return null},daff.TableView=e,daff.CellView=t,daff.TableView=e}(),function(){var t=function(t,e){this.data=t,this.height=t.length,this.width=0,this.columns=[],this.hasMapping=null!=e,null==e&&(e=function(t){return t}),this.mapping=e;var n={};if(this.height>0)for(var i=0;i<this.height;i++){var r=e(t[i]);for(var s in r)s in n||r.hasOwnProperty(s)&&(this.width++,n[s]=this.columns.length,this.columns.push(s))}this.columns.sort(),this.height>0&&this.height++};t.prototype.get_width=function(){return this.width},t.prototype.get_height=function(){return this.height},t.prototype.getCell=function(t,e){var n=this.columns[t];if(null==n)throw Error("bad key");return 0==e?n:this.mapping(this.data[e-1])[n]},t.prototype.setCell=function(t,e,n){var i=this.columns[t];if(null==i&&0!=e)throw Error("bad key");if(0==e){if(null!=i)throw Error("cannot yet change column set in this type of table");this.columns[t]=n}else this.mapping(this.data[e-1])[i]=n},t.prototype.toString=function(){return daff.SimpleTable.tableToString(this)},t.prototype.getCellView=function(){return new daff.CellView},t.prototype.isResizable=function(){return!1},t.prototype.resize=function(t,e){return!1},t.prototype.clear=function(){return!1},t.prototype.getData=function(){return this.data},t.prototype.clone=function(){for(var e=[],n=0;n<this.data.length;n++)for(var i=e[n]={},r=0;r<this.columns;r++){var s=this.columns[r];i[s]=this.data[n][s]}return new t(e,this.hasMapping?this.mapping:null)},t.prototype.insertOrDeleteRows=function(t,e){return!1},t.prototype.insertOrDeleteColumns=function(t,e){return!1},t.prototype.getMeta=function(){return null},daff.NdjsonTable=t}(),"undefined"!=typeof exports&&"undefined"!=typeof window)for(const i in daff)daff.hasOwnProperty(i)&&(exports[i]=daff[i]);if(function(){const t=function(t,e,n){this.db=t,this.fname=e,this.row=null,this.active=!1,this.index2name={},this.Fiber=n,this.quoter=new daff.Csv,this.view=new daff.SimpleView};t.prototype.getHelper=function(){return new daff.SqliteHelper},t.prototype.getQuotedColumnName=function(t){return this.quoter.renderCell(this.view,t,!0)},t.prototype.getQuotedTableName=function(t){return this.quoter.renderCell(this.view,t.toString(),!0)},t.prototype.getColumns=function(t){var e=this.Fiber.current,n=this.getQuotedColumnName(t),i=this;return this.db.all("pragma table_info("+n+")",(function(t,n){var r=[];for(var s in n){var l=n[s],o=new daff.SqlColumn;o.setName(l.name),o.setPrimaryKey(l.pk>0),l.type&&o.setType(l.type,"sqlite"),r.push(o),i.index2name[s]=l.name}e.run(r)})),this.Fiber.yield()},t.prototype.exec=function(t,e){var n=this.Fiber.current;if(null==e)return this.db.run(t,(function(t){t&&console.log(t),n.run(null==t)})),this.Fiber.yield();this.db.run(t,e,(function(t){t&&console.log(t),n.run(null==t)}));return this.Fiber.yield()},t.prototype.beginRow=function(t,e,n){return this.begin("SELECT * FROM "+this.getQuotedColumnName(t)+" WHERE rowid = ?",[e],n)},t.prototype.begin=function(t,e,n){if(null!=n){this.index2name={};for(var i=n.length,r=0;r<i;r++)this.index2name[r]=n[r]}var s=this.Fiber.current;this.active=!0;return this.db.each(t,null==e?[]:e,(function(t,e){for(var n=Object.keys(e),i=0;i<n.length;i++){var r=e[n[i]];if(Buffer.isBuffer(r)){var l=require("crypto").createHash("md5").update(r).digest("hex");e[n[i]]="[buffer:"+l+"]"}}t?s.run([!1,0]):s.run([!0,e])}),(function(t,e){t&&console.log(t),s.run([!1,e])})),!0},t.prototype.read=function(){if(!this.active)return!1;var t=this.Fiber.yield();return t[0]?(this.row=t[1],!0):(this.row=null,this.active=!1,!1)},t.prototype.get=function(t){return this.row[this.index2name[t]]},t.prototype.end=function(){for(;this.active;)this.read()},t.prototype.rowid=function(){return"rowid"},t.prototype.getNameForAttachment=function(){return this.fname},"undefined"!=typeof exports&&(exports.SqliteDatabase=t)}(),"undefined"!=typeof exports){var tio={},tio_args=[],coopy=exports,fs=require("fs"),exec=require("child_process").exec,readline=null,Fiber=null,sqlite3=null,tty=null;tio.valid=function(){return!0},tio.getContent=function(t){var e="";return 65279===(e="-"==t?fs.readFileSync("/dev/stdin","utf8"):fs.readFileSync(t,"utf8")).charCodeAt(0)?e.slice(1):e},tio.saveContent=function(t,e){return fs.writeFileSync(t,e,"utf8")},tio.args=function(){return tio_args},tio.writeStdout=function(t){process.stdout.write(t)},tio.writeStderr=function(t){process.stderr.write(t)},tio.hasAsync=function(){return!0},tio.exists=function(t){return fs.existsSync(t)},tio.isTtyKnown=function(){return!0},tio.isTty=function(){if(void 0!==process.stdout.isTTY){if(process.stdout.isTTY)return!0}else if(null==tty&&(tty=require("tty")),tty.isatty(process.stdout.fd))return!0;return"true"==process.env.GIT_PAGER_IN_USE},tio.openSqliteDatabase=function(t){if(Fiber)return new coopy.SqliteDatabase(new sqlite3.Database(t),t,Fiber);throw"run inside Fiber plz"},tio.sendToBrowser=function(t){var e=require("http"),n=null,i=e.createServer((function(e,i){i.writeHead(200,{"Content-Type":"text/html; charset=UTF-8",Connection:"close"}),i.write(t),i.end(),setTimeout((function(){n()}),0)})),r={},s=0;i.on("connection",(function(t){var e=s++;r[e]=t,t.on("close",(function(){delete r[e]}))})),n=function(){for(var t in i.close(),r)r[t].destroy()},i.listen(0,null,null,(function(){var t="http://localhost:"+i.address().port,e=require("child_process").exec,n="xdg-open";switch(process.platform){case"darwin":n="open";break;case"win32":n='start ""'}e(n+' "'+t+'"',(function(t){t&&(console.error(t),i.close())}))}))};var cmd_result=1,cmd_pending=null;function run_daff_base(t,e){tio_args=e.slice();var n=t.coopyhx(tio);return 999==n&&null!=cmd_pending&&exec(cmd_pending,(function(n,i,r){return cmd_result=0,null!=n&&(cmd_result=n.code),run_daff_base(t,e)})),n}tio.command=function(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.indexOf(" ")>=0&&(i='"'+i+'"'),t+=" "+i}return t==cmd_pending?(cmd_pending=null,cmd_result):null!=cmd_pending?998:(cmd_pending=t,999)},daff.run_daff_main=function(){var t=run_daff_base(new daff.Coopy,process.argv.slice(2));999!=t&&0!=t&&process.exit(t)},daff.cmd=function(t){return run_daff_base(new daff.Coopy,t)}}if("undefined"!=typeof require&&require.main===module)try{daff.run_daff_main()}catch(r){if(-1===(""+r).indexOf("run inside Fiber plz"))throw r;try{Fiber=require("fibers"),sqlite3=require("sqlite3")}catch(s){console.log("No sqlite3/fibers")}Fiber((function(){daff.run_daff_main()})).run()}
//# sourceMappingURL=/sm/3e31ce87b899bf91ce73ff4a6fd21e8933cfcb79e9d658e0efe362146f3e5ea8.map