zb-admin/docs/assets/useResizeElement.b085afa9.js

2 lines
9.3 KiB
JavaScript

import{R as z,P as G}from"./index.bd00656a.js";var C=function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(i,o){return i[0]===n?(r=o,!0):!1}),r}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),i=this.__entries__[r];return i&&i[1]},t.prototype.set=function(n,r){var i=e(this.__entries__,n);~i?this.__entries__[i][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,i=e(r,n);~i&&r.splice(i,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var i=0,o=this.__entries__;i<o.length;i++){var s=o[i];n.call(r,s[1],s[0])}},t}()}(),M=typeof window<"u"&&typeof document<"u"&&window.document===document,O=function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()}(),P=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(O):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),W=2;function k(e,t){var n=!1,r=!1,i=0;function o(){n&&(n=!1,e()),r&&a()}function s(){P(o)}function a(){var c=Date.now();if(n){if(c-i<W)return;r=!0}else n=!0,r=!1,setTimeout(s,t);i=c}return a}var B=20,H=["top","right","bottom","left","width","height","size","weight"],q=typeof MutationObserver<"u",I=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=k(this.refresh.bind(this),B)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!M||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),q?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!M||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,i=H.some(function(o){return!!~r.indexOf(o)});i&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),D=function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e},d=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||O},S=R(0,0,0,0);function E(e){return parseFloat(e)||0}function T(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,i){var o=e["border-"+i+"-width"];return r+E(o)},0)}function V(e){for(var t=["top","right","bottom","left"],n={},r=0,i=t;r<i.length;r++){var o=i[r],s=e["padding-"+o];n[o]=E(s)}return n}function j(e){var t=e.getBBox();return R(0,0,t.width,t.height)}function N(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return S;var r=d(e).getComputedStyle(e),i=V(r),o=i.left+i.right,s=i.top+i.bottom,a=E(r.width),c=E(r.height);if(r.boxSizing==="border-box"&&(Math.round(a+o)!==t&&(a-=T(r,"left","right")+o),Math.round(c+s)!==n&&(c-=T(r,"top","bottom")+s)),!K(e)){var y=Math.round(a+o)-t,f=Math.round(c+s)-n;Math.abs(y)!==1&&(a-=y),Math.abs(f)!==1&&(c-=f)}return R(i.left,i.top,a,c)}var $=function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof d(e).SVGGraphicsElement}:function(e){return e instanceof d(e).SVGElement&&typeof e.getBBox=="function"}}();function K(e){return e===d(e).document.documentElement}function U(e){return M?$(e)?j(e):N(e):S}function Y(e){var t=e.x,n=e.y,r=e.width,i=e.height,o=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,s=Object.create(o.prototype);return D(s,{x:t,y:n,width:r,height:i,top:n,right:t+r,bottom:i+n,left:t}),s}function R(e,t,n,r){return{x:e,y:t,width:n,height:r}}var J=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=R(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=U(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e}(),Q=function(){function e(t,n){var r=Y(n);D(this,{target:t,contentRect:r})}return e}(),X=function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new C,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new J(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;!n.has(t)||(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(!!this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new Q(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),F=typeof WeakMap<"u"?new WeakMap:new C,L=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=I.getInstance(),r=new X(t,n,this);F.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){L.prototype[e]=function(){var t;return(t=F.get(this))[e].apply(t,arguments)}});var Z=function(){return typeof O.ResizeObserver<"u"?O.ResizeObserver:L}(),b={exports:{}},m={exports:{}};(function(){var e,t,n,r,i,o;typeof performance<"u"&&performance!==null&&performance.now?m.exports=function(){return performance.now()}:typeof process<"u"&&process!==null&&process.hrtime?(m.exports=function(){return(e()-i)/1e6},t=process.hrtime,e=function(){var s;return s=t(),s[0]*1e9+s[1]},r=e(),o=process.uptime()*1e9,i=r-o):Date.now?(m.exports=function(){return Date.now()-n},n=Date.now()):(m.exports=function(){return new Date().getTime()-n},n=new Date().getTime())}).call(z);var ee=m.exports,u=typeof window>"u"?z:window,g=["moz","webkit"],l="AnimationFrame",v=u["request"+l],_=u["cancel"+l]||u["cancelRequest"+l];for(var p=0;!v&&p<g.length;p++)v=u[g[p]+"Request"+l],_=u[g[p]+"Cancel"+l]||u[g[p]+"CancelRequest"+l];if(!v||!_){var x=0,A=0,h=[],te=1e3/60;v=function(e){if(h.length===0){var t=ee(),n=Math.max(0,te-(t-x));x=n+t,setTimeout(function(){var r=h.slice(0);h.length=0;for(var i=0;i<r.length;i++)if(!r[i].cancelled)try{r[i].callback(x)}catch(o){setTimeout(function(){throw o},0)}},Math.round(n))}return h.push({handle:++A,callback:e,cancelled:!1}),A},_=function(e){for(var t=0;t<h.length;t++)h[t].handle===e&&(h[t].cancelled=!0)}}b.exports=function(e){return v.call(u,e)};b.exports.cancel=function(){_.apply(u,arguments)};b.exports.polyfill=function(e){e||(e=u),e.requestAnimationFrame=v,e.cancelAnimationFrame=_};function ne(e){let t;const n=i=>()=>{t=null,e(...i)},r=(...i)=>{t==null&&(t=b.exports(n(i)))};return r.cancel=()=>b.exports.cancel(t),r}const ie=(e,t)=>{let n=null,r=0,i=0;const o=c=>{const{contentRect:y}=c[0];let{width:f,height:w}=y;f=Math.floor(f),w=Math.floor(w),(r!==f||i!==w)&&(r=f,i=w,e&&e.resize())},s=()=>{n=new Z(ne(o)),n.observe(t)},a=()=>{n&&(n.disconnect(),n=null),e&&e.dispose()};return G(()=>{a()}),{addObserver:s}};export{ie as u};