text: var DGWM=function(t){function n(e){if(i[e])return i[e].exports;var o=i[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var i={};return n.m=t,n.c=i,n.i=function(t){return t},n.d=function(t,i,e){n.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:e})},n.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(i,"a",i),i},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=5)}([function(t,n,i){"use strict";function e(t,n){this.id=Symbol(n),this._record=[],this.level=0,this.generalPadding="";for(var i=0;i<a.size;i+=1)this.generalPadding+=e.padding;a.set(this.id,this),r.enabled&&console.log(""+this.generalPadding+t+(n?" # "+n:""))}var o=arguments,r={enabled:!1};r.moduleErrorPrinter=function(t){return void 0!==(void 0).Reading?function(){}:function(t){console.error('Missing "${missingService}" service for "${moduleName}"')}},r.moduleLogPrinter=function(t){var n=function(t){console.log(t)};return void 0!==(void 0).Reading?function(){}:function(i){if(r.enabled){console.log("\n",t),console.log(i);for(var e=1;e<o.length;e+=1){var a=o[e];void 0!==a&&(a instanceof Array?a.forEach(n):console.log(a))}}}},r.forModule=function(t){return{start:function(n){return new e(t,n)},end:function(t){a.delete(t.id)},log:function(){var n;r.enabled&&(n=console).log.apply(n,[t].concat(Array.prototype.slice.call(arguments)))}}},e.padding="    ",e.prototype.push=function(){for(var t="",n=0;n<this.level;n+=1)t+=e.padding;r.enabled&&console.log(e.padding+this.generalPadding+t+Array.prototype.join.call(arguments," "))},e.prototype.levelUp=function(t){void 0!==t&&this.push(t),this.level+=1},e.prototype.levelDown=function(){this.level-=1,this.level<0&&(this.level=0)},e.prototype.notEmpty=function(){return this._record.length>0},e.prototype.print=function(){r.enabled&&console.log(e.padding+this.generalPadding+this._record.join("\n"+e.padding))};var a=new Map;t.exports=r},function(t,n,i){"use strict";function e(t,n,i,e,o){this.left=Number.MAX_VALUE,this.top=Number.MAX_VALUE,this.right=Number.MIN_VALUE,this.bottom=Number.MIN_VALUE,this.center=void 0,this.index=e||0,this.previous=o||null,this.next=null,this.previous&&(this.previous.next=this),this.fixations=[],this.fitEq=null,this.words=[],t&&this.addWord(t,n,i)}function o(t,n){for(var i=0,e=0;e<t.length;++e){var o=t[e];i+=o[1]-n*o[0]}return[i/t.length,n]}function r(t,n,i,e){this.left=t.left,this.top=t.top,this.right=t.right,this.bottom=t.bottom,this.id=n,this.index=e.words.length,this.text=i.textContent,this.element=i,this.line=e,this.fixations=[]}var a=i(4),s=i(0);e.init=function(t){f=s.forModule("Line"),t=t||{},l=t.useModel||!1,u=t.modelMaxGradient||.15,h=t.modelTypeSwitchThreshold||8,d=t.modelRemoveOldFixThreshold||10},e.prototype.width=function(){return this.right-this.left},e.prototype.addWord=function(t,n,i){this.left=Math.min(this.left,t.left),this.right=Math.max(this.right,t.right),this.top=Math.min(this.top,t.top),this.bottom=Math.max(this.bottom,t.bottom),this.center={x:(this.left+this.right)/2,y:(this.top+this.bottom)/2},this.words.push(new r(t,n,i,this))},e.prototype.addFixation=function(t){if(this.fixations.push([t.x,t.y,t.saccade,t.id]),l&&!(this.fixations.length<2)){c=f.start("addFixation"),this._removeOldFixation();var n=this.fixations.length<h?"linear":"polynomial",i=a.model(n,this.fixations,2);this.fitEq=i.equation,c.push("model for line",this.index,":",this.fitEq.map(function(t){return t.toFixed(3)})),"linear"===n&&(this.fitEq[1]<-u?(this.fitEq=o(this.fixations,-u),c.push("model reset to",this.fitEq[0].toFixed(0),",",this.fitEq[1].toFixed(3))):this.fitEq[1]>u&&(this.fitEq=o(this.fixations,u),c.push("model reset to",this.fitEq[0].toFixed(0),",",this.fitEq[1].toFixed(3)))),f.end(c)}},e.prototype.fit=function(t,n){if(this.fitEq){var i=n-a.fit(this.fitEq,t),e=f.start("fit");return e.push("e[",this.index,"|",t,n,"] =",Math.floor(i)),f.end(e),i}return Number.MAX_VALUE},e.prototype._removeOldFixation=function(){var t=this.fixations.length-1;if(!(t<5))for(var n=t,i=void 0;n>0;){if(i=this.fixations[n],n>0&&i[2].newLine){t-n+1>d&&(this.fixations=this.fixations.slice(n),c.push("line fixations: reduced"));break}n-=1}};var l=void 0,u=void 0,h=void 0,d=void 0,f=void 0,c=void 0;r.prototype.toString=function(){return this.left+","+this.top+" / "+this.line.index},t.exports={Line:e,Word:r}},function(t,n,i){"use strict";function e(t,n){var i=t-c.x,e=n-c.y,o=void 0;if(Math.sqrt(i*i+e*e)>u)null===p?(p=new r(t,n,h),p.previous=c,p.saccade=new a(t-c.x,n-c.y),c.next=p):(p.x=d*t+v*p.x,p.y=d*n+v*p.y,p.duration+=h,c=p,p=null);else{p=null;var s=c.duration;c.duration+=h,c.x=d*c.x+v*t,c.y=d*c.y+v*n,s<l&&c.duration>=l&&(o=c)}return o}function o(t){var n=void 0;if(t.duration<l)return n;if(c.duration>t.duration){var i=new r(t.x,t.y,t.duration);i.previous=c,c.next=i;var e=t.saccade;i.saccade=e?new a(e.dx,e.dy):new a(t.x-c.x,t.y-c.y),c=i,f.push(c),n=c}else c.duration=t.duration,c.x=t.x,c.y=t.y;return n}function r(t,n,i){this.x=t,this.y=n,this.duration=i,this.saccade=null,this.word=null,this.previous=null,this.next=null}function a(t,n){this.x=t,this.y=n,this.newLine=!1}var s={init:function(t){t=t||{},l=t.minDuration||80,u=t.threshold||70,h=t.sampleDuration||33,d=t.filterDemph||.4,v=1-d,c=new r(-1e4,-1e4,Number.MAX_VALUE),c.saccade=new a(0,0)},feed:function(t,n){return void 0!==n?e(t,n):o(t)},add:function(t,n,i){if(i<l)return null;var e=new r(t,n,i);return e.previous=c,c.next=e,e.saccade=new a(t-c.x,n-c.y),c=e},reset:function(){f.length=0,c=new r(-1e4,-1e4,Number.MAX_VALUE),c.saccade=new a(0,0),p=null},current:function(){return c}},l=void 0,u=void 0,h=void 0,d=void 0,f=[],c=void 0,p=null,v=void 0;r.prototype.toString=function(){return"FIX "+this.x+","+this.y+" / "+this.duration+"ms SACC=["+this.saccade+"], WORD=["+this.word+"]"},a.prototype.toString=function(){return this.x+","+this.y+" / "+this.zone+(this.newLine?", new line":"")},t.exports={Detector:s,Fixation:r,Saccade:a}},function(t,n,i){"use strict";function e(t){for(var n=0,i=null,e=0;e<t.length;e+=1){var o=t[e],a=o.getBoundingClientRect();n<a.top||!i?(i&&(u+=a.top-i.top,h+=i.bottom-i.top,d<i.right-i.left&&(d=i.right-i.left)),i=new r(a,e,o,l.length,l[l.length-1]),l.push(i),n=a.top):i.addWord(a,e,o)}if(i&&(h+=i.bottom-i.top,h/=l.length,d<i.right-i.left&&(d=i.right-i.left)),l.length>1)u/=l.length-1;else if(l.length>0){var s=l[0];u=2*(s.bottom-s.top)}f.push("spacing:",u.toFixed(0),", height:"+h.toFixed(0))}var o=i(0),r=i(1).Line,a={init:function(t){t=t||{},s=t.isTextFixed||!0,c=o.forModule("TextModel")},create:function(t){return s&&l.length>0?null:(f=c.start("create"),this.reset(),e(t),f.push(l.length+" lines"),c.end(f),this.model())},reset:function(){l=[],u=0,h=0,d=0},model:function(){return{lines:l,lineSpacing:u,lineHeight:h,lineWidth:d}}},s=void 0,l=[],u=void 0,h=void 0,d=void 0,f=void 0,c=void 0;t.exports=a},function(t,n,i){"use strict";!function(){var n=function(t,n){var i=0,e=0,o=0,r=0,a=0,s=t.length-1,l=Array(n);for(i=0;i<s;i++){for(r=i,e=i+1;e<s;e++)Math.abs(t[i][e])>Math.abs(t[i][r])&&(r=e);for(o=i;o<s+1;o++)a=t[o][i],t[o][i]=t[o][r],t[o][r]=a;for(e=i+1;e<s;e++)for(o=s;o>=i;o--)t[o][e]-=t[o][i]*t[i][e]/t[i][i]}for(e=s-1;e>=0;e--){for(a=0,o=e+1;o<s;o++)a+=t[o][e]*l[o];l[e]=(t[s][e]-a)/t[e][e]}return l},i={linear:function(t){for(var n=[0,0,0,0,0],i=0,e=[];i<t.length;i++)null!=t[i][1]&&(n[0]+=t[i][0],n[1]+=t[i][1],n[2]+=t[i][0]*t[i][0],n[3]+=t[i][0]*t[i][1],n[4]+=t[i][1]*t[i][1]);for(var o=(i*n[3]-n[0]*n[1])/(i*n[2]-n[0]*n[0]),r=n[1]/i-o*n[0]/i,a=0,s=t.length;a<s;a++){var l=[t[a][0],t[a][0]*o+r];e.push(l)}return{equation:[r,o],points:e,string:"y = "+Math.round(100*o)/100+"x + "+Math.round(100*r)/100}},linearThroughOrigin:function(t){for(var n=[0,0],i=0,e=[];i<t.length;i++)null!=t[i][1]&&(n[0]+=t[i][0]*t[i][0],n[1]+=t[i][0]*t[i][1]);for(var o=n[1]/n[0],r=0,a=t.length;r<a;r++){var s=[t[r][0],t[r][0]*o];e.push(s)}return{equation:[0,o],points:e,string:"y = "+Math.round(100*o)/100+"x"}},exponential:function(t){var n=[0,0,0,0,0,0],i=0,e=[];for(l=t.length;i<l;i++)null!=t[i][1]&&(n[0]+=t[i][0],n[1]+=t[i][1],n[2]+=t[i][0]*t[i][0]*t[i][1],n[3]+=t[i][1]*Math.log(t[i][1]),n[4]+=t[i][0]*t[i][1]*Math.log(t[i][1]),n[5]+=t[i][0]*t[i][1]);for(var o=n[1]*n[2]-n[5]*n[5],r=Math.pow(Math.E,(n[2]*n[3]-n[5]*n[4])/o),a=(n[1]*n[4]-n[5]*n[3])/o,s=0,l=t.length;s<l;s++){var u=[t[s][0],r*Math.pow(Math.E,a*t[s][0])];e.push(u)}return{equation:[r,a],points:e,string:"y = "+Math.round(100*r)/100+"e^("+Math.round(100*a)/100+"x)"}},logarithmic:function(t){var n=[0,0,0,0],i=0,e=[];for(s=t.length;i<s;i++)null!=t[i][1]&&(n[0]+=Math.log(t[i][0]),n[1]+=t[i][1]*Math.log(t[i][0]),n[2]+=t[i][1],n[3]+=Math.pow(Math.log(t[i][0]),2));for(var o=(i*n[1]-n[2]*n[0])/(i*n[3]-n[0]*n[0]),r=(n[2]-o*n[0])/i,a=0,s=t.length;a<s;a++){var l=[t[a][0],r+o*Math.log(t[a][0])];e.push(l)}return{equation:[r,o],points:e,string:"y = "+Math.round(100*r)/100+" + "+Math.round(100*o)/100+" ln(x)"}},power:function(t){var n=[0,0,0,0],i=0,e=[];for(s=t.length;i<s;i++)null!=t[i][1]&&(n[0]+=Math.log(t[i][0]),n[1]+=Math.log(t[i][1])*Math.log(t[i][0]),n[2]+=Math.log(t[i][1]),n[3]+=Math.pow(Math.log(t[i][0]),2));for(var o=(i*n[1]-n[2]*n[0])/(i*n[3]-n[0]*n[0]),r=Math.pow(Math.E,(n[2]-o*n[0])/i),a=0,s=t.length;a<s;a++){var l=[t[a][0],r*Math.pow(t[a][0],o)];e.push(l)}return{equation:[r,o],points:e,string:"y = "+Math.round(100*r)/100+"x^"+Math.round(100*o)/100}},polynomial:function(t,i){void 0===i&&(i=2);for(var e=[],o=[],r=[],a=0,s=0,l=0,u=i+1;l<u;l++){for(var h=0,d=t.length;h<d;h++)null!=t[h][1]&&(a+=Math.pow(t[h][0],l)*t[h][1]);e.push(a),a=0;for(var f=[],c=0;c<u;c++){for(var h=0,d=t.length;h<d;h++)null!=t[h][1]&&(s+=Math.pow(t[h][0],l+c));f.push(s),s=0}o.push(f)}o.push(e);for(var p=n(o,u),l=0,d=t.length;l<d;l++){for(var v=0,g=0;g<p.length;g++)v+=p[g]*Math.pow(t[l][0],g);r.push([t[l][0],v])}for(var x="y = ",l=p.length-1;l>=0;l--)x+=l>1?Math.round(p[l]*Math.pow(10,l))/Math.pow(10,l)+"x^"+l+" + ":1==l?Math.round(100*p[l])/100+"x + ":Math.round(100*p[l])/100;return{equation:p,points:r,string:x}},lastvalue:function t(n){for(var i=[],t=null,e=0;e<n.length;e++)n[e][1]?(t=n[e][1],i.push([n[e][0],n[e][1]])):i.push([n[e][0],t]);return{equation:[t],points:i,string:""+t}}},e={model:function(t,n,e){if("string"==typeof t)return i[t](n,e)},fit:function(t,n){var i=0,e=1;if(!t)return Number.MAX_VALUE;for(var o=0;o<t.length;++o)i+=t[o]*e,e*=n;return i}};t.exports=e}()},function(t,n,i){"use strict";function e(t){var n=t.fixations.filter(function(n,i){return n[3]&&(n[2].x>0||i===t.fixations.length-1&&t.fixations.length>1)});return N&&t!==N?n.length>1:n.length>0}function o(t,n){var i=0,e=0;return t.forEach(function(t){var o=t.center.y,r=0,a=0;t.fixations.forEach(function(t){var i=1;if(n){var e=Math.abs(n.y-t[1]);i=Math.sqrt(100/(e>1?e:1))}r+=t[1]-o,a+=i});var s=a/t.fixations.length,l=r/t.fixations.length;q.push("    ly =",o.toFixed(0),"d =",l.toFixed(0),"w =",s.toFixed(3)),i+=s*l,e+=s}),i/e}function r(t){var n=A.lines.filter(e);return n.length?o(n,t):0}function a(t,n){if(!N)return q.push("no reference line to apply line-from-saccade computation"),null;var i=A.lineHeight*g,e=A.lineSpacing*x,o=Number.NaN;q.push("comparing dy =",n.toFixed(0),"against",i.toFixed(0),"(next_max =",e.toFixed(0),")"),Math.abs(n)<i?o=0:n>0&&n<e?o=1:n<0&&(o=Math.round(n/A.lineSpacing)),q.push(Number.isNaN(o)?"chaotic jump":"line changed by "+o);var r=null;if(Number.isNaN(o))q.push("cannot estimate line from saccade");else{var a=N.index+o;a>=0&&a<A.lines.length?(r=A.lines[a],q.push("line #",r.index)):q.push("jump outside the line")}return r}function s(t){var n=A.lineSpacing*y,i=m;q.push("estimating line naively, vt =",n.toFixed(0),"ht =",i.toFixed(0));var o=r(t);q.push("    offset",o.toFixed(0));var a=A.lines.map(function(e){var r=Math.abs(t.y-o-e.center.y),a=t.x<e.left?e.left-t.x:t.x>e.right?t.x-e.right:0;return q.push("    proximity to line",e.index,"at y =",e.center.y.toFixed(0),":",a.toFixed(2),r.toFixed(2)),{x:a/i,y:r/n,valid:a<i&&r<n,line:e}}),s=a.reduce(function(t,n){if(!n.valid)return t;if(t){var i=n.x+n.y,o=t.x+t.y,r=o-i,a=e(t.line),s=e(n.line),l=void 0;l=a?s?0:-w:w,r>l&&(t.y<A.lineSpacing/2&&q.push("    replaced! line",n.line.index,"closer than line",t.line.index),t=n)}else t=n;return t},null),l=s?s.line:null;return l?q.push("line #",l.index):q.push("the fixation is not on any line"),l}function l(t){var n=t.y-N.center.y,i=A.lineSpacing*M,r=A.lines.filter(e);if(!r.length)return q.push("cannot verify mapping"),s(t);q.push("verification:"),q.push("    fix-line dy =",n.toFixed(0),"should differ max",i.toFixed(0),"from other offsets");var a=o(r,t);return q.push("avg offset =",a.toFixed(0)),n<a-i||n>a+i?(q.push("--- the line is too far, mapping naively"),s(t)):(q.push("--- OK"),N)}function u(t,n){q.push("word search");var i=h(t.x,n);return i?q.push("    mapped to",i.text,"=",i.line.index+", "+i.index):q.push("    not mapped"),i}function h(t,n){for(var i=Number.MAX_VALUE,e=null,o=0;o<n.length;o++){var r=n[o],a=r.right-r.left,s=r.text.length,l=a;if(r.fixations.length>0||s>b){l=a-a*(Math.min(F,s-b)/s)}var u=r.left,h=r.left+l;if(t>=u&&t<h)e=r,i=0;else{var d=Math.max(u-t,t-h);d<i&&(i=d,e=r)}}return i>m&&(e=null),e}var d=i(0),f=i(1).Line,c=i(3),p=i(2),v={init:function(t){t=t||{},t.dgwm=t.dgwm||{},d.enabled=t.verbose,g=t.dgwm.saccadeYThresholdInLines||1.2,x=t.dgwm.saccadeYThresholdInSpacings||1.75,m=t.dgwm.fixationXDistFromLineThresholdInPixels||200,y=t.dgwm.fixationYDistFromLineThresholdInSpaces||.65,M=t.dgwm.fixationYOffsetDiffThresholdInLines||1,w=t.dgwm.emptyLineSuperority||.3,b=t.dgwm.effectiveLengthReductionMinWordLength||2,F=t.dgwm.effectiveLengthReductionInChars||3,f.init(t.line),c.init(t.textModel),E=p.Detector,E.init(t.fixationDetector),L=d.forModule("DGWM")},feedFixation:function(t){return t?(_=t,q=L.start("feedFixation"),q.push("fix",""+t),0===t.x&&t.y===-1?(q.push("...invalid"),L.end(q),null):(N=a(t.saccade.x,t.saccade.y),(N=N?l(t):s(t))?(S=u(t,N.words),t.word=S,S&&N&&(t.line=N.index,S.fixations.push(t),N.addFixation(t)),S&&D.onMapped&&D.onMapped(t),L.end(q),S?S.element:null):(L.end(q),null))):null},feed:function(t,n,i){var e=null;A=c.create(t);var o=E.feed(n,i);return o?e=this.feedFixation(o):_=null,e},setWords:function(t){return t&&(this.reset(),A=c.create(t)),A},reset:function(){c.reset(),E.reset(),N=null,S=null,_=null,A=null},callbacks:function(t){if(!t)return D;D.onMapped=t.onMapped},currentWord:function(){return S},mappedFix:function(){return _}},g=void 0,x=void 0,m=void 0,y=void 0,M=void 0,w=void 0,b=void 0,F=void 0,E=void 0,L=void 0,q=void 0,A=void 0,N=void 0,S=void 0,_=void 0,D={onMapped:null};t.exports=v}]);