Agriculture-front-end/dist/assets/index.030fe210.js

2 lines
5.7 KiB
JavaScript
Raw Normal View History

function t(t,n,h,r,a){i(t,n,h||0,r||t.length-1,a||e)}function i(t,e,h,r,a){for(;r>h;){if(r-h>600){var s=r-h+1,o=e-h+1,l=Math.log(s),c=.5*Math.exp(2*l/3),m=.5*Math.sqrt(l*c*(s-c)/s)*(o-s/2<0?-1:1);i(t,e,Math.max(h,Math.floor(e-o*c/s+m)),Math.min(r,Math.floor(e+(s-o)*c/s+m)),a)}var f=t[e],u=h,x=r;for(n(t,h,e),a(t[r],f)>0&&n(t,h,r);u<x;){for(n(t,u,x),u++,x--;a(t[u],f)<0;)u++;for(;a(t[x],f)>0;)x--}0===a(t[h],f)?n(t,h,x):n(t,++x,r),x<=e&&(h=x+1),e<=x&&(r=x-1)}}function n(t,i,n){var e=t[i];t[i]=t[n],t[n]=e}function e(t,i){return t<i?-1:t>i?1:0}class h{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let i=this.data;const n=[];if(!d(t,i))return n;const e=this.toBBox,h=[];for(;i;){for(let r=0;r<i.children.length;r++){const a=i.children[r],s=i.leaf?e(a):a;d(t,s)&&(i.leaf?n.push(a):x(t,s)?this._all(a,n):h.push(a))}i=h.pop()}return n}collides(t){let i=this.data;if(!d(t,i))return!1;const n=[];for(;i;){for(let e=0;e<i.children.length;e++){const h=i.children[e],r=i.leaf?this.toBBox(h):h;if(d(t,r)){if(i.leaf||x(t,r))return!0;n.push(h)}}i=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let i=0;i<t.length;i++)this.insert(t[i]);return this}let i=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===i.height)this._splitRoot(this.data,i);else{if(this.data.height<i.height){const t=this.data;this.data=i,i=t}this._insert(i,this.data.height-i.height-1,!0)}else this.data=i;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=p([]),this}remove(t,i){if(!t)return this;let n=this.data;const e=this.toBBox(t),h=[],a=[];let s,o,l;for(;n||h.length;){if(n||(n=h.pop(),o=h[h.length-1],s=a.pop(),l=!0),n.leaf){const e=r(t,n.children,i);if(-1!==e)return n.children.splice(e,1),h.push(n),this._condense(h),this}l||n.leaf||!x(n,e)?o?(s++,n=o.children[s],l=!1):n=null:(h.push(n),a.push(s),s=0,o=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,i){return t.minX-i.minX}compareMinY(t,i){return t.minY-i.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,i){const n=[];for(;t;)t.leaf?i.push(...t.children):n.push(...t.children),t=n.pop();return i}_build(t,i,n,e){const h=n-i+1;let r,s=this._maxEntries;if(h<=s)return r=p(t.slice(i,n+1)),a(r,this.toBBox),r;e||(e=Math.ceil(Math.log(h)/Math.log(s)),s=Math.ceil(h/Math.pow(s,e-1))),r=p([]),r.leaf=!1,r.height=e;const o=Math.ceil(h/s),l=o*Math.ceil(Math.sqrt(s));M(t,i,n,l,this.compareMinX);for(let a=i;a<=n;a+=l){const i=Math.min(a+l-1,n);M(t,a,i,o,this.compareMinY);for(let n=a;n<=i;n+=o){const h=Math.min(n+o-1,i);r.children.push(this._build(t,n,h,e-1))}}return a(r,this.toBBox),r}_chooseSubtree(t,i,n,e){for(;e.push(i),!i.leaf&&e.length-1!==n;){let n,e=1/0,a=1/0;for(let s=0;s<i.children.length;s++){const o=i.children[s],l=m(o),c=(h=t,r=o,(Math.max(r.maxX,h.maxX)-Math.min(r.minX,h.minX))*(Math.max(r.maxY,h.maxY)-Math.min(r.minY,h.minY))-l);c<a?(a=c,e=l<e?l:e,n=o):c===a&&l<e&&(e=l,n=o)}i=n||i.children[0]}var h,r;return i}_insert(t,i,n){const e=n?t:this.toBBox(t),h=[],r=this._chooseSubtree(e,this.data,i,h);for(r.children.push(t),o(r,e);i>=0&&h[i].children.length>this._maxEntries;)this._split(h,i),i--;this._adjustParentBBoxes(e,h,i)}_split(t,i){const n=t[i],e=n.children.length,h=this._minEntries;this._chooseSplitAxis(n,h,e);const r=this._chooseSplitIndex(n,h,e),s=p(n.children.splice(r,n.children.length-r));s.height=n.height,s.leaf=n.leaf,a(n,this.toBBox),a(s,this.toBBox),i?t[i-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,i){this.data=p([t,i]),this.data.height=t.height+1,this.data.leaf=!1,a(this.data,this.toBBox)}_chooseSplitIndex(t,i,n){let e,h=1/0,r=1/0;for(let a=i;a<=n-i;a++){const i=s(t,0,a,this.toBBox),o=s(t,a,n,this.toBBox),l=u(i,o),c=m(i)+m(o);l<h?(h=l,e=a,r=c<r?c:r):l===h&&c<r&&(r=c,e=a)}return e||n-i}_chooseSplitAxis(t,i,n){const e=t.leaf?this.compareMinX:l,h=t.leaf?this.compareMinY:c;this._allDistMargin(t,i,n,e)<this._allDistMargin(t,i,n,h)&&t.chil