@mxtommy/kip 4.7.0 → 4.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +3 -0
  3. package/README.md +37 -29
  4. package/package.json +23 -34
  5. package/plugin/history-series.service.js +108 -11
  6. package/plugin/index.js +170 -44
  7. package/plugin/kip-series-contract.js +18 -1
  8. package/plugin/openApi.json +75 -7
  9. package/public/3rdpartylicenses.txt +0 -26
  10. package/public/assets/help-docs/contributing-widgets.md +40 -0
  11. package/public/assets/help-docs/dashboards.md +8 -0
  12. package/public/assets/help-docs/menu.json +4 -2
  13. package/public/assets/svg/icons.svg +48 -1
  14. package/public/assets/svg/symbols.svg +68 -0
  15. package/public/{chunk-PKB75FW2.js → chunk-2TP7C66X.js} +1 -1
  16. package/public/chunk-3SJSLBCV.js +6 -0
  17. package/public/chunk-5SMHTIVS.js +50 -0
  18. package/public/{chunk-E3ROX3JL.js → chunk-6ISGIPNP.js} +1 -1
  19. package/public/chunk-6ZR3M3IQ.js +3 -0
  20. package/public/{chunk-6LPU67GV.js → chunk-ACY7HYMZ.js} +1 -1
  21. package/public/{chunk-E3VC75HO.js → chunk-C23GLDFH.js} +1 -1
  22. package/public/{chunk-W5RYIISE.js → chunk-CB4E7PPA.js} +1 -1
  23. package/public/{chunk-JL7DODKZ.js → chunk-DNM5XUIF.js} +1 -1
  24. package/public/{chunk-2BKBAKG4.js → chunk-GSM7FZE2.js} +2 -2
  25. package/public/{chunk-OBMTAHXF.js → chunk-HF7V6XFA.js} +1 -1
  26. package/public/{chunk-2BY2XRFX.js → chunk-HUCDJ6CS.js} +7 -7
  27. package/public/{chunk-CSJ2TU72.js → chunk-ILQQCGMJ.js} +1 -1
  28. package/public/chunk-IXUKD73N.js +5 -0
  29. package/public/{chunk-BMEO4VRV.js → chunk-JMZYPL54.js} +1 -1
  30. package/public/chunk-KG4C6HZC.js +1 -0
  31. package/public/{chunk-UBBLNNPA.js → chunk-LEY6MANN.js} +13 -13
  32. package/public/chunk-NS2OV2OW.js +9 -0
  33. package/public/{chunk-3JK476CX.js → chunk-O5BTKN5D.js} +1 -1
  34. package/public/{chunk-PDJFHMII.js → chunk-Q32FSCUX.js} +1 -1
  35. package/public/{chunk-3B5RVPSS.js → chunk-SHJMXSDM.js} +1 -1
  36. package/public/{chunk-GWAFO3MC.js → chunk-T4VTC6GW.js} +1 -1
  37. package/public/{chunk-GHPW4BPE.js → chunk-VFJD3XKT.js} +1 -1
  38. package/public/{chunk-KHZPPOSI.js → chunk-VFZSH4TC.js} +1 -1
  39. package/public/{chunk-S4UHQERA.js → chunk-W6MCE3GH.js} +1 -1
  40. package/public/index.html +1 -1
  41. package/public/main-UBENKC2D.js +1 -0
  42. package/public/polyfills-BWA36QKG.js +1 -0
  43. package/public/chunk-B2CYEVGO.js +0 -9
  44. package/public/chunk-HIXACNNV.js +0 -6
  45. package/public/chunk-QN4XMV3X.js +0 -50
  46. package/public/chunk-U5QHLGHD.js +0 -1
  47. package/public/chunk-WYC65OAX.js +0 -5
  48. package/public/chunk-XFHXLFTX.js +0 -3
  49. package/public/main-WGYSOKJC.js +0 -1
  50. package/public/polyfills-L4FJGPOC.js +0 -2
@@ -1 +1 @@
1
- import{a as H}from"./chunk-OBMTAHXF.js";import{d as U,e as F,h as O,i as V,j as A,k as P,n as G,o as Y,u as j,w as K}from"./chunk-CSJ2TU72.js";import{A as R,B as q,M as k,P as z,p as L,t as N,u as W,x as B}from"./chunk-PKB75FW2.js";import{$b as h,Db as l,Eb as e,Fb as t,Gb as m,Nb as b,Pb as v,Rb as D,Wa as a,ec as n,fc as E,gb as w,gc as I,he as T,kc as f,lc as M,mc as C,qa as g,tc as _,va as u,wa as c,xb as S,yb as x}from"./chunk-UBBLNNPA.js";var J=()=>({standalone:!1});function Q(o,X){if(o&1&&(e(0,"div",3),m(1,"i",10),n(2),t()),o&2){let p=D();a(2),I(" ",p.data.error," ")}}var de=(()=>{class o{dialogRef=g(U);data=g(F);titleDialog="Sign in to Signal K";saveCredential(){this.data.error=null,this.dialogRef.close(this.data)}static \u0275fac=function(d){return new(d||o)};static \u0275cmp=w({type:o,selectors:[["app-modal-user-credential"]],decls:26,vars:10,consts:[["login","ngForm"],["name","login",3,"ngSubmit"],["mat-dialog-title",""],[1,"errorMsgBox"],[1,"login-grid"],[1,"userLoginInput"],["type","text","autocomplete","username","id","username","matInput","","placeholder","User ID","name","username","required","",3,"ngModelChange","ngModel","ngModelOptions"],["type","password","autocomplete","current-password","autocapitalize","off","autocorrect","off","spellcheck","false","id","current-password","matInput","","placeholder","Password","name","current-password","required","",3,"ngModelChange","ngModel","ngModelOptions"],["mat-flat-button","","type","button",3,"mat-dialog-close"],["mat-flat-button","","type","submit",3,"disabled"],["aria-hidden","true",1,"fa-solid","fa-times-circle",2,"color","red","padding-right","5px"]],template:function(d,i){if(d&1){let s=b();e(0,"form",1,0),v("ngSubmit",function(){return i.saveCredential()}),e(2,"span",2),n(3),t(),e(4,"mat-dialog-content"),S(5,Q,3,1,"div",3),m(6,"br"),e(7,"div",4)(8,"mat-form-field",5)(9,"mat-label"),n(10,"User ID"),t(),e(11,"input",6),C("ngModelChange",function(r){return u(s),M(i.data.user,r)||(i.data.user=r),c(r)}),t(),e(12,"mat-error"),n(13," You must enter a User ID value "),t()(),e(14,"mat-form-field",5)(15,"mat-label"),n(16,"Password"),t(),e(17,"input",7),C("ngModelChange",function(r){return u(s),M(i.data.password,r)||(i.data.password=r),c(r)}),t(),e(18,"mat-error"),n(19," You must enter a password value "),t()()()(),m(20,"mat-divider"),e(21,"mat-dialog-actions")(22,"button",8),n(23,"Cancel"),t(),e(24,"button",9),n(25,"Sign in"),t()()()}if(d&2){let s=h(1);a(3),E(i.titleDialog),a(2),x(i.data.error?5:-1),a(6),f("ngModel",i.data.user),l("ngModelOptions",_(8,J)),a(6),f("ngModel",i.data.password),l("ngModelOptions",_(9,J)),a(5),l("mat-dialog-close",!1),a(2),l("disabled",!s.valid)}},dependencies:[z,q,L,N,W,k,R,B,V,A,j,G,K,Y,H,P,T,O],styles:[".errorMsgBox[_ngcontent-%COMP%]{background-color:#fff8dc;color:#2f4f4f;display:flex;padding:5px;font-family:Arial,Times,serif;font-size:14px}.login-grid[_ngcontent-%COMP%]{display:grid;gap:10px;padding-left:10px;padding-right:10px}.userLoginInput[_ngcontent-%COMP%]{margin-bottom:10px}"]})}return o})();export{de as a};
1
+ import{a as H}from"./chunk-HF7V6XFA.js";import{d as U,e as F,h as O,i as V,j as A,k as P,n as G,o as Y,u as j,w as K}from"./chunk-ILQQCGMJ.js";import{A as R,B as q,M as k,P as z,p as L,t as N,u as W,x as B}from"./chunk-2TP7C66X.js";import{$b as h,Db as l,Eb as e,Fb as t,Gb as m,Nb as b,Pb as v,Rb as D,Wa as a,ec as n,fc as E,gb as w,gc as I,ie as T,kc as f,lc as M,mc as C,qa as g,tc as _,va as u,wa as c,xb as S,yb as x}from"./chunk-LEY6MANN.js";var J=()=>({standalone:!1});function Q(o,X){if(o&1&&(e(0,"div",3),m(1,"i",10),n(2),t()),o&2){let p=D();a(2),I(" ",p.data.error," ")}}var de=(()=>{class o{dialogRef=g(U);data=g(F);titleDialog="Sign in to Signal K";saveCredential(){this.data.error=null,this.dialogRef.close(this.data)}static \u0275fac=function(d){return new(d||o)};static \u0275cmp=w({type:o,selectors:[["app-modal-user-credential"]],decls:26,vars:10,consts:[["login","ngForm"],["name","login",3,"ngSubmit"],["mat-dialog-title",""],[1,"errorMsgBox"],[1,"login-grid"],[1,"userLoginInput"],["type","text","autocomplete","username","id","username","matInput","","placeholder","User ID","name","username","required","",3,"ngModelChange","ngModel","ngModelOptions"],["type","password","autocomplete","current-password","autocapitalize","off","autocorrect","off","spellcheck","false","id","current-password","matInput","","placeholder","Password","name","current-password","required","",3,"ngModelChange","ngModel","ngModelOptions"],["mat-flat-button","","type","button",3,"mat-dialog-close"],["mat-flat-button","","type","submit",3,"disabled"],["aria-hidden","true",1,"fa-solid","fa-times-circle",2,"color","red","padding-right","5px"]],template:function(d,i){if(d&1){let s=b();e(0,"form",1,0),v("ngSubmit",function(){return i.saveCredential()}),e(2,"span",2),n(3),t(),e(4,"mat-dialog-content"),S(5,Q,3,1,"div",3),m(6,"br"),e(7,"div",4)(8,"mat-form-field",5)(9,"mat-label"),n(10,"User ID"),t(),e(11,"input",6),C("ngModelChange",function(r){return u(s),M(i.data.user,r)||(i.data.user=r),c(r)}),t(),e(12,"mat-error"),n(13," You must enter a User ID value "),t()(),e(14,"mat-form-field",5)(15,"mat-label"),n(16,"Password"),t(),e(17,"input",7),C("ngModelChange",function(r){return u(s),M(i.data.password,r)||(i.data.password=r),c(r)}),t(),e(18,"mat-error"),n(19," You must enter a password value "),t()()()(),m(20,"mat-divider"),e(21,"mat-dialog-actions")(22,"button",8),n(23,"Cancel"),t(),e(24,"button",9),n(25,"Sign in"),t()()()}if(d&2){let s=h(1);a(3),E(i.titleDialog),a(2),x(i.data.error?5:-1),a(6),f("ngModel",i.data.user),l("ngModelOptions",_(8,J)),a(6),f("ngModel",i.data.password),l("ngModelOptions",_(9,J)),a(5),l("mat-dialog-close",!1),a(2),l("disabled",!s.valid)}},dependencies:[z,q,L,N,W,k,R,B,V,A,j,G,K,Y,H,P,T,O],styles:[".errorMsgBox[_ngcontent-%COMP%]{background-color:#fff8dc;color:#2f4f4f;display:flex;padding:5px;font-family:Arial,Times,serif;font-size:14px}.login-grid[_ngcontent-%COMP%]{display:grid;gap:10px;padding-left:10px;padding-right:10px}.userLoginInput[_ngcontent-%COMP%]{margin-bottom:10px}"]})}return o})();export{de as a};
@@ -0,0 +1,3 @@
1
+ import{a as ie,b as V,d as q,e as He,f as It,g as Wt,h as Ne,n as we,o as Ae,q as rt,r as Lt,s as ne,t as Bt,u as Ie,v as ae,w as Ft,x as We}from"./chunk-5SMHTIVS.js";import{c as Ht,g as oe}from"./chunk-NS2OV2OW.js";import{a as Nt,b as At,e as Le,f as Be,h as Fe,i as Gt,j as Ge}from"./chunk-W6MCE3GH.js";import{e as Ot}from"./chunk-VFJD3XKT.js";import{a as Me,d as F,i as Oe,m as Mt,n as Pt}from"./chunk-2TP7C66X.js";import{Ad as St,Ba as Q,Bb as pt,Bc as be,Cb as gt,Cc as _e,Da as A,Db as L,Dd as kt,Eb as y,Fb as _,Fc as Ct,Ga as ue,Gb as ke,Gc as $,Ha as B,Hb as J,Hc as xt,Ib as fe,Jb as ft,La as pe,Mb as mt,Nb as U,Pb as C,Qc as Et,Qe as ve,Rb as S,Re as Pe,Sb as it,Tb as Te,Te as se,Ua as dt,Ub as yt,Ue as re,V as lt,Va as Ze,Vb as me,Wa as T,Wb as Z,Xb as ee,Zb as bt,_b as _t,_c as Dt,a as m,ab as et,ac as Re,b as E,cb as Ee,db as ge,ec as v,f as D,fc as vt,gb as R,gc as wt,ib as ht,ie as Tt,je as Rt,kb as De,la as X,lb as Se,le as zt,mb as ct,nb as ut,nc as ze,oc as ye,pc as te,qa as b,va as H,wa as N,wb as tt,x as xe,xb as I,yb as W,yc as st}from"./chunk-LEY6MANN.js";var h=class l{static getElements(o,e=document){if(typeof o=="string"){let t="getElementById"in e?e:void 0;if(t&&!isNaN(+o[0])){let s=t.getElementById(o);return s?[s]:[]}let i=e.querySelectorAll(o);if(!i.length&&o[0]!=="."&&o[0]!=="#"&&(i=e.querySelectorAll("."+o),i.length||(i=e.querySelectorAll("#"+o)),!i.length)){let s=e.querySelector(`[gs-id="${o}"]`);return s?[s]:[]}return Array.from(i)}return[o]}static getElement(o,e=document){if(typeof o=="string"){let t="getElementById"in e?e:void 0;if(!o.length)return null;if(t&&o[0]==="#")return t.getElementById(o.substring(1));if(o[0]==="#"||o[0]==="."||o[0]==="[")return e.querySelector(o);if(t&&!isNaN(+o[0]))return t.getElementById(o);let i=e.querySelector(o);return t&&!i&&(i=t.getElementById(o)),i||(i=e.querySelector("."+o)),i}return o}static lazyLoad(o){return o.lazyLoad||o.grid?.opts?.lazyLoad&&o.lazyLoad!==!1}static createDiv(o,e){let t=document.createElement("div");return o.forEach(i=>{i&&t.classList.add(i)}),e?.appendChild(t),t}static shouldSizeToContent(o,e=!1){return o?.grid&&(e?o.sizeToContent===!0||o.grid.opts.sizeToContent===!0&&o.sizeToContent===void 0:!!o.sizeToContent||o.grid.opts.sizeToContent&&o.sizeToContent!==!1)}static isIntercepted(o,e){return!(o.y>=e.y+e.h||o.y+o.h<=e.y||o.x+o.w<=e.x||o.x>=e.x+e.w)}static isTouching(o,e){return l.isIntercepted(o,{x:e.x-.5,y:e.y-.5,w:e.w+1,h:e.h+1})}static areaIntercept(o,e){let t=o.x>e.x?o.x:e.x,i=o.x+o.w<e.x+e.w?o.x+o.w:e.x+e.w;if(i<=t)return 0;let s=o.y>e.y?o.y:e.y,r=o.y+o.h<e.y+e.h?o.y+o.h:e.y+e.h;return r<=s?0:(i-t)*(r-s)}static area(o){return o.w*o.h}static sort(o,e=1){return o.sort((i,s)=>{let r=e*((i.y??1e4)-(s.y??1e4));return r===0?e*((i.x??1e4)-(s.x??1e4)):r})}static find(o,e){return e?o.find(t=>t.id===e):void 0}static toBool(o){return typeof o=="boolean"?o:typeof o=="string"?(o=o.toLowerCase(),!(o===""||o==="no"||o==="false"||o==="0")):!!o}static toNumber(o){return o===null||o.length===0?void 0:Number(o)}static parseHeight(o){let e,t="px";if(typeof o=="string")if(o==="auto"||o==="")e=0;else{let i=o.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!i)throw new Error(`Invalid height val = ${o}`);t=i[2]||"px",e=parseFloat(i[1])}else e=o;return{h:e,unit:t}}static defaults(o,...e){return e.forEach(t=>{for(let i in t){if(!t.hasOwnProperty(i))return;o[i]===null||o[i]===void 0?o[i]=t[i]:typeof t[i]=="object"&&typeof o[i]=="object"&&l.defaults(o[i],t[i])}}),o}static same(o,e){if(typeof o!="object")return o==e;if(typeof o!=typeof e||Object.keys(o).length!==Object.keys(e).length)return!1;for(let t in o)if(o[t]!==e[t])return!1;return!0}static copyPos(o,e,t=!1){return e.x!==void 0&&(o.x=e.x),e.y!==void 0&&(o.y=e.y),e.w!==void 0&&(o.w=e.w),e.h!==void 0&&(o.h=e.h),t&&(e.minW&&(o.minW=e.minW),e.minH&&(o.minH=e.minH),e.maxW&&(o.maxW=e.maxW),e.maxH&&(o.maxH=e.maxH)),o}static samePos(o,e){return o&&e&&o.x===e.x&&o.y===e.y&&(o.w||1)===(e.w||1)&&(o.h||1)===(e.h||1)}static sanitizeMinMax(o){o.minW||delete o.minW,o.minH||delete o.minH,o.maxW||delete o.maxW,o.maxH||delete o.maxH}static removeInternalAndSame(o,e){if(!(typeof o!="object"||typeof e!="object")&&!(Array.isArray(o)||Array.isArray(e)))for(let t in o){let i=o[t],s=e[t];t[0]==="_"||i===s?delete o[t]:i&&typeof i=="object"&&s!==void 0&&(l.removeInternalAndSame(i,s),Object.keys(i).length||delete o[t])}}static removeInternalForSave(o,e=!0){for(let t in o)(t[0]==="_"||o[t]===null||o[t]===void 0)&&delete o[t];delete o.grid,e&&delete o.el,o.autoPosition||delete o.autoPosition,o.noResize||delete o.noResize,o.noMove||delete o.noMove,o.locked||delete o.locked,(o.w===1||o.w===o.minW)&&delete o.w,(o.h===1||o.h===o.minH)&&delete o.h}static throttle(o,e){let t=!1;return(...i)=>{t||(t=!0,setTimeout(()=>{o(...i),t=!1},e))}}static removePositioningStyles(o){let e=o.style;e.position&&e.removeProperty("position"),e.left&&e.removeProperty("left"),e.top&&e.removeProperty("top"),e.width&&e.removeProperty("width"),e.height&&e.removeProperty("height")}static getScrollElement(o){if(!o)return document.scrollingElement||document.documentElement;let e=getComputedStyle(o);return/(auto|scroll)/.test(e.overflow+e.overflowY)?o:l.getScrollElement(o.parentElement)}static updateScrollPosition(o,e,t){let i=l.getScrollElement(o);if(!i)return;let s=o.getBoundingClientRect(),r=i.getBoundingClientRect(),n=window.innerHeight||document.documentElement.clientHeight,a=s.bottom-Math.min(r.bottom,n),u=s.top-Math.max(r.top,0),c=i.scrollTop;u<0&&t<0?o.offsetHeight>r.height?i.scrollTop+=t:i.scrollTop+=Math.abs(u)>Math.abs(t)?t:u:a>0&&t>0&&(o.offsetHeight>r.height?i.scrollTop+=t:i.scrollTop+=a>t?t:a),e.top+=i.scrollTop-c}static updateScrollResize(o,e,t){let i=l.getScrollElement(e),s=i.clientHeight,r=i===l.getScrollElement()?0:i.getBoundingClientRect().top,n=o.clientY-r,a=n<t,u=n>s-t;a?i.scrollBy({behavior:"smooth",top:n-t}):u&&i.scrollBy({behavior:"smooth",top:t-(s-n)})}static clone(o){return o==null||typeof o!="object"?o:o instanceof Array?[...o]:m({},o)}static cloneDeep(o){let e=["parentGrid","el","grid","subGrid","engine"],t=l.clone(o);for(let i in t)t.hasOwnProperty(i)&&typeof t[i]=="object"&&i.substring(0,2)!=="__"&&!e.find(s=>s===i)&&(t[i]=l.cloneDeep(o[i]));return t}static cloneNode(o){let e=o.cloneNode(!0);return e.removeAttribute("id"),e}static appendTo(o,e){let t;typeof e=="string"?t=l.getElement(e):t=e,t&&t.appendChild(o)}static addElStyles(o,e){if(e instanceof Object)for(let t in e)e.hasOwnProperty(t)&&(Array.isArray(e[t])?e[t].forEach(i=>{o.style[t]=i}):o.style[t]=e[t])}static initEvent(o,e){let t={type:e.type},i={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:e.target?e.target:o.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(s=>t[s]=o[s]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(s=>t[s]=o[s]),m(m({},t),i)}static simulateMouseEvent(o,e,t){let i=o,s=new MouseEvent(e,{bubbles:!0,composed:!0,cancelable:!0,view:window,detail:1,screenX:o.screenX,screenY:o.screenY,clientX:o.clientX,clientY:o.clientY,ctrlKey:i.ctrlKey??!1,altKey:i.altKey??!1,shiftKey:i.shiftKey??!1,metaKey:i.metaKey??!1,button:0,relatedTarget:o.target});(t||o.target).dispatchEvent(s)}static getValuesFromTransformedElement(o){let e=document.createElement("div");l.addElStyles(e,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),o.appendChild(e);let t=e.getBoundingClientRect();return o.removeChild(e),e.remove(),{xScale:1/t.width,yScale:1/t.height,xOffset:t.left,yOffset:t.top}}static swap(o,e,t){if(!o)return;let i=o[e];o[e]=o[t],o[t]=i}static canBeRotated(o){return!(!o||o.w===o.h||o.locked||o.noResize||o.grid?.opts.disableResize||o.minW&&o.minW===o.maxW||o.minH&&o.minH===o.maxH)}};var ot=(()=>{class l{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 n=!1,a={nested:!0,pack:!1},u=0;for(;i=i||this.collide(e,r,s.skip);){if(u++>this.nodes.length*2)throw new Error("Infinite collide check");let c;if(i.locked||this._loading||e._moving&&!e._skipDown&&t.y>e.y&&!this.float&&(!this.collide(i,E(m({},i),{y:e.y}),e)||!this.collide(i,E(m({},i),{y:t.y-i.h}),e))){e._skipDown=e._skipDown||t.y>e.y;let d=m(E(m({},t),{y:i.y+i.h}),a);c=this._loading&&h.samePos(e,d)?!0:this.moveNode(e,d),(i.locked||this._loading)&&c?h.copyPos(t,e):!i.locked&&c&&s.pack&&(this._packNodes(),t.y=i.y+i.h,h.copyPos(e,t)),n=n||c}else c=this.moveNode(i,m(E(m({},i),{y:t.y+t.h,skip:e}),a));if(!c)return n;i=void 0}return n}collide(e,t=e,i){let s=e._id,r=i?._id;return this.nodes.find(n=>n._id!==s&&n._id!==r&&h.isIntercepted(n,t))}collideAll(e,t=e,i){let s=e._id,r=i?._id;return this.nodes.filter(n=>n._id!==s&&n._id!==r&&h.isIntercepted(n,t))}directionCollideCoverage(e,t,i){if(!t.rect||!e._rect)return;let s=e._rect,r=m({},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 n,a=.5;for(let u of i){if(u.locked||!u._rect)break;let c=u._rect,d=Number.MAX_VALUE,p=Number.MAX_VALUE;s.y<c.y?d=(r.y+r.h-c.y)/c.h:s.y+s.h>c.y+c.h&&(d=(c.y+c.h-r.y)/c.h),s.x<c.x?p=(r.x+r.w-c.x)/c.w:s.x+s.w>c.x+c.w&&(p=(c.x+c.w-r.x)/c.w);let g=Math.min(p,d);g>a&&(a=g,n=u)}return t.collide=n,n}cacheRects(e,t,i,s,r,n){return this.nodes.forEach(a=>a._rect={y:a.y*t+i,x:a.x*e+n,w:a.w*e-n-s,h:a.h*t-i-r}),this}swap(e,t){if(!t||t.locked||!e||e.locked)return!1;function i(){let r=t.x,n=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=n):(e.x=r,e.y=n),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=h.isTouching(e,t)))return i();if(s!==!1){if(e.w===t.w&&e.x===t.x&&(s||(s=h.isTouching(e,t)))){if(t.y<e.y){let r=e;e=t,t=r}return i()}if(s!==!1){if(e.h===t.h&&e.y===t.y&&(s||(s=h.isTouching(e,t)))){if(t.x<e.x){let r=e;e=t,t=r}return i()}return!1}}}isAreaEmpty(e,t,i,s){let 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();let i=this.batchMode;i||this.batchUpdate();let s=this._inColumnResize;s||(this._inColumnResize=!0);let r=this.nodes;return this.nodes=[],r.forEach((n,a,u)=>{let c;n.locked||(n.autoPosition=!0,e==="list"&&a&&(c=u[a-1])),this.addNode(n,!1,c)}),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=h.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;){let 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??l._idSeq++;let i=e.id;if(i){let r=1;for(;this.nodes.find(n=>n.id===e.id&&n!==e);)e.id=i+"_"+r++}(e.x===void 0||e.y===void 0||e.x===null||e.y===null)&&(e.autoPosition=!0);let s={x:0,y:0,w:1,h:1};return h.defaults(e,s),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,h.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){let i=e._orig||h.copyPos({},e);if(e.maxW&&(e.w=Math.min(e.w||1,e.maxW)),e.maxH&&(e.h=Math.min(e.h||1,e.maxH)),e.minW&&(e.w=Math.max(e.w||1,e.minW)),e.minH&&(e.h=Math.max(e.h||1,e.minH)),(e.x||0)+(e.w||1)>this.column&&this.column<this.defaultColumn&&!this._inColumnResize&&!this.skipCacheUpdate&&e._id!=null&&this.findCacheLayout(e,this.defaultColumn)===-1){let r=m({},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),h.samePos(e,i)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(t=>t._dirty&&!h.samePos(t,t._orig)):this.nodes.filter(t=>t._dirty)}_notify(e){if(this.batchMode||!this.onChange)return this;let 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=h.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||h.samePos(e,e._orig)||(h.copyPos(e,e._orig),e._dirty=!0)}),this._notify(),this}findEmptyPosition(e,t=this.nodes,i=this.column,s){let r=s?s.y*i+(s.x+s.w):0,n=!1;for(let a=r;!n;++a){let u=a%i,c=Math.floor(a/i);if(u+e.w>i)continue;let d={x:u,y:c,w:e.w,h:e.h};t.find(p=>h.isIntercepted(d,p))||((e.x!==u||e.y!==c)&&(e._dirty=!0),e.x=u,e.y=c,delete e.autoPosition,n=!0)}return n}addNode(e,t=!1,i){let s=this.nodes.find(n=>n._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);let 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,s=new l({column:this.column,float:this.float,nodes:this.nodes.map(n=>n._id===e._id?(i=m({},n),i):m({},n))});if(!i)return!1;let r=s.moveNode(i,t)&&s.getRow()<=Math.max(this.getRow(),this.maxRow);if(!r&&!t.resizing&&t.collide){let n=t.collide.el.gridstackNode;if(this.swap(e,n))return this._notify(),!0}return r?(s.nodes.filter(n=>n._dirty).forEach(n=>{let a=this.nodes.find(u=>u._id===n._id);a&&(h.copyPos(a,n),a._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;let t=new l({column:this.column,float:this.float,nodes:this.nodes.map(s=>m({},s))}),i=m({},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=h.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){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);let s=e.w!==t.w||e.h!==t.h,r=h.copyPos({},e,!0);if(h.copyPos(r,t),this.nodeBoundFix(r,s),h.copyPos(t,r),!t.forceCollide&&h.samePos(e,t))return!1;let n=h.copyPos({},e),a=this.collideAll(e,r,t.skip),u=!0;if(a.length){let c=e._moving&&!t.nested,d=c?this.directionCollideCoverage(e,t,a):a[0];if(c&&d&&e.grid?.opts?.subGridDynamic&&!e.grid._isTemp){let p=h.areaIntercept(t.rect,d._rect),g=h.area(t.rect),w=h.area(d._rect);p/(g<w?g:w)>.8&&(d.grid.makeSubGrid(d.el,void 0,e),d=void 0)}d?u=!this._fixCollisions(e,r,d,t):(u=!1,i&&delete t.pack)}return u&&!h.samePos(e,r)&&(e._dirty=!0,h.copyPos(e,r)),t.pack&&this._packNodes()._notify(),!h.samePos(e,n)}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(){let e=this.nodes.find(t=>t._updating);return e&&(delete e._updating,delete e._skipDown),this}save(e=!0,t,i){let s=this._layouts?.length||0,r;s&&(i?i!==this.column&&(r=this._layouts[i]):this.column!==s-1&&(r=this._layouts[s-1]));let n=[];return this.sortNodes(),this.nodes.forEach(a=>{let u=r?.find(d=>d._id===a._id),c=m(m({},a),u||{});h.removeInternalForSave(c,!e),t&&t(a,c),n.push(c)}),n}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{let s=i/this.column;e.forEach(r=>{if(!r._orig)return;let n=t.find(a=>a._id===r._id);n&&(n.y>=0&&r.y!==r._orig.y&&(n.y+=r.y-r._orig.y,n.y<0&&(n.y=0)),r.x!==r._orig.x&&(n.x=Math.round(r.x*s),n.x<0&&(n.x=0)),r.w!==r._orig.w&&(n.w=Math.round(r.w*s),n.w<1&&(n.w=1)))})}}),this)}columnChanged(e,t,i="moveScale"){if(!this.nodes.length||!t||e===t)return this;let s=i==="compact"||i==="list";s&&this.sortNodes(1),t<e&&this.cacheLayout(this.nodes,e),this.batchUpdate();let r=[],n=s?this.nodes:h.sort(this.nodes,-1);if(t>e&&this._layouts){let a=this._layouts[t]||[],u=this._layouts.length-1;!a.length&&e!==u&&this._layouts[u]?.length&&(e=u,this._layouts[u].forEach(c=>{let d=n.find(p=>p._id===c._id);d&&(!s&&!c.autoPosition&&(d.x=c.x??d.x,d.y=c.y??d.y),d.w=c.w??d.w,(c.x==null||c.y===void 0)&&(d.autoPosition=!0))})),a.forEach(c=>{let d=n.findIndex(p=>p._id===c._id);if(d!==-1){let p=n[d];if(s){p.w=c.w;return}(c.autoPosition||isNaN(c.x)||isNaN(c.y))&&this.findEmptyPosition(c,r),c.autoPosition||(p.x=c.x??p.x,p.y=c.y??p.y,p.w=c.w??p.w,r.push(p)),n.splice(d,1)}})}if(s)this.compact(i,!1);else{if(n.length)if(typeof i=="function")i(t,e,r,n);else{let a=s||i==="none"?1:t/e,u=i==="move"||i==="moveScale",c=i==="scale"||i==="moveScale";n.forEach(d=>{d.x=t===1?0:u?Math.round(d.x*a):Math.min(d.x,t-1),d.w=t===1||e===1?1:c?Math.round(d.w*a)||1:Math.min(d.w,t),r.push(d)}),n=[]}r=h.sort(r,-1),this._inColumnResize=!0,this.nodes=[],r.forEach(a=>{this.addNode(a,!1),delete a._orig})}return this.nodes.forEach(a=>delete a._orig),this.batchUpdate(!1,!s),delete this._inColumnResize,this}cacheLayout(e,t,i=!1){let s=[];return e.forEach((r,n)=>{if(r._id===void 0){let a=r.id?this.nodes.find(u=>u.id===r.id):void 0;r._id=a?._id??l._idSeq++}s[n]={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??l._idSeq++;let 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]||[];let s=this.findCacheLayout(e,t);return s===-1?this._layouts[t].push(i):this._layouts[t][s]=i,this}findCacheLayout(e,t){return this._layouts?.[t]?.findIndex(i=>i._id===e._id)??-1}removeNodeFromLayoutCache(e){if(this._layouts)for(let t=0;t<this._layouts.length;t++){let i=this.findCacheLayout(e,t);i!==-1&&this._layouts[t].splice(i,1)}}cleanupNode(e){for(let t in e)t[0]==="_"&&t!=="_id"&&delete e[t];return this}}return l._idSeq=0,l})();var P={alwaysShowResizeHandle:"mobile",animate:!0,auto:!0,cellHeight:"auto",cellHeightThrottle:100,cellHeightUnit:"px",column:12,draggable:{handle:".grid-stack-item-content",appendTo:"body",scroll:!0},handle:".grid-stack-item-content",itemClass:"grid-stack-item",margin:10,marginUnit:"px",maxRow:0,minRow:0,placeholderClass:"grid-stack-placeholder",placeholderText:"",removableOptions:{accept:"grid-stack-item",decline:"grid-stack-non-removable"},resizable:{handles:"se"},rtl:"auto"};var f=class{};var 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),k=class{};function Ue(l,o){l.touches.length>1||(l.cancelable&&l.preventDefault(),h.simulateMouseEvent(l.changedTouches[0],o))}function Ut(l,o){l.cancelable&&l.preventDefault(),h.simulateMouseEvent(l,o)}function le(l){k.touchHandled||(k.touchHandled=!0,Ue(l,"mousedown"))}function de(l){k.touchHandled&&Ue(l,"mousemove")}function he(l){if(!k.touchHandled)return;k.pointerLeaveTimeout&&(window.clearTimeout(k.pointerLeaveTimeout),delete k.pointerLeaveTimeout);let o=!!f.dragElement;Ue(l,"mouseup"),o||Ue(l,"click"),k.touchHandled=!1}function ce(l){l.pointerType!=="mouse"&&l.target.releasePointerCapture(l.pointerId)}function nt(l){f.dragElement&&l.pointerType!=="mouse"&&Ut(l,"mouseenter")}function at(l){f.dragElement&&l.pointerType!=="mouse"&&(k.pointerLeaveTimeout=window.setTimeout(()=>{delete k.pointerLeaveTimeout,Ut(l,"mouseleave")},10))}var $t=(()=>{class l{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(){if(this.option.element)try{this.el=this.option.element instanceof HTMLElement?this.option.element:this.host.querySelector(this.option.element)}catch(e){this.option.element=void 0,console.error("Query for resizeable handle failed, falling back",e)}return this.el||(this.el=document.createElement("div"),this.host.appendChild(this.el)),this.el.classList.add("ui-resizable-handle"),this.el.classList.add(`${l.prefix}${this.dir}`),this.el.style.zIndex="100",this.el.style.userSelect="none",this.el.addEventListener("mousedown",this._mouseDown),z&&(this.el.addEventListener("touchstart",le),this.el.addEventListener("pointerdown",ce)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),z&&(this.el.removeEventListener("touchstart",le),this.el.removeEventListener("pointerdown",ce)),this.option.element||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",de),this.el.addEventListener("touchend",he)),e.stopPropagation(),e.preventDefault()}_mouseMove(e){let 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",de),this.el.removeEventListener("touchend",he)),delete this.moving,delete this.mouseDownEvent,e.stopPropagation(),e.preventDefault()}_keyEvent(e){e.key==="Escape"&&(this.host.gridstackNode?.grid?.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(e,t){return this.option[e]&&this.option[e](t),this}}return l.prefix="ui-resizable-",l})();var K=class{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(o,e){this._eventRegister[o]=e}off(o){delete this._eventRegister[o]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(o,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[o])return this._eventRegister[o](e)}};var Vt=(()=>{class l extends K{constructor(e,t={}){super(),this.el=e,this.option=t,this.rectScale={x:1,y:1},this._ui=()=>{let 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},n=this.temporalRect||r;return{position:{left:(n.left-s.left)*this.rectScale.x,top:(n.top-s.top)*this.rectScale.y},size:{width:n.width*this.rectScale.x,height:n.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){let 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),f.overResizeElement===this&&delete f.overResizeElement),this}_mouseOver(e){f.overResizeElement||f.dragElement||(f.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){f.overResizeElement===this&&(delete f.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new $t(this.el,e,{element:this.option.element,start:t=>this._resizeStart(t),stop:t=>this._resizeStop(t),move:t=>this._resizing(t,e)})),this}_resizeStart(e){this.sizeToContent=h.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=h.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();let t=h.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();let i=h.initEvent(e,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(i,this._ui()),this.triggerEvent("resize",i),this}_resizeStop(e){let t=h.initEvent(e,{type:"resizestop",target:this.el});return this._cleanHelper(),this.option.stop&&this.option.stop(t),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",t),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=l._originStyleProp.map(i=>this.el.style[i]),this.parentOriginStylePosition=this.el.parentElement.style.position;let e=this.el.parentElement,t=h.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 l._originStyleProp.forEach((e,t)=>{this.el.style[e]=this.elOriginStyleVal[t]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(e,t){let 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,n=this.sizeToContent?0:e.clientY-i.clientY,a,u;t.indexOf("e")>-1?s.width+=r:t.indexOf("w")>-1&&(s.width-=r,s.left+=r,a=!0),t.indexOf("s")>-1?s.height+=n:t.indexOf("n")>-1&&(s.height-=n,s.top+=n,u=!0);let c=this._constrainSize(s.width,s.height,a,u);return Math.round(s.width)!==Math.round(c.width)&&(t.indexOf("w")>-1&&(s.left+=s.width-c.width),s.width=c.width),Math.round(s.height)!==Math.round(c.height)&&(t.indexOf("n")>-1&&(s.top+=s.height-c.height),s.height=c.height),s}_constrainSize(e,t,i,s){let r=this.option,n=(i?r.maxWidthMoveLeft:r.maxWidth)||Number.MAX_SAFE_INTEGER,a=r.minWidth/this.rectScale.x||e,u=(s?r.maxHeightMoveUp:r.maxHeight)||Number.MAX_SAFE_INTEGER,c=r.minHeight/this.rectScale.y||t,d=Math.min(n,Math.max(a,e)),p=Math.min(u,Math.max(c,t));return{width:d,height:p}}_applyChange(){let e={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){let 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=>{let 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}}return l._originStyleProp=["width","height","position","left","top","opacity","zIndex"],l})();var ri='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle',qt=(()=>{class l extends K{constructor(e,t={}){super(),this.el=e,this.option=t,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};let i=t?.handle?.substring(1),s=e.gridstackNode;this.dragEls=!i||e.classList.contains(i)?[e]: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",le),e.addEventListener("pointerdown",ce))}),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",le),t.removeEventListener("pointerdown",ce))}),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(k.touchHandled&&e.isTrusted&&(k.touchHandled=!1),!f.mouseHandled)return e.button!==0||!this.dragEls.find(t=>t===e.target)&&e.target.closest(ri)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete f.dragElement,delete f.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),z&&(e.currentTarget.addEventListener("touchmove",de),e.currentTarget.addEventListener("touchend",he)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),f.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;let t=h.initEvent(e,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(t,this.ui()),this.triggerEvent("drag",t)}_mouseMove(e){let t=this.mouseDownEvent;if(this.lastDrag=e,this.dragging)if(this._dragFollow(e),f.pauseDrag){let i=Number.isInteger(f.pauseDrag)?f.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(e),i)}else this._callDrag(e);else if(Math.abs(e.x-t.x)+Math.abs(e.y-t.y)>3){this.dragging=!0,f.dragElement=this;let i=this.el.gridstackNode?.grid;i?f.dropElement=i.el.ddElement.ddDroppable:delete f.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=h.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);let s=h.initEvent(e,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(s,this.ui()),this.triggerEvent("dragstart",s),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(e){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),z&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",de,!0),e.currentTarget.removeEventListener("touchend",he,!0)),this.dragging){delete this.dragging,delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),f.dropElement?.el===this.el.parentElement&&delete f.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();let t=h.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(t),this.triggerEvent("dragstop",t),f.dropElement&&f.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete f.dragElement,delete f.dropElement,delete f.mouseHandled,e.preventDefault()}_keyEvent(e){let t=this.el.gridstackNode,i=t?.grid||f.dropElement?.el?.gridstack;if(e.key==="Escape")t&&t._origRotate&&(t._orig=t._origRotate,delete t._origRotate),i?.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(t&&i&&(e.key==="r"||e.key==="R")){if(!h.canBeRotated(t))return;t._origRotate=t._origRotate||m({},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",h.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=h.cloneNode(this.el)),e.parentElement||h.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=l.originStyleProp.map(t=>this.el.style[t]),e}_setupHelperStyle(e){this.helper.classList.add("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.add("grid-stack-dragging");let 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(){if(this.helper.classList.remove("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.remove("grid-stack-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){let t=this.helper,i=this.dragElementOriginStyle.transition||null;t.style.transition=this.dragElementOriginStyle.transition="none",l.originStyleProp.forEach(s=>t.style[s]=this.dragElementOriginStyle[s]||null),setTimeout(()=>t.style.transition=i,50)}return delete this.dragElementOriginStyle,this}_dragFollow(e){let 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);let n=t.getBoundingClientRect();return{left:n.left,top:n.top,offsetLeft:-e.clientX+n.left-s,offsetTop:-e.clientY+n.top-r,width:n.width*this.dragTransform.xScale,height:n.height*this.dragTransform.yScale}}ui(){let 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}}}}return l.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","top","minWidth","willChange"],l})();var $e=class extends K{constructor(o,e={}){super(),this.el=o,this.option=e,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(o,e){super.on(o,e)}off(o){super.off(o)}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",nt),this.el.addEventListener("pointerleave",at)))}disable(o=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),o||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),z&&(this.el.removeEventListener("pointerenter",nt),this.el.removeEventListener("pointerleave",at)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(o){return Object.keys(o).forEach(e=>this.option[e]=o[e]),this._setupAccept(),this}_mouseEnter(o){if(!f.dragElement||k.touchHandled&&o.isTrusted||!this._canDrop(f.dragElement.el))return;o.preventDefault(),o.stopPropagation(),f.dropElement&&f.dropElement!==this&&f.dropElement._mouseLeave(o,!0),f.dropElement=this;let e=h.initEvent(o,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(f.dragElement)),this.triggerEvent("dropover",e),this.el.classList.add("ui-droppable-over")}_mouseLeave(o,e=!1){if(!f.dragElement||f.dropElement!==this)return;o.preventDefault(),o.stopPropagation();let t=h.initEvent(o,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(t,this._ui(f.dragElement)),this.triggerEvent("dropout",t),f.dropElement===this&&(delete f.dropElement,!e)){let i,s=this.el.parentElement;for(;!i&&s;)i=s.ddElement?.ddDroppable,s=s.parentElement;i&&i._mouseEnter(o)}}drop(o){o.preventDefault();let e=h.initEvent(o,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(f.dragElement)),this.triggerEvent("drop",e)}_canDrop(o){return o&&(!this.accept||this.accept(o))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=o=>o.classList.contains(this.option.accept)||o.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(o){return m({draggable:o.el},o.ui())}};var Ve=class l{static init(o){return o.ddElement||(o.ddElement=new l(o)),o.ddElement}constructor(o){this.el=o}on(o,e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(o)>-1?this.ddDraggable.on(o,e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(o)>-1?this.ddDroppable.on(o,e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(o)>-1&&this.ddResizable.on(o,e),this}off(o){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(o)>-1?this.ddDraggable.off(o):this.ddDroppable&&["drop","dropover","dropout"].indexOf(o)>-1?this.ddDroppable.off(o):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(o)>-1&&this.ddResizable.off(o),this}setupDraggable(o){return this.ddDraggable?this.ddDraggable.updateOption(o):this.ddDraggable=new qt(this.el,o),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(o){return this.ddResizable?this.ddResizable.updateOption(o):this.ddResizable=new Vt(this.el,o),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(o){return this.ddDroppable?this.ddDroppable.updateOption(o):this.ddDroppable=new $e(this.el,o),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}};var qe=class{resizable(o,e,t,i){return this._getDDElements(o,e).forEach(s=>{if(e==="disable"||e==="enable")s.ddResizable&&s.ddResizable[e]();else if(e==="destroy")s.ddResizable&&s.cleanResizable();else if(e==="option")s.setupResizable({[t]:i});else{let n=s.el.gridstackNode.grid,a=s.el.getAttribute("gs-resize-handles")||n.opts.resizable.handles||"e,s,se";a==="all"&&(a="n,e,s,w,se,sw,ne,nw");let u=!n.opts.alwaysShowResizeHandle;s.setupResizable(E(m({},n.opts.resizable),{handles:a,autoHide:u,start:e.start,stop:e.stop,resize:e.resize}))}}),this}draggable(o,e,t,i){return this._getDDElements(o,e).forEach(s=>{if(e==="disable"||e==="enable")s.ddDraggable&&s.ddDraggable[e]();else if(e==="destroy")s.ddDraggable&&s.cleanDraggable();else if(e==="option")s.setupDraggable({[t]:i});else{let r=s.el.gridstackNode.grid;s.setupDraggable(E(m({},r.opts.draggable),{start:e.start,stop:e.stop,drag:e.drag}))}}),this}dragIn(o,e){return this._getDDElements(o).forEach(t=>t.setupDraggable(e)),this}droppable(o,e,t,i){return typeof e.accept=="function"&&!e._accept&&(e._accept=e.accept,e.accept=s=>e._accept(s)),this._getDDElements(o,e).forEach(s=>{e==="disable"||e==="enable"?s.ddDroppable&&s.ddDroppable[e]():e==="destroy"?s.ddDroppable&&s.cleanDroppable():e==="option"?s.setupDroppable({[t]:i}):s.setupDroppable(e)}),this}isDroppable(o){return!!(o?.ddElement?.ddDroppable&&!o.ddElement.ddDroppable.disabled)}isDraggable(o){return!!(o?.ddElement?.ddDraggable&&!o.ddElement.ddDraggable.disabled)}isResizable(o){return!!(o?.ddElement?.ddResizable&&!o.ddElement.ddResizable.disabled)}on(o,e,t){return this._getDDElements(o).forEach(i=>i.on(e,s=>{t(s,f.dragElement?f.dragElement.el:s.target,f.dragElement?f.dragElement.helper:null)})),this}off(o,e){return this._getDDElements(o).forEach(t=>t.off(e)),this}_getDDElements(o,e){let t=o.gridstack||e!=="destroy"&&e!=="disable",i=h.getElements(o);return i.length?i.map(r=>r.ddElement||(t?Ve.init(r):null)).filter(r=>r):[]}};var M=new qe,j=(()=>{class l{static init(e={},t=".grid-stack"){if(typeof document>"u")return null;let i=l.getGridElement(t);return i?(i.gridstack||(i.gridstack=new l(i,h.cloneDeep(e))),i.gridstack):(console.error(typeof t=="string"?'GridStack.initAll() no grid was found with selector "'+t+`" - element missing or wrong selector ?
2
+ 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"){let i=[];return typeof document>"u"||(l.getGridElements(t).forEach(s=>{s.gridstack||(s.gridstack=new l(s,h.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 ?
3
+ 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){let n=i.gridstack;return t&&(n.opts=m(m({},n.opts),t)),t.children!==void 0&&n.load(t.children),n}return(!e.classList.contains("grid-stack")||l.addRemoveCB)&&(l.addRemoveCB?i=l.addRemoveCB(e,t,!0,!0):i=h.createDiv(["grid-stack",t.class],e)),l.init(t,i)}static registerEngine(e){l.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=h.createDiv([this.opts.placeholderClass,P.itemClass,this.opts.itemClass]);let e=h.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,t={}){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);let i=h.toNumber(e.getAttribute("gs-row"));t.column==="auto"&&delete t.column,t.alwaysShowResizeHandle!==void 0&&(t._alwaysShowResizeHandle=t.alwaysShowResizeHandle);let s=t.columnOpts;if(s){let c=s.breakpoints;!s.columnWidth&&!c?.length?delete t.columnOpts:(s.columnMax=s.columnMax||12,c?.length>1&&c.sort((d,p)=>(p.w||0)-(d.w||0)))}let r=E(m({},h.cloneDeep(P)),{column:h.toNumber(e.getAttribute("gs-column"))||P.column,minRow:i||h.toNumber(e.getAttribute("gs-min-row"))||P.minRow,maxRow:i||h.toNumber(e.getAttribute("gs-max-row"))||P.maxRow,staticGrid:h.toBool(e.getAttribute("gs-static"))||P.staticGrid,sizeToContent:h.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(t.handleClass?"."+t.handleClass:t.handle?t.handle:"")||P.draggable.handle},removableOptions:{accept:t.itemClass||P.removableOptions.accept,decline:P.removableOptions.decline}});e.getAttribute("gs-animate")&&(r.animate=h.toBool(e.getAttribute("gs-animate"))),t=h.defaults(t,r),this._initMargin(),this.checkDynamicColumn(),this._updateColumnVar(t),t.rtl==="auto"&&(t.rtl=e.style.direction==="rtl"),t.rtl&&this.el.classList.add("grid-stack-rtl");let a=this.el.closest("."+P.itemClass)?.gridstackNode;if(a&&(a.subGrid=this,this.parentGridNode=a,this.el.classList.add("grid-stack-nested"),a.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=t.cellHeight==="auto",this._isAutoCellHeight||t.cellHeight==="initial")this.cellHeight(void 0);else{typeof t.cellHeight=="number"&&t.cellHeightUnit&&t.cellHeightUnit!==P.cellHeightUnit&&(t.cellHeight=t.cellHeight+t.cellHeightUnit,delete t.cellHeightUnit);let c=t.cellHeight;delete t.cellHeight,this.cellHeight(c)}t.alwaysShowResizeHandle==="mobile"&&(t.alwaysShowResizeHandle=z),this._setStaticClass();let u=t.engineClass||l.engineClass||ot;if(this.engine=new u({column:this.getColumn(),float:t.float,maxRow:t.maxRow,onChange:c=>{c.forEach(d=>{let p=d.el;p&&(d._removeDOM?(p&&p.remove(),delete d._removeDOM):this._writePosAttr(p,d))}),this._updateContainerHeight()}}),t.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(c=>this._prepareElement(c)),delete this.engine._loading,this.batchUpdate(!1)),t.children){let c=t.children;delete t.children,c.length&&this.load(c)}this.setAnimation(),t.subGridDynamic&&!f.pauseDrag&&(f.pauseDrag=!0),t.draggable?.pause!==void 0&&(f.pauseDrag=t.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}_updateColumnVar(e=this.opts){this.el.classList.add("gs-"+e.column),typeof e.column=="number"&&this.el.style.setProperty("--gs-column-width",`${100/e.column}%`)}addWidget(e){if(!e)return;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.el?t=i.el:l.addRemoveCB?t=l.addRemoveCB(this.el,e,!0,!1):t=this.createWidgetDivs(i),!t)return;if(i=t.gridstackNode,i&&t.parentElement===this.el&&this.engine.nodes.find(r=>r._id===i._id))return t;let s=this._readAttr(t);return h.defaults(e,s),this.engine.prepareNode(e),this.el.appendChild(t),this.makeWidget(t,e),t}createWidgetDivs(e){let t=h.createDiv(["grid-stack-item",this.opts.itemClass]),i=h.createDiv(["grid-stack-item-content"],t);return h.lazyLoad(e)?e.visibleObservable||(e.visibleObservable=new IntersectionObserver(([s])=>{s.isIntersecting&&(e.visibleObservable?.disconnect(),delete e.visibleObservable,l.renderCB(i,e),e.grid?.prepareDragDrop(e.el))}),window.setTimeout(()=>e.visibleObservable?.observe(t))):l.renderCB(i,e),t}makeSubGrid(e,t,i,s=!0){let r=e.gridstackNode;if(r||(r=this.makeWidget(e).gridstackNode),r.subGrid?.el)return r.subGrid;let n,a=this;for(;a&&!n;)n=a.opts?.subGridOpts,a=a.parentGridNode?.grid;t=h.cloneDeep(m(m(E(m({},this.opts),{id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0}),n||{}),t||r.subGridOpts||{})),r.subGridOpts=t;let u;t.column==="auto"&&(u=!0,t.column=Math.max(r.w||1,i?.w||1),delete t.columnOpts);let c=r.el.querySelector(".grid-stack-item-content"),d,p;if(s&&(this._removeDD(r.el),p=E(m({},r),{x:0,y:0}),h.removeInternalForSave(p),delete p.subGridOpts,r.content&&(p.content=r.content,delete r.content),l.addRemoveCB?d=l.addRemoveCB(this.el,p,!0,!1):(d=h.createDiv(["grid-stack-item"]),d.appendChild(c),c=h.createDiv(["grid-stack-item-content"],r.el)),this.prepareDragDrop(r.el)),i){let w=u?t.column:r.w,x=r.h+i.h,O=r.el.style;O.transition="none",this.update(r.el,{w,h:x}),setTimeout(()=>O.transition=null)}let g=r.subGrid=l.addGrid(c,t);return i?._moving&&(g._isTemp=!0),u&&(g._autoColumn=!0),s&&g.makeWidget(d,p),i&&(i._moving?window.setTimeout(()=>h.simulateMouseEvent(i._event,"mouseenter",g.el),0):g.makeWidget(r.el,r)),this.resizeToContentCheck(!1,r),g}removeAsSubGrid(e){let t=this.parentGridNode?.grid;t&&(t.batchUpdate(),t.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(i=>{i.x+=this.parentGridNode.x,i.y+=this.parentGridNode.y,t.makeWidget(i.el,i)}),t.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,e&&window.setTimeout(()=>h.simulateMouseEvent(e._event,"mouseenter",t.el),0))}save(e=!0,t=!1,i=l.saveCB,s){let r=this.engine.save(e,i,s);if(r.forEach(n=>{if(e&&n.el&&!n.subGrid&&!i){let a=n.el.querySelector(".grid-stack-item-content");n.content=a?.innerHTML,n.content||delete n.content}else if(!e&&!i&&delete n.content,n.subGrid?.el){let a=n.w||n.subGrid.getColumn(),u=n.subGrid.save(e,t,i,a);n.subGridOpts=t?u:{children:u},delete n.subGrid}delete n.el}),t){let n=h.cloneDeep(this.opts);n.marginBottom===n.marginTop&&n.marginRight===n.marginLeft&&n.marginTop===n.marginRight&&(n.margin=n.marginTop,delete n.marginTop,delete n.marginRight,delete n.marginBottom,delete n.marginLeft),n.rtl===(this.el.style.direction==="rtl")&&(n.rtl="auto"),this._isAutoCellHeight&&(n.cellHeight="auto"),this._autoColumn&&(n.column="auto");let a=n._alwaysShowResizeHandle;return delete n._alwaysShowResizeHandle,a!==void 0?n.alwaysShowResizeHandle=a:delete n.alwaysShowResizeHandle,h.removeInternalAndSame(n,P),n.children=r,n}return r}load(e,t=l.addRemoveCB||!0){e=h.cloneDeep(e);let i=this.getColumn();e.forEach(d=>{d.w=d.w||d.minW||1,d.h=d.h||d.minH||1}),e=h.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let s=0;e.forEach(d=>{s=Math.max(s,(d.x||0)+d.w)}),s>this.engine.defaultColumn&&(this.engine.defaultColumn=s),s>i&&(this.engine.nodes.length===0&&this.responseLayout?(this.engine.nodes=e,this.engine.columnChanged(s,i,this.responseLayout),e=this.engine.nodes,this.engine.nodes=[],delete this.responseLayout):this.engine.cacheLayout(e,s,!0));let r=l.addRemoveCB;typeof t=="function"&&(l.addRemoveCB=t);let n=[];this.batchUpdate();let a=!this.engine.nodes.length,u=a&&this.opts.animate;u&&this.setAnimation(!1),!a&&t&&[...this.engine.nodes].forEach(p=>{if(!p.id)return;h.find(e,p.id)||(l.addRemoveCB&&l.addRemoveCB(this.el,p,!1,!1),n.push(p),this.removeWidget(p.el,!0,!1))}),this.engine._loading=!0;let c=[];return this.engine.nodes=this.engine.nodes.filter(d=>h.find(e,d.id)?(c.push(d),!1):!0),e.forEach(d=>{let p=h.find(c,d.id);if(p){if(h.shouldSizeToContent(p)&&(d.h=p.h),this.engine.nodeBoundFix(d),(d.autoPosition||d.x===void 0||d.y===void 0)&&(d.w=d.w||p.w,d.h=d.h||p.h,this.engine.findEmptyPosition(d)),this.engine.nodes.push(p),h.samePos(p,d)&&this.engine.nodes.length>1&&(this.moveNode(p,E(m({},d),{forceCollide:!0})),h.copyPos(d,p)),this.update(p.el,d),d.subGridOpts?.children){let g=p.el.querySelector(".grid-stack");g&&g.gridstack&&g.gridstack.load(d.subGridOpts.children)}}else t&&this.addWidget(d)}),delete this.engine._loading,this.engine.removedNodes=n,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,r?l.addRemoveCB=r:delete l.addRemoveCB,u&&this.setAnimation(!0,!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;let t=this.el.querySelector("."+this.opts.itemClass);if(t){let s=h.toNumber(t.getAttribute("gs-h"))||1;return Math.round(t.offsetHeight/s)}let i=parseInt(this.el.getAttribute("gs-current-row"));return i?Math.round(this.el.getBoundingClientRect().height/i):this.opts.cellHeight}cellHeight(e){if(e!==void 0&&this._isAutoCellHeight!==(e==="auto")&&(this._isAutoCellHeight=e==="auto",this._updateResizeEvent()),(e==="initial"||e==="auto")&&(e=void 0),e===void 0){let i=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+i}let t=h.parseHeight(e);return this.opts.cellHeightUnit===t.unit&&this.opts.cellHeight===t.h?this:(this.opts.cellHeightUnit=t.unit,this.opts.cellHeight=t.h,this.el.style.setProperty("--gs-cell-height",`${this.opts.cellHeight}${this.opts.cellHeightUnit}`),this._updateContainerHeight(),this.resizeToContentCheck(),this)}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(e=!1){return e&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){let e=this.opts.columnOpts;if(!e||!e.columnWidth&&!e.breakpoints?.length)return!1;let t=this.getColumn(),i=t,s=this._widthOrContainer(!0);if(e.columnWidth)i=Math.min(Math.round(s/e.columnWidth)||1,e.columnMax);else{i=e.columnMax;let r=0;for(;r<e.breakpoints.length&&s<=e.breakpoints[r].w;)i=e.breakpoints[r++].c||t}if(i!==t){let r=e.breakpoints?.find(n=>n.c===i);return this.column(i,r?.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;let i=this.getColumn();return this.opts.column=e,this.engine?(this.engine.column=e,this.el.classList.remove("gs-"+i),this._updateColumnVar(),this.engine.columnChanged(i,e,t),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):(this.responseLayout=t,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){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.removeAttribute("gs-current-row")),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,delete this.opts,delete this._placeholder?.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){let i=this.el.getBoundingClientRect(),s;t?s={top:i.top+document.documentElement.scrollTop,left:i.left}:s={top:this.el.offsetTop,left:this.el.offsetLeft};let r=e.left-s.left,n=e.top-s.top,a=i.width/this.getColumn(),u=i.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(r/a),y:Math.floor(n/u)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow||0)}isAreaEmpty(e,t,i,s){return this.engine.isAreaEmpty(e,t,i,s)}makeWidget(e,t){let i=l.getElement(e);if(!i||i.gridstackNode)return i;i.parentElement||this.el.appendChild(i),this._prepareElement(i,!0,t);let 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?(l.getElements(e).forEach(s=>{if(s.parentElement&&s.parentElement!==this.el)return;let r=s.gridstackNode;r||(r=this.engine.nodes.find(n=>s===n.el)),r&&(t&&l.addRemoveCB&&l.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&&l.addRemoveCB&&l.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.opts.animate=e,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.prepareDragDrop(s.el),s.subGrid&&i&&s.subGrid.setStatic(e,t,i)}),t&&this._setStaticClass(),this)}updateOptions(e){let t=this.opts;return e===t?this:(e.acceptWidgets!==void 0&&(t.acceptWidgets=e.acceptWidgets,this._setupAcceptWidget()),e.animate!==void 0&&this.setAnimation(e.animate),e.cellHeight&&this.cellHeight(e.cellHeight),e.class!==void 0&&e.class!==t.class&&(t.class&&this.el.classList.remove(t.class),e.class&&this.el.classList.add(e.class)),e.columnOpts?(this.opts.columnOpts=e.columnOpts,this.checkDynamicColumn()):e.columnOpts===null&&this.opts.columnOpts?(delete this.opts.columnOpts,this._updateResizeEvent()):typeof e.column=="number"&&this.column(e.column),e.margin!==void 0&&this.margin(e.margin),e.staticGrid!==void 0&&this.setStatic(e.staticGrid),e.disableDrag!==void 0&&!e.staticGrid&&this.enableMove(!e.disableDrag),e.disableResize!==void 0&&!e.staticGrid&&this.enableResize(!e.disableResize),e.float!==void 0&&this.float(e.float),e.row!==void 0?(t.minRow=t.maxRow=t.row=e.row,this._updateContainerHeight()):(e.minRow!==void 0&&(t.minRow=e.minRow,this._updateContainerHeight()),e.maxRow!==void 0&&(t.maxRow=e.maxRow)),e.lazyLoad!==void 0&&(t.lazyLoad=e.lazyLoad),e.children?.length&&this.load(e.children),this)}update(e,t){return l.getElements(e).forEach(i=>{let s=i?.gridstackNode;if(!s)return;let r=m(m({},h.copyPos({},s)),h.cloneDeep(t));this.engine.nodeBoundFix(r),delete r.autoPosition;let n=["x","y","w","h"],a;if(n.some(d=>r[d]!==void 0&&r[d]!==s[d])&&(a={},n.forEach(d=>{a[d]=r[d]!==void 0?r[d]:s[d],delete r[d]})),!a&&(r.minW||r.minH||r.maxW||r.maxH)&&(a={}),r.content!==void 0){let d=i.querySelector(".grid-stack-item-content");d&&d.textContent!==r.content&&(s.content=r.content,l.renderCB(d,r),s.subGrid?.el&&(d.appendChild(s.subGrid.el),s.subGrid._updateContainerHeight())),delete r.content}let u=!1,c=!1;for(let d in r)d[0]!=="_"&&s[d]!==r[d]&&(s[d]=r[d],u=!0,c=c||!this.opts.staticGrid&&(d==="noResize"||d==="noMove"||d==="locked"));if(h.sanitizeMinMax(s),a){let d=a.w!==void 0&&a.w!==s.w;this.moveNode(s,a),d&&s.subGrid?s.subGrid.onResize(this.hasAnimationCSS()?s.w:void 0):this.resizeToContentCheck(d,s),delete s._orig}(a||u)&&this._writeAttr(i,s),c&&this.prepareDragDrop(s.el),l.updateCB&&l.updateCB(s)}),this}moveNode(e,t){let i=e._updating;i||this.engine.cleanNodes().beginUpdate(e),this.engine.moveNode(e,t),this._updateContainerHeight(),i||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(e){if(!e||(e.classList.remove("size-to-content-max"),!e.clientHeight))return;let t=e.gridstackNode;if(!t)return;let i=t.grid;if(!i||e.parentElement!==i.el)return;let s=i.getCellHeight(!0);if(!s)return;let r=t.h?t.h*s:e.clientHeight,n;if(t.resizeToContentParent&&(n=e.querySelector(t.resizeToContentParent)),n||(n=e.querySelector(l.resizeToContentParent)),!n)return;let a=e.clientHeight-n.clientHeight,u=t.h?t.h*s-a:n.clientHeight,c;if(t.subGrid){c=t.subGrid.getRow()*t.subGrid.getCellHeight(!0);let g=t.subGrid.el.getBoundingClientRect(),w=e.getBoundingClientRect();c+=g.top-w.top}else{if(t.subGridOpts?.children?.length)return;{let g=n.firstElementChild;if(!g){console.error(`Error: GridStack.resizeToContent() widget id:${t.id} '${l.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}c=g.getBoundingClientRect().height||u}}if(u===c)return;r+=c-u;let d=Math.ceil(r/s),p=Number.isInteger(t.sizeToContent)?t.sizeToContent:0;p&&d>p&&(d=p,e.classList.add("size-to-content-max")),t.minH&&d<t.minH?d=t.minH:t.maxH&&d>t.maxH&&(d=t.maxH),d!==t.h&&(i._ignoreLayoutsNodeChange=!0,i.moveNode(t,{h:d}),delete i._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){l.resizeToContentCB?l.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,t){return l.getElements(e).forEach(i=>{let s=i.gridstackNode;if(!h.canBeRotated(s))return;let r={w:s.h,h:s.w,minH:s.minW,minW:s.minH,maxH:s.maxW,maxW:s.maxH};if(t){let a=t.left>0?Math.floor(t.left/this.cellWidth()):0,u=t.top>0?Math.floor(t.top/this.opts.cellHeight):0;r.x=s.x+a-(s.h-(u+1)),r.y=s.y+u-a}Object.keys(r).forEach(a=>{r[a]===void 0&&delete r[a]});let n=s._orig;this.update(i,r),s._orig=n}),this}margin(e){if(!(typeof e=="string"&&e.split(" ").length>1)){let i=h.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}getMargin(){return this.opts.margin}willItFit(e){return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;let e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(t=>{delete t._dirty});let e=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",e)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){let e=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",e)}return this}_triggerEvent(e,t){let i=t?new CustomEvent(e,{bubbles:!1,detail:t}):new Event(e),s=this;for(;s.parentGridNode;)s=s.parentGridNode.grid;return s.el.dispatchEvent(i),this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;let e=this.parentGridNode,t=this.getRow()+this._extraDragRow,i=this.opts.cellHeight,s=this.opts.cellHeightUnit;if(!i)return this;if(!e&&!this.opts.minRow){let r=h.parseHeight(getComputedStyle(this.el).minHeight);if(r.h>0&&r.unit===s){let n=Math.floor(r.h/i);t<n&&(t=n)}}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&&h.shouldSizeToContent(e)&&e.grid.resizeToContentCBCheck(e.el),this}_prepareElement(e,t=!1,i){i=i||this._readAttr(e),e.gridstackNode=i,i.el=e,i.grid=this,i=this.engine.addNode(i,t),this._writeAttr(e,i),e.classList.add(P.itemClass,this.opts.itemClass);let s=h.shouldSizeToContent(i);return s?e.classList.add("size-to-content"):e.classList.remove("size-to-content"),s&&this.resizeToContentCheck(!1,i),h.lazyLoad(i)||this.prepareDragDrop(i.el),this}_writePosAttr(e,t){return(!t._moving&&!t._resizing||this._placeholder===e)&&(e.style.top=t.y?t.y===1?"var(--gs-cell-height)":`calc(${t.y} * var(--gs-cell-height))`:null,e.style.left=t.x?t.x===1?"var(--gs-column-width)":`calc(${t.x} * var(--gs-column-width))`:null,e.style.width=t.w>1?`calc(${t.w} * var(--gs-column-width))`:null,e.style.height=t.h>1?`calc(${t.h} * var(--gs-cell-height))`:null),e.setAttribute("gs-x",String(t.x)),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);let i={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(let s in i)t[s]?e.setAttribute(i[s],String(t[s])):e.removeAttribute(i[s]);return this}_readAttr(e,t=!0){let i={};i.x=h.toNumber(e.getAttribute("gs-x")),i.y=h.toNumber(e.getAttribute("gs-y")),i.w=h.toNumber(e.getAttribute("gs-w")),i.h=h.toNumber(e.getAttribute("gs-h")),i.autoPosition=h.toBool(e.getAttribute("gs-auto-position")),i.noResize=h.toBool(e.getAttribute("gs-no-resize")),i.noMove=h.toBool(e.getAttribute("gs-no-move")),i.locked=h.toBool(e.getAttribute("gs-locked"));let s=e.getAttribute("gs-size-to-content");s&&(s==="true"||s==="false"?i.sizeToContent=h.toBool(s):i.sizeToContent=parseInt(s,10)),i.id=e.getAttribute("gs-id"),i.maxW=h.toNumber(e.getAttribute("gs-max-w")),i.minW=h.toNumber(e.getAttribute("gs-min-w")),i.maxH=h.toNumber(e.getAttribute("gs-max-h")),i.minH=h.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(let r in i){if(!i.hasOwnProperty(r))return;!i[r]&&i[r]!==0&&r!=="sizeToContent"&&delete i[r]}return i}_setStaticClass(){let 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=this.el?.clientWidth){if(!e||this.prevWidth===e)return;this.prevWidth=e,this.batchUpdate();let t=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),t=!0):t=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(i=>{i.subGrid&&i.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(t),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)h.shouldSizeToContent(t)&&this.resizeToContentCBCheck(t.el);else if(this.engine.nodes.some(i=>h.shouldSizeToContent(i))){let i=[...this.engine.nodes];this.batchUpdate(),i.forEach(s=>{h.shouldSizeToContent(s)&&this.resizeToContentCBCheck(s.el)}),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(!1),this._ignoreLayoutsNodeChange=!1}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,t?[t]:this.engine.nodes)}}_updateResizeEvent(e=!1){let 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=h.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 h.getElement(e)}static getElements(e=".grid-stack-item"){return h.getElements(e)}static getGridElement(e){return l.getElement(e)}static getGridElements(e){return h.getElements(e)}_initMargin(){let e,t=0,i=[];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=h.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,t=this.opts.margin=e.h),["marginTop","marginRight","marginBottom","marginLeft"].forEach(n=>{this.opts[n]===void 0?this.opts[n]=t:(e=h.parseHeight(this.opts[n]),this.opts[n]=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);let r=this.el.style;return r.setProperty("--gs-item-margin-top",`${this.opts.marginTop}${this.opts.marginUnit}`),r.setProperty("--gs-item-margin-bottom",`${this.opts.marginBottom}${this.opts.marginUnit}`),r.setProperty("--gs-item-margin-right",`${this.opts.marginRight}${this.opts.marginUnit}`),r.setProperty("--gs-item-margin-left",`${this.opts.marginLeft}${this.opts.marginUnit}`),this}static getDD(){return M}static setupDragIn(e,t,i,s=document){t?.pause!==void 0&&(f.pauseDrag=t.pause),t=m({appendTo:"body",helper:"clone"},t||{}),(typeof e=="string"?h.getElements(e,s):e).forEach((n,a)=>{M.isDraggable(n)||M.dragIn(n,t),i?.[a]&&(n.gridstackNode=i[a])})}movable(e,t){return this.opts.staticGrid?this:(l.getElements(e).forEach(i=>{let s=i.gridstackNode;s&&(t?delete s.noMove:s.noMove=!0,this.prepareDragDrop(s.el))}),this)}resizable(e,t){return this.opts.staticGrid?this:(l.getElements(e).forEach(i=>{let s=i.gridstackNode;s&&(t?delete s.noResize:s.noResize=!0,this.prepareDragDrop(s.el))}),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.prepareDragDrop(i.el),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.prepareDragDrop(i.el),i.subGrid&&t&&i.subGrid.enableResize(e,t)}),this)}cancelDrag(){let e=this._placeholder?.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&l._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return M.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 M.droppable(this.el,"destroy"),this;let e,t,i=(s,r,n)=>{n=n||r;let a=n.gridstackNode;if(!a)return;if(!a.grid?.el){n.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;let g=n.getBoundingClientRect();n.style.left=g.x+(this.dragTransform.xScale-1)*(s.clientX-g.x)/this.dragTransform.xScale+"px",n.style.top=g.y+(this.dragTransform.yScale-1)*(s.clientY-g.y)/this.dragTransform.yScale+"px",n.style.transformOrigin="0px 0px"}let{top:u,left:c}=n.getBoundingClientRect(),d=this.el.getBoundingClientRect();c-=d.left,u-=d.top;let p={position:{top:u*this.dragTransform.xScale,left:c*this.dragTransform.yScale}};if(a._temporaryRemoved){if(a.x=Math.max(0,Math.round(c/t)),a.y=Math.max(0,Math.round(u/e)),delete a.autoPosition,this.engine.nodeBoundFix(a),!this.engine.willItFit(a)){if(a.autoPosition=!0,!this.engine.willItFit(a)){M.off(r,"drag");return}a._willFitPos&&(h.copyPos(a,a._willFitPos),delete a._willFitPos)}this._onStartMoving(n,s,p,a,t,e)}else this._dragOrResize(n,s,p,a,t,e)};return M.droppable(this.el,{accept:s=>{let r=s.gridstackNode||this._readAttr(s,!1);if(r?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let n=!0;if(typeof this.opts.acceptWidgets=="function")n=this.opts.acceptWidgets(s);else{let a=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;n=s.matches(a)}if(n&&r&&this.opts.maxRow){let a={w:r.w,h:r.h,minW:r.minW,minH:r.minH};n=this.engine.willItFit(a)}return n}}).on(this.el,"dropover",(s,r,n)=>{let a=n?.gridstackNode||r.gridstackNode;if(a?.grid===this&&!a._temporaryRemoved)return!1;if(a?._sidebarOrig&&(a.w=a._sidebarOrig.w,a.h=a._sidebarOrig.h),a?.grid&&a.grid!==this&&!a._temporaryRemoved&&a.grid._leave(r,n),n=n||r,t=this.cellWidth(),e=this.getCellHeight(!0),!a){let d=n.getAttribute("data-gs-widget")||n.getAttribute("gridstacknode");if(d){try{a=JSON.parse(d)}catch(p){console.error("Gridstack dropover: Bad JSON format: ",d)}n.removeAttribute("data-gs-widget"),n.removeAttribute("gridstacknode")}a||(a=this._readAttr(n)),a._sidebarOrig={w:a.w,h:a.h}}a.grid||(a.el||(a=m({},a)),a._isExternal=!0,n.gridstackNode=a);let u=a.w||Math.round(n.offsetWidth/t)||1,c=a.h||Math.round(n.offsetHeight/e)||1;return a.grid&&a.grid!==this?(r._gridstackNodeOrig||(r._gridstackNodeOrig=a),r.gridstackNode=a=E(m({},a),{w:u,h:c,grid:this}),delete a.x,delete a.y,this.engine.cleanupNode(a).nodeBoundFix(a),a._initDD=a._isExternal=a._temporaryRemoved=!0):(a.w=u,a.h=c,a._temporaryRemoved=!0),l._itemRemoving(a.el,!1),M.on(r,"drag",i),i(s,r,n),!1}).on(this.el,"dropout",(s,r,n)=>{let a=n?.gridstackNode||r.gridstackNode;return a&&(!a.grid||a.grid===this)&&(this._leave(r,n),this._isTemp&&this.removeAsSubGrid(a)),!1}).on(this.el,"drop",(s,r,n)=>{let a=n?.gridstackNode||r.gridstackNode;if(a?.grid===this&&!a._isExternal)return!1;let u=!!this.placeholder.parentElement,c=r!==n;this.placeholder.remove(),delete this.placeholder.gridstackNode,u&&this.opts.animate&&(this.setAnimation(!1),this.setAnimation(!0,!0));let d=r._gridstackNodeOrig;if(delete r._gridstackNodeOrig,u&&d?.grid&&d.grid!==this){let g=d.grid;g.engine.removeNodeFromLayoutCache(d),g.engine.removedNodes.push(d),g._triggerRemoveEvent()._triggerChangeEvent(),g.parentGridNode&&!g.engine.nodes.length&&g.opts.subGridDynamic&&g.removeAsSubGrid()}if(!a||(u&&(this.engine.cleanupNode(a),a.grid=this),delete a.grid?._isTemp,M.off(r,"drag"),n!==r?(n.remove(),r=n):r.remove(),this._removeDD(r),!u))return!1;let p=a.subGrid?.el?.gridstack;return h.copyPos(a,this._readAttr(this.placeholder)),h.removePositioningStyles(r),c&&(a.content||a.subGridOpts||l.addRemoveCB)?(delete a.el,r=this.addWidget(a)):(this._prepareElement(r,!0,a),this.el.appendChild(r),this.resizeToContentCheck(!1,a),p&&(p.parentGridNode=a),this._updateContainerHeight()),this.engine.addedNodes.push(a),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped(E(m({},s),{type:"dropped"}),d&&d.grid?d:void 0,a),!1}),this}static _itemRemoving(e,t){if(!e)return;let i=e?e.gridstackNode:void 0;!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;let e=document.querySelector(this.opts.removable);return e?(!this.opts.staticGrid&&!M.isDroppable(e)&&M.droppable(e,this.opts.removableOptions).on(e,"dropover",(t,i)=>l._itemRemoving(i,!0)).on(e,"dropout",(t,i)=>l._itemRemoving(i,!1)),this):this}prepareDragDrop(e,t=!1){let i=e?.gridstackNode;if(!i)return;let s=i.noMove||this.opts.disableDrag,r=i.noResize||this.opts.disableResize,n=this.opts.staticGrid||s&&r;if((t||n)&&(i._initDD&&(this._removeDD(e),delete i._initDD),n&&e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),!t))return this;if(!i._initDD){let a,u,c=(g,w)=>{this.triggerEvent(g,g.target),a=this.cellWidth(),u=this.getCellHeight(!0),this._onStartMoving(e,g,w,i,a,u)},d=(g,w)=>{this._dragOrResize(e,g,w,i,a,u)},p=g=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete i._moving,delete i._resizing,delete i._event,delete i._lastTried;let w=i.w!==i._orig.w,x=g.target;if(!(!x.gridstackNode||x.gridstackNode.grid!==this)){if(i.el=x,i._isAboutToRemove){let O=e.gridstackNode.grid;O._gsEventHandler[g.type]&&O._gsEventHandler[g.type](g,x),O.engine.nodes.push(i),O.removeWidget(e,!0,!0)}else h.removePositioningStyles(x),i._temporaryRemoved?(this._writePosAttr(x,i),this.engine.addNode(i)):this._writePosAttr(x,i),this.triggerEvent(g,x);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),g.type==="resizestop"&&(Number.isInteger(i.sizeToContent)&&(i.sizeToContent=i.h),this.resizeToContentCheck(w,i))}};M.draggable(e,{start:c,stop:p,drag:d}).resizable(e,{start:c,stop:p,resize:d}),i._initDD=!0}return M.draggable(e,s?"disable":"enable").resizable(e,r?"disable":"enable"),this}_onStartMoving(e,t,i,s,r,n){if(this.engine.cleanNodes().beginUpdate(s),this._writePosAttr(this.placeholder,s),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=s,s.grid?.el)this.dragTransform=h.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){let a=this.placeholder.closest(".grid-stack");this.dragTransform=h.getValuesFromTransformedElement(a)}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",s._resizing=t.type==="resizestart",delete s._lastTried,t.type==="dropover"&&s._temporaryRemoved&&(this.engine.addNode(s),s._moving=!0),this.engine.cacheRects(r,n,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),t.type==="resizestart"){let a=this.getColumn()-s.x,u=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-s.y;M.resizable(e,"option","minWidth",r*Math.min(s.minW||1,a)).resizable(e,"option","minHeight",n*Math.min(s.minH||1,u)).resizable(e,"option","maxWidth",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,a)).resizable(e,"option","maxWidthMoveLeft",r*Math.min(s.maxW||Number.MAX_SAFE_INTEGER,s.x+s.w)).resizable(e,"option","maxHeight",n*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,u)).resizable(e,"option","maxHeightMoveUp",n*Math.min(s.maxH||Number.MAX_SAFE_INTEGER,s.y+s.h))}}_dragOrResize(e,t,i,s,r,n){let a=m({},s._orig),u,c=this.opts.marginLeft,d=this.opts.marginRight,p=this.opts.marginTop,g=this.opts.marginBottom,w=Math.round(n*.1),x=Math.round(r*.1);if(c=Math.min(c,x),d=Math.min(d,x),p=Math.min(p,w),g=Math.min(g,w),t.type==="drag"){if(s._temporaryRemoved)return;let Y=i.position.top-s._prevYPix;s._prevYPix=i.position.top,this.opts.draggable.scroll!==!1&&h.updateScrollPosition(e,i.position,Y);let Xe=i.position.left+(i.position.left>s._lastUiPosition.left?-d:c),ii=i.position.top+(i.position.top>s._lastUiPosition.top?-g:p);a.x=Math.round(Xe/r),a.y=Math.round(ii/n);let si=this._extraDragRow;if(this.engine.collide(s,a)){let Qe=this.getRow(),Je=Math.max(0,a.y+s.h-Qe);this.opts.maxRow&&Qe+Je>this.opts.maxRow&&(Je=Math.max(0,this.opts.maxRow-Qe)),this._extraDragRow=Je}else this._extraDragRow=0;if(this._extraDragRow!==si&&this._updateContainerHeight(),s.x===a.x&&s.y===a.y)return}else if(t.type==="resize"){if(a.x<0||(h.updateScrollResize(t,e,n),a.w=Math.round((i.size.width-c)/r),a.h=Math.round((i.size.height-p)/n),s.w===a.w&&s.h===a.h)||s._lastTried&&s._lastTried.w===a.w&&s._lastTried.h===a.h)return;let Y=i.position.left+c,Xe=i.position.top+p;a.x=Math.round(Y/r),a.y=Math.round(Xe/n),u=!0}s._event=t,s._lastTried=a;let O={x:i.position.left+c,y:i.position.top+p,w:(i.size?i.size.width:s.w*r)-c-d,h:(i.size?i.size.height:s.h*n)-p-g};if(this.engine.moveNodeCheck(s,E(m({},a),{cellWidth:r,cellHeight:n,rect:O,resizing:u}))){s._lastUiPosition=i.position,this.engine.cacheRects(r,n,p,d,g,c),delete s._skipDown,u&&s.subGrid&&s.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();let Y=t.target;s._sidebarOrig||this._writePosAttr(Y,s),this.triggerEvent(t,Y)}}triggerEvent(e,t){let i=this;for(;i.parentGridNode;)i=i.parentGridNode.grid;i._gsEventHandler[e.type]&&i._gsEventHandler[e.type](e,t)}_leave(e,t){t=t||e;let i=t.gridstackNode;if(!i||(t.style.transform=t.style.transformOrigin=null,M.off(e,"drag"),i._temporaryRemoved))return;i._temporaryRemoved=!0,this.engine.removeNode(i),i.el=i._isExternal&&t?t:e;let s=i._sidebarOrig;i._isExternal&&this.engine.cleanupNode(i),i._sidebarOrig=s,this.opts.removable===!0&&l._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):i._isExternal&&this.engine.restoreInitial()}}return l.renderCB=(o,e)=>{o&&e?.content&&(o.textContent=e.content)},l.resizeToContentParent=".grid-stack-item-content",l.Utils=h,l.Engine=ot,l.GDRev="12.4.2",l})();var Kt=["container"],oi=["*"];function ni(l,o){}var ai=["*",[["","empty-content",""]]],li=["*","[empty-content]"];function di(l,o){l&1&&Te(0,1,["*ngIf","isEmpty"])}function hi(l,o){}var Ke=(()=>{class l{serialize(){}deserialize(e){this.widgetItem=e,e&&e.input&&Object.assign(this,e.input)}}return l.\u0275fac=function(e){return new(e||l)},l.\u0275prov=X({token:l,factory:l.\u0275fac}),l})(),jt=(()=>{class l{constructor(e){this.elementRef=e,this.el._gridItemComp=this}set options(e){let t=this.el.gridstackNode?.grid;t?t.update(this.el,e):this._options=E(m({},e),{el:this.el})}get options(){return this.el.gridstackNode||this._options||{el:this.el}}get el(){return this.elementRef.nativeElement}clearOptions(){delete this._options}ngOnDestroy(){this.clearOptions(),delete this.childWidget,delete this.el._gridItemComp,delete this.container,delete this.ref}}return l.\u0275fac=function(e){return new(e||l)(et(pe))},l.\u0275cmp=R({type:l,selectors:[["gridstack-item"]],viewQuery:function(e,t){if(e&1&&me(Kt,7,ge),e&2){let i;Z(i=ee())&&(t.container=i.first)}},inputs:{options:"options"},ngContentSelectors:oi,decls:5,vars:1,consts:[["container",""],[1,"grid-stack-item-content"]],template:function(e,t){e&1&&(it(),J(0,"div",1),ut(1,ni,0,0,"ng-template",null,0,st),Te(3),v(4),fe()),e&2&&(T(4),wt(" ",t.options.content," "))},styles:["[_nghost-%COMP%]{display:block}"]}),l})(),Ce=(()=>{class l{constructor(e){this.elementRef=e,this.addedCB=new A,this.changeCB=new A,this.disableCB=new A,this.dragCB=new A,this.dragStartCB=new A,this.dragStopCB=new A,this.droppedCB=new A,this.enableCB=new A,this.removedCB=new A,this.resizeCB=new A,this.resizeStartCB=new A,this.resizeStopCB=new A,j.addRemoveCB||(j.addRemoveCB=ci),j.saveCB||(j.saveCB=ui),j.updateCB||(j.updateCB=pi),this.el._gridComp=this}set options(e){this._grid?this._grid.updateOptions(e):this._options=e}get options(){return this._grid?.opts||this._options||{}}get el(){return this.elementRef.nativeElement}get grid(){return this._grid}static addComponentToSelectorType(e){e.forEach(t=>l.selectorToType[l.getSelector(t)]=t)}static getSelector(e){return Et(e).selector}ngOnInit(){this.loaded=!!this.options?.children?.length,this._grid=j.init(this._options,this.el),delete this._options,this.checkEmpty()}ngAfterContentInit(){this._sub=this.gridstackItems?.changes.subscribe(()=>this.updateAll()),this.loaded||this.updateAll(),this.hookEvents(this.grid)}ngOnDestroy(){this.unhookEvents(this._grid),this._sub?.unsubscribe(),this._grid?.destroy(),delete this._grid,delete this.el._gridComp,delete this.container,delete this.ref}updateAll(){if(!this.grid)return;let e=[];this.gridstackItems?.forEach(t=>{e.push(t.options),t.clearOptions()}),this.grid.load(e)}checkEmpty(){this.grid&&(this.isEmpty=!this.grid.engine.nodes.length)}hookEvents(e){e&&(e.parentGridNode||e.on("added",(t,i)=>{(i[0].grid?.el._gridComp||this).checkEmpty(),this.addedCB.emit({event:t,nodes:i})}).on("change",(t,i)=>this.changeCB.emit({event:t,nodes:i})).on("disable",t=>this.disableCB.emit({event:t})).on("drag",(t,i)=>this.dragCB.emit({event:t,el:i})).on("dragstart",(t,i)=>this.dragStartCB.emit({event:t,el:i})).on("dragstop",(t,i)=>this.dragStopCB.emit({event:t,el:i})).on("dropped",(t,i,s)=>this.droppedCB.emit({event:t,previousNode:i,newNode:s})).on("enable",t=>this.enableCB.emit({event:t})).on("removed",(t,i)=>{(i[0].grid?.el._gridComp||this).checkEmpty(),this.removedCB.emit({event:t,nodes:i})}).on("resize",(t,i)=>this.resizeCB.emit({event:t,el:i})).on("resizestart",(t,i)=>this.resizeStartCB.emit({event:t,el:i})).on("resizestop",(t,i)=>this.resizeStopCB.emit({event:t,el:i})))}unhookEvents(e){e&&(e.parentGridNode||e.off("added change disable drag dragstart dragstop dropped enable removed resize resizestart resizestop"))}}return l.selectorToType={},l.\u0275fac=function(e){return new(e||l)(et(pe))},l.\u0275cmp=R({type:l,selectors:[["gridstack"]],contentQueries:function(e,t,i){if(e&1&&yt(i,jt,4),e&2){let s;Z(s=ee())&&(t.gridstackItems=s)}},viewQuery:function(e,t){if(e&1&&me(Kt,7,ge),e&2){let i;Z(i=ee())&&(t.container=i.first)}},inputs:{options:"options",isEmpty:"isEmpty"},outputs:{addedCB:"addedCB",changeCB:"changeCB",disableCB:"disableCB",dragCB:"dragCB",dragStartCB:"dragStartCB",dragStopCB:"dragStopCB",droppedCB:"droppedCB",enableCB:"enableCB",removedCB:"removedCB",resizeCB:"resizeCB",resizeStartCB:"resizeStartCB",resizeStopCB:"resizeStopCB"},ngContentSelectors:li,decls:4,vars:1,consts:[["container",""],[4,"ngIf"]],template:function(e,t){e&1&&(it(ai),ct(0,di,1,0,"ng-content",1)(1,hi,0,0,"ng-template",null,0,st),Te(3)),e&2&&L("ngIf",t.isEmpty)},dependencies:[Dt],styles:["[_nghost-%COMP%]{display:block}"]}),l})();function ci(l,o,e,t){if(e){if(!l)return;if(t){let i=l.parentElement?._gridItemComp;if(!i)return;let r=(i.childWidget?.container||i.container)?.createComponent(Ce),n=r?.instance;return n?(n.ref=r,n.options=o,n.el):void 0}else{let s=l._gridComp?.container?.createComponent(jt),r=s?.instance;if(!r)return;r.ref=s;let n=o.selector,a=n?Ce.selectorToType[n]:void 0;if(a){let u=()=>{let d=r.container?.createComponent(a)?.instance;d&&typeof d.serialize=="function"&&typeof d.deserialize=="function"&&(r.childWidget=d,d.deserialize(o))};o.lazyLoad||o.grid?.opts?.lazyLoad&&o.lazyLoad!==!1?o.visibleObservable||(o.visibleObservable=new IntersectionObserver(([d])=>{d.isIntersecting&&(o.visibleObservable?.disconnect(),delete o.visibleObservable,u())}),window.setTimeout(()=>o.visibleObservable?.observe(r.el))):u()}return r.el}}else if(t){let i=o.el?._gridComp;i?.ref?i.ref.destroy():i?.ngOnDestroy()}else{let i=o.el?._gridItemComp;i?.ref?i.ref.destroy():i?.ngOnDestroy()}}function ui(l,o){let e=l.el?._gridItemComp;if(e){let i=e.childWidget?.serialize();i&&(o.input=i);return}let t=l.el?._gridComp}function pi(l){let o=l,e=l.el?._gridItemComp;e?.childWidget&&o.input&&e.childWidget.deserialize(o)}var gi=(l,o)=>o.id;function fi(l,o){if(l&1&&ft(0,"div",4),l&2){let e=o.$index;S(2);let t=te(0);Re("background-color",t===e?"var(--mat-sys-on-surface)":"var(--mat-sys-inverse-on-surface)")}}function mi(l,o){if(l&1&&(J(0,"div",0),tt("fade-toast"),J(1,"span",1),v(2),fe()(),J(3,"div",2),tt("fade-toast"),pt(4,fi,1,2,"div",3,gi),fe()),l&2){S();let e=te(0),t=te(1);T(2),vt(t[e].name),T(2),gt(t)}}var Yt=(()=>{class l{activePage=$();dashboards=$();visible=ue(!1);constructor(){B(()=>{let e=this.activePage();if(e==null){this.visible.set(!1);return}this.visible.set(!1),queueMicrotask(()=>this.visible.set(!0))})}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=R({type:l,selectors:[["dashboard-scroller"]],inputs:{activePage:[1,"activePage"],dashboards:[1,"dashboards"]},decls:3,vars:3,consts:[[1,"page-scroll-title","page-scroll-container"],[1,"page-label"],[1,"page-scroll-page-number","page-scroll-container","fade-toast"],[1,"page-marker",3,"background-color"],[1,"page-marker"]],template:function(t,i){t&1&&(ze(0)(1),I(2,mi,6,1)),t&2&&(ye(i.activePage()),T(),ye(i.dashboards()),T(),W(i.visible()?2:-1))},styles:["[_nghost-%COMP%]{pointer-events:none}.page-scroll-title[_ngcontent-%COMP%]{position:absolute;top:50%;right:54px;transform:translateY(-50%);z-index:100;cursor:default;text-align:center;padding:10px;color:var(--mat-sys-inverse-surface)}.page-scroll-page-number[_ngcontent-%COMP%]{position:absolute;top:50%;right:15px;transform:translateY(-50%);z-index:100;cursor:default;display:grid;padding:0}.page-scroll-container[_ngcontent-%COMP%]{opacity:0;background-color:var(--mat-sys-tertiary-fixed-dim);border-radius:10px;border:1px solid var(--mat-sys-inverse-surface)}.page-label[_ngcontent-%COMP%]{color:var(--mat-sys-on-surface);text-shadow:1px 1px 0 var(--mat-sys-outline),-1px 1px 0 var(--mat-sys-outline),-1px -1px 0 var(--mat-sys-outline),1px -1px 0 var(--mat-sys-outline);font-size:x-large}.page-marker[_ngcontent-%COMP%]{height:20px;width:20px;margin:4px;border-radius:50%;border:1px solid var(--mat-sys-outline)}@keyframes _ngcontent-%COMP%_fadeInHoldFadeOut{0%{opacity:0}7.407%{opacity:1}25.926%{opacity:1}to{opacity:0}}.fade-toast[_ngcontent-%COMP%]{opacity:0;animation:_ngcontent-%COMP%_fadeInHoldFadeOut 1.35s linear forwards}"]})}return l})();var Xt=(()=>{class l{twoFingerTapEnabled=$(!0);twoFingerTapMaxDurationMs=$(450);twoFingerTapMoveThresholdPx=$(24);twoFingerTapPreventDefault=$(!0);twoFingerTap=Ct();pointers=new Map;candidate=!1;moved=!1;startedAtMs=0;blocked=!1;onPointerDown(e){if(!(!this.twoFingerTapEnabled()||e.pointerType!=="touch")){if(this.pointers.set(e.pointerId,{x:e.clientX,y:e.clientY}),this.pointers.size===2&&!this.blocked){this.candidate=!0,this.moved=!1,this.startedAtMs=Date.now();return}this.pointers.size>2&&(this.blocked=!0,this.resetTracking(!1))}}onPointerMove(e){if(!this.candidate||e.pointerType!=="touch")return;let t=this.pointers.get(e.pointerId);if(!t)return;let i=e.clientX-t.x,s=e.clientY-t.y;Math.hypot(i,s)>this.twoFingerTapMoveThresholdPx()&&(this.moved=!0)}onPointerUp(e){if(e.pointerType!=="touch")return;if(this.pointers.delete(e.pointerId),this.blocked){this.pointers.size===0&&(this.blocked=!1);return}if(!this.candidate||this.pointers.size>0)return;let t=Date.now()-this.startedAtMs,i=!this.moved&&t<=this.twoFingerTapMaxDurationMs();this.resetTracking(!1),i&&(this.twoFingerTapPreventDefault()&&(e.preventDefault(),e.stopPropagation()),this.twoFingerTap.emit(e))}onPointerCancel(e){e.pointerType==="touch"&&(this.pointers.delete(e.pointerId),this.pointers.size===0&&this.resetTracking(!0))}resetTracking(e){this.pointers.clear(),this.candidate=!1,this.moved=!1,this.startedAtMs=0,e||(this.blocked=!1)}static \u0275fac=function(t){return new(t||l)};static \u0275dir=ht({type:l,selectors:[["","twoFingerTap",""]],hostBindings:function(t,i){t&1&&C("pointerdown",function(r){return i.onPointerDown(r)})("pointermove",function(r){return i.onPointerMove(r)})("pointerup",function(r){return i.onPointerUp(r)})("pointercancel",function(r){return i.onPointerCancel(r)})},inputs:{twoFingerTapEnabled:[1,"twoFingerTapEnabled"],twoFingerTapMaxDurationMs:[1,"twoFingerTapMaxDurationMs"],twoFingerTapMoveThresholdPx:[1,"twoFingerTapMoveThresholdPx"],twoFingerTapPreventDefault:[1,"twoFingerTapPreventDefault"]},outputs:{twoFingerTap:"twoFingerTap"}})}return l})();function bi(l,o){if(l&1){let e=U();y(0,"button",0),C("click",function(){H(e);let i=S();return N(i.clickAction("cancel"))}),y(1,"mat-icon",1),v(2,"close"),_(),y(3,"span"),v(4,"Close"),_()()}}var je=(()=>{class l{_bottomSheetRef=b(Ie);data=b(Bt);showCancel=!!(this.data&&this.data.showCancel);clickAction(e){this._bottomSheetRef.dismiss(e)}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=R({type:l,selectors:[["widget-host-bottom-sheet"]],decls:22,vars:1,consts:[["mat-list-item","",3,"click"],["matListItemIcon",""],["mat-list-item",""]],template:function(t,i){t&1&&(y(0,"mat-action-list")(1,"button",0),C("click",function(){return i.clickAction("duplicate")}),y(2,"mat-icon",1),v(3,"add_to_photos"),_(),y(4,"span"),v(5,"Duplicate"),_()(),y(6,"button",0),C("click",function(){return i.clickAction("copy")}),y(7,"mat-icon",1),v(8,"content_copy"),_(),y(9,"span"),v(10,"Copy"),_()(),y(11,"button",0),C("click",function(){return i.clickAction("cut")}),y(12,"mat-icon",1),v(13,"content_cut"),_(),y(14,"span"),v(15,"Cut"),_()(),y(16,"button",0),C("click",function(){return i.clickAction("delete")}),y(17,"mat-icon",1),v(18,"delete_forever"),_(),y(19,"span"),v(20,"Delete"),_()(),I(21,bi,5,0,"button",2),_()),t&2&&(T(21),W(i.showCancel?21:-1))},dependencies:[Ge,Be,Fe,Le,re,se],encapsulation:2})}return l})();var Ye=(()=>{class l{http=b(kt);connection=b(Oe);pluginConfig=b(oe);destroyRef=b(Q);kipPluginServiceUrl=null;constructor(){this.connection.serverServiceEndpoint$.pipe(ve(this.destroyRef)).subscribe(e=>{let t=e?.httpServiceUrl||null;this.kipPluginServiceUrl=this.resolveKipPluginServiceUrl(t)})}resolveKipPluginServiceUrl(e){let t=this.connection.signalKURL?.url?.trim();return t?`${t.endsWith("/")?t.slice(0,-1):t}/plugins/kip/`:e?`${(e.endsWith("/")?e.slice(0,-1):e).replace(/\/signalk\/v2\/api$/,"").replace(/\/signalk\/v1\/api$/,"").replace(/\/signalk\/v2$/,"").replace(/\/signalk\/v1$/,"").replace(/\/signalk$/,"")}/plugins/kip/`:null}reconcileSeries(e){return D(this,null,function*(){try{if(!(yield this.pluginConfig.getKipRuntimeModeConfigCached("kip")).historySeriesServiceEnabled)return console.warn("[KipSeriesApiClientService] Reconcile skipped because history-series service is disabled in KIP plugin settings"),null;if(!this.kipPluginServiceUrl)return console.warn("[KipSeriesApiClientService] No KIP plugin endpoint available for series reconcile"),null;let i=`${this.kipPluginServiceUrl}series/reconcile`;console.log(`[KipSeriesApiClientService] POST ${i} (${e.length} series)`);let s=yield xe(this.http.post(i,e));return console.log(`[KipSeriesApiClientService] Series reconcile successful (created=${s.created}, updated=${s.updated}, deleted=${s.deleted}, total=${s.total})`),s}catch(t){return console.error("[KipSeriesApiClientService] Series reconcile request failed:",t),null}})}getSeriesDefinitions(){return D(this,null,function*(){try{if(!(yield this.pluginConfig.getKipRuntimeModeConfigCached("kip")).historySeriesServiceEnabled)return console.warn("[KipSeriesApiClientService] Series list skipped because history-series service is disabled in KIP plugin settings"),null;if(!this.kipPluginServiceUrl)return console.warn("[KipSeriesApiClientService] No KIP plugin endpoint available for series list"),null;let t=`${this.kipPluginServiceUrl}series`;return yield xe(this.http.get(t))}catch(e){return console.error("[KipSeriesApiClientService] Series list request failed:",e),null}})}getValues(e){return D(this,null,function*(){try{if(!this.kipPluginServiceUrl)return console.warn("[HistoryApiClientService] No HTTP service URL available"),null;let t=`${this.kipPluginServiceUrl}history/values`,i=new St;i=i.set("paths",e.paths),e.context&&(i=i.set("context",e.context)),e.from&&(i=i.set("from",e.from)),e.to&&(i=i.set("to",e.to)),e.duration&&(i=i.set("duration",e.duration.toString())),e.resolution!==void 0&&e.resolution!==null&&(i=i.set("resolution",e.resolution.toString()));let s=`${t}?${i.toString()}`;console.log(`[HistoryApiClientService] GET ${s}`);let r=yield xe(this.http.get(t,{params:i}));return console.log(`[HistoryApiClientService] History fetch successful, received ${r.data?.length??0} data points`),r}catch(t){return console.error("[HistoryApiClientService] History API request failed:",t),null}})}static \u0275fac=function(t){return new(t||l)};static \u0275prov=X({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var _i={batteries:"bms",solar:"solarCharger",chargers:"charger",inverters:"inverter",alternators:"alternator",ac:"ac"},Jt=(()=>{class l{dashboard=b(V);kipSeries=b(Ye);destroyRef=b(Q);connection=b(Oe);pluginConfig=b(oe);widgetService=b(Ae);serverEndpoint=Pe(this.connection.serverServiceEndpoint$,{initialValue:null});RECONCILE_DEBOUNCE_MS=750;AUTO_RETENTION_MS=1440*60*1e3;reconcileTimer=null;lastSubmittedSignature=null;pendingSignature=null;pendingSeries=[];constructor(){B(()=>{let e=this.serverEndpoint(),t=this.dashboard.dashboards();if(e?.httpServiceUrl)try{let i=this.extractSeriesFromDashboards(t);this.scheduleReconcile(i)}catch(i){console.error("[DashboardHistorySeriesSyncService] Error extracting series from dashboards:",i)}}),this.destroyRef.onDestroy(()=>{this.reconcileTimer!==null&&(clearTimeout(this.reconcileTimer),this.reconcileTimer=null)})}scheduleReconcile(e){let t=this.getCanonicalSeriesSignature(e);t!==this.lastSubmittedSignature&&(this.pendingSeries=e,this.pendingSignature=t,this.reconcileTimer!==null&&clearTimeout(this.reconcileTimer),this.reconcileTimer=window.setTimeout(()=>{this.flushReconcile()},this.RECONCILE_DEBOUNCE_MS))}flushReconcile(){return D(this,null,function*(){if(!this.pendingSignature)return;let e=this.pendingSignature,t=this.pendingSeries;if(this.pendingSignature=null,this.reconcileTimer=null,!(yield this.pluginConfig.getKipRuntimeModeConfigCached("kip")).historySeriesServiceEnabled){console.warn("[DashboardHistorySeriesSyncService] Reconcile skipped because history series service mode is disabled"),this.lastSubmittedSignature=e;return}try{yield this.kipSeries.reconcileSeries(t),this.lastSubmittedSignature=e}catch(s){console.error("[DashboardHistorySeriesSyncService] Reconcile failed:",s)}})}extractSeriesFromDashboards(e){let t=[];return e.forEach(i=>{let s=this.coerceNodeList(i.configuration);this.collectSeriesFromNodes(s,t)}),t.sort((i,s)=>i.seriesId.localeCompare(s.seriesId))}resolveSeriesForWidget(e){let t=e?.type,i=e?.uuid,s=this.resolveWidgetConfig(t,e?.config);if(!t||!i||s?.supportAutomaticHistoricalSeries===!1)return[];if(t==="widget-data-chart"){let n=this.mapDataChartWidget(i,t,s);return n?[n]:[]}if(t==="widget-windtrends-chart")return this.mapWindTrendsWidget(i,t,s);let r=we(t);if(r?.templateExpansionMode){let n=this.mapElectricalTemplateWidget(i,s,r);if(n)return[n]}return this.mapAutomaticHistorySeries(i,t,s)}resolveWidgetConfig(e,t){if(!e)return t;let i=this.getDefaultConfigForType(e);return i?t?E(m(m({},i),t),{paths:t.paths??i.paths}):i:t}getDefaultConfigForType(e){try{return this.widgetService.getComponentType(e)?.DEFAULT_CONFIG}catch(t){return}}collectSeriesFromNodes(e,t){e.forEach(i=>{let s=i?.input?.widgetProperties;t.push(...this.resolveSeriesForWidget(s));let r=this.coerceNodeList(i?.subGridOpts?.children);r.length>0&&this.collectSeriesFromNodes(r,t)})}mapDataChartWidget(e,t,i){let s=this.normalizeString(i?.datachartPath);return s?{seriesId:`${e}:datachart`,datasetUuid:e,ownerWidgetUuid:e,ownerWidgetSelector:t,path:s,context:null,source:this.normalizeString(i?.datachartSource),timeScale:this.normalizeString(i?.timeScale),period:this.normalizeNumber(i?.period),retentionDurationMs:null,sampleTime:null,enabled:!0}:null}mapWindTrendsWidget(e,t,i){let s={ownerWidgetUuid:e,ownerWidgetSelector:t,context:null,source:"default",timeScale:this.normalizeString(i?.timeScale),period:30,retentionDurationMs:null,sampleTime:null,enabled:!0};return[E(m({},s),{seriesId:`${e}:wind-direction`,datasetUuid:`${e}-twd`,path:"self.environment.wind.directionTrue"}),E(m({},s),{seriesId:`${e}:wind-speed`,datasetUuid:`${e}-tws`,path:"self.environment.wind.speedTrue"})]}mapElectricalTemplateWidget(e,t,i){let s=i.templateExpansionMode;if(!s)return null;let r=this.resolveElectricalAllowedIds(t,i.familyKey),n=this.resolveTrackedDevicePairs(t,i.familyKey),a=i.familyKey;return{seriesId:`${e}:${a}-template`,datasetUuid:`${e}:${a}-template`,ownerWidgetUuid:e,ownerWidgetSelector:i.selector,path:`${i.selfRootPath}.*`,expansionMode:s,familyKey:i.familyKey,allowedIds:r.length>0?[...r]:null,trackedDevices:n.length>0?[...n]:null,context:null,source:"default",timeScale:this.normalizeString(t?.timeScale),period:this.normalizeNumber(t?.period),retentionDurationMs:this.AUTO_RETENTION_MS,sampleTime:null,enabled:!0}}resolveElectricalAllowedIds(e,t){let i=this.resolveFamilyConfig(e,t);if(!i)return[];let s=this.resolveTrackedDevicePairs(e,t);if(s.length===0)return[];let r=new Set,n=new Set,a=s.map(d=>d.id);return this.collectStringIdsIntoSet(r,a),this.collectStringIdsIntoSet(n,a),(Array.isArray(i.groups)?i.groups:[]).forEach(d=>{this.collectStringIdsIntoSet(n,d.memberIds,r),this.collectStringIdsIntoSet(n,d.batteryIds,r)}),(Array.isArray(i.banks)?i.banks:[]).forEach(d=>{this.collectStringIdsIntoSet(n,d.memberIds,r),this.collectStringIdsIntoSet(n,d.batteryIds,r)}),[...n].sort((d,p)=>d.localeCompare(p))}resolveFamilyConfig(e,t){if(!e)return null;let s=e[_i[t]];return s&&typeof s=="object"?s:null}resolveTrackedDevicePairs(e,t){let i=this.resolveFamilyConfig(e,t);if(!i||!Array.isArray(i.trackedDevices))return[];let s=new Map;return i.trackedDevices.forEach(r=>{if(!r||typeof r!="object")return;let n=r,a=this.normalizeString(n.id);if(!a)return;let u=this.normalizeString(n.source)??"default";s.set(`${a}||${u}`,{id:a,source:u})}),[...s.values()].sort((r,n)=>{let a=r.id.localeCompare(n.id);return a!==0?a:r.source.localeCompare(n.source)})}collectStringIdsIntoSet(e,t,i){Array.isArray(t)&&t.forEach(s=>{if(typeof s!="string")return;let r=this.normalizeTrackedIdentifierToId(s);if(r.length>0){if(i&&!i.has(r))return;e.add(r)}})}normalizeTrackedIdentifierToId(e){let t=e.trim();if(t.length===0)return"";let i=t.indexOf("||");return i<0?t:t.slice(0,i).trim()}mapAutomaticHistorySeries(e,t,i){let s=this.extractWidgetPaths(i?.paths),r=new Map;return s.forEach(n=>{if(n.pathType!=="number")return;let a=this.normalizeString(n.path);if(!a)return;let u=this.normalizeString(n.source),c=`${a}|${u??"default"}`;if(r.has(c))return;let d=this.slugify(a),p=this.slugify(u??"default"),g=this.normalizeNumber(n.sampleTime);r.set(c,{seriesId:`${e}:auto:${d}:${p}`,datasetUuid:`${e}:${d}:${p}`,ownerWidgetUuid:e,ownerWidgetSelector:t,path:a,context:null,source:u,timeScale:this.normalizeString(i?.timeScale),period:this.normalizeNumber(i?.period),retentionDurationMs:this.AUTO_RETENTION_MS,sampleTime:g,enabled:!0})}),[...r.values()]}extractWidgetPaths(e){return e?Array.isArray(e)?e:Object.values(e):[]}slugify(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}normalizeString(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}normalizeNumber(e){return typeof e!="number"||!Number.isFinite(e)?null:e}coerceNodeList(e){return Array.isArray(e)?e:[]}getCanonicalSeriesSignature(e){let t=e.map(i=>({seriesId:i.seriesId,datasetUuid:i.datasetUuid,ownerWidgetUuid:i.ownerWidgetUuid,ownerWidgetSelector:i.ownerWidgetSelector,path:i.path,expansionMode:i.expansionMode??null,familyKey:i.familyKey??null,allowedIds:Array.isArray(i.allowedIds)?[...i.allowedIds].sort():null,trackedDevices:Array.isArray(i.trackedDevices)?[...i.trackedDevices].map(s=>({id:s.id,source:s.source})).sort((s,r)=>{let n=s.id.localeCompare(r.id);return n!==0?n:s.source.localeCompare(r.source)}):null,context:i.context??null,source:i.source??null,timeScale:i.timeScale??null,period:i.period??null,retentionDurationMs:i.retentionDurationMs??null,sampleTime:i.sampleTime??null,enabled:i.enabled}));return JSON.stringify(t)}static \u0275fac=function(t){return new(t||l)};static \u0275prov=X({token:l,factory:l.\u0275fac,providedIn:"root"})}return l})();var wi=["childOutlet"],Zt=(()=>{class l extends Ke{widgetProperties;outlet;dialog=b(ne);dashboard=b(V);bottomSheet=b(ae);streams=b(He,{optional:!0});meta=b(Ne,{optional:!0});runtime=b(q,{optional:!0});widgetService=b(Ae);app=b(Ht);historySync=b(Jt);kipSeries=b(Ye);_uiEvent=b(We);settings=b(Mt);theme=Pe(this.app.cssThemeColorRoles$,{requireSync:!0});dashboardStaticView=_e(()=>this.dashboard.isDashboardStatic());childRef=null;compType;_hasInitialized=!1;openOverlays=new Set;isDebugEnabled(){try{return typeof localStorage<"u"&&localStorage.getItem("kip:gesturesDebug")==="1"}catch(e){return!1}}debug(...e){this.isDebugEnabled()&&console.debug("[Host2]",...e)}acquireOverlay(e){return this.openOverlays.has(e)?(this.debug(`${e} already open; ignoring`,{widgetId:this.widgetProperties?.uuid}),!1):(this.openOverlays.add(e),!0)}releaseOverlay(e){this.openOverlays.delete(e)}constructor(){super(),B(()=>{let e=this.dashboard.layoutEditCanceled();!this._hasInitialized||!e||be(()=>{this.reinitFromSavedConfig()})})}ngOnInit(){let e=this.widgetProperties.type;if(!e)return;let t=this.widgetProperties.autoOpenOptionsOnCreate===!0;t&&delete this.widgetProperties.autoOpenOptionsOnCreate,this.compType=this.widgetService.getComponentType(e);let i=this.getDefaultConfig();this.runtime?.initialize?.(i,this.widgetProperties.config);let s=this.runtime?.options();s&&(this.widgetProperties.config=s),this.streams?.applyStreamsConfigDiff?.(s),this.meta?.applyMetaConfigDiff?.(s),this.outlet&&this.compType&&(this.childRef=this.outlet.createComponent(this.compType,{bindings:[Ee("id",()=>this.widgetProperties.uuid),Ee("type",()=>this.widgetProperties.type),Ee("theme",this.theme)]})),this._hasInitialized=!0,t&&queueMicrotask(()=>this.openWidgetOptions(new Event("kip:auto-open-options")))}ngOnDestroy(){this.childRef?.destroy(),this.childRef=null,this.openOverlays.clear()}serialize(){let e=this.runtime?.options();return e?this.widgetProperties.config=e:this.widgetProperties.config||(this.widgetProperties.config={}),{widgetProperties:this.widgetProperties}}applyRuntimeConfig(e){e&&this.runtime?.setRuntimeConfig?.(e);let t=this.runtime?.options();t&&(this.widgetProperties.config=t),this.streams?.applyStreamsConfigDiff?.(t),this.meta?.applyMetaConfigDiff?.(t)}reinitFromSavedConfig(){try{let e=this.getSavedConfigForSelf(),t=this.getDefaultConfig();this.runtime?.initialize?.(t,F(e));let i=this.runtime?.options();i&&(this.widgetProperties.config=i),this.streams?.applyStreamsConfigDiff?.(i),this.meta?.applyMetaConfigDiff?.(i)}catch(e){console.error("[Host2] failed to reinitialize saved config",{widgetId:this.widgetProperties?.uuid,error:e})}}getSavedConfigForSelf(){try{let e=this.dashboard.dashboards(),t=this.dashboard.activeDashboard(),r=(e?.[t]?.configuration??[]).find(n=>n?.id===this.widgetProperties.uuid);return r?.input?.widgetProperties?.config??r?.widgetProperties?.config??void 0}catch(e){return}}getDefaultConfig(){let e=this.compType&&this.compType.DEFAULT_CONFIG;if(!e&&this.compType&&this.outlet){let t=this.outlet.createComponent(this.compType);e=t.instance.defaultConfig,t.destroy()}return e}openWidgetOptions(e){if(e.stopPropagation(),this.debug("openWidgetOptions invoked",{widgetId:this.widgetProperties?.uuid,static:this.dashboard.isDashboardStatic()}),!this.dashboard.isDashboardStatic()){if(!this.acquireOverlay("options"))return;if(!this.widgetProperties){this.releaseOverlay("options");return}try{this.dialog.openWidgetOptions({title:"Widget Options",config:this.widgetProperties.config,confirmBtnText:"Save",cancelBtnText:"Cancel"}).afterClosed().subscribe(t=>{this.releaseOverlay("options"),t&&(this.debug("options saved",{widgetId:this.widgetProperties?.uuid}),this.applyRuntimeConfig(t))})}catch(t){this.releaseOverlay("options"),console.error("[Host2] failed to open widget options",{widgetId:this.widgetProperties?.uuid,error:t})}}}openBottomSheet(e){if(e.stopPropagation(),this.debug("openBottomSheet invoked",{widgetId:this.widgetProperties?.uuid,static:this.dashboard.isDashboardStatic()}),!this.dashboard.isDashboardStatic()){if(this._uiEvent.isDragging()){this.debug("bottom sheet suppressed during drag",{widgetId:this.widgetProperties?.uuid});return}if(!this.acquireOverlay("sheet"))return;let t=typeof navigator<"u"&&/Linux/.test(navigator.platform)&&/Firefox/.test(navigator.userAgent);try{this.bottomSheet.open(je,t?{disableClose:!0,data:{showCancel:!0}}:{}).afterDismissed().subscribe(s=>{switch(this.releaseOverlay("sheet"),this.debug("bottom sheet dismissed",{widgetId:this.widgetProperties?.uuid,action:s}),s){case"delete":this.dashboard.deleteWidget(this.widgetProperties.uuid);break;case"duplicate":this.dashboard.duplicateWidget(this.widgetProperties.uuid);break;case"copy":this.dashboard.copyWidget(this.widgetProperties.uuid);break;case"cut":this.dashboard.cutWidget(this.widgetProperties.uuid);break;default:break}})}catch(i){this.releaseOverlay("sheet"),console.error("[Host2] failed to open bottom sheet",{widgetId:this.widgetProperties?.uuid,error:i})}}}openWidgetHistoryDialog(e){e.preventDefault(),e.stopPropagation(),this.openWidgetHistoryDialogInternal()}onHistoryTwoFingerTap(e){e.preventDefault(),e.stopPropagation(),this.openWidgetHistoryDialogInternal()}openWidgetHistoryDialogInternal(){return D(this,null,function*(){if(!this.settings.getWidgetHistoryDisabled()&&this.dashboard.isDashboardStatic()&&this.acquireOverlay("history"))try{let e=yield this.resolveEffectiveSeriesDefinitions();if(!this.isHistoryDialogEligible(this.widgetProperties,e)){this.releaseOverlay("history");return}let t=we(this.widgetProperties?.type),i=this.widgetProperties?.config?.displayName||t?.displayTitle||"Widget Data History";this.dialog.openWidgetHistoryDialog({title:i,widget:this.widgetProperties,seriesDefinitions:e}).afterClosed().subscribe(()=>{this.releaseOverlay("history")})}catch(e){this.releaseOverlay("history"),console.error("[Host2] failed to open history dialog",{widgetId:this.widgetProperties?.uuid,error:e})}})}resolveEffectiveSeriesDefinitions(){return D(this,null,function*(){let e=this.historySync.resolveSeriesForWidget(this.widgetProperties);if(!e.some(rt))return e;let i=yield this.kipSeries.getSeriesDefinitions();if(!i)return e;let s=this.widgetProperties?.uuid;if(!s)return e;let r=new Set(e.filter(rt).map(n=>{let a=(n.path??"").trim(),u=a.endsWith(".*")?a.slice(0,-2):a;return u.length?u.startsWith("self.")?u.slice(5):u:null}).filter(n=>!!n));return r.size===0?e:i.filter(n=>{if(n.ownerWidgetUuid!==s||!Lt(n))return!1;let a=(n.path??"").trim();if(!a.length)return!1;let u=a.startsWith("self.")?a.slice(5):a;return Array.from(r).some(c=>u.startsWith(`${c}.`))})})}isHistoryDialogEligible(e,t){if(!e?.config||e.config.supportAutomaticHistoricalSeries===!1)return!1;let i=we(e.type);if(t.some(r=>typeof r.expansionMode=="string"||r.enabled===!0)&&i?.templateExpansionMode)return t.some(r=>r.enabled===!0);let s=this.extractNumericPaths(e.config.paths);return s.length?t.some(r=>{let n=typeof r.path=="string"?r.path.trim():"";return s.includes(n)?r.enabled===!0:!1}):!1}extractNumericPaths(e){if(!e)return[];let t=Array.isArray(e)?e:Object.values(e),i=new Set;return t.forEach(s=>{if(s?.pathType!=="number")return;let r=typeof s.path=="string"?s.path.trim():"";r.length&&i.add(r)}),[...i]}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=R({type:l,selectors:[["widget-host2"]],viewQuery:function(t,i){if(t&1&&me(wi,7,ge),t&2){let s;Z(s=ee())&&(i.outlet=s.first)}},inputs:{widgetProperties:"widgetProperties"},features:[De([He,Ne,q]),Se],decls:3,vars:3,consts:[["childOutlet",""],["kipGestures","","mode","press","appearance","raised","twoFingerTap","",1,"widget-container","kip-widget-card-colors",3,"twoFingerTap","doubletap","press","contextmenu","twoFingerTapEnabled"]],template:function(t,i){t&1&&(y(0,"mat-card",1),C("twoFingerTap",function(r){return i.onHistoryTwoFingerTap(r)})("doubletap",function(r){return i.openWidgetOptions(r)})("press",function(r){return i.openBottomSheet(r)})("contextmenu",function(r){return i.openWidgetHistoryDialog(r)}),mt(1,null,0),_()),t&2&&(Re("border",i.dashboardStaticView()?"1px dashed transparent":"1px dashed var(--mat-sys-outline)"),L("twoFingerTapEnabled",i.dashboardStaticView()))},dependencies:[At,Nt,Ft,ie,Xt],styles:["[_nghost-%COMP%]{width:100%;height:100%;display:block;overflow:hidden}.widget-container[_ngcontent-%COMP%]{display:block;width:100%;height:100%;margin:0;padding:0}.kip-widget-card-colors[_ngcontent-%COMP%]{background-color:var(--kip-widget-card-background-color)}"],changeDetection:0})}return l})();function Ci(l,o){if(l&1){let e=U();y(0,"div",2),C("doubletap",function(i){H(e);let s=S();return N(s.openWidgetOptions(i))})("press",function(i){H(e);let s=S();return N(s.openBottomSheet(i))}),_()}}var ei=(()=>{class l extends Ke{widgetProperties;dashboard=b(V);_dialog=b(ne);_bottomSheet=b(ae);runtime=b(q);static DEFAULT_CONFIG={displayName:"Gauge Label",color:"contrast"};_sheetOpen=!1;_optionsOpen=!1;constructor(){super()}ngOnInit(){let e=this.widgetProperties.autoOpenOptionsOnCreate===!0;e&&delete this.widgetProperties.autoOpenOptionsOnCreate,this.runtime?.initialize?.(l.DEFAULT_CONFIG,this.widgetProperties.config),e&&queueMicrotask(()=>this.openWidgetOptions(new Event("kip:auto-open-options")))}serialize(){let e=this.runtime?.options();return e?this.widgetProperties.config=e:this.widgetProperties.config||(this.widgetProperties.config={}),{widgetProperties:this.widgetProperties}}openWidgetOptions(e){if(e.stopPropagation(),!this.dashboard.isDashboardStatic()){if(this._optionsOpen)return;this._optionsOpen=!0,this._dialog.openWidgetOptions({title:"Widget Options",config:F(this.runtime.options()),confirmBtnText:"Save",cancelBtnText:"Cancel"}).afterClosed().subscribe(t=>{this._optionsOpen=!1,t&&this.runtime.setRuntimeConfig(t)})}}openBottomSheet(e){if(e.stopPropagation(),!this.dashboard.isDashboardStatic()){if(this._sheetOpen)return;this._sheetOpen=!0;let t=typeof navigator<"u"&&/Linux/.test(navigator.platform)&&/Firefox/.test(navigator.userAgent);this._bottomSheet.open(je,t?{disableClose:!0,data:{showCancel:!0}}:{}).afterDismissed().subscribe(s=>{this._sheetOpen=!1,s==="delete"&&this.dashboard.deleteWidget(this.widgetProperties.uuid)})}}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=R({type:l,selectors:[["group-widget"]],inputs:{widgetProperties:"widgetProperties"},features:[De([q]),Se],decls:2,vars:3,consts:[[3,"text","color"],["kipGestures","","mode","press",1,"widgetOverlay"],["kipGestures","","mode","press",1,"widgetOverlay",3,"doubletap","press"]],template:function(t,i){t&1&&(ke(0,"widget-title",0),I(1,Ci,1,0,"div",1)),t&2&&(L("text",i.runtime.options().displayName)("color",i.runtime.options().color),T(),W(i.dashboard.isDashboardStatic()?-1:1))},dependencies:[Wt,ie],styles:["[_nghost-%COMP%]{display:block;height:15%}.widgetOverlay[_ngcontent-%COMP%]{position:absolute;width:100%;height:15%;right:0;top:0;color:transparent;z-index:21}"],changeDetection:0})}return l})();var ti=(()=>{class l{_bottomSheetRef=b(Ie);clickAction(e){this._bottomSheetRef.dismiss(e)}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=R({type:l,selectors:[["dashboard-clipboard-bottom-sheet"]],decls:20,vars:0,consts:[["mat-subheader",""],["mat-list-item","",3,"click"],["matListItemIcon",""]],template:function(t,i){t&1&&(y(0,"mat-action-list")(1,"div",0),v(2,"Clipboard"),_(),y(3,"button",1),C("click",function(){return i.clickAction("paste")}),y(4,"mat-icon",2),v(5,"content_paste"),_(),y(6,"span"),v(7,"Paste"),_()(),y(8,"button",1),C("click",function(){return i.clickAction("clear")}),y(9,"mat-icon",2),v(10,"clear"),_(),y(11,"span"),v(12,"Clear"),_()(),y(13,"div",0),v(14,"New Widget"),_(),y(15,"button",1),C("click",function(){return i.clickAction("add")}),y(16,"mat-icon",2),v(17,"add_circle"),_(),y(18,"span"),v(19,"Add"),_()()())},dependencies:[Ge,Be,Fe,Le,Gt,re,se],styles:["[_nghost-%COMP%]{display:block}"],changeDetection:0})}return l})();var xi=["grid"];function Ei(l,o){l&1&&(y(0,"p",10)(1,"strong"),v(2,"Long press/click and hold anywhere"),_(),v(3," to add widgets"),_(),y(4,"mat-icon",11),v(5,"touch_app"),_())}function Di(l,o){if(l&1){let e=U();y(0,"p",10),v(1,"This empty dashboard is ready to be customized."),_(),y(2,"button",12),C("click",function(){H(e);let i=S(2);return N(i.editDashboard())}),y(3,"mat-icon"),v(4,"lock_open"),_(),v(5," Unlock and Customize "),_()}}function Si(l,o){if(l&1){let e=U();y(0,"div",5),C("swipeup",function(){H(e);let i=S();return N(i.previousDashboard())})("swipedown",function(){H(e);let i=S();return N(i.nextDashboard())})("press",function(i){H(e);let s=S();return N(s.addNewWidget(i))}),y(1,"div",6)(2,"mat-icon",7),v(3,"dashboard"),_(),I(4,Ei,6,0)(5,Di,6,0),_(),y(6,"div")(7,"div",8)(8,"button",9),C("click",function(){H(e);let i=S();return N(i.navigateToHelp())}),y(9,"mat-icon"),v(10,"help"),_(),v(11," Get Help "),_()()()()}if(l&2){S();let e=te(0);L("mode",e===!0?"dashboard":"editor")("enablePress",e===!1)("enableDoubleTap",!1),T(4),W(e?5:4)}}function ki(l,o){if(l&1){let e=U();y(0,"div",3)(1,"button",13),C("click",function(){H(e);let i=S();return N(i.cancelLayoutChanges())}),y(2,"mat-icon"),v(3,"close"),_()(),y(4,"button",14),C("click",function(){H(e);let i=S();return N(i.saveLayoutChanges())}),y(5,"mat-icon"),v(6,"done"),_()()()}}function Ti(l,o){if(l&1&&ke(0,"dashboard-scroller",4),l&2){let e=S();L("activePage",e.dashboard.activeDashboard())("dashboards",e.dashboard.dashboards())}}var jo=(()=>{class l{toast=b(Pt);_dialog=b(ne);_bottomSheet=b(ae);dashboard=b(V);_destroyRef=b(Q);_uiEvent=b(We);datasetLifecycle=b(It);_pluginConfig=b(oe);_router=b(Ot);_hostEl=b(pe);isDashboardStatic=_e(()=>this.dashboard.isDashboardStatic());dashboardStaticView=_e(()=>this.dashboard.isDashboardStatic());gridIsEmpty=ue(!0);_gridstack=xt.required("grid");_previousIsStaticState=!0;_suppressDrag=!1;subGridOptions={cellHeight:"auto",column:"auto",acceptWidgets:!0,subGridDynamic:!1,class:"group-container"};gridOptions=ue({column:24,row:24,margin:4,float:!0,resizable:{handles:"all"},acceptWidgets:!0,subGridDynamic:!1,subGridOpts:this.subGridOptions,children:[]});_boundHandleKeyDown=this.handleKeyDown.bind(this);_resizeObserver;_pendingResizeRaf=null;_lastContainerHeight=0;_lastCellHeight=0;_addDialogOpen=!1;_clipboardSheetOpen=!1;constructor(){Ce.addComponentToSelectorType([Zt,ei]),B(()=>{let e=this.dashboard.isDashboardStatic();be(()=>{if(this._previousIsStaticState!==e){this._previousIsStaticState=e;try{this._gridstack().grid.setStatic(e)}catch(t){}}})}),B(()=>{let e=this.dashboard.activeDashboard();be(()=>{this.loadDashboard(e)})})}ngAfterViewInit(){this._gridstack().grid?.setStatic(this._previousIsStaticState),this.syncGridEmptyState(),this.resizeGridColumns(),this.setupResizeObserver(),this._uiEvent.addHotkeyListener(this._boundHandleKeyDown,{ctrlKey:!0,keys:["arrowdown","arrowup"]});try{let e=this._gridstack().grid;e&&typeof e.on=="function"&&(e.on("dragstart",()=>{this._uiEvent.isDragging.set(!0)}),e.on("dragstop",()=>{setTimeout(()=>this._uiEvent.isDragging.set(!1),0)}),e.on("resizestart",()=>{this._uiEvent.isDragging.set(!0)}),e.on("resizestop",()=>{setTimeout(()=>this._uiEvent.isDragging.set(!1),0)}))}catch(e){}this.dashboard.widgetAction$.pipe(ve(this._destroyRef)).subscribe(e=>{e&&this._gridstack().grid.getGridItems().forEach(t=>{if(t.gridstackNode.id===e.id)switch(e.operation){case"delete":this.deleteWidget(t);break;case"duplicate":this.duplicateWidget(t);break;case"copy":this.dashboard.setWidgetClipboardFromNode(t.gridstackNode);break;case"cut":this.dashboard.setWidgetClipboardFromNode(t.gridstackNode),this.deleteWidget(t);break;default:break}})})}setupResizeObserver(){if(this._resizeObserver)return;let e=this._hostEl.nativeElement;try{this._resizeObserver=new ResizeObserver(()=>{this._pendingResizeRaf===null&&(this._pendingResizeRaf=requestAnimationFrame(()=>{this._pendingResizeRaf=null,this.resizeGridColumns()}))}),this._resizeObserver.observe(e)}catch(t){}}handleKeyDown(e){e==="arrowdown"?this.previousDashboard():e==="arrowup"&&this.nextDashboard()}resizeGridColumns(){try{let t=this._gridstack().grid;if(!t)return;let i=t,s=this._hostEl.nativeElement.clientHeight||window.innerHeight;if(s===this._lastContainerHeight&&this._lastCellHeight>0)return;let r=i.getRow?i.getRow():0;if(r>0&&i.cellHeight){let n=Number(r)||0,a=n>0?s/n:1;if(a=Math.max(1,Math.round(a*100)/100),this._lastCellHeight===a&&this._lastContainerHeight===s)return;i.cellHeight(a),i.batchUpdate&&(i.batchUpdate(),i.batchUpdate(!1)),this._lastContainerHeight=s,this._lastCellHeight=a}}catch(e){}}loadDashboard(e){let t=F(this.dashboard.dashboards()[e]),i=this._gridstack();if(!i?.grid){queueMicrotask(()=>this.loadDashboard(e));return}i.grid.batchUpdate(),i.grid.load(t.configuration),i.grid.batchUpdate(!1),this.syncGridEmptyState()}onGridItemsChanged(){this.syncGridEmptyState()}syncGridEmptyState(){try{let t=(this._gridstack().grid?.getGridItems?.()??[]).length===0;this.gridIsEmpty.set(t)}catch(e){this.gridIsEmpty.set(!0)}}saveDashboard(){let e=this._gridstack().grid.save(!1,!1)||null,t=F(e);this.dashboard.updateConfiguration(this.dashboard.activeDashboard(),t)}saveLayoutChanges(){this.dashboard.setStaticDashboard(!0),this.saveDashboard(),this.dashboard.notifyLayoutEditSaved()}cancelLayoutChanges(){this.loadDashboard(this.dashboard.activeDashboard()),this.dashboard.setStaticDashboard(!0),this.dashboard.notifyLayoutEditCanceled()}addNewWidget(e){if(!this.dashboard.isDashboardStatic()&&e.detail!==void 0){if(this._addDialogOpen||this._clipboardSheetOpen)return;let t=e.detail||{},i=t.center?.x??t.x??0,s=t.center?.y??t.y??0,r=this._gridstack().grid.getCellFromPixel({left:i,top:s});if(this._gridstack().grid.isAreaEmpty(r.x,r.y,1,2)){if(this.dashboard.widgetClipboard()){this.openClipboardBottomSheet(r.x,r.y);return}this.openAddWidgetDialog(r.x,r.y)}else this.toast.show("Not enough free space at the selected location to add a widget. Please reorganize the dashboard to free up space or try a larger empty area.",0,!1,"error")}}openClipboardBottomSheet(e,t){if(this._clipboardSheetOpen)return;this._clipboardSheetOpen=!0,this._bottomSheet.open(ti).afterDismissed().subscribe(s=>{switch(this._clipboardSheetOpen=!1,s){case"paste":this.pasteCopiedWidget(e,t);break;case"clear":this.dashboard.clearWidgetClipboard();break;case"add":this.openAddWidgetDialog(e,t);break;default:break}})}openAddWidgetDialog(e,t){this._addDialogOpen=!0,this._dialog.openFrameDialog({title:"Add Widget",component:"select-widget"},!0).pipe(lt(()=>{this._addDialogOpen=!1})).subscribe(i=>D(this,null,function*(){if(!i||typeof i!="object")return;let s=i;yield this.tryAddWidgetWithDependencyChecks(s,e,t)}))}tryAddWidgetWithDependencyChecks(e,t,i){return D(this,null,function*(){let s=yield this.getDisabledRequiredPlugins(e.requiredPlugins??[]);if(s.length>0){this.promptEnableRequiredPlugins(e,t,i,s);return}let r=yield this.getAnyOfPluginActivationState(e.anyOfPlugins??[]),n=r.installed.length>0,a=r.enabled.length>0;if(n&&!a){this.notifyAnyOfPluginsRequireManualActivation(e,r.installed);return}this.addWidgetToGrid(e,t,i)})}getDisabledRequiredPlugins(e){return D(this,null,function*(){if(!e?.length)return[];let t=[...new Set(e)];return(yield Promise.all(t.map(s=>D(this,null,function*(){let r=yield this._pluginConfig.getPlugin(s);return{pluginId:s,enabled:r.ok&&r.data.state.enabled}})))).filter(s=>!s.enabled).map(s=>s.pluginId)})}getAnyOfPluginActivationState(e){return D(this,null,function*(){if(!e?.length)return{installed:[],enabled:[]};let t=[...new Set(e)],i=yield Promise.all(t.map(s=>D(this,null,function*(){let r=yield this._pluginConfig.getPlugin(s);return{pluginId:s,installed:r.ok,enabled:r.ok&&r.data.state.enabled}})));return{installed:i.filter(s=>s.installed).map(s=>s.pluginId),enabled:i.filter(s=>s.enabled).map(s=>s.pluginId)}})}notifyAnyOfPluginsRequireManualActivation(e,t){let i=t.join(", ");this.toast.show(`Cannot add "${e.name}" yet. Any-of plugin${t.length>1?"s are":" is"} installed (${i}) but none ${t.length>1?"are":"is"} active. Please manually activate and configure one or all in Signal K Plugin Config, then come back and add the widget.`,0,!1,"warn")}promptEnableRequiredPlugins(e,t,i,s){let r=s.join(", ");this.toast.show(`Cannot add "${e.name}" widget until required plugin${s.length>1?"s are":" is"} enabled: ${r}.`,0,!1,"warn","Enable").onAction().pipe(ve(this._destroyRef)).subscribe(()=>{this.enableRequiredPluginsAndAddWidget(e,t,i,s)})}enableRequiredPluginsAndAddWidget(e,t,i,s){return D(this,null,function*(){let r=[...new Set(s)],a=(yield Promise.all(r.map(u=>D(this,null,function*(){return{pluginId:u,result:yield this._pluginConfig.setPluginEnabled(u,!0)}})))).filter(u=>!u.result.ok).map(u=>u.pluginId);if(a.length>0){this.toast.show(`Failed to enable required plugin${a.length>1?"s":""}: ${a.join(", ")}.`,0,!1,"error");return}this.toast.show(`Enabled required plugin${r.length>1?"s":""}: ${r.join(", ")}.`,3e3,!0,"success"),yield this.tryAddWidgetWithDependencyChecks(e,t,i)})}addWidgetToGrid(e,t,i){let s=Me.create(),r={};e.selector==="group-widget"?r={x:t,y:i,w:3,h:4,id:s,selector:"group-widget",input:{widgetProperties:{type:e.selector,uuid:s,config:{displayName:"Group Widget",color:"contrast"},autoOpenOptionsOnCreate:!0}},subGridOpts:{children:[]}}:r={x:t,y:i,w:e.defaultWidth,h:e.defaultHeight,minW:e.minWidth,minH:e.minHeight,id:s,selector:"widget-host2",input:{widgetProperties:{type:e.selector,uuid:s,autoOpenOptionsOnCreate:!0}}};let n=this._gridstack().grid,a=Number(e.minWidth??1),u=Number(e.minHeight??2),c=Number(e.defaultWidth??a),d=Number(e.defaultHeight??u);if(!(n.isAreaEmpty(t,i,c,d)&&n.willItFit({x:t,y:i,w:c,h:d}))){let w=this.findBestWidgetSizeAtCell(n,t,i,a,u,c,d);if(!w){this.toast.show(`Not enough free space to add "${e.name}" widget at the selected location. Please reorganize the dashboard to free up space or try a larger empty area.`,0,!1,"error");return}r.w=w.w,r.h=w.h}let g=this._gridstack().grid.addWidget(r);g.gridstackNode.subGrid&&(g.gridstackNode.subGridOpts.row=g.gridstackNode.subGridOpts.minRow=g.gridstackNode.subGridOpts.maxRow=g.gridstackNode.h)}findBestWidgetSizeAtCell(e,t,i,s,r,n,a){let u=Math.max(1,Math.floor(s)),c=Math.max(1,Math.floor(r)),d=Math.max(u,Math.floor(n)),p=Math.max(c,Math.floor(a)),g=null;for(let w=u;w<=d;w++)for(let x=c;x<=p;x++){if(!e.isAreaEmpty(t,i,w,x)||!e.willItFit({x:t,y:i,w,h:x}))continue;let O=w*x;(!g||O>g.area||O===g.area&&x>g.h||O===g.area&&x===g.h&&w>g.w)&&(g={w,h:x,area:O})}return g?{w:g.w,h:g.h}:null}cancelPointerSequence(){if(!this._suppressDrag){this._suppressDrag=!0;try{this._gridstack().grid.setStatic(!0)}catch(e){}["pointerup","mouseup","touchend"].forEach(e=>{document.dispatchEvent(new Event(e,{bubbles:!0}))})}}onPointerRelease(){if(this._suppressDrag&&(this._suppressDrag=!1,!this.dashboard.isDashboardStatic()))try{this._gridstack().grid.setStatic(!1)}catch(e){}}duplicateWidget(e){let t=Me.create(),i=e.gridstackNode,s={w:i.w,h:i.h,id:t,selector:i.selector,input:{widgetProperties:{type:i.input.widgetProperties.type,uuid:t,config:F(i.input.widgetProperties.config)}}},r=this._gridstack();r.grid.willItFit(s)?r.grid.addWidget(s):(s.h=2,s.w=1,r.grid.willItFit(s)?r.grid.addWidget(s):this.toast.show("Insufficient space on the dashboard. Please reorganize to free up space.",0,!1,"error"))}pasteCopiedWidget(e,t){if(this.dashboard.isDashboardStatic())return;let i=this.dashboard.widgetClipboard(),s=i?.input?.widgetProperties;if(!i||!s?.type)return;let r=Me.create(),n={w:i.w,h:i.h,id:r,selector:i.selector,input:{widgetProperties:{type:s.type,uuid:r,config:F(s.config)}}};typeof e=="number"&&typeof t=="number"&&(n.x=e,n.y=t);let a=this._gridstack();a.grid.willItFit(n)?(a.grid.addWidget(n),this.dashboard.clearWidgetClipboard()):(n.h=2,n.w=1,a.grid.willItFit(n)?(a.grid.addWidget(n),this.dashboard.clearWidgetClipboard()):this.toast.show("Insufficient space on the dashboard. Please reorganize to free up space.",0,!1,"error"))}deleteWidget(e){let t=e.gridstackNode;this._gridstack().grid.removeWidget(e),t?.id&&this.datasetLifecycle.removeOwnedDatasets(t.id,!0)}nextDashboard(){this.dashboard.isDashboardStatic()&&this.dashboard.navigateToNextDashboard()}previousDashboard(){this.dashboard.isDashboardStatic()&&this.dashboard.navigateToPreviousDashboard()}editDashboard(){this.dashboard.setStaticDashboard(!1)}navigateToHelp(){this._router.navigate(["/help"])}ngOnDestroy(){let e=this._gridstack();if(e?.grid&&(e.grid.offAll(),e.grid.destroy()),this._resizeObserver){try{this._resizeObserver.disconnect()}catch(t){}this._resizeObserver=void 0}this._pendingResizeRaf!==null&&(cancelAnimationFrame(this._pendingResizeRaf),this._pendingResizeRaf=null),this._uiEvent.removeHotkeyListener(this._boundHandleKeyDown)}static \u0275fac=function(t){return new(t||l)};static \u0275cmp=R({type:l,selectors:[["dashboard"]],viewQuery:function(t,i){t&1&&bt(i._gridstack,xi,5),t&2&&_t()},hostBindings:function(t,i){t&1&&C("mouseup",function(){return i.onPointerRelease()},Ze)("touchend",function(){return i.onPointerRelease()},Ze)},decls:6,vars:8,consts:[["grid",""],["kipGestures","",3,"addedCB","removedCB","swipeup","swipedown","press","resize","mode","enablePress","enableDoubleTap","isEmpty","options"],["kipGestures","",1,"dashboard-empty-state-container",3,"mode","enablePress","enableDoubleTap"],[1,"edit-layout-close-icon"],[3,"activePage","dashboards"],["kipGestures","",1,"dashboard-empty-state-container",3,"swipeup","swipedown","press","mode","enablePress","enableDoubleTap"],[1,"dashboard-empty-state-action"],[1,"empty-state-icon"],[1,"empty-state-help"],["mat-button","",1,"empty-state-help-button",3,"click"],[1,"empty-state-text"],[1,"touch-icon"],["mat-flat-button","",1,"empty-state-button",3,"click"],["mat-fab","",1,"cancel",2,"margin-right","10px",3,"click"],["mat-fab","",1,"save",3,"click"]],template:function(t,i){if(t&1&&(ze(0),y(1,"gridstack",1,0),C("addedCB",function(){return i.onGridItemsChanged()})("removedCB",function(){return i.onGridItemsChanged()})("swipeup",function(){return i.previousDashboard()})("swipedown",function(){return i.nextDashboard()})("press",function(r){return i.addNewWidget(r)})("resize",function(){return i.resizeGridColumns()},dt),_(),I(3,Si,12,4,"div",2),I(4,ki,7,0,"div",3)(5,Ti,1,2,"dashboard-scroller",4)),t&2){let s=ye(i.dashboardStaticView()??!0);T(),L("mode",s===!0?"dashboard":"editor")("enablePress",s===!1)("enableDoubleTap",!1)("isEmpty",!1)("options",i.gridOptions()),T(2),W(i.gridIsEmpty()?3:-1),T(),W(s?5:4)}},dependencies:[Ce,Yt,re,se,zt,Tt,Rt,ie],styles:["[_nghost-%COMP%]{display:flex;flex-direction:row;flex-wrap:nowrap;height:100%;width:100%;overflow:hidden}.grid-stack[_ngcontent-%COMP%]{width:100%;height:100%;box-sizing:border-box;position:relative} .grid-stack-sub-grid{border:1px solid var(--mat-sys-outline);border-radius:8px} .grid-stack-sub-grid div{display:flex;flex-direction:column} .grid-stack-sub-grid div .grid-stack{flex:1 1 auto;min-height:500px}.edit-layout-close-icon[_ngcontent-%COMP%]{position:absolute;bottom:20px;right:20px;cursor:pointer;z-index:100}.cancel[_ngcontent-%COMP%]{--mat-fab-container-color: var(--mat-sys-primary);--mat-fab-foreground-color: var(--mat-sys-background)}.save[_ngcontent-%COMP%]{--mat-fab-container-color: var(--mat-sys-primary-fixed);--mat-fab-foreground-color: var(--mat-sys-background)}.dashboard-empty-state-container[_ngcontent-%COMP%]{position:absolute;inset:0;display:flex;flex-direction:column;flex-wrap:nowrap;align-items:center;justify-content:space-around;padding:1.5rem;text-align:center;box-sizing:border-box;overflow:hidden;pointer-events:auto}@media(orientation:landscape)and (max-height:420px){.dashboard-empty-state-container[_ngcontent-%COMP%]{padding:.75rem}.empty-state-icon[_ngcontent-%COMP%]{font-size:3.25rem;width:3.25rem;height:3.25rem}}.dashboard-empty-state-action[_ngcontent-%COMP%]{max-width:500px;color:var(--mat-sys-outline-variant)}.dashboard-empty-state-action[_ngcontent-%COMP%] .touch-icon[_ngcontent-%COMP%]{font-size:2rem;width:2rem;height:2rem;color:var(--mat-sys-outline-variant);margin-top:.5rem;animation:_ngcontent-%COMP%_bounce 2s infinite}.empty-state-icon[_ngcontent-%COMP%]{font-size:4rem;width:4rem;height:4rem;color:var(--mat-sys-outline-variant);margin-bottom:1rem}.empty-state-button[_ngcontent-%COMP%]{--mat-button-filled-label-text-color: var(--kip-widget-card-background-color);--mat-button-filled-container-color: var(--mat-sys-outline-variant);--mat-button-filled-hover-state-layer-opacity: .7;--mat-button-filled-state-layer-color: var(--mat-sys-primary-fixed-dim)}.empty-state-help-button[_ngcontent-%COMP%]{--mat-button-text-label-text-color: var(--mat-sys-outline-variant);--mat-button-text-hover-state-layer-opacity: .7;--mat-button-text-state-layer-color: var(--mat-sys-primary-fixed-dim)}.empty-state-text[_ngcontent-%COMP%]{color:var(--mat-sys-outline-variant);font-style:italic}@keyframes _ngcontent-%COMP%_bounce{0%,20%,50%,80%,to{transform:translateY(0)}40%{transform:translateY(-10px)}60%{transform:translateY(-5px)}}"],changeDetection:0})}return l})();export{Jt as a,jo as b};