@kong-ui-public/dashboard-renderer 0.35.0 → 0.35.1

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(x,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-metric-provider"),require("@kong-ui-public/entities-shared"),require("@kong/icons"),require("@kong-ui-public/analytics-config-store")):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-metric-provider","@kong-ui-public/entities-shared","@kong/icons","@kong-ui-public/analytics-config-store"],a):(x=typeof globalThis<"u"?globalThis:x||self,a(x["kong-ui-public-dashboard-renderer"]={},x.Vue,x["kong-ui-public-analytics-utilities"],x["kong-ui-public-analytics-chart"],x.swrv,x.axios,x["kong-ui-public-i18n"],x["kong-ui-public-analytics-metric-provider"],x["kong-ui-public-entities-shared"],x.KongIcons,x["kong-ui-public-analytics-config-store"]))})(this,function(x,a,O,$,ye,Je,ee,te,_e,ie,be){"use strict";var se=(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))(se||{});const Ee=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 we(f=a.ref({}),e,t,i=Ee){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:se}}const ve={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"},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 Ce(){const f=ee.createI18n("en-us",ve);return{i18n:f,i18nT:ee.i18nTComponent(f)}}const F=170,B="analytics-query-provider",X="{entity-id}",re="{cp-id}",ne="{timeframe}",oe=30*1e3;function xe(){const f=a.inject(B);return{evaluateFeatureFlag:(t,i)=>f?f.evaluateFeatureFlagFn(t,i):i}}const M={useI18n:Ce,useEvaluateFeatureFlag:xe},Q=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}=M.useI18n(),r=a.inject(B),o=()=>t.queryReady&&r?JSON.stringify([t.query,t.context,t.refreshCounter]):null,n=new AbortController;a.onUnmounted(()=>{n.abort()});const h=(v,C,k)=>{const D=[];return C&&D.push(...C),D.push(...O.stripUnknownFilters(v,k)),D},{data:d,error:c,isValidating:u}=ye(o,async()=>{var v,C,k,D;try{let{datasource:R,..._}=t.query;R||(R="basic");const L=h(R,t.query.filters,t.context.filters);let z=t.query.time_range;z?z.tz||(z={...z,tz:t.context.tz}):z={...t.context.timeSpec,tz:t.context.tz};const j={datasource:R,query:{..._,time_range:z,filters:L}};return r==null?void 0:r.queryFn(j,n)}catch(R){E.value=((C=(v=R==null?void 0:R.response)==null?void 0:v.data)==null?void 0:C.message)==="Range not allowed for this tier"?s.t("queryDataProvider.timeRangeExceeded"):((D=(k=R==null?void 0:R.response)==null?void 0:k.data)==null?void 0:D.message)||(R==null?void 0:R.message)}finally{i("queryComplete")}},{refreshInterval:t.context.refreshInterval,revalidateOnFocus:!1}),{state:g,swrvState:b}=we(d,c,u),E=a.ref(null),w=a.computed(()=>g.value===b.ERROR||!!E.value),m=a.computed(()=>!t.queryReady||g.value===b.PENDING);return a.watch(d,v=>{v&&i("chart-data",v)}),(v,C)=>{const k=a.resolveComponent("KSkeleton"),D=a.resolveComponent("KEmptyState");return m.value||!a.unref(d)&&!w.value?(a.openBlock(),a.createBlock(k,{key:0,class:"chart-skeleton",type:"table"})):w.value?(a.openBlock(),a.createBlock(D,{key:1,"action-button-visible":!1,"data-testid":"chart-empty-state","icon-variant":"error"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(E.value),1)]),_:1})):a.unref(d)?a.renderSlot(v.$slots,"default",{key:2,data:a.unref(d)}):a.createCommentVNode("",!0)}}}),Re={class:"analytics-chart"},ke=a.defineComponent({__name:"SimpleChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){a.useCssVars(t=>({c40c0e86:`${t.height}px`}));const e=f;return(t,i)=>(a.openBlock(),a.createBlock(Q,{context:t.context,query:t.query,"query-ready":t.queryReady,"refresh-counter":t.refreshCounter},{default:a.withCtx(({data:s})=>[a.createElementVNode("div",Re,[a.createVNode(a.unref($.SimpleChart),{"chart-data":s,"chart-options":e.chartOptions,"synthetics-data-key":t.chartOptions.syntheticsDataKey},null,8,["chart-data","chart-options","synthetics-data-key"])])]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),I=(f,e)=>{const t=f.__vccOpts||f;for(const[i,s]of e)t[i]=s;return t},De=I(ke,[["__scopeId","data-v-694cf637"]]),Se={class:"analytics-chart"},ae=I(a.defineComponent({__name:"BaseAnalyticsChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{},extraProps:{}},emits:["edit-tile","chart-data"],setup(f,{emit:e}){const t=f,i=e,s=a.inject(B),{i18n:r}=M.useI18n(),{evaluateFeatureFlag:o}=M.useEvaluateFeatureFlag(),n=o("ma-3043-analytics-chart-kebab-menu",!1),h=a.computed(()=>({type:t.chartOptions.type,stacked:t.chartOptions.stacked??!1,chartDatasetColors:t.chartOptions.chartDatasetColors,threshold:t.chartOptions.threshold})),d=a.computed(()=>{if(s&&s.exploreBaseUrl){const g={filters:[...t.context.filters,...t.query.filters??[]],metrics:t.query.metrics??[],dimensions:t.query.dimensions??[],time_range:t.query.time_range||t.context.timeSpec},b=["advanced","ai"].includes(t.query.datasource)?t.query.datasource:"advanced";return`${s.exploreBaseUrl()}?q=${JSON.stringify(g)}&d=${b}&c=${t.chartOptions.type}`}return""}),c=()=>{i("edit-tile")},u=g=>{i("chart-data",g)};return(g,b)=>{const E=a.resolveComponent("KDropdownItem");return a.openBlock(),a.createBlock(Q,{context:g.context,query:g.query,"query-ready":g.queryReady,"refresh-counter":g.refreshCounter,onChartData:u},{default:a.withCtx(({data:w})=>[a.createElementVNode("div",Se,[a.createVNode(a.unref($.AnalyticsChart),a.mergeProps({"allow-csv-export":g.chartOptions.allowCsvExport,"chart-data":w,"chart-options":h.value,"chart-title":!a.unref(n)&&g.chartOptions.chartTitle||"","go-to-explore":d.value,"legend-position":"bottom","show-menu":g.context.editable,"synthetics-data-key":g.chartOptions.syntheticsDataKey,"tooltip-title":""},g.extraProps),a.createSlots({_:2},[g.context.editable?{name:"menu-items",fn:a.withCtx(()=>[a.createVNode(E,{onClick:c},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(a.unref(r).t("renderer.edit")),1)]),_:1})]),key:"0"}:void 0]),1040,["allow-csv-export","chart-data","chart-options","chart-title","go-to-explore","show-menu","synthetics-data-key"])])]),_:1},8,["context","query","query-ready","refresh-counter"])}}}),[["__scopeId","data-v-1bc587d3"]]),le=a.defineComponent({__name:"BarChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(a.openBlock(),a.createBlock(ae,{"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"]))}}),he=a.defineComponent({__name:"TimeseriesChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(a.openBlock(),a.createBlock(ae,{"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"]))}}),ze={class:"metric-card-tile-wrapper"},Ne=I(a.defineComponent({__name:"GoldenSignalsRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){a.useCssVars(o=>({"926e3b48":a.unref(i)?"90%":"100%","7be2893e":a.unref(i)?"auto":"100%","0d55c162":a.unref(i)?"100%":"none"}));const e=f,{evaluateFeatureFlag:t}=M.useEvaluateFeatureFlag(),i=t("ma-3043-analytics-chart-kebab-menu",!1),s=a.computed(()=>{const o=e.context.timeSpec;if(o.type==="absolute")return new O.Timeframe({key:"custom",timeframeText:"custom",display:"custom",startCustom:o.start,endCustom:o.end,timeframeLength:()=>o.end.getTime()-o.start.getTime(),defaultResponseGranularity:"daily",dataGranularity:"daily",isRelative:!1,allowedTiers:["free","plus","enterprise"]});const n=O.TimePeriods.get(o.time_range);if(!n)throw new Error("Unknown time range");return n}),r=a.computed(()=>{var n,h;const o=(n=e.query)==null?void 0:n.datasource;if(o&&o!=="advanced"&&o!=="basic")throw new Error(`Invalid datasource value: ${o}`);return{datasource:(h=e.query)==null?void 0:h.datasource,overrideTimeframe:s.value,tz:e.context.tz,additionalFilter:e.context.filters,longCardTitles:e.chartOptions.longCardTitles,...!i&&{containerTitle:e.chartOptions.chartTitle},...!i&&{description:e.chartOptions.description},percentileLatency:e.chartOptions.percentileLatency,refreshInterval:e.context.refreshInterval,queryReady:e.queryReady,refreshCounter:e.refreshCounter}});return(o,n)=>(a.openBlock(),a.createElementBlock("div",ze,[a.createVNode(a.unref(te.MetricsProvider),a.normalizeProps(a.guardReactiveProps(r.value)),{default:a.withCtx(()=>[a.createVNode(a.unref(te.MetricsConsumer))]),_:1},16)]))}}),[["__scopeId","data-v-0f571079"]]),de="#6c7489",ce="20px",ue="20px",Te=a.defineComponent({__name:"TopNTableRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){const e=f,{evaluateFeatureFlag:t}=M.useEvaluateFeatureFlag(),i=t("ma-3043-analytics-chart-kebab-menu",!1),s=r=>{var o;if((o=e.chartOptions)!=null&&o.entityLink)if(r.id.includes(":")){const[n,h]=r.id.split(":");return e.chartOptions.entityLink.replace(re,n).replace(X,h)}else return e.chartOptions.entityLink.replace(X,r.id);return""};return(r,o)=>(a.openBlock(),a.createBlock(Q,{context:r.context,query:r.query,"query-ready":r.queryReady,"refresh-counter":r.refreshCounter},{default:a.withCtx(({data:n})=>[a.createVNode(a.unref($.TopNTable),{data:n,description:!a.unref(i)&&r.chartOptions.description||"","synthetics-data-key":r.chartOptions.syntheticsDataKey,title:!a.unref(i)&&r.chartOptions.chartTitle||""},a.createSlots({_:2},[e.chartOptions.entityLink?{name:"name",fn:a.withCtx(({record:h})=>[a.createVNode(a.unref(_e.EntityLink),{"entity-link-data":{id:h.id,label:h.name,deleted:h.deleted},"external-link":s(h)},null,8,["entity-link-data","external-link"])]),key:"0"}:void 0]),1032,["data","description","synthetics-data-key","title"])]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),He=["data-testid"],Ae={key:0,class:"tile-header"},Le=["data-testid"],Oe=["data-testid"],Me=["data-testid"],Be=["data-testid"],Ie=["data-testid"],Pe=I(a.defineComponent({__name:"DashboardTile",props:{definition:{},context:{},height:{default:F},queryReady:{type:Boolean},refreshCounter:{},tileId:{}},emits:["edit-tile"],setup(f,{emit:e}){a.useCssVars(_=>({bb9f837a:`${_.height}px`}));const t=parseInt(ue,10),i=f,s=e,r=a.inject(B),{evaluateFeatureFlag:o}=M.useEvaluateFeatureFlag(),{i18n:n}=M.useI18n(),h=o("ma-3043-analytics-chart-kebab-menu",!1),d=a.ref(),c=a.ref(!1),u=a.computed(()=>{if(r&&r.exploreBaseUrl){const _={filters:[...i.context.filters,...i.definition.query.filters??[]],metrics:i.definition.query.metrics??[],dimensions:i.definition.query.dimensions??[],time_range:i.definition.query.time_range||i.context.timeSpec,granularity:i.definition.query.granularity||v.value},L=["advanced","ai"].includes(i.definition.query.datasource)?i.definition.query.datasource:"advanced";return`${r.exploreBaseUrl()}?q=${JSON.stringify(_)}&d=${L}&c=${i.definition.chart.type}`}return""}),g=a.computed(()=>n.t("csvExport.defaultFilename")),b=a.computed(()=>h&&!["golden_signals","top_n","gauge"].includes(i.definition.chart.type)),E={timeseries_line:he,timeseries_bar:he,horizontal_bar:le,vertical_bar:le,gauge:De,golden_signals:Ne,top_n:Te,slottable:void 0},w=a.computed(()=>{const _=E[i.definition.chart.type];return _&&{component:_,rendererProps:{query:i.definition.query,context:i.context,queryReady:i.queryReady,chartOptions:i.definition.chart,height:i.height-t*2,refreshCounter:i.refreshCounter}}}),m=a.computed(()=>{var L;const _=(L=i.definition.query)==null?void 0:L.time_range;if((_==null?void 0:_.type)==="relative"){const z=O.TimePeriods.get(O.TIMEFRAME_LOOKUP[_.time_range]);return z?z.display:(console.warn("Did not recognize the given relative time range:",_.time_range),_.time_range)}else if((_==null?void 0:_.type)==="absolute"){const z=_.tz||"Etc/UTC";return`${O.formatTime(_.start,{short:!0,tz:z})} - ${O.formatTime(_.end,{short:!0,tz:z})}`}return null}),v=a.computed(()=>d.value?O.msToGranularity(d.value.meta.granularity_ms):void 0),C=()=>{s("edit-tile",i.definition)},k=_=>{d.value=_},D=_=>{c.value=_},R=()=>{D(!0)};return(_,L)=>{const z=a.resolveComponent("KBadge"),j=a.resolveComponent("KDropdownItem"),Qe=a.resolveComponent("KDropdown");return a.openBlock(),a.createElementBlock("div",{class:"tile-boundary","data-testid":`tile-${_.tileId}`},[a.unref(h)&&_.definition.chart.type!=="slottable"?(a.openBlock(),a.createElementBlock("div",Ae,[a.createElementVNode("div",{class:"title","data-testid":`tile-title-${_.tileId}`},a.toDisplayString(_.definition.chart.chartTitle),9,Le),b.value||m.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"tile-actions","data-testid":`tile-actions-${_.tileId}`},[m.value?(a.openBlock(),a.createBlock(z,{key:0},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(m.value),1)]),_:1})):a.createCommentVNode("",!0),b.value&&_.context.editable?(a.openBlock(),a.createBlock(a.unref(ie.EditIcon),{key:1,class:"edit-icon",color:a.unref(de),"data-testid":`edit-tile-${_.tileId}`,size:a.unref(ce),onClick:C},null,8,["color","data-testid","size"])):a.createCommentVNode("",!0),b.value?(a.openBlock(),a.createBlock(Qe,{key:2,class:"dropdown","data-testid":`chart-action-menu-${_.tileId}`,"kpop-attributes":{placement:"bottom-end"}},{items:a.withCtx(()=>[u.value?(a.openBlock(),a.createBlock(j,{key:0,"data-testid":`chart-jump-to-explore-${_.tileId}`,item:{label:a.unref(n).t("jumpToExplore"),to:u.value}},null,8,["data-testid","item"])):a.createCommentVNode("",!0),"allowCsvExport"in _.definition.chart&&_.definition.chart.allowCsvExport?(a.openBlock(),a.createBlock(j,{key:1,class:"chart-export-button","data-testid":`chart-csv-export-${_.tileId}`,onClick:L[0]||(L[0]=lt=>R())},{default:a.withCtx(()=>[a.createElementVNode("span",{class:"chart-export-trigger","data-testid":`csv-export-button-${_.tileId}`},a.toDisplayString(a.unref(n).t("csvExport.exportAsCsv")),9,Me)]),_:1},8,["data-testid"])):a.createCommentVNode("",!0)]),default:a.withCtx(()=>[a.createVNode(a.unref(ie.MoreIcon),{class:"kebab-action-menu",color:a.unref(de),"data-testid":`kebab-action-menu-${_.tileId}`,size:a.unref(ce)},null,8,["color","data-testid","size"])]),_:1},8,["data-testid"])):a.createCommentVNode("",!0)],8,Oe)):"description"in _.definition.chart?(a.openBlock(),a.createElementBlock("div",{key:1,class:"header-description","data-testid":`tile-description-${_.tileId}`},a.toDisplayString(_.definition.chart.description),9,Be)):a.createCommentVNode("",!0),c.value?(a.openBlock(),a.createBlock(a.unref($.CsvExportModal),{key:2,"chart-data":d.value,"data-testid":`csv-export-modal-${_.tileId}`,filename:g.value,onToggleModal:D},null,8,["chart-data","data-testid","filename"])):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"tile-content","data-testid":`tile-content-${_.tileId}`},[w.value?(a.openBlock(),a.createBlock(a.resolveDynamicComponent(w.value.component),a.mergeProps({key:0},w.value.rendererProps,{onChartData:k}),null,16)):a.createCommentVNode("",!0)],8,Ie)],8,He)}}}),[["__scopeId","data-v-12d69e34"]]),qe=(f,e,t)=>{const i=new Map;t.forEach(r=>{const o=r.layout.position.row,n=i.get(o),h=r.layout.size.rows===1&&!!r.layout.size.fitToContent;n===void 0?i.set(o,h):i.set(o,n&&h)});const s=[];for(let r=0;r<f;r++)i.get(r)?s.push("auto"):s.push(`${e}px`);return s},fe=I(a.defineComponent({__name:"GridLayout",props:{gridSize:{type:Object,required:!0},tileHeight:{type:Number,required:!1,default:()=>F},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 h;return qe((h=e.gridSize)==null?void 0:h.rows,e.tileHeight,e.tiles).join(" ")}),o=a.computed(()=>e.tiles.map((n,h)=>({key:`tile-${h}`,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,h)=>(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 $e(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 l{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=l.createDiv(["grid-stack-item",e]),s=l.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(([h])=>{var d;h.isIntersecting&&((d=t.visibleObservable)==null||d.disconnect(),delete t.visibleObservable,p.renderCB(s,t))}),window.setTimeout(()=>{var h;return(h=t.visibleObservable)==null?void 0:h.observe(i)})):p.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 l.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&&(l.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,h=this.getScrollElement(e);if(h!==null){const d=h.scrollTop;s.top<0&&i<0?e.offsetHeight>r?h.scrollTop+=i:h.scrollTop+=Math.abs(n)>Math.abs(i)?i:n:i>0&&(e.offsetHeight>r?h.scrollTop+=i:h.scrollTop+=o>i?i:o),t.top+=h.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,h=n<i,d=n>r-i;h?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=l.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]=l.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=l.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");l.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 H{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 h=0;for(;i=i||this.collide(e,r,s.skip);){if(h++>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 c={...t,y:i.y+i.h,...n};d=this._loading&&l.samePos(e,c)?!0:this.moveNode(e,c),(i.locked||this._loading)&&d?l.copyPos(t,e):!i.locked&&d&&s.pack&&(this._packNodes(),t.y=i.y+i.h,l.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&&l.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&&l.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 h of i){if(h.locked||!h._rect)break;const d=h._rect;let c=Number.MAX_VALUE,u=Number.MAX_VALUE;s.y<d.y?c=(r.y+r.h-d.y)/d.h:s.y+s.h>d.y+d.h&&(c=(d.y+d.h-r.y)/d.h),s.x<d.x?u=(r.x+r.w-d.x)/d.w:s.x+s.w>d.x+d.w&&(u=(d.x+d.w-r.x)/d.w);const g=Math.min(u,c);g>n&&(n=g,o=h)}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=l.isTouching(e,t)))return i();if(s!==!1){if(e.w===t.w&&e.x===t.x&&(s||(s=l.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=l.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,h)=>{let d;o.locked||(o.autoPosition=!0,e==="list"&&n&&(d=h[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=l.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??H._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 l.defaults(e,s),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,l.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||l.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),l.samePos(e,i)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(t=>t._dirty&&!l.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=l.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||l.samePos(e,e._orig)||(l.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 h=n%i,d=Math.floor(n/i);if(h+e.w>i)continue;const c={x:h,y:d,w:e.w,h:e.h};t.find(u=>l.isIntercepted(c,u))||((e.x!==h||e.y!==d)&&(e._dirty=!0),e.x=h,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 H({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(h=>h._id===o._id);n&&(l.copyPos(n,o),n._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;const t=new H({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=l.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,c;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=l.copyPos({},e,!0);if(l.copyPos(r,t),this.nodeBoundFix(r,s),l.copyPos(t,r),!t.forceCollide&&l.samePos(e,t))return!1;const o=l.copyPos({},e),n=this.collideAll(e,r,t.skip);let h=!0;if(n.length){const u=e._moving&&!t.nested;let g=u?this.directionCollideCoverage(e,t,n):n[0];if(u&&g&&((c=(d=e.grid)==null?void 0:d.opts)!=null&&c.subGridDynamic)&&!e.grid._isTemp){const b=l.areaIntercept(t.rect,g._rect),E=l.area(t.rect),w=l.area(g._rect);b/(E<w?E:w)>.8&&(g.grid.makeSubGrid(g.el,void 0,e),g=void 0)}g?h=!this._fixCollisions(e,r,g,t):(h=!1,i&&delete t.pack)}return h&&!l.samePos(e,r)&&(e._dirty=!0,l.copyPos(e,r)),t.pack&&this._packNodes()._notify(),!l.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 h=s==null?void 0:s.find(c=>c._id===n._id),d={...n,...h||{}};l.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:l.sort(this.nodes,-1);if(t>e&&this._layouts){const h=this._layouts[t]||[],d=this._layouts.length-1;!h.length&&e!==d&&((n=this._layouts[d])!=null&&n.length)&&(e=d,this._layouts[d].forEach(c=>{const u=o.find(g=>g._id===c._id);u&&(!s&&!c.autoPosition&&(u.x=c.x??u.x,u.y=c.y??u.y),u.w=c.w??u.w,(c.x==null||c.y===void 0)&&(u.autoPosition=!0))})),h.forEach(c=>{const u=o.findIndex(g=>g._id===c._id);if(u!==-1){const g=o[u];if(s){g.w=c.w;return}(c.autoPosition||isNaN(c.x)||isNaN(c.y))&&this.findEmptyPosition(c,r),c.autoPosition||(g.x=c.x??g.x,g.y=c.y??g.y,g.w=c.w??g.w,r.push(g)),o.splice(u,1)}})}if(s)this.compact(i,!1);else{if(o.length)if(typeof i=="function")i(t,e,r,o);else{const h=s||i==="none"?1:t/e,d=i==="move"||i==="moveScale",c=i==="scale"||i==="moveScale";o.forEach(u=>{u.x=t===1?0:d?Math.round(u.x*h):Math.min(u.x,t-1),u.w=t===1||e===1?1:c?Math.round(u.w*h)||1:Math.min(u.w,t),r.push(u)}),o=[]}r=l.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(h=>{this.addNode(h,!1),delete h._orig})}return this.nodes.forEach(h=>delete h._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(h=>h.id===r.id):void 0;r._id=(n==null?void 0:n._id)??H._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??H._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}}H._idSeq=0;const N={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 y{}const T=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 A{}function G(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 ge(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 U(f){A.touchHandled||(A.touchHandled=!0,G(f,"mousedown"))}function W(f){A.touchHandled&&G(f,"mousemove")}function V(f){if(!A.touchHandled)return;A.pointerLeaveTimeout&&(window.clearTimeout(A.pointerLeaveTimeout),delete A.pointerLeaveTimeout);const e=!!y.dragElement;G(f,"mouseup"),e||G(f,"click"),A.touchHandled=!1}function K(f){f.pointerType!=="mouse"&&f.target.releasePointerCapture(f.pointerId)}function pe(f){y.dragElement&&f.pointerType!=="mouse"&&ge(f,"mouseenter")}function me(f){y.dragElement&&f.pointerType!=="mouse"&&(A.pointerLeaveTimeout=window.setTimeout(()=>{delete A.pointerLeaveTimeout,ge(f,"mouseleave")},10))}class Y{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(`${Y.prefix}${this.dir}`),e.style.zIndex="100",e.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),T&&(this.el.addEventListener("touchstart",U),this.el.addEventListener("pointerdown",K)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),T&&(this.el.removeEventListener("touchstart",U),this.el.removeEventListener("pointerdown",K)),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),T&&(this.el.addEventListener("touchmove",W),this.el.addEventListener("touchend",V)),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),T&&(this.el.removeEventListener("touchmove",W),this.el.removeEventListener("touchend",V)),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}}Y.prefix="ui-resizable-";class J{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 P extends J{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),y.overResizeElement===this&&delete y.overResizeElement),this}_mouseOver(e){y.overResizeElement||y.dragElement||(y.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){y.overResizeElement===this&&(delete y.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new Y(this.el,e,{start:t=>{this._resizeStart(t)},stop:t=>{this._resizeStop(t)},move:t=>{this._resizing(t,e)}})),this}_resizeStart(e){this.sizeToContent=l.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=l.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();const t=l.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=l.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=l.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=P._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;const e=this.el.parentElement,t=l.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 P._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,h;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,h=!0);const d=this._constrainSize(s.width,s.height,n,h);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,h=(s?r.maxHeightMoveUp:r.maxHeight)||Number.MAX_SAFE_INTEGER,d=r.minHeight/this.rectScale.y||t,c=Math.min(o,Math.max(n,e)),u=Math.min(h,Math.max(d,t));return{width:c,height:u}}_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}}P._originStyleProp=["width","height","position","left","top","opacity","zIndex"];const Fe='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';class q extends J{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),T&&(e.addEventListener("touchstart",U),e.addEventListener("pointerdown",K))}),this.el.classList.remove("ui-draggable-disabled"))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(t=>{t.removeEventListener("mousedown",this._mouseDown),T&&(t.removeEventListener("touchstart",U),t.removeEventListener("pointerdown",K))}),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(!y.mouseHandled)return e.button!==0||!this.dragEls.find(t=>t===e.target)&&e.target.closest(Fe)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete y.dragElement,delete y.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),T&&(e.currentTarget.addEventListener("touchmove",W),e.currentTarget.addEventListener("touchend",V)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),y.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;const t=l.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),y.pauseDrag){const s=Number.isInteger(y.pauseDrag)?y.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,y.dragElement=this;const s=(i=this.el.gridstackNode)==null?void 0:i.grid;s?y.dropElement=s.el.ddElement.ddDroppable:delete y.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=l.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);const r=l.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),T&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",W,!0),e.currentTarget.removeEventListener("touchend",V,!0)),this.dragging){delete this.dragging,(t=this.el.gridstackNode)==null||delete t._origRotate,document.removeEventListener("keydown",this._keyEvent),((i=y.dropElement)==null?void 0:i.el)===this.el.parentElement&&delete y.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const s=l.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(s),this.triggerEvent("dragstop",s),y.dropElement&&y.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete y.dragElement,delete y.dropElement,delete y.mouseHandled,e.preventDefault()}_keyEvent(e){var s,r;const t=this.el.gridstackNode,i=(t==null?void 0:t.grid)||((r=(s=y.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(!l.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",l.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=l.cloneNode(this.el)),document.body.contains(e)||l.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=q.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",q.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}}}}q.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","top","minWidth","willChange"];class Ge extends J{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),T&&(this.el.addEventListener("pointerenter",pe),this.el.addEventListener("pointerleave",me)))}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),T&&(this.el.removeEventListener("pointerenter",pe),this.el.removeEventListener("pointerleave",me)))}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(!y.dragElement||!this._canDrop(y.dragElement.el))return;e.preventDefault(),e.stopPropagation(),y.dropElement&&y.dropElement!==this&&y.dropElement._mouseLeave(e,!0),y.dropElement=this;const t=l.initEvent(e,{target:this.el,type:"dropover"});this.option.over&&this.option.over(t,this._ui(y.dragElement)),this.triggerEvent("dropover",t),this.el.classList.add("ui-droppable-over")}_mouseLeave(e,t=!1){var s;if(!y.dragElement||y.dropElement!==this)return;e.preventDefault(),e.stopPropagation();const i=l.initEvent(e,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(i,this._ui(y.dragElement)),this.triggerEvent("dropout",i),y.dropElement===this&&(delete y.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=l.initEvent(e,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(t,this._ui(y.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 Z{static init(e){return e.ddElement||(e.ddElement=new Z(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 q(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 P(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 Ge(this.el,e),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}class Ue{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 h=r.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";h==="all"&&(h="n,e,s,w,se,sw,ne,nw");const d=!n.opts.alwaysShowResizeHandle;r.setupResizable({...n.opts.resizable,handles:h,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,y.dragElement?y.dragElement.el:r.target,y.dragElement?y.dragElement.helper:null)})),this}off(e,t){return this._getDDElements(e).forEach(i=>i.off(t)),this}_getDDElements(e,t=!0){const i=l.getElements(e);if(!i.length)return[];const s=i.map(r=>r.ddElement||(t?Z.init(r):null));return t||s.filter(r=>r),s}}/*!
1
+ (function(C,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-metric-provider"),require("@kong-ui-public/entities-shared"),require("@kong/icons"),require("@kong-ui-public/analytics-config-store")):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-metric-provider","@kong-ui-public/entities-shared","@kong/icons","@kong-ui-public/analytics-config-store"],a):(C=typeof globalThis<"u"?globalThis:C||self,a(C["kong-ui-public-dashboard-renderer"]={},C.Vue,C["kong-ui-public-analytics-utilities"],C["kong-ui-public-analytics-chart"],C.swrv,C.axios,C["kong-ui-public-i18n"],C["kong-ui-public-analytics-metric-provider"],C["kong-ui-public-entities-shared"],C.KongIcons,C["kong-ui-public-analytics-config-store"]))})(this,function(C,a,L,$,be,et,te,ie,Ee,se,we){"use strict";var re=(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))(re||{});const ve=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 xe(f=a.ref({}),e,t,i=ve){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:re}}const Ce={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"},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 Re(){const f=te.createI18n("en-us",Ce);return{i18n:f,i18nT:te.i18nTComponent(f)}}const G=170,I="analytics-query-provider",X="{entity-id}",ne="{cp-id}",oe="{timeframe}",ae=30*1e3;function ke(){const f=a.inject(I);return{evaluateFeatureFlag:(t,i)=>f?f.evaluateFeatureFlagFn(t,i):i}}const O={useI18n:Re,useEvaluateFeatureFlag:ke},Q=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}=O.useI18n(),r=a.inject(I),o=()=>t.queryReady&&r?JSON.stringify([t.query,t.context,t.refreshCounter]):null,n=new AbortController;a.onUnmounted(()=>{n.abort()});const h=(v,x,k)=>{const D=[];return x&&D.push(...x),D.push(...L.stripUnknownFilters(v,k)),D},{data:d,error:c,isValidating:u}=be(o,async()=>{var v,x,k,D;try{let{datasource:R,...M}=t.query;R||(R="basic");const ee=h(R,t.query.filters,t.context.filters);let m=t.query.time_range;m?m.tz||(m={...m,tz:t.context.tz}):m={...t.context.timeSpec,tz:t.context.tz};const A={datasource:R,query:{...M,time_range:m,filters:ee}};return r==null?void 0:r.queryFn(A,n)}catch(R){E.value=((x=(v=R==null?void 0:R.response)==null?void 0:v.data)==null?void 0:x.message)==="Range not allowed for this tier"?s.t("queryDataProvider.timeRangeExceeded"):((D=(k=R==null?void 0:R.response)==null?void 0:k.data)==null?void 0:D.message)||(R==null?void 0:R.message)}finally{i("queryComplete")}},{refreshInterval:t.context.refreshInterval,revalidateOnFocus:!1}),{state:g,swrvState:b}=xe(d,c,u),E=a.ref(null),w=a.computed(()=>g.value===b.ERROR||!!E.value),_=a.computed(()=>!t.queryReady||g.value===b.PENDING);return a.watch(d,v=>{v&&i("chart-data",v)}),(v,x)=>{const k=a.resolveComponent("KSkeleton"),D=a.resolveComponent("KEmptyState");return _.value||!a.unref(d)&&!w.value?(a.openBlock(),a.createBlock(k,{key:0,class:"chart-skeleton",type:"table"})):w.value?(a.openBlock(),a.createBlock(D,{key:1,"action-button-visible":!1,"data-testid":"chart-empty-state","icon-variant":"error"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(E.value),1)]),_:1})):a.unref(d)?a.renderSlot(v.$slots,"default",{key:2,data:a.unref(d)}):a.createCommentVNode("",!0)}}}),De={class:"analytics-chart"},Te=a.defineComponent({__name:"SimpleChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){a.useCssVars(t=>({c40c0e86:`${t.height}px`}));const e=f;return(t,i)=>(a.openBlock(),a.createBlock(Q,{context:t.context,query:t.query,"query-ready":t.queryReady,"refresh-counter":t.refreshCounter},{default:a.withCtx(({data:s})=>[a.createElementVNode("div",De,[a.createVNode(a.unref($.SimpleChart),{"chart-data":s,"chart-options":e.chartOptions,"synthetics-data-key":t.chartOptions.syntheticsDataKey},null,8,["chart-data","chart-options","synthetics-data-key"])])]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),P=(f,e)=>{const t=f.__vccOpts||f;for(const[i,s]of e)t[i]=s;return t},Se=P(Te,[["__scopeId","data-v-694cf637"]]),ze={class:"analytics-chart"},le=P(a.defineComponent({__name:"BaseAnalyticsChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{},extraProps:{}},emits:["edit-tile","chart-data"],setup(f,{emit:e}){const t=f,i=e,s=a.inject(I),{i18n:r}=O.useI18n(),{evaluateFeatureFlag:o}=O.useEvaluateFeatureFlag(),n=o("ma-3043-analytics-chart-kebab-menu",!1),h=a.computed(()=>({type:t.chartOptions.type,stacked:t.chartOptions.stacked??!1,chartDatasetColors:t.chartOptions.chartDatasetColors,threshold:t.chartOptions.threshold})),d=a.computed(()=>{if(s&&s.exploreBaseUrl){const g={filters:[...t.context.filters,...t.query.filters??[]],metrics:t.query.metrics??[],dimensions:t.query.dimensions??[],time_range:t.query.time_range||t.context.timeSpec},b=["advanced","ai"].includes(t.query.datasource)?t.query.datasource:"advanced";return`${s.exploreBaseUrl()}?q=${JSON.stringify(g)}&d=${b}&c=${t.chartOptions.type}`}return""}),c=()=>{i("edit-tile")},u=g=>{i("chart-data",g)};return(g,b)=>{const E=a.resolveComponent("KDropdownItem");return a.openBlock(),a.createBlock(Q,{context:g.context,query:g.query,"query-ready":g.queryReady,"refresh-counter":g.refreshCounter,onChartData:u},{default:a.withCtx(({data:w})=>[a.createElementVNode("div",ze,[a.createVNode(a.unref($.AnalyticsChart),a.mergeProps({"allow-csv-export":g.chartOptions.allowCsvExport,"chart-data":w,"chart-options":h.value,"chart-title":!a.unref(n)&&g.chartOptions.chartTitle||"","go-to-explore":d.value,"legend-position":"bottom","show-menu":g.context.editable,"synthetics-data-key":g.chartOptions.syntheticsDataKey,"tooltip-title":""},g.extraProps),a.createSlots({_:2},[g.context.editable?{name:"menu-items",fn:a.withCtx(()=>[a.createVNode(E,{onClick:c},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(a.unref(r).t("renderer.edit")),1)]),_:1})]),key:"0"}:void 0]),1040,["allow-csv-export","chart-data","chart-options","chart-title","go-to-explore","show-menu","synthetics-data-key"])])]),_:1},8,["context","query","query-ready","refresh-counter"])}}}),[["__scopeId","data-v-1bc587d3"]]),he=a.defineComponent({__name:"BarChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(a.openBlock(),a.createBlock(le,{"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"]))}}),de=a.defineComponent({__name:"TimeseriesChartRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){return(e,t)=>(a.openBlock(),a.createBlock(le,{"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"]))}}),Ne={class:"metric-card-tile-wrapper"},He=P(a.defineComponent({__name:"GoldenSignalsRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){a.useCssVars(o=>({"926e3b48":a.unref(i)?"90%":"100%","7be2893e":a.unref(i)?"auto":"100%","0d55c162":a.unref(i)?"100%":"none"}));const e=f,{evaluateFeatureFlag:t}=O.useEvaluateFeatureFlag(),i=t("ma-3043-analytics-chart-kebab-menu",!1),s=a.computed(()=>{const o=e.context.timeSpec;if(o.type==="absolute")return new L.Timeframe({key:"custom",timeframeText:"custom",display:"custom",startCustom:o.start,endCustom:o.end,timeframeLength:()=>o.end.getTime()-o.start.getTime(),defaultResponseGranularity:"daily",dataGranularity:"daily",isRelative:!1,allowedTiers:["free","plus","enterprise"]});const n=L.TimePeriods.get(o.time_range);if(!n)throw new Error("Unknown time range");return n}),r=a.computed(()=>{var n,h;const o=(n=e.query)==null?void 0:n.datasource;if(o&&o!=="advanced"&&o!=="basic")throw new Error(`Invalid datasource value: ${o}`);return{datasource:(h=e.query)==null?void 0:h.datasource,overrideTimeframe:s.value,tz:e.context.tz,additionalFilter:e.context.filters,longCardTitles:e.chartOptions.longCardTitles,...!i&&{containerTitle:e.chartOptions.chartTitle},...!i&&{description:e.chartOptions.description},percentileLatency:e.chartOptions.percentileLatency,refreshInterval:e.context.refreshInterval,queryReady:e.queryReady,refreshCounter:e.refreshCounter}});return(o,n)=>(a.openBlock(),a.createElementBlock("div",Ne,[a.createVNode(a.unref(ie.MetricsProvider),a.normalizeProps(a.guardReactiveProps(r.value)),{default:a.withCtx(()=>[a.createVNode(a.unref(ie.MetricsConsumer))]),_:1},16)]))}}),[["__scopeId","data-v-0f571079"]]),ce="#6c7489",ue="20px",fe="20px",Ae=a.defineComponent({__name:"TopNTableRenderer",props:{query:{},context:{},queryReady:{type:Boolean},chartOptions:{},height:{},refreshCounter:{}},setup(f){const e=f,{evaluateFeatureFlag:t}=O.useEvaluateFeatureFlag(),i=t("ma-3043-analytics-chart-kebab-menu",!1),s=r=>{var o;if((o=e.chartOptions)!=null&&o.entityLink)if(r.id.includes(":")){const[n,h]=r.id.split(":");return e.chartOptions.entityLink.replace(ne,n).replace(X,h)}else return e.chartOptions.entityLink.replace(X,r.id);return""};return(r,o)=>(a.openBlock(),a.createBlock(Q,{context:r.context,query:r.query,"query-ready":r.queryReady,"refresh-counter":r.refreshCounter},{default:a.withCtx(({data:n})=>[a.createVNode(a.unref($.TopNTable),{data:n,description:!a.unref(i)&&r.chartOptions.description||"","synthetics-data-key":r.chartOptions.syntheticsDataKey,title:!a.unref(i)&&r.chartOptions.chartTitle||""},a.createSlots({_:2},[e.chartOptions.entityLink?{name:"name",fn:a.withCtx(({record:h})=>[a.createVNode(a.unref(Ee.EntityLink),{"entity-link-data":{id:h.id,label:h.name,deleted:h.deleted},"external-link":s(h)},null,8,["entity-link-data","external-link"])]),key:"0"}:void 0]),1032,["data","description","synthetics-data-key","title"])]),_:1},8,["context","query","query-ready","refresh-counter"]))}}),Le=["data-testid"],Oe={key:0,class:"tile-header"},Me=["data-testid"],Be=["data-testid"],Ie=["data-testid"],Pe=["data-testid"],qe=P(a.defineComponent({__name:"DashboardTile",props:{definition:{},context:{},height:{default:G},queryReady:{type:Boolean},refreshCounter:{},tileId:{}},emits:["edit-tile"],setup(f,{emit:e}){a.useCssVars(m=>({"35d14b98":`${m.height}px`}));const t=parseInt(fe,10),i=f,s=e,r=a.inject(I),{evaluateFeatureFlag:o}=O.useEvaluateFeatureFlag(),{i18n:n}=O.useI18n(),h=o("ma-3043-analytics-chart-kebab-menu",!1),d=a.ref(),c=a.ref(!1),u=a.ref(),g=a.ref(!1);a.watch(()=>i.definition,async()=>{await a.nextTick(),u.value&&(g.value=u.value.scrollWidth>u.value.clientWidth)},{immediate:!0,deep:!0});const b=a.computed(()=>{if(r&&r.exploreBaseUrl){const m={filters:[...i.context.filters,...i.definition.query.filters??[]],metrics:i.definition.query.metrics??[],dimensions:i.definition.query.dimensions??[],time_range:i.definition.query.time_range||i.context.timeSpec,granularity:i.definition.query.granularity||k.value},A=["advanced","ai"].includes(i.definition.query.datasource)?i.definition.query.datasource:"advanced";return`${r.exploreBaseUrl()}?q=${JSON.stringify(m)}&d=${A}&c=${i.definition.chart.type}`}return""}),E=a.computed(()=>n.t("csvExport.defaultFilename")),w=a.computed(()=>h&&!["golden_signals","top_n","gauge"].includes(i.definition.chart.type)),_={timeseries_line:de,timeseries_bar:de,horizontal_bar:he,vertical_bar:he,gauge:Se,golden_signals:He,top_n:Ae,slottable:void 0},v=a.computed(()=>{const m=_[i.definition.chart.type];return m&&{component:m,rendererProps:{query:i.definition.query,context:i.context,queryReady:i.queryReady,chartOptions:i.definition.chart,height:i.height-t*2,refreshCounter:i.refreshCounter}}}),x=a.computed(()=>{var A;const m=(A=i.definition.query)==null?void 0:A.time_range;if((m==null?void 0:m.type)==="relative"){const B=L.TimePeriods.get(L.TIMEFRAME_LOOKUP[m.time_range]);return B?B.display:(console.warn("Did not recognize the given relative time range:",m.time_range),m.time_range)}else if((m==null?void 0:m.type)==="absolute"){const B=m.tz||"Etc/UTC";return`${L.formatTime(m.start,{short:!0,tz:B})} - ${L.formatTime(m.end,{short:!0,tz:B})}`}return null}),k=a.computed(()=>d.value?L.msToGranularity(d.value.meta.granularity_ms):void 0),D=()=>{s("edit-tile",i.definition)},R=m=>{d.value=m},M=m=>{c.value=m},ee=()=>{M(!0)};return(m,A)=>{const B=a.resolveComponent("KTooltip"),Je=a.resolveComponent("KBadge"),_e=a.resolveComponent("KDropdownItem"),Ze=a.resolveComponent("KDropdown");return a.openBlock(),a.createElementBlock("div",{class:"tile-boundary","data-testid":`tile-${m.tileId}`},[a.unref(h)&&m.definition.chart.type!=="slottable"?(a.openBlock(),a.createElementBlock("div",Oe,[a.createVNode(B,{class:"title-tooltip",disabled:!g.value,"max-width":"500",text:m.definition.chart.chartTitle},{default:a.withCtx(()=>[a.createElementVNode("div",{ref_key:"titleRef",ref:u,class:"title"},a.toDisplayString(m.definition.chart.chartTitle),513)]),_:1},8,["disabled","text"]),w.value||x.value?(a.openBlock(),a.createElementBlock("div",{key:0,class:"tile-actions","data-testid":`tile-actions-${m.tileId}`},[x.value?(a.openBlock(),a.createBlock(Je,{key:0},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(x.value),1)]),_:1})):a.createCommentVNode("",!0),w.value&&m.context.editable?(a.openBlock(),a.createBlock(a.unref(se.EditIcon),{key:1,class:"edit-icon",color:a.unref(ce),"data-testid":`edit-tile-${m.tileId}`,size:a.unref(ue),onClick:D},null,8,["color","data-testid","size"])):a.createCommentVNode("",!0),w.value?(a.openBlock(),a.createBlock(Ze,{key:2,class:"dropdown","data-testid":`chart-action-menu-${m.tileId}`,"kpop-attributes":{placement:"bottom-end"}},{items:a.withCtx(()=>[b.value?(a.openBlock(),a.createBlock(_e,{key:0,"data-testid":`chart-jump-to-explore-${m.tileId}`,item:{label:a.unref(n).t("jumpToExplore"),to:b.value}},null,8,["data-testid","item"])):a.createCommentVNode("",!0),"allowCsvExport"in m.definition.chart&&m.definition.chart.allowCsvExport?(a.openBlock(),a.createBlock(_e,{key:1,class:"chart-export-button","data-testid":`chart-csv-export-${m.tileId}`,onClick:A[0]||(A[0]=dt=>ee())},{default:a.withCtx(()=>[a.createElementVNode("span",{class:"chart-export-trigger","data-testid":`csv-export-button-${m.tileId}`},a.toDisplayString(a.unref(n).t("csvExport.exportAsCsv")),9,Be)]),_:1},8,["data-testid"])):a.createCommentVNode("",!0)]),default:a.withCtx(()=>[a.createVNode(a.unref(se.MoreIcon),{class:"kebab-action-menu",color:a.unref(ce),"data-testid":`kebab-action-menu-${m.tileId}`,size:a.unref(ue)},null,8,["color","data-testid","size"])]),_:1},8,["data-testid"])):a.createCommentVNode("",!0)],8,Me)):"description"in m.definition.chart?(a.openBlock(),a.createElementBlock("div",{key:1,class:"header-description","data-testid":`tile-description-${m.tileId}`},a.toDisplayString(m.definition.chart.description),9,Ie)):a.createCommentVNode("",!0),c.value?(a.openBlock(),a.createBlock(a.unref($.CsvExportModal),{key:2,"chart-data":d.value,"data-testid":`csv-export-modal-${m.tileId}`,filename:E.value,onToggleModal:M},null,8,["chart-data","data-testid","filename"])):a.createCommentVNode("",!0)])):a.createCommentVNode("",!0),a.createElementVNode("div",{class:"tile-content","data-testid":`tile-content-${m.tileId}`},[v.value?(a.openBlock(),a.createBlock(a.resolveDynamicComponent(v.value.component),a.mergeProps({key:0},v.value.rendererProps,{onChartData:R}),null,16)):a.createCommentVNode("",!0)],8,Pe)],8,Le)}}}),[["__scopeId","data-v-ff00dcd4"]]),Fe=(f,e,t)=>{const i=new Map;t.forEach(r=>{const o=r.layout.position.row,n=i.get(o),h=r.layout.size.rows===1&&!!r.layout.size.fitToContent;n===void 0?i.set(o,h):i.set(o,n&&h)});const s=[];for(let r=0;r<f;r++)i.get(r)?s.push("auto"):s.push(`${e}px`);return s},ge=P(a.defineComponent({__name:"GridLayout",props:{gridSize:{type:Object,required:!0},tileHeight:{type:Number,required:!1,default:()=>G},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 h;return Fe((h=e.gridSize)==null?void 0:h.rows,e.tileHeight,e.tiles).join(" ")}),o=a.computed(()=>e.tiles.map((n,h)=>({key:`tile-${h}`,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,h)=>(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 $e(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 l{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=l.createDiv(["grid-stack-item",e]),s=l.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(([h])=>{var d;h.isIntersecting&&((d=t.visibleObservable)==null||d.disconnect(),delete t.visibleObservable,p.renderCB(s,t))}),window.setTimeout(()=>{var h;return(h=t.visibleObservable)==null?void 0:h.observe(i)})):p.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 l.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&&(l.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,h=this.getScrollElement(e);if(h!==null){const d=h.scrollTop;s.top<0&&i<0?e.offsetHeight>r?h.scrollTop+=i:h.scrollTop+=Math.abs(n)>Math.abs(i)?i:n:i>0&&(e.offsetHeight>r?h.scrollTop+=i:h.scrollTop+=o>i?i:o),t.top+=h.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,h=n<i,d=n>r-i;h?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=l.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]=l.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=l.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");l.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 N{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 h=0;for(;i=i||this.collide(e,r,s.skip);){if(h++>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 c={...t,y:i.y+i.h,...n};d=this._loading&&l.samePos(e,c)?!0:this.moveNode(e,c),(i.locked||this._loading)&&d?l.copyPos(t,e):!i.locked&&d&&s.pack&&(this._packNodes(),t.y=i.y+i.h,l.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&&l.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&&l.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 h of i){if(h.locked||!h._rect)break;const d=h._rect;let c=Number.MAX_VALUE,u=Number.MAX_VALUE;s.y<d.y?c=(r.y+r.h-d.y)/d.h:s.y+s.h>d.y+d.h&&(c=(d.y+d.h-r.y)/d.h),s.x<d.x?u=(r.x+r.w-d.x)/d.w:s.x+s.w>d.x+d.w&&(u=(d.x+d.w-r.x)/d.w);const g=Math.min(u,c);g>n&&(n=g,o=h)}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=l.isTouching(e,t)))return i();if(s!==!1){if(e.w===t.w&&e.x===t.x&&(s||(s=l.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=l.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,h)=>{let d;o.locked||(o.autoPosition=!0,e==="list"&&n&&(d=h[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=l.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??N._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 l.defaults(e,s),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,l.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||l.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),l.samePos(e,i)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(t=>t._dirty&&!l.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=l.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||l.samePos(e,e._orig)||(l.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 h=n%i,d=Math.floor(n/i);if(h+e.w>i)continue;const c={x:h,y:d,w:e.w,h:e.h};t.find(u=>l.isIntercepted(c,u))||((e.x!==h||e.y!==d)&&(e._dirty=!0),e.x=h,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 N({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(h=>h._id===o._id);n&&(l.copyPos(n,o),n._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;const t=new N({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=l.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,c;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=l.copyPos({},e,!0);if(l.copyPos(r,t),this.nodeBoundFix(r,s),l.copyPos(t,r),!t.forceCollide&&l.samePos(e,t))return!1;const o=l.copyPos({},e),n=this.collideAll(e,r,t.skip);let h=!0;if(n.length){const u=e._moving&&!t.nested;let g=u?this.directionCollideCoverage(e,t,n):n[0];if(u&&g&&((c=(d=e.grid)==null?void 0:d.opts)!=null&&c.subGridDynamic)&&!e.grid._isTemp){const b=l.areaIntercept(t.rect,g._rect),E=l.area(t.rect),w=l.area(g._rect);b/(E<w?E:w)>.8&&(g.grid.makeSubGrid(g.el,void 0,e),g=void 0)}g?h=!this._fixCollisions(e,r,g,t):(h=!1,i&&delete t.pack)}return h&&!l.samePos(e,r)&&(e._dirty=!0,l.copyPos(e,r)),t.pack&&this._packNodes()._notify(),!l.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 h=s==null?void 0:s.find(c=>c._id===n._id),d={...n,...h||{}};l.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:l.sort(this.nodes,-1);if(t>e&&this._layouts){const h=this._layouts[t]||[],d=this._layouts.length-1;!h.length&&e!==d&&((n=this._layouts[d])!=null&&n.length)&&(e=d,this._layouts[d].forEach(c=>{const u=o.find(g=>g._id===c._id);u&&(!s&&!c.autoPosition&&(u.x=c.x??u.x,u.y=c.y??u.y),u.w=c.w??u.w,(c.x==null||c.y===void 0)&&(u.autoPosition=!0))})),h.forEach(c=>{const u=o.findIndex(g=>g._id===c._id);if(u!==-1){const g=o[u];if(s){g.w=c.w;return}(c.autoPosition||isNaN(c.x)||isNaN(c.y))&&this.findEmptyPosition(c,r),c.autoPosition||(g.x=c.x??g.x,g.y=c.y??g.y,g.w=c.w??g.w,r.push(g)),o.splice(u,1)}})}if(s)this.compact(i,!1);else{if(o.length)if(typeof i=="function")i(t,e,r,o);else{const h=s||i==="none"?1:t/e,d=i==="move"||i==="moveScale",c=i==="scale"||i==="moveScale";o.forEach(u=>{u.x=t===1?0:d?Math.round(u.x*h):Math.min(u.x,t-1),u.w=t===1||e===1?1:c?Math.round(u.w*h)||1:Math.min(u.w,t),r.push(u)}),o=[]}r=l.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(h=>{this.addNode(h,!1),delete h._orig})}return this.nodes.forEach(h=>delete h._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(h=>h.id===r.id):void 0;r._id=(n==null?void 0:n._id)??N._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??N._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}}N._idSeq=0;const S={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 y{}const z=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 H{}function U(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 pe(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 W(f){H.touchHandled||(H.touchHandled=!0,U(f,"mousedown"))}function V(f){H.touchHandled&&U(f,"mousemove")}function K(f){if(!H.touchHandled)return;H.pointerLeaveTimeout&&(window.clearTimeout(H.pointerLeaveTimeout),delete H.pointerLeaveTimeout);const e=!!y.dragElement;U(f,"mouseup"),e||U(f,"click"),H.touchHandled=!1}function Y(f){f.pointerType!=="mouse"&&f.target.releasePointerCapture(f.pointerId)}function me(f){y.dragElement&&f.pointerType!=="mouse"&&pe(f,"mouseenter")}function ye(f){y.dragElement&&f.pointerType!=="mouse"&&(H.pointerLeaveTimeout=window.setTimeout(()=>{delete H.pointerLeaveTimeout,pe(f,"mouseleave")},10))}class j{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(`${j.prefix}${this.dir}`),e.style.zIndex="100",e.style.userSelect="none",this.host.appendChild(this.el),this.el.addEventListener("mousedown",this._mouseDown),z&&(this.el.addEventListener("touchstart",W),this.el.addEventListener("pointerdown",Y)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),z&&(this.el.removeEventListener("touchstart",W),this.el.removeEventListener("pointerdown",Y)),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),z&&(this.el.addEventListener("touchmove",V),this.el.addEventListener("touchend",K)),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),z&&(this.el.removeEventListener("touchmove",V),this.el.removeEventListener("touchend",K)),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}}j.prefix="ui-resizable-";class J{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 q extends J{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),y.overResizeElement===this&&delete y.overResizeElement),this}_mouseOver(e){y.overResizeElement||y.dragElement||(y.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){y.overResizeElement===this&&(delete y.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new j(this.el,e,{start:t=>{this._resizeStart(t)},stop:t=>{this._resizeStop(t)},move:t=>{this._resizing(t,e)}})),this}_resizeStart(e){this.sizeToContent=l.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=l.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();const t=l.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=l.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=l.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=q._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;const e=this.el.parentElement,t=l.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 q._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,h;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,h=!0);const d=this._constrainSize(s.width,s.height,n,h);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,h=(s?r.maxHeightMoveUp:r.maxHeight)||Number.MAX_SAFE_INTEGER,d=r.minHeight/this.rectScale.y||t,c=Math.min(o,Math.max(n,e)),u=Math.min(h,Math.max(d,t));return{width:c,height:u}}_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}}q._originStyleProp=["width","height","position","left","top","opacity","zIndex"];const Ge='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle';class F extends J{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),z&&(e.addEventListener("touchstart",W),e.addEventListener("pointerdown",Y))}),this.el.classList.remove("ui-draggable-disabled"))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(t=>{t.removeEventListener("mousedown",this._mouseDown),z&&(t.removeEventListener("touchstart",W),t.removeEventListener("pointerdown",Y))}),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(!y.mouseHandled)return e.button!==0||!this.dragEls.find(t=>t===e.target)&&e.target.closest(Ge)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete y.dragElement,delete y.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),z&&(e.currentTarget.addEventListener("touchmove",V),e.currentTarget.addEventListener("touchend",K)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),y.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;const t=l.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),y.pauseDrag){const s=Number.isInteger(y.pauseDrag)?y.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,y.dragElement=this;const s=(i=this.el.gridstackNode)==null?void 0:i.grid;s?y.dropElement=s.el.ddElement.ddDroppable:delete y.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=l.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);const r=l.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),z&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",V,!0),e.currentTarget.removeEventListener("touchend",K,!0)),this.dragging){delete this.dragging,(t=this.el.gridstackNode)==null||delete t._origRotate,document.removeEventListener("keydown",this._keyEvent),((i=y.dropElement)==null?void 0:i.el)===this.el.parentElement&&delete y.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const s=l.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(s),this.triggerEvent("dragstop",s),y.dropElement&&y.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete y.dragElement,delete y.dropElement,delete y.mouseHandled,e.preventDefault()}_keyEvent(e){var s,r;const t=this.el.gridstackNode,i=(t==null?void 0:t.grid)||((r=(s=y.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(!l.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",l.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=l.cloneNode(this.el)),document.body.contains(e)||l.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=F.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",F.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}}}}F.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","top","minWidth","willChange"];class Ue extends J{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),z&&(this.el.addEventListener("pointerenter",me),this.el.addEventListener("pointerleave",ye)))}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),z&&(this.el.removeEventListener("pointerenter",me),this.el.removeEventListener("pointerleave",ye)))}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(!y.dragElement||!this._canDrop(y.dragElement.el))return;e.preventDefault(),e.stopPropagation(),y.dropElement&&y.dropElement!==this&&y.dropElement._mouseLeave(e,!0),y.dropElement=this;const t=l.initEvent(e,{target:this.el,type:"dropover"});this.option.over&&this.option.over(t,this._ui(y.dragElement)),this.triggerEvent("dropover",t),this.el.classList.add("ui-droppable-over")}_mouseLeave(e,t=!1){var s;if(!y.dragElement||y.dropElement!==this)return;e.preventDefault(),e.stopPropagation();const i=l.initEvent(e,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(i,this._ui(y.dragElement)),this.triggerEvent("dropout",i),y.dropElement===this&&(delete y.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=l.initEvent(e,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(t,this._ui(y.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 Z{static init(e){return e.ddElement||(e.ddElement=new Z(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 F(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 q(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 Ue(this.el,e),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}}class We{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 h=r.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";h==="all"&&(h="n,e,s,w,se,sw,ne,nw");const d=!n.opts.alwaysShowResizeHandle;r.setupResizable({...n.opts.resizable,handles:h,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,y.dragElement?y.dragElement.el:r.target,y.dragElement?y.dragElement.helper:null)})),this}off(e,t){return this._getDDElements(e).forEach(i=>i.off(t)),this}_getDDElements(e,t=!0){const i=l.getElements(e);if(!i.length)return[];const s=i.map(r=>r.ddElement||(t?Z.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 S=new Ue;class p{static init(e={},t=".grid-stack"){if(typeof document>"u")return null;const i=p.getGridElement(t);return i?(i.gridstack||(i.gridstack=new p(i,l.cloneDeep(e))),i.gridstack):(console.error(typeof t=="string"?'GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
7
+ */const T=new We;class p{static init(e={},t=".grid-stack"){if(typeof document>"u")return null;const i=p.getGridElement(t);return i?(i.gridstack||(i.gridstack=new p(i,l.cloneDeep(e))),i.gridstack):(console.error(typeof t=="string"?'GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
8
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"||(p.getGridElements(t).forEach(s=>{s.gridstack||(s.gridstack=new p(s,l.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")||p.addRemoveCB)&&(p.addRemoveCB?i=p.addRemoveCB(e,t,!0,!0):i=l.createDiv(["grid-stack",t.class],e)),p.init(t,i)}static registerEngine(e){p.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=l.createDiv([this.opts.placeholderClass,N.itemClass,this.opts.itemClass]);const e=l.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,t={}){var u,g,b;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=l.toNumber(e.getAttribute("gs-row"));t.column==="auto"&&delete t.column,t.alwaysShowResizeHandle!==void 0&&(t._alwaysShowResizeHandle=t.alwaysShowResizeHandle);let s=(u=t.columnOpts)==null?void 0:u.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 E=r.oneColumnSize||768;delete r.oneColumnSize,delete r.disableOneColumnMode,t.columnOpts=t.columnOpts||{},s=t.columnOpts.breakpoints=t.columnOpts.breakpoints||[];let w=s.find(m=>m.c===1);w?w.w=E:(w={c:1,w:E},s.push(w,{c:12,w:E+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((E,w)=>(w.w||0)-(E.w||0));const n={...l.cloneDeep(N),column:l.toNumber(e.getAttribute("gs-column"))||N.column,minRow:i||l.toNumber(e.getAttribute("gs-min-row"))||N.minRow,maxRow:i||l.toNumber(e.getAttribute("gs-max-row"))||N.maxRow,staticGrid:l.toBool(e.getAttribute("gs-static"))||N.staticGrid,sizeToContent:l.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(t.handleClass?"."+t.handleClass:t.handle?t.handle:"")||N.draggable.handle},removableOptions:{accept:t.itemClass||N.removableOptions.accept,decline:N.removableOptions.decline}};e.getAttribute("gs-animate")&&(n.animate=l.toBool(e.getAttribute("gs-animate"))),t=l.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 h=this.el.closest("."+N.itemClass),d=h==null?void 0:h.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!==N.cellHeightUnit&&(t.cellHeight=t.cellHeight+t.cellHeightUnit,delete t.cellHeightUnit),this.cellHeight(t.cellHeight,!1)),t.alwaysShowResizeHandle==="mobile"&&(t.alwaysShowResizeHandle=T),this._styleSheetClass="gs-id-"+H._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();const c=t.engineClass||p.engineClass||H;if(this.engine=new c({column:this.getColumn(),float:t.float,maxRow:t.maxRow,onChange:E=>{let w=0;this.engine.nodes.forEach(m=>{w=Math.max(w,m.y+m.h)}),E.forEach(m=>{const v=m.el;v&&(m._removeDOM?(v&&v.remove(),delete m._removeDOM):this._writePosAttr(v,m))}),this._updateStyles(!1,w)}}),this._updateStyles(!1,0),t.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(E=>this._prepareElement(E)),delete this.engine._loading,this.batchUpdate(!1)),t.children){const E=t.children;delete t.children,E.length&&this.load(E)}this.setAnimation(),t.subGridDynamic&&!y.pauseDrag&&(y.pauseDrag=!0),((b=t.draggable)==null?void 0:b.pause)!==void 0&&(y.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:p.addRemoveCB?t=p.addRemoveCB(this.el,e,!0,!1):t=l.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 l.defaults(e,s),this.engine.prepareNode(e),this.el.appendChild(t),this.makeWidget(t,e),t}makeSubGrid(e,t,i,s=!0){var b,E,w;let r=e.gridstackNode;if(r||(r=this.makeWidget(e).gridstackNode),(b=r.subGrid)!=null&&b.el)return r.subGrid;let o,n=this;for(;n&&!o;)o=(E=n.opts)==null?void 0:E.subGridOpts,n=(w=n.parentGridNode)==null?void 0:w.grid;t=l.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 h;t.column==="auto"&&(h=!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"),c,u;if(s&&(this._removeDD(r.el),u={...r,x:0,y:0},l.removeInternalForSave(u),delete u.subGridOpts,r.content&&(u.content=r.content,delete r.content),p.addRemoveCB?c=p.addRemoveCB(this.el,u,!0,!1):(c=l.createDiv(["grid-stack-item"]),c.appendChild(d),d=l.createDiv(["grid-stack-item-content"],r.el)),this._prepareDragDropByNode(r)),i){const m=h?t.column:r.w,v=r.h+i.h,C=r.el.style;C.transition="none",this.update(r.el,{w:m,h:v}),setTimeout(()=>C.transition=null)}const g=r.subGrid=p.addGrid(d,t);return i!=null&&i._moving&&(g._isTemp=!0),h&&(g._autoColumn=!0),s&&g.makeWidget(c,u),i&&(i._moving?window.setTimeout(()=>l.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(()=>l.simulateMouseEvent(e._event,"mouseenter",t.el),0))}save(e=!0,t=!1,i=p.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=l.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,l.removeInternalAndSame(r,N),r.children=s,r}return s}load(e,t=p.addRemoveCB||!0){var d;e=l.cloneDeep(e);const i=this.getColumn();e.forEach(c=>{c.w=c.w||1,c.h=c.h||1}),e=l.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let s=0;e.forEach(c=>{s=Math.max(s,(c.x||0)+c.w)}),s>this.engine.defaultColumn&&(this.engine.defaultColumn=s),s>i&&this.engine.cacheLayout(e,s,!0);const r=p.addRemoveCB;typeof t=="function"&&(p.addRemoveCB=t);const o=[];this.batchUpdate();const n=!this.engine.nodes.length;n&&this.setAnimation(!1),!n&&t&&[...this.engine.nodes].forEach(u=>{if(!u.id)return;l.find(e,u.id)||(p.addRemoveCB&&p.addRemoveCB(this.el,u,!1,!1),o.push(u),this.removeWidget(u.el,!0,!1))}),this.engine._loading=!0;const h=[];return this.engine.nodes=this.engine.nodes.filter(c=>l.find(e,c.id)?(h.push(c),!1):!0),e.forEach(c=>{var g;const u=l.find(h,c.id);if(u){if(l.shouldSizeToContent(u)&&(c.h=u.h),this.engine.nodeBoundFix(c),(c.autoPosition||c.x===void 0||c.y===void 0)&&(c.w=c.w||u.w,c.h=c.h||u.h,this.engine.findEmptyPosition(c)),this.engine.nodes.push(u),l.samePos(u,c)&&this.engine.nodes.length>1&&(this.moveNode(u,{...c,forceCollide:!0}),l.copyPos(c,u)),this.update(u.el,c),(g=c.subGridOpts)!=null&&g.children){const b=u.el.querySelector(".grid-stack");b&&b.gridstack&&b.gridstack.load(c.subGridOpts.children)}}else t&&this.addWidget(c)}),delete this.engine._loading,this.engine.removedNodes=o,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,r?p.addRemoveCB=r:delete p.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=l.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=l.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(h=>h.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(),h=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/n),y:Math.floor(o/h)}}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=p.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?(p.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&&p.addRemoveCB&&p.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&&p.addRemoveCB&&p.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 p.getElements(e).forEach(i=>{var c;const s=i==null?void 0:i.gridstackNode;if(!s)return;const r=l.cloneDeep(t);this.engine.nodeBoundFix(r),delete r.autoPosition;const o=["x","y","w","h"];let n;if(o.some(u=>r[u]!==void 0&&r[u]!==s[u])&&(n={},o.forEach(u=>{n[u]=r[u]!==void 0?r[u]:s[u],delete r[u]})),!n&&(r.minW||r.minH||r.maxW||r.maxH)&&(n={}),r.content!==void 0){const u=i.querySelector(".grid-stack-item-content");u&&u.textContent!==r.content&&(s.content=r.content,p.renderCB(u,r),(c=s.subGrid)!=null&&c.el&&(u.appendChild(s.subGrid.el),s.subGrid.opts.styleInHead||s.subGrid._updateStyles(!0))),delete r.content}let h=!1,d=!1;for(const u in r)u[0]!=="_"&&s[u]!==r[u]&&(s[u]=r[u],h=!0,d=d||!this.opts.staticGrid&&(u==="noResize"||u==="noMove"||u==="locked"));if(l.sanitizeMinMax(s),n){const u=n.w!==void 0&&n.w!==s.w;this.moveNode(s,n),u&&s.subGrid?s.subGrid.onResize(this.hasAnimationCSS()?s.w:void 0):this.resizeToContentCheck(u,s),delete s._orig}(n||h)&&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,b;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(p.resizeToContentParent)),!o)return;const n=e.clientHeight-o.clientHeight,h=t.h?t.h*s-n:o.clientHeight;let d;if(t.subGrid){d=t.subGrid.getRow()*t.subGrid.getCellHeight(!0);const E=t.subGrid.el.getBoundingClientRect(),w=t.subGrid.el.parentElement.getBoundingClientRect();d+=E.top-w.top}else{if((b=(g=t.subGridOpts)==null?void 0:g.children)!=null&&b.length)return;{const E=o.firstElementChild;if(!E){console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${p.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}d=E.getBoundingClientRect().height||h}}if(h===d)return;r+=d-h;let c=Math.ceil(r/s);const u=Number.isInteger(t.sizeToContent)?t.sizeToContent:0;u&&c>u&&(c=u,e.classList.add("size-to-content-max")),t.minH&&c<t.minH?c=t.minH:t.maxH&&c>t.maxH&&(c=t.maxH),c!==t.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(t,{h:c}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){p.resizeToContentCB?p.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,t){return p.getElements(e).forEach(i=>{const s=i.gridstackNode;if(!l.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,h=t.top>0?Math.floor(t.top/this.opts.cellHeight):0;r.x=s.x+n-(s.h-(h+1)),r.y=s.y+h-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=l.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;l.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=l.createStylesheet(this._styleSheetClass,o,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,l.addCSSRule(this._styles,r,`height: ${i}${s}`);const n=this.opts.marginTop+this.opts.marginUnit,h=this.opts.marginBottom+this.opts.marginUnit,d=this.opts.marginRight+this.opts.marginUnit,c=this.opts.marginLeft+this.opts.marginUnit,u=`${r} > .grid-stack-item-content`,g=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;l.addCSSRule(this._styles,u,`top: ${n}; right: ${d}; bottom: ${h}; left: ${c};`),l.addCSSRule(this._styles,g,`top: ${n}; right: ${d}; bottom: ${h}; left: ${c};`),l.addCSSRule(this._styles,`${r} > .ui-resizable-n`,`top: ${n};`),l.addCSSRule(this._styles,`${r} > .ui-resizable-s`,`bottom: ${h}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-ne`,`right: ${d}; top: ${n}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-e`,`right: ${d}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-se`,`right: ${d}; bottom: ${h}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-nw`,`left: ${c}; top: ${n}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-w`,`left: ${c}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-sw`,`left: ${c}; bottom: ${h}`)}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++)l.addCSSRule(this._styles,`${r}[gs-y="${n}"]`,`top: ${o(n)}`),l.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=l.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&&l.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(N.itemClass,this.opts.itemClass);const s=l.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=l.toNumber(e.getAttribute("gs-x")),i.y=l.toNumber(e.getAttribute("gs-y")),i.w=l.toNumber(e.getAttribute("gs-w")),i.h=l.toNumber(e.getAttribute("gs-h")),i.autoPosition=l.toBool(e.getAttribute("gs-auto-position")),i.noResize=l.toBool(e.getAttribute("gs-no-resize")),i.noMove=l.toBool(e.getAttribute("gs-no-move")),i.locked=l.toBool(e.getAttribute("gs-locked")),i.sizeToContent=l.toBool(e.getAttribute("gs-size-to-content")),i.id=e.getAttribute("gs-id"),i.maxW=l.toNumber(e.getAttribute("gs-max-w")),i.minW=l.toNumber(e.getAttribute("gs-min-w")),i.maxH=l.toNumber(e.getAttribute("gs-max-h")),i.minH=l.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)l.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el);else if(this.engine.nodes.some(i=>l.shouldSizeToContent(i))){const i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{l.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=l.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 l.getElement(e)}static getElements(e=".grid-stack-item"){return l.getElements(e)}static getGridElement(e){return p.getElement(e)}static getGridElements(e){return l.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=l.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=l.parseHeight(this.opts.marginTop),this.opts.marginTop=e.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=t:(e=l.parseHeight(this.opts.marginBottom),this.opts.marginBottom=e.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=t:(e=l.parseHeight(this.opts.marginRight),this.opts.marginRight=e.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=t:(e=l.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 S}static setupDragIn(e,t,i,s=document){(t==null?void 0:t.pause)!==void 0&&(y.pauseDrag=t.pause),t={appendTo:"body",helper:"clone",...t||{}},(typeof e=="string"?l.getElements(e,s):e).forEach((o,n)=>{S.isDraggable(o)||S.dragIn(o,t),i!=null&&i[n]&&(o.gridstackNode=i[n])})}movable(e,t){return this.opts.staticGrid?this:(p.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:(p.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&&p._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return S.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 S.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 b=o.getBoundingClientRect();o.style.left=b.x+(this.dragTransform.xScale-1)*(s.clientX-b.x)/this.dragTransform.xScale+"px",o.style.top=b.y+(this.dragTransform.yScale-1)*(s.clientY-b.y)/this.dragTransform.yScale+"px",o.style.transformOrigin="0px 0px"}let{top:h,left:d}=o.getBoundingClientRect();const c=this.el.getBoundingClientRect();d-=c.left,h-=c.top;const u={position:{top:h*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(h/e)),delete n.autoPosition,this.engine.nodeBoundFix(n),!this.engine.willItFit(n)){if(n.autoPosition=!0,!this.engine.willItFit(n)){S.off(r,"drag");return}n._willFitPos&&(l.copyPos(n,n._willFitPos),delete n._willFitPos)}this._onStartMoving(o,s,u,n,t,e)}else this._dragOrResize(o,s,u,n,t,e)};return S.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 c=o.getAttribute("data-gs-widget")||o.getAttribute("gridstacknode");if(c){try{n=JSON.parse(c)}catch{console.error("Gridstack dropover: Bad JSON format: ",c)}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 h=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:h,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=h,n.h=d,n._temporaryRemoved=!0),p._itemRemoving(n.el,!1),S.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 b,E,w;const n=(o==null?void 0:o.gridstackNode)||r.gridstackNode;if((n==null?void 0:n.grid)===this&&!n._isExternal)return!1;const h=!!this.placeholder.parentElement,d=r!==o;this.placeholder.remove(),delete this.placeholder.gridstackNode;const c=h&&this.opts.animate;c&&this.setAnimation(!1);const u=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,h&&(u!=null&&u.grid)&&u.grid!==this){const m=u.grid;m.engine.removeNodeFromLayoutCache(u),m.engine.removedNodes.push(u),m._triggerRemoveEvent()._triggerChangeEvent(),m.parentGridNode&&!m.engine.nodes.length&&m.opts.subGridDynamic&&m.removeAsSubGrid()}if(!n||(h&&(this.engine.cleanupNode(n),n.grid=this),(b=n.grid)==null||delete b._isTemp,S.off(r,"drag"),o!==r?(o.remove(),r=o):r.remove(),this._removeDD(r),!h))return!1;const g=(w=(E=n.subGrid)==null?void 0:E.el)==null?void 0:w.gridstack;return l.copyPos(n,this._readAttr(this.placeholder)),l.removePositioningStyles(r),d&&(n.content||n.subGridOpts||p.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"},u&&u.grid?u:void 0,n),c&&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&&!S.isDroppable(e)&&S.droppable(e,this.opts.removableOptions).on(e,"dropover",(t,i)=>p._itemRemoving(i,!0)).on(e,"dropout",(t,i)=>p._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=(c,u)=>{this._gsEventHandler[c.type]&&this._gsEventHandler[c.type](c,c.target),r=this.cellWidth(),o=this.getCellHeight(!0),this._onStartMoving(t,c,u,e,r,o)},h=(c,u)=>{this._dragOrResize(t,c,u,e,r,o)},d=c=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete e._moving,delete e._event,delete e._lastTried;const u=e.w!==e._orig.w,g=c.target;if(!(!g.gridstackNode||g.gridstackNode.grid!==this)){if(e.el=g,e._isAboutToRemove){const b=t.gridstackNode.grid;b._gsEventHandler[c.type]&&b._gsEventHandler[c.type](c,g),b.engine.nodes.push(e),b.removeWidget(t,!0,!0)}else l.removePositioningStyles(g),e._temporaryRemoved?(l.copyPos(e,e._orig),this._writePosAttr(g,e),this.engine.addNode(e)):this._writePosAttr(g,e),this._gsEventHandler[c.type]&&this._gsEventHandler[c.type](c,g);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),c.type==="resizestop"&&(Number.isInteger(e.sizeToContent)&&(e.sizeToContent=e.h),this.resizeToContentCheck(u,e))}};S.draggable(t,{start:n,stop:d,drag:h}).resizable(t,{start:n,stop:d,resize:h}),e._initDD=!0}return S.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=l.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const h=this.placeholder.closest(".grid-stack");this.dragTransform=l.getValuesFromTransformedElement(h)}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 h=this.getColumn()-s.x,d=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-s.y;S.resizable(e,"option","minWidth",r*Math.min(s.minW||1,h)).resizable(e,"option","minHeight",o*Math.min(s.minH||1,d)).resizable(e,"option","maxWidth",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,h)).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 h,d=this.opts.marginLeft,c=this.opts.marginRight,u=this.opts.marginTop,g=this.opts.marginBottom;const b=Math.round(o*.1),E=Math.round(r*.1);if(d=Math.min(d,E),c=Math.min(c,E),u=Math.min(u,b),g=Math.min(g,b),t.type==="drag"){if(s._temporaryRemoved)return;const m=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&l.updateScrollPosition(e,i.position,m);const v=i.position.left+(i.position.left>s._lastUiPosition.left?-c:d),C=i.position.top+(i.position.top>s._lastUiPosition.top?-g:u);n.x=Math.round(v/r),n.y=Math.round(C/o);const k=this._extraDragRow;if(this.engine.collide(s,n)){const D=this.getRow();let R=Math.max(0,n.y+s.h-D);this.opts.maxRow&&D+R>this.opts.maxRow&&(R=Math.max(0,this.opts.maxRow-D)),this._extraDragRow=R}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||(l.updateScrollResize(t,e,o),n.w=Math.round((i.size.width-d)/r),n.h=Math.round((i.size.height-u)/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,v=i.position.top+u;n.x=Math.round(m/r),n.y=Math.round(v/o),h=!0}s._event=t,s._lastTried=n;const w={x:i.position.left+d,y:i.position.top+u,w:(i.size?i.size.width:s.w*r)-d-c,h:(i.size?i.size.height:s.h*o)-u-g};if(this.engine.moveNodeCheck(s,{...n,cellWidth:r,cellHeight:o,rect:w,resizing:h})){s._lastUiPosition=i.position,this.engine.cacheRects(r,o,u,c,g,d),delete s._skipDown,h&&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,S.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&&p._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):i._isExternal&&this.engine.restoreInitial()))}commit(){return $e(this,this.batchUpdate(!1),"commit","batchUpdate","5.2"),this}}p.renderCB=(f,e)=>{f&&(e!=null&&e.content)&&(f.textContent=e.content)},p.resizeToContentParent=".grid-stack-item-content",p.Utils=l,p.Engine=H,p.GDRev="11.3.0";const We=["data-index","gs-h","gs-w","gs-x","gs-y"],Ve={class:"grid-stack-item-content"},Ke=a.defineComponent({__name:"DraggableGridLayout",props:{tiles:{},gridSize:{},tileHeight:{default:200}},emits:["update-tiles"],setup(f,{emit:e}){const t=f,i=e,s=a.ref(null);let r=null;return a.onMounted(()=>{s.value&&(r=p.init({column:t.gridSize.cols,cellHeight:t.tileHeight,resizable:{handles:"all"}},s.value),r.on("change",(o,n)=>{const h=t.tiles.map((d,c)=>{const u=n.find(g=>{var b;return Number((b=g.el)==null?void 0:b.getAttribute("data-index"))===c});return u?{...d,layout:{position:{col:u.x,row:u.y},size:{cols:u.w,rows:u.h}}}:d});i("update-tiles",h)}))}),a.onUnmounted(()=>{r&&r.destroy(!1)}),a.watch(()=>t.tiles,o=>{r&&s.value&&o.forEach((n,h)=>{var c;const d=(c=s.value)==null?void 0:c.querySelector(`[data-index="${h}"]`);d&&(r==null||r.update(d,{x:n.layout.position.col,y:n.layout.position.row,w:n.layout.size.cols,h:n.layout.size.rows}))})},{deep:!0}),(o,n)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"gridContainer",ref:s,class:"grid-stack"},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(o.tiles,(h,d)=>(a.openBlock(),a.createElementBlock("div",{key:"tile-"+d,class:"grid-stack-item","data-index":d,"gs-h":h.layout.size.rows,"gs-w":h.layout.size.cols,"gs-x":h.layout.position.col,"gs-y":h.layout.position.row},[a.createElementVNode("div",Ve,[a.renderSlot(o.$slots,"tile",{tile:h})])],8,We))),128))],512))}}),Ye={class:"kong-ui-public-dashboard-renderer"},je={key:0,class:"tile-container"},Xe=I(a.defineComponent({__name:"DashboardRenderer",props:{context:{},config:{},draggable:{type:Boolean,default:!1}},emits:["edit-tile","update-tiles"],setup(f,{expose:e,emit:t}){const i=f,s=t,{i18n:r}=M.useI18n(),o=a.ref(0),n=a.inject(B);n||(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"));const h=be.useAnalyticsConfigStore(),d=a.computed(()=>i.context.timeSpec?i.context.timeSpec:{type:"relative",time_range:h.defaultQueryTimeForOrg}),c=a.computed(()=>!!i.context.timeSpec||!h.loading),u=a.computed(()=>i.config.tiles.map((m,v)=>{var k;let C=m.definition;if("description"in C.chart){const D=(k=C.chart.description)==null?void 0:k.replace(ne,()=>{const _=`renderer.trendRange.${d.value.type==="absolute"?"custom":d.value.time_range}`;return r.te(_)?r.t(_):""});C={...C,chart:{...C.chart,description:D}}}return{layout:m.layout,meta:C,id:v}})),g=a.computed(()=>{let{tz:m,refreshInterval:v,editable:C}=i.context;return m||(m=new Intl.DateTimeFormat().resolvedOptions().timeZone),v===void 0&&(v=oe),C===void 0&&(C=!1),{...i.context,tz:m,timeSpec:d.value,refreshInterval:v,editable:C}}),b=m=>{s("edit-tile",m)},E=()=>{o.value++},w=m=>{const v=m.map(C=>({layout:C.layout,definition:C.meta}));s("update-tiles",v)};return e({refresh:E}),(m,v)=>{const C=a.resolveComponent("KAlert");return a.openBlock(),a.createElementBlock("div",Ye,[a.unref(n)?(a.openBlock(),a.createBlock(a.resolveDynamicComponent(m.draggable?Ke:fe),{key:1,"grid-size":m.config.gridSize,"tile-height":m.config.tileHeight,tiles:u.value,onUpdateTiles:w},{tile:a.withCtx(({tile:k})=>[k.meta.chart.type==="slottable"?(a.openBlock(),a.createElementBlock("div",je,[a.renderSlot(m.$slots,k.meta.chart.id,{},void 0,!0)])):(a.openBlock(),a.createBlock(Pe,{key:1,class:"tile-container",context:g.value,definition:k.meta,height:k.layout.size.rows*(m.config.tileHeight||a.unref(F))+parseInt(a.unref(ue),10),"query-ready":c.value,"refresh-counter":o.value,"tile-id":k.id,onEditTile:D=>b(k)},null,8,["context","definition","height","query-ready","refresh-counter","tile-id","onEditTile"]))]),_:3},40,["grid-size","tile-height","tiles"])):(a.openBlock(),a.createBlock(C,{key:0,appearance:"danger"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(a.unref(r).t("renderer.noQueryBridge")),1)]),_:1}))])}}}),[["__scopeId","data-v-57e1dfb8"]]);x.CP_ID_TOKEN=re,x.DEFAULT_TILE_HEIGHT=F,x.DEFAULT_TILE_REFRESH_INTERVAL_MS=oe,x.DashboardRenderer=Xe,x.ENTITY_ID_TOKEN=X,x.GridLayout=fe,x.INJECT_QUERY_PROVIDER=B,x.TIMEFRAME_TOKEN=ne,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
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")||p.addRemoveCB)&&(p.addRemoveCB?i=p.addRemoveCB(e,t,!0,!0):i=l.createDiv(["grid-stack",t.class],e)),p.init(t,i)}static registerEngine(e){p.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=l.createDiv([this.opts.placeholderClass,S.itemClass,this.opts.itemClass]);const e=l.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,t={}){var u,g,b;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=l.toNumber(e.getAttribute("gs-row"));t.column==="auto"&&delete t.column,t.alwaysShowResizeHandle!==void 0&&(t._alwaysShowResizeHandle=t.alwaysShowResizeHandle);let s=(u=t.columnOpts)==null?void 0:u.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 E=r.oneColumnSize||768;delete r.oneColumnSize,delete r.disableOneColumnMode,t.columnOpts=t.columnOpts||{},s=t.columnOpts.breakpoints=t.columnOpts.breakpoints||[];let w=s.find(_=>_.c===1);w?w.w=E:(w={c:1,w:E},s.push(w,{c:12,w:E+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((E,w)=>(w.w||0)-(E.w||0));const n={...l.cloneDeep(S),column:l.toNumber(e.getAttribute("gs-column"))||S.column,minRow:i||l.toNumber(e.getAttribute("gs-min-row"))||S.minRow,maxRow:i||l.toNumber(e.getAttribute("gs-max-row"))||S.maxRow,staticGrid:l.toBool(e.getAttribute("gs-static"))||S.staticGrid,sizeToContent:l.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(t.handleClass?"."+t.handleClass:t.handle?t.handle:"")||S.draggable.handle},removableOptions:{accept:t.itemClass||S.removableOptions.accept,decline:S.removableOptions.decline}};e.getAttribute("gs-animate")&&(n.animate=l.toBool(e.getAttribute("gs-animate"))),t=l.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 h=this.el.closest("."+S.itemClass),d=h==null?void 0:h.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!==S.cellHeightUnit&&(t.cellHeight=t.cellHeight+t.cellHeightUnit,delete t.cellHeightUnit),this.cellHeight(t.cellHeight,!1)),t.alwaysShowResizeHandle==="mobile"&&(t.alwaysShowResizeHandle=z),this._styleSheetClass="gs-id-"+N._idSeq++,this.el.classList.add(this._styleSheetClass),this._setStaticClass();const c=t.engineClass||p.engineClass||N;if(this.engine=new c({column:this.getColumn(),float:t.float,maxRow:t.maxRow,onChange:E=>{let w=0;this.engine.nodes.forEach(_=>{w=Math.max(w,_.y+_.h)}),E.forEach(_=>{const v=_.el;v&&(_._removeDOM?(v&&v.remove(),delete _._removeDOM):this._writePosAttr(v,_))}),this._updateStyles(!1,w)}}),this._updateStyles(!1,0),t.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(E=>this._prepareElement(E)),delete this.engine._loading,this.batchUpdate(!1)),t.children){const E=t.children;delete t.children,E.length&&this.load(E)}this.setAnimation(),t.subGridDynamic&&!y.pauseDrag&&(y.pauseDrag=!0),((b=t.draggable)==null?void 0:b.pause)!==void 0&&(y.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:p.addRemoveCB?t=p.addRemoveCB(this.el,e,!0,!1):t=l.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 l.defaults(e,s),this.engine.prepareNode(e),this.el.appendChild(t),this.makeWidget(t,e),t}makeSubGrid(e,t,i,s=!0){var b,E,w;let r=e.gridstackNode;if(r||(r=this.makeWidget(e).gridstackNode),(b=r.subGrid)!=null&&b.el)return r.subGrid;let o,n=this;for(;n&&!o;)o=(E=n.opts)==null?void 0:E.subGridOpts,n=(w=n.parentGridNode)==null?void 0:w.grid;t=l.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 h;t.column==="auto"&&(h=!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"),c,u;if(s&&(this._removeDD(r.el),u={...r,x:0,y:0},l.removeInternalForSave(u),delete u.subGridOpts,r.content&&(u.content=r.content,delete r.content),p.addRemoveCB?c=p.addRemoveCB(this.el,u,!0,!1):(c=l.createDiv(["grid-stack-item"]),c.appendChild(d),d=l.createDiv(["grid-stack-item-content"],r.el)),this._prepareDragDropByNode(r)),i){const _=h?t.column:r.w,v=r.h+i.h,x=r.el.style;x.transition="none",this.update(r.el,{w:_,h:v}),setTimeout(()=>x.transition=null)}const g=r.subGrid=p.addGrid(d,t);return i!=null&&i._moving&&(g._isTemp=!0),h&&(g._autoColumn=!0),s&&g.makeWidget(c,u),i&&(i._moving?window.setTimeout(()=>l.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(()=>l.simulateMouseEvent(e._event,"mouseenter",t.el),0))}save(e=!0,t=!1,i=p.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=l.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,l.removeInternalAndSame(r,S),r.children=s,r}return s}load(e,t=p.addRemoveCB||!0){var d;e=l.cloneDeep(e);const i=this.getColumn();e.forEach(c=>{c.w=c.w||1,c.h=c.h||1}),e=l.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let s=0;e.forEach(c=>{s=Math.max(s,(c.x||0)+c.w)}),s>this.engine.defaultColumn&&(this.engine.defaultColumn=s),s>i&&this.engine.cacheLayout(e,s,!0);const r=p.addRemoveCB;typeof t=="function"&&(p.addRemoveCB=t);const o=[];this.batchUpdate();const n=!this.engine.nodes.length;n&&this.setAnimation(!1),!n&&t&&[...this.engine.nodes].forEach(u=>{if(!u.id)return;l.find(e,u.id)||(p.addRemoveCB&&p.addRemoveCB(this.el,u,!1,!1),o.push(u),this.removeWidget(u.el,!0,!1))}),this.engine._loading=!0;const h=[];return this.engine.nodes=this.engine.nodes.filter(c=>l.find(e,c.id)?(h.push(c),!1):!0),e.forEach(c=>{var g;const u=l.find(h,c.id);if(u){if(l.shouldSizeToContent(u)&&(c.h=u.h),this.engine.nodeBoundFix(c),(c.autoPosition||c.x===void 0||c.y===void 0)&&(c.w=c.w||u.w,c.h=c.h||u.h,this.engine.findEmptyPosition(c)),this.engine.nodes.push(u),l.samePos(u,c)&&this.engine.nodes.length>1&&(this.moveNode(u,{...c,forceCollide:!0}),l.copyPos(c,u)),this.update(u.el,c),(g=c.subGridOpts)!=null&&g.children){const b=u.el.querySelector(".grid-stack");b&&b.gridstack&&b.gridstack.load(c.subGridOpts.children)}}else t&&this.addWidget(c)}),delete this.engine._loading,this.engine.removedNodes=o,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,r?p.addRemoveCB=r:delete p.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=l.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=l.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(h=>h.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(),h=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/n),y:Math.floor(o/h)}}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=p.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?(p.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&&p.addRemoveCB&&p.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&&p.addRemoveCB&&p.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 p.getElements(e).forEach(i=>{var c;const s=i==null?void 0:i.gridstackNode;if(!s)return;const r=l.cloneDeep(t);this.engine.nodeBoundFix(r),delete r.autoPosition;const o=["x","y","w","h"];let n;if(o.some(u=>r[u]!==void 0&&r[u]!==s[u])&&(n={},o.forEach(u=>{n[u]=r[u]!==void 0?r[u]:s[u],delete r[u]})),!n&&(r.minW||r.minH||r.maxW||r.maxH)&&(n={}),r.content!==void 0){const u=i.querySelector(".grid-stack-item-content");u&&u.textContent!==r.content&&(s.content=r.content,p.renderCB(u,r),(c=s.subGrid)!=null&&c.el&&(u.appendChild(s.subGrid.el),s.subGrid.opts.styleInHead||s.subGrid._updateStyles(!0))),delete r.content}let h=!1,d=!1;for(const u in r)u[0]!=="_"&&s[u]!==r[u]&&(s[u]=r[u],h=!0,d=d||!this.opts.staticGrid&&(u==="noResize"||u==="noMove"||u==="locked"));if(l.sanitizeMinMax(s),n){const u=n.w!==void 0&&n.w!==s.w;this.moveNode(s,n),u&&s.subGrid?s.subGrid.onResize(this.hasAnimationCSS()?s.w:void 0):this.resizeToContentCheck(u,s),delete s._orig}(n||h)&&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,b;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(p.resizeToContentParent)),!o)return;const n=e.clientHeight-o.clientHeight,h=t.h?t.h*s-n:o.clientHeight;let d;if(t.subGrid){d=t.subGrid.getRow()*t.subGrid.getCellHeight(!0);const E=t.subGrid.el.getBoundingClientRect(),w=t.subGrid.el.parentElement.getBoundingClientRect();d+=E.top-w.top}else{if((b=(g=t.subGridOpts)==null?void 0:g.children)!=null&&b.length)return;{const E=o.firstElementChild;if(!E){console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${p.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}d=E.getBoundingClientRect().height||h}}if(h===d)return;r+=d-h;let c=Math.ceil(r/s);const u=Number.isInteger(t.sizeToContent)?t.sizeToContent:0;u&&c>u&&(c=u,e.classList.add("size-to-content-max")),t.minH&&c<t.minH?c=t.minH:t.maxH&&c>t.maxH&&(c=t.maxH),c!==t.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(t,{h:c}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){p.resizeToContentCB?p.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,t){return p.getElements(e).forEach(i=>{const s=i.gridstackNode;if(!l.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,h=t.top>0?Math.floor(t.top/this.opts.cellHeight):0;r.x=s.x+n-(s.h-(h+1)),r.y=s.y+h-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=l.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;l.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=l.createStylesheet(this._styleSheetClass,o,{nonce:this.opts.nonce}),!this._styles)return this;this._styles._max=0,l.addCSSRule(this._styles,r,`height: ${i}${s}`);const n=this.opts.marginTop+this.opts.marginUnit,h=this.opts.marginBottom+this.opts.marginUnit,d=this.opts.marginRight+this.opts.marginUnit,c=this.opts.marginLeft+this.opts.marginUnit,u=`${r} > .grid-stack-item-content`,g=`.${this._styleSheetClass} > .grid-stack-placeholder > .placeholder-content`;l.addCSSRule(this._styles,u,`top: ${n}; right: ${d}; bottom: ${h}; left: ${c};`),l.addCSSRule(this._styles,g,`top: ${n}; right: ${d}; bottom: ${h}; left: ${c};`),l.addCSSRule(this._styles,`${r} > .ui-resizable-n`,`top: ${n};`),l.addCSSRule(this._styles,`${r} > .ui-resizable-s`,`bottom: ${h}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-ne`,`right: ${d}; top: ${n}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-e`,`right: ${d}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-se`,`right: ${d}; bottom: ${h}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-nw`,`left: ${c}; top: ${n}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-w`,`left: ${c}`),l.addCSSRule(this._styles,`${r} > .ui-resizable-sw`,`left: ${c}; bottom: ${h}`)}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++)l.addCSSRule(this._styles,`${r}[gs-y="${n}"]`,`top: ${o(n)}`),l.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=l.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&&l.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(S.itemClass,this.opts.itemClass);const s=l.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=l.toNumber(e.getAttribute("gs-x")),i.y=l.toNumber(e.getAttribute("gs-y")),i.w=l.toNumber(e.getAttribute("gs-w")),i.h=l.toNumber(e.getAttribute("gs-h")),i.autoPosition=l.toBool(e.getAttribute("gs-auto-position")),i.noResize=l.toBool(e.getAttribute("gs-no-resize")),i.noMove=l.toBool(e.getAttribute("gs-no-move")),i.locked=l.toBool(e.getAttribute("gs-locked")),i.sizeToContent=l.toBool(e.getAttribute("gs-size-to-content")),i.id=e.getAttribute("gs-id"),i.maxW=l.toNumber(e.getAttribute("gs-max-w")),i.minW=l.toNumber(e.getAttribute("gs-min-w")),i.maxH=l.toNumber(e.getAttribute("gs-max-h")),i.minH=l.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)l.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el);else if(this.engine.nodes.some(i=>l.shouldSizeToContent(i))){const i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{l.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=l.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 l.getElement(e)}static getElements(e=".grid-stack-item"){return l.getElements(e)}static getGridElement(e){return p.getElement(e)}static getGridElements(e){return l.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=l.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=l.parseHeight(this.opts.marginTop),this.opts.marginTop=e.h,delete this.opts.margin),this.opts.marginBottom===void 0?this.opts.marginBottom=t:(e=l.parseHeight(this.opts.marginBottom),this.opts.marginBottom=e.h,delete this.opts.margin),this.opts.marginRight===void 0?this.opts.marginRight=t:(e=l.parseHeight(this.opts.marginRight),this.opts.marginRight=e.h,delete this.opts.margin),this.opts.marginLeft===void 0?this.opts.marginLeft=t:(e=l.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 T}static setupDragIn(e,t,i,s=document){(t==null?void 0:t.pause)!==void 0&&(y.pauseDrag=t.pause),t={appendTo:"body",helper:"clone",...t||{}},(typeof e=="string"?l.getElements(e,s):e).forEach((o,n)=>{T.isDraggable(o)||T.dragIn(o,t),i!=null&&i[n]&&(o.gridstackNode=i[n])})}movable(e,t){return this.opts.staticGrid?this:(p.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:(p.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&&p._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return T.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 T.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 b=o.getBoundingClientRect();o.style.left=b.x+(this.dragTransform.xScale-1)*(s.clientX-b.x)/this.dragTransform.xScale+"px",o.style.top=b.y+(this.dragTransform.yScale-1)*(s.clientY-b.y)/this.dragTransform.yScale+"px",o.style.transformOrigin="0px 0px"}let{top:h,left:d}=o.getBoundingClientRect();const c=this.el.getBoundingClientRect();d-=c.left,h-=c.top;const u={position:{top:h*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(h/e)),delete n.autoPosition,this.engine.nodeBoundFix(n),!this.engine.willItFit(n)){if(n.autoPosition=!0,!this.engine.willItFit(n)){T.off(r,"drag");return}n._willFitPos&&(l.copyPos(n,n._willFitPos),delete n._willFitPos)}this._onStartMoving(o,s,u,n,t,e)}else this._dragOrResize(o,s,u,n,t,e)};return T.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 c=o.getAttribute("data-gs-widget")||o.getAttribute("gridstacknode");if(c){try{n=JSON.parse(c)}catch{console.error("Gridstack dropover: Bad JSON format: ",c)}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 h=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:h,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=h,n.h=d,n._temporaryRemoved=!0),p._itemRemoving(n.el,!1),T.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 b,E,w;const n=(o==null?void 0:o.gridstackNode)||r.gridstackNode;if((n==null?void 0:n.grid)===this&&!n._isExternal)return!1;const h=!!this.placeholder.parentElement,d=r!==o;this.placeholder.remove(),delete this.placeholder.gridstackNode;const c=h&&this.opts.animate;c&&this.setAnimation(!1);const u=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,h&&(u!=null&&u.grid)&&u.grid!==this){const _=u.grid;_.engine.removeNodeFromLayoutCache(u),_.engine.removedNodes.push(u),_._triggerRemoveEvent()._triggerChangeEvent(),_.parentGridNode&&!_.engine.nodes.length&&_.opts.subGridDynamic&&_.removeAsSubGrid()}if(!n||(h&&(this.engine.cleanupNode(n),n.grid=this),(b=n.grid)==null||delete b._isTemp,T.off(r,"drag"),o!==r?(o.remove(),r=o):r.remove(),this._removeDD(r),!h))return!1;const g=(w=(E=n.subGrid)==null?void 0:E.el)==null?void 0:w.gridstack;return l.copyPos(n,this._readAttr(this.placeholder)),l.removePositioningStyles(r),d&&(n.content||n.subGridOpts||p.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"},u&&u.grid?u:void 0,n),c&&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&&!T.isDroppable(e)&&T.droppable(e,this.opts.removableOptions).on(e,"dropover",(t,i)=>p._itemRemoving(i,!0)).on(e,"dropout",(t,i)=>p._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=(c,u)=>{this._gsEventHandler[c.type]&&this._gsEventHandler[c.type](c,c.target),r=this.cellWidth(),o=this.getCellHeight(!0),this._onStartMoving(t,c,u,e,r,o)},h=(c,u)=>{this._dragOrResize(t,c,u,e,r,o)},d=c=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete e._moving,delete e._event,delete e._lastTried;const u=e.w!==e._orig.w,g=c.target;if(!(!g.gridstackNode||g.gridstackNode.grid!==this)){if(e.el=g,e._isAboutToRemove){const b=t.gridstackNode.grid;b._gsEventHandler[c.type]&&b._gsEventHandler[c.type](c,g),b.engine.nodes.push(e),b.removeWidget(t,!0,!0)}else l.removePositioningStyles(g),e._temporaryRemoved?(l.copyPos(e,e._orig),this._writePosAttr(g,e),this.engine.addNode(e)):this._writePosAttr(g,e),this._gsEventHandler[c.type]&&this._gsEventHandler[c.type](c,g);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),c.type==="resizestop"&&(Number.isInteger(e.sizeToContent)&&(e.sizeToContent=e.h),this.resizeToContentCheck(u,e))}};T.draggable(t,{start:n,stop:d,drag:h}).resizable(t,{start:n,stop:d,resize:h}),e._initDD=!0}return T.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=l.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const h=this.placeholder.closest(".grid-stack");this.dragTransform=l.getValuesFromTransformedElement(h)}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 h=this.getColumn()-s.x,d=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-s.y;T.resizable(e,"option","minWidth",r*Math.min(s.minW||1,h)).resizable(e,"option","minHeight",o*Math.min(s.minH||1,d)).resizable(e,"option","maxWidth",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,h)).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 h,d=this.opts.marginLeft,c=this.opts.marginRight,u=this.opts.marginTop,g=this.opts.marginBottom;const b=Math.round(o*.1),E=Math.round(r*.1);if(d=Math.min(d,E),c=Math.min(c,E),u=Math.min(u,b),g=Math.min(g,b),t.type==="drag"){if(s._temporaryRemoved)return;const _=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&l.updateScrollPosition(e,i.position,_);const v=i.position.left+(i.position.left>s._lastUiPosition.left?-c:d),x=i.position.top+(i.position.top>s._lastUiPosition.top?-g:u);n.x=Math.round(v/r),n.y=Math.round(x/o);const k=this._extraDragRow;if(this.engine.collide(s,n)){const D=this.getRow();let R=Math.max(0,n.y+s.h-D);this.opts.maxRow&&D+R>this.opts.maxRow&&(R=Math.max(0,this.opts.maxRow-D)),this._extraDragRow=R}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||(l.updateScrollResize(t,e,o),n.w=Math.round((i.size.width-d)/r),n.h=Math.round((i.size.height-u)/o),s.w===n.w&&s.h===n.h)||s._lastTried&&s._lastTried.w===n.w&&s._lastTried.h===n.h)return;const _=i.position.left+d,v=i.position.top+u;n.x=Math.round(_/r),n.y=Math.round(v/o),h=!0}s._event=t,s._lastTried=n;const w={x:i.position.left+d,y:i.position.top+u,w:(i.size?i.size.width:s.w*r)-d-c,h:(i.size?i.size.height:s.h*o)-u-g};if(this.engine.moveNodeCheck(s,{...n,cellWidth:r,cellHeight:o,rect:w,resizing:h})){s._lastUiPosition=i.position,this.engine.cacheRects(r,o,u,c,g,d),delete s._skipDown,h&&s.subGrid&&s.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const _=t.target;this._writePosAttr(_,s),this._gsEventHandler[t.type]&&this._gsEventHandler[t.type](t,_)}}_leave(e,t){t=t||e;const i=t.gridstackNode;i&&(t.style.transform=t.style.transformOrigin=null,T.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&&p._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):i._isExternal&&this.engine.restoreInitial()))}commit(){return $e(this,this.batchUpdate(!1),"commit","batchUpdate","5.2"),this}}p.renderCB=(f,e)=>{f&&(e!=null&&e.content)&&(f.textContent=e.content)},p.resizeToContentParent=".grid-stack-item-content",p.Utils=l,p.Engine=N,p.GDRev="11.3.0";const Ve=["data-index","gs-h","gs-w","gs-x","gs-y"],Ke={class:"grid-stack-item-content"},Ye=a.defineComponent({__name:"DraggableGridLayout",props:{tiles:{},gridSize:{},tileHeight:{default:200}},emits:["update-tiles"],setup(f,{emit:e}){const t=f,i=e,s=a.ref(null);let r=null;return a.onMounted(()=>{s.value&&(r=p.init({column:t.gridSize.cols,cellHeight:t.tileHeight,resizable:{handles:"all"}},s.value),r.on("change",(o,n)=>{const h=t.tiles.map((d,c)=>{const u=n.find(g=>{var b;return Number((b=g.el)==null?void 0:b.getAttribute("data-index"))===c});return u?{...d,layout:{position:{col:u.x,row:u.y},size:{cols:u.w,rows:u.h}}}:d});i("update-tiles",h)}))}),a.onUnmounted(()=>{r&&r.destroy(!1)}),a.watch(()=>t.tiles,o=>{r&&s.value&&o.forEach((n,h)=>{var c;const d=(c=s.value)==null?void 0:c.querySelector(`[data-index="${h}"]`);d&&(r==null||r.update(d,{x:n.layout.position.col,y:n.layout.position.row,w:n.layout.size.cols,h:n.layout.size.rows}))})},{deep:!0}),(o,n)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"gridContainer",ref:s,class:"grid-stack"},[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(o.tiles,(h,d)=>(a.openBlock(),a.createElementBlock("div",{key:"tile-"+d,class:"grid-stack-item","data-index":d,"gs-h":h.layout.size.rows,"gs-w":h.layout.size.cols,"gs-x":h.layout.position.col,"gs-y":h.layout.position.row},[a.createElementVNode("div",Ke,[a.renderSlot(o.$slots,"tile",{tile:h})])],8,Ve))),128))],512))}}),je={class:"kong-ui-public-dashboard-renderer"},Xe={key:0,class:"tile-container"},Qe=P(a.defineComponent({__name:"DashboardRenderer",props:{context:{},config:{},draggable:{type:Boolean,default:!1}},emits:["edit-tile","update-tiles"],setup(f,{expose:e,emit:t}){const i=f,s=t,{i18n:r}=O.useI18n(),o=a.ref(0),n=a.inject(I);n||(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"));const h=we.useAnalyticsConfigStore(),d=a.computed(()=>i.context.timeSpec?i.context.timeSpec:{type:"relative",time_range:h.defaultQueryTimeForOrg}),c=a.computed(()=>!!i.context.timeSpec||!h.loading),u=a.computed(()=>i.config.tiles.map((_,v)=>{var k;let x=_.definition;if("description"in x.chart){const D=(k=x.chart.description)==null?void 0:k.replace(oe,()=>{const M=`renderer.trendRange.${d.value.type==="absolute"?"custom":d.value.time_range}`;return r.te(M)?r.t(M):""});x={...x,chart:{...x.chart,description:D}}}return{layout:_.layout,meta:x,id:v}})),g=a.computed(()=>{let{tz:_,refreshInterval:v,editable:x}=i.context;return _||(_=new Intl.DateTimeFormat().resolvedOptions().timeZone),v===void 0&&(v=ae),x===void 0&&(x=!1),{...i.context,tz:_,timeSpec:d.value,refreshInterval:v,editable:x}}),b=_=>{s("edit-tile",_)},E=()=>{o.value++},w=_=>{const v=_.map(x=>({layout:x.layout,definition:x.meta}));s("update-tiles",v)};return e({refresh:E}),(_,v)=>{const x=a.resolveComponent("KAlert");return a.openBlock(),a.createElementBlock("div",je,[a.unref(n)?(a.openBlock(),a.createBlock(a.resolveDynamicComponent(_.draggable?Ye:ge),{key:1,"grid-size":_.config.gridSize,"tile-height":_.config.tileHeight,tiles:u.value,onUpdateTiles:w},{tile:a.withCtx(({tile:k})=>[k.meta.chart.type==="slottable"?(a.openBlock(),a.createElementBlock("div",Xe,[a.renderSlot(_.$slots,k.meta.chart.id,{},void 0,!0)])):(a.openBlock(),a.createBlock(qe,{key:1,class:"tile-container",context:g.value,definition:k.meta,height:k.layout.size.rows*(_.config.tileHeight||a.unref(G))+parseInt(a.unref(fe),10),"query-ready":c.value,"refresh-counter":o.value,"tile-id":k.id,onEditTile:D=>b(k)},null,8,["context","definition","height","query-ready","refresh-counter","tile-id","onEditTile"]))]),_:3},40,["grid-size","tile-height","tiles"])):(a.openBlock(),a.createBlock(x,{key:0,appearance:"danger"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(a.unref(r).t("renderer.noQueryBridge")),1)]),_:1}))])}}}),[["__scopeId","data-v-57e1dfb8"]]);C.CP_ID_TOKEN=ne,C.DEFAULT_TILE_HEIGHT=G,C.DEFAULT_TILE_REFRESH_INTERVAL_MS=ae,C.DashboardRenderer=Qe,C.ENTITY_ID_TOKEN=X,C.GridLayout=ge,C.INJECT_QUERY_PROVIDER=I,C.TIMEFRAME_TOKEN=oe,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});