@kong-ui-public/dashboard-renderer 5.1.2 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- (function(b,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue"),require("@kong-ui-public/analytics-utilities"),require("@kong-ui-public/analytics-chart"),require("swrv"),require("axios"),require("@kong-ui-public/i18n"),require("@kong-ui-public/analytics-config-store"),require("@kong-ui-public/analytics-metric-provider"),require("@kong/icons")):typeof define=="function"&&define.amd?define(["exports","vue","@kong-ui-public/analytics-utilities","@kong-ui-public/analytics-chart","swrv","axios","@kong-ui-public/i18n","@kong-ui-public/analytics-config-store","@kong-ui-public/analytics-metric-provider","@kong/icons"],a):(b=typeof globalThis<"u"?globalThis:b||self,a(b["kong-ui-public-dashboard-renderer"]={},b.Vue,b["kong-ui-public-analytics-utilities"],b["kong-ui-public-analytics-chart"],b.swrv,b.axios,b["kong-ui-public-i18n"],b["kong-ui-public-analytics-config-store"],b["kong-ui-public-analytics-metric-provider"],b.KongIcons))})(this,function(b,a,z,Y,ke,ei,Me,Ie,Be,Pe){"use strict";var Zt=Object.defineProperty;var ot=b=>{throw TypeError(b)};var Jt=(b,a,z)=>a in b?Zt(b,a,{enumerable:!0,configurable:!0,writable:!0,value:z}):b[a]=z;var at=(b,a,z)=>Jt(b,typeof a!="symbol"?a+"":a,z),He=(b,a,z)=>a.has(b)||ot("Cannot "+z);var v=(b,a,z)=>(He(b,a,"read from private field"),z?z.call(b):a.get(b)),H=(b,a,z)=>a.has(b)?ot("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(b):a.set(b,z),A=(b,a,z,Y)=>(He(b,a,"write to private field"),Y?Y.call(b,z):a.set(b,z),z),L=(b,a,z)=>(He(b,a,"access private method"),z);var fe=(b,a,z,Y)=>({set _(ke){A(b,a,ke,z)},get _(){return v(b,a,Y)}});var q,te,ie,Q,le,se,he,$,re,M,de,F,ne,j,ce,Ee,D,lt,ht,dt,ct,ut,Ce,Le,Oe,xe,ft,Re;var qe=(f=>(f.VALIDATING="VALIDATING",f.VALIDATING_HAS_DATA="VALIDATING_HAS_DATA",f.PENDING="PENDING",f.SUCCESS="SUCCESS",f.SUCCESS_HAS_DATA="SUCCESS_HAS_DATA",f.ERROR="ERROR",f.STALE_IF_ERROR="STALE_IF_ERROR",f))(qe||{});const gt=f=>{var e,t,i,s,r;return f?!!((e=Object.keys(f))!=null&&e.length||(t=f.data)!=null&&t.length||(s=(i=f.data)==null?void 0:i.data)!=null&&s.length||!((r=f.data)!=null&&r.data)&&typeof f.data=="object"&&Object.keys(f==null?void 0:f.data).length):!1};function mt(f=a.ref({}),e,t,i=gt){const s=a.ref("PENDING");return a.watchEffect(()=>{const r=i(f.value);if(f.value&&r&&t.value){s.value="VALIDATING_HAS_DATA";return}if(f.value&&t.value){s.value="VALIDATING";return}if(f.value&&e.value){s.value="STALE_IF_ERROR";return}if(f.value===void 0&&!e.value){s.value="PENDING";return}if(f.value&&!e.value&&r){s.value="SUCCESS_HAS_DATA";return}if(f.value&&!e.value){s.value="SUCCESS";return}f.value===void 0&&e&&(s.value="ERROR")}),{state:s,swrvState:qe}}const pt={renderer:{noQueryBridge:"No query bridge provided. Unable to render dashboard.",trendRange:{"24h":"Last 24-Hour Summary","7d":"Last 7-Day Summary","30d":"Last 30-Day Summary"},edit:"Edit",remove:"Remove"},queryDataProvider:{timeRangeExceeded:"The time range for this report is outside of your organization's data retention period"},csvExport:{defaultFilename:"Chart Export",exportAsCsv:"Export as CSV"},jumpToExplore:"Explore"};function yt(){const f=Me.createI18n("en-us",pt);return{i18n:f,i18nT:Me.i18nTComponent(f)}}const ge=170,X="analytics-query-provider",Te="{entity-id}",$e="{cp-id}",Fe="{timeframe}",Ge=30*1e3;function _t(){const f=a.inject(X);return{evaluateFeatureFlag:(t,i)=>f?f.evaluateFeatureFlagFn(t,i):i}}function vt(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Ue={exports:{}};(function(f){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(c,d,l){this.fn=c,this.context=d,this.once=l||!1}function r(c,d,l,h,g){if(typeof l!="function")throw new TypeError("The listener must be a function");var p=new s(l,h||c,g),y=t?t+d:d;return c._events[y]?c._events[y].fn?c._events[y]=[c._events[y],p]:c._events[y].push(p):(c._events[y]=p,c._eventsCount++),c}function o(c,d){--c._eventsCount===0?c._events=new i:delete c._events[d]}function n(){this._events=new i,this._eventsCount=0}n.prototype.eventNames=function(){var d=[],l,h;if(this._eventsCount===0)return d;for(h in l=this._events)e.call(l,h)&&d.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(l)):d},n.prototype.listeners=function(d){var l=t?t+d:d,h=this._events[l];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,p=h.length,y=new Array(p);g<p;g++)y[g]=h[g].fn;return y},n.prototype.listenerCount=function(d){var l=t?t+d:d,h=this._events[l];return h?h.fn?1:h.length:0},n.prototype.emit=function(d,l,h,g,p,y){var _=t?t+d:d;if(!this._events[_])return!1;var m=this._events[_],T=arguments.length,N,k;if(m.fn){switch(m.once&&this.removeListener(d,m.fn,void 0,!0),T){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,l),!0;case 3:return m.fn.call(m.context,l,h),!0;case 4:return m.fn.call(m.context,l,h,g),!0;case 5:return m.fn.call(m.context,l,h,g,p),!0;case 6:return m.fn.call(m.context,l,h,g,p,y),!0}for(k=1,N=new Array(T-1);k<T;k++)N[k-1]=arguments[k];m.fn.apply(m.context,N)}else{var R=m.length,x;for(k=0;k<R;k++)switch(m[k].once&&this.removeListener(d,m[k].fn,void 0,!0),T){case 1:m[k].fn.call(m[k].context);break;case 2:m[k].fn.call(m[k].context,l);break;case 3:m[k].fn.call(m[k].context,l,h);break;case 4:m[k].fn.call(m[k].context,l,h,g);break;default:if(!N)for(x=1,N=new Array(T-1);x<T;x++)N[x-1]=arguments[x];m[k].fn.apply(m[k].context,N)}}return!0},n.prototype.on=function(d,l,h){return r(this,d,l,h,!1)},n.prototype.once=function(d,l,h){return r(this,d,l,h,!0)},n.prototype.removeListener=function(d,l,h,g){var p=t?t+d:d;if(!this._events[p])return this;if(!l)return o(this,p),this;var y=this._events[p];if(y.fn)y.fn===l&&(!g||y.once)&&(!h||y.context===h)&&o(this,p);else{for(var _=0,m=[],T=y.length;_<T;_++)(y[_].fn!==l||g&&!y[_].once||h&&y[_].context!==h)&&m.push(y[_]);m.length?this._events[p]=m.length===1?m[0]:m:o(this,p)}return this},n.prototype.removeAllListeners=function(d){var l;return d?(l=t?t+d:d,this._events[l]&&o(this,l)):(this._events=new i,this._eventsCount=0),this},n.prototype.off=n.prototype.removeListener,n.prototype.addListener=n.prototype.on,n.prefixed=t,n.EventEmitter=n,f.exports=n})(Ue);var wt=Ue.exports;const Et=vt(wt);class We extends Error{constructor(e){super(e),this.name="TimeoutError"}}class bt extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Ve=f=>globalThis.DOMException===void 0?new bt(f):new DOMException(f),Ke=f=>{const e=f.reason===void 0?Ve("This operation was aborted."):f.reason;return e instanceof Error?e:Ve(e)};function Ct(f,e){const{milliseconds:t,fallback:i,message:s,customTimers:r={setTimeout,clearTimeout}}=e;let o,n;const d=new Promise((l,h)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){const{signal:p}=e;p.aborted&&h(Ke(p)),n=()=>{h(Ke(p))},p.addEventListener("abort",n,{once:!0})}if(t===Number.POSITIVE_INFINITY){f.then(l,h);return}const g=new We;o=r.setTimeout.call(void 0,()=>{if(i){try{l(i())}catch(p){h(p)}return}typeof f.cancel=="function"&&f.cancel(),s===!1?l():s instanceof Error?h(s):(g.message=s??`Promise timed out after ${t} milliseconds`,h(g))},t),(async()=>{try{l(await f)}catch(p){h(p)}})()}).finally(()=>{d.clear(),n&&e.signal&&e.signal.removeEventListener("abort",n)});return d.clear=()=>{r.clearTimeout.call(void 0,o),o=void 0},d}function xt(f,e,t){let i=0,s=f.length;for(;s>0;){const r=Math.trunc(s/2);let o=i+r;t(f[o],e)<=0?(i=++o,s-=r+1):s=r}return i}class Rt{constructor(){H(this,q,[])}enqueue(e,t){t={priority:0,...t};const i={priority:t.priority,id:t.id,run:e};if(this.size===0||v(this,q)[this.size-1].priority>=t.priority){v(this,q).push(i);return}const s=xt(v(this,q),i,(r,o)=>o.priority-r.priority);v(this,q).splice(s,0,i)}setPriority(e,t){const i=v(this,q).findIndex(r=>r.id===e);if(i===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);const[s]=v(this,q).splice(i,1);this.enqueue(s.run,{priority:t,id:e})}dequeue(){const e=v(this,q).shift();return e==null?void 0:e.run}filter(e){return v(this,q).filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return v(this,q).length}}q=new WeakMap;class kt extends Et{constructor(t){var i,s;super();H(this,D);H(this,te);H(this,ie);H(this,Q,0);H(this,le);H(this,se);H(this,he,0);H(this,$);H(this,re);H(this,M);H(this,de);H(this,F,0);H(this,ne);H(this,j);H(this,ce);H(this,Ee,1n);at(this,"timeout");if(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Rt,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${((i=t.intervalCap)==null?void 0:i.toString())??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${((s=t.interval)==null?void 0:s.toString())??""}\` (${typeof t.interval})`);A(this,te,t.carryoverConcurrencyCount),A(this,ie,t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0),A(this,le,t.intervalCap),A(this,se,t.interval),A(this,M,new t.queueClass),A(this,de,t.queueClass),this.concurrency=t.concurrency,this.timeout=t.timeout,A(this,ce,t.throwOnTimeout===!0),A(this,j,t.autoStart===!1)}get concurrency(){return v(this,ne)}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);A(this,ne,t),L(this,D,xe).call(this)}setPriority(t,i){v(this,M).setPriority(t,i)}async add(t,i={}){return i.id??(i.id=(fe(this,Ee)._++).toString()),i={timeout:this.timeout,throwOnTimeout:v(this,ce),...i},new Promise((s,r)=>{v(this,M).enqueue(async()=>{var o;fe(this,F)._++,fe(this,Q)._++;try{(o=i.signal)==null||o.throwIfAborted();let n=t({signal:i.signal});i.timeout&&(n=Ct(Promise.resolve(n),{milliseconds:i.timeout})),i.signal&&(n=Promise.race([n,L(this,D,ft).call(this,i.signal)]));const c=await n;s(c),this.emit("completed",c)}catch(n){if(n instanceof We&&!i.throwOnTimeout){s();return}r(n),this.emit("error",n)}finally{L(this,D,dt).call(this)}},i),this.emit("add"),L(this,D,Ce).call(this)})}async addAll(t,i){return Promise.all(t.map(async s=>this.add(s,i)))}start(){return v(this,j)?(A(this,j,!1),L(this,D,xe).call(this),this):this}pause(){A(this,j,!0)}clear(){A(this,M,new(v(this,de)))}async onEmpty(){v(this,M).size!==0&&await L(this,D,Re).call(this,"empty")}async onSizeLessThan(t){v(this,M).size<t||await L(this,D,Re).call(this,"next",()=>v(this,M).size<t)}async onIdle(){v(this,F)===0&&v(this,M).size===0||await L(this,D,Re).call(this,"idle")}get size(){return v(this,M).size}sizeBy(t){return v(this,M).filter(t).length}get pending(){return v(this,F)}get isPaused(){return v(this,j)}}te=new WeakMap,ie=new WeakMap,Q=new WeakMap,le=new WeakMap,se=new WeakMap,he=new WeakMap,$=new WeakMap,re=new WeakMap,M=new WeakMap,de=new WeakMap,F=new WeakMap,ne=new WeakMap,j=new WeakMap,ce=new WeakMap,Ee=new WeakMap,D=new WeakSet,lt=function(){return v(this,ie)||v(this,Q)<v(this,le)},ht=function(){return v(this,F)<v(this,ne)},dt=function(){fe(this,F)._--,L(this,D,Ce).call(this),this.emit("next")},ct=function(){L(this,D,Oe).call(this),L(this,D,Le).call(this),A(this,re,void 0)},ut=function(){const t=Date.now();if(v(this,$)===void 0){const i=v(this,he)-t;if(i<0)A(this,Q,v(this,te)?v(this,F):0);else return v(this,re)===void 0&&A(this,re,setTimeout(()=>{L(this,D,ct).call(this)},i)),!0}return!1},Ce=function(){if(v(this,M).size===0)return v(this,$)&&clearInterval(v(this,$)),A(this,$,void 0),this.emit("empty"),v(this,F)===0&&this.emit("idle"),!1;if(!v(this,j)){const t=!v(this,D,ut);if(v(this,D,lt)&&v(this,D,ht)){const i=v(this,M).dequeue();return i?(this.emit("active"),i(),t&&L(this,D,Le).call(this),!0):!1}}return!1},Le=function(){v(this,ie)||v(this,$)!==void 0||(A(this,$,setInterval(()=>{L(this,D,Oe).call(this)},v(this,se))),A(this,he,Date.now()+v(this,se)))},Oe=function(){v(this,Q)===0&&v(this,F)===0&&v(this,$)&&(clearInterval(v(this,$)),A(this,$,void 0)),A(this,Q,v(this,te)?v(this,F):0),L(this,D,xe).call(this)},xe=function(){for(;L(this,D,Ce).call(this););},ft=async function(t){return new Promise((i,s)=>{t.addEventListener("abort",()=>{s(t.reason)},{once:!0})})},Re=async function(t,i){return new Promise(s=>{const r=()=>{i&&!i()||(this.off(t,r),s())};this.on(t,r)})};const ee={useI18n:yt,useEvaluateFeatureFlag:_t,useRequestQueue:()=>{const f=Ie.useAnalyticsConfigStore(),e=a.inject(X);if(!e)return;if(e.queryFnOverride){console.warn("Detected incorrect use of useRequestQueue. This composable should not be used in nested components. Please discuss with team-data or report an issue if you feel you have a use case.");return}const t=new kt({carryoverConcurrencyCount:!0,concurrency:f.maxParallelRequests,interval:f.requestInterval,intervalCap:f.requestIntervalCap}),i={...e,queryFnOverride:!0,queryFn:(s,r)=>t.add(()=>e.queryFn(s,r),{throwOnTimeout:!0})};a.provide(X,i)}},De=a.defineComponent({__name:"QueryDataProvider",props:{context:{},query:{},queryReady:{type:Boolean},refreshCounter:{}},emits:["chart-data","queryComplete"],setup(f,{emit:e}){const t=f,i=e,{i18n:s}=ee.useI18n(),r=a.inject(X),o=()=>t.queryReady&&r?JSON.stringify([t.query,t.context,t.refreshCounter]):null,n=new AbortController;a.onUnmounted(()=>{n.abort()});const c=(T,N,k)=>{const R=[];return N&&R.push(...N),R.push(...z.stripUnknownFilters(T,k)),R},{data:d,error:l,isValidating:h}=ke(o,async()=>{var T,N,k,R;try{let{datasource:x,...S}=t.query;x||(x="basic");const B=c(x,t.query.filters,t.context.filters);let I=t.query.time_range;I?I.tz||(I={...I,tz:t.context.tz}):I={...t.context.timeSpec,tz:t.context.tz};const be={datasource:x,query:{...S,time_range:I,filters:B}};return r==null?void 0:r.queryFn(be,n)}catch(x){y.value=((N=(T=x==null?void 0:x.response)==null?void 0:T.data)==null?void 0:N.message)==="Range not allowed for this tier"?s.t("queryDataProvider.timeRangeExceeded"):((R=(k=x==null?void 0:x.response)==null?void 0:k.data)==null?void 0:R.message)||(x==null?void 0:x.message)}finally{i("queryComplete")}},{refreshInterval:t.context.refreshInterval,revalidateOnFocus:!1}),{state:g,swrvState:p}=mt(d,l,h),y=a.ref(null),_=a.computed(()=>g.value===p.ERROR||!!y.value),m=a.computed(()=>!t.queryReady||g.value===p.PENDING);return a.watch(d,T=>{T&&i("chart-data",T)}),(T,N)=>{const k=a.resolveComponent("KSkeleton"),R=a.resolveComponent("KEmptyState");return m.value||!a.unref(d)&&!_.value?(a.openBlock(),a.createBlock(k,{key:0,class:"chart-skeleton",type:"table"})):_.value?(a.openBlock(),a.createBlock(R,{key:1,"action-button-visible":!1,"data-testid":"chart-empty-state","icon-variant":"error"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(y.value),1)]),_:1})):a.unref(d)?a.renderSlot(T.$slots,"default",{key:2,data:a.unref(d)}):a.createCommentVNode("",!0)}}}),Tt=a.defineComponent({__name:"SimpleChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){a.useCssVars(i=>({"35a26ebf":`${i.height}px`}));const e=f,t=a.computed(()=>e.chartOptions.type==="single_value");return(i,s)=>(a.openBlock(),a.createBlock(De,{context:i.context,query:i.query,"query-ready":i.queryReady,"refresh-counter":i.refreshCounter},{default:a.withCtx(({data:r})=>[a.createElementVNode("div",{class:a.normalizeClass(["analytics-chart",{"single-value":t.value}])},[a.createVNode(a.unref(Y.SimpleChart),{"chart-data":r,"chart-options":i.chartOptions,"synthetics-data-key":t.value?void 0:i.chartOptions.syntheticsDataKey},null,8,["chart-data","chart-options","synthetics-data-key"])],2)]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),J=(f,e)=>{const t=f.__vccOpts||f;for(const[i,s]of e)t[i]=s;return t},Ye=J(Tt,[["__scopeId","data-v-65cc8607"]]),Dt={class:"analytics-chart"},ze=J(a.defineComponent({__name:"BaseAnalyticsChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{},extraProps:{}},emits:["edit-tile","chart-data","zoom-time-range"],setup(f,{emit:e}){const t=f,i=e,{i18n:s}=ee.useI18n(),{evaluateFeatureFlag:r}=ee.useEvaluateFeatureFlag(),o=r("explore-v4-fine-granularity",!1),n=a.computed(()=>({type:t.chartOptions.type,stacked:t.chartOptions.stacked??!1,chartDatasetColors:t.chartOptions.chartDatasetColors,threshold:t.chartOptions.threshold})),c=()=>{i("edit-tile")},d=l=>{i("chart-data",l)};return(l,h)=>{const g=a.resolveComponent("KDropdownItem");return a.openBlock(),a.createBlock(De,{context:l.context,query:l.query,"query-ready":l.queryReady,"refresh-counter":l.refreshCounter,onChartData:d},{default:a.withCtx(({data:p})=>[a.createElementVNode("div",Dt,[a.createVNode(a.unref(Y.AnalyticsChart),a.mergeProps({"allow-csv-export":l.chartOptions.allowCsvExport,"chart-data":p,"chart-options":n.value,"legend-position":"bottom","show-menu":l.context.editable,"synthetics-data-key":l.chartOptions.syntheticsDataKey,"timeseries-zoom":a.unref(o)&&!l.query.time_range,"tooltip-title":""},l.extraProps,{onZoomTimeRange:h[0]||(h[0]=y=>i("zoom-time-range",y))}),a.createSlots({_:2},[l.context.editable?{name:"menu-items",fn:a.withCtx(()=>[a.createVNode(g,{onClick:c},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(a.unref(s).t("renderer.edit")),1)]),_:1})]),key:"0"}:void 0]),1040,["allow-csv-export","chart-data","chart-options","show-menu","synthetics-data-key","timeseries-zoom"])])]),_:1},8,["context","query","query-ready","refresh-counter"])}}}),[["__scopeId","data-v-a9ee3db9"]]),je=a.defineComponent({__name:"BarChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(a.openBlock(),a.createBlock(ze,{"chart-options":e.chartOptions,context:e.context,"extra-props":{showAnnotations:!1},height:e.height,query:e.query,"query-ready":e.queryReady,"refresh-counter":e.refreshCounter},null,8,["chart-options","context","height","query","query-ready","refresh-counter"]))}}),Xe=a.defineComponent({__name:"TimeseriesChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},emits:["zoom-time-range"],setup(f,{emit:e}){const t=e;return(i,s)=>(a.openBlock(),a.createBlock(ze,{"chart-options":i.chartOptions,context:i.context,height:i.height,query:i.query,"query-ready":i.queryReady,"refresh-counter":i.refreshCounter,onZoomTimeRange:s[0]||(s[0]=r=>t("zoom-time-range",r))},null,8,["chart-options","context","height","query","query-ready","refresh-counter"]))}}),zt={class:"metric-card-tile-wrapper"},St=J(a.defineComponent({__name:"GoldenSignalsRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){const e=f,t=a.computed(()=>{const s=e.context.timeSpec;if(s.type==="absolute")return new z.Timeframe({key:"custom",timeframeText:"custom",display:"custom",startCustom:s.start,endCustom:s.end,timeframeLength:()=>s.end.getTime()-s.start.getTime(),defaultResponseGranularity:"daily",dataGranularity:"daily",isRelative:!1,allowedTiers:["free","plus","enterprise"]});const r=z.TimePeriods.get(s.time_range);if(!r)throw new Error("Unknown time range");return r}),i=a.computed(()=>{var r,o;const s=(r=e.query)==null?void 0:r.datasource;if(s&&s!=="advanced"&&s!=="basic")throw new Error(`Invalid datasource value: ${s}`);return{datasource:(o=e.query)==null?void 0:o.datasource,overrideTimeframe:t.value,tz:e.context.tz,additionalFilter:e.context.filters,longCardTitles:e.chartOptions.longCardTitles,percentileLatency:e.chartOptions.percentileLatency,refreshInterval:e.context.refreshInterval,queryReady:e.queryReady,refreshCounter:e.refreshCounter}});return(s,r)=>(a.openBlock(),a.createElementBlock("div",zt,[a.createVNode(a.unref(Be.MetricsProvider),a.normalizeProps(a.guardReactiveProps(i.value)),{default:a.withCtx(()=>[a.createVNode(a.unref(Be.MetricsConsumer))]),_:1},16)]))}}),[["__scopeId","data-v-bd5889d1"]]),Qe="#6c7489",Ze="20px",Je="20px",Nt={class:"fallback-entity-link","data-testid":"entity-link-parent"},et=a.defineComponent({__name:"FallbackEntityLink",props:{entityLinkData:{}},setup(f){return(e,t)=>(a.openBlock(),a.createElementBlock("div",Nt,a.toDisplayString(e.entityLinkData.label),1))}}),At=a.defineComponent({__name:"TopNTableRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){const e=f,t=a.inject(X),i=a.defineAsyncComponent(async()=>{if(t!=null&&t.fetchComponent)try{return await t.fetchComponent("EntityLink")}catch{return et}return et}),s=r=>{var o;if((o=e.chartOptions)!=null&&o.entityLink)if(r.id.includes(":")){const[n,c]=r.id.split(":");return e.chartOptions.entityLink.replace($e,n).replace(Te,c)}else return e.chartOptions.entityLink.replace(Te,r.id);return""};return(r,o)=>(a.openBlock(),a.createBlock(De,{context:r.context,query:r.query,"query-ready":r.queryReady,"refresh-counter":r.refreshCounter},{default:a.withCtx(({data:n})=>[a.createVNode(a.unref(Y.TopNTable),{data:n,"synthetics-data-key":r.chartOptions.syntheticsDataKey},a.createSlots({_:2},[e.chartOptions.entityLink?{name:"name",fn:a.withCtx(({record:c})=>[a.createVNode(a.unref(i),{"entity-link-data":{id:c.id,label:c.name,deleted:c.deleted},"external-link":s(c)},null,8,["entity-link-data","external-link"])]),key:"0"}:void 0]),1032,["data","synthetics-data-key"])]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),Ht=a.defineComponent({__name:"DonutChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(a.openBlock(),a.createBlock(ze,{"chart-options":e.chartOptions,context:e.context,height:e.height,query:e.query,"query-ready":e.queryReady,"refresh-counter":e.refreshCounter},null,8,["chart-options","context","height","query","query-ready","refresh-counter"]))}}),Lt=["data-testid"],Ot={key:0,class:"tile-header"},Mt=["data-testid"],It=["data-testid"],Bt=["data-testid"],Pt=["data-testid"],qt=J(a.defineComponent({__name:"DashboardTile",props:{definition:{},context:{},height:{default:ge},queryReady:{type:Boolean},refreshCounter:{},tileId:{}},emits:["edit-tile","remove-tile","zoom-time-range"],setup(f,{emit:e}){a.useCssVars(E=>({"050eccb7":`${E.height}px`}));const t=parseInt(Je,10),i=f,s=e,r=a.inject(X),{i18n:o}=ee.useI18n(),n=a.ref(),c=a.ref(!1),d=a.ref(),l=a.ref(!1),h=a.ref("");a.onMounted(async()=>{var E;h.value=await((E=r==null?void 0:r.exploreBaseUrl)==null?void 0:E.call(r))??""}),a.watch(()=>i.definition,async()=>{await a.nextTick(),d.value&&(l.value=d.value.scrollWidth>d.value.clientWidth)},{immediate:!0,deep:!0});const g=a.computed(()=>{if(!h.value||!i.definition.query||!_.value)return"";const E=[...i.context.filters,...i.definition.query.filters??[]],K=i.definition.query.dimensions??[],U=new Set(["portal","api"]);if(E.some(Z=>"dimension"in Z&&U.has(Z.dimension)||"field"in Z&&U.has(Z.field))||K.some(Z=>U.has(Z)))return"";const Ae={filters:E,metrics:i.definition.query.metrics??[],dimensions:K,time_range:i.definition.query.time_range||i.context.timeSpec,granularity:i.definition.query.granularity||R.value},ue=["advanced","ai"].includes(i.definition.query.datasource)?i.definition.query.datasource:"advanced";return`${h.value}?q=${JSON.stringify(Ae)}&d=${ue}&c=${i.definition.chart.type}`}),p=a.computed(()=>o.t("csvExport.defaultFilename")),y=a.computed(()=>_.value&&(m.value||i.context.editable)||!!k.value),_=a.computed(()=>!["golden_signals","top_n","gauge"].includes(i.definition.chart.type)),m=a.computed(()=>!!g.value||"allowCsvExport"in i.definition.chart&&i.definition.chart.allowCsvExport||i.context.editable),T={timeseries_line:Xe,timeseries_bar:Xe,horizontal_bar:je,vertical_bar:je,gauge:Ye,donut:Ht,golden_signals:St,top_n:At,slottable:void 0,single_value:Ye},N=a.computed(()=>{const E=T[i.definition.chart.type];return E&&{component:E,rendererProps:{query:i.definition.query,context:i.context,queryReady:i.queryReady,chartOptions:i.definition.chart,height:i.height-t*2,refreshCounter:i.refreshCounter}}}),k=a.computed(()=>{var K;const E=(K=i.definition.query)==null?void 0:K.time_range;if((E==null?void 0:E.type)==="relative"){const U=z.TimePeriods.get(z.TIMEFRAME_LOOKUP[E.time_range]);return U?U.display:(console.warn("Did not recognize the given relative time range:",E.time_range),E.time_range)}else if((E==null?void 0:E.type)==="absolute"){const U=E.tz||"Etc/UTC";return`${z.formatTime(E.start,{short:!0,tz:U})} - ${z.formatTime(E.end,{short:!0,tz:U})}`}return null}),R=a.computed(()=>n.value?z.msToGranularity(n.value.meta.granularity_ms):void 0),x=()=>{s("edit-tile",i.definition)},S=()=>{s("remove-tile",i.definition)},B=E=>{n.value=E},I=E=>{c.value=E},be=()=>{I(!0)};return(E,K)=>{const U=a.resolveComponent("KTooltip"),Ae=a.resolveComponent("KBadge"),ue=a.resolveComponent("KDropdownItem"),Z=a.resolveComponent("KDropdown");return a.openBlock(),a.createElementBlock("div",{class:a.normalizeClass(["tile-boundary",{editable:E.context.editable}]),"data-testid":`tile-${E.tileId}`},[E.definition.chart.type!=="slottable"?(a.openBlock(),a.createElementBlock("div",Ot,[a.createVNode(U,{class:"title-tooltip",disabled:!l.value,"max-width":"500",text:E.definition.chart.chartTitle},{default:a.withCtx(()=>[a.createElementVNode("div",{ref_key:"titleRef",ref:d,class:"title"},a.toDisplayString(E.definition.chart.chartTitle),513)]),_:1},8,["disabled","text"]),y.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"tile-actions","data-testid":`tile-actions-${E.tileId}`},[k.value?(a.openBlock(),a.createBlock(Ae,{key:0},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(k.value),1)]),_:1})):a.createCommentVNode("",!0),_.value&&E.context.editable?(a.openBlock(),a.createBlock(a.unref(Pe.EditIcon),{key:1,class:"edit-icon",color:a.unref(Qe),"data-testid":`edit-tile-${E.tileId}`,size:a.unref(Ze),onClick:x},null,8,["color","data-testid","size"])):a.createCommentVNode("",!0),_.value&&m.value?(a.openBlock(),a.createBlock(Z,{key:2,class:"dropdown","data-testid":`chart-action-menu-${E.tileId}`,"kpop-attributes":{placement:"bottom-end"}},{items:a.withCtx(()=>[g.value?(a.openBlock(),a.createBlock(ue,{key:0,"data-testid":`chart-jump-to-explore-${E.tileId}`,item:{label:a.unref(o).t("jumpToExplore"),to:g.value}},null,8,["data-testid","item"])):a.createCommentVNode("",!0),!("allowCsvExport"in E.definition.chart)||E.definition.chart.allowCsvExport?(a.openBlock(),a.createBlock(ue,{key:1,class:"chart-export-button","data-testid":`chart-csv-export-${E.tileId}`,onClick:K[0]||(K[0]=nt=>be())},{default:a.withCtx(()=>[a.createElementVNode("span",{class:"chart-export-trigger","data-testid":`csv-export-button-${E.tileId}`},a.toDisplayString(a.unref(o).t("csvExport.exportAsCsv")),9,It)]),_:1},8,["data-testid"])):a.createCommentVNode("",!0),E.context.editable?(a.openBlock(),a.createBlock(ue,{key:2,"data-testid":`remove-tile-${E.tileId}`,onClick:S},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(a.unref(o).t("renderer.remove")),1)]),_:1},8,["data-testid"])):a.createCommentVNode("",!0)]),default:a.withCtx(()=>[a.createVNode(a.unref(Pe.MoreIcon),{class:"kebab-action-menu",color:a.unref(Qe),"data-testid":`kebab-action-menu-${E.tileId}`,size:a.unref(Ze)},null,8,["color","data-testid","size"])]),_:1},8,["data-testid"])):a.createCommentVNode("",!0)],8,Mt)):"description"in E.definition.chart?(a.openBlock(),a.createElementBlock("div",{key:1,class:"header-description","data-testid":`tile-description-${E.tileId}`},a.toDisplayString(E.definition.chart.description),9,Bt)):a.createCommentVNode("",!0),c.value?(a.openBlock(),a.createBlock(a.unref(Y.CsvExportModal),{key:2,"chart-data":n.value,"data-testid":`csv-export-modal-${E.tileId}`,filename:p.value,onToggleModal:I},null,8,["chart-data","data-testid","filename"])):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"tile-content","data-testid":`tile-content-${E.tileId}`},[N.value?(a.openBlock(),a.createBlock(a.resolveDynamicComponent(N.value.component),a.mergeProps({key:0},N.value.rendererProps,{onChartData:B,onZoomTimeRange:K[1]||(K[1]=nt=>s("zoom-time-range",nt))}),null,16)):a.createCommentVNode("",!0)],8,Pt)],10,Lt)}}}),[["__scopeId","data-v-caafa72e"]]),$t=(f,e,t)=>{const i=new Map;t.forEach(r=>{const o=r.layout.position.row,n=i.get(o),c=r.layout.size.rows===1&&!!r.layout.size.fitToContent;n===void 0?i.set(o,c):i.set(o,n&&c)});const s=[];for(let r=0;r<f;r++)i.get(r)?s.push("auto"):s.push(`${e}px`);return s},tt=J(a.defineComponent({__name:"GridLayout",props:{gridSize:{type:Object,required:!0},tileHeight:{type:Number,required:!1,default:()=>ge},tiles:{type:Array,required:!0}},setup(f){a.useCssVars(n=>({"3bc5e939":f.gridSize.cols,"77aa3028":r.value}));const e=f,t=a.ref(null),i=a.ref(0),s=new ResizeObserver(n=>{window.requestAnimationFrame(()=>{!Array.isArray(n)||!n.length||(i.value=n[0].contentRect.width)})});a.onMounted(()=>{t.value&&s.observe(t.value)}),a.onUnmounted(()=>{t.value&&s.unobserve(t.value)});const r=a.computed(()=>{var c;return $t((c=e.gridSize)==null?void 0:c.rows,e.tileHeight,e.tiles).join(" ")}),o=a.computed(()=>e.tiles.map((n,c)=>({key:`tile-${c}`,tile:n,style:{"grid-column-start":n.layout.position.col+1,"grid-column-end":n.layout.position.col+1+n.layout.size.cols,"grid-row-start":n.layout.position.row+1,"grid-row-end":n.layout.position.row+1+n.layout.size.rows}})));return(n,c)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"gridContainer",ref:t,class:"kong-ui-public-grid-layout"},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(o.value,d=>(a.openBlock(),a.createElementBlock("div",{key:d.key,class:a.normalizeClass(["grid-cell",{"empty-cell":!d.tile}]),style:a.normalizeStyle(d.style)},[a.renderSlot(n.$slots,"tile",{style:a.normalizeStyle(d.style),tile:d.tile},void 0,!0)],6))),128))],512))}}),[["__scopeId","data-v-f43eb7b8"]]);function Ft(f,e,t,i,s){const r=(...o)=>(console.warn("gridstack.js: Function `"+t+"` is deprecated in "+s+" and has been replaced with `"+i+"`. It will be **removed** in a future release"),e.apply(f,o));return r.prototype=e.prototype,r}class u{static getElements(e,t=document){if(typeof e=="string"){const i="getElementById"in t?t:void 0;if(i&&!isNaN(+e[0])){const r=i.getElementById(e);return r?[r]:[]}let s=t.querySelectorAll(e);return!s.length&&e[0]!=="."&&e[0]!=="#"&&(s=t.querySelectorAll("."+e),s.length||(s=t.querySelectorAll("#"+e))),Array.from(s)}return[e]}static getElement(e,t=document){if(typeof e=="string"){const i="getElementById"in t?t:void 0;if(!e.length)return null;if(i&&e[0]==="#")return i.getElementById(e.substring(1));if(e[0]==="#"||e[0]==="."||e[0]==="[")return t.querySelector(e);if(i&&!isNaN(+e[0]))return i.getElementById(e);let s=t.querySelector(e);return i&&!s&&(s=i.getElementById(e)),s||(s=t.querySelector("."+e)),s}return e}static createWidgetDivs(e,t){var o,n;const i=u.createDiv(["grid-stack-item",e]),s=u.createDiv(["grid-stack-item-content"],i);return t.lazyLoad||((n=(o=t.grid)==null?void 0:o.opts)==null?void 0:n.lazyLoad)&&t.lazyLoad!==!1?t.visibleObservable||(t.visibleObservable=new IntersectionObserver(([c])=>{var d;c.isIntersecting&&((d=t.visibleObservable)==null||d.disconnect(),delete t.visibleObservable,w.renderCB(s,t))}),window.setTimeout(()=>{var c;return(c=t.visibleObservable)==null?void 0:c.observe(i)})):w.renderCB(s,t),i}static createDiv(e,t){const i=document.createElement("div");return e.forEach(s=>{s&&i.classList.add(s)}),t==null||t.appendChild(i),i}static shouldSizeToContent(e,t=!1){return(e==null?void 0:e.grid)&&(t?e.sizeToContent===!0||e.grid.opts.sizeToContent===!0&&e.sizeToContent===void 0:!!e.sizeToContent||e.grid.opts.sizeToContent&&e.sizeToContent!==!1)}static isIntercepted(e,t){return!(e.y>=t.y+t.h||e.y+e.h<=t.y||e.x+e.w<=t.x||e.x>=t.x+t.w)}static isTouching(e,t){return u.isIntercepted(e,{x:t.x-.5,y:t.y-.5,w:t.w+1,h:t.h+1})}static areaIntercept(e,t){const i=e.x>t.x?e.x:t.x,s=e.x+e.w<t.x+t.w?e.x+e.w:t.x+t.w;if(s<=i)return 0;const r=e.y>t.y?e.y:t.y,o=e.y+e.h<t.y+t.h?e.y+e.h:t.y+t.h;return o<=r?0:(s-i)*(o-r)}static area(e){return e.w*e.h}static sort(e,t=1){return e.sort((s,r)=>{const o=t*((s.y??1e4)-(r.y??1e4));return o===0?t*((s.x??1e4)-(r.x??1e4)):o})}static find(e,t){return t?e.find(i=>i.id===t):void 0}static createStylesheet(e,t,i){const s=document.createElement("style"),r=i==null?void 0:i.nonce;return r&&(s.nonce=r),s.setAttribute("type","text/css"),s.setAttribute("gs-style-id",e),s.styleSheet?s.styleSheet.cssText="":s.appendChild(document.createTextNode("")),t?t.insertBefore(s,t.firstChild):(t=document.getElementsByTagName("head")[0],t.appendChild(s)),s}static removeStylesheet(e,t){const s=(t||document).querySelector("STYLE[gs-style-id="+e+"]");s&&s.parentNode&&s.remove()}static addCSSRule(e,t,i){e.textContent+=`${t} { ${i} } `}static toBool(e){return typeof e=="boolean"?e:typeof e=="string"?(e=e.toLowerCase(),!(e===""||e==="no"||e==="false"||e==="0")):!!e}static toNumber(e){return e===null||e.length===0?void 0:Number(e)}static parseHeight(e){let t,i="px";if(typeof e=="string")if(e==="auto"||e==="")t=0;else{const s=e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!s)throw new Error(`Invalid height val = ${e}`);i=s[2]||"px",t=parseFloat(s[1])}else t=e;return{h:t,unit:i}}static defaults(e,...t){return t.forEach(i=>{for(const s in i){if(!i.hasOwnProperty(s))return;e[s]===null||e[s]===void 0?e[s]=i[s]:typeof i[s]=="object"&&typeof e[s]=="object"&&this.defaults(e[s],i[s])}}),e}static same(e,t){if(typeof e!="object")return e==t;if(typeof e!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}static copyPos(e,t,i=!1){return t.x!==void 0&&(e.x=t.x),t.y!==void 0&&(e.y=t.y),t.w!==void 0&&(e.w=t.w),t.h!==void 0&&(e.h=t.h),i&&(t.minW&&(e.minW=t.minW),t.minH&&(e.minH=t.minH),t.maxW&&(e.maxW=t.maxW),t.maxH&&(e.maxH=t.maxH)),e}static samePos(e,t){return e&&t&&e.x===t.x&&e.y===t.y&&(e.w||1)===(t.w||1)&&(e.h||1)===(t.h||1)}static sanitizeMinMax(e){e.minW||delete e.minW,e.minH||delete e.minH,e.maxW||delete e.maxW,e.maxH||delete e.maxH}static removeInternalAndSame(e,t){if(!(typeof e!="object"||typeof t!="object"))for(let i in e){const s=e[i],r=t[i];i[0]==="_"||s===r?delete e[i]:s&&typeof s=="object"&&r!==void 0&&(u.removeInternalAndSame(s,r),Object.keys(s).length||delete e[i])}}static removeInternalForSave(e,t=!0){for(let i in e)(i[0]==="_"||e[i]===null||e[i]===void 0)&&delete e[i];delete e.grid,t&&delete e.el,e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,e.locked||delete e.locked,(e.w===1||e.w===e.minW)&&delete e.w,(e.h===1||e.h===e.minH)&&delete e.h}static throttle(e,t){let i=!1;return(...s)=>{i||(i=!0,setTimeout(()=>{e(...s),i=!1},t))}}static removePositioningStyles(e){const t=e.style;t.position&&t.removeProperty("position"),t.left&&t.removeProperty("left"),t.top&&t.removeProperty("top"),t.width&&t.removeProperty("width"),t.height&&t.removeProperty("height")}static getScrollElement(e){if(!e)return document.scrollingElement||document.documentElement;const t=getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowY)?e:this.getScrollElement(e.parentElement)}static updateScrollPosition(e,t,i){const s=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight;if(s.top<0||s.bottom>r){const o=s.bottom-r,n=s.top,c=this.getScrollElement(e);if(c!==null){const d=c.scrollTop;s.top<0&&i<0?e.offsetHeight>r?c.scrollTop+=i:c.scrollTop+=Math.abs(n)>Math.abs(i)?i:n:i>0&&(e.offsetHeight>r?c.scrollTop+=i:c.scrollTop+=o>i?i:o),t.top+=c.scrollTop-d}}}static updateScrollResize(e,t,i){const s=this.getScrollElement(t),r=s.clientHeight,o=s===this.getScrollElement()?0:s.getBoundingClientRect().top,n=e.clientY-o,c=n<i,d=n>r-i;c?s.scrollBy({behavior:"smooth",top:n-i}):d&&s.scrollBy({behavior:"smooth",top:i-(r-n)})}static clone(e){return e==null||typeof e!="object"?e:e instanceof Array?[...e]:{...e}}static cloneDeep(e){const t=["parentGrid","el","grid","subGrid","engine"],i=u.clone(e);for(const s in i)i.hasOwnProperty(s)&&typeof i[s]=="object"&&s.substring(0,2)!=="__"&&!t.find(r=>r===s)&&(i[s]=u.cloneDeep(e[s]));return i}static cloneNode(e){const t=e.cloneNode(!0);return t.removeAttribute("id"),t}static appendTo(e,t){let i;typeof t=="string"?i=u.getElement(t):i=t,i&&i.appendChild(e)}static addElStyles(e,t){if(t instanceof Object)for(const i in t)t.hasOwnProperty(i)&&(Array.isArray(t[i])?t[i].forEach(s=>{e.style[i]=s}):e.style[i]=t[i])}static initEvent(e,t){const i={type:t.type},s={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:t.target?t.target:e.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(r=>i[r]=e[r]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(r=>i[r]=e[r]),{...i,...s}}static simulateMouseEvent(e,t,i){const s=document.createEvent("MouseEvents");s.initMouseEvent(t,!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,e.target),(i||e.target).dispatchEvent(s)}static getValuesFromTransformedElement(e){const t=document.createElement("div");u.addElStyles(t,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),e.appendChild(t);const i=t.getBoundingClientRect();return e.removeChild(t),t.remove(),{xScale:1/i.width,yScale:1/i.height,xOffset:i.left,yOffset:i.top}}static swap(e,t,i){if(!e)return;const s=e[t];e[t]=e[i],e[i]=s}static canBeRotated(e){var t;return!(!e||e.w===e.h||e.locked||e.noResize||(t=e.grid)!=null&&t.opts.disableResize||e.minW&&e.minW===e.maxW||e.minH&&e.minH===e.maxH)}}class W{constructor(e={}){this.addedNodes=[],this.removedNodes=[],this.defaultColumn=12,this.column=e.column||this.defaultColumn,this.column>this.defaultColumn&&(this.defaultColumn=this.column),this.maxRow=e.maxRow,this._float=e.float,this.nodes=e.nodes||[],this.onChange=e.onChange}batchUpdate(e=!0,t=!0){return!!this.batchMode===e?this:(this.batchMode=e,e?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,t&&this._packNodes(),this._notify()),this)}_useEntireRowArea(e,t){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!e._moving||e._skipDown||t.y<=e.y)}_fixCollisions(e,t=e,i,s={}){if(this.sortNodes(-1),i=i||this.collide(e,t),!i)return!1;if(e._moving&&!s.nested&&!this.float&&this.swap(e,i))return!0;let r=t;!this._loading&&this._useEntireRowArea(e,t)&&(r={x:0,w:this.column,y:t.y,h:t.h},i=this.collide(e,r,s.skip));let o=!1;const n={nested:!0,pack:!1};let c=0;for(;i=i||this.collide(e,r,s.skip);){if(c++>this.nodes.length*2)throw new Error("Infinite collide check");let d;if(i.locked||this._loading||e._moving&&!e._skipDown&&t.y>e.y&&!this.float&&(!this.collide(i,{...i,y:e.y},e)||!this.collide(i,{...i,y:t.y-i.h},e))){e._skipDown=e._skipDown||t.y>e.y;const l={...t,y:i.y+i.h,...n};d=this._loading&&u.samePos(e,l)?!0:this.moveNode(e,l),(i.locked||this._loading)&&d?u.copyPos(t,e):!i.locked&&d&&s.pack&&(this._packNodes(),t.y=i.y+i.h,u.copyPos(e,t)),o=o||d}else d=this.moveNode(i,{...i,y:t.y+t.h,skip:e,...n});if(!d)return o;i=void 0}return o}collide(e,t=e,i){const s=e._id,r=i==null?void 0:i._id;return this.nodes.find(o=>o._id!==s&&o._id!==r&&u.isIntercepted(o,t))}collideAll(e,t=e,i){const s=e._id,r=i==null?void 0:i._id;return this.nodes.filter(o=>o._id!==s&&o._id!==r&&u.isIntercepted(o,t))}directionCollideCoverage(e,t,i){if(!t.rect||!e._rect)return;const s=e._rect,r={...t.rect};r.y>s.y?(r.h+=r.y-s.y,r.y=s.y):r.h+=s.y-r.y,r.x>s.x?(r.w+=r.x-s.x,r.x=s.x):r.w+=s.x-r.x;let o,n=.5;for(let c of i){if(c.locked||!c._rect)break;const d=c._rect;let l=Number.MAX_VALUE,h=Number.MAX_VALUE;s.y<d.y?l=(r.y+r.h-d.y)/d.h:s.y+s.h>d.y+d.h&&(l=(d.y+d.h-r.y)/d.h),s.x<d.x?h=(r.x+r.w-d.x)/d.w:s.x+s.w>d.x+d.w&&(h=(d.x+d.w-r.x)/d.w);const g=Math.min(h,l);g>n&&(n=g,o=c)}return t.collide=o,o}cacheRects(e,t,i,s,r,o){return this.nodes.forEach(n=>n._rect={y:n.y*t+i,x:n.x*e+o,w:n.w*e-o-s,h:n.h*t-i-r}),this}swap(e,t){if(!t||t.locked||!e||e.locked)return!1;function i(){const r=t.x,o=t.y;return t.x=e.x,t.y=e.y,e.h!=t.h?(e.x=r,e.y=t.y+t.h):e.w!=t.w?(e.x=t.x+t.w,e.y=o):(e.x=r,e.y=o),e._dirty=t._dirty=!0,!0}let s;if(e.w===t.w&&e.h===t.h&&(e.x===t.x||e.y===t.y)&&(s=u.isTouching(e,t)))return i();if(s!==!1){if(e.w===t.w&&e.x===t.x&&(s||(s=u.isTouching(e,t)))){if(t.y<e.y){const r=e;e=t,t=r}return i()}if(s!==!1){if(e.h===t.h&&e.y===t.y&&(s||(s=u.isTouching(e,t)))){if(t.x<e.x){const r=e;e=t,t=r}return i()}return!1}}}isAreaEmpty(e,t,i,s){const r={x:e||0,y:t||0,w:i||1,h:s||1};return!this.collide(r)}compact(e="compact",t=!0){if(this.nodes.length===0)return this;t&&this.sortNodes();const i=this.batchMode;i||this.batchUpdate();const s=this._inColumnResize;s||(this._inColumnResize=!0);const r=this.nodes;return this.nodes=[],r.forEach((o,n,c)=>{let d;o.locked||(o.autoPosition=!0,e==="list"&&n&&(d=c[n-1])),this.addNode(o,!1,d)}),s||delete this._inColumnResize,i||this.batchUpdate(!1),this}set float(e){this._float!==e&&(this._float=e||!1,e||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(e=1){return this.nodes=u.sort(this.nodes,e),this}_packNodes(){return this.batchMode?this:(this.sortNodes(),this.float?this.nodes.forEach(e=>{if(e._updating||e._orig===void 0||e.y===e._orig.y)return;let t=e.y;for(;t>e._orig.y;)--t,this.collide(e,{x:e.x,y:t,w:e.w,h:e.h})||(e._dirty=!0,e.y=t)}):this.nodes.forEach((e,t)=>{if(!e.locked)for(;e.y>0;){const i=t===0?0:e.y-1;if(!(t===0||!this.collide(e,{x:e.x,y:i,w:e.w,h:e.h})))break;e._dirty=e.y!==i,e.y=i}}),this)}prepareNode(e,t){e._id=e._id??W._idSeq++;const i=e.id;if(i){let r=1;for(;this.nodes.find(o=>o.id===e.id&&o!==e);)e.id=i+"_"+r++}(e.x===void 0||e.y===void 0||e.x===null||e.y===null)&&(e.autoPosition=!0);const s={x:0,y:0,w:1,h:1};return u.defaults(e,s),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,u.sanitizeMinMax(e),typeof e.x=="string"&&(e.x=Number(e.x)),typeof e.y=="string"&&(e.y=Number(e.y)),typeof e.w=="string"&&(e.w=Number(e.w)),typeof e.h=="string"&&(e.h=Number(e.h)),isNaN(e.x)&&(e.x=s.x,e.autoPosition=!0),isNaN(e.y)&&(e.y=s.y,e.autoPosition=!0),isNaN(e.w)&&(e.w=s.w),isNaN(e.h)&&(e.h=s.h),this.nodeBoundFix(e,t),e}nodeBoundFix(e,t){const i=e._orig||u.copyPos({},e);if(e.maxW&&e.w&&(e.w=Math.min(e.w,e.maxW)),e.maxH&&e.h&&(e.h=Math.min(e.h,e.maxH)),e.minW&&e.w&&e.minW<=this.column&&(e.w=Math.max(e.w,e.minW)),e.minH&&e.h&&(e.h=Math.max(e.h,e.minH)),(e.x||0)+(e.w||1)>this.column&&this.column<this.defaultColumn&&!this._inColumnResize&&!this.skipCacheUpdate&&e._id&&this.findCacheLayout(e,this.defaultColumn)===-1){const r={...e};r.autoPosition||r.x===void 0?(delete r.x,delete r.y):r.x=Math.min(this.defaultColumn-1,r.x),r.w=Math.min(this.defaultColumn,r.w||1),this.cacheOneLayout(r,this.defaultColumn)}return e.w>this.column?e.w=this.column:e.w<1&&(e.w=1),this.maxRow&&e.h>this.maxRow?e.h=this.maxRow:e.h<1&&(e.h=1),e.x<0&&(e.x=0),e.y<0&&(e.y=0),e.x+e.w>this.column&&(t?e.w=this.column-e.x:e.x=this.column-e.w),this.maxRow&&e.y+e.h>this.maxRow&&(t?e.h=this.maxRow-e.y:e.y=this.maxRow-e.h),u.samePos(e,i)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(t=>t._dirty&&!u.samePos(t,t._orig)):this.nodes.filter(t=>t._dirty)}_notify(e){if(this.batchMode||!this.onChange)return this;const t=(e||[]).concat(this.getDirtyNodes());return this.onChange(t),this}cleanNodes(){return this.batchMode?this:(this.nodes.forEach(e=>{delete e._dirty,delete e._lastTried}),this)}saveInitial(){return this.nodes.forEach(e=>{e._orig=u.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||u.samePos(e,e._orig)||(u.copyPos(e,e._orig),e._dirty=!0)}),this._notify(),this}findEmptyPosition(e,t=this.nodes,i=this.column,s){const r=s?s.y*i+(s.x+s.w):0;let o=!1;for(let n=r;!o;++n){const c=n%i,d=Math.floor(n/i);if(c+e.w>i)continue;const l={x:c,y:d,w:e.w,h:e.h};t.find(h=>u.isIntercepted(l,h))||((e.x!==c||e.y!==d)&&(e._dirty=!0),e.x=c,e.y=d,delete e.autoPosition,o=!0)}return o}addNode(e,t=!1,i){const s=this.nodes.find(o=>o._id===e._id);if(s)return s;this._inColumnResize?this.nodeBoundFix(e):this.prepareNode(e),delete e._temporaryRemoved,delete e._removeDOM;let r;return e.autoPosition&&this.findEmptyPosition(e,this.nodes,this.column,i)&&(delete e.autoPosition,r=!0),this.nodes.push(e),t&&this.addedNodes.push(e),r||this._fixCollisions(e),this.batchMode||this._packNodes()._notify(),e}removeNode(e,t=!0,i=!1){return this.nodes.find(s=>s._id===e._id)?(i&&this.removedNodes.push(e),t&&(e._removeDOM=!0),this.nodes=this.nodes.filter(s=>s._id!==e._id),e._isAboutToRemove||this._packNodes(),this._notify([e]),this):this}removeAll(e=!0,t=!0){if(delete this._layouts,!this.nodes.length)return this;e&&this.nodes.forEach(s=>s._removeDOM=!0);const i=this.nodes;return this.removedNodes=t?i:[],this.nodes=[],this._notify(i)}moveNodeCheck(e,t){if(!this.changedPosConstrain(e,t))return!1;if(t.pack=!0,!this.maxRow)return this.moveNode(e,t);let i;const s=new W({column:this.column,float:this.float,nodes:this.nodes.map(o=>o._id===e._id?(i={...o},i):{...o})});if(!i)return!1;const r=s.moveNode(i,t)&&s.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!t.resizing&&t.collide){const o=t.collide.el.gridstackNode;if(this.swap(e,o))return this._notify(),!0}return r?(s.nodes.filter(o=>o._dirty).forEach(o=>{const n=this.nodes.find(c=>c._id===o._id);n&&(u.copyPos(n,o),n._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;const t=new W({column:this.column,float:this.float,nodes:this.nodes.map(s=>({...s}))}),i={...e};return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,t.addNode(i),t.getRow()<=this.maxRow?(e._willFitPos=u.copyPos({},i),!0):!1}changedPosConstrain(e,t){return t.w=t.w||e.w,t.h=t.h||e.h,e.x!==t.x||e.y!==t.y?!0:(e.maxW&&(t.w=Math.min(t.w,e.maxW)),e.maxH&&(t.h=Math.min(t.h,e.maxH)),e.minW&&(t.w=Math.max(t.w,e.minW)),e.minH&&(t.h=Math.max(t.h,e.minH)),e.w!==t.w||e.h!==t.h)}moveNode(e,t){var d,l;if(!e||!t)return!1;let i;t.pack===void 0&&!this.batchMode&&(i=t.pack=!0),typeof t.x!="number"&&(t.x=e.x),typeof t.y!="number"&&(t.y=e.y),typeof t.w!="number"&&(t.w=e.w),typeof t.h!="number"&&(t.h=e.h);const s=e.w!==t.w||e.h!==t.h,r=u.copyPos({},e,!0);if(u.copyPos(r,t),this.nodeBoundFix(r,s),u.copyPos(t,r),!t.forceCollide&&u.samePos(e,t))return!1;const o=u.copyPos({},e),n=this.collideAll(e,r,t.skip);let c=!0;if(n.length){const h=e._moving&&!t.nested;let g=h?this.directionCollideCoverage(e,t,n):n[0];if(h&&g&&((l=(d=e.grid)==null?void 0:d.opts)!=null&&l.subGridDynamic)&&!e.grid._isTemp){const p=u.areaIntercept(t.rect,g._rect),y=u.area(t.rect),_=u.area(g._rect);p/(y<_?y:_)>.8&&(g.grid.makeSubGrid(g.el,void 0,e),g=void 0)}g?c=!this._fixCollisions(e,r,g,t):(c=!1,i&&delete t.pack)}return c&&!u.samePos(e,r)&&(e._dirty=!0,u.copyPos(e,r)),t.pack&&this._packNodes()._notify(),!u.samePos(e,o)}getRow(){return this.nodes.reduce((e,t)=>Math.max(e,t.y+t.h),0)}beginUpdate(e){return e._updating||(e._updating=!0,delete e._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){const e=this.nodes.find(t=>t._updating);return e&&(delete e._updating,delete e._skipDown),this}save(e=!0,t){var o;const i=(o=this._layouts)==null?void 0:o.length,s=i&&this.column!==i-1?this._layouts[i-1]:null,r=[];return this.sortNodes(),this.nodes.forEach(n=>{const c=s==null?void 0:s.find(l=>l._id===n._id),d={...n,...c||{}};u.removeInternalForSave(d,!e),t&&t(n,d),r.push(d)}),r}layoutsNodesChange(e){return!this._layouts||this._inColumnResize?this:(this._layouts.forEach((t,i)=>{if(!t||i===this.column)return this;if(i<this.column)this._layouts[i]=void 0;else{const s=i/this.column;e.forEach(r=>{if(!r._orig)return;const o=t.find(n=>n._id===r._id);o&&(o.y>=0&&r.y!==r._orig.y&&(o.y+=r.y-r._orig.y),r.x!==r._orig.x&&(o.x=Math.round(r.x*s)),r.w!==r._orig.w&&(o.w=Math.round(r.w*s)))})}}),this)}columnChanged(e,t,i="moveScale"){var n;if(!this.nodes.length||!t||e===t)return this;const s=i==="compact"||i==="list";s&&this.sortNodes(1),t<e&&this.cacheLayout(this.nodes,e),this.batchUpdate();let r=[],o=s?this.nodes:u.sort(this.nodes,-1);if(t>e&&this._layouts){const c=this._layouts[t]||[],d=this._layouts.length-1;!c.length&&e!==d&&((n=this._layouts[d])!=null&&n.length)&&(e=d,this._layouts[d].forEach(l=>{const h=o.find(g=>g._id===l._id);h&&(!s&&!l.autoPosition&&(h.x=l.x??h.x,h.y=l.y??h.y),h.w=l.w??h.w,(l.x==null||l.y===void 0)&&(h.autoPosition=!0))})),c.forEach(l=>{const h=o.findIndex(g=>g._id===l._id);if(h!==-1){const g=o[h];if(s){g.w=l.w;return}(l.autoPosition||isNaN(l.x)||isNaN(l.y))&&this.findEmptyPosition(l,r),l.autoPosition||(g.x=l.x??g.x,g.y=l.y??g.y,g.w=l.w??g.w,r.push(g)),o.splice(h,1)}})}if(s)this.compact(i,!1);else{if(o.length)if(typeof i=="function")i(t,e,r,o);else{const c=s||i==="none"?1:t/e,d=i==="move"||i==="moveScale",l=i==="scale"||i==="moveScale";o.forEach(h=>{h.x=t===1?0:d?Math.round(h.x*c):Math.min(h.x,t-1),h.w=t===1||e===1?1:l?Math.round(h.w*c)||1:Math.min(h.w,t),r.push(h)}),o=[]}r=u.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(c=>{this.addNode(c,!1),delete c._orig})}return this.nodes.forEach(c=>delete c._orig),this.batchUpdate(!1,!s),delete this._inColumnResize,this}cacheLayout(e,t,i=!1){const s=[];return e.forEach((r,o)=>{if(r._id===void 0){const n=r.id?this.nodes.find(c=>c.id===r.id):void 0;r._id=(n==null?void 0:n._id)??W._idSeq++}s[o]={x:r.x,y:r.y,w:r.w,_id:r._id}}),this._layouts=i?[]:this._layouts||[],this._layouts[t]=s,this}cacheOneLayout(e,t){e._id=e._id??W._idSeq++;const i={x:e.x,y:e.y,w:e.w,_id:e._id};(e.autoPosition||e.x===void 0)&&(delete i.x,delete i.y,e.autoPosition&&(i.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[t]=this._layouts[t]||[];const s=this.findCacheLayout(e,t);return s===-1?this._layouts[t].push(i):this._layouts[t][s]=i,this}findCacheLayout(e,t){var i,s;return((s=(i=this._layouts)==null?void 0:i[t])==null?void 0:s.findIndex(r=>r._id===e._id))??-1}removeNodeFromLayoutCache(e){if(this._layouts)for(let t=0;t<this._layouts.length;t++){const i=this.findCacheLayout(e,t);i!==-1&&this._layouts[t].splice(i,1)}}cleanupNode(e){for(const t in e)t[0]==="_"&&t!=="_id"&&delete e[t];return this}}W._idSeq=0;const P={alwaysShowResizeHandle:"mobile",animate:!0,auto:!0,cellHeight:"auto",cellHeightThrottle:100,cellHeightUnit:"px",column:12,draggable:{handle:".grid-stack-item-content",appendTo:"body",scroll:!0},handle:".grid-stack-item-content",itemClass:"grid-stack-item",margin:10,marginUnit:"px",maxRow:0,minRow:0,placeholderClass:"grid-stack-placeholder",placeholderText:"",removableOptions:{accept:"grid-stack-item",decline:"grid-stack-non-removable"},resizable:{handles:"se"},rtl:"auto"};class C{}const G=typeof window<"u"&&typeof document<"u"&&("ontouchstart"in document||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0);class V{}function me(f,e){if(f.touches.length>1)return;f.cancelable&&f.preventDefault();const t=f.changedTouches[0],i=document.createEvent("MouseEvents");i.initMouseEvent(e,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null),f.target.dispatchEvent(i)}function it(f,e){f.cancelable&&f.preventDefault();const t=document.createEvent("MouseEvents");t.initMouseEvent(e,!0,!0,window,1,f.screenX,f.screenY,f.clientX,f.clientY,!1,!1,!1,!1,0,null),f.target.dispatchEvent(t)}function pe(f){V.touchHandled||(V.touchHandled=!0,me(f,"mousedown"))}function ye(f){V.touchHandled&&me(f,"mousemove")}function _e(f){if(!V.touchHandled)return;V.pointerLeaveTimeout&&(window.clearTimeout(V.pointerLeaveTimeout),delete V.pointerLeaveTimeout);const e=!!C.dragElement;me(f,"mouseup"),e||me(f,"click"),V.touchHandled=!1}function ve(f){f.pointerType!=="mouse"&&f.target.releasePointerCapture(f.pointerId)}function st(f){C.dragElement&&f.pointerType!=="mouse"&&it(f,"mouseenter")}function rt(f){C.dragElement&&f.pointerType!=="mouse"&&(V.pointerLeaveTimeout=window.setTimeout(()=>{delete V.pointerLeaveTimeout,it(f,"mouseleave")},10))}class we{constructor(e,t,i){this.host=e,this.dir=t,this.option=i,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){const e=this.el=document.createElement("div");return e.classList.add("ui-resizable-handle"),e.classList.add(`${we.prefix}${this.dir}`),e.style.zIndex="100",e.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),G&&(this.el.addEventListener("touchstart",pe),this.el.addEventListener("pointerdown",ve)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),G&&(this.el.removeEventListener("touchstart",pe),this.el.removeEventListener("pointerdown",ve)),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(e){this.mouseDownEvent=e,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),G&&(this.el.addEventListener("touchmove",ye),this.el.addEventListener("touchend",_e)),e.stopPropagation(),e.preventDefault()}_mouseMove(e){const t=this.mouseDownEvent;this.moving?this._triggerEvent("move",e):Math.abs(e.x-t.x)+Math.abs(e.y-t.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",e),document.addEventListener("keydown",this._keyEvent)),e.stopPropagation()}_mouseUp(e){this.moving&&(this._triggerEvent("stop",e),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),G&&(this.el.removeEventListener("touchmove",ye),this.el.removeEventListener("touchend",_e)),delete this.moving,delete this.mouseDownEvent,e.stopPropagation(),e.preventDefault()}_keyEvent(e){var t,i;e.key==="Escape"&&((i=(t=this.host.gridstackNode)==null?void 0:t.grid)==null||i.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(e,t){return this.option[e]&&this.option[e](t),this}}we.prefix="ui-resizable-";class Se{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(e,t){this._eventRegister[e]=t}off(e){delete this._eventRegister[e]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(e,t){if(!this.disabled&&this._eventRegister&&this._eventRegister[e])return this._eventRegister[e](t)}}class oe extends Se{constructor(e,t={}){super(),this.el=e,this.option=t,this.rectScale={x:1,y:1},this._ui=()=>{const s=this.el.parentElement.getBoundingClientRect(),r={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},o=this.temporalRect||r;return{position:{left:(o.left-s.left)*this.rectScale.x,top:(o.top-s.top)*this.rectScale.y},size:{width:o.width*this.rectScale.x,height:o.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(e){const t=e.handles&&e.handles!==this.option.handles,i=e.autoHide&&e.autoHide!==this.option.autoHide;return Object.keys(e).forEach(s=>this.option[s]=e[s]),t&&(this._removeHandlers(),this._setupHandlers()),i&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(e){return e?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),C.overResizeElement===this&&delete C.overResizeElement),this}_mouseOver(e){C.overResizeElement||C.dragElement||(C.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){C.overResizeElement===this&&(delete C.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new we(this.el,e,{start:t=>{this._resizeStart(t)},stop:t=>{this._resizeStop(t)},move:t=>{this._resizing(t,e)}})),this}_resizeStart(e){this.sizeToContent=u.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=u.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();const t=u.initEvent(e,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(t,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",t),this}_resizing(e,t){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(e,t),this._applyChange();const i=u.initEvent(e,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(e){const t=u.initEvent(e,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(t),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",t),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=oe._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;const e=this.el.parentElement,t=u.getValuesFromTransformedElement(e);return this.rectScale={x:t.xScale,y:t.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return oe._originStyleProp.forEach((e,t)=>{this.el.style[e]=this.elOriginStyleVal[t]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(e,t){const i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},r=e.clientX-i.clientX,o=this.sizeToContent?0:e.clientY-i.clientY;let n,c;t.indexOf("e")>-1?s.width+=r:t.indexOf("w")>-1&&(s.width-=r,s.left+=r,n=!0),t.indexOf("s")>-1?s.height+=o:t.indexOf("n")>-1&&(s.height-=o,s.top+=o,c=!0);const d=this._constrainSize(s.width,s.height,n,c);return Math.round(s.width)!==Math.round(d.width)&&(t.indexOf("w")>-1&&(s.left+=s.width-d.width),s.width=d.width),Math.round(s.height)!==Math.round(d.height)&&(t.indexOf("n")>-1&&(s.top+=s.height-d.height),s.height=d.height),s}_constrainSize(e,t,i,s){const r=this.option,o=(i?r.maxWidthMoveLeft:r.maxWidth)||Number.MAX_SAFE_INTEGER,n=r.minWidth/this.rectScale.x||e,c=(s?r.maxHeightMoveUp:r.maxHeight)||Number.MAX_SAFE_INTEGER,d=r.minHeight/this.rectScale.y||t,l=Math.min(o,Math.max(n,e)),h=Math.min(c,Math.max(d,t));return{width:l,height:h}}_applyChange(){let e={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){const t=this.el.parentElement,{left:i,top:s}=t.getBoundingClientRect();e={left:i,top:s,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(t=>{const i=this.temporalRect[t],s=t==="width"||t==="left"?this.rectScale.x:t==="height"||t==="top"?this.rectScale.y:1;this.el.style[t]=(i-e[t])*s+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(e=>e.destroy()),delete this.handlers,this}}oe._originStyleProp=["width","height","position","left","top","opacity","zIndex"];const Gt='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';class ae extends Se{constructor(e,t={}){var r;super(),this.el=e,this.option=t,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};const i=(r=t==null?void 0:t.handle)==null?void 0:r.substring(1),s=e.gridstackNode;this.dragEls=!i||e.classList.contains(i)?[e]:s!=null&&s.subGrid?[e.querySelector(t.handle)||e]:Array.from(e.querySelectorAll(t.handle)),this.dragEls.length===0&&(this.dragEls=[e]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(e=>{e.addEventListener("mousedown",this._mouseDown),G&&(e.addEventListener("touchstart",pe),e.addEventListener("pointerdown",ve))}),this.el.classList.remove("ui-draggable-disabled"))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(t=>{t.removeEventListener("mousedown",this._mouseDown),G&&(t.removeEventListener("touchstart",pe),t.removeEventListener("pointerdown",ve))}),e||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(e){return Object.keys(e).forEach(t=>this.option[t]=e[t]),this}_mouseDown(e){if(!C.mouseHandled)return e.button!==0||!this.dragEls.find(t=>t===e.target)&&e.target.closest(Gt)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete C.dragElement,delete C.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),G&&(e.currentTarget.addEventListener("touchmove",ye),e.currentTarget.addEventListener("touchend",_e)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),C.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;const t=u.initEvent(e,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(t,this.ui()),this.triggerEvent("drag",t)}_mouseMove(e){var i;const t=this.mouseDownEvent;if(this.lastDrag=e,this.dragging)if(this._dragFollow(e),C.pauseDrag){const s=Number.isInteger(C.pauseDrag)?C.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(e),s)}else this._callDrag(e);else if(Math.abs(e.x-t.x)+Math.abs(e.y-t.y)>3){this.dragging=!0,C.dragElement=this;const s=(i=this.el.gridstackNode)==null?void 0:i.grid;s?C.dropElement=s.el.ddElement.ddDroppable:delete C.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=u.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);const r=u.initEvent(e,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(r,this.ui()),this.triggerEvent("dragstart",r),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(e){var t,i;if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),G&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",ye,!0),e.currentTarget.removeEventListener("touchend",_e,!0)),this.dragging){delete this.dragging,(t=this.el.gridstackNode)==null||delete t._origRotate,document.removeEventListener("keydown",this._keyEvent),((i=C.dropElement)==null?void 0:i.el)===this.el.parentElement&&delete C.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const s=u.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(s),this.triggerEvent("dragstop",s),C.dropElement&&C.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete C.dragElement,delete C.dropElement,delete C.mouseHandled,e.preventDefault()}_keyEvent(e){var s,r;const t=this.el.gridstackNode,i=(t==null?void 0:t.grid)||((r=(s=C.dropElement)==null?void 0:s.el)==null?void 0:r.gridstack);if(e.key==="Escape")t&&t._origRotate&&(t._orig=t._origRotate,delete t._origRotate),i==null||i.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(t&&i&&(e.key==="r"||e.key==="R")){if(!u.canBeRotated(t))return;t._origRotate=t._origRotate||{...t._orig},delete t._moving,i.setAnimation(!1).rotate(t.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetLeft}).setAnimation(),t._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,t.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",u.swap(t._orig,"w","h"),delete t._rect,this._mouseMove(this.lastDrag)}}_createHelper(){let e=this.el;return typeof this.option.helper=="function"?e=this.option.helper(this.el):this.option.helper==="clone"&&(e=u.cloneNode(this.el)),document.body.contains(e)||u.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=ae.originStyleProp.map(t=>this.el.style[t]),e}_setupHelperStyle(e){this.helper.classList.add("ui-draggable-dragging");const t=this.helper.style;return t.pointerEvents="none",t.width=this.dragOffset.width+"px",t.height=this.dragOffset.height+"px",t.willChange="left, top",t.position="fixed",this._dragFollow(e),t.transition="none",setTimeout(()=>{this.helper&&(t.transition=null)},0),this}_removeHelperStyle(){var t;this.helper.classList.remove("ui-draggable-dragging");const e=(t=this.helper)==null?void 0:t.gridstackNode;if(!(e!=null&&e._isAboutToRemove)&&this.dragElementOriginStyle){const i=this.helper,s=this.dragElementOriginStyle.transition||null;i.style.transition=this.dragElementOriginStyle.transition="none",ae.originStyleProp.forEach(r=>i.style[r]=this.dragElementOriginStyle[r]||null),setTimeout(()=>i.style.transition=s,50)}return delete this.dragElementOriginStyle,this}_dragFollow(e){const t={left:0,top:0},i=this.helper.style,s=this.dragOffset;i.left=(e.clientX+s.offsetLeft-t.left)*this.dragTransform.xScale+"px",i.top=(e.clientY+s.offsetTop-t.top)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(e,t,i){let s=0,r=0;i&&(s=this.dragTransform.xOffset,r=this.dragTransform.yOffset);const o=t.getBoundingClientRect();return{left:o.left,top:o.top,offsetLeft:-e.clientX+o.left-s,offsetTop:-e.clientY+o.top-r,width:o.width*this.dragTransform.xScale,height:o.height*this.dragTransform.yScale}}ui(){const t=this.el.parentElement.getBoundingClientRect(),i=this.helper.getBoundingClientRect();return{position:{top:(i.top-t.top)*this.dragTransform.yScale,left:(i.left-t.left)*this.dragTransform.xScale}}}}ae.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","top","minWidth","willChange"];class Ut extends Se{constructor(e,t={}){super(),this.el=e,this.option=t,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),G&&(this.el.addEventListener("pointerenter",st),this.el.addEventListener("pointerleave",rt)))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),e||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),G&&(this.el.removeEventListener("pointerenter",st),this.el.removeEventListener("pointerleave",rt)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(e){return Object.keys(e).forEach(t=>this.option[t]=e[t]),this._setupAccept(),this}_mouseEnter(e){if(!C.dragElement||!this._canDrop(C.dragElement.el))return;e.preventDefault(),e.stopPropagation(),C.dropElement&&C.dropElement!==this&&C.dropElement._mouseLeave(e,!0),C.dropElement=this;const t=u.initEvent(e,{target:this.el,type:"dropover"});this.option.over&&this.option.over(t,this._ui(C.dragElement)),this.triggerEvent("dropover",t),this.el.classList.add("ui-droppable-over")}_mouseLeave(e,t=!1){var s;if(!C.dragElement||C.dropElement!==this)return;e.preventDefault(),e.stopPropagation();const i=u.initEvent(e,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(i,this._ui(C.dragElement)),this.triggerEvent("dropout",i),C.dropElement===this&&(delete C.dropElement,!t)){let r,o=this.el.parentElement;for(;!r&&o;)r=(s=o.ddElement)==null?void 0:s.ddDroppable,o=o.parentElement;r&&r._mouseEnter(e)}}drop(e){e.preventDefault();const t=u.initEvent(e,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(t,this._ui(C.dragElement)),this.triggerEvent("drop",t)}_canDrop(e){return e&&(!this.accept||this.accept(e))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=e=>e.classList.contains(this.option.accept)||e.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(e){return{draggable:e.el,...e.ui()}}}class Ne{static init(e){return e.ddElement||(e.ddElement=new Ne(e)),e.ddElement}constructor(e){this.el=e}on(e,t){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.on(e,t):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.on(e,t):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.on(e,t),this}off(e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.off(e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.off(e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.off(e),this}setupDraggable(e){return this.ddDraggable?this.ddDraggable.updateOption(e):this.ddDraggable=new ae(this.el,e),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(e){return this.ddResizable?this.ddResizable.updateOption(e):this.ddResizable=new oe(this.el,e),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(e){return this.ddDroppable?this.ddDroppable.updateOption(e):this.ddDroppable=new Ut(this.el,e),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}class Wt{resizable(e,t,i,s){return this._getDDElements(e).forEach(r=>{if(t==="disable"||t==="enable")r.ddResizable&&r.ddResizable[t]();else if(t==="destroy")r.ddResizable&&r.cleanResizable();else if(t==="option")r.setupResizable({[i]:s});else{const n=r.el.gridstackNode.grid;let c=r.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";c==="all"&&(c="n,e,s,w,se,sw,ne,nw");const d=!n.opts.alwaysShowResizeHandle;r.setupResizable({...n.opts.resizable,handles:c,autoHide:d,start:t.start,stop:t.stop,resize:t.resize})}}),this}draggable(e,t,i,s){return this._getDDElements(e).forEach(r=>{if(t==="disable"||t==="enable")r.ddDraggable&&r.ddDraggable[t]();else if(t==="destroy")r.ddDraggable&&r.cleanDraggable();else if(t==="option")r.setupDraggable({[i]:s});else{const o=r.el.gridstackNode.grid;r.setupDraggable({...o.opts.draggable,start:t.start,stop:t.stop,drag:t.drag})}}),this}dragIn(e,t){return this._getDDElements(e).forEach(i=>i.setupDraggable(t)),this}droppable(e,t,i,s){return typeof t.accept=="function"&&!t._accept&&(t._accept=t.accept,t.accept=r=>t._accept(r)),this._getDDElements(e).forEach(r=>{t==="disable"||t==="enable"?r.ddDroppable&&r.ddDroppable[t]():t==="destroy"?r.ddDroppable&&r.cleanDroppable():t==="option"?r.setupDroppable({[i]:s}):r.setupDroppable(t)}),this}isDroppable(e){var t;return!!((t=e==null?void 0:e.ddElement)!=null&&t.ddDroppable&&!e.ddElement.ddDroppable.disabled)}isDraggable(e){var t;return!!((t=e==null?void 0:e.ddElement)!=null&&t.ddDraggable&&!e.ddElement.ddDraggable.disabled)}isResizable(e){var t;return!!((t=e==null?void 0:e.ddElement)!=null&&t.ddResizable&&!e.ddElement.ddResizable.disabled)}on(e,t,i){return this._getDDElements(e).forEach(s=>s.on(t,r=>{i(r,C.dragElement?C.dragElement.el:r.target,C.dragElement?C.dragElement.helper:null)})),this}off(e,t){return this._getDDElements(e).forEach(i=>i.off(t)),this}_getDDElements(e,t=!0){const i=u.getElements(e);if(!i.length)return[];const s=i.map(r=>r.ddElement||(t?Ne.init(r):null));return t||s.filter(r=>r),s}}/*!
1
+ (function(E,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("@kong-ui-public/analytics-utilities"),require("@kong-ui-public/analytics-chart"),require("swrv"),require("axios"),require("@kong-ui-public/i18n"),require("@kong-ui-public/analytics-config-store"),require("@kong-ui-public/analytics-metric-provider"),require("@kong/icons")):typeof define=="function"&&define.amd?define(["exports","vue","@kong-ui-public/analytics-utilities","@kong-ui-public/analytics-chart","swrv","axios","@kong-ui-public/i18n","@kong-ui-public/analytics-config-store","@kong-ui-public/analytics-metric-provider","@kong/icons"],o):(E=typeof globalThis<"u"?globalThis:E||self,o(E["kong-ui-public-dashboard-renderer"]={},E.Vue,E["kong-ui-public-analytics-utilities"],E["kong-ui-public-analytics-chart"],E.swrv,E.axios,E["kong-ui-public-i18n"],E["kong-ui-public-analytics-config-store"],E["kong-ui-public-analytics-metric-provider"],E.KongIcons))})(this,function(E,o,z,j,Te,ti,Ie,Be,Pe,qe){"use strict";var Jt=Object.defineProperty;var at=E=>{throw TypeError(E)};var ei=(E,o,z)=>o in E?Jt(E,o,{enumerable:!0,configurable:!0,writable:!0,value:z}):E[o]=z;var lt=(E,o,z)=>ei(E,typeof o!="symbol"?o+"":o,z),Le=(E,o,z)=>o.has(E)||at("Cannot "+z);var w=(E,o,z)=>(Le(E,o,"read from private field"),z?z.call(E):o.get(E)),O=(E,o,z)=>o.has(E)?at("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(E):o.set(E,z),H=(E,o,z,j)=>(Le(E,o,"write to private field"),j?j.call(E,z):o.set(E,z),z),M=(E,o,z)=>(Le(E,o,"access private method"),z);var me=(E,o,z,j)=>({set _(Te){H(E,o,Te,z)},get _(){return w(E,o,j)}});var $,se,re,Z,ce,ne,ue,F,oe,B,fe,G,ae,X,ge,Ce,T,ht,dt,ct,ut,ft,xe,Oe,Me,Re,gt,ke;var $e=(f=>(f.VALIDATING="VALIDATING",f.VALIDATING_HAS_DATA="VALIDATING_HAS_DATA",f.PENDING="PENDING",f.SUCCESS="SUCCESS",f.SUCCESS_HAS_DATA="SUCCESS_HAS_DATA",f.ERROR="ERROR",f.STALE_IF_ERROR="STALE_IF_ERROR",f))($e||{});const mt=f=>{var e,t,i,s,r;return f?!!((e=Object.keys(f))!=null&&e.length||(t=f.data)!=null&&t.length||(s=(i=f.data)==null?void 0:i.data)!=null&&s.length||!((r=f.data)!=null&&r.data)&&typeof f.data=="object"&&Object.keys(f==null?void 0:f.data).length):!1};function pt(f=o.ref({}),e,t,i=mt){const s=o.ref("PENDING");return o.watchEffect(()=>{const r=i(f.value);if(f.value&&r&&t.value){s.value="VALIDATING_HAS_DATA";return}if(f.value&&t.value){s.value="VALIDATING";return}if(f.value&&e.value){s.value="STALE_IF_ERROR";return}if(f.value===void 0&&!e.value){s.value="PENDING";return}if(f.value&&!e.value&&r){s.value="SUCCESS_HAS_DATA";return}if(f.value&&!e.value){s.value="SUCCESS";return}f.value===void 0&&e&&(s.value="ERROR")}),{state:s,swrvState:$e}}const yt={renderer:{noQueryBridge:"No query bridge provided. Unable to render dashboard.",trendRange:{"24h":"Last 24-Hour Summary","7d":"Last 7-Day Summary","30d":"Last 30-Day Summary"},edit:"Edit",duplicateTile:"Duplicate",remove:"Remove"},queryDataProvider:{timeRangeExceeded:"The time range for this report is outside of your organization's data retention period"},csvExport:{defaultFilename:"Chart Export",exportAsCsv:"Export as CSV"},jumpToExplore:"Explore"};function _t(){const f=Ie.createI18n("en-us",yt);return{i18n:f,i18nT:Ie.i18nTComponent(f)}}const pe=170,Q="analytics-query-provider",De="{entity-id}",Fe="{cp-id}",Ge="{timeframe}",Ue=30*1e3;function vt(){const f=o.inject(Q);return{evaluateFeatureFlag:(t,i)=>f?f.evaluateFeatureFlagFn(t,i):i}}function wt(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var We={exports:{}};(function(f){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function s(c,d,l){this.fn=c,this.context=d,this.once=l||!1}function r(c,d,l,h,g){if(typeof l!="function")throw new TypeError("The listener must be a function");var p=new s(l,h||c,g),y=t?t+d:d;return c._events[y]?c._events[y].fn?c._events[y]=[c._events[y],p]:c._events[y].push(p):(c._events[y]=p,c._eventsCount++),c}function a(c,d){--c._eventsCount===0?c._events=new i:delete c._events[d]}function n(){this._events=new i,this._eventsCount=0}n.prototype.eventNames=function(){var d=[],l,h;if(this._eventsCount===0)return d;for(h in l=this._events)e.call(l,h)&&d.push(t?h.slice(1):h);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(l)):d},n.prototype.listeners=function(d){var l=t?t+d:d,h=this._events[l];if(!h)return[];if(h.fn)return[h.fn];for(var g=0,p=h.length,y=new Array(p);g<p;g++)y[g]=h[g].fn;return y},n.prototype.listenerCount=function(d){var l=t?t+d:d,h=this._events[l];return h?h.fn?1:h.length:0},n.prototype.emit=function(d,l,h,g,p,y){var _=t?t+d:d;if(!this._events[_])return!1;var m=this._events[_],k=arguments.length,N,x;if(m.fn){switch(m.once&&this.removeListener(d,m.fn,void 0,!0),k){case 1:return m.fn.call(m.context),!0;case 2:return m.fn.call(m.context,l),!0;case 3:return m.fn.call(m.context,l,h),!0;case 4:return m.fn.call(m.context,l,h,g),!0;case 5:return m.fn.call(m.context,l,h,g,p),!0;case 6:return m.fn.call(m.context,l,h,g,p,y),!0}for(x=1,N=new Array(k-1);x<k;x++)N[x-1]=arguments[x];m.fn.apply(m.context,N)}else{var L=m.length,S;for(x=0;x<L;x++)switch(m[x].once&&this.removeListener(d,m[x].fn,void 0,!0),k){case 1:m[x].fn.call(m[x].context);break;case 2:m[x].fn.call(m[x].context,l);break;case 3:m[x].fn.call(m[x].context,l,h);break;case 4:m[x].fn.call(m[x].context,l,h,g);break;default:if(!N)for(S=1,N=new Array(k-1);S<k;S++)N[S-1]=arguments[S];m[x].fn.apply(m[x].context,N)}}return!0},n.prototype.on=function(d,l,h){return r(this,d,l,h,!1)},n.prototype.once=function(d,l,h){return r(this,d,l,h,!0)},n.prototype.removeListener=function(d,l,h,g){var p=t?t+d:d;if(!this._events[p])return this;if(!l)return a(this,p),this;var y=this._events[p];if(y.fn)y.fn===l&&(!g||y.once)&&(!h||y.context===h)&&a(this,p);else{for(var _=0,m=[],k=y.length;_<k;_++)(y[_].fn!==l||g&&!y[_].once||h&&y[_].context!==h)&&m.push(y[_]);m.length?this._events[p]=m.length===1?m[0]:m:a(this,p)}return this},n.prototype.removeAllListeners=function(d){var l;return d?(l=t?t+d:d,this._events[l]&&a(this,l)):(this._events=new i,this._eventsCount=0),this},n.prototype.off=n.prototype.removeListener,n.prototype.addListener=n.prototype.on,n.prefixed=t,n.EventEmitter=n,f.exports=n})(We);var bt=We.exports;const Et=wt(bt);class Ve extends Error{constructor(e){super(e),this.name="TimeoutError"}}class Ct extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Ke=f=>globalThis.DOMException===void 0?new Ct(f):new DOMException(f),Ye=f=>{const e=f.reason===void 0?Ke("This operation was aborted."):f.reason;return e instanceof Error?e:Ke(e)};function xt(f,e){const{milliseconds:t,fallback:i,message:s,customTimers:r={setTimeout,clearTimeout}}=e;let a,n;const d=new Promise((l,h)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){const{signal:p}=e;p.aborted&&h(Ye(p)),n=()=>{h(Ye(p))},p.addEventListener("abort",n,{once:!0})}if(t===Number.POSITIVE_INFINITY){f.then(l,h);return}const g=new Ve;a=r.setTimeout.call(void 0,()=>{if(i){try{l(i())}catch(p){h(p)}return}typeof f.cancel=="function"&&f.cancel(),s===!1?l():s instanceof Error?h(s):(g.message=s??`Promise timed out after ${t} milliseconds`,h(g))},t),(async()=>{try{l(await f)}catch(p){h(p)}})()}).finally(()=>{d.clear(),n&&e.signal&&e.signal.removeEventListener("abort",n)});return d.clear=()=>{r.clearTimeout.call(void 0,a),a=void 0},d}function Rt(f,e,t){let i=0,s=f.length;for(;s>0;){const r=Math.trunc(s/2);let a=i+r;t(f[a],e)<=0?(i=++a,s-=r+1):s=r}return i}class kt{constructor(){O(this,$,[])}enqueue(e,t){t={priority:0,...t};const i={priority:t.priority,id:t.id,run:e};if(this.size===0||w(this,$)[this.size-1].priority>=t.priority){w(this,$).push(i);return}const s=Rt(w(this,$),i,(r,a)=>a.priority-r.priority);w(this,$).splice(s,0,i)}setPriority(e,t){const i=w(this,$).findIndex(r=>r.id===e);if(i===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);const[s]=w(this,$).splice(i,1);this.enqueue(s.run,{priority:t,id:e})}dequeue(){const e=w(this,$).shift();return e==null?void 0:e.run}filter(e){return w(this,$).filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return w(this,$).length}}$=new WeakMap;class Tt extends Et{constructor(t){var i,s;super();O(this,T);O(this,se);O(this,re);O(this,Z,0);O(this,ce);O(this,ne);O(this,ue,0);O(this,F);O(this,oe);O(this,B);O(this,fe);O(this,G,0);O(this,ae);O(this,X);O(this,ge);O(this,Ce,1n);lt(this,"timeout");if(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:kt,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${((i=t.intervalCap)==null?void 0:i.toString())??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${((s=t.interval)==null?void 0:s.toString())??""}\` (${typeof t.interval})`);H(this,se,t.carryoverConcurrencyCount),H(this,re,t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0),H(this,ce,t.intervalCap),H(this,ne,t.interval),H(this,B,new t.queueClass),H(this,fe,t.queueClass),this.concurrency=t.concurrency,this.timeout=t.timeout,H(this,ge,t.throwOnTimeout===!0),H(this,X,t.autoStart===!1)}get concurrency(){return w(this,ae)}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);H(this,ae,t),M(this,T,Re).call(this)}setPriority(t,i){w(this,B).setPriority(t,i)}async add(t,i={}){return i.id??(i.id=(me(this,Ce)._++).toString()),i={timeout:this.timeout,throwOnTimeout:w(this,ge),...i},new Promise((s,r)=>{w(this,B).enqueue(async()=>{var a;me(this,G)._++,me(this,Z)._++;try{(a=i.signal)==null||a.throwIfAborted();let n=t({signal:i.signal});i.timeout&&(n=xt(Promise.resolve(n),{milliseconds:i.timeout})),i.signal&&(n=Promise.race([n,M(this,T,gt).call(this,i.signal)]));const c=await n;s(c),this.emit("completed",c)}catch(n){if(n instanceof Ve&&!i.throwOnTimeout){s();return}r(n),this.emit("error",n)}finally{M(this,T,ct).call(this)}},i),this.emit("add"),M(this,T,xe).call(this)})}async addAll(t,i){return Promise.all(t.map(async s=>this.add(s,i)))}start(){return w(this,X)?(H(this,X,!1),M(this,T,Re).call(this),this):this}pause(){H(this,X,!0)}clear(){H(this,B,new(w(this,fe)))}async onEmpty(){w(this,B).size!==0&&await M(this,T,ke).call(this,"empty")}async onSizeLessThan(t){w(this,B).size<t||await M(this,T,ke).call(this,"next",()=>w(this,B).size<t)}async onIdle(){w(this,G)===0&&w(this,B).size===0||await M(this,T,ke).call(this,"idle")}get size(){return w(this,B).size}sizeBy(t){return w(this,B).filter(t).length}get pending(){return w(this,G)}get isPaused(){return w(this,X)}}se=new WeakMap,re=new WeakMap,Z=new WeakMap,ce=new WeakMap,ne=new WeakMap,ue=new WeakMap,F=new WeakMap,oe=new WeakMap,B=new WeakMap,fe=new WeakMap,G=new WeakMap,ae=new WeakMap,X=new WeakMap,ge=new WeakMap,Ce=new WeakMap,T=new WeakSet,ht=function(){return w(this,re)||w(this,Z)<w(this,ce)},dt=function(){return w(this,G)<w(this,ae)},ct=function(){me(this,G)._--,M(this,T,xe).call(this),this.emit("next")},ut=function(){M(this,T,Me).call(this),M(this,T,Oe).call(this),H(this,oe,void 0)},ft=function(){const t=Date.now();if(w(this,F)===void 0){const i=w(this,ue)-t;if(i<0)H(this,Z,w(this,se)?w(this,G):0);else return w(this,oe)===void 0&&H(this,oe,setTimeout(()=>{M(this,T,ut).call(this)},i)),!0}return!1},xe=function(){if(w(this,B).size===0)return w(this,F)&&clearInterval(w(this,F)),H(this,F,void 0),this.emit("empty"),w(this,G)===0&&this.emit("idle"),!1;if(!w(this,X)){const t=!w(this,T,ft);if(w(this,T,ht)&&w(this,T,dt)){const i=w(this,B).dequeue();return i?(this.emit("active"),i(),t&&M(this,T,Oe).call(this),!0):!1}}return!1},Oe=function(){w(this,re)||w(this,F)!==void 0||(H(this,F,setInterval(()=>{M(this,T,Me).call(this)},w(this,ne))),H(this,ue,Date.now()+w(this,ne)))},Me=function(){w(this,Z)===0&&w(this,G)===0&&w(this,F)&&(clearInterval(w(this,F)),H(this,F,void 0)),H(this,Z,w(this,se)?w(this,G):0),M(this,T,Re).call(this)},Re=function(){for(;M(this,T,xe).call(this););},gt=async function(t){return new Promise((i,s)=>{t.addEventListener("abort",()=>{s(t.reason)},{once:!0})})},ke=async function(t,i){return new Promise(s=>{const r=()=>{i&&!i()||(this.off(t,r),s())};this.on(t,r)})};const ie={useI18n:_t,useEvaluateFeatureFlag:vt,useRequestQueue:()=>{const f=Be.useAnalyticsConfigStore(),e=o.inject(Q);if(!e)return;if(e.queryFnOverride){console.warn("Detected incorrect use of useRequestQueue. This composable should not be used in nested components. Please discuss with team-data or report an issue if you feel you have a use case.");return}const t=new Tt({carryoverConcurrencyCount:!0,concurrency:f.maxParallelRequests,interval:f.requestInterval,intervalCap:f.requestIntervalCap}),i={...e,queryFnOverride:!0,queryFn:(s,r)=>t.add(()=>e.queryFn(s,r),{throwOnTimeout:!0})};o.provide(Q,i)}},ze=o.defineComponent({__name:"QueryDataProvider",props:{context:{},query:{},queryReady:{type:Boolean},refreshCounter:{}},emits:["chart-data","queryComplete"],setup(f,{emit:e}){const t=f,i=e,{i18n:s}=ie.useI18n(),r=o.inject(Q),a=()=>t.queryReady&&r?JSON.stringify([t.query,t.context,t.refreshCounter]):null,n=new AbortController;o.onUnmounted(()=>{n.abort()});const c=(k,N,x)=>{const L=[];return N&&L.push(...N),L.push(...z.stripUnknownFilters(k,x)),L},{data:d,error:l,isValidating:h}=Te(a,async()=>{var k,N,x,L;try{let{datasource:S,...R}=t.query;S||(S="basic");const A=c(S,t.query.filters,t.context.filters);let D=t.query.time_range;D?D.tz||(D={...D,tz:t.context.tz}):D={...t.context.timeSpec,tz:t.context.tz};const P={datasource:S,query:{...R,time_range:D,filters:A}};return r==null?void 0:r.queryFn(P,n)}catch(S){y.value=((N=(k=S==null?void 0:S.response)==null?void 0:k.data)==null?void 0:N.message)==="Range not allowed for this tier"?s.t("queryDataProvider.timeRangeExceeded"):((L=(x=S==null?void 0:S.response)==null?void 0:x.data)==null?void 0:L.message)||(S==null?void 0:S.message)}finally{i("queryComplete")}},{refreshInterval:t.context.refreshInterval,revalidateOnFocus:!1}),{state:g,swrvState:p}=pt(d,l,h),y=o.ref(null),_=o.computed(()=>g.value===p.ERROR||!!y.value),m=o.computed(()=>!t.queryReady||g.value===p.PENDING);return o.watch(d,k=>{k&&i("chart-data",k)}),(k,N)=>{const x=o.resolveComponent("KSkeleton"),L=o.resolveComponent("KEmptyState");return m.value||!o.unref(d)&&!_.value?(o.openBlock(),o.createBlock(x,{key:0,class:"chart-skeleton",type:"table"})):_.value?(o.openBlock(),o.createBlock(L,{key:1,"action-button-visible":!1,"data-testid":"chart-empty-state","icon-variant":"error"},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(y.value),1)]),_:1})):o.unref(d)?o.renderSlot(k.$slots,"default",{key:2,data:o.unref(d)}):o.createCommentVNode("",!0)}}}),Dt=o.defineComponent({__name:"SimpleChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){o.useCssVars(i=>({"35a26ebf":`${i.height}px`}));const e=f,t=o.computed(()=>e.chartOptions.type==="single_value");return(i,s)=>(o.openBlock(),o.createBlock(ze,{context:i.context,query:i.query,"query-ready":i.queryReady,"refresh-counter":i.refreshCounter},{default:o.withCtx(({data:r})=>[o.createElementVNode("div",{class:o.normalizeClass(["analytics-chart",{"single-value":t.value}])},[o.createVNode(o.unref(j.SimpleChart),{"chart-data":r,"chart-options":i.chartOptions,"synthetics-data-key":t.value?void 0:i.chartOptions.syntheticsDataKey},null,8,["chart-data","chart-options","synthetics-data-key"])],2)]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),ee=(f,e)=>{const t=f.__vccOpts||f;for(const[i,s]of e)t[i]=s;return t},je=ee(Dt,[["__scopeId","data-v-65cc8607"]]),zt={class:"analytics-chart"},Se=ee(o.defineComponent({__name:"BaseAnalyticsChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{},extraProps:{}},emits:["edit-tile","chart-data","zoom-time-range"],setup(f,{emit:e}){const t=f,i=e,{i18n:s}=ie.useI18n(),{evaluateFeatureFlag:r}=ie.useEvaluateFeatureFlag(),a=r("explore-v4-fine-granularity",!1),n=o.computed(()=>({type:t.chartOptions.type,stacked:t.chartOptions.stacked??!1,chartDatasetColors:t.chartOptions.chartDatasetColors,threshold:t.chartOptions.threshold})),c=()=>{i("edit-tile")},d=l=>{i("chart-data",l)};return(l,h)=>{const g=o.resolveComponent("KDropdownItem");return o.openBlock(),o.createBlock(ze,{context:l.context,query:l.query,"query-ready":l.queryReady,"refresh-counter":l.refreshCounter,onChartData:d},{default:o.withCtx(({data:p})=>[o.createElementVNode("div",zt,[o.createVNode(o.unref(j.AnalyticsChart),o.mergeProps({"allow-csv-export":l.chartOptions.allowCsvExport,"chart-data":p,"chart-options":n.value,"legend-position":"bottom","show-menu":l.context.editable,"synthetics-data-key":l.chartOptions.syntheticsDataKey,"timeseries-zoom":o.unref(a)&&!l.query.time_range,"tooltip-title":""},l.extraProps,{onZoomTimeRange:h[0]||(h[0]=y=>i("zoom-time-range",y))}),o.createSlots({_:2},[l.context.editable?{name:"menu-items",fn:o.withCtx(()=>[o.createVNode(g,{onClick:c},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(o.unref(s).t("renderer.edit")),1)]),_:1})]),key:"0"}:void 0]),1040,["allow-csv-export","chart-data","chart-options","show-menu","synthetics-data-key","timeseries-zoom"])])]),_:1},8,["context","query","query-ready","refresh-counter"])}}}),[["__scopeId","data-v-a9ee3db9"]]),Xe=o.defineComponent({__name:"BarChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(o.openBlock(),o.createBlock(Se,{"chart-options":e.chartOptions,context:e.context,"extra-props":{showAnnotations:!1},height:e.height,query:e.query,"query-ready":e.queryReady,"refresh-counter":e.refreshCounter},null,8,["chart-options","context","height","query","query-ready","refresh-counter"]))}}),Qe=o.defineComponent({__name:"TimeseriesChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},emits:["zoom-time-range"],setup(f,{emit:e}){const t=e;return(i,s)=>(o.openBlock(),o.createBlock(Se,{"chart-options":i.chartOptions,context:i.context,height:i.height,query:i.query,"query-ready":i.queryReady,"refresh-counter":i.refreshCounter,onZoomTimeRange:s[0]||(s[0]=r=>t("zoom-time-range",r))},null,8,["chart-options","context","height","query","query-ready","refresh-counter"]))}}),St={class:"metric-card-tile-wrapper"},Nt=ee(o.defineComponent({__name:"GoldenSignalsRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){const e=f,t=o.computed(()=>{const s=e.context.timeSpec;if(s.type==="absolute")return new z.Timeframe({key:"custom",timeframeText:"custom",display:"custom",startCustom:s.start,endCustom:s.end,timeframeLength:()=>s.end.getTime()-s.start.getTime(),defaultResponseGranularity:"daily",dataGranularity:"daily",isRelative:!1,allowedTiers:["free","plus","enterprise"]});const r=z.TimePeriods.get(s.time_range);if(!r)throw new Error("Unknown time range");return r}),i=o.computed(()=>{var r,a;const s=(r=e.query)==null?void 0:r.datasource;if(s&&s!=="advanced"&&s!=="basic")throw new Error(`Invalid datasource value: ${s}`);return{datasource:(a=e.query)==null?void 0:a.datasource,overrideTimeframe:t.value,tz:e.context.tz,additionalFilter:e.context.filters,longCardTitles:e.chartOptions.longCardTitles,percentileLatency:e.chartOptions.percentileLatency,refreshInterval:e.context.refreshInterval,queryReady:e.queryReady,refreshCounter:e.refreshCounter}});return(s,r)=>(o.openBlock(),o.createElementBlock("div",St,[o.createVNode(o.unref(Pe.MetricsProvider),o.normalizeProps(o.guardReactiveProps(i.value)),{default:o.withCtx(()=>[o.createVNode(o.unref(Pe.MetricsConsumer))]),_:1},16)]))}}),[["__scopeId","data-v-bd5889d1"]]),Ze="#6c7489",Je="20px",et="20px",At={class:"fallback-entity-link","data-testid":"entity-link-parent"},tt=o.defineComponent({__name:"FallbackEntityLink",props:{entityLinkData:{}},setup(f){return(e,t)=>(o.openBlock(),o.createElementBlock("div",At,o.toDisplayString(e.entityLinkData.label),1))}}),Ht=o.defineComponent({__name:"TopNTableRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){const e=f,t=o.inject(Q),i=o.defineAsyncComponent(async()=>{if(t!=null&&t.fetchComponent)try{return await t.fetchComponent("EntityLink")}catch{return tt}return tt}),s=r=>{var a;if((a=e.chartOptions)!=null&&a.entityLink)if(r.id.includes(":")){const[n,c]=r.id.split(":");return e.chartOptions.entityLink.replace(Fe,n).replace(De,c)}else return e.chartOptions.entityLink.replace(De,r.id);return""};return(r,a)=>(o.openBlock(),o.createBlock(ze,{context:r.context,query:r.query,"query-ready":r.queryReady,"refresh-counter":r.refreshCounter},{default:o.withCtx(({data:n})=>[o.createVNode(o.unref(j.TopNTable),{data:n,"synthetics-data-key":r.chartOptions.syntheticsDataKey},o.createSlots({_:2},[e.chartOptions.entityLink?{name:"name",fn:o.withCtx(({record:c})=>[o.createVNode(o.unref(i),{"entity-link-data":{id:c.id,label:c.name,deleted:c.deleted},"external-link":s(c)},null,8,["entity-link-data","external-link"])]),key:"0"}:void 0]),1032,["data","synthetics-data-key"])]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),Lt=o.defineComponent({__name:"DonutChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(o.openBlock(),o.createBlock(Se,{"chart-options":e.chartOptions,context:e.context,height:e.height,query:e.query,"query-ready":e.queryReady,"refresh-counter":e.refreshCounter},null,8,["chart-options","context","height","query","query-ready","refresh-counter"]))}}),Ot=["data-testid"],Mt={key:0,class:"tile-header"},It=["data-testid"],Bt=["data-testid"],Pt=["data-testid"],qt=["data-testid"],$t=ee(o.defineComponent({__name:"DashboardTile",props:{definition:{},context:{},height:{default:pe},queryReady:{type:Boolean},refreshCounter:{},tileId:{}},emits:["edit-tile","duplicate-tile","remove-tile","zoom-time-range"],setup(f,{emit:e}){o.useCssVars(v=>({"32c3e459":`${v.height}px`}));const t=parseInt(et,10),i=f,s=e,r=o.inject(Q),{i18n:a}=ie.useI18n(),n=o.ref(),c=o.ref(!1),d=o.ref(),l=o.ref(!1),h=o.ref("");o.onMounted(async()=>{var v;h.value=await((v=r==null?void 0:r.exploreBaseUrl)==null?void 0:v.call(r))??""}),o.watch(()=>i.definition,async()=>{await o.nextTick(),d.value&&(l.value=d.value.scrollWidth>d.value.clientWidth)},{immediate:!0,deep:!0});const g=o.computed(()=>{if(!h.value||!i.definition.query||!_.value)return"";const v=[...i.context.filters,...i.definition.query.filters??[]],Y=i.definition.query.dimensions??[],W=new Set(["portal","api"]);if(v.some(J=>"dimension"in J&&W.has(J.dimension)||"field"in J&&W.has(J.field))||Y.some(J=>W.has(J)))return"";const He={filters:v,metrics:i.definition.query.metrics??[],dimensions:Y,time_range:i.definition.query.time_range||i.context.timeSpec,granularity:i.definition.query.granularity||L.value},le=["advanced","ai"].includes(i.definition.query.datasource)?i.definition.query.datasource:"advanced";return`${h.value}?q=${JSON.stringify(He)}&d=${le}&c=${i.definition.chart.type}`}),p=o.computed(()=>a.t("csvExport.defaultFilename")),y=o.computed(()=>_.value&&(m.value||i.context.editable)||!!x.value),_=o.computed(()=>!["golden_signals","top_n","gauge"].includes(i.definition.chart.type)),m=o.computed(()=>!!g.value||"allowCsvExport"in i.definition.chart&&i.definition.chart.allowCsvExport||i.context.editable),k={timeseries_line:Qe,timeseries_bar:Qe,horizontal_bar:Xe,vertical_bar:Xe,gauge:je,donut:Lt,golden_signals:Nt,top_n:Ht,slottable:void 0,single_value:je},N=o.computed(()=>{const v=k[i.definition.chart.type];return v&&{component:v,rendererProps:{query:i.definition.query,context:i.context,queryReady:i.queryReady,chartOptions:i.definition.chart,height:i.height-t*2,refreshCounter:i.refreshCounter}}}),x=o.computed(()=>{var Y;const v=(Y=i.definition.query)==null?void 0:Y.time_range;if((v==null?void 0:v.type)==="relative"){const W=z.TimePeriods.get(z.TIMEFRAME_LOOKUP[v.time_range]);return W?W.display:(console.warn("Did not recognize the given relative time range:",v.time_range),v.time_range)}else if((v==null?void 0:v.type)==="absolute"){const W=v.tz||"Etc/UTC";return`${z.formatTime(v.start,{short:!0,tz:W})} - ${z.formatTime(v.end,{short:!0,tz:W})}`}return null}),L=o.computed(()=>n.value?z.msToGranularity(n.value.meta.granularity_ms):void 0),S=()=>{s("edit-tile",i.definition)},R=()=>{s("duplicate-tile",i.definition)},A=()=>{s("remove-tile",i.definition)},D=v=>{n.value=v},P=v=>{c.value=v},te=()=>{P(!0)};return(v,Y)=>{const W=o.resolveComponent("KTooltip"),He=o.resolveComponent("KBadge"),le=o.resolveComponent("KDropdownItem"),J=o.resolveComponent("KDropdown");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["tile-boundary",{editable:v.context.editable}]),"data-testid":`tile-${v.tileId}`},[v.definition.chart.type!=="slottable"?(o.openBlock(),o.createElementBlock("div",Mt,[o.createVNode(W,{class:"title-tooltip",disabled:!l.value,"max-width":"500",text:v.definition.chart.chartTitle},{default:o.withCtx(()=>[o.createElementVNode("div",{ref_key:"titleRef",ref:d,class:"title"},o.toDisplayString(v.definition.chart.chartTitle),513)]),_:1},8,["disabled","text"]),y.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"tile-actions","data-testid":`tile-actions-${v.tileId}`},[x.value?(o.openBlock(),o.createBlock(He,{key:0},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(x.value),1)]),_:1})):o.createCommentVNode("",!0),_.value&&v.context.editable?(o.openBlock(),o.createBlock(o.unref(qe.EditIcon),{key:1,class:"edit-icon",color:o.unref(Ze),"data-testid":`edit-tile-${v.tileId}`,size:o.unref(Je),onClick:S},null,8,["color","data-testid","size"])):o.createCommentVNode("",!0),_.value&&m.value?(o.openBlock(),o.createBlock(J,{key:2,class:"dropdown","data-testid":`chart-action-menu-${v.tileId}`,"kpop-attributes":{placement:"bottom-end"}},{items:o.withCtx(()=>[g.value?(o.openBlock(),o.createBlock(le,{key:0,"data-testid":`chart-jump-to-explore-${v.tileId}`,item:{label:o.unref(a).t("jumpToExplore"),to:g.value}},null,8,["data-testid","item"])):o.createCommentVNode("",!0),!("allowCsvExport"in v.definition.chart)||v.definition.chart.allowCsvExport?(o.openBlock(),o.createBlock(le,{key:1,class:"chart-export-button","data-testid":`chart-csv-export-${v.tileId}`,onClick:Y[0]||(Y[0]=ot=>te())},{default:o.withCtx(()=>[o.createElementVNode("span",{class:"chart-export-trigger","data-testid":`csv-export-button-${v.tileId}`},o.toDisplayString(o.unref(a).t("csvExport.exportAsCsv")),9,Bt)]),_:1},8,["data-testid"])):o.createCommentVNode("",!0),v.context.editable?(o.openBlock(),o.createBlock(le,{key:2,"data-testid":`duplicate-tile-${v.tileId}`,onClick:R},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(o.unref(a).t("renderer.duplicateTile")),1)]),_:1},8,["data-testid"])):o.createCommentVNode("",!0),v.context.editable?(o.openBlock(),o.createBlock(le,{key:3,"data-testid":`remove-tile-${v.tileId}`,onClick:A},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(o.unref(a).t("renderer.remove")),1)]),_:1},8,["data-testid"])):o.createCommentVNode("",!0)]),default:o.withCtx(()=>[o.createVNode(o.unref(qe.MoreIcon),{class:"kebab-action-menu",color:o.unref(Ze),"data-testid":`kebab-action-menu-${v.tileId}`,size:o.unref(Je)},null,8,["color","data-testid","size"])]),_:1},8,["data-testid"])):o.createCommentVNode("",!0)],8,It)):"description"in v.definition.chart?(o.openBlock(),o.createElementBlock("div",{key:1,class:"header-description","data-testid":`tile-description-${v.tileId}`},o.toDisplayString(v.definition.chart.description),9,Pt)):o.createCommentVNode("",!0),c.value?(o.openBlock(),o.createBlock(o.unref(j.CsvExportModal),{key:2,"chart-data":n.value,"data-testid":`csv-export-modal-${v.tileId}`,filename:p.value,onToggleModal:P},null,8,["chart-data","data-testid","filename"])):o.createCommentVNode("",!0)])):o.createCommentVNode("",!0),o.createElementVNode("div",{class:"tile-content","data-testid":`tile-content-${v.tileId}`},[N.value?(o.openBlock(),o.createBlock(o.resolveDynamicComponent(N.value.component),o.mergeProps({key:0},N.value.rendererProps,{onChartData:D,onZoomTimeRange:Y[1]||(Y[1]=ot=>s("zoom-time-range",ot))}),null,16)):o.createCommentVNode("",!0)],8,qt)],10,Ot)}}}),[["__scopeId","data-v-e670d00d"]]),Ft=(f,e,t)=>{const i=new Map;t.forEach(r=>{const a=r.layout.position.row,n=i.get(a),c=r.layout.size.rows===1&&!!r.layout.size.fitToContent;n===void 0?i.set(a,c):i.set(a,n&&c)});const s=[];for(let r=0;r<f;r++)i.get(r)?s.push("auto"):s.push(`${e}px`);return s},it=ee(o.defineComponent({__name:"GridLayout",props:{gridSize:{type:Object,required:!0},tileHeight:{type:Number,required:!1,default:()=>pe},tiles:{type:Array,required:!0}},setup(f){o.useCssVars(n=>({"3bc5e939":f.gridSize.cols,"77aa3028":r.value}));const e=f,t=o.ref(null),i=o.ref(0),s=new ResizeObserver(n=>{window.requestAnimationFrame(()=>{!Array.isArray(n)||!n.length||(i.value=n[0].contentRect.width)})});o.onMounted(()=>{t.value&&s.observe(t.value)}),o.onUnmounted(()=>{t.value&&s.unobserve(t.value)});const r=o.computed(()=>{var c;return Ft((c=e.gridSize)==null?void 0:c.rows,e.tileHeight,e.tiles).join(" ")}),a=o.computed(()=>e.tiles.map((n,c)=>({key:`tile-${c}`,tile:n,style:{"grid-column-start":n.layout.position.col+1,"grid-column-end":n.layout.position.col+1+n.layout.size.cols,"grid-row-start":n.layout.position.row+1,"grid-row-end":n.layout.position.row+1+n.layout.size.rows}})));return(n,c)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"gridContainer",ref:t,class:"kong-ui-public-grid-layout"},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(a.value,d=>(o.openBlock(),o.createElementBlock("div",{key:d.key,class:o.normalizeClass(["grid-cell",{"empty-cell":!d.tile}]),style:o.normalizeStyle(d.style)},[o.renderSlot(n.$slots,"tile",{style:o.normalizeStyle(d.style),tile:d.tile},void 0,!0)],6))),128))],512))}}),[["__scopeId","data-v-f43eb7b8"]]);function Gt(f,e,t,i,s){const r=(...a)=>(console.warn("gridstack.js: Function `"+t+"` is deprecated in "+s+" and has been replaced with `"+i+"`. It will be **removed** in a future release"),e.apply(f,a));return r.prototype=e.prototype,r}class u{static getElements(e,t=document){if(typeof e=="string"){const i="getElementById"in t?t:void 0;if(i&&!isNaN(+e[0])){const r=i.getElementById(e);return r?[r]:[]}let s=t.querySelectorAll(e);return!s.length&&e[0]!=="."&&e[0]!=="#"&&(s=t.querySelectorAll("."+e),s.length||(s=t.querySelectorAll("#"+e))),Array.from(s)}return[e]}static getElement(e,t=document){if(typeof e=="string"){const i="getElementById"in t?t:void 0;if(!e.length)return null;if(i&&e[0]==="#")return i.getElementById(e.substring(1));if(e[0]==="#"||e[0]==="."||e[0]==="[")return t.querySelector(e);if(i&&!isNaN(+e[0]))return i.getElementById(e);let s=t.querySelector(e);return i&&!s&&(s=i.getElementById(e)),s||(s=t.querySelector("."+e)),s}return e}static createWidgetDivs(e,t){var a,n;const i=u.createDiv(["grid-stack-item",e]),s=u.createDiv(["grid-stack-item-content"],i);return t.lazyLoad||((n=(a=t.grid)==null?void 0:a.opts)==null?void 0:n.lazyLoad)&&t.lazyLoad!==!1?t.visibleObservable||(t.visibleObservable=new IntersectionObserver(([c])=>{var d;c.isIntersecting&&((d=t.visibleObservable)==null||d.disconnect(),delete t.visibleObservable,b.renderCB(s,t))}),window.setTimeout(()=>{var c;return(c=t.visibleObservable)==null?void 0:c.observe(i)})):b.renderCB(s,t),i}static createDiv(e,t){const i=document.createElement("div");return e.forEach(s=>{s&&i.classList.add(s)}),t==null||t.appendChild(i),i}static shouldSizeToContent(e,t=!1){return(e==null?void 0:e.grid)&&(t?e.sizeToContent===!0||e.grid.opts.sizeToContent===!0&&e.sizeToContent===void 0:!!e.sizeToContent||e.grid.opts.sizeToContent&&e.sizeToContent!==!1)}static isIntercepted(e,t){return!(e.y>=t.y+t.h||e.y+e.h<=t.y||e.x+e.w<=t.x||e.x>=t.x+t.w)}static isTouching(e,t){return u.isIntercepted(e,{x:t.x-.5,y:t.y-.5,w:t.w+1,h:t.h+1})}static areaIntercept(e,t){const i=e.x>t.x?e.x:t.x,s=e.x+e.w<t.x+t.w?e.x+e.w:t.x+t.w;if(s<=i)return 0;const r=e.y>t.y?e.y:t.y,a=e.y+e.h<t.y+t.h?e.y+e.h:t.y+t.h;return a<=r?0:(s-i)*(a-r)}static area(e){return e.w*e.h}static sort(e,t=1){return e.sort((s,r)=>{const a=t*((s.y??1e4)-(r.y??1e4));return a===0?t*((s.x??1e4)-(r.x??1e4)):a})}static find(e,t){return t?e.find(i=>i.id===t):void 0}static createStylesheet(e,t,i){const s=document.createElement("style"),r=i==null?void 0:i.nonce;return r&&(s.nonce=r),s.setAttribute("type","text/css"),s.setAttribute("gs-style-id",e),s.styleSheet?s.styleSheet.cssText="":s.appendChild(document.createTextNode("")),t?t.insertBefore(s,t.firstChild):(t=document.getElementsByTagName("head")[0],t.appendChild(s)),s}static removeStylesheet(e,t){const s=(t||document).querySelector("STYLE[gs-style-id="+e+"]");s&&s.parentNode&&s.remove()}static addCSSRule(e,t,i){e.textContent+=`${t} { ${i} } `}static toBool(e){return typeof e=="boolean"?e:typeof e=="string"?(e=e.toLowerCase(),!(e===""||e==="no"||e==="false"||e==="0")):!!e}static toNumber(e){return e===null||e.length===0?void 0:Number(e)}static parseHeight(e){let t,i="px";if(typeof e=="string")if(e==="auto"||e==="")t=0;else{const s=e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!s)throw new Error(`Invalid height val = ${e}`);i=s[2]||"px",t=parseFloat(s[1])}else t=e;return{h:t,unit:i}}static defaults(e,...t){return t.forEach(i=>{for(const s in i){if(!i.hasOwnProperty(s))return;e[s]===null||e[s]===void 0?e[s]=i[s]:typeof i[s]=="object"&&typeof e[s]=="object"&&this.defaults(e[s],i[s])}}),e}static same(e,t){if(typeof e!="object")return e==t;if(typeof e!=typeof t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(e[i]!==t[i])return!1;return!0}static copyPos(e,t,i=!1){return t.x!==void 0&&(e.x=t.x),t.y!==void 0&&(e.y=t.y),t.w!==void 0&&(e.w=t.w),t.h!==void 0&&(e.h=t.h),i&&(t.minW&&(e.minW=t.minW),t.minH&&(e.minH=t.minH),t.maxW&&(e.maxW=t.maxW),t.maxH&&(e.maxH=t.maxH)),e}static samePos(e,t){return e&&t&&e.x===t.x&&e.y===t.y&&(e.w||1)===(t.w||1)&&(e.h||1)===(t.h||1)}static sanitizeMinMax(e){e.minW||delete e.minW,e.minH||delete e.minH,e.maxW||delete e.maxW,e.maxH||delete e.maxH}static removeInternalAndSame(e,t){if(!(typeof e!="object"||typeof t!="object"))for(let i in e){const s=e[i],r=t[i];i[0]==="_"||s===r?delete e[i]:s&&typeof s=="object"&&r!==void 0&&(u.removeInternalAndSame(s,r),Object.keys(s).length||delete e[i])}}static removeInternalForSave(e,t=!0){for(let i in e)(i[0]==="_"||e[i]===null||e[i]===void 0)&&delete e[i];delete e.grid,t&&delete e.el,e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,e.locked||delete e.locked,(e.w===1||e.w===e.minW)&&delete e.w,(e.h===1||e.h===e.minH)&&delete e.h}static throttle(e,t){let i=!1;return(...s)=>{i||(i=!0,setTimeout(()=>{e(...s),i=!1},t))}}static removePositioningStyles(e){const t=e.style;t.position&&t.removeProperty("position"),t.left&&t.removeProperty("left"),t.top&&t.removeProperty("top"),t.width&&t.removeProperty("width"),t.height&&t.removeProperty("height")}static getScrollElement(e){if(!e)return document.scrollingElement||document.documentElement;const t=getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowY)?e:this.getScrollElement(e.parentElement)}static updateScrollPosition(e,t,i){const s=e.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight;if(s.top<0||s.bottom>r){const a=s.bottom-r,n=s.top,c=this.getScrollElement(e);if(c!==null){const d=c.scrollTop;s.top<0&&i<0?e.offsetHeight>r?c.scrollTop+=i:c.scrollTop+=Math.abs(n)>Math.abs(i)?i:n:i>0&&(e.offsetHeight>r?c.scrollTop+=i:c.scrollTop+=a>i?i:a),t.top+=c.scrollTop-d}}}static updateScrollResize(e,t,i){const s=this.getScrollElement(t),r=s.clientHeight,a=s===this.getScrollElement()?0:s.getBoundingClientRect().top,n=e.clientY-a,c=n<i,d=n>r-i;c?s.scrollBy({behavior:"smooth",top:n-i}):d&&s.scrollBy({behavior:"smooth",top:i-(r-n)})}static clone(e){return e==null||typeof e!="object"?e:e instanceof Array?[...e]:{...e}}static cloneDeep(e){const t=["parentGrid","el","grid","subGrid","engine"],i=u.clone(e);for(const s in i)i.hasOwnProperty(s)&&typeof i[s]=="object"&&s.substring(0,2)!=="__"&&!t.find(r=>r===s)&&(i[s]=u.cloneDeep(e[s]));return i}static cloneNode(e){const t=e.cloneNode(!0);return t.removeAttribute("id"),t}static appendTo(e,t){let i;typeof t=="string"?i=u.getElement(t):i=t,i&&i.appendChild(e)}static addElStyles(e,t){if(t instanceof Object)for(const i in t)t.hasOwnProperty(i)&&(Array.isArray(t[i])?t[i].forEach(s=>{e.style[i]=s}):e.style[i]=t[i])}static initEvent(e,t){const i={type:t.type},s={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:t.target?t.target:e.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(r=>i[r]=e[r]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(r=>i[r]=e[r]),{...i,...s}}static simulateMouseEvent(e,t,i){const s=document.createEvent("MouseEvents");s.initMouseEvent(t,!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,e.ctrlKey,e.altKey,e.shiftKey,e.metaKey,0,e.target),(i||e.target).dispatchEvent(s)}static getValuesFromTransformedElement(e){const t=document.createElement("div");u.addElStyles(t,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),e.appendChild(t);const i=t.getBoundingClientRect();return e.removeChild(t),t.remove(),{xScale:1/i.width,yScale:1/i.height,xOffset:i.left,yOffset:i.top}}static swap(e,t,i){if(!e)return;const s=e[t];e[t]=e[i],e[i]=s}static canBeRotated(e){var t;return!(!e||e.w===e.h||e.locked||e.noResize||(t=e.grid)!=null&&t.opts.disableResize||e.minW&&e.minW===e.maxW||e.minH&&e.minH===e.maxH)}}class V{constructor(e={}){this.addedNodes=[],this.removedNodes=[],this.defaultColumn=12,this.column=e.column||this.defaultColumn,this.column>this.defaultColumn&&(this.defaultColumn=this.column),this.maxRow=e.maxRow,this._float=e.float,this.nodes=e.nodes||[],this.onChange=e.onChange}batchUpdate(e=!0,t=!0){return!!this.batchMode===e?this:(this.batchMode=e,e?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,t&&this._packNodes(),this._notify()),this)}_useEntireRowArea(e,t){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!e._moving||e._skipDown||t.y<=e.y)}_fixCollisions(e,t=e,i,s={}){if(this.sortNodes(-1),i=i||this.collide(e,t),!i)return!1;if(e._moving&&!s.nested&&!this.float&&this.swap(e,i))return!0;let r=t;!this._loading&&this._useEntireRowArea(e,t)&&(r={x:0,w:this.column,y:t.y,h:t.h},i=this.collide(e,r,s.skip));let a=!1;const n={nested:!0,pack:!1};let c=0;for(;i=i||this.collide(e,r,s.skip);){if(c++>this.nodes.length*2)throw new Error("Infinite collide check");let d;if(i.locked||this._loading||e._moving&&!e._skipDown&&t.y>e.y&&!this.float&&(!this.collide(i,{...i,y:e.y},e)||!this.collide(i,{...i,y:t.y-i.h},e))){e._skipDown=e._skipDown||t.y>e.y;const l={...t,y:i.y+i.h,...n};d=this._loading&&u.samePos(e,l)?!0:this.moveNode(e,l),(i.locked||this._loading)&&d?u.copyPos(t,e):!i.locked&&d&&s.pack&&(this._packNodes(),t.y=i.y+i.h,u.copyPos(e,t)),a=a||d}else d=this.moveNode(i,{...i,y:t.y+t.h,skip:e,...n});if(!d)return a;i=void 0}return a}collide(e,t=e,i){const s=e._id,r=i==null?void 0:i._id;return this.nodes.find(a=>a._id!==s&&a._id!==r&&u.isIntercepted(a,t))}collideAll(e,t=e,i){const s=e._id,r=i==null?void 0:i._id;return this.nodes.filter(a=>a._id!==s&&a._id!==r&&u.isIntercepted(a,t))}directionCollideCoverage(e,t,i){if(!t.rect||!e._rect)return;const s=e._rect,r={...t.rect};r.y>s.y?(r.h+=r.y-s.y,r.y=s.y):r.h+=s.y-r.y,r.x>s.x?(r.w+=r.x-s.x,r.x=s.x):r.w+=s.x-r.x;let a,n=.5;for(let c of i){if(c.locked||!c._rect)break;const d=c._rect;let l=Number.MAX_VALUE,h=Number.MAX_VALUE;s.y<d.y?l=(r.y+r.h-d.y)/d.h:s.y+s.h>d.y+d.h&&(l=(d.y+d.h-r.y)/d.h),s.x<d.x?h=(r.x+r.w-d.x)/d.w:s.x+s.w>d.x+d.w&&(h=(d.x+d.w-r.x)/d.w);const g=Math.min(h,l);g>n&&(n=g,a=c)}return t.collide=a,a}cacheRects(e,t,i,s,r,a){return this.nodes.forEach(n=>n._rect={y:n.y*t+i,x:n.x*e+a,w:n.w*e-a-s,h:n.h*t-i-r}),this}swap(e,t){if(!t||t.locked||!e||e.locked)return!1;function i(){const r=t.x,a=t.y;return t.x=e.x,t.y=e.y,e.h!=t.h?(e.x=r,e.y=t.y+t.h):e.w!=t.w?(e.x=t.x+t.w,e.y=a):(e.x=r,e.y=a),e._dirty=t._dirty=!0,!0}let s;if(e.w===t.w&&e.h===t.h&&(e.x===t.x||e.y===t.y)&&(s=u.isTouching(e,t)))return i();if(s!==!1){if(e.w===t.w&&e.x===t.x&&(s||(s=u.isTouching(e,t)))){if(t.y<e.y){const r=e;e=t,t=r}return i()}if(s!==!1){if(e.h===t.h&&e.y===t.y&&(s||(s=u.isTouching(e,t)))){if(t.x<e.x){const r=e;e=t,t=r}return i()}return!1}}}isAreaEmpty(e,t,i,s){const r={x:e||0,y:t||0,w:i||1,h:s||1};return!this.collide(r)}compact(e="compact",t=!0){if(this.nodes.length===0)return this;t&&this.sortNodes();const i=this.batchMode;i||this.batchUpdate();const s=this._inColumnResize;s||(this._inColumnResize=!0);const r=this.nodes;return this.nodes=[],r.forEach((a,n,c)=>{let d;a.locked||(a.autoPosition=!0,e==="list"&&n&&(d=c[n-1])),this.addNode(a,!1,d)}),s||delete this._inColumnResize,i||this.batchUpdate(!1),this}set float(e){this._float!==e&&(this._float=e||!1,e||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(e=1){return this.nodes=u.sort(this.nodes,e),this}_packNodes(){return this.batchMode?this:(this.sortNodes(),this.float?this.nodes.forEach(e=>{if(e._updating||e._orig===void 0||e.y===e._orig.y)return;let t=e.y;for(;t>e._orig.y;)--t,this.collide(e,{x:e.x,y:t,w:e.w,h:e.h})||(e._dirty=!0,e.y=t)}):this.nodes.forEach((e,t)=>{if(!e.locked)for(;e.y>0;){const i=t===0?0:e.y-1;if(!(t===0||!this.collide(e,{x:e.x,y:i,w:e.w,h:e.h})))break;e._dirty=e.y!==i,e.y=i}}),this)}prepareNode(e,t){e._id=e._id??V._idSeq++;const i=e.id;if(i){let r=1;for(;this.nodes.find(a=>a.id===e.id&&a!==e);)e.id=i+"_"+r++}(e.x===void 0||e.y===void 0||e.x===null||e.y===null)&&(e.autoPosition=!0);const s={x:0,y:0,w:1,h:1};return u.defaults(e,s),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,u.sanitizeMinMax(e),typeof e.x=="string"&&(e.x=Number(e.x)),typeof e.y=="string"&&(e.y=Number(e.y)),typeof e.w=="string"&&(e.w=Number(e.w)),typeof e.h=="string"&&(e.h=Number(e.h)),isNaN(e.x)&&(e.x=s.x,e.autoPosition=!0),isNaN(e.y)&&(e.y=s.y,e.autoPosition=!0),isNaN(e.w)&&(e.w=s.w),isNaN(e.h)&&(e.h=s.h),this.nodeBoundFix(e,t),e}nodeBoundFix(e,t){const i=e._orig||u.copyPos({},e);if(e.maxW&&e.w&&(e.w=Math.min(e.w,e.maxW)),e.maxH&&e.h&&(e.h=Math.min(e.h,e.maxH)),e.minW&&e.w&&e.minW<=this.column&&(e.w=Math.max(e.w,e.minW)),e.minH&&e.h&&(e.h=Math.max(e.h,e.minH)),(e.x||0)+(e.w||1)>this.column&&this.column<this.defaultColumn&&!this._inColumnResize&&!this.skipCacheUpdate&&e._id&&this.findCacheLayout(e,this.defaultColumn)===-1){const r={...e};r.autoPosition||r.x===void 0?(delete r.x,delete r.y):r.x=Math.min(this.defaultColumn-1,r.x),r.w=Math.min(this.defaultColumn,r.w||1),this.cacheOneLayout(r,this.defaultColumn)}return e.w>this.column?e.w=this.column:e.w<1&&(e.w=1),this.maxRow&&e.h>this.maxRow?e.h=this.maxRow:e.h<1&&(e.h=1),e.x<0&&(e.x=0),e.y<0&&(e.y=0),e.x+e.w>this.column&&(t?e.w=this.column-e.x:e.x=this.column-e.w),this.maxRow&&e.y+e.h>this.maxRow&&(t?e.h=this.maxRow-e.y:e.y=this.maxRow-e.h),u.samePos(e,i)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(t=>t._dirty&&!u.samePos(t,t._orig)):this.nodes.filter(t=>t._dirty)}_notify(e){if(this.batchMode||!this.onChange)return this;const t=(e||[]).concat(this.getDirtyNodes());return this.onChange(t),this}cleanNodes(){return this.batchMode?this:(this.nodes.forEach(e=>{delete e._dirty,delete e._lastTried}),this)}saveInitial(){return this.nodes.forEach(e=>{e._orig=u.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||u.samePos(e,e._orig)||(u.copyPos(e,e._orig),e._dirty=!0)}),this._notify(),this}findEmptyPosition(e,t=this.nodes,i=this.column,s){const r=s?s.y*i+(s.x+s.w):0;let a=!1;for(let n=r;!a;++n){const c=n%i,d=Math.floor(n/i);if(c+e.w>i)continue;const l={x:c,y:d,w:e.w,h:e.h};t.find(h=>u.isIntercepted(l,h))||((e.x!==c||e.y!==d)&&(e._dirty=!0),e.x=c,e.y=d,delete e.autoPosition,a=!0)}return a}addNode(e,t=!1,i){const s=this.nodes.find(a=>a._id===e._id);if(s)return s;this._inColumnResize?this.nodeBoundFix(e):this.prepareNode(e),delete e._temporaryRemoved,delete e._removeDOM;let r;return e.autoPosition&&this.findEmptyPosition(e,this.nodes,this.column,i)&&(delete e.autoPosition,r=!0),this.nodes.push(e),t&&this.addedNodes.push(e),r||this._fixCollisions(e),this.batchMode||this._packNodes()._notify(),e}removeNode(e,t=!0,i=!1){return this.nodes.find(s=>s._id===e._id)?(i&&this.removedNodes.push(e),t&&(e._removeDOM=!0),this.nodes=this.nodes.filter(s=>s._id!==e._id),e._isAboutToRemove||this._packNodes(),this._notify([e]),this):this}removeAll(e=!0,t=!0){if(delete this._layouts,!this.nodes.length)return this;e&&this.nodes.forEach(s=>s._removeDOM=!0);const i=this.nodes;return this.removedNodes=t?i:[],this.nodes=[],this._notify(i)}moveNodeCheck(e,t){if(!this.changedPosConstrain(e,t))return!1;if(t.pack=!0,!this.maxRow)return this.moveNode(e,t);let i;const s=new V({column:this.column,float:this.float,nodes:this.nodes.map(a=>a._id===e._id?(i={...a},i):{...a})});if(!i)return!1;const r=s.moveNode(i,t)&&s.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!t.resizing&&t.collide){const a=t.collide.el.gridstackNode;if(this.swap(e,a))return this._notify(),!0}return r?(s.nodes.filter(a=>a._dirty).forEach(a=>{const n=this.nodes.find(c=>c._id===a._id);n&&(u.copyPos(n,a),n._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;const t=new V({column:this.column,float:this.float,nodes:this.nodes.map(s=>({...s}))}),i={...e};return this.cleanupNode(i),delete i.el,delete i._id,delete i.content,delete i.grid,t.addNode(i),t.getRow()<=this.maxRow?(e._willFitPos=u.copyPos({},i),!0):!1}changedPosConstrain(e,t){return t.w=t.w||e.w,t.h=t.h||e.h,e.x!==t.x||e.y!==t.y?!0:(e.maxW&&(t.w=Math.min(t.w,e.maxW)),e.maxH&&(t.h=Math.min(t.h,e.maxH)),e.minW&&(t.w=Math.max(t.w,e.minW)),e.minH&&(t.h=Math.max(t.h,e.minH)),e.w!==t.w||e.h!==t.h)}moveNode(e,t){var d,l;if(!e||!t)return!1;let i;t.pack===void 0&&!this.batchMode&&(i=t.pack=!0),typeof t.x!="number"&&(t.x=e.x),typeof t.y!="number"&&(t.y=e.y),typeof t.w!="number"&&(t.w=e.w),typeof t.h!="number"&&(t.h=e.h);const s=e.w!==t.w||e.h!==t.h,r=u.copyPos({},e,!0);if(u.copyPos(r,t),this.nodeBoundFix(r,s),u.copyPos(t,r),!t.forceCollide&&u.samePos(e,t))return!1;const a=u.copyPos({},e),n=this.collideAll(e,r,t.skip);let c=!0;if(n.length){const h=e._moving&&!t.nested;let g=h?this.directionCollideCoverage(e,t,n):n[0];if(h&&g&&((l=(d=e.grid)==null?void 0:d.opts)!=null&&l.subGridDynamic)&&!e.grid._isTemp){const p=u.areaIntercept(t.rect,g._rect),y=u.area(t.rect),_=u.area(g._rect);p/(y<_?y:_)>.8&&(g.grid.makeSubGrid(g.el,void 0,e),g=void 0)}g?c=!this._fixCollisions(e,r,g,t):(c=!1,i&&delete t.pack)}return c&&!u.samePos(e,r)&&(e._dirty=!0,u.copyPos(e,r)),t.pack&&this._packNodes()._notify(),!u.samePos(e,a)}getRow(){return this.nodes.reduce((e,t)=>Math.max(e,t.y+t.h),0)}beginUpdate(e){return e._updating||(e._updating=!0,delete e._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){const e=this.nodes.find(t=>t._updating);return e&&(delete e._updating,delete e._skipDown),this}save(e=!0,t){var a;const i=(a=this._layouts)==null?void 0:a.length,s=i&&this.column!==i-1?this._layouts[i-1]:null,r=[];return this.sortNodes(),this.nodes.forEach(n=>{const c=s==null?void 0:s.find(l=>l._id===n._id),d={...n,...c||{}};u.removeInternalForSave(d,!e),t&&t(n,d),r.push(d)}),r}layoutsNodesChange(e){return!this._layouts||this._inColumnResize?this:(this._layouts.forEach((t,i)=>{if(!t||i===this.column)return this;if(i<this.column)this._layouts[i]=void 0;else{const s=i/this.column;e.forEach(r=>{if(!r._orig)return;const a=t.find(n=>n._id===r._id);a&&(a.y>=0&&r.y!==r._orig.y&&(a.y+=r.y-r._orig.y),r.x!==r._orig.x&&(a.x=Math.round(r.x*s)),r.w!==r._orig.w&&(a.w=Math.round(r.w*s)))})}}),this)}columnChanged(e,t,i="moveScale"){var n;if(!this.nodes.length||!t||e===t)return this;const s=i==="compact"||i==="list";s&&this.sortNodes(1),t<e&&this.cacheLayout(this.nodes,e),this.batchUpdate();let r=[],a=s?this.nodes:u.sort(this.nodes,-1);if(t>e&&this._layouts){const c=this._layouts[t]||[],d=this._layouts.length-1;!c.length&&e!==d&&((n=this._layouts[d])!=null&&n.length)&&(e=d,this._layouts[d].forEach(l=>{const h=a.find(g=>g._id===l._id);h&&(!s&&!l.autoPosition&&(h.x=l.x??h.x,h.y=l.y??h.y),h.w=l.w??h.w,(l.x==null||l.y===void 0)&&(h.autoPosition=!0))})),c.forEach(l=>{const h=a.findIndex(g=>g._id===l._id);if(h!==-1){const g=a[h];if(s){g.w=l.w;return}(l.autoPosition||isNaN(l.x)||isNaN(l.y))&&this.findEmptyPosition(l,r),l.autoPosition||(g.x=l.x??g.x,g.y=l.y??g.y,g.w=l.w??g.w,r.push(g)),a.splice(h,1)}})}if(s)this.compact(i,!1);else{if(a.length)if(typeof i=="function")i(t,e,r,a);else{const c=s||i==="none"?1:t/e,d=i==="move"||i==="moveScale",l=i==="scale"||i==="moveScale";a.forEach(h=>{h.x=t===1?0:d?Math.round(h.x*c):Math.min(h.x,t-1),h.w=t===1||e===1?1:l?Math.round(h.w*c)||1:Math.min(h.w,t),r.push(h)}),a=[]}r=u.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(c=>{this.addNode(c,!1),delete c._orig})}return this.nodes.forEach(c=>delete c._orig),this.batchUpdate(!1,!s),delete this._inColumnResize,this}cacheLayout(e,t,i=!1){const s=[];return e.forEach((r,a)=>{if(r._id===void 0){const n=r.id?this.nodes.find(c=>c.id===r.id):void 0;r._id=(n==null?void 0:n._id)??V._idSeq++}s[a]={x:r.x,y:r.y,w:r.w,_id:r._id}}),this._layouts=i?[]:this._layouts||[],this._layouts[t]=s,this}cacheOneLayout(e,t){e._id=e._id??V._idSeq++;const i={x:e.x,y:e.y,w:e.w,_id:e._id};(e.autoPosition||e.x===void 0)&&(delete i.x,delete i.y,e.autoPosition&&(i.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[t]=this._layouts[t]||[];const s=this.findCacheLayout(e,t);return s===-1?this._layouts[t].push(i):this._layouts[t][s]=i,this}findCacheLayout(e,t){var i,s;return((s=(i=this._layouts)==null?void 0:i[t])==null?void 0:s.findIndex(r=>r._id===e._id))??-1}removeNodeFromLayoutCache(e){if(this._layouts)for(let t=0;t<this._layouts.length;t++){const i=this.findCacheLayout(e,t);i!==-1&&this._layouts[t].splice(i,1)}}cleanupNode(e){for(const t in e)t[0]==="_"&&t!=="_id"&&delete e[t];return this}}V._idSeq=0;const q={alwaysShowResizeHandle:"mobile",animate:!0,auto:!0,cellHeight:"auto",cellHeightThrottle:100,cellHeightUnit:"px",column:12,draggable:{handle:".grid-stack-item-content",appendTo:"body",scroll:!0},handle:".grid-stack-item-content",itemClass:"grid-stack-item",margin:10,marginUnit:"px",maxRow:0,minRow:0,placeholderClass:"grid-stack-placeholder",placeholderText:"",removableOptions:{accept:"grid-stack-item",decline:"grid-stack-non-removable"},resizable:{handles:"se"},rtl:"auto"};class C{}const U=typeof window<"u"&&typeof document<"u"&&("ontouchstart"in document||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0);class K{}function ye(f,e){if(f.touches.length>1)return;f.cancelable&&f.preventDefault();const t=f.changedTouches[0],i=document.createEvent("MouseEvents");i.initMouseEvent(e,!0,!0,window,1,t.screenX,t.screenY,t.clientX,t.clientY,!1,!1,!1,!1,0,null),f.target.dispatchEvent(i)}function st(f,e){f.cancelable&&f.preventDefault();const t=document.createEvent("MouseEvents");t.initMouseEvent(e,!0,!0,window,1,f.screenX,f.screenY,f.clientX,f.clientY,!1,!1,!1,!1,0,null),f.target.dispatchEvent(t)}function _e(f){K.touchHandled||(K.touchHandled=!0,ye(f,"mousedown"))}function ve(f){K.touchHandled&&ye(f,"mousemove")}function we(f){if(!K.touchHandled)return;K.pointerLeaveTimeout&&(window.clearTimeout(K.pointerLeaveTimeout),delete K.pointerLeaveTimeout);const e=!!C.dragElement;ye(f,"mouseup"),e||ye(f,"click"),K.touchHandled=!1}function be(f){f.pointerType!=="mouse"&&f.target.releasePointerCapture(f.pointerId)}function rt(f){C.dragElement&&f.pointerType!=="mouse"&&st(f,"mouseenter")}function nt(f){C.dragElement&&f.pointerType!=="mouse"&&(K.pointerLeaveTimeout=window.setTimeout(()=>{delete K.pointerLeaveTimeout,st(f,"mouseleave")},10))}class Ee{constructor(e,t,i){this.host=e,this.dir=t,this.option=i,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){const e=this.el=document.createElement("div");return e.classList.add("ui-resizable-handle"),e.classList.add(`${Ee.prefix}${this.dir}`),e.style.zIndex="100",e.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),U&&(this.el.addEventListener("touchstart",_e),this.el.addEventListener("pointerdown",be)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),U&&(this.el.removeEventListener("touchstart",_e),this.el.removeEventListener("pointerdown",be)),this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(e){this.mouseDownEvent=e,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),U&&(this.el.addEventListener("touchmove",ve),this.el.addEventListener("touchend",we)),e.stopPropagation(),e.preventDefault()}_mouseMove(e){const t=this.mouseDownEvent;this.moving?this._triggerEvent("move",e):Math.abs(e.x-t.x)+Math.abs(e.y-t.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",e),document.addEventListener("keydown",this._keyEvent)),e.stopPropagation()}_mouseUp(e){this.moving&&(this._triggerEvent("stop",e),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),U&&(this.el.removeEventListener("touchmove",ve),this.el.removeEventListener("touchend",we)),delete this.moving,delete this.mouseDownEvent,e.stopPropagation(),e.preventDefault()}_keyEvent(e){var t,i;e.key==="Escape"&&((i=(t=this.host.gridstackNode)==null?void 0:t.grid)==null||i.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(e,t){return this.option[e]&&this.option[e](t),this}}Ee.prefix="ui-resizable-";class Ne{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(e,t){this._eventRegister[e]=t}off(e){delete this._eventRegister[e]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(e,t){if(!this.disabled&&this._eventRegister&&this._eventRegister[e])return this._eventRegister[e](t)}}class he extends Ne{constructor(e,t={}){super(),this.el=e,this.option=t,this.rectScale={x:1,y:1},this._ui=()=>{const s=this.el.parentElement.getBoundingClientRect(),r={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},a=this.temporalRect||r;return{position:{left:(a.left-s.left)*this.rectScale.x,top:(a.top-s.top)*this.rectScale.y},size:{width:a.width*this.rectScale.x,height:a.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(e){const t=e.handles&&e.handles!==this.option.handles,i=e.autoHide&&e.autoHide!==this.option.autoHide;return Object.keys(e).forEach(s=>this.option[s]=e[s]),t&&(this._removeHandlers(),this._setupHandlers()),i&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(e){return e?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),C.overResizeElement===this&&delete C.overResizeElement),this}_mouseOver(e){C.overResizeElement||C.dragElement||(C.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){C.overResizeElement===this&&(delete C.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new Ee(this.el,e,{start:t=>{this._resizeStart(t)},stop:t=>{this._resizeStop(t)},move:t=>{this._resizing(t,e)}})),this}_resizeStart(e){this.sizeToContent=u.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=u.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();const t=u.initEvent(e,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(t,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",t),this}_resizing(e,t){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(e,t),this._applyChange();const i=u.initEvent(e,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(e){const t=u.initEvent(e,{type:"resizestop",target:this.el});return this.option.stop&&this.option.stop(t),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",t),this._cleanHelper(),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=he._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;const e=this.el.parentElement,t=u.getValuesFromTransformedElement(e);return this.rectScale={x:t.xScale,y:t.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return he._originStyleProp.forEach((e,t)=>{this.el.style[e]=this.elOriginStyleVal[t]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(e,t){const i=this.startEvent,s={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},r=e.clientX-i.clientX,a=this.sizeToContent?0:e.clientY-i.clientY;let n,c;t.indexOf("e")>-1?s.width+=r:t.indexOf("w")>-1&&(s.width-=r,s.left+=r,n=!0),t.indexOf("s")>-1?s.height+=a:t.indexOf("n")>-1&&(s.height-=a,s.top+=a,c=!0);const d=this._constrainSize(s.width,s.height,n,c);return Math.round(s.width)!==Math.round(d.width)&&(t.indexOf("w")>-1&&(s.left+=s.width-d.width),s.width=d.width),Math.round(s.height)!==Math.round(d.height)&&(t.indexOf("n")>-1&&(s.top+=s.height-d.height),s.height=d.height),s}_constrainSize(e,t,i,s){const r=this.option,a=(i?r.maxWidthMoveLeft:r.maxWidth)||Number.MAX_SAFE_INTEGER,n=r.minWidth/this.rectScale.x||e,c=(s?r.maxHeightMoveUp:r.maxHeight)||Number.MAX_SAFE_INTEGER,d=r.minHeight/this.rectScale.y||t,l=Math.min(a,Math.max(n,e)),h=Math.min(c,Math.max(d,t));return{width:l,height:h}}_applyChange(){let e={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){const t=this.el.parentElement,{left:i,top:s}=t.getBoundingClientRect();e={left:i,top:s,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(t=>{const i=this.temporalRect[t],s=t==="width"||t==="left"?this.rectScale.x:t==="height"||t==="top"?this.rectScale.y:1;this.el.style[t]=(i-e[t])*s+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(e=>e.destroy()),delete this.handlers,this}}he._originStyleProp=["width","height","position","left","top","opacity","zIndex"];const Ut='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';class de extends Ne{constructor(e,t={}){var r;super(),this.el=e,this.option=t,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};const i=(r=t==null?void 0:t.handle)==null?void 0:r.substring(1),s=e.gridstackNode;this.dragEls=!i||e.classList.contains(i)?[e]:s!=null&&s.subGrid?[e.querySelector(t.handle)||e]:Array.from(e.querySelectorAll(t.handle)),this.dragEls.length===0&&(this.dragEls=[e]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(e=>{e.addEventListener("mousedown",this._mouseDown),U&&(e.addEventListener("touchstart",_e),e.addEventListener("pointerdown",be))}),this.el.classList.remove("ui-draggable-disabled"))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(t=>{t.removeEventListener("mousedown",this._mouseDown),U&&(t.removeEventListener("touchstart",_e),t.removeEventListener("pointerdown",be))}),e||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(e){return Object.keys(e).forEach(t=>this.option[t]=e[t]),this}_mouseDown(e){if(!C.mouseHandled)return e.button!==0||!this.dragEls.find(t=>t===e.target)&&e.target.closest(Ut)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete C.dragElement,delete C.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),U&&(e.currentTarget.addEventListener("touchmove",ve),e.currentTarget.addEventListener("touchend",we)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),C.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;const t=u.initEvent(e,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(t,this.ui()),this.triggerEvent("drag",t)}_mouseMove(e){var i;const t=this.mouseDownEvent;if(this.lastDrag=e,this.dragging)if(this._dragFollow(e),C.pauseDrag){const s=Number.isInteger(C.pauseDrag)?C.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(e),s)}else this._callDrag(e);else if(Math.abs(e.x-t.x)+Math.abs(e.y-t.y)>3){this.dragging=!0,C.dragElement=this;const s=(i=this.el.gridstackNode)==null?void 0:i.grid;s?C.dropElement=s.el.ddElement.ddDroppable:delete C.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=u.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);const r=u.initEvent(e,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(r,this.ui()),this.triggerEvent("dragstart",r),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(e){var t,i;if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),U&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",ve,!0),e.currentTarget.removeEventListener("touchend",we,!0)),this.dragging){delete this.dragging,(t=this.el.gridstackNode)==null||delete t._origRotate,document.removeEventListener("keydown",this._keyEvent),((i=C.dropElement)==null?void 0:i.el)===this.el.parentElement&&delete C.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const s=u.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(s),this.triggerEvent("dragstop",s),C.dropElement&&C.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete C.dragElement,delete C.dropElement,delete C.mouseHandled,e.preventDefault()}_keyEvent(e){var s,r;const t=this.el.gridstackNode,i=(t==null?void 0:t.grid)||((r=(s=C.dropElement)==null?void 0:s.el)==null?void 0:r.gridstack);if(e.key==="Escape")t&&t._origRotate&&(t._orig=t._origRotate,delete t._origRotate),i==null||i.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(t&&i&&(e.key==="r"||e.key==="R")){if(!u.canBeRotated(t))return;t._origRotate=t._origRotate||{...t._orig},delete t._moving,i.setAnimation(!1).rotate(t.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetLeft}).setAnimation(),t._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,t.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",u.swap(t._orig,"w","h"),delete t._rect,this._mouseMove(this.lastDrag)}}_createHelper(){let e=this.el;return typeof this.option.helper=="function"?e=this.option.helper(this.el):this.option.helper==="clone"&&(e=u.cloneNode(this.el)),document.body.contains(e)||u.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=de.originStyleProp.map(t=>this.el.style[t]),e}_setupHelperStyle(e){this.helper.classList.add("ui-draggable-dragging");const t=this.helper.style;return t.pointerEvents="none",t.width=this.dragOffset.width+"px",t.height=this.dragOffset.height+"px",t.willChange="left, top",t.position="fixed",this._dragFollow(e),t.transition="none",setTimeout(()=>{this.helper&&(t.transition=null)},0),this}_removeHelperStyle(){var t;this.helper.classList.remove("ui-draggable-dragging");const e=(t=this.helper)==null?void 0:t.gridstackNode;if(!(e!=null&&e._isAboutToRemove)&&this.dragElementOriginStyle){const i=this.helper,s=this.dragElementOriginStyle.transition||null;i.style.transition=this.dragElementOriginStyle.transition="none",de.originStyleProp.forEach(r=>i.style[r]=this.dragElementOriginStyle[r]||null),setTimeout(()=>i.style.transition=s,50)}return delete this.dragElementOriginStyle,this}_dragFollow(e){const t={left:0,top:0},i=this.helper.style,s=this.dragOffset;i.left=(e.clientX+s.offsetLeft-t.left)*this.dragTransform.xScale+"px",i.top=(e.clientY+s.offsetTop-t.top)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(e,t,i){let s=0,r=0;i&&(s=this.dragTransform.xOffset,r=this.dragTransform.yOffset);const a=t.getBoundingClientRect();return{left:a.left,top:a.top,offsetLeft:-e.clientX+a.left-s,offsetTop:-e.clientY+a.top-r,width:a.width*this.dragTransform.xScale,height:a.height*this.dragTransform.yScale}}ui(){const t=this.el.parentElement.getBoundingClientRect(),i=this.helper.getBoundingClientRect();return{position:{top:(i.top-t.top)*this.dragTransform.yScale,left:(i.left-t.left)*this.dragTransform.xScale}}}}de.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","top","minWidth","willChange"];class Wt extends Ne{constructor(e,t={}){super(),this.el=e,this.option=t,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(e,t){super.on(e,t)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),U&&(this.el.addEventListener("pointerenter",rt),this.el.addEventListener("pointerleave",nt)))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),e||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),U&&(this.el.removeEventListener("pointerenter",rt),this.el.removeEventListener("pointerleave",nt)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(e){return Object.keys(e).forEach(t=>this.option[t]=e[t]),this._setupAccept(),this}_mouseEnter(e){if(!C.dragElement||!this._canDrop(C.dragElement.el))return;e.preventDefault(),e.stopPropagation(),C.dropElement&&C.dropElement!==this&&C.dropElement._mouseLeave(e,!0),C.dropElement=this;const t=u.initEvent(e,{target:this.el,type:"dropover"});this.option.over&&this.option.over(t,this._ui(C.dragElement)),this.triggerEvent("dropover",t),this.el.classList.add("ui-droppable-over")}_mouseLeave(e,t=!1){var s;if(!C.dragElement||C.dropElement!==this)return;e.preventDefault(),e.stopPropagation();const i=u.initEvent(e,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(i,this._ui(C.dragElement)),this.triggerEvent("dropout",i),C.dropElement===this&&(delete C.dropElement,!t)){let r,a=this.el.parentElement;for(;!r&&a;)r=(s=a.ddElement)==null?void 0:s.ddDroppable,a=a.parentElement;r&&r._mouseEnter(e)}}drop(e){e.preventDefault();const t=u.initEvent(e,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(t,this._ui(C.dragElement)),this.triggerEvent("drop",t)}_canDrop(e){return e&&(!this.accept||this.accept(e))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=e=>e.classList.contains(this.option.accept)||e.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(e){return{draggable:e.el,...e.ui()}}}class Ae{static init(e){return e.ddElement||(e.ddElement=new Ae(e)),e.ddElement}constructor(e){this.el=e}on(e,t){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.on(e,t):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.on(e,t):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.on(e,t),this}off(e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.off(e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.off(e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.off(e),this}setupDraggable(e){return this.ddDraggable?this.ddDraggable.updateOption(e):this.ddDraggable=new de(this.el,e),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(e){return this.ddResizable?this.ddResizable.updateOption(e):this.ddResizable=new he(this.el,e),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(e){return this.ddDroppable?this.ddDroppable.updateOption(e):this.ddDroppable=new Wt(this.el,e),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}class Vt{resizable(e,t,i,s){return this._getDDElements(e).forEach(r=>{if(t==="disable"||t==="enable")r.ddResizable&&r.ddResizable[t]();else if(t==="destroy")r.ddResizable&&r.cleanResizable();else if(t==="option")r.setupResizable({[i]:s});else{const n=r.el.gridstackNode.grid;let c=r.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";c==="all"&&(c="n,e,s,w,se,sw,ne,nw");const d=!n.opts.alwaysShowResizeHandle;r.setupResizable({...n.opts.resizable,handles:c,autoHide:d,start:t.start,stop:t.stop,resize:t.resize})}}),this}draggable(e,t,i,s){return this._getDDElements(e).forEach(r=>{if(t==="disable"||t==="enable")r.ddDraggable&&r.ddDraggable[t]();else if(t==="destroy")r.ddDraggable&&r.cleanDraggable();else if(t==="option")r.setupDraggable({[i]:s});else{const a=r.el.gridstackNode.grid;r.setupDraggable({...a.opts.draggable,start:t.start,stop:t.stop,drag:t.drag})}}),this}dragIn(e,t){return this._getDDElements(e).forEach(i=>i.setupDraggable(t)),this}droppable(e,t,i,s){return typeof t.accept=="function"&&!t._accept&&(t._accept=t.accept,t.accept=r=>t._accept(r)),this._getDDElements(e).forEach(r=>{t==="disable"||t==="enable"?r.ddDroppable&&r.ddDroppable[t]():t==="destroy"?r.ddDroppable&&r.cleanDroppable():t==="option"?r.setupDroppable({[i]:s}):r.setupDroppable(t)}),this}isDroppable(e){var t;return!!((t=e==null?void 0:e.ddElement)!=null&&t.ddDroppable&&!e.ddElement.ddDroppable.disabled)}isDraggable(e){var t;return!!((t=e==null?void 0:e.ddElement)!=null&&t.ddDraggable&&!e.ddElement.ddDraggable.disabled)}isResizable(e){var t;return!!((t=e==null?void 0:e.ddElement)!=null&&t.ddResizable&&!e.ddElement.ddResizable.disabled)}on(e,t,i){return this._getDDElements(e).forEach(s=>s.on(t,r=>{i(r,C.dragElement?C.dragElement.el:r.target,C.dragElement?C.dragElement.helper:null)})),this}off(e,t){return this._getDDElements(e).forEach(i=>i.off(t)),this}_getDDElements(e,t=!0){const i=u.getElements(e);if(!i.length)return[];const s=i.map(r=>r.ddElement||(t?Ae.init(r):null));return t||s.filter(r=>r),s}}/*!
2
2
  * GridStack 11.3.0
3
3
  * https://gridstackjs.com/
4
4
  *
5
5
  * Copyright (c) 2021-2024 Alain Dumesny
6
6
  * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
7
- */const O=new Wt;class w{static init(e={},t=".grid-stack"){if(typeof document>"u")return null;const i=w.getGridElement(t);return i?(i.gridstack||(i.gridstack=new w(i,u.cloneDeep(e))),i.gridstack):(console.error(typeof t=="string"?'GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
8
- Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(e={},t=".grid-stack"){const i=[];return typeof document>"u"||(w.getGridElements(t).forEach(s=>{s.gridstack||(s.gridstack=new w(s,u.cloneDeep(e))),i.push(s.gridstack)}),i.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
9
- Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),i}static addGrid(e,t={}){if(!e)return null;let i=e;if(i.gridstack){const o=i.gridstack;return t&&(o.opts={...o.opts,...t}),t.children!==void 0&&o.load(t.children),o}return(!e.classList.contains("grid-stack")||w.addRemoveCB)&&(w.addRemoveCB?i=w.addRemoveCB(e,t,!0,!0):i=u.createDiv(["grid-stack",t.class],e)),w.init(t,i)}static registerEngine(e){w.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=u.createDiv([this.opts.placeholderClass,P.itemClass,this.opts.itemClass]);const e=u.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,t={}){var h,g,p;this.el=e,this.opts=t,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},e.gridstack=this,this.opts=t=t||{},e.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),t.row&&(t.minRow=t.maxRow=t.row,delete t.row);const i=u.toNumber(e.getAttribute("gs-row"));t.column==="auto"&&delete t.column,t.alwaysShowResizeHandle!==void 0&&(t._alwaysShowResizeHandle=t.alwaysShowResizeHandle);let s=(h=t.columnOpts)==null?void 0:h.breakpoints;const r=t;if(r.oneColumnModeDomSort&&(delete r.oneColumnModeDomSort,console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")),r.oneColumnSize||r.disableOneColumnMode===!1){const y=r.oneColumnSize||768;delete r.oneColumnSize,delete r.disableOneColumnMode,t.columnOpts=t.columnOpts||{},s=t.columnOpts.breakpoints=t.columnOpts.breakpoints||[];let _=s.find(m=>m.c===1);_?_.w=y:(_={c:1,w:y},s.push(_,{c:12,w:y+1}))}const o=t.columnOpts;o&&(!o.columnWidth&&!((g=o.breakpoints)!=null&&g.length)?(delete t.columnOpts,s=void 0):o.columnMax=o.columnMax||12),(s==null?void 0:s.length)>1&&s.sort((y,_)=>(_.w||0)-(y.w||0));const n={...u.cloneDeep(P),column:u.toNumber(e.getAttribute("gs-column"))||P.column,minRow:i||u.toNumber(e.getAttribute("gs-min-row"))||P.minRow,maxRow:i||u.toNumber(e.getAttribute("gs-max-row"))||P.maxRow,staticGrid:u.toBool(e.getAttribute("gs-static"))||P.staticGrid,sizeToContent:u.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(t.handleClass?"."+t.handleClass:t.handle?t.handle:"")||P.draggable.handle},removableOptions:{accept:t.itemClass||P.removableOptions.accept,decline:P.removableOptions.decline}};e.getAttribute("gs-animate")&&(n.animate=u.toBool(e.getAttribute("gs-animate"))),t=u.defaults(t,n),this._initMargin(),this.checkDynamicColumn(),this.el.classList.add("gs-"+t.column),t.rtl==="auto"&&(t.rtl=e.style.direction==="rtl"),t.rtl&&this.el.classList.add("grid-stack-rtl");const c=this.el.closest("."+P.itemClass),d=c==null?void 0:c.gridstackNode;d&&(d.subGrid=this,this.parentGridNode=d,this.el.classList.add("grid-stack-nested"),d.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=t.cellHeight==="auto",this._isAutoCellHeight||t.cellHeight==="initial"?this.cellHeight(void 0,!1):(typeof t.cellHeight=="number"&&t.cellHeightUnit&&t.cellHeightUnit!==P.cellHeightUnit&&(t.cellHeight=t.cellHeight+t.cellHeightUnit,delete t.cellHeightUnit),this.cellHeight(t.cellHeight,!1)),t.alwaysShowResizeHandle==="mobile"&&(t.alwaysShowResizeHandle=G),this._styleSheetClass="gs-id-"+W._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();const l=t.engineClass||w.engineClass||W;if(this.engine=new l({column:this.getColumn(),float:t.float,maxRow:t.maxRow,onChange:y=>{let _=0;this.engine.nodes.forEach(m=>{_=Math.max(_,m.y+m.h)}),y.forEach(m=>{const T=m.el;T&&(m._removeDOM?(T&&T.remove(),delete m._removeDOM):this._writePosAttr(T,m))}),this._updateStyles(!1,_)}}),this._updateStyles(!1,0),t.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(y=>this._prepareElement(y)),delete this.engine._loading,this.batchUpdate(!1)),t.children){const y=t.children;delete t.children,y.length&&this.load(y)}this.setAnimation(),t.subGridDynamic&&!C.pauseDrag&&(C.pauseDrag=!0),((p=t.draggable)==null?void 0:p.pause)!==void 0&&(C.pauseDrag=t.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}addWidget(e){if(typeof e=="string"){console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");return}if(e.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(e);let t,i=e;if(i.grid=this,i!=null&&i.el?t=i.el:w.addRemoveCB?t=w.addRemoveCB(this.el,e,!0,!1):t=u.createWidgetDivs(this.opts.itemClass,i),!t)return;if(i=t.gridstackNode,i&&t.parentElement===this.el&&this.engine.nodes.find(r=>r._id===i._id))return t;const s=this._readAttr(t);return u.defaults(e,s),this.engine.prepareNode(e),this.el.appendChild(t),this.makeWidget(t,e),t}makeSubGrid(e,t,i,s=!0){var p,y,_;let r=e.gridstackNode;if(r||(r=this.makeWidget(e).gridstackNode),(p=r.subGrid)!=null&&p.el)return r.subGrid;let o,n=this;for(;n&&!o;)o=(y=n.opts)==null?void 0:y.subGridOpts,n=(_=n.parentGridNode)==null?void 0:_.grid;t=u.cloneDeep({...this.opts,id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0,...o||{},...t||r.subGridOpts||{}}),r.subGridOpts=t;let c;t.column==="auto"&&(c=!0,t.column=Math.max(r.w||1,(i==null?void 0:i.w)||1),delete t.columnOpts);let d=r.el.querySelector(".grid-stack-item-content"),l,h;if(s&&(this._removeDD(r.el),h={...r,x:0,y:0},u.removeInternalForSave(h),delete h.subGridOpts,r.content&&(h.content=r.content,delete r.content),w.addRemoveCB?l=w.addRemoveCB(this.el,h,!0,!1):(l=u.createDiv(["grid-stack-item"]),l.appendChild(d),d=u.createDiv(["grid-stack-item-content"],r.el)),this._prepareDragDropByNode(r)),i){const m=c?t.column:r.w,T=r.h+i.h,N=r.el.style;N.transition="none",this.update(r.el,{w:m,h:T}),setTimeout(()=>N.transition=null)}const g=r.subGrid=w.addGrid(d,t);return i!=null&&i._moving&&(g._isTemp=!0),c&&(g._autoColumn=!0),s&&g.makeWidget(l,h),i&&(i._moving?window.setTimeout(()=>u.simulateMouseEvent(i._event,"mouseenter",g.el),0):g.makeWidget(r.el,r)),this.resizeToContentCheck(!1,r),g}removeAsSubGrid(e){var i;const t=(i=this.parentGridNode)==null?void 0:i.grid;t&&(t.batchUpdate(),t.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(s=>{s.x+=this.parentGridNode.x,s.y+=this.parentGridNode.y,t.makeWidget(s.el,s)}),t.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,e&&window.setTimeout(()=>u.simulateMouseEvent(e._event,"mouseenter",t.el),0))}save(e=!0,t=!1,i=w.saveCB){const s=this.engine.save(e,i);if(s.forEach(r=>{var o;if(e&&r.el&&!r.subGrid&&!i){const n=r.el.querySelector(".grid-stack-item-content");r.content=n==null?void 0:n.innerHTML,r.content||delete r.content}else if(!e&&!i&&delete r.content,(o=r.subGrid)!=null&&o.el){const n=r.subGrid.save(e,t,i);r.subGridOpts=t?n:{children:n},delete r.subGrid}delete r.el}),t){const r=u.cloneDeep(this.opts);r.marginBottom===r.marginTop&&r.marginRight===r.marginLeft&&r.marginTop===r.marginRight&&(r.margin=r.marginTop,delete r.marginTop,delete r.marginRight,delete r.marginBottom,delete r.marginLeft),r.rtl===(this.el.style.direction==="rtl")&&(r.rtl="auto"),this._isAutoCellHeight&&(r.cellHeight="auto"),this._autoColumn&&(r.column="auto");const o=r._alwaysShowResizeHandle;return delete r._alwaysShowResizeHandle,o!==void 0?r.alwaysShowResizeHandle=o:delete r.alwaysShowResizeHandle,u.removeInternalAndSame(r,P),r.children=s,r}return s}load(e,t=w.addRemoveCB||!0){var d;e=u.cloneDeep(e);const i=this.getColumn();e.forEach(l=>{l.w=l.w||1,l.h=l.h||1}),e=u.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let s=0;e.forEach(l=>{s=Math.max(s,(l.x||0)+l.w)}),s>this.engine.defaultColumn&&(this.engine.defaultColumn=s),s>i&&this.engine.cacheLayout(e,s,!0);const r=w.addRemoveCB;typeof t=="function"&&(w.addRemoveCB=t);const o=[];this.batchUpdate();const n=!this.engine.nodes.length;n&&this.setAnimation(!1),!n&&t&&[...this.engine.nodes].forEach(h=>{if(!h.id)return;u.find(e,h.id)||(w.addRemoveCB&&w.addRemoveCB(this.el,h,!1,!1),o.push(h),this.removeWidget(h.el,!0,!1))}),this.engine._loading=!0;const c=[];return this.engine.nodes=this.engine.nodes.filter(l=>u.find(e,l.id)?(c.push(l),!1):!0),e.forEach(l=>{var g;const h=u.find(c,l.id);if(h){if(u.shouldSizeToContent(h)&&(l.h=h.h),this.engine.nodeBoundFix(l),(l.autoPosition||l.x===void 0||l.y===void 0)&&(l.w=l.w||h.w,l.h=l.h||h.h,this.engine.findEmptyPosition(l)),this.engine.nodes.push(h),u.samePos(h,l)&&this.engine.nodes.length>1&&(this.moveNode(h,{...l,forceCollide:!0}),u.copyPos(l,h)),this.update(h.el,l),(g=l.subGridOpts)!=null&&g.children){const p=h.el.querySelector(".grid-stack");p&&p.gridstack&&p.gridstack.load(l.subGridOpts.children)}}else t&&this.addWidget(l)}),delete this.engine._loading,this.engine.removedNodes=o,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,r?w.addRemoveCB=r:delete w.addRemoveCB,n&&((d=this.opts)!=null&&d.animate)&&this.setAnimation(this.opts.animate,!0),this}batchUpdate(e=!0){return this.engine.batchUpdate(e),e||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(e=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!e||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;const t=this.el.querySelector("."+this.opts.itemClass);if(t){const s=u.toNumber(t.getAttribute("gs-h"))||1;return Math.round(t.offsetHeight/s)}const i=parseInt(this.el.getAttribute("gs-current-row"));return i?Math.round(this.el.getBoundingClientRect().height/i):this.opts.cellHeight}cellHeight(e,t=!0){if(t&&e!==void 0&&this._isAutoCellHeight!==(e==="auto")&&(this._isAutoCellHeight=e==="auto",this._updateResizeEvent()),(e==="initial"||e==="auto")&&(e=void 0),e===void 0){const s=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+s}const i=u.parseHeight(e);return this.opts.cellHeightUnit===i.unit&&this.opts.cellHeight===i.h?this:(this.opts.cellHeightUnit=i.unit,this.opts.cellHeight=i.h,this.resizeToContentCheck(),t&&this._updateStyles(!0),this)}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(e=!1){var t;return e&&((t=this.opts.columnOpts)!=null&&t.breakpointForWindow)?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){var r,o;const e=this.opts.columnOpts;if(!e||!e.columnWidth&&!((r=e.breakpoints)!=null&&r.length))return!1;const t=this.getColumn();let i=t;const s=this._widthOrContainer(!0);if(e.columnWidth)i=Math.min(Math.round(s/e.columnWidth)||1,e.columnMax);else{i=e.columnMax;let n=0;for(;n<e.breakpoints.length&&s<=e.breakpoints[n].w;)i=e.breakpoints[n++].c||t}if(i!==t){const n=(o=e.breakpoints)==null?void 0:o.find(c=>c.c===i);return this.column(i,(n==null?void 0:n.layout)||e.layout),!0}return!1}compact(e="compact",t=!0){return this.engine.compact(e,t),this._triggerChangeEvent(),this}column(e,t="moveScale"){if(!e||e<1||this.opts.column===e)return this;const i=this.getColumn();return this.opts.column=e,this.engine?(this.engine.column=e,this.el.classList.remove("gs-"+i),this.el.classList.add("gs-"+e),this.engine.columnChanged(i,e,t),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):this}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(e=>e.matches("."+this.opts.itemClass)&&!e.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return this._ignoreLayoutsNodeChange}destroy(e=!0){var t,i;if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),e?this.el.parentNode.removeChild(this.el):(this.removeAll(e),this.el.classList.remove(this._styleSheetClass),this.el.removeAttribute("gs-current-row")),this._removeStylesheet(),(t=this.parentGridNode)==null||delete t.subGrid,delete this.parentGridNode,delete this.opts,(i=this._placeholder)==null||delete i.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(e){return this.opts.float!==e&&(this.opts.float=this.engine.float=e,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(e,t=!1){const i=this.el.getBoundingClientRect();let s;t?s={top:i.top+document.documentElement.scrollTop,left:i.left}:s={top:this.el.offsetTop,left:this.el.offsetLeft};const r=e.left-s.left,o=e.top-s.top,n=i.width/this.getColumn(),c=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/n),y:Math.floor(o/c)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(e,t,i,s){return this.engine.isAreaEmpty(e,t,i,s)}makeWidget(e,t){const i=w.getElement(e);if(!i)return;i.parentElement||this.el.appendChild(i),this._prepareElement(i,!0,t);const s=i.gridstackNode;this._updateContainerHeight(),s.subGridOpts&&this.makeSubGrid(i,s.subGridOpts,void 0,!1);let r;return this.opts.column===1&&!this._ignoreLayoutsNodeChange&&(r=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),r&&delete this._ignoreLayoutsNodeChange,i}on(e,t){return e.indexOf(" ")!==-1?(e.split(" ").forEach(s=>this.on(s,t)),this):(e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable"?(e==="enable"||e==="disable"?this._gsEventHandler[e]=s=>t(s):this._gsEventHandler[e]=s=>{s.detail&&t(s,s.detail)},this.el.addEventListener(e,this._gsEventHandler[e])):e==="drag"||e==="dragstart"||e==="dragstop"||e==="resizestart"||e==="resize"||e==="resizestop"||e==="dropped"||e==="resizecontent"?this._gsEventHandler[e]=t:console.error("GridStack.on("+e+") event not supported"),this)}off(e){return e.indexOf(" ")!==-1?(e.split(" ").forEach(i=>this.off(i)),this):((e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable")&&this._gsEventHandler[e]&&this.el.removeEventListener(e,this._gsEventHandler[e]),delete this._gsEventHandler[e],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(e=>this.off(e)),this}removeWidget(e,t=!0,i=!0){return e?(w.getElements(e).forEach(s=>{if(s.parentElement&&s.parentElement!==this.el)return;let r=s.gridstackNode;r||(r=this.engine.nodes.find(o=>s===o.el)),r&&(t&&w.addRemoveCB&&w.addRemoveCB(this.el,r,!1,!1),delete s.gridstackNode,this._removeDD(s),this.engine.removeNode(r,t,i),t&&s.parentElement&&s.remove())}),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(e=!0,t=!0){return this.engine.nodes.forEach(i=>{e&&w.addRemoveCB&&w.addRemoveCB(this.el,i,!1,!1),delete i.el.gridstackNode,this.opts.staticGrid||this._removeDD(i.el)}),this.engine.removeAll(e,t),t&&this._triggerRemoveEvent(),this}setAnimation(e=this.opts.animate,t){return t?setTimeout(()=>{this.opts&&this.setAnimation(e)}):e?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(e,t=!0,i=!0){return!!this.opts.staticGrid===e?this:(e?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(s=>{this._prepareDragDropByNode(s),s.subGrid&&i&&s.subGrid.setStatic(e,t,i)}),t&&this._setStaticClass(),this)}update(e,t){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");const i=arguments;let s=1;return t={x:i[s++],y:i[s++],w:i[s++],h:i[s++]},this.update(e,t)}return w.getElements(e).forEach(i=>{var l;const s=i==null?void 0:i.gridstackNode;if(!s)return;const r=u.cloneDeep(t);this.engine.nodeBoundFix(r),delete r.autoPosition;const o=["x","y","w","h"];let n;if(o.some(h=>r[h]!==void 0&&r[h]!==s[h])&&(n={},o.forEach(h=>{n[h]=r[h]!==void 0?r[h]:s[h],delete r[h]})),!n&&(r.minW||r.minH||r.maxW||r.maxH)&&(n={}),r.content!==void 0){const h=i.querySelector(".grid-stack-item-content");h&&h.textContent!==r.content&&(s.content=r.content,w.renderCB(h,r),(l=s.subGrid)!=null&&l.el&&(h.appendChild(s.subGrid.el),s.subGrid.opts.styleInHead||s.subGrid._updateStyles(!0))),delete r.content}let c=!1,d=!1;for(const h in r)h[0]!=="_"&&s[h]!==r[h]&&(s[h]=r[h],c=!0,d=d||!this.opts.staticGrid&&(h==="noResize"||h==="noMove"||h==="locked"));if(u.sanitizeMinMax(s),n){const h=n.w!==void 0&&n.w!==s.w;this.moveNode(s,n),h&&s.subGrid?s.subGrid.onResize(this.hasAnimationCSS()?s.w:void 0):this.resizeToContentCheck(h,s),delete s._orig}(n||c)&&this._writeAttr(i,s),d&&this._prepareDragDropByNode(s)}),this}moveNode(e,t){const i=e._updating;i||this.engine.cleanNodes().beginUpdate(e),this.engine.moveNode(e,t),this._updateContainerHeight(),i||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(e){var g,p;if(!e||(e.classList.remove("size-to-content-max"),!e.clientHeight))return;const t=e.gridstackNode;if(!t)return;const i=t.grid;if(!i||e.parentElement!==i.el)return;const s=i.getCellHeight(!0);if(!s)return;let r=t.h?t.h*s:e.clientHeight,o;if(t.resizeToContentParent&&(o=e.querySelector(t.resizeToContentParent)),o||(o=e.querySelector(w.resizeToContentParent)),!o)return;const n=e.clientHeight-o.clientHeight,c=t.h?t.h*s-n:o.clientHeight;let d;if(t.subGrid){d=t.subGrid.getRow()*t.subGrid.getCellHeight(!0);const y=t.subGrid.el.getBoundingClientRect(),_=t.subGrid.el.parentElement.getBoundingClientRect();d+=y.top-_.top}else{if((p=(g=t.subGridOpts)==null?void 0:g.children)!=null&&p.length)return;{const y=o.firstElementChild;if(!y){console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${w.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}d=y.getBoundingClientRect().height||c}}if(c===d)return;r+=d-c;let l=Math.ceil(r/s);const h=Number.isInteger(t.sizeToContent)?t.sizeToContent:0;h&&l>h&&(l=h,e.classList.add("size-to-content-max")),t.minH&&l<t.minH?l=t.minH:t.maxH&&l>t.maxH&&(l=t.maxH),l!==t.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(t,{h:l}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){w.resizeToContentCB?w.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,t){return w.getElements(e).forEach(i=>{const s=i.gridstackNode;if(!u.canBeRotated(s))return;const r={w:s.h,h:s.w,minH:s.minW,minW:s.minH,maxH:s.maxW,maxW:s.maxH};if(t){const n=t.left>0?Math.floor(t.left/this.cellWidth()):0,c=t.top>0?Math.floor(t.top/this.opts.cellHeight):0;r.x=s.x+n-(s.h-(c+1)),r.y=s.y+c-n}Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n]});const o=s._orig;this.update(i,r),s._orig=o}),this}margin(e){if(!(typeof e=="string"&&e.split(" ").length>1)){const i=u.parseHeight(e);if(this.opts.marginUnit===i.unit&&this.opts.margin===i.h)return}return this.opts.margin=e,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this._updateStyles(!0),this}getMargin(){return this.opts.margin}willItFit(e){if(arguments.length>1){console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");const t=arguments;let i=0,s={x:t[i++],y:t[i++],w:t[i++],h:t[i++],autoPosition:t[i++]};return this.willItFit(s)}return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;const e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){var e;if(this.engine.batchMode)return this;if((e=this.engine.addedNodes)!=null&&e.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(i=>{delete i._dirty});const t=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",t)}return this}_triggerRemoveEvent(){var e;if(this.engine.batchMode)return this;if((e=this.engine.removedNodes)!=null&&e.length){const t=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",t)}return this}_triggerEvent(e,t){const i=t?new CustomEvent(e,{bubbles:!1,detail:t}):new Event(e);return this.el.dispatchEvent(i),this}_removeStylesheet(){if(this._styles){const e=this.opts.styleInHead?void 0:this.el.parentNode;u.removeStylesheet(this._styleSheetClass,e),delete this._styles}return this}_updateStyles(e=!1,t){if(e&&this._removeStylesheet(),t===void 0&&(t=this.getRow()),this._updateContainerHeight(),this.opts.cellHeight===0)return this;const i=this.opts.cellHeight,s=this.opts.cellHeightUnit,r=`.${this._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){const o=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=u.createStylesheet(this._styleSheetClass,o,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,u.addCSSRule(this._styles,r,`height: ${i}${s}`);const n=this.opts.marginTop+this.opts.marginUnit,c=this.opts.marginBottom+this.opts.marginUnit,d=this.opts.marginRight+this.opts.marginUnit,l=this.opts.marginLeft+this.opts.marginUnit,h=`${r} > .grid-stack-item-content`,g=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;u.addCSSRule(this._styles,h,`top: ${n}; right: ${d}; bottom: ${c}; left: ${l};`),u.addCSSRule(this._styles,g,`top: ${n}; right: ${d}; bottom: ${c}; left: ${l};`),u.addCSSRule(this._styles,`${r} > .ui-resizable-n`,`top: ${n};`),u.addCSSRule(this._styles,`${r} > .ui-resizable-s`,`bottom: ${c}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-ne`,`right: ${d}; top: ${n}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-e`,`right: ${d}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-se`,`right: ${d}; bottom: ${c}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-nw`,`left: ${l}; top: ${n}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-w`,`left: ${l}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-sw`,`left: ${l}; bottom: ${c}`)}if(t=t||this._styles._max,t>this._styles._max){const o=n=>i*n+s;for(let n=this._styles._max+1;n<=t;n++)u.addCSSRule(this._styles,`${r}[gs-y="${n}"]`,`top: ${o(n)}`),u.addCSSRule(this._styles,`${r}[gs-h="${n+1}"]`,`height: ${o(n+1)}`);this._styles._max=t}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;const e=this.parentGridNode;let t=this.getRow()+this._extraDragRow;const i=this.opts.cellHeight,s=this.opts.cellHeightUnit;if(!i)return this;if(!e){const r=u.parseHeight(getComputedStyle(this.el).minHeight);if(r.h>0&&r.unit===s){const o=Math.floor(r.h/i);t<o&&(t=o)}}return this.el.setAttribute("gs-current-row",String(t)),this.el.style.removeProperty("min-height"),this.el.style.removeProperty("height"),t&&(this.el.style[e?"minHeight":"height"]=t*i+s),e&&!e.grid.engine.batchMode&&u.shouldSizeToContent(e)&&e.grid.resizeToContentCBCheck(e.el),this}_prepareElement(e,t=!1,i){i=i||this._readAttr(e),e.gridstackNode=i,i.el=e,i.grid=this,i=this.engine.addNode(i,t),this._writeAttr(e,i),e.classList.add(P.itemClass,this.opts.itemClass);const s=u.shouldSizeToContent(i);return s?e.classList.add("size-to-content"):e.classList.remove("size-to-content"),s&&this.resizeToContentCheck(!1,i),this._prepareDragDropByNode(i),this}_writePosAttr(e,t){return t.x!==void 0&&t.x!==null&&e.setAttribute("gs-x",String(t.x)),t.y!==void 0&&t.y!==null&&e.setAttribute("gs-y",String(t.y)),t.w>1?e.setAttribute("gs-w",String(t.w)):e.removeAttribute("gs-w"),t.h>1?e.setAttribute("gs-h",String(t.h)):e.removeAttribute("gs-h"),this}_writeAttr(e,t){if(!t)return this;this._writePosAttr(e,t);const i={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(const s in i)t[s]?e.setAttribute(i[s],String(t[s])):e.removeAttribute(i[s]);return this}_readAttr(e,t=!0){const i={};i.x=u.toNumber(e.getAttribute("gs-x")),i.y=u.toNumber(e.getAttribute("gs-y")),i.w=u.toNumber(e.getAttribute("gs-w")),i.h=u.toNumber(e.getAttribute("gs-h")),i.autoPosition=u.toBool(e.getAttribute("gs-auto-position")),i.noResize=u.toBool(e.getAttribute("gs-no-resize")),i.noMove=u.toBool(e.getAttribute("gs-no-move")),i.locked=u.toBool(e.getAttribute("gs-locked")),i.sizeToContent=u.toBool(e.getAttribute("gs-size-to-content")),i.id=e.getAttribute("gs-id"),i.maxW=u.toNumber(e.getAttribute("gs-max-w")),i.minW=u.toNumber(e.getAttribute("gs-min-w")),i.maxH=u.toNumber(e.getAttribute("gs-max-h")),i.minH=u.toNumber(e.getAttribute("gs-min-h")),t&&(i.w===1&&e.removeAttribute("gs-w"),i.h===1&&e.removeAttribute("gs-h"),i.maxW&&e.removeAttribute("gs-max-w"),i.minW&&e.removeAttribute("gs-min-w"),i.maxH&&e.removeAttribute("gs-max-h"),i.minH&&e.removeAttribute("gs-min-h"));for(const s in i){if(!i.hasOwnProperty(s))return;!i[s]&&i[s]!==0&&delete i[s]}return i}_setStaticClass(){const e=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...e),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...e),this.el.removeAttribute("gs-static")),this}onResize(e=(t=>(t=this.el)==null?void 0:t.clientWidth)()){if(!e||this.prevWidth===e)return;this.prevWidth=e,this.batchUpdate();let i=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),i=!0):i=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(s=>{s.subGrid&&s.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(i),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(e=!1,t=void 0){if(this.engine){if(e&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,t),this.animationDelay);if(t)u.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el);else if(this.engine.nodes.some(i=>u.shouldSizeToContent(i))){const i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{u.shouldSizeToContent(s)&&this.resizeToContentCBCheck(s.el)}),this.batchUpdate(!1)}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,t?[t]:this.engine.nodes)}}_updateResizeEvent(e=!1){const t=!this.parentGridNode&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(i=>i.sizeToContent));return!e&&t&&!this.resizeObserver?(this._sizeThrottle=u.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(e||!t)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(e=".grid-stack-item"){return u.getElement(e)}static getElements(e=".grid-stack-item"){return u.getElements(e)}static getGridElement(e){return w.getElement(e)}static getGridElements(e){return u.getElements(e)}_initMargin(){let e,t=0,i=[];return typeof this.opts.margin=="string"&&(i=this.opts.margin.split(" ")),i.length===2?(this.opts.marginTop=this.opts.marginBottom=i[0],this.opts.marginLeft=this.opts.marginRight=i[1]):i.length===4?(this.opts.marginTop=i[0],this.opts.marginRight=i[1],this.opts.marginBottom=i[2],this.opts.marginLeft=i[3]):(e=u.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,t=this.opts.margin=e.h),this.opts.marginTop===void 0?this.opts.marginTop=t:(e=u.parseHeight(this.opts.marginTop),this.opts.marginTop=e.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=t:(e=u.parseHeight(this.opts.marginBottom),this.opts.marginBottom=e.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=t:(e=u.parseHeight(this.opts.marginRight),this.opts.marginRight=e.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=t:(e=u.parseHeight(this.opts.marginLeft),this.opts.marginLeft=e.h,delete this.opts.margin),this.opts.marginUnit=e.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop),this}static getDD(){return O}static setupDragIn(e,t,i,s=document){(t==null?void 0:t.pause)!==void 0&&(C.pauseDrag=t.pause),t={appendTo:"body",helper:"clone",...t||{}},(typeof e=="string"?u.getElements(e,s):e).forEach((o,n)=>{O.isDraggable(o)||O.dragIn(o,t),i!=null&&i[n]&&(o.gridstackNode=i[n])})}movable(e,t){return this.opts.staticGrid?this:(w.getElements(e).forEach(i=>{const s=i.gridstackNode;s&&(t?delete s.noMove:s.noMove=!0,this._prepareDragDropByNode(s))}),this)}resizable(e,t){return this.opts.staticGrid?this:(w.getElements(e).forEach(i=>{const s=i.gridstackNode;s&&(t?delete s.noResize:s.noResize=!0,this._prepareDragDropByNode(s))}),this)}disable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!1,e),this.enableResize(!1,e),this._triggerEvent("disable"),this}enable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!0,e),this.enableResize(!0,e),this._triggerEvent("enable"),this}enableMove(e,t=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&t&&i.subGrid.enableMove(e,t)}),this)}enableResize(e,t=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&t&&i.subGrid.enableResize(e,t)}),this)}cancelDrag(){var t;const e=(t=this._placeholder)==null?void 0:t.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&w._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return O.draggable(e,"destroy").resizable(e,"destroy"),e.gridstackNode&&delete e.gridstackNode._initDD,delete e.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return O.droppable(this.el,"destroy"),this;let e,t;const i=(s,r,o)=>{var g;o=o||r;const n=o.gridstackNode;if(!n)return;if(!((g=n.grid)!=null&&g.el)){o.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;const p=o.getBoundingClientRect();o.style.left=p.x+(this.dragTransform.xScale-1)*(s.clientX-p.x)/this.dragTransform.xScale+"px",o.style.top=p.y+(this.dragTransform.yScale-1)*(s.clientY-p.y)/this.dragTransform.yScale+"px",o.style.transformOrigin="0px 0px"}let{top:c,left:d}=o.getBoundingClientRect();const l=this.el.getBoundingClientRect();d-=l.left,c-=l.top;const h={position:{top:c*this.dragTransform.xScale,left:d*this.dragTransform.yScale}};if(n._temporaryRemoved){if(n.x=Math.max(0,Math.round(d/t)),n.y=Math.max(0,Math.round(c/e)),delete n.autoPosition,this.engine.nodeBoundFix(n),!this.engine.willItFit(n)){if(n.autoPosition=!0,!this.engine.willItFit(n)){O.off(r,"drag");return}n._willFitPos&&(u.copyPos(n,n._willFitPos),delete n._willFitPos)}this._onStartMoving(o,s,h,n,t,e)}else this._dragOrResize(o,s,h,n,t,e)};return O.droppable(this.el,{accept:s=>{const r=s.gridstackNode||this._readAttr(s,!1);if((r==null?void 0:r.grid)===this)return!0;if(!this.opts.acceptWidgets)return!1;let o=!0;if(typeof this.opts.acceptWidgets=="function")o=this.opts.acceptWidgets(s);else{const n=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;o=s.matches(n)}if(o&&r&&this.opts.maxRow){const n={w:r.w,h:r.h,minW:r.minW,minH:r.minH};o=this.engine.willItFit(n)}return o}}).on(this.el,"dropover",(s,r,o)=>{let n=(o==null?void 0:o.gridstackNode)||r.gridstackNode;if((n==null?void 0:n.grid)===this&&!n._temporaryRemoved)return!1;if(n!=null&&n.grid&&n.grid!==this&&!n._temporaryRemoved&&n.grid._leave(r,o),o=o||r,t=this.cellWidth(),e=this.getCellHeight(!0),!n){const l=o.getAttribute("data-gs-widget")||o.getAttribute("gridstacknode");if(l){try{n=JSON.parse(l)}catch{console.error("Gridstack dropover: Bad JSON format: ",l)}o.removeAttribute("data-gs-widget"),o.removeAttribute("gridstacknode")}n||(n=this._readAttr(o))}n.grid||(n.el||(n={...n}),n._isExternal=!0,o.gridstackNode=n);const c=n.w||Math.round(o.offsetWidth/t)||1,d=n.h||Math.round(o.offsetHeight/e)||1;return n.grid&&n.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=n),r.gridstackNode=n={...n,w:c,h:d,grid:this},delete n.x,delete n.y,this.engine.cleanupNode(n).nodeBoundFix(n),n._initDD=n._isExternal=n._temporaryRemoved=!0):(n.w=c,n.h=d,n._temporaryRemoved=!0),w._itemRemoving(n.el,!1),O.on(r,"drag",i),i(s,r,o),!1}).on(this.el,"dropout",(s,r,o)=>{const n=(o==null?void 0:o.gridstackNode)||r.gridstackNode;return n&&(!n.grid||n.grid===this)&&(this._leave(r,o),this._isTemp&&this.removeAsSubGrid(n)),!1}).on(this.el,"drop",(s,r,o)=>{var p,y,_;const n=(o==null?void 0:o.gridstackNode)||r.gridstackNode;if((n==null?void 0:n.grid)===this&&!n._isExternal)return!1;const c=!!this.placeholder.parentElement,d=r!==o;this.placeholder.remove(),delete this.placeholder.gridstackNode;const l=c&&this.opts.animate;l&&this.setAnimation(!1);const h=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,c&&(h!=null&&h.grid)&&h.grid!==this){const m=h.grid;m.engine.removeNodeFromLayoutCache(h),m.engine.removedNodes.push(h),m._triggerRemoveEvent()._triggerChangeEvent(),m.parentGridNode&&!m.engine.nodes.length&&m.opts.subGridDynamic&&m.removeAsSubGrid()}if(!n||(c&&(this.engine.cleanupNode(n),n.grid=this),(p=n.grid)==null||delete p._isTemp,O.off(r,"drag"),o!==r?(o.remove(),r=o):r.remove(),this._removeDD(r),!c))return!1;const g=(_=(y=n.subGrid)==null?void 0:y.el)==null?void 0:_.gridstack;return u.copyPos(n,this._readAttr(this.placeholder)),u.removePositioningStyles(r),d&&(n.content||n.subGridOpts||w.addRemoveCB)?(delete n.el,r=this.addWidget(n)):(this._prepareElement(r,!0,n),this.el.appendChild(r),this.resizeToContentCheck(!1,n),g&&(g.parentGridNode=n,g.opts.styleInHead||g._updateStyles(!0)),this._updateContainerHeight()),this.engine.addedNodes.push(n),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...s,type:"dropped"},h&&h.grid?h:void 0,n),l&&this.setAnimation(this.opts.animate,!0),!1}),this}static _itemRemoving(e,t){if(!e)return;const i=e?e.gridstackNode:void 0;!(i!=null&&i.grid)||e.classList.contains(i.grid.opts.removableOptions.decline)||(t?i._isAboutToRemove=!0:delete i._isAboutToRemove,t?e.classList.add("grid-stack-item-removing"):e.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;const e=document.querySelector(this.opts.removable);return e?(!this.opts.staticGrid&&!O.isDroppable(e)&&O.droppable(e,this.opts.removableOptions).on(e,"dropover",(t,i)=>w._itemRemoving(i,!0)).on(e,"dropout",(t,i)=>w._itemRemoving(i,!1)),this):this}_prepareDragDropByNode(e){const t=e.el,i=e.noMove||this.opts.disableDrag,s=e.noResize||this.opts.disableResize;if(this.opts.staticGrid||i&&s)return e._initDD&&(this._removeDD(t),delete e._initDD),t.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!e._initDD){let r,o;const n=(l,h)=>{this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,l.target),r=this.cellWidth(),o=this.getCellHeight(!0),this._onStartMoving(t,l,h,e,r,o)},c=(l,h)=>{this._dragOrResize(t,l,h,e,r,o)},d=l=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete e._moving,delete e._event,delete e._lastTried;const h=e.w!==e._orig.w,g=l.target;if(!(!g.gridstackNode||g.gridstackNode.grid!==this)){if(e.el=g,e._isAboutToRemove){const p=t.gridstackNode.grid;p._gsEventHandler[l.type]&&p._gsEventHandler[l.type](l,g),p.engine.nodes.push(e),p.removeWidget(t,!0,!0)}else u.removePositioningStyles(g),e._temporaryRemoved?(u.copyPos(e,e._orig),this._writePosAttr(g,e),this.engine.addNode(e)):this._writePosAttr(g,e),this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,g);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),l.type==="resizestop"&&(Number.isInteger(e.sizeToContent)&&(e.sizeToContent=e.h),this.resizeToContentCheck(h,e))}};O.draggable(t,{start:n,stop:d,drag:c}).resizable(t,{start:n,stop:d,resize:c}),e._initDD=!0}return O.draggable(t,i?"disable":"enable").resizable(t,s?"disable":"enable"),this}_onStartMoving(e,t,i,s,r,o){var n;if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=s,(n=s.grid)!=null&&n.el)this.dragTransform=u.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const c=this.placeholder.closest(".grid-stack");this.dragTransform=u.getValuesFromTransformedElement(c)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(s.el=this.placeholder,s._lastUiPosition=i.position,s._prevYPix=i.position.top,s._moving=t.type==="dragstart",delete s._lastTried,t.type==="dropover"&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(r,o,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),t.type==="resizestart"){const c=this.getColumn()-s.x,d=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-s.y;O.resizable(e,"option","minWidth",r*Math.min(s.minW||1,c)).resizable(e,"option","minHeight",o*Math.min(s.minH||1,d)).resizable(e,"option","maxWidth",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,c)).resizable(e,"option","maxWidthMoveLeft",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,s.x+s.w)).resizable(e,"option","maxHeight",o*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,d)).resizable(e,"option","maxHeightMoveUp",o*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,s.y+s.h))}}_dragOrResize(e,t,i,s,r,o){const n={...s._orig};let c,d=this.opts.marginLeft,l=this.opts.marginRight,h=this.opts.marginTop,g=this.opts.marginBottom;const p=Math.round(o*.1),y=Math.round(r*.1);if(d=Math.min(d,y),l=Math.min(l,y),h=Math.min(h,p),g=Math.min(g,p),t.type==="drag"){if(s._temporaryRemoved)return;const m=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&u.updateScrollPosition(e,i.position,m);const T=i.position.left+(i.position.left>s._lastUiPosition.left?-l:d),N=i.position.top+(i.position.top>s._lastUiPosition.top?-g:h);n.x=Math.round(T/r),n.y=Math.round(N/o);const k=this._extraDragRow;if(this.engine.collide(s,n)){const R=this.getRow();let x=Math.max(0,n.y+s.h-R);this.opts.maxRow&&R+x>this.opts.maxRow&&(x=Math.max(0,this.opts.maxRow-R)),this._extraDragRow=x}else this._extraDragRow=0;if(this._extraDragRow!==k&&this._updateContainerHeight(),s.x===n.x&&s.y===n.y)return}else if(t.type==="resize"){if(n.x<0||(u.updateScrollResize(t,e,o),n.w=Math.round((i.size.width-d)/r),n.h=Math.round((i.size.height-h)/o),s.w===n.w&&s.h===n.h)||s._lastTried&&s._lastTried.w===n.w&&s._lastTried.h===n.h)return;const m=i.position.left+d,T=i.position.top+h;n.x=Math.round(m/r),n.y=Math.round(T/o),c=!0}s._event=t,s._lastTried=n;const _={x:i.position.left+d,y:i.position.top+h,w:(i.size?i.size.width:s.w*r)-d-l,h:(i.size?i.size.height:s.h*o)-h-g};if(this.engine.moveNodeCheck(s,{...n,cellWidth:r,cellHeight:o,rect:_,resizing:c})){s._lastUiPosition=i.position,this.engine.cacheRects(r,o,h,l,g,d),delete s._skipDown,c&&s.subGrid&&s.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const m=t.target;this._writePosAttr(m,s),this._gsEventHandler[t.type]&&this._gsEventHandler[t.type](t,m)}}_leave(e,t){t=t||e;const i=t.gridstackNode;i&&(t.style.transform=t.style.transformOrigin=null,O.off(e,"drag"),!i._temporaryRemoved&&(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&t?t:e,i._isExternal&&this.engine.cleanupNode(i),this.opts.removable===!0&&w._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):i._isExternal&&this.engine.restoreInitial()))}commit(){return Ft(this,this.batchUpdate(!1),"commit","batchUpdate","5.2"),this}}w.renderCB=(f,e)=>{f&&(e!=null&&e.content)&&(f.textContent=e.content)},w.resizeToContentParent=".grid-stack-item-content",w.Utils=u,w.Engine=W,w.GDRev="11.3.0";const Vt=["data-id","data-testid","gs-h","gs-w","gs-x","gs-y"],Kt={class:"grid-stack-item-content"},Yt=J(a.defineComponent({__name:"DraggableGridLayout",props:{tiles:{},gridSize:{},tileHeight:{default:200}},emits:["update-tiles"],setup(f,{expose:e,emit:t}){const i=f,s=t,r=a.ref(null),o=a.ref(new Map(i.tiles.map(p=>[`${p.id}`,p])));let n=null;const c=p=>`[data-id="${p}"]`,d=p=>p.map(y=>{var m;const _=o.value.get(`${(m=y.el)==null?void 0:m.getAttribute("data-id")}`);if(_)return{..._,layout:{position:{col:Number(y.x),row:Number(y.y)},size:{cols:Number(y.w),rows:Number(y.h)}}}}).filter(y=>y!==void 0),l=(p,y)=>{n&&(d(y).forEach(m=>{o.value.set(`${m.id}`,m)}),s("update-tiles",Array.from(o.value.values())))},h=(p,y)=>{y.forEach(_=>{var m;o.value.delete(`${(m=_.el)==null?void 0:m.getAttribute("data-id")}`)}),s("update-tiles",Array.from(o.value.values()))};a.onMounted(()=>{r.value&&(n=w.init({column:i.gridSize.cols,cellHeight:i.tileHeight,resizable:{handles:"se, sw"},handle:".tile-header"},r.value),n.on("change",l),n.on("added",l),n.on("removed",h))}),a.onUnmounted(()=>{n&&n.destroy(!1)});const g=p=>{if(n&&r.value){const y=r.value.querySelector(c(p));y&&n.removeWidget(y)}};return a.watch(()=>i.tiles.length,async(p,y)=>{if(p>y&&n){const _=i.tiles.slice(y);for(const m of _)o.value.set(`${m.id}`,m),await a.nextTick(),n.makeWidget(c(m.id),{autoPosition:!0,w:m.layout.size.cols,h:m.layout.size.rows})}}),a.watchEffect(()=>{i.tiles.forEach(p=>{o.value.set(`${p.id}`,p)})}),e({removeWidget:g}),(p,y)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"gridContainer",ref:r,class:"grid-stack"},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(i.tiles,_=>(a.openBlock(),a.createElementBlock("div",{key:_.id,class:"grid-stack-item","data-id":`${_.id}`,"data-testid":`grid-stack-item-${_.id}`,"gs-h":_.layout.size.rows,"gs-lazy-load":!0,"gs-w":_.layout.size.cols,"gs-x":_.layout.position.col,"gs-y":_.layout.position.row},[a.createElementVNode("div",Kt,[a.renderSlot(p.$slots,"tile",{tile:_},void 0,!0)])],8,Vt))),128))],512))}}),[["__scopeId","data-v-f4f87f74"]]),jt={class:"kong-ui-public-dashboard-renderer"},Xt={key:0,class:"tile-container slottable-tile"},Qt=J(a.defineComponent({__name:"DashboardRenderer",props:a.mergeModels({context:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:a.mergeModels(["edit-tile","zoom-time-range"],["update:modelValue"]),setup(f,{expose:e,emit:t}){const i=f,s=t,r=a.useModel(f,"modelValue"),{i18n:o}=ee.useI18n(),n=a.ref(0),c=a.ref(null),d=a.inject(X);d||(console.warn("Analytics dashboards require a query bridge supplied via provide / inject."),console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"),console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/README.md#requirements")),ee.useRequestQueue();const l=Ie.useAnalyticsConfigStore(),h=a.computed(()=>i.context.timeSpec?i.context.timeSpec:{type:"relative",time_range:l.defaultQueryTimeForOrg}),g=a.computed(()=>!!i.context.timeSpec||!l.loading),p=(R,x)=>{const S=R.layout.position.row-x.layout.position.row;return S!==0?S:R.layout.position.col-x.layout.position.col},y=a.computed(()=>r.value.tiles.map((R,x)=>{var B;let S=R.definition;if("description"in S.chart){const I=(B=S.chart.description)==null?void 0:B.replace(Fe,()=>{const E=`renderer.trendRange.${h.value.type==="absolute"?"custom":h.value.time_range}`;return o.te(E)?o.t(E):""});S={...S,chart:{...S.chart,description:I}}}return i.context.editable&&!R.id&&console.warn("No id provided for tile. One will be generated automatically,","however tracking changes to this tile may not work as expected.",R),{layout:R.layout,meta:S,id:R.id??crypto.randomUUID()}})),_=a.computed(()=>{let{tz:R,refreshInterval:x,editable:S}=i.context;return R||(R=new Intl.DateTimeFormat().resolvedOptions().timeZone),x===void 0&&(x=Ge),S===void 0&&(S=!1),{...i.context,tz:R,timeSpec:h.value,refreshInterval:x,editable:S}}),m=R=>{s("edit-tile",R)},T=R=>{c.value&&c.value.removeWidget(R.id)},N=()=>{n.value++},k=R=>{const x=R.map(S=>({id:S.id,layout:S.layout,definition:S.meta}));r.value.gridSize.rows=Math.max(1,...x.map(S=>S.layout.position.row+S.layout.size.rows)),r.value.tiles=x.sort(p)};return e({refresh:N}),(R,x)=>{const S=a.resolveComponent("KAlert");return a.openBlock(),a.createElementBlock("div",jt,[a.unref(d)?(a.openBlock(),a.createBlock(a.resolveDynamicComponent(R.context.editable?Yt:tt),{key:1,ref_key:"gridLayoutRef",ref:c,"grid-size":r.value.gridSize,"tile-height":r.value.tileHeight,tiles:y.value,onUpdateTiles:k},{tile:a.withCtx(({tile:B})=>[B.meta.chart.type==="slottable"?(a.openBlock(),a.createElementBlock("div",Xt,[a.renderSlot(R.$slots,B.meta.chart.id,{},void 0,!0)])):(a.openBlock(),a.createBlock(qt,{key:1,class:"tile-container",context:_.value,definition:B.meta,height:B.layout.size.rows*(r.value.tileHeight||a.unref(ge))+parseInt(a.unref(Je),10),"query-ready":g.value,"refresh-counter":n.value,"tile-id":B.id,onEditTile:I=>m(B),onRemoveTile:I=>T(B),onZoomTimeRange:x[0]||(x[0]=I=>s("zoom-time-range",I))},null,8,["context","definition","height","query-ready","refresh-counter","tile-id","onEditTile","onRemoveTile"]))]),_:3},40,["grid-size","tile-height","tiles"])):(a.openBlock(),a.createBlock(S,{key:0,appearance:"danger"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(a.unref(o).t("renderer.noQueryBridge")),1)]),_:1}))])}}}),[["__scopeId","data-v-d96885ca"]]);b.CP_ID_TOKEN=$e,b.DEFAULT_TILE_HEIGHT=ge,b.DEFAULT_TILE_REFRESH_INTERVAL_MS=Ge,b.DashboardRenderer=Qt,b.ENTITY_ID_TOKEN=Te,b.GridLayout=tt,b.INJECT_QUERY_PROVIDER=X,b.TIMEFRAME_TOKEN=Fe,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
7
+ */const I=new Vt;class b{static init(e={},t=".grid-stack"){if(typeof document>"u")return null;const i=b.getGridElement(t);return i?(i.gridstack||(i.gridstack=new b(i,u.cloneDeep(e))),i.gridstack):(console.error(typeof t=="string"?'GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
8
+ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(e={},t=".grid-stack"){const i=[];return typeof document>"u"||(b.getGridElements(t).forEach(s=>{s.gridstack||(s.gridstack=new b(s,u.cloneDeep(e))),i.push(s.gridstack)}),i.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
9
+ Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),i}static addGrid(e,t={}){if(!e)return null;let i=e;if(i.gridstack){const a=i.gridstack;return t&&(a.opts={...a.opts,...t}),t.children!==void 0&&a.load(t.children),a}return(!e.classList.contains("grid-stack")||b.addRemoveCB)&&(b.addRemoveCB?i=b.addRemoveCB(e,t,!0,!0):i=u.createDiv(["grid-stack",t.class],e)),b.init(t,i)}static registerEngine(e){b.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=u.createDiv([this.opts.placeholderClass,q.itemClass,this.opts.itemClass]);const e=u.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,t={}){var h,g,p;this.el=e,this.opts=t,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},e.gridstack=this,this.opts=t=t||{},e.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),t.row&&(t.minRow=t.maxRow=t.row,delete t.row);const i=u.toNumber(e.getAttribute("gs-row"));t.column==="auto"&&delete t.column,t.alwaysShowResizeHandle!==void 0&&(t._alwaysShowResizeHandle=t.alwaysShowResizeHandle);let s=(h=t.columnOpts)==null?void 0:h.breakpoints;const r=t;if(r.oneColumnModeDomSort&&(delete r.oneColumnModeDomSort,console.log("warning: Gridstack oneColumnModeDomSort no longer supported. Use GridStackOptions.columnOpts instead.")),r.oneColumnSize||r.disableOneColumnMode===!1){const y=r.oneColumnSize||768;delete r.oneColumnSize,delete r.disableOneColumnMode,t.columnOpts=t.columnOpts||{},s=t.columnOpts.breakpoints=t.columnOpts.breakpoints||[];let _=s.find(m=>m.c===1);_?_.w=y:(_={c:1,w:y},s.push(_,{c:12,w:y+1}))}const a=t.columnOpts;a&&(!a.columnWidth&&!((g=a.breakpoints)!=null&&g.length)?(delete t.columnOpts,s=void 0):a.columnMax=a.columnMax||12),(s==null?void 0:s.length)>1&&s.sort((y,_)=>(_.w||0)-(y.w||0));const n={...u.cloneDeep(q),column:u.toNumber(e.getAttribute("gs-column"))||q.column,minRow:i||u.toNumber(e.getAttribute("gs-min-row"))||q.minRow,maxRow:i||u.toNumber(e.getAttribute("gs-max-row"))||q.maxRow,staticGrid:u.toBool(e.getAttribute("gs-static"))||q.staticGrid,sizeToContent:u.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(t.handleClass?"."+t.handleClass:t.handle?t.handle:"")||q.draggable.handle},removableOptions:{accept:t.itemClass||q.removableOptions.accept,decline:q.removableOptions.decline}};e.getAttribute("gs-animate")&&(n.animate=u.toBool(e.getAttribute("gs-animate"))),t=u.defaults(t,n),this._initMargin(),this.checkDynamicColumn(),this.el.classList.add("gs-"+t.column),t.rtl==="auto"&&(t.rtl=e.style.direction==="rtl"),t.rtl&&this.el.classList.add("grid-stack-rtl");const c=this.el.closest("."+q.itemClass),d=c==null?void 0:c.gridstackNode;d&&(d.subGrid=this,this.parentGridNode=d,this.el.classList.add("grid-stack-nested"),d.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=t.cellHeight==="auto",this._isAutoCellHeight||t.cellHeight==="initial"?this.cellHeight(void 0,!1):(typeof t.cellHeight=="number"&&t.cellHeightUnit&&t.cellHeightUnit!==q.cellHeightUnit&&(t.cellHeight=t.cellHeight+t.cellHeightUnit,delete t.cellHeightUnit),this.cellHeight(t.cellHeight,!1)),t.alwaysShowResizeHandle==="mobile"&&(t.alwaysShowResizeHandle=U),this._styleSheetClass="gs-id-"+V._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();const l=t.engineClass||b.engineClass||V;if(this.engine=new l({column:this.getColumn(),float:t.float,maxRow:t.maxRow,onChange:y=>{let _=0;this.engine.nodes.forEach(m=>{_=Math.max(_,m.y+m.h)}),y.forEach(m=>{const k=m.el;k&&(m._removeDOM?(k&&k.remove(),delete m._removeDOM):this._writePosAttr(k,m))}),this._updateStyles(!1,_)}}),this._updateStyles(!1,0),t.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(y=>this._prepareElement(y)),delete this.engine._loading,this.batchUpdate(!1)),t.children){const y=t.children;delete t.children,y.length&&this.load(y)}this.setAnimation(),t.subGridDynamic&&!C.pauseDrag&&(C.pauseDrag=!0),((p=t.draggable)==null?void 0:p.pause)!==void 0&&(C.pauseDrag=t.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}addWidget(e){if(typeof e=="string"){console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");return}if(e.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(e);let t,i=e;if(i.grid=this,i!=null&&i.el?t=i.el:b.addRemoveCB?t=b.addRemoveCB(this.el,e,!0,!1):t=u.createWidgetDivs(this.opts.itemClass,i),!t)return;if(i=t.gridstackNode,i&&t.parentElement===this.el&&this.engine.nodes.find(r=>r._id===i._id))return t;const s=this._readAttr(t);return u.defaults(e,s),this.engine.prepareNode(e),this.el.appendChild(t),this.makeWidget(t,e),t}makeSubGrid(e,t,i,s=!0){var p,y,_;let r=e.gridstackNode;if(r||(r=this.makeWidget(e).gridstackNode),(p=r.subGrid)!=null&&p.el)return r.subGrid;let a,n=this;for(;n&&!a;)a=(y=n.opts)==null?void 0:y.subGridOpts,n=(_=n.parentGridNode)==null?void 0:_.grid;t=u.cloneDeep({...this.opts,id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0,...a||{},...t||r.subGridOpts||{}}),r.subGridOpts=t;let c;t.column==="auto"&&(c=!0,t.column=Math.max(r.w||1,(i==null?void 0:i.w)||1),delete t.columnOpts);let d=r.el.querySelector(".grid-stack-item-content"),l,h;if(s&&(this._removeDD(r.el),h={...r,x:0,y:0},u.removeInternalForSave(h),delete h.subGridOpts,r.content&&(h.content=r.content,delete r.content),b.addRemoveCB?l=b.addRemoveCB(this.el,h,!0,!1):(l=u.createDiv(["grid-stack-item"]),l.appendChild(d),d=u.createDiv(["grid-stack-item-content"],r.el)),this._prepareDragDropByNode(r)),i){const m=c?t.column:r.w,k=r.h+i.h,N=r.el.style;N.transition="none",this.update(r.el,{w:m,h:k}),setTimeout(()=>N.transition=null)}const g=r.subGrid=b.addGrid(d,t);return i!=null&&i._moving&&(g._isTemp=!0),c&&(g._autoColumn=!0),s&&g.makeWidget(l,h),i&&(i._moving?window.setTimeout(()=>u.simulateMouseEvent(i._event,"mouseenter",g.el),0):g.makeWidget(r.el,r)),this.resizeToContentCheck(!1,r),g}removeAsSubGrid(e){var i;const t=(i=this.parentGridNode)==null?void 0:i.grid;t&&(t.batchUpdate(),t.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(s=>{s.x+=this.parentGridNode.x,s.y+=this.parentGridNode.y,t.makeWidget(s.el,s)}),t.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,e&&window.setTimeout(()=>u.simulateMouseEvent(e._event,"mouseenter",t.el),0))}save(e=!0,t=!1,i=b.saveCB){const s=this.engine.save(e,i);if(s.forEach(r=>{var a;if(e&&r.el&&!r.subGrid&&!i){const n=r.el.querySelector(".grid-stack-item-content");r.content=n==null?void 0:n.innerHTML,r.content||delete r.content}else if(!e&&!i&&delete r.content,(a=r.subGrid)!=null&&a.el){const n=r.subGrid.save(e,t,i);r.subGridOpts=t?n:{children:n},delete r.subGrid}delete r.el}),t){const r=u.cloneDeep(this.opts);r.marginBottom===r.marginTop&&r.marginRight===r.marginLeft&&r.marginTop===r.marginRight&&(r.margin=r.marginTop,delete r.marginTop,delete r.marginRight,delete r.marginBottom,delete r.marginLeft),r.rtl===(this.el.style.direction==="rtl")&&(r.rtl="auto"),this._isAutoCellHeight&&(r.cellHeight="auto"),this._autoColumn&&(r.column="auto");const a=r._alwaysShowResizeHandle;return delete r._alwaysShowResizeHandle,a!==void 0?r.alwaysShowResizeHandle=a:delete r.alwaysShowResizeHandle,u.removeInternalAndSame(r,q),r.children=s,r}return s}load(e,t=b.addRemoveCB||!0){var d;e=u.cloneDeep(e);const i=this.getColumn();e.forEach(l=>{l.w=l.w||1,l.h=l.h||1}),e=u.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let s=0;e.forEach(l=>{s=Math.max(s,(l.x||0)+l.w)}),s>this.engine.defaultColumn&&(this.engine.defaultColumn=s),s>i&&this.engine.cacheLayout(e,s,!0);const r=b.addRemoveCB;typeof t=="function"&&(b.addRemoveCB=t);const a=[];this.batchUpdate();const n=!this.engine.nodes.length;n&&this.setAnimation(!1),!n&&t&&[...this.engine.nodes].forEach(h=>{if(!h.id)return;u.find(e,h.id)||(b.addRemoveCB&&b.addRemoveCB(this.el,h,!1,!1),a.push(h),this.removeWidget(h.el,!0,!1))}),this.engine._loading=!0;const c=[];return this.engine.nodes=this.engine.nodes.filter(l=>u.find(e,l.id)?(c.push(l),!1):!0),e.forEach(l=>{var g;const h=u.find(c,l.id);if(h){if(u.shouldSizeToContent(h)&&(l.h=h.h),this.engine.nodeBoundFix(l),(l.autoPosition||l.x===void 0||l.y===void 0)&&(l.w=l.w||h.w,l.h=l.h||h.h,this.engine.findEmptyPosition(l)),this.engine.nodes.push(h),u.samePos(h,l)&&this.engine.nodes.length>1&&(this.moveNode(h,{...l,forceCollide:!0}),u.copyPos(l,h)),this.update(h.el,l),(g=l.subGridOpts)!=null&&g.children){const p=h.el.querySelector(".grid-stack");p&&p.gridstack&&p.gridstack.load(l.subGridOpts.children)}}else t&&this.addWidget(l)}),delete this.engine._loading,this.engine.removedNodes=a,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,r?b.addRemoveCB=r:delete b.addRemoveCB,n&&((d=this.opts)!=null&&d.animate)&&this.setAnimation(this.opts.animate,!0),this}batchUpdate(e=!0){return this.engine.batchUpdate(e),e||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(e=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!e||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;const t=this.el.querySelector("."+this.opts.itemClass);if(t){const s=u.toNumber(t.getAttribute("gs-h"))||1;return Math.round(t.offsetHeight/s)}const i=parseInt(this.el.getAttribute("gs-current-row"));return i?Math.round(this.el.getBoundingClientRect().height/i):this.opts.cellHeight}cellHeight(e,t=!0){if(t&&e!==void 0&&this._isAutoCellHeight!==(e==="auto")&&(this._isAutoCellHeight=e==="auto",this._updateResizeEvent()),(e==="initial"||e==="auto")&&(e=void 0),e===void 0){const s=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+s}const i=u.parseHeight(e);return this.opts.cellHeightUnit===i.unit&&this.opts.cellHeight===i.h?this:(this.opts.cellHeightUnit=i.unit,this.opts.cellHeight=i.h,this.resizeToContentCheck(),t&&this._updateStyles(!0),this)}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(e=!1){var t;return e&&((t=this.opts.columnOpts)!=null&&t.breakpointForWindow)?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){var r,a;const e=this.opts.columnOpts;if(!e||!e.columnWidth&&!((r=e.breakpoints)!=null&&r.length))return!1;const t=this.getColumn();let i=t;const s=this._widthOrContainer(!0);if(e.columnWidth)i=Math.min(Math.round(s/e.columnWidth)||1,e.columnMax);else{i=e.columnMax;let n=0;for(;n<e.breakpoints.length&&s<=e.breakpoints[n].w;)i=e.breakpoints[n++].c||t}if(i!==t){const n=(a=e.breakpoints)==null?void 0:a.find(c=>c.c===i);return this.column(i,(n==null?void 0:n.layout)||e.layout),!0}return!1}compact(e="compact",t=!0){return this.engine.compact(e,t),this._triggerChangeEvent(),this}column(e,t="moveScale"){if(!e||e<1||this.opts.column===e)return this;const i=this.getColumn();return this.opts.column=e,this.engine?(this.engine.column=e,this.el.classList.remove("gs-"+i),this.el.classList.add("gs-"+e),this.engine.columnChanged(i,e,t),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):this}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(e=>e.matches("."+this.opts.itemClass)&&!e.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return this._ignoreLayoutsNodeChange}destroy(e=!0){var t,i;if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),e?this.el.parentNode.removeChild(this.el):(this.removeAll(e),this.el.classList.remove(this._styleSheetClass),this.el.removeAttribute("gs-current-row")),this._removeStylesheet(),(t=this.parentGridNode)==null||delete t.subGrid,delete this.parentGridNode,delete this.opts,(i=this._placeholder)==null||delete i.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(e){return this.opts.float!==e&&(this.opts.float=this.engine.float=e,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(e,t=!1){const i=this.el.getBoundingClientRect();let s;t?s={top:i.top+document.documentElement.scrollTop,left:i.left}:s={top:this.el.offsetTop,left:this.el.offsetLeft};const r=e.left-s.left,a=e.top-s.top,n=i.width/this.getColumn(),c=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/n),y:Math.floor(a/c)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow)}isAreaEmpty(e,t,i,s){return this.engine.isAreaEmpty(e,t,i,s)}makeWidget(e,t){const i=b.getElement(e);if(!i)return;i.parentElement||this.el.appendChild(i),this._prepareElement(i,!0,t);const s=i.gridstackNode;this._updateContainerHeight(),s.subGridOpts&&this.makeSubGrid(i,s.subGridOpts,void 0,!1);let r;return this.opts.column===1&&!this._ignoreLayoutsNodeChange&&(r=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),r&&delete this._ignoreLayoutsNodeChange,i}on(e,t){return e.indexOf(" ")!==-1?(e.split(" ").forEach(s=>this.on(s,t)),this):(e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable"?(e==="enable"||e==="disable"?this._gsEventHandler[e]=s=>t(s):this._gsEventHandler[e]=s=>{s.detail&&t(s,s.detail)},this.el.addEventListener(e,this._gsEventHandler[e])):e==="drag"||e==="dragstart"||e==="dragstop"||e==="resizestart"||e==="resize"||e==="resizestop"||e==="dropped"||e==="resizecontent"?this._gsEventHandler[e]=t:console.error("GridStack.on("+e+") event not supported"),this)}off(e){return e.indexOf(" ")!==-1?(e.split(" ").forEach(i=>this.off(i)),this):((e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable")&&this._gsEventHandler[e]&&this.el.removeEventListener(e,this._gsEventHandler[e]),delete this._gsEventHandler[e],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(e=>this.off(e)),this}removeWidget(e,t=!0,i=!0){return e?(b.getElements(e).forEach(s=>{if(s.parentElement&&s.parentElement!==this.el)return;let r=s.gridstackNode;r||(r=this.engine.nodes.find(a=>s===a.el)),r&&(t&&b.addRemoveCB&&b.addRemoveCB(this.el,r,!1,!1),delete s.gridstackNode,this._removeDD(s),this.engine.removeNode(r,t,i),t&&s.parentElement&&s.remove())}),i&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(e=!0,t=!0){return this.engine.nodes.forEach(i=>{e&&b.addRemoveCB&&b.addRemoveCB(this.el,i,!1,!1),delete i.el.gridstackNode,this.opts.staticGrid||this._removeDD(i.el)}),this.engine.removeAll(e,t),t&&this._triggerRemoveEvent(),this}setAnimation(e=this.opts.animate,t){return t?setTimeout(()=>{this.opts&&this.setAnimation(e)}):e?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(e,t=!0,i=!0){return!!this.opts.staticGrid===e?this:(e?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(s=>{this._prepareDragDropByNode(s),s.subGrid&&i&&s.subGrid.setStatic(e,t,i)}),t&&this._setStaticClass(),this)}update(e,t){if(arguments.length>2){console.warn("gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon");const i=arguments;let s=1;return t={x:i[s++],y:i[s++],w:i[s++],h:i[s++]},this.update(e,t)}return b.getElements(e).forEach(i=>{var l;const s=i==null?void 0:i.gridstackNode;if(!s)return;const r=u.cloneDeep(t);this.engine.nodeBoundFix(r),delete r.autoPosition;const a=["x","y","w","h"];let n;if(a.some(h=>r[h]!==void 0&&r[h]!==s[h])&&(n={},a.forEach(h=>{n[h]=r[h]!==void 0?r[h]:s[h],delete r[h]})),!n&&(r.minW||r.minH||r.maxW||r.maxH)&&(n={}),r.content!==void 0){const h=i.querySelector(".grid-stack-item-content");h&&h.textContent!==r.content&&(s.content=r.content,b.renderCB(h,r),(l=s.subGrid)!=null&&l.el&&(h.appendChild(s.subGrid.el),s.subGrid.opts.styleInHead||s.subGrid._updateStyles(!0))),delete r.content}let c=!1,d=!1;for(const h in r)h[0]!=="_"&&s[h]!==r[h]&&(s[h]=r[h],c=!0,d=d||!this.opts.staticGrid&&(h==="noResize"||h==="noMove"||h==="locked"));if(u.sanitizeMinMax(s),n){const h=n.w!==void 0&&n.w!==s.w;this.moveNode(s,n),h&&s.subGrid?s.subGrid.onResize(this.hasAnimationCSS()?s.w:void 0):this.resizeToContentCheck(h,s),delete s._orig}(n||c)&&this._writeAttr(i,s),d&&this._prepareDragDropByNode(s)}),this}moveNode(e,t){const i=e._updating;i||this.engine.cleanNodes().beginUpdate(e),this.engine.moveNode(e,t),this._updateContainerHeight(),i||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(e){var g,p;if(!e||(e.classList.remove("size-to-content-max"),!e.clientHeight))return;const t=e.gridstackNode;if(!t)return;const i=t.grid;if(!i||e.parentElement!==i.el)return;const s=i.getCellHeight(!0);if(!s)return;let r=t.h?t.h*s:e.clientHeight,a;if(t.resizeToContentParent&&(a=e.querySelector(t.resizeToContentParent)),a||(a=e.querySelector(b.resizeToContentParent)),!a)return;const n=e.clientHeight-a.clientHeight,c=t.h?t.h*s-n:a.clientHeight;let d;if(t.subGrid){d=t.subGrid.getRow()*t.subGrid.getCellHeight(!0);const y=t.subGrid.el.getBoundingClientRect(),_=t.subGrid.el.parentElement.getBoundingClientRect();d+=y.top-_.top}else{if((p=(g=t.subGridOpts)==null?void 0:g.children)!=null&&p.length)return;{const y=a.firstElementChild;if(!y){console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${b.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}d=y.getBoundingClientRect().height||c}}if(c===d)return;r+=d-c;let l=Math.ceil(r/s);const h=Number.isInteger(t.sizeToContent)?t.sizeToContent:0;h&&l>h&&(l=h,e.classList.add("size-to-content-max")),t.minH&&l<t.minH?l=t.minH:t.maxH&&l>t.maxH&&(l=t.maxH),l!==t.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(t,{h:l}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){b.resizeToContentCB?b.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,t){return b.getElements(e).forEach(i=>{const s=i.gridstackNode;if(!u.canBeRotated(s))return;const r={w:s.h,h:s.w,minH:s.minW,minW:s.minH,maxH:s.maxW,maxW:s.maxH};if(t){const n=t.left>0?Math.floor(t.left/this.cellWidth()):0,c=t.top>0?Math.floor(t.top/this.opts.cellHeight):0;r.x=s.x+n-(s.h-(c+1)),r.y=s.y+c-n}Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n]});const a=s._orig;this.update(i,r),s._orig=a}),this}margin(e){if(!(typeof e=="string"&&e.split(" ").length>1)){const i=u.parseHeight(e);if(this.opts.marginUnit===i.unit&&this.opts.margin===i.h)return}return this.opts.margin=e,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this._updateStyles(!0),this}getMargin(){return this.opts.margin}willItFit(e){if(arguments.length>1){console.warn("gridstack.ts: `willItFit(x,y,w,h,autoPosition)` is deprecated. Use `willItFit({x, y,...})`. It will be removed soon");const t=arguments;let i=0,s={x:t[i++],y:t[i++],w:t[i++],h:t[i++],autoPosition:t[i++]};return this.willItFit(s)}return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;const e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){var e;if(this.engine.batchMode)return this;if((e=this.engine.addedNodes)!=null&&e.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(i=>{delete i._dirty});const t=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",t)}return this}_triggerRemoveEvent(){var e;if(this.engine.batchMode)return this;if((e=this.engine.removedNodes)!=null&&e.length){const t=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",t)}return this}_triggerEvent(e,t){const i=t?new CustomEvent(e,{bubbles:!1,detail:t}):new Event(e);return this.el.dispatchEvent(i),this}_removeStylesheet(){if(this._styles){const e=this.opts.styleInHead?void 0:this.el.parentNode;u.removeStylesheet(this._styleSheetClass,e),delete this._styles}return this}_updateStyles(e=!1,t){if(e&&this._removeStylesheet(),t===void 0&&(t=this.getRow()),this._updateContainerHeight(),this.opts.cellHeight===0)return this;const i=this.opts.cellHeight,s=this.opts.cellHeightUnit,r=`.${this._styleSheetClass} > .${this.opts.itemClass}`;if(!this._styles){const a=this.opts.styleInHead?void 0:this.el.parentNode;if(this._styles=u.createStylesheet(this._styleSheetClass,a,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,u.addCSSRule(this._styles,r,`height: ${i}${s}`);const n=this.opts.marginTop+this.opts.marginUnit,c=this.opts.marginBottom+this.opts.marginUnit,d=this.opts.marginRight+this.opts.marginUnit,l=this.opts.marginLeft+this.opts.marginUnit,h=`${r} > .grid-stack-item-content`,g=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;u.addCSSRule(this._styles,h,`top: ${n}; right: ${d}; bottom: ${c}; left: ${l};`),u.addCSSRule(this._styles,g,`top: ${n}; right: ${d}; bottom: ${c}; left: ${l};`),u.addCSSRule(this._styles,`${r} > .ui-resizable-n`,`top: ${n};`),u.addCSSRule(this._styles,`${r} > .ui-resizable-s`,`bottom: ${c}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-ne`,`right: ${d}; top: ${n}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-e`,`right: ${d}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-se`,`right: ${d}; bottom: ${c}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-nw`,`left: ${l}; top: ${n}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-w`,`left: ${l}`),u.addCSSRule(this._styles,`${r} > .ui-resizable-sw`,`left: ${l}; bottom: ${c}`)}if(t=t||this._styles._max,t>this._styles._max){const a=n=>i*n+s;for(let n=this._styles._max+1;n<=t;n++)u.addCSSRule(this._styles,`${r}[gs-y="${n}"]`,`top: ${a(n)}`),u.addCSSRule(this._styles,`${r}[gs-h="${n+1}"]`,`height: ${a(n+1)}`);this._styles._max=t}return this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;const e=this.parentGridNode;let t=this.getRow()+this._extraDragRow;const i=this.opts.cellHeight,s=this.opts.cellHeightUnit;if(!i)return this;if(!e){const r=u.parseHeight(getComputedStyle(this.el).minHeight);if(r.h>0&&r.unit===s){const a=Math.floor(r.h/i);t<a&&(t=a)}}return this.el.setAttribute("gs-current-row",String(t)),this.el.style.removeProperty("min-height"),this.el.style.removeProperty("height"),t&&(this.el.style[e?"minHeight":"height"]=t*i+s),e&&!e.grid.engine.batchMode&&u.shouldSizeToContent(e)&&e.grid.resizeToContentCBCheck(e.el),this}_prepareElement(e,t=!1,i){i=i||this._readAttr(e),e.gridstackNode=i,i.el=e,i.grid=this,i=this.engine.addNode(i,t),this._writeAttr(e,i),e.classList.add(q.itemClass,this.opts.itemClass);const s=u.shouldSizeToContent(i);return s?e.classList.add("size-to-content"):e.classList.remove("size-to-content"),s&&this.resizeToContentCheck(!1,i),this._prepareDragDropByNode(i),this}_writePosAttr(e,t){return t.x!==void 0&&t.x!==null&&e.setAttribute("gs-x",String(t.x)),t.y!==void 0&&t.y!==null&&e.setAttribute("gs-y",String(t.y)),t.w>1?e.setAttribute("gs-w",String(t.w)):e.removeAttribute("gs-w"),t.h>1?e.setAttribute("gs-h",String(t.h)):e.removeAttribute("gs-h"),this}_writeAttr(e,t){if(!t)return this;this._writePosAttr(e,t);const i={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(const s in i)t[s]?e.setAttribute(i[s],String(t[s])):e.removeAttribute(i[s]);return this}_readAttr(e,t=!0){const i={};i.x=u.toNumber(e.getAttribute("gs-x")),i.y=u.toNumber(e.getAttribute("gs-y")),i.w=u.toNumber(e.getAttribute("gs-w")),i.h=u.toNumber(e.getAttribute("gs-h")),i.autoPosition=u.toBool(e.getAttribute("gs-auto-position")),i.noResize=u.toBool(e.getAttribute("gs-no-resize")),i.noMove=u.toBool(e.getAttribute("gs-no-move")),i.locked=u.toBool(e.getAttribute("gs-locked")),i.sizeToContent=u.toBool(e.getAttribute("gs-size-to-content")),i.id=e.getAttribute("gs-id"),i.maxW=u.toNumber(e.getAttribute("gs-max-w")),i.minW=u.toNumber(e.getAttribute("gs-min-w")),i.maxH=u.toNumber(e.getAttribute("gs-max-h")),i.minH=u.toNumber(e.getAttribute("gs-min-h")),t&&(i.w===1&&e.removeAttribute("gs-w"),i.h===1&&e.removeAttribute("gs-h"),i.maxW&&e.removeAttribute("gs-max-w"),i.minW&&e.removeAttribute("gs-min-w"),i.maxH&&e.removeAttribute("gs-max-h"),i.minH&&e.removeAttribute("gs-min-h"));for(const s in i){if(!i.hasOwnProperty(s))return;!i[s]&&i[s]!==0&&delete i[s]}return i}_setStaticClass(){const e=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...e),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...e),this.el.removeAttribute("gs-static")),this}onResize(e=(t=>(t=this.el)==null?void 0:t.clientWidth)()){if(!e||this.prevWidth===e)return;this.prevWidth=e,this.batchUpdate();let i=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),i=!0):i=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(s=>{s.subGrid&&s.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(i),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(e=!1,t=void 0){if(this.engine){if(e&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,t),this.animationDelay);if(t)u.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el);else if(this.engine.nodes.some(i=>u.shouldSizeToContent(i))){const i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{u.shouldSizeToContent(s)&&this.resizeToContentCBCheck(s.el)}),this.batchUpdate(!1)}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,t?[t]:this.engine.nodes)}}_updateResizeEvent(e=!1){const t=!this.parentGridNode&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(i=>i.sizeToContent));return!e&&t&&!this.resizeObserver?(this._sizeThrottle=u.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(e||!t)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(e=".grid-stack-item"){return u.getElement(e)}static getElements(e=".grid-stack-item"){return u.getElements(e)}static getGridElement(e){return b.getElement(e)}static getGridElements(e){return u.getElements(e)}_initMargin(){let e,t=0,i=[];return typeof this.opts.margin=="string"&&(i=this.opts.margin.split(" ")),i.length===2?(this.opts.marginTop=this.opts.marginBottom=i[0],this.opts.marginLeft=this.opts.marginRight=i[1]):i.length===4?(this.opts.marginTop=i[0],this.opts.marginRight=i[1],this.opts.marginBottom=i[2],this.opts.marginLeft=i[3]):(e=u.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,t=this.opts.margin=e.h),this.opts.marginTop===void 0?this.opts.marginTop=t:(e=u.parseHeight(this.opts.marginTop),this.opts.marginTop=e.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=t:(e=u.parseHeight(this.opts.marginBottom),this.opts.marginBottom=e.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=t:(e=u.parseHeight(this.opts.marginRight),this.opts.marginRight=e.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=t:(e=u.parseHeight(this.opts.marginLeft),this.opts.marginLeft=e.h,delete this.opts.margin),this.opts.marginUnit=e.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop),this}static getDD(){return I}static setupDragIn(e,t,i,s=document){(t==null?void 0:t.pause)!==void 0&&(C.pauseDrag=t.pause),t={appendTo:"body",helper:"clone",...t||{}},(typeof e=="string"?u.getElements(e,s):e).forEach((a,n)=>{I.isDraggable(a)||I.dragIn(a,t),i!=null&&i[n]&&(a.gridstackNode=i[n])})}movable(e,t){return this.opts.staticGrid?this:(b.getElements(e).forEach(i=>{const s=i.gridstackNode;s&&(t?delete s.noMove:s.noMove=!0,this._prepareDragDropByNode(s))}),this)}resizable(e,t){return this.opts.staticGrid?this:(b.getElements(e).forEach(i=>{const s=i.gridstackNode;s&&(t?delete s.noResize:s.noResize=!0,this._prepareDragDropByNode(s))}),this)}disable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!1,e),this.enableResize(!1,e),this._triggerEvent("disable"),this}enable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!0,e),this.enableResize(!0,e),this._triggerEvent("enable"),this}enableMove(e,t=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&t&&i.subGrid.enableMove(e,t)}),this)}enableResize(e,t=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(i=>{this._prepareDragDropByNode(i),i.subGrid&&t&&i.subGrid.enableResize(e,t)}),this)}cancelDrag(){var t;const e=(t=this._placeholder)==null?void 0:t.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&b._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return I.draggable(e,"destroy").resizable(e,"destroy"),e.gridstackNode&&delete e.gridstackNode._initDD,delete e.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return I.droppable(this.el,"destroy"),this;let e,t;const i=(s,r,a)=>{var g;a=a||r;const n=a.gridstackNode;if(!n)return;if(!((g=n.grid)!=null&&g.el)){a.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;const p=a.getBoundingClientRect();a.style.left=p.x+(this.dragTransform.xScale-1)*(s.clientX-p.x)/this.dragTransform.xScale+"px",a.style.top=p.y+(this.dragTransform.yScale-1)*(s.clientY-p.y)/this.dragTransform.yScale+"px",a.style.transformOrigin="0px 0px"}let{top:c,left:d}=a.getBoundingClientRect();const l=this.el.getBoundingClientRect();d-=l.left,c-=l.top;const h={position:{top:c*this.dragTransform.xScale,left:d*this.dragTransform.yScale}};if(n._temporaryRemoved){if(n.x=Math.max(0,Math.round(d/t)),n.y=Math.max(0,Math.round(c/e)),delete n.autoPosition,this.engine.nodeBoundFix(n),!this.engine.willItFit(n)){if(n.autoPosition=!0,!this.engine.willItFit(n)){I.off(r,"drag");return}n._willFitPos&&(u.copyPos(n,n._willFitPos),delete n._willFitPos)}this._onStartMoving(a,s,h,n,t,e)}else this._dragOrResize(a,s,h,n,t,e)};return I.droppable(this.el,{accept:s=>{const r=s.gridstackNode||this._readAttr(s,!1);if((r==null?void 0:r.grid)===this)return!0;if(!this.opts.acceptWidgets)return!1;let a=!0;if(typeof this.opts.acceptWidgets=="function")a=this.opts.acceptWidgets(s);else{const n=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;a=s.matches(n)}if(a&&r&&this.opts.maxRow){const n={w:r.w,h:r.h,minW:r.minW,minH:r.minH};a=this.engine.willItFit(n)}return a}}).on(this.el,"dropover",(s,r,a)=>{let n=(a==null?void 0:a.gridstackNode)||r.gridstackNode;if((n==null?void 0:n.grid)===this&&!n._temporaryRemoved)return!1;if(n!=null&&n.grid&&n.grid!==this&&!n._temporaryRemoved&&n.grid._leave(r,a),a=a||r,t=this.cellWidth(),e=this.getCellHeight(!0),!n){const l=a.getAttribute("data-gs-widget")||a.getAttribute("gridstacknode");if(l){try{n=JSON.parse(l)}catch{console.error("Gridstack dropover: Bad JSON format: ",l)}a.removeAttribute("data-gs-widget"),a.removeAttribute("gridstacknode")}n||(n=this._readAttr(a))}n.grid||(n.el||(n={...n}),n._isExternal=!0,a.gridstackNode=n);const c=n.w||Math.round(a.offsetWidth/t)||1,d=n.h||Math.round(a.offsetHeight/e)||1;return n.grid&&n.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=n),r.gridstackNode=n={...n,w:c,h:d,grid:this},delete n.x,delete n.y,this.engine.cleanupNode(n).nodeBoundFix(n),n._initDD=n._isExternal=n._temporaryRemoved=!0):(n.w=c,n.h=d,n._temporaryRemoved=!0),b._itemRemoving(n.el,!1),I.on(r,"drag",i),i(s,r,a),!1}).on(this.el,"dropout",(s,r,a)=>{const n=(a==null?void 0:a.gridstackNode)||r.gridstackNode;return n&&(!n.grid||n.grid===this)&&(this._leave(r,a),this._isTemp&&this.removeAsSubGrid(n)),!1}).on(this.el,"drop",(s,r,a)=>{var p,y,_;const n=(a==null?void 0:a.gridstackNode)||r.gridstackNode;if((n==null?void 0:n.grid)===this&&!n._isExternal)return!1;const c=!!this.placeholder.parentElement,d=r!==a;this.placeholder.remove(),delete this.placeholder.gridstackNode;const l=c&&this.opts.animate;l&&this.setAnimation(!1);const h=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,c&&(h!=null&&h.grid)&&h.grid!==this){const m=h.grid;m.engine.removeNodeFromLayoutCache(h),m.engine.removedNodes.push(h),m._triggerRemoveEvent()._triggerChangeEvent(),m.parentGridNode&&!m.engine.nodes.length&&m.opts.subGridDynamic&&m.removeAsSubGrid()}if(!n||(c&&(this.engine.cleanupNode(n),n.grid=this),(p=n.grid)==null||delete p._isTemp,I.off(r,"drag"),a!==r?(a.remove(),r=a):r.remove(),this._removeDD(r),!c))return!1;const g=(_=(y=n.subGrid)==null?void 0:y.el)==null?void 0:_.gridstack;return u.copyPos(n,this._readAttr(this.placeholder)),u.removePositioningStyles(r),d&&(n.content||n.subGridOpts||b.addRemoveCB)?(delete n.el,r=this.addWidget(n)):(this._prepareElement(r,!0,n),this.el.appendChild(r),this.resizeToContentCheck(!1,n),g&&(g.parentGridNode=n,g.opts.styleInHead||g._updateStyles(!0)),this._updateContainerHeight()),this.engine.addedNodes.push(n),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...s,type:"dropped"},h&&h.grid?h:void 0,n),l&&this.setAnimation(this.opts.animate,!0),!1}),this}static _itemRemoving(e,t){if(!e)return;const i=e?e.gridstackNode:void 0;!(i!=null&&i.grid)||e.classList.contains(i.grid.opts.removableOptions.decline)||(t?i._isAboutToRemove=!0:delete i._isAboutToRemove,t?e.classList.add("grid-stack-item-removing"):e.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;const e=document.querySelector(this.opts.removable);return e?(!this.opts.staticGrid&&!I.isDroppable(e)&&I.droppable(e,this.opts.removableOptions).on(e,"dropover",(t,i)=>b._itemRemoving(i,!0)).on(e,"dropout",(t,i)=>b._itemRemoving(i,!1)),this):this}_prepareDragDropByNode(e){const t=e.el,i=e.noMove||this.opts.disableDrag,s=e.noResize||this.opts.disableResize;if(this.opts.staticGrid||i&&s)return e._initDD&&(this._removeDD(t),delete e._initDD),t.classList.add("ui-draggable-disabled","ui-resizable-disabled"),this;if(!e._initDD){let r,a;const n=(l,h)=>{this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,l.target),r=this.cellWidth(),a=this.getCellHeight(!0),this._onStartMoving(t,l,h,e,r,a)},c=(l,h)=>{this._dragOrResize(t,l,h,e,r,a)},d=l=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete e._moving,delete e._event,delete e._lastTried;const h=e.w!==e._orig.w,g=l.target;if(!(!g.gridstackNode||g.gridstackNode.grid!==this)){if(e.el=g,e._isAboutToRemove){const p=t.gridstackNode.grid;p._gsEventHandler[l.type]&&p._gsEventHandler[l.type](l,g),p.engine.nodes.push(e),p.removeWidget(t,!0,!0)}else u.removePositioningStyles(g),e._temporaryRemoved?(u.copyPos(e,e._orig),this._writePosAttr(g,e),this.engine.addNode(e)):this._writePosAttr(g,e),this._gsEventHandler[l.type]&&this._gsEventHandler[l.type](l,g);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),l.type==="resizestop"&&(Number.isInteger(e.sizeToContent)&&(e.sizeToContent=e.h),this.resizeToContentCheck(h,e))}};I.draggable(t,{start:n,stop:d,drag:c}).resizable(t,{start:n,stop:d,resize:c}),e._initDD=!0}return I.draggable(t,i?"disable":"enable").resizable(t,s?"disable":"enable"),this}_onStartMoving(e,t,i,s,r,a){var n;if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=s,(n=s.grid)!=null&&n.el)this.dragTransform=u.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const c=this.placeholder.closest(".grid-stack");this.dragTransform=u.getValuesFromTransformedElement(c)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(s.el=this.placeholder,s._lastUiPosition=i.position,s._prevYPix=i.position.top,s._moving=t.type==="dragstart",delete s._lastTried,t.type==="dropover"&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(r,a,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),t.type==="resizestart"){const c=this.getColumn()-s.x,d=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-s.y;I.resizable(e,"option","minWidth",r*Math.min(s.minW||1,c)).resizable(e,"option","minHeight",a*Math.min(s.minH||1,d)).resizable(e,"option","maxWidth",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,c)).resizable(e,"option","maxWidthMoveLeft",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,s.x+s.w)).resizable(e,"option","maxHeight",a*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,d)).resizable(e,"option","maxHeightMoveUp",a*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,s.y+s.h))}}_dragOrResize(e,t,i,s,r,a){const n={...s._orig};let c,d=this.opts.marginLeft,l=this.opts.marginRight,h=this.opts.marginTop,g=this.opts.marginBottom;const p=Math.round(a*.1),y=Math.round(r*.1);if(d=Math.min(d,y),l=Math.min(l,y),h=Math.min(h,p),g=Math.min(g,p),t.type==="drag"){if(s._temporaryRemoved)return;const m=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&u.updateScrollPosition(e,i.position,m);const k=i.position.left+(i.position.left>s._lastUiPosition.left?-l:d),N=i.position.top+(i.position.top>s._lastUiPosition.top?-g:h);n.x=Math.round(k/r),n.y=Math.round(N/a);const x=this._extraDragRow;if(this.engine.collide(s,n)){const L=this.getRow();let S=Math.max(0,n.y+s.h-L);this.opts.maxRow&&L+S>this.opts.maxRow&&(S=Math.max(0,this.opts.maxRow-L)),this._extraDragRow=S}else this._extraDragRow=0;if(this._extraDragRow!==x&&this._updateContainerHeight(),s.x===n.x&&s.y===n.y)return}else if(t.type==="resize"){if(n.x<0||(u.updateScrollResize(t,e,a),n.w=Math.round((i.size.width-d)/r),n.h=Math.round((i.size.height-h)/a),s.w===n.w&&s.h===n.h)||s._lastTried&&s._lastTried.w===n.w&&s._lastTried.h===n.h)return;const m=i.position.left+d,k=i.position.top+h;n.x=Math.round(m/r),n.y=Math.round(k/a),c=!0}s._event=t,s._lastTried=n;const _={x:i.position.left+d,y:i.position.top+h,w:(i.size?i.size.width:s.w*r)-d-l,h:(i.size?i.size.height:s.h*a)-h-g};if(this.engine.moveNodeCheck(s,{...n,cellWidth:r,cellHeight:a,rect:_,resizing:c})){s._lastUiPosition=i.position,this.engine.cacheRects(r,a,h,l,g,d),delete s._skipDown,c&&s.subGrid&&s.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const m=t.target;this._writePosAttr(m,s),this._gsEventHandler[t.type]&&this._gsEventHandler[t.type](t,m)}}_leave(e,t){t=t||e;const i=t.gridstackNode;i&&(t.style.transform=t.style.transformOrigin=null,I.off(e,"drag"),!i._temporaryRemoved&&(i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&t?t:e,i._isExternal&&this.engine.cleanupNode(i),this.opts.removable===!0&&b._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):i._isExternal&&this.engine.restoreInitial()))}commit(){return Gt(this,this.batchUpdate(!1),"commit","batchUpdate","5.2"),this}}b.renderCB=(f,e)=>{f&&(e!=null&&e.content)&&(f.textContent=e.content)},b.resizeToContentParent=".grid-stack-item-content",b.Utils=u,b.Engine=V,b.GDRev="11.3.0";const Kt=["data-id","data-testid","gs-h","gs-w","gs-x","gs-y"],Yt={class:"grid-stack-item-content"},jt=ee(o.defineComponent({__name:"DraggableGridLayout",props:{tiles:{},gridSize:{},tileHeight:{default:200}},emits:["update-tiles"],setup(f,{expose:e,emit:t}){const i=f,s=t,r=o.ref(null),a=o.ref(new Map(i.tiles.map(p=>[`${p.id}`,p])));let n=null;const c=p=>`[data-id="${p}"]`,d=p=>p.map(y=>{var m;const _=a.value.get(`${(m=y.el)==null?void 0:m.getAttribute("data-id")}`);if(_)return{..._,layout:{position:{col:Number(y.x),row:Number(y.y)},size:{cols:Number(y.w),rows:Number(y.h)}}}}).filter(y=>y!==void 0),l=(p,y)=>{n&&(d(y).forEach(m=>{a.value.set(`${m.id}`,m)}),s("update-tiles",Array.from(a.value.values())))},h=(p,y)=>{y.forEach(_=>{var m;a.value.delete(`${(m=_.el)==null?void 0:m.getAttribute("data-id")}`)}),s("update-tiles",Array.from(a.value.values()))};o.onMounted(()=>{r.value&&(n=b.init({column:i.gridSize.cols,cellHeight:i.tileHeight,resizable:{handles:"se, sw"},handle:".tile-header"},r.value),n.on("change",l),n.on("added",l),n.on("removed",h))}),o.onUnmounted(()=>{n&&n.destroy(!1)});const g=p=>{if(n&&r.value){const y=r.value.querySelector(c(p));y&&n.removeWidget(y)}};return o.watch(()=>i.tiles.length,async(p,y)=>{if(p>y&&n){const _=i.tiles.slice(y);for(const m of _)a.value.set(`${m.id}`,m),await o.nextTick(),n.makeWidget(c(m.id),{autoPosition:!0,w:m.layout.size.cols,h:m.layout.size.rows})}}),o.watchEffect(()=>{i.tiles.forEach(p=>{a.value.set(`${p.id}`,p)})}),e({removeWidget:g}),(p,y)=>(o.openBlock(),o.createElementBlock("div",{ref_key:"gridContainer",ref:r,class:"grid-stack"},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(i.tiles,_=>(o.openBlock(),o.createElementBlock("div",{key:_.id,class:"grid-stack-item","data-id":`${_.id}`,"data-testid":`grid-stack-item-${_.id}`,"gs-h":_.layout.size.rows,"gs-lazy-load":!0,"gs-w":_.layout.size.cols,"gs-x":_.layout.position.col,"gs-y":_.layout.position.row},[o.createElementVNode("div",Yt,[o.renderSlot(p.$slots,"tile",{tile:_},void 0,!0)])],8,Kt))),128))],512))}}),[["__scopeId","data-v-f4f87f74"]]),Xt={class:"kong-ui-public-dashboard-renderer"},Qt={key:0,class:"tile-container slottable-tile"},Zt=ee(o.defineComponent({__name:"DashboardRenderer",props:o.mergeModels({context:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:o.mergeModels(["edit-tile","zoom-time-range"],["update:modelValue"]),setup(f,{expose:e,emit:t}){const i=f,s=t,r=o.useModel(f,"modelValue"),{i18n:a}=ie.useI18n(),n=o.ref(0),c=o.ref(null),d=o.inject(Q);d||(console.warn("Analytics dashboards require a query bridge supplied via provide / inject."),console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"),console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/dashboard-renderer/README.md#requirements")),ie.useRequestQueue();const l=Be.useAnalyticsConfigStore(),h=o.computed(()=>i.context.timeSpec?i.context.timeSpec:{type:"relative",time_range:l.defaultQueryTimeForOrg}),g=o.computed(()=>!!i.context.timeSpec||!l.loading),p=(R,A)=>{const D=R.layout.position.row-A.layout.position.row;return D!==0?D:R.layout.position.col-A.layout.position.col},y=o.computed(()=>r.value.tiles.map(R=>{var D;let A=R.definition;if("description"in A.chart){const P=(D=A.chart.description)==null?void 0:D.replace(Ge,()=>{const v=`renderer.trendRange.${h.value.type==="absolute"?"custom":h.value.time_range}`;return a.te(v)?a.t(v):""});A={...A,chart:{...A.chart,description:P}}}return i.context.editable&&!R.id&&console.warn("No id provided for tile. One will be generated automatically,","however tracking changes to this tile may not work as expected.",R),{layout:R.layout,meta:A,id:R.id??crypto.randomUUID()}})),_=o.computed(()=>{let{tz:R,refreshInterval:A,editable:D}=i.context;return R||(R=new Intl.DateTimeFormat().resolvedOptions().timeZone),A===void 0&&(A=Ue),D===void 0&&(D=!1),{...i.context,tz:R,timeSpec:h.value,refreshInterval:A,editable:D}}),m=R=>{s("edit-tile",R)},k=R=>R.type==="slottable",N=R=>{const A=k(R.meta.chart)?{...R.meta.chart}:{...R.meta.chart,chartTitle:R.meta.chart.chartTitle?`Copy of ${R.meta.chart.chartTitle}`:""},D={id:crypto.randomUUID(),definition:{...R.meta,chart:A},layout:{position:{col:0,row:0},size:R.layout.size}};r.value.tiles.push(D)},x=R=>{c.value&&c.value.removeWidget(R.id)},L=()=>{n.value++},S=R=>{const A=R.map(D=>({id:D.id,layout:D.layout,definition:D.meta}));r.value.gridSize.rows=Math.max(1,...A.map(D=>D.layout.position.row+D.layout.size.rows)),r.value.tiles=A.sort(p)};return e({refresh:L}),(R,A)=>{const D=o.resolveComponent("KAlert");return o.openBlock(),o.createElementBlock("div",Xt,[o.unref(d)?(o.openBlock(),o.createBlock(o.resolveDynamicComponent(R.context.editable?jt:it),{key:1,ref_key:"gridLayoutRef",ref:c,"grid-size":r.value.gridSize,"tile-height":r.value.tileHeight,tiles:y.value,onUpdateTiles:S},{tile:o.withCtx(({tile:P})=>[P.meta.chart.type==="slottable"?(o.openBlock(),o.createElementBlock("div",Qt,[o.renderSlot(R.$slots,P.meta.chart.id,{},void 0,!0)])):(o.openBlock(),o.createBlock($t,{key:1,class:"tile-container",context:_.value,definition:P.meta,height:P.layout.size.rows*(r.value.tileHeight||o.unref(pe))+parseInt(o.unref(et),10),"query-ready":g.value,"refresh-counter":n.value,"tile-id":P.id,onDuplicateTile:te=>N(P),onEditTile:te=>m(P),onRemoveTile:te=>x(P),onZoomTimeRange:A[0]||(A[0]=te=>s("zoom-time-range",te))},null,8,["context","definition","height","query-ready","refresh-counter","tile-id","onDuplicateTile","onEditTile","onRemoveTile"]))]),_:3},40,["grid-size","tile-height","tiles"])):(o.openBlock(),o.createBlock(D,{key:0,appearance:"danger"},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(o.unref(a).t("renderer.noQueryBridge")),1)]),_:1}))])}}}),[["__scopeId","data-v-d31fa719"]]);E.CP_ID_TOKEN=Fe,E.DEFAULT_TILE_HEIGHT=pe,E.DEFAULT_TILE_REFRESH_INTERVAL_MS=Ue,E.DashboardRenderer=Zt,E.ENTITY_ID_TOKEN=De,E.GridLayout=it,E.INJECT_QUERY_PROVIDER=Q,E.TIMEFRAME_TOKEN=Ge,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});