xtendui
Version:
Xtend UI is a powerful frontend library of Tailwind CSS components enhanced by vanilla js. It helps you build interfaces with advanced interactions and animations.
3 lines • 16.8 kB
JavaScript
/*! For license information please see 471.min.js.LICENSE.txt */
"use strict";(globalThis.webpackChunkxtendui=globalThis.webpackChunkxtendui||[]).push([[471],{2510:(t,e,r)=>{r.d(e,{w1:()=>T});var s=r(3212),o=r.n(s);const i=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class n{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,r]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const s=r>>4;if(1!==s)throw new Error(`Got v${s} data when expected v1.`);const o=i[15&r];if(!o)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,2,1),[h]=new Uint32Array(t,4,1);return new n(h,a,o,t)}constructor(t,e=64,r=Float64Array,s){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const o=i.indexOf(this.ArrayType),n=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,h=(8-a%8)%8;if(o<0)throw new Error(`Unexpected typed array class: ${r}.`);s&&s instanceof ArrayBuffer?(this.data=s,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+h,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+n+a+h),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+a+h,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+o]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return a(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,s){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:o,coords:i,nodeSize:n}=this,a=[0,o.length-1,0],h=[];for(;a.length;){const c=a.pop()||0,l=a.pop()||0,u=a.pop()||0;if(l-u<=n){for(let n=u;n<=l;n++){const a=i[2*n],c=i[2*n+1];a>=t&&a<=r&&c>=e&&c<=s&&h.push(o[n])}continue}const p=u+l>>1,m=i[2*p],d=i[2*p+1];m>=t&&m<=r&&d>=e&&d<=s&&h.push(o[p]),(0===c?t<=m:e<=d)&&(a.push(u),a.push(p-1),a.push(1-c)),(0===c?r>=m:s>=d)&&(a.push(p+1),a.push(l),a.push(1-c))}return h}within(t,e,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:o,nodeSize:i}=this,n=[0,s.length-1,0],a=[],h=r*r;for(;n.length;){const c=n.pop()||0,l=n.pop()||0,p=n.pop()||0;if(l-p<=i){for(let r=p;r<=l;r++)u(o[2*r],o[2*r+1],t,e)<=h&&a.push(s[r]);continue}const m=p+l>>1,d=o[2*m],f=o[2*m+1];u(d,f,t,e)<=h&&a.push(s[m]),(0===c?t-r<=d:e-r<=f)&&(n.push(p),n.push(m-1),n.push(1-c)),(0===c?t+r>=d:e+r>=f)&&(n.push(m+1),n.push(l),n.push(1-c))}return a}}function a(t,e,r,s,o,i){if(o-s<=r)return;const n=s+o>>1;h(t,e,n,s,o,i),a(t,e,r,s,n-1,1-i),a(t,e,r,n+1,o,1-i)}function h(t,e,r,s,o,i){for(;o>s;){if(o-s>600){const n=o-s+1,a=r-s+1,c=Math.log(n),l=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*l*(n-l)/n)*(a-n/2<0?-1:1);h(t,e,r,Math.max(s,Math.floor(r-a*l/n+u)),Math.min(o,Math.floor(r+(n-a)*l/n+u)),i)}const n=e[2*r+i];let a=s,l=o;for(c(t,e,s,r),e[2*o+i]>n&&c(t,e,s,o);a<l;){for(c(t,e,a,l),a++,l--;e[2*a+i]<n;)a++;for(;e[2*l+i]>n;)l--}e[2*s+i]===n?c(t,e,s,l):(l++,c(t,e,l,o)),l<=r&&(s=l+1),r<=l&&(o=l-1)}}function c(t,e,r,s){l(t,r,s),l(e,2*r,2*s),l(e,2*r+1,2*s+1)}function l(t,e,r){const s=t[e];t[e]=t[r],t[r]=s}function u(t,e,r,s){const o=t-r,i=e-s;return o*o+i*i}const p={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},m=Math.fround||(d=new Float32Array(1),t=>(d[0]=+t,d[0]));var d;class f{constructor(t){this.options=Object.assign(Object.create(p),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:r,maxZoom:s}=this.options;e&&console.time("total time");const o=`prepare ${t.length} points`;e&&console.time(o),this.points=t;const i=[];for(let e=0;e<t.length;e++){const r=t[e];if(!r.geometry)continue;const[s,o]=r.geometry.coordinates,n=m(k(s)),a=m(w(o));i.push(n,a,1/0,e,-1,1),this.options.reduce&&i.push(0)}let n=this.trees[s+1]=this._createTree(i);e&&console.timeEnd(o);for(let t=s;t>=r;t--){const r=+Date.now();n=this.trees[t]=this._createTree(this._cluster(n,t)),e&&console.log("z%d: %d clusters in %dms",t,n.numItems,+Date.now()-r)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let r=((t[0]+180)%360+360)%360-180;const s=Math.max(-90,Math.min(90,t[1]));let o=180===t[2]?180:((t[2]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)r=-180,o=180;else if(r>o){const t=this.getClusters([r,s,180,i],e),n=this.getClusters([-180,s,o,i],e);return t.concat(n)}const n=this.trees[this._limitZoom(e)],a=n.range(k(r),w(i),k(o),w(s)),h=n.data,c=[];for(const t of a){const e=this.stride*t;c.push(h[e+5]>1?g(h,e,this.clusterProps):this.points[h[e+3]])}return c}getChildren(t){const e=this._getOriginId(t),r=this._getOriginZoom(t),s="No cluster with the specified id.",o=this.trees[r];if(!o)throw new Error(s);const i=o.data;if(e*this.stride>=i.length)throw new Error(s);const n=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=i[e*this.stride],h=i[e*this.stride+1],c=o.within(a,h,n),l=[];for(const e of c){const r=e*this.stride;i[r+4]===t&&l.push(i[r+5]>1?g(i,r,this.clusterProps):this.points[i[r+3]])}if(0===l.length)throw new Error(s);return l}getLeaves(t,e,r){e=e||10,r=r||0;const s=[];return this._appendLeaves(s,t,e,r,0),s}getTile(t,e,r){const s=this.trees[this._limitZoom(t)],o=Math.pow(2,t),{extent:i,radius:n}=this.options,a=n/i,h=(r-a)/o,c=(r+1+a)/o,l={features:[]};return this._addTileFeatures(s.range((e-a)/o,h,(e+1+a)/o,c),s.data,e,r,o,l),0===e&&this._addTileFeatures(s.range(1-a/o,h,1,c),s.data,o,r,o,l),e===o-1&&this._addTileFeatures(s.range(0,h,a/o,c),s.data,-1,r,o,l),l.features.length?l:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const r=this.getChildren(t);if(e++,1!==r.length)break;t=r[0].properties.cluster_id}return e}_appendLeaves(t,e,r,s,o){const i=this.getChildren(e);for(const e of i){const i=e.properties;if(i&&i.cluster?o+i.point_count<=s?o+=i.point_count:o=this._appendLeaves(t,i.cluster_id,r,s,o):o<s?o++:t.push(e),t.length===r)break}return o}_createTree(t){const e=new n(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let r=0;r<t.length;r+=this.stride)e.add(t[r],t[r+1]);return e.finish(),e.data=t,e}_addTileFeatures(t,e,r,s,o,i){for(const n of t){const t=n*this.stride,a=e[t+5]>1;let h,c,l;if(a)h=y(e,t,this.clusterProps),c=e[t],l=e[t+1];else{const r=this.points[e[t+3]];h=r.properties;const[s,o]=r.geometry.coordinates;c=k(s),l=w(o)}const u={type:1,geometry:[[Math.round(this.options.extent*(c*o-r)),Math.round(this.options.extent*(l*o-s))]],tags:h};let p;p=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==p&&(u.id=p),i.features.push(u)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:r,extent:s,reduce:o,minPoints:i}=this.options,n=r/(s*Math.pow(2,e)),a=t.data,h=[],c=this.stride;for(let r=0;r<a.length;r+=c){if(a[r+2]<=e)continue;a[r+2]=e;const s=a[r],l=a[r+1],u=t.within(a[r],a[r+1],n),p=a[r+5];let m=p;for(const t of u){const r=t*c;a[r+2]>e&&(m+=a[r+5])}if(m>p&&m>=i){let t,i=s*p,n=l*p,d=-1;const f=(r/c<<5)+(e+1)+this.points.length;for(const s of u){const h=s*c;if(a[h+2]<=e)continue;a[h+2]=e;const l=a[h+5];i+=a[h]*l,n+=a[h+1]*l,a[h+4]=f,o&&(t||(t=this._map(a,r,!0),d=this.clusterProps.length,this.clusterProps.push(t)),o(t,this._map(a,h)))}a[r+4]=f,h.push(i/m,n/m,1/0,f,-1,m),o&&h.push(d)}else{for(let t=0;t<c;t++)h.push(a[r+t]);if(m>1)for(const t of u){const r=t*c;if(!(a[r+2]<=e)){a[r+2]=e;for(let t=0;t<c;t++)h.push(a[r+t])}}}}return h}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,r){if(t[e+5]>1){const s=this.clusterProps[t[e+6]];return r?Object.assign({},s):s}const s=this.points[t[e+3]].properties,o=this.options.map(s);return r&&o===s?Object.assign({},o):o}}function g(t,e,r){return{type:"Feature",id:t[e+3],properties:y(t,e,r),geometry:{type:"Point",coordinates:[(s=t[e],360*(s-.5)),M(t[e+1])]}};var s}function y(t,e,r){const s=t[e+5],o=s>=1e4?`${Math.round(s/1e3)}k`:s>=1e3?Math.round(s/100)/10+"k":s,i=t[e+6],n=-1===i?{}:Object.assign({},r[i]);return Object.assign(n,{cluster:!0,cluster_id:t[e+3],point_count:s,point_count_abbreviated:o})}function k(t){return t/360+.5}function w(t){const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function M(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function x(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(r[s[o]]=t[s[o]])}return r}class _{static isAdvancedMarkerAvailable(t){return google.maps.marker&&!0===t.getMapCapabilities().isAdvancedMarkersAvailable}static isAdvancedMarker(t){return google.maps.marker&&t instanceof google.maps.marker.AdvancedMarkerElement}static setMap(t,e){this.isAdvancedMarker(t)?t.map=e:t.setMap(e)}static getPosition(t){if(this.isAdvancedMarker(t)){if(t.position){if(t.position instanceof google.maps.LatLng)return t.position;if(t.position.lat&&t.position.lng)return new google.maps.LatLng(t.position.lat,t.position.lng)}return new google.maps.LatLng(null)}return t.getPosition()}static getVisible(t){return!!this.isAdvancedMarker(t)||t.getVisible()}}class v{constructor({markers:t,position:e}){this.markers=t,e&&(e instanceof google.maps.LatLng?this._position=e:this._position=new google.maps.LatLng(e))}get bounds(){if(0===this.markers.length&&!this._position)return;const t=new google.maps.LatLngBounds(this._position,this._position);for(const e of this.markers)t.extend(_.getPosition(e));return t}get position(){return this._position||this.bounds.getCenter()}get count(){return this.markers.filter((t=>_.getVisible(t))).length}push(t){this.markers.push(t)}delete(){this.marker&&(_.setMap(this.marker,null),this.marker=void 0),this.markers.length=0}}class A{constructor({maxZoom:t=16}){this.maxZoom=t}noop({markers:t}){return E(t)}}const E=t=>t.map((t=>new v({position:_.getPosition(t),markers:[t]})));class b extends A{constructor(t){var{maxZoom:e,radius:r=60}=t,s=x(t,["maxZoom","radius"]);super({maxZoom:e}),this.state={zoom:-1},this.superCluster=new f(Object.assign({maxZoom:this.maxZoom,radius:r},s))}calculate(t){let e=!1;const r={zoom:t.map.getZoom()};if(!o()(t.markers,this.markers)){e=!0,this.markers=[...t.markers];const r=this.markers.map((t=>{const e=_.getPosition(t);return{type:"Feature",geometry:{type:"Point",coordinates:[e.lng(),e.lat()]},properties:{marker:t}}}));this.superCluster.load(r)}return e||(this.state.zoom<=this.maxZoom||r.zoom<=this.maxZoom)&&(e=!o()(this.state,r)),this.state=r,e&&(this.clusters=this.cluster(t)),{clusters:this.clusters,changed:e}}cluster({map:t}){return this.superCluster.getClusters([-180,-90,180,90],Math.round(t.getZoom())).map((t=>this.transformCluster(t)))}transformCluster({geometry:{coordinates:[t,e]},properties:r}){if(r.cluster)return new v({markers:this.superCluster.getLeaves(r.cluster_id,1/0).map((t=>t.properties.marker)),position:{lat:e,lng:t}});const s=r.marker;return new v({markers:[s],position:_.getPosition(s)})}}class C{constructor(t,e){this.markers={sum:t.length};const r=e.map((t=>t.count)),s=r.reduce(((t,e)=>t+e),0);this.clusters={count:e.length,markers:{mean:s/e.length,sum:s,min:Math.min(...r),max:Math.max(...r)}}}}class O{render({count:t,position:e},r,s){const o=`<svg fill="${t>Math.max(10,r.clusters.markers.mean)?"#ff0000":"#0000ff"}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 240" width="50" height="50">\n<circle cx="120" cy="120" opacity=".6" r="70" />\n<circle cx="120" cy="120" opacity=".3" r="90" />\n<circle cx="120" cy="120" opacity=".2" r="110" />\n<text x="50%" y="50%" style="fill:#fff" text-anchor="middle" font-size="50" dominant-baseline="middle" font-family="roboto,arial,sans-serif">${t}</text>\n</svg>`,i=`Cluster of ${t} markers`,n=Number(google.maps.Marker.MAX_ZINDEX)+t;if(_.isAdvancedMarkerAvailable(s)){const t=(new DOMParser).parseFromString(o,"image/svg+xml").documentElement;t.setAttribute("transform","translate(0 25)");const r={map:s,position:e,zIndex:n,title:i,content:t};return new google.maps.marker.AdvancedMarkerElement(r)}const a={position:e,zIndex:n,title:i,icon:{url:`data:image/svg+xml;base64,${btoa(o)}`,anchor:new google.maps.Point(25,25)}};return new google.maps.Marker(a)}}class I{constructor(){!function(t,e){for(let r in e.prototype)t.prototype[r]=e.prototype[r]}(I,google.maps.OverlayView)}}var L;!function(t){t.CLUSTERING_BEGIN="clusteringbegin",t.CLUSTERING_END="clusteringend",t.CLUSTER_CLICK="click"}(L||(L={}));const P=(t,e,r)=>{r.fitBounds(e.bounds)};class T extends I{constructor({map:t,markers:e=[],algorithmOptions:r={},algorithm:s=new b(r),renderer:o=new O,onClusterClick:i=P}){super(),this.markers=[...e],this.clusters=[],this.algorithm=s,this.renderer=o,this.onClusterClick=i,t&&this.setMap(t)}addMarker(t,e){this.markers.includes(t)||(this.markers.push(t),e||this.render())}addMarkers(t,e){t.forEach((t=>{this.addMarker(t,!0)})),e||this.render()}removeMarker(t,e){const r=this.markers.indexOf(t);return-1!==r&&(_.setMap(t,null),this.markers.splice(r,1),e||this.render(),!0)}removeMarkers(t,e){let r=!1;return t.forEach((t=>{r=this.removeMarker(t,!0)||r})),r&&!e&&this.render(),r}clearMarkers(t){this.markers.length=0,t||this.render()}render(){const t=this.getMap();if(t instanceof google.maps.Map&&t.getProjection()){google.maps.event.trigger(this,L.CLUSTERING_BEGIN,this);const{clusters:e,changed:r}=this.algorithm.calculate({markers:this.markers,map:t,mapCanvasProjection:this.getProjection()});if(r||null==r){const t=new Set;for(const r of e)1==r.markers.length&&t.add(r.markers[0]);const r=[];for(const e of this.clusters)null!=e.marker&&(1==e.markers.length?t.has(e.marker)||_.setMap(e.marker,null):r.push(e.marker));this.clusters=e,this.renderClusters(),requestAnimationFrame((()=>r.forEach((t=>_.setMap(t,null)))))}google.maps.event.trigger(this,L.CLUSTERING_END,this)}}onAdd(){this.idleListener=this.getMap().addListener("idle",this.render.bind(this)),this.render()}onRemove(){google.maps.event.removeListener(this.idleListener),this.reset()}reset(){this.markers.forEach((t=>_.setMap(t,null))),this.clusters.forEach((t=>t.delete())),this.clusters=[]}renderClusters(){const t=new C(this.markers,this.clusters),e=this.getMap();this.clusters.forEach((r=>{1===r.markers.length?r.marker=r.markers[0]:(r.marker=this.renderer.render(r,t,e),r.markers.forEach((t=>_.setMap(t,null))),this.onClusterClick&&r.marker.addListener("click",(t=>{google.maps.event.trigger(this,L.CLUSTER_CLICK,r),this.onClusterClick(t,r,e)}))),_.setMap(r.marker,e)}))}}},2807:(t,e,r)=>{var s=r(7508),o=r(6671),i=r(1832),n=r(8485),a=r(9065),h=r(6964),c=r(197),l=r(2817),u=r(1027),p=r(6101),m=!p&&u("map",TypeError),d=h((function(){var t=this.iterator,e=n(o(this.next,t));if(!(this.done=!!e.done))return c(t,this.mapper,[e.value,this.counter++],!0)}));s({target:"Iterator",proto:!0,real:!0,forced:p||m},{map:function(t){n(this);try{i(t)}catch(t){l(this,"throw",t)}return m?o(m,this,t):new d(a(this),{mapper:t})}})},3212:t=>{t.exports=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var s,o,i;if(Array.isArray(e)){if((s=e.length)!=r.length)return!1;for(o=s;0!==o--;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((s=(i=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(o=s;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=s;0!==o--;){var n=i[o];if(!t(e[n],r[n]))return!1}return!0}return e!=e&&r!=r}},9370:(t,e,r)=>{var s=r(7508),o=r(6671),i=r(9282),n=r(1832),a=r(8485),h=r(9065),c=r(2817),l=r(1027)("forEach",TypeError);s({target:"Iterator",proto:!0,real:!0,forced:l},{forEach:function(t){a(this);try{n(t)}catch(t){c(this,"throw",t)}if(l)return o(l,this,t);var e=h(this),r=0;i(e,(function(e){t(e,r++)}),{IS_RECORD:!0})}})}}]);
//# sourceMappingURL=471.min.js.map