wunderbaum 0.0.4 → 0.0.7

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.
@@ -2,79 +2,85 @@
2
2
  /*!
3
3
  * Wunderbaum - util
4
4
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
5
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
6
- */const t={0:"",1:"left",2:"middle",3:"right",4:"back",5:"forward"},i=function(){const e=navigator;return{isMac:/Mac/.test(e.platform)}}().isMac,s=/[&<>"'/]/g,n=/[<>"'/]/g,r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function o(e,t){if(!e)throw t=t||"Assertion failed.",new Error(t)}function l(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}function a(e){throw new Error(e)}function d(e){return(""+e).replace(s,(function(e){return r[e]}))}function c(e){return(""+e).replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function h(e,t=!1){const i=e.tagName;let s=null;if("SPAN"===i&&e.classList.contains("wb-col")){const i=e,n=i.querySelector("input,select");if(n)return h(n,t);i.innerText=""+s}else if("INPUT"===i){const i=e;switch(i.type){case"button":case"reset":case"submit":case"image":break;case"checkbox":s=i.indeterminate?null:i.checked;break;case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":s=t?i.valueAsDate:i.value;break;case"number":case"range":s=i.valueAsNumber;break;case"radio":const e=i.name,n=i.parentElement.querySelector(`input[name="${e}"]:checked`);s=n?n.value:void 0;break;default:s=i.value}}else if("SELECT"===i){s=e.value}return s}function u(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstElementChild}const p=new Set(["Alt","Control","Meta","Shift"]);function f(e){return e?"string"==typeof e?document.querySelector(e):e:null}function g(e){return e?"string"==typeof e?document.querySelector(e):e:null}function v(e){let i=e.key,s=e.type,n=[];return e.altKey&&n.push("Alt"),e.ctrlKey&&n.push("Control"),e.metaKey&&n.push("Meta"),e.shiftKey&&n.push("Shift"),"click"===s||"dblclick"===s?n.push(t[e.button]+s):"wheel"===s?n.push(s):p.has(i)||n.push(i),n.join("+")}function m(...e){for(let t=1;t<e.length;t++){let i=e[t];if(null!=i)for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[0][t]=i[t])}return e[0]}function w(e){return Array.isArray(e)}function b(e){return 0===Object.keys(e).length&&e.constructor===Object}function y(e){return"function"==typeof e}function E(e){return"[object Object]"===Object.prototype.toString.call(e)}function x(...e){}function _(e,t,i,s){let n,r;e=g(e),s?(n=i,r=s):(n="",r=i),t.split(" ").forEach((t=>{e.addEventListener(t,(function(e){if(!n)return r(e);if(e.target){let t=e.target;if(t.matches(n))return r(e);if(t=t.closest(n),t)return r(e)}}))}))}function C(e,t,i,s){let n,r,o=s||e,l=e[t],a=(...e)=>l.apply(o,e),d=e=>l.apply(o,e);e[t]=(...e)=>{try{return n=o._super,r=o._superApply,o._super=a,o._superApply=d,i.apply(o,e)}finally{o._super=n,o._superApply=r}}}function k(e,t,i){let s;e&&t.indexOf(".")>=0&&([s,t]=t.split("."),e=e[s]);let n=e?e[t]:null;return null!=n?n:i}function N(e){if(e instanceof Set)return e;if("string"==typeof e){let t=new Set;for(const i of e.split(" "))t.add(i.trim());return t}if(Array.isArray(e))return new Set(e);throw new Error("Cannot convert to Set<string>: "+e)}function M(e,t){let i=0,s=null;const n=Object.assign({minDelay:16,defaultDelay:200,maxDelay:5e3,delayFactor:2},t),r=Math.max(16,+n.minDelay),o=+n.maxDelay,l=(...t)=>{if(i)s=t,i+=1;else{i=1;const a=t;s=null;const d=Date.now();try{e.apply(this,a)}catch(e){console.error(e)}const c=Date.now()-d,h=Math.min(Math.max(r,c*n.delayFactor),o),u=Math.max(r,h-c);setTimeout((()=>{i=0,null!=s&&l.apply(this,s)}),u)}};return l}var T=Object.freeze({__proto__:null,MOUSE_BUTTONS:t,MAX_INT:9007199254740991,isMac:i,Deferred:class{constructor(){this.thens=[],this.catches=[],this.status=""}resolve(e){if(this.status)throw new Error("already settled");this.status="resolved",this.resolvedValue=e,this.thens.forEach((t=>t(e))),this.thens=[]}reject(e){if(this.status)throw new Error("already settled");this.status="rejected",this.rejectedError=e,this.catches.forEach((t=>t(e))),this.catches=[]}then(e){"resolved"===status?e(this.resolvedValue):this.thens.unshift(e)}catch(e){"rejected"===this.status?e(this.rejectedError):this.catches.unshift(e)}promise(){return{then:this.then,catch:this.catch}}},assert:o,documentReady:l,documentReadyPromise:function(){return new Promise((e=>{l(e)}))},each:function(e,t){if(null==e)return e;let i=e.length,s=0;if("number"==typeof i)for(;s<i&&!1!==t.call(e[s],s,e[s]);s++);else for(let i in e)if(!1===t.call(e[s],i,e[i]))break;return e},error:a,escapeHtml:d,escapeRegex:c,escapeTooltip:function(e){return(""+e).replace(n,(function(e){return r[e]}))},extractHtmlText:function(e){return e.indexOf(">")>=0&&a("Not implemented"),e},getValueFromElem:h,setValueToElem:function e(t,i){const s=t.tagName;if("SPAN"===s&&t.classList.contains("wb-col")){const s=t,n=s.querySelector("input,select");if(n)return e(n,i);s.innerText=""+i}else if("INPUT"===s){const e=t;switch(e.type){case"checkbox":e.indeterminate=null==i,e.checked=!!i;break;case"date":case"month":case"time":case"week":case"datetime":case"datetime-local":e.valueAsDate=i;break;case"number":case"range":e.valueAsNumber=i;break;case"radio":a("Not implemented");break;case"button":case"reset":case"submit":case"image":break;default:e.value=i||""}}else if("SELECT"===s){t.value=i}},elemFromHtml:u,elemFromSelector:f,eventTargetFromSelector:g,eventToString:v,extend:m,isArray:w,isEmptyObject:b,isFunction:y,isPlainObject:E,noop:x,onEvent:_,overrideMethod:C,setTimeoutPromise:function(e,t){return new Promise(((i,s)=>{setTimeout((()=>{try{i(e.apply(this))}catch(e){s(e)}}),t)}))},sleep:async function(e){return new Promise((t=>setTimeout(t,e)))},toggleCheckbox:function(e,t,i){const s=f(e);if(o("checkbox"===s.type),null!=i||(i=s.classList.contains("wb-tristate")||s.indeterminate),void 0===t){switch(s.indeterminate?null:s.checked){case!0:t=!1;break;case!1:t=!i||null;break;case null:t=!0}}s.indeterminate=null==t,s.checked=!!t},getOption:k,toSet:N,type:function(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()},addaptiveThrottle:M});
5
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
6
+ */const t={0:"",1:"left",2:"middle",3:"right",4:"back",5:"forward"},i=function(){const e=navigator;return{isMac:/Mac/.test(e.platform)}}().isMac,s=/[&<>"'/]/g,n=/[<>"'/]/g,r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function l(e,t){if(!e)throw t=t||"Assertion failed.",new Error(t)}function o(e){"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()}function a(e){throw new Error(e)}function d(e){return(""+e).replace(s,(function(e){return r[e]}))}function c(e){return(""+e).replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1")}function h(e){return(""+e).replace(n,(function(e){return r[e]}))}function u(e,t=!1){const i=e.tagName;let s=null;if("SPAN"===i&&e.classList.contains("wb-col")){const i=e,n=i.querySelector("input,select");if(n)return u(n,t);i.innerText=""+s}else if("INPUT"===i){const i=e;switch(i.type){case"button":case"reset":case"submit":case"image":break;case"checkbox":s=i.indeterminate?null:i.checked;break;case"date":case"datetime":case"datetime-local":case"month":case"time":case"week":s=t?i.valueAsDate:i.value;break;case"number":case"range":s=i.valueAsNumber;break;case"radio":const e=i.name,n=i.parentElement.querySelector(`input[name="${e}"]:checked`);s=n?n.value:void 0;break;default:s=i.value}}else if("SELECT"===i){s=e.value}return s}function p(e,t){const i=v(e).style;t?"none"===i.display&&(i.display=""):""===i.display&&(i.display="none")}function f(e){const t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstElementChild}const g=new Set(["Alt","Control","Meta","Shift"]);function v(e){return e?"string"==typeof e?document.querySelector(e):e:null}function m(e){return e?"string"==typeof e?document.querySelector(e):e:null}function b(e){let i=e.key,s=e.type,n=[];return e.altKey&&n.push("Alt"),e.ctrlKey&&n.push("Control"),e.metaKey&&n.push("Meta"),e.shiftKey&&n.push("Shift"),"click"===s||"dblclick"===s?n.push(t[e.button]+s):"wheel"===s?n.push(s):g.has(i)||n.push(i),n.join("+")}function y(...e){for(let t=1;t<e.length;t++){let i=e[t];if(null!=i)for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&(e[0][t]=i[t])}return e[0]}function w(e){return Array.isArray(e)}function E(e){return 0===Object.keys(e).length&&e.constructor===Object}function x(e){return"function"==typeof e}function _(e){return"[object Object]"===Object.prototype.toString.call(e)}function k(...e){}function C(e,t,i,s){let n,r;e=m(e),s?(n=i,r=s):(n="",r=i),t.split(" ").forEach((t=>{e.addEventListener(t,(function(e){if(!n)return r(e);if(e.target){let t=e.target;if(t.matches(n))return r(e);if(t=t.closest(n),t)return r(e)}}))}))}function N(e,t,i,s){let n,r,l=s||e,o=e[t],a=(...e)=>o.apply(l,e),d=e=>o.apply(l,e);e[t]=(...e)=>{try{return n=l._super,r=l._superApply,l._super=a,l._superApply=d,i.apply(l,e)}finally{l._super=n,l._superApply=r}}}function M(e,t,i){let s;e&&t.indexOf(".")>=0&&([s,t]=t.split("."),e=e[s]);let n=e?e[t]:null;return null!=n?n:i}function T(e){if(e instanceof Set)return e;if("string"==typeof e){let t=new Set;for(const i of e.split(" "))t.add(i.trim());return t}if(Array.isArray(e))return new Set(e);throw new Error("Cannot convert to Set<string>: "+e)}function I(e,t){let i=0,s=null;const n=Object.assign({minDelay:16,defaultDelay:200,maxDelay:5e3,delayFactor:2},t),r=Math.max(16,+n.minDelay),l=+n.maxDelay,o=(...t)=>{if(i)s=t,i+=1;else{i=1;const a=t;s=null;const d=Date.now();try{e.apply(this,a)}catch(e){console.error(e)}const c=Date.now()-d,h=Math.min(Math.max(r,c*n.delayFactor),l),u=Math.max(r,h-c);setTimeout((()=>{i=0,null!=s&&o.apply(this,s)}),u)}};return o}var S,L,A,D,O=Object.freeze({__proto__:null,MOUSE_BUTTONS:t,MAX_INT:9007199254740991,isMac:i,Deferred:class{constructor(){this.thens=[],this.catches=[],this.status=""}resolve(e){if(this.status)throw new Error("already settled");this.status="resolved",this.resolvedValue=e,this.thens.forEach((t=>t(e))),this.thens=[]}reject(e){if(this.status)throw new Error("already settled");this.status="rejected",this.rejectedError=e,this.catches.forEach((t=>t(e))),this.catches=[]}then(e){"resolved"===status?e(this.resolvedValue):this.thens.unshift(e)}catch(e){"rejected"===this.status?e(this.rejectedError):this.catches.unshift(e)}promise(){return{then:this.then,catch:this.catch}}},assert:l,documentReady:o,documentReadyPromise:function(){return new Promise((e=>{o(e)}))},each:function(e,t){if(null==e)return e;let i=e.length,s=0;if("number"==typeof i)for(;s<i&&!1!==t.call(e[s],s,e[s]);s++);else for(let i in e)if(!1===t.call(e[s],i,e[i]))break;return e},error:a,escapeHtml:d,escapeRegex:c,escapeTooltip:h,extractHtmlText:function(e){return e.indexOf(">")>=0&&a("Not implemented"),e},getValueFromElem:u,setValueToElem:function e(t,i){const s=t.tagName;if("SPAN"===s&&t.classList.contains("wb-col")){const s=t,n=s.querySelector("input,select");if(n)return e(n,i);s.innerText=""+i}else if("INPUT"===s){const e=t;switch(e.type){case"checkbox":e.indeterminate=null===i,e.checked=!!i;break;case"date":case"month":case"time":case"week":case"datetime":case"datetime-local":e.valueAsDate=i;break;case"number":case"range":e.valueAsNumber=i;break;case"radio":a("Not implemented");break;case"button":case"reset":case"submit":case"image":break;default:e.value=i||""}}else if("SELECT"===s){const e=t;null==i?e.selectedIndex=-1:e.value=i}},setElemDisplay:p,elemFromHtml:f,elemFromSelector:v,eventTargetFromSelector:m,eventToString:b,extend:y,isArray:w,isEmptyObject:E,isFunction:x,isPlainObject:_,noop:k,onEvent:C,overrideMethod:N,setTimeoutPromise:function(e,t){return new Promise(((i,s)=>{setTimeout((()=>{try{i(e.apply(this))}catch(e){s(e)}}),t)}))},sleep:async function(e){return new Promise((t=>setTimeout(t,e)))},toggleCheckbox:function(e,t,i){const s=v(e);if(l("checkbox"===s.type),null!=i||(i=s.classList.contains("wb-tristate")||s.indeterminate),void 0===t){switch(s.indeterminate?null:s.checked){case!0:t=!1;break;case!1:t=!i||null;break;case null:t=!0}}s.indeterminate=null==t,s.checked=!!t},getOption:M,toSet:T,type:function(e){return Object.prototype.toString.call(e).replace(/^\[object (.+)\]$/,"$1").toLowerCase()},adaptiveThrottle:I});
7
7
  /*!
8
- * Wunderbaum - common
8
+ * Wunderbaum - types
9
9
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
10
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
11
- */const L=22,S=new RegExp(/\.|\//);var A,I,D;!function(e){e.any="any",e.data="data",e.header="header",e.row="row",e.structure="structure",e.status="status",e.vscroll="vscroll"}(A||(A={})),function(e){e.ok="ok",e.loading="loading",e.error="error",e.noData="noData"}(I||(I={})),function(e){e.unknown="",e.checkbox="checkbox",e.column="column",e.expander="expander",e.icon="icon",e.prefix="prefix",e.title="title"}(D||(D={}));let O={error:"bi bi-exclamation-triangle",loading:"bi bi-arrow-repeat wb-spin",noData:"bi bi-question-circle",expanderExpanded:"bi bi-chevron-down",expanderCollapsed:"bi bi-chevron-right",expanderLazy:"bi bi-chevron-right wb-helper-lazy-expander",checkChecked:"bi bi-check-square",checkUnchecked:"bi bi-square",checkUnknown:"bi dash-square-dotted",radioChecked:"bi bi-circle-fill",radioUnchecked:"bi bi-circle",radioUnknown:"bi bi-circle-dotted",folder:"bi bi-folder2",folderOpen:"bi bi-folder2-open",doc:"bi bi-file-earmark"};var P,R;!function(e){e.startRow="startRow",e.cell="cell",e.startCell="startCell",e.row="row"}(P||(P={})),function(e){e.row="row",e.cellNav="cellNav",e.cellEdit="cellEdit"}(R||(R={}));const q={" ":"toggleSelect","+":"expand",Add:"expand",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"parent","/":"collapseAll",Divide:"collapseAll",End:"lastCol",Home:"firstCol","Control+End":"last","Control+Home":"first","Meta+ArrowDown":"last","Meta+ArrowUp":"first","*":"expandAll",Multiply:"expandAll",PageDown:"pageDown",PageUp:"pageUp","-":"collapse",Subtract:"collapse"};function F(e){return e=c(e.toLowerCase()),function(t){return t.title.toLowerCase().indexOf(e)>=0}}
10
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
11
+ */!function(e){e.any="any",e.data="data",e.header="header",e.row="row",e.structure="structure",e.status="status",e.vscroll="vscroll"}(S||(S={})),function(e){e.ok="ok",e.loading="loading",e.error="error",e.noData="noData"}(L||(L={})),function(e){e.unknown="",e.checkbox="checkbox",e.column="column",e.expander="expander",e.icon="icon",e.prefix="prefix",e.title="title"}(A||(A={})),function(e){e.startRow="startRow",e.cell="cell",e.startCell="startCell",e.row="row"}(D||(D={}));
12
12
  /*!
13
13
  * Wunderbaum - wb_extension_base
14
14
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
15
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
15
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
16
16
  */
17
- class z{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id=t,this.treeOpts=e.options;const s=e.options;void 0===this.treeOpts[t]?s[t]=this.extensionOpts=m({},i):(this.extensionOpts=m({},i,s[t]),s[t]=this.extensionOpts),this.enabled=this.getPluginOption("enabled",!0)}init(){this.tree.element.classList.add("wb-ext-"+this.id)}getPluginOption(e,t){var i;return null!==(i=this.extensionOpts[e])&&void 0!==i?i:t}setPluginOption(e,t){this.extensionOpts[e]=t}setEnabled(e=!0){return this.setPluginOption("enabled",!!e)}onKeyEvent(e){}onRender(e){}}
17
+ class P{constructor(e,t,i){this.enabled=!0,this.tree=e,this.id=t,this.treeOpts=e.options;const s=e.options;void 0===this.treeOpts[t]?s[t]=this.extensionOpts=y({},i):(this.extensionOpts=y({},i,s[t]),s[t]=this.extensionOpts),this.enabled=this.getPluginOption("enabled",!0)}init(){this.tree.element.classList.add("wb-ext-"+this.id)}getPluginOption(e,t){var i;return null!==(i=this.extensionOpts[e])&&void 0!==i?i:t}setPluginOption(e,t){this.extensionOpts[e]=t}setEnabled(e=!0){return this.setPluginOption("enabled",!!e)}onKeyEvent(e){}onRender(e){}}
18
18
  /*!
19
19
  * debounce & throttle, taken from https://github.com/lodash/lodash v4.17.21
20
20
  * MIT License: https://raw.githubusercontent.com/lodash/lodash/4.17.21-npm/LICENSE
21
21
  * Modified for TypeScript type annotations.
22
- */const U="object"==typeof global&&null!==global&&global.Object===Object&&global,$="object"==typeof globalThis&&null!==globalThis&&globalThis.Object==Object&&globalThis,j="object"==typeof self&&null!==self&&self.Object===Object&&self,H=$||U||j||Function("return this")();function V(e,t=0,i={}){let s,n,r,o,l,a,d=0,c=!1,h=!1,u=!0;const p=!t&&0!==t&&"function"==typeof H.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){const i=s,r=n;return s=n=void 0,d=t,o=e.apply(r,i),o}function g(e,t){return p?(H.cancelAnimationFrame(l),H.requestAnimationFrame(e)):setTimeout(e,t)}function v(e){const i=e-a;return void 0===a||i>=t||i<0||h&&e-d>=r}function m(){const e=Date.now();if(v(e))return w(e);l=g(m,function(e){const i=e-d,s=t-(e-a);return h?Math.min(s,r-i):s}(e))}function w(e){return l=void 0,u&&s?f(e):(s=n=void 0,o)}function b(...e){const i=Date.now(),r=v(i);if(s=e,n=this,a=i,r){if(void 0===l)return function(e){return d=e,l=g(m,t),c?f(e):o}(a);if(h)return l=g(m,t),f(a)}return void 0===l&&(l=g(m,t)),o}return t=+t||0,function(e){const t=typeof e;return null!=e&&("object"===t||"function"===t)}(i)&&(c=!!i.leading,h="maxWait"in i,r=h?Math.max(+i.maxWait||0,t):r,u="trailing"in i?!!i.trailing:u),b.cancel=function(){void 0!==l&&function(e){if(p)return H.cancelAnimationFrame(e);clearTimeout(e)}(l),d=0,s=a=n=l=void 0},b.flush=function(){return void 0===l?o:w(Date.now())},b.pending=function(){return void 0!==l},b}
22
+ */const R="object"==typeof global&&null!==global&&global.Object===Object&&global,F="object"==typeof globalThis&&null!==globalThis&&globalThis.Object==Object&&globalThis,q="object"==typeof self&&null!==self&&self.Object===Object&&self,$=F||R||q||Function("return this")();function z(e,t=0,i={}){let s,n,r,l,o,a,d=0,c=!1,h=!1,u=!0;const p=!t&&0!==t&&"function"==typeof $.requestAnimationFrame;if("function"!=typeof e)throw new TypeError("Expected a function");function f(t){const i=s,r=n;return s=n=void 0,d=t,l=e.apply(r,i),l}function g(e,t){return p?($.cancelAnimationFrame(o),$.requestAnimationFrame(e)):setTimeout(e,t)}function v(e){const i=e-a;return void 0===a||i>=t||i<0||h&&e-d>=r}function m(){const e=Date.now();if(v(e))return b(e);o=g(m,function(e){const i=e-d,s=t-(e-a);return h?Math.min(s,r-i):s}(e))}function b(e){return o=void 0,u&&s?f(e):(s=n=void 0,l)}function y(...e){const i=Date.now(),r=v(i);if(s=e,n=this,a=i,r){if(void 0===o)return function(e){return d=e,o=g(m,t),c?f(e):l}(a);if(h)return o=g(m,t),f(a)}return void 0===o&&(o=g(m,t)),l}return t=+t||0,function(e){const t=typeof e;return null!=e&&("object"===t||"function"===t)}(i)&&(c=!!i.leading,h="maxWait"in i,r=h?Math.max(+i.maxWait||0,t):r,u="trailing"in i?!!i.trailing:u),y.cancel=function(){void 0!==o&&function(e){if(p)return $.cancelAnimationFrame(e);clearTimeout(e)}(o),d=0,s=a=n=o=void 0},y.flush=function(){return void 0===o?l:b(Date.now())},y.pending=function(){return void 0!==o},y}
23
23
  /*!
24
24
  * Wunderbaum - ext-filter
25
25
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
26
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
27
- */const K="￷",W="￸",B=new RegExp(c("￷"),"g"),Q=new RegExp(c("￸"),"g");class Y extends z{constructor(e){super(e,"filter",{autoApply:!0,autoExpand:!1,counter:!0,fuzzy:!1,hideExpandedCounter:!0,hideExpanders:!1,highlight:!0,leavesOnly:!1,mode:"hide",noData:!0}),this.lastFilterArgs=null}init(){super.init();let e=this.getPluginOption("attachInput");e&&(this.queryInput=f(e),_(this.queryInput,"input",V((e=>{this.filterNodes(this.queryInput.value.trim(),{})}),700)))}_applyFilterNoUpdate(e,t,i){return this.tree.runWithoutUpdate((()=>this._applyFilterImpl(e,t,i)))}_applyFilterImpl(e,t,i){let s,n,r=Date.now(),o=0,l=this.tree,a=l.options,h=a.autoCollapse,u=m({},a.filter,i),p="hide"===u.mode,f=!!u.leavesOnly&&!t;if("string"==typeof e){if(""===e)return l.logInfo("Passing an empty string as a filter is handled as clearFilter()."),void this.clearFilter();s=u.fuzzy?e.split("").map(c).reduce((function(e,t){return e+"([^"+t+"]*)"+t}),""):c(e);let t=new RegExp(s,"i"),i=new RegExp(c(e),"gi");e=e=>{if(!e.title)return!1;let s=e.title,r=s.match(t);return r&&u.highlight&&(n=u.fuzzy?function(e,t,i=!0){let s=[];for(let e=1;e<t.length;e++){let i=t[e].length+(1===e?0:1)+(s[s.length-1]||0);s.push(i)}let n=e.split("");i?s.forEach((function(e){n[e]=K+n[e]+W})):s.forEach((function(e){n[e]="<mark>"+n[e]+"</mark>"}));return n.join("")}
26
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
27
+ */const U="￷",H="￸",j=new RegExp(c("￷"),"g"),V=new RegExp(c("￸"),"g");class K extends P{constructor(e){super(e,"filter",{connectInput:null,autoApply:!0,autoExpand:!1,counter:!0,fuzzy:!1,hideExpandedCounter:!0,hideExpanders:!1,highlight:!0,leavesOnly:!1,mode:"dim",noData:!0}),this.lastFilterArgs=null}init(){super.init();const e=this.getPluginOption("connectInput");e&&(this.queryInput=v(e),C(this.queryInput,"input",z((e=>{this.filterNodes(this.queryInput.value.trim(),{})}),700)))}setPluginOption(e,t){if(super.setPluginOption(e,t),"mode"===e)this.tree.filterMode="hide"===t?"hide":"dim",this.tree.updateFilter()}_applyFilterNoUpdate(e,t,i){return this.tree.runWithoutUpdate((()=>this._applyFilterImpl(e,t,i)))}_applyFilterImpl(e,t,i){let s,n,r=Date.now(),l=0,o=this.tree,a=o.options,h=a.autoCollapse,u=y({},a.filter,i),p="hide"===u.mode,f=!!u.leavesOnly&&!t;if("string"==typeof e){if(""===e)return o.logInfo("Passing an empty string as a filter is handled as clearFilter()."),void this.clearFilter();s=u.fuzzy?e.split("").map(c).reduce((function(e,t){return e+"([^"+t+"]*)"+t}),""):c(e);let t=new RegExp(s,"i"),i=new RegExp(c(e),"gi");e=e=>{if(!e.title)return!1;let s=e.title,r=s.match(t);return r&&u.highlight&&(n=u.fuzzy?function(e,t,i=!0){let s=[];for(let e=1;e<t.length;e++){let i=t[e].length+(1===e?0:1)+(s[s.length-1]||0);s.push(i)}let n=e.split("");i?s.forEach((function(e){n[e]=U+n[e]+H})):s.forEach((function(e){n[e]="<mark>"+n[e]+"</mark>"}));return n.join("")}
28
28
  /*!
29
29
  * Wunderbaum - ext-keynav
30
30
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
31
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
32
- */(s,r,!0):s.replace(i,(function(e){return K+e+W})),e.titleWithHighlight=d(n).replace(B,"<mark>").replace(Q,"</mark>")),!!r}}return l.filterMode=u.mode,this.lastFilterArgs=arguments,l.element.classList.toggle("wb-ext-filter-hide",!!p),l.element.classList.toggle("wb-ext-filter-dim",!p),l.element.classList.toggle("wb-ext-filter-hide-expanders",!!u.hideExpanders),l.root.subMatchCount=0,l.visit((e=>{delete e.match,delete e.titleWithHighlight,e.subMatchCount=0})),l.setStatus(I.ok),a.autoCollapse=!1,l.visit((i=>{if(f&&null!=i.children)return;let s=e(i);if("skip"===s)return i.visit((function(e){e.match=!1}),!0),"skip";let n=!1;(t||"branch"===s)&&i.parent.match&&(s=!0,n=!0),s&&(o++,i.match=!0,i.visitParents((e=>{e!==i&&(e.subMatchCount+=1),!u.autoExpand||n||e.expanded||(e.setExpanded(!0,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),e._filterAutoExpanded=!0)}),!0))})),a.autoCollapse=h,0===o&&u.noData&&p&&l.root.setStatus(I.noData),l.logInfo(`Filter '${s}' found ${o} nodes in ${Date.now()-r} ms.`),o}filterNodes(e,t){return this._applyFilterNoUpdate(e,!1,t)}filterBranches(e,t){return this._applyFilterNoUpdate(e,!0,t)}updateFilter(){let e=this.tree;e.filterMode&&this.lastFilterArgs&&e.options.filter.autoApply?this._applyFilterNoUpdate.apply(this,this.lastFilterArgs):e.logWarn("updateFilter(): no filter active.")}clearFilter(){let e=this.tree;e.enableUpdate(!1),e.setStatus(I.ok),delete e.root.match,delete e.root.subMatchCount,e.visit((e=>{if(e.match&&e._rowElem){let t=e._rowElem.querySelector("span.wb-title");t.textContent=e.title,e._callEvent("enhanceTitle",{titleElem:t})}delete e.match,delete e.subMatchCount,delete e.titleWithHighlight,e.subMatchBadge&&(e.subMatchBadge.remove(),delete e.subMatchBadge),e._filterAutoExpanded&&e.expanded&&e.setExpanded(!1,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),delete e._filterAutoExpanded})),e.filterMode=null,this.lastFilterArgs=null,e.element.classList.remove("wb-ext-filter-dim","wb-ext-filter-hide"),e.enableUpdate(!0)}}class G extends z{constructor(e){super(e,"keynav",{})}onKeyEvent(e){let t,i=e.event,s=v(i),n=e.node,r=this.tree,o=e.options,l=!0,a=!i.ctrlKey||o.autoActivate;const d=o.navigationMode;if(r.logDebug(`onKeyEvent: ${s}`),!1===r._callEvent("keydown",e))return!1;if(!1===r._callMethod("edit._preprocessKeyEvent",e))return!1;if(!n){const e=r.getActiveNode(),i=r.getFirstChild();if(!e&&i&&"ArrowDown"===s)return i.logInfo("Keydown: activate first node."),void i.setActive();t=e||i,t&&(t.setFocus(),n=r.getFocusNode(),n.logInfo("Keydown: force focus on active node."))}if(r.navMode===R.row){if(o.quicksearch&&1===s.length&&/^\w$/.test(s)){const e=Date.now();e-r.lastQuicksearchTime>500&&(r.lastQuicksearchTerm=""),r.lastQuicksearchTime=e,r.lastQuicksearchTerm+=s;let t=r.findNextNode(r.lastQuicksearchTerm,r.getActiveNode());return t&&t.setActive(!0,{event:i}),void i.preventDefault()}switch(s){case"ArrowLeft":n.expanded&&(s="Subtract");break;case"ArrowRight":if(n.expanded||!n.children&&!n.lazy){if(d===P.startRow)return void r.setNavigationMode(R.cellNav)}else s="Add"}switch(s){case"+":case"Add":n.setExpanded(!0);break;case"-":case"Subtract":n.setExpanded(!1);break;case" ":n.getOption("checkbox")?n.setSelected(!n.isSelected()):n.setActive(!0,{event:i});break;case"Enter":n.setActive(!0,{event:i});break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":n.navigate(s,{activate:a,event:i});break;default:l=!1}}else switch(s){case" ":if(0===r.activeColIdx&&n.getOption("checkbox"))n.setSelected(!n.isSelected()),l=!0;else{const e=r.getActiveColElem(),t=null==e?void 0:e.querySelector("input[type=checkbox]");null==t||t.click()}break;case"Enter":0===r.activeColIdx&&n.isExpandable()&&(n.setExpanded(!n.isExpanded()),l=!0);break;case"Escape":r.navMode===R.cellEdit?(r.setNavigationMode(R.cellNav),l=!0):r.navMode===R.cellNav&&(r.setNavigationMode(R.row),l=!0);break;case"ArrowLeft":r.activeColIdx>0?(r.setColumn(r.activeColIdx-1),l=!0):d!==P.cell&&(r.setNavigationMode(R.row),l=!0);break;case"ArrowRight":r.activeColIdx<r.columns.length-1&&(r.setColumn(r.activeColIdx+1),l=!0);break;case"ArrowDown":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":n.navigate(s,{activate:a,event:i});break;default:l=!1}l&&i.preventDefault()}}
31
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
32
+ */(s,r,!0):s.replace(i,(function(e){return U+e+H})),e.titleWithHighlight=d(n).replace(j,"<mark>").replace(V,"</mark>")),!!r}}return o.filterMode=u.mode,this.lastFilterArgs=arguments,o.element.classList.toggle("wb-ext-filter-hide",!!p),o.element.classList.toggle("wb-ext-filter-dim",!p),o.element.classList.toggle("wb-ext-filter-hide-expanders",!!u.hideExpanders),o.root.subMatchCount=0,o.visit((e=>{delete e.match,delete e.titleWithHighlight,e.subMatchCount=0})),o.setStatus(L.ok),a.autoCollapse=!1,o.visit((i=>{if(f&&null!=i.children)return;let s=e(i);if("skip"===s)return i.visit((function(e){e.match=!1}),!0),"skip";let n=!1;(t||"branch"===s)&&i.parent.match&&(s=!0,n=!0),s&&(l++,i.match=!0,i.visitParents((e=>{e!==i&&(e.subMatchCount+=1),!u.autoExpand||n||e.expanded||(e.setExpanded(!0,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),e._filterAutoExpanded=!0)}),!0))})),a.autoCollapse=h,0===l&&u.noData&&p&&o.root.setStatus(L.noData),o.logInfo(`Filter '${s}' found ${l} nodes in ${Date.now()-r} ms.`),l}filterNodes(e,t){return this._applyFilterNoUpdate(e,!1,t)}filterBranches(e,t){return this._applyFilterNoUpdate(e,!0,t)}updateFilter(){let e=this.tree;e.filterMode&&this.lastFilterArgs&&e.options.filter.autoApply?this._applyFilterNoUpdate.apply(this,this.lastFilterArgs):e.logWarn("updateFilter(): no filter active.")}clearFilter(){let e=this.tree;e.enableUpdate(!1),e.setStatus(L.ok),delete e.root.match,delete e.root.subMatchCount,e.visit((e=>{if(e.match&&e._rowElem){let t=e._rowElem.querySelector("span.wb-title");t.textContent=e.title,e._callEvent("enhanceTitle",{titleElem:t})}delete e.match,delete e.subMatchCount,delete e.titleWithHighlight,e.subMatchBadge&&(e.subMatchBadge.remove(),delete e.subMatchBadge),e._filterAutoExpanded&&e.expanded&&e.setExpanded(!1,{noAnimation:!0,noEvents:!0,scrollIntoView:!1}),delete e._filterAutoExpanded})),e.filterMode=null,this.lastFilterArgs=null,e.element.classList.remove("wb-ext-filter-dim","wb-ext-filter-hide"),e.enableUpdate(!0)}}class W extends P{constructor(e){super(e,"keynav",{})}_getEmbeddedInputElem(e){var t;let i=null;if(e&&null!=e.type)i=e;else{const e=null===(t=this.tree.getActiveColElem())||void 0===t?void 0:t.querySelector("input,select");e&&(i=e)}return i}_isCurInputFocused(){var e;const t=null===(e=this.tree.getActiveColElem())||void 0===e?void 0:e.querySelector("input:focus,select:focus");return console.log("_isCurInputFocused",t),!!t}onKeyEvent(e){const t=e.event,i=this.tree,s=e.options,n=!t.ctrlKey||s.autoActivate,r=this._getEmbeddedInputElem(t.target),l=s.navigationModeOption;let o,a=b(t),d=e.node,c=!0;if(!i.isEnabled())return!1;if(!1===i._callEvent("keydown",e))return!1;if(!1===i._callMethod("edit._preprocessKeyEvent",e))return!1;if(!d){const e=i.getFocusNode()||i.getActiveNode(),t=i.getFirstChild();if(!e&&t&&"ArrowDown"===a)return t.logInfo("Keydown: activate first node."),void t.setActive();o=e||t,o&&(o.setFocus(),d=i.getFocusNode(),d.logInfo("Keydown: force focus on active node."))}const h=d.isColspan();if(i.isRowNav()){if(s.quicksearch&&1===a.length&&/^\w$/.test(a)&&!r){const e=Date.now();e-i.lastQuicksearchTime>500&&(i.lastQuicksearchTerm=""),i.lastQuicksearchTime=e,i.lastQuicksearchTerm+=a;let s=i.findNextNode(i.lastQuicksearchTerm,i.getActiveNode());return s&&s.setActive(!0,{event:t}),void t.preventDefault()}switch(a){case"ArrowLeft":d.expanded&&(a="Subtract");break;case"ArrowRight":if(d.expanded||!d.children&&!d.lazy){if(l===D.startRow)return void i.setCellNav()}else a="Add"}switch(a){case"+":case"Add":d.setExpanded(!0);break;case"-":case"Subtract":d.setExpanded(!1);break;case" ":d.getOption("checkbox")?d.setSelected(!d.isSelected()):d.setActive(!0,{event:t});break;case"Enter":d.setActive(!0,{event:t});break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":d.navigate(a,{activate:n,event:t});break;default:c=!1}}else{const e=this._getEmbeddedInputElem(null),s=e?e.type||e.tagName:"",r=e&&this._isCurInputFocused(),o=e&&"checkbox"!==s;if(r){if("Escape"===a)d.render();else if("Enter"!==a)return void d.logDebug(`Ignored ${a} inside focused input`)}else if(e&&1===a.length&&o)return e.focus(),e.value="",d.logDebug(`Focus imput: ${a}`),!1;switch("Tab"===a?(a="ArrowRight",c=!0):"Shift+Tab"===a&&(a=i.activeColIdx>0?"ArrowLeft":"",c=!0),a){case" ":0===i.activeColIdx&&d.getOption("checkbox")?(d.setSelected(!d.isSelected()),c=!0):e&&"checkbox"===s&&(e.click(),c=!0);break;case"F2":e&&!r&&o&&(e.focus(),c=!0);break;case"Enter":i.setFocus(),0===i.activeColIdx&&d.isExpandable()?(d.setExpanded(!d.isExpanded()),c=!0):e&&!r&&o&&(e.focus(),c=!0);break;case"Escape":i.setFocus(),i.isCellNav()&&l!==D.cell&&(i.setCellNav(!1),c=!0);break;case"ArrowLeft":i.setFocus(),h&&d.isExpanded()?d.setExpanded(!1):!h&&i.activeColIdx>0?i.setColumn(i.activeColIdx-1):l!==D.cell&&i.setCellNav(!1),c=!0;break;case"ArrowRight":i.setFocus(),h&&!d.isExpanded()?d.setExpanded():!h&&i.activeColIdx<i.columns.length-1&&i.setColumn(i.activeColIdx+1),c=!0;break;case"ArrowDown":case"ArrowUp":case"Backspace":case"End":case"Home":case"Control+End":case"Control+Home":case"Meta+ArrowDown":case"Meta+ArrowUp":case"PageDown":case"PageUp":d.navigate(a,{activate:n,event:t}),c=!0;break;default:c=!1}}c&&t.preventDefault()}}
33
33
  /*!
34
34
  * Wunderbaum - ext-logger
35
35
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
36
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
37
- */class X extends z{constructor(e){super(e,"logger",{}),this.ignoreEvents=new Set(["enhanceTitle","render","discard"]),this.prefix=e+".ext-logger"}init(){const e=this.tree;if(e.getOption("debugLevel")>=4){const t=this.ignoreEvents,i=this.prefix;C(e,"callEvent",(function(s,n){if(t.has(s))return e._superApply(arguments);let r=Date.now();const o=e._superApply(arguments);return console.debug(`${i}: callEvent('${s}') took ${Date.now()-r} ms.`,arguments[1]),o}))}}onKeyEvent(e){console.debug(`${this.prefix}: onKeyEvent()`,e)}}
36
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
37
+ */class B extends P{constructor(e){super(e,"logger",{}),this.ignoreEvents=new Set(["enhanceTitle","render","discard"]),this.prefix=e+".ext-logger"}init(){const e=this.tree;if(e.getOption("debugLevel")>=4){const t=this.ignoreEvents,i=this.prefix;N(e,"callEvent",(function(s,n){if(t.has(s))return e._superApply(arguments);const r=Date.now(),l=e._superApply(arguments);return console.debug(`${i}: callEvent('${s}') took ${Date.now()-r} ms.`,arguments[1]),l}))}}onKeyEvent(e){console.debug(`${this.prefix}: onKeyEvent()`,e)}}
38
38
  /*!
39
- * Wunderbaum - ext-dnd
39
+ * Wunderbaum - common
40
40
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
41
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
42
- */class J extends z{constructor(e){super(e,"dnd",{autoExpandMS:1500,multiSource:!1,effectAllowed:"all",dropEffectDefault:"move",preventForeignNodes:!1,preventLazyParents:!0,preventNonNodes:!1,preventRecursion:!0,preventSameParent:!1,preventVoidMoves:!0,scroll:!0,scrollSensitivity:20,scrollSpeed:5,sourceCopyHook:null,dragStart:null,dragDrag:null,dragEnd:null,dragEnter:null,dragOver:null,dragExpand:null,dragDrop:null,dragLeave:null}),this.srcNode=null,this.lastTargetNode=null,this.lastEnterStamp=0,this.lastAllowedDropRegions=null,this.lastDropEffect=null,this.lastDropRegion=!1}init(){super.init();const e=this.tree,t=e.options.dnd;t.dragStart&&_(e.element,"dragstart drag dragend",this.onDragEvent.bind(this)),t.dragEnter&&_(e.element,"dragenter dragover dragleave drop",this.onDropEvent.bind(this))}_leaveNode(){const e=this.lastTargetNode;this.lastEnterStamp=0,e&&(e.removeClass("wb-drop-target wb-drop-over wb-drop-after wb-drop-before"),this.lastTargetNode=null)}unifyDragover(e){if(!1===e)return!1;if(e instanceof Set)return e.size>0&&e;if(!0===e)return new Set(["over","before","after"]);if("string"==typeof e||w(e))return(e=N(e)).size>0&&e;throw new Error("Unsupported drop region definition: "+e)}_calcDropRegion(e,t){const i=e.offsetY;return!!t&&(3===t.size?i<5.5?"before":i>16.5?"after":"over":1===t.size&&t.has("over")?"over":i>11?"after":"before")}autoScroll(e){let t=this.tree,i=t.options.dnd,s=t.scrollContainer,n=i.scrollSensitivity,r=i.scrollSpeed,o=0;const l=s.offsetTop;if(l+s.offsetHeight-e.pageY<n){s.scrollHeight-s.clientHeight-l>0&&(s.scrollTop=o=l+r)}else l>0&&e.pageY-l<n&&(s.scrollTop=o=l-r);return o}onDragEvent(e){const t=this.treeOpts.dnd,i=oe.getNode(e);if(i){if("drag"!==e.type&&this.tree.logDebug("onDragEvent."+e.type+", srcNode: "+i,e),"dragstart"===e.type){e.dataTransfer.effectAllowed=t.effectAllowed;if(!i._callEvent("dnd.dragStart",{event:e}))return e.preventDefault(),!1;let s=i.toDict(!0,(e=>{e._org_key=e.key,delete e.key}));s.treeId=i.tree.id;const n=JSON.stringify(s);e.dataTransfer.setData("application/x-wunderbaum-node",n),e.dataTransfer.setData("text/plain",i.title),this.srcNode=i,setTimeout((()=>{i.addClass("wb-drag-source")}),0)}else"drag"===e.type||"dragend"===e.type&&(i.removeClass("wb-drag-source"),this.srcNode=null,this.lastTargetNode&&this._leaveNode());return!0}}onDropEvent(e){const t=oe.getNode(e),i=this.treeOpts.dnd,s=e.dataTransfer;if(t){if("dragover"!==e.type&&this.tree.logDebug("onDropEvent."+e.type+" targetNode: "+t+", ea: "+(null==s?void 0:s.effectAllowed)+", de: "+(null==s?void 0:s.dropEffect),", cy: "+e.offsetY,", r: "+this._calcDropRegion(e,this.lastAllowedDropRegions),e),"dragenter"===e.type){if(this.lastAllowedDropRegions=null,this.lastTargetNode&&this.lastTargetNode!==t&&this._leaveNode(),this.lastTargetNode=t,this.lastEnterStamp=Date.now(),i.preventVoidMoves&&t===this.srcNode||t.isStatusNode())return s.dropEffect="none",!0;let n=t._callEvent("dnd.dragEnter",{event:e});return n=this.unifyDragover(n),n?(this.lastAllowedDropRegions=n,this.lastDropEffect=s.dropEffect,t.addClass("wb-drop-target"),e.preventDefault(),!1):(s.dropEffect="none",!0)}if("dragover"===e.type){this.autoScroll(e);const s=this._calcDropRegion(e,this.lastAllowedDropRegions);if(this.lastDropRegion=s,i.autoExpandMS>0&&t.isExpandable(!0)&&!t._isLoading&&Date.now()-this.lastEnterStamp>i.autoExpandMS&&!1!==t._callEvent("dnd.dragExpand",{event:e})&&t.setExpanded(),!s)return;return t.toggleClass("wb-drop-over","over"===s),t.toggleClass("wb-drop-before","before"===s),t.toggleClass("wb-drop-after","after"===s),e.preventDefault(),!1}"dragleave"===e.type||"drop"===e.type&&(e.stopPropagation(),this._leaveNode(),t._callEvent("dnd.drop",{event:e,region:this.lastDropRegion,sourceNode:this.srcNode}))}else this._leaveNode()}}
41
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
42
+ */const G=22,Q=new RegExp(/\.|\//),Y={error:"bi bi-exclamation-triangle",loading:"bi bi-chevron-right wb-busy",noData:"bi bi-question-circle",expanderExpanded:"bi bi-chevron-down",expanderCollapsed:"bi bi-chevron-right",expanderLazy:"bi bi-chevron-right wb-helper-lazy-expander",checkChecked:"bi bi-check-square",checkUnchecked:"bi bi-square",checkUnknown:"bi dash-square-dotted",radioChecked:"bi bi-circle-fill",radioUnchecked:"bi bi-circle",radioUnknown:"bi bi-circle-dotted",folder:"bi bi-folder2",folderOpen:"bi bi-folder2-open",folderLazy:"bi bi-folder-symlink",doc:"bi bi-file-earmark"},X=new Set(["children","columns","format","keyMap","positional","typeList","types","version"]),J={" ":"toggleSelect","+":"expand",Add:"expand",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up",Backspace:"parent","/":"collapseAll",Divide:"collapseAll",End:"lastCol",Home:"firstCol","Control+End":"last","Control+Home":"first","Meta+ArrowDown":"last","Meta+ArrowUp":"first","*":"expandAll",Multiply:"expandAll",PageDown:"pageDown",PageUp:"pageUp","-":"collapse",Subtract:"collapse"};function Z(e){return e=c(e.toLowerCase()),function(t){return t.title.toLowerCase().indexOf(e)>=0}}class ee extends P{constructor(e){super(e,"dnd",{autoExpandMS:1500,multiSource:!1,effectAllowed:"all",dropEffectDefault:"move",preventForeignNodes:!1,preventLazyParents:!0,preventNonNodes:!1,preventRecursion:!0,preventSameParent:!1,preventVoidMoves:!0,scroll:!0,scrollSensitivity:20,scrollSpeed:5,sourceCopyHook:null,dragStart:null,dragDrag:null,dragEnd:null,dragEnter:null,dragOver:null,dragExpand:null,dragDrop:null,dragLeave:null}),this.srcNode=null,this.lastTargetNode=null,this.lastEnterStamp=0,this.lastAllowedDropRegions=null,this.lastDropEffect=null,this.lastDropRegion=!1}init(){super.init();const e=this.tree,t=e.options.dnd;t.dragStart&&C(e.element,"dragstart drag dragend",this.onDragEvent.bind(this)),t.dragEnter&&C(e.element,"dragenter dragover dragleave drop",this.onDropEvent.bind(this))}_leaveNode(){const e=this.lastTargetNode;this.lastEnterStamp=0,e&&(e.setClass("wb-drop-target wb-drop-over wb-drop-after wb-drop-before",!1),this.lastTargetNode=null)}unifyDragover(e){if(!1===e)return!1;if(e instanceof Set)return e.size>0&&e;if(!0===e)return new Set(["over","before","after"]);if("string"==typeof e||w(e))return(e=T(e)).size>0&&e;throw new Error("Unsupported drop region definition: "+e)}_calcDropRegion(e,t){const i=e.offsetY;return!!t&&(3===t.size?i<5.5?"before":i>16.5?"after":"over":1===t.size&&t.has("over")?"over":i>11?"after":"before")}autoScroll(e){let t=this.tree,i=t.options.dnd,s=t.scrollContainerElement,n=i.scrollSensitivity,r=i.scrollSpeed,l=0;const o=s.offsetTop;if(o+s.offsetHeight-e.pageY<n){s.scrollHeight-s.clientHeight-o>0&&(s.scrollTop=l=o+r)}else o>0&&e.pageY-o<n&&(s.scrollTop=l=o-r);return l}onDragEvent(e){const t=this.treeOpts.dnd,i=de.getNode(e);if(i){if("drag"!==e.type&&this.tree.logDebug("onDragEvent."+e.type+", srcNode: "+i,e),"dragstart"===e.type){e.dataTransfer.effectAllowed=t.effectAllowed;if(!i._callEvent("dnd.dragStart",{event:e}))return e.preventDefault(),!1;let s=i.toDict(!0,(e=>{e._org_key=e.key,delete e.key}));s.treeId=i.tree.id;const n=JSON.stringify(s);e.dataTransfer.setData("application/x-wunderbaum-node",n),e.dataTransfer.setData("text/plain",i.title),this.srcNode=i,setTimeout((()=>{i.setClass("wb-drag-source")}),0)}else"drag"===e.type||"dragend"===e.type&&(i.setClass("wb-drag-source",!1),this.srcNode=null,this.lastTargetNode&&this._leaveNode());return!0}}onDropEvent(e){const t=de.getNode(e),i=this.treeOpts.dnd,s=e.dataTransfer;if(t){if("dragover"!==e.type&&this.tree.logDebug("onDropEvent."+e.type+" targetNode: "+t+", ea: "+(null==s?void 0:s.effectAllowed)+", de: "+(null==s?void 0:s.dropEffect),", cy: "+e.offsetY,", r: "+this._calcDropRegion(e,this.lastAllowedDropRegions),e),"dragenter"===e.type){if(this.lastAllowedDropRegions=null,this.lastTargetNode&&this.lastTargetNode!==t&&this._leaveNode(),this.lastTargetNode=t,this.lastEnterStamp=Date.now(),i.preventVoidMoves&&t===this.srcNode||t.isStatusNode())return s.dropEffect="none",!0;let n=t._callEvent("dnd.dragEnter",{event:e});return n=this.unifyDragover(n),n?(this.lastAllowedDropRegions=n,this.lastDropEffect=s.dropEffect,t.setClass("wb-drop-target"),e.preventDefault(),!1):(s.dropEffect="none",!0)}if("dragover"===e.type){this.autoScroll(e);const s=this._calcDropRegion(e,this.lastAllowedDropRegions);if(this.lastDropRegion=s,i.autoExpandMS>0&&t.isExpandable(!0)&&!t._isLoading&&Date.now()-this.lastEnterStamp>i.autoExpandMS&&!1!==t._callEvent("dnd.dragExpand",{event:e})&&t.setExpanded(),!s)return;return t.setClass("wb-drop-over","over"===s),t.setClass("wb-drop-before","before"===s),t.setClass("wb-drop-after","after"===s),e.preventDefault(),!1}"dragleave"===e.type||"drop"===e.type&&(e.stopPropagation(),this._leaveNode(),t._callEvent("dnd.drop",{event:e,region:this.lastDropRegion,sourceNode:this.srcNode}))}else this._leaveNode()}}
43
43
  /*!
44
44
  * Wunderbaum - drag_observer
45
45
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
46
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
47
- */class Z{constructor(e){this.start={x:0,y:0,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},this.dragElem=null,this.dragging=!1,this.events=["mousedown","mouseup","mousemove","keydown"],o(e.root),this.opts=m({thresh:5},e),this.root=e.root,this._handler=this.handleEvent.bind(this),this.events.forEach((e=>{this.root.addEventListener(e,this._handler)}))}disconnect(){this.events.forEach((e=>{this.root.removeEventListener(e,this._handler)}))}getDragElem(){return this.dragElem}isDragging(){return this.dragging}stopDrag(e){this.dragging&&this.opts.dragstop&&e&&(e.type="dragstop",this.opts.dragstop(e)),this.dragElem=null,this.dragging=!1}handleEvent(e){const t=e.type,i=this.opts,s={type:e.type,event:e,dragElem:this.dragElem,dx:e.pageX-this.start.x,dy:e.pageY-this.start.y,apply:void 0};switch(t){case"keydown":this.stopDrag(s);break;case"mousedown":if(this.dragElem){this.stopDrag(s);break}if(i.selector){let t=e.target;if(t.matches(i.selector))this.dragElem=t;else{if(t=t.closest(i.selector),!t)break;this.dragElem=t}}this.start.x=e.pageX,this.start.y=e.pageY,this.start.altKey=e.altKey,this.start.ctrlKey=e.ctrlKey,this.start.metaKey=e.metaKey,this.start.shiftKey=e.shiftKey;break;case"mousemove":if(!this.dragElem)break;if(!this.dragging){if(i.thresh){if(s.dx*s.dx+s.dy*s.dy<i.thresh*i.thresh)break}if(s.type="dragstart",!1===i.dragstart(s)){this.stopDrag(s);break}this.dragging=!0}this.dragging&&this.opts.drag&&(s.type="drag",this.opts.drag(s));break;case"mouseup":if(!this.dragging){this.stopDrag(s);break}0===e.button?s.apply=!0:s.apply=!1,this.stopDrag(s)}}}
46
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
47
+ */class te{constructor(e){this.start={x:0,y:0,altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},this.dragElem=null,this.dragging=!1,this.events=["mousedown","mouseup","mousemove","keydown"],l(e.root),this.opts=y({thresh:5},e),this.root=e.root,this._handler=this.handleEvent.bind(this),this.events.forEach((e=>{this.root.addEventListener(e,this._handler)}))}disconnect(){this.events.forEach((e=>{this.root.removeEventListener(e,this._handler)}))}getDragElem(){return this.dragElem}isDragging(){return this.dragging}stopDrag(e){this.dragging&&this.opts.dragstop&&e&&(e.type="dragstop",this.opts.dragstop(e)),this.dragElem=null,this.dragging=!1}handleEvent(e){const t=e.type,i=this.opts,s={type:e.type,event:e,dragElem:this.dragElem,dx:e.pageX-this.start.x,dy:e.pageY-this.start.y,apply:void 0};switch(t){case"keydown":this.stopDrag(s);break;case"mousedown":if(this.dragElem){this.stopDrag(s);break}if(i.selector){let t=e.target;if(t.matches(i.selector))this.dragElem=t;else{if(t=t.closest(i.selector),!t)break;this.dragElem=t}}this.start.x=e.pageX,this.start.y=e.pageY,this.start.altKey=e.altKey,this.start.ctrlKey=e.ctrlKey,this.start.metaKey=e.metaKey,this.start.shiftKey=e.shiftKey;break;case"mousemove":if(!this.dragElem)break;if(!this.dragging){if(i.thresh){if(s.dx*s.dx+s.dy*s.dy<i.thresh*i.thresh)break}if(s.type="dragstart",!1===i.dragstart(s)){this.stopDrag(s);break}this.dragging=!0}this.dragging&&this.opts.drag&&(s.type="drag",this.opts.drag(s));break;case"mouseup":if(!this.dragging){this.stopDrag(s);break}0===e.button?s.apply=!0:s.apply=!1,this.stopDrag(s)}}}
48
48
  /*!
49
49
  * Wunderbaum - ext-grid
50
50
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
51
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
52
- */class ee extends z{constructor(e){super(e,"grid",{}),this.observer=new Z({root:window.document,selector:"span.wb-col-resizer",thresh:4,dragstart:e=>this.tree.element.contains(e.dragElem),drag:e=>this.handleDrag(e),dragstop:e=>this.handleDrag(e)})}init(){super.init()}handleDrag(e){const t=oe.getEventInfo(e.event);this.tree.log(`${e.type}(${e.dx})`,e,t)}}
51
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
52
+ */class ie extends P{constructor(e){super(e,"grid",{}),this.observer=new te({root:window.document,selector:"span.wb-col-resizer",thresh:4,dragstart:e=>this.tree.element.contains(e.dragElem),drag:e=>this.handleDrag(e),dragstop:e=>this.handleDrag(e)})}init(){super.init()}handleDrag(e){const t=de.getEventInfo(e.event);this.tree.log(`${e.type}(${e.dx})`,e,t)}}
53
53
  /*!
54
54
  * Wunderbaum - deferred
55
55
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
56
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
57
- */class te{constructor(){this._promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){this._resolve(e)}reject(e){this._reject(e)}promise(){return this._promise}then(e){return this._promise.then(e)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}}
56
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
57
+ */class se{constructor(){this._promise=new Promise(((e,t)=>{this._resolve=e,this._reject=t}))}resolve(e){this._resolve(e)}reject(e){this._reject(e)}promise(){return this._promise}then(e){return this._promise.then(e)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}}
58
58
  /*!
59
59
  * Wunderbaum - wunderbaum_node
60
60
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
61
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
62
- */const ie=new Set(["classes","expanded","icon","key","lazy","refKey","selected","title","tooltip","type"]),se=new Set(["checkbox","expanded","extraClasses","folder","icon","iconTooltip","key","lazy","partsel","radiogroup","refKey","selected","statusNodeType","title","tooltip","type","unselectable","unselectableIgnore","unselectableStatus"]);class ne{constructor(e,t,i){var s,n;if(this.refKey=void 0,this.children=null,this.lazy=!1,this.expanded=!1,this.selected=!1,this.extraClasses=new Set,this.data={},this._isLoading=!1,this._requestId=0,this._errorInfo=null,this._partsel=!1,this._partload=!1,this.subMatchCount=0,this._rowIdx=0,this._rowElem=void 0,o(!t||t.tree===e),o(!i.children),this.tree=e,this.parent=t,this.key=""+(null!==(s=i.key)&&void 0!==s?s:++ne.sequence),this.title=""+(null!==(n=i.title)&&void 0!==n?n:"<"+this.key+">"),null!=i.refKey&&(this.refKey=""+i.refKey),null!=i.statusNodeType&&(this.statusNodeType=""+i.statusNodeType),null!=i.type&&(this.type=""+i.type),null!=i.checkbox&&(this.checkbox=!!i.checkbox),null!=i.colspan&&(this.colspan=!!i.colspan),this.expanded=!0===i.expanded,null!=i.icon&&(this.icon=i.icon),this.lazy=!0===i.lazy,this.selected=!0===i.selected,i.classes)for(const e of i.classes.split(" "))this.extraClasses.add(e.trim());for(const[e,t]of Object.entries(i))ie.has(e)||(this.data[e]=t);t&&!this.statusNodeType&&e._registerNode(this)}toString(){return"WunderbaumNode@"+this.key+"<'"+this.title+"'>"}_callEvent(e,t){return this.tree._callEvent(e,m({node:this,typeInfo:this.type?this.tree.types[this.type]:{}},t))}addChildren(e,t){let i=t?t.before:null,s=[];try{this.tree.enableUpdate(!1),E(e)&&(e=[e]);for(let t of e){let e=t.children;delete t.children;let i=new ne(this.tree,this,t);s.push(i),e&&i.addChildren(e,{redraw:!1})}if(this.children)if(null==i||0===this.children.length)this.children=this.children.concat(s);else{i=this.findDirectChild(i);let e=this.children.indexOf(i);o(e>=0,"insertBefore must be an existing child"),this.children.splice(e,0,...s)}else this.children=s;return this.tree.setModified(A.structure),s[0]}finally{this.tree.enableUpdate(!0)}}addNode(e,t="child"){switch("over"===t&&(t="child"),t){case"after":return this.parent.addChildren(e,{before:this.getNextSibling()});case"before":return this.parent.addChildren(e,{before:this});case"firstChild":return this.addChildren(e,{before:0});case"child":return this.addChildren(e)}o(!1,"Invalid mode: "+t)}applyCommand(e,t){return this.tree.applyCommand(e,this,t)}addClass(e){N(e).forEach((e=>{var t;this.extraClasses.add(e),null===(t=this._rowElem)||void 0===t||t.classList.add(e)}))}removeClass(e){N(e).forEach((e=>{var t;this.extraClasses.delete(e),null===(t=this._rowElem)||void 0===t||t.classList.remove(e)}))}toggleClass(e,t){N(e).forEach((e=>{var i;t?this.extraClasses.add(e):this.extraClasses.delete(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)}))}async expandAll(e=!0){this.visit((t=>{t.setExpanded(e)}))}findAll(e){const t=y(e)?e:F(e),i=[];return this.visit((e=>{t(e)&&i.push(e)})),i}findDirectChild(e){let t=this.children;if(!t)return null;if("string"==typeof e){for(let i=0,s=t.length;i<s;i++)if(t[i].key===e)return t[i]}else{if("number"==typeof e)return t[e];if(e.parent===this)return e}return null}findFirst(e){const t=y(e)?e:F(e);let i=null;return this.visit((e=>{if(t(e))return i=e,!1})),i}findRelatedNode(e,t=!1){return this.tree.findRelatedNode(this,e,t)}getColElem(e){var t;"string"==typeof e&&(e=this.tree.columns.findIndex((t=>t.id===e)));const i=null===(t=this._rowElem)||void 0===t?void 0:t.querySelectorAll("span.wb-col");return i?i[e]:null}getFirstChild(){return this.children?this.children[0]:null}getLastChild(){return this.children?this.children[this.children.length-1]:null}getLevel(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}getNextSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t+1]||null}getParent(){return this.parent}getParentList(e=!1,t=!1){let i=[],s=t?this:this.parent;for(;s;)(e||s.parent)&&i.unshift(s),s=s.parent;return i}getPath(e=!0,t="title",i="/"){let s,n=[],r="function"==typeof t;return this.visitParents((e=>{e.parent&&(s=r?t(e):e[t],n.unshift(s))}),e),n.join(i)}getPrevSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t-1]||null}hasChildren(){if(this.lazy){if(null==this.children)return;if(0===this.children.length)return!1;if(1===this.children.length&&this.children[0].isStatusNode())return;return!0}return!(!this.children||!this.children.length)}isActive(){return this.tree.activeNode===this}isChildOf(e){return this.parent&&this.parent===e}isDescendantOf(e){if(!e||e.tree!==this.tree)return!1;for(var t=this.parent;t;){if(t===e)return!0;t===t.parent&&a("Recursive parent link: "+t),t=t.parent}return!1}isExpandable(e=!1){return!(!this.children||this.expanded&&e)}isEditing(){return this.tree._callMethod("edit.isEditingTitle",this)}isExpanded(){return!!this.expanded}isFirstSibling(){var e=this.parent;return!e||e.children[0]===this}isLastSibling(){var e=this.parent;return!e||e.children[e.children.length-1]===this}isLazy(){return!!this.lazy}isLoaded(){return!this.lazy||void 0!==this.hasChildren()}isLoading(){return this._isLoading}isPagingNode(){return"paging"===this.statusNodeType}isPartload(){return!!this._partload}isPartsel(){return!this.selected&&!!this._partsel}isRendered(){return!!this._rowElem}isRootNode(){return this.tree.root===this}isSelected(){return!!this.selected}isStatusNode(){return!!this.statusNodeType}isTopLevel(){return this.tree.root===this.parent}isUnloaded(){return void 0===this.hasChildren()}isVisible(){let e,t,i,s="hide"===this.tree.filterMode,n=this.getParentList(!1,!1);if(s&&!this.match&&!this.subMatchCount)return!1;for(e=0,t=n.length;e<t;e++)if(i=n[e],!i.expanded)return!1;return!0}_loadSourceObject(e){const t=this.tree;this._callEvent("receive",{response:e}),w(e)&&(e={children:e}),o(E(e)),o(e.children,"If `source` is an object, it must have a `children` property"),e.types&&m(t.types,e.types),this.addChildren(e.children),this._callEvent("load")}async load(e){const t=this.tree,i=Date.now(),s=this.parent,n="string"==typeof e?e:e.url;this._requestId&&this.logWarn(`Recursive load request #${i} while #${this._requestId} is pending.`),this._requestId=i;const r=t.logTime(this+".load()");try{if(n){this.setStatus(I.loading);const e=await fetch(n,{method:"GET"});e.ok||a(`GET ${n} returned ${e.status}, ${e}`);const r=await e.json();if(this._requestId&&this._requestId>i)return void this.logWarn(`Ignored load response #${i} because #${this._requestId} is pending.`);if(this.logDebug(`Received response for load request #${i}`),null===this.parent&&null!==s)return void this.logWarn("Lazy parent node was removed while loading: discarding response.");this.setStatus(I.ok),r.columns&&(t.logInfo("Re-define columns",r.columns),o(!this.parent),t.columns=r.columns,delete r.columns,t.updateColumns({calculateCols:!1})),this._loadSourceObject(r)}else this._loadSourceObject(e)}catch(t){throw this.logError("Error during load()",e,t),this._callEvent("error",{error:t}),this.setStatus(I.error,""+t),t}finally{this._requestId=0,t.logTimeEnd(r)}}async loadLazy(e=!1){const t=this.expanded;if(o(this.lazy,"load() requires a lazy node"),e||this.isUnloaded()){this.isLoaded()&&this.resetLazy(),this.setStatus(I.loading);try{const e=await this._callEvent("lazyLoad");if(!1===e)return void this.setStatus(I.ok);o(w(e)||e&&e.url,"The lazyLoad event must return a node list, `{url: ...}`, or false."),await this.load(e),t?(this.expanded=!0,this.tree.setModified(A.structure)):this.setModified()}catch(e){this.logError("Error during loadLazy()",e),this._callEvent("error",{error:e}),this.setStatus(I.error,""+e)}}}log(...e){this.logDebug.apply(this,e)}logDebug(...e){this.tree.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.tree.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.tree.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logWarn(...e){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}async makeVisible(e){let t,i=new te,s=[],n=this.getParentList(!1,!1),r=n.length,o=!(e&&!0===e.noAnimation),l=!(e&&!1===e.scrollIntoView);for(t=r-1;t>=0;t--)s.push(n[t].setExpanded(!0,e));return Promise.all(s).then((()=>{l?this.scrollIntoView(o).then((()=>{i.resolve()})):i.resolve()})),i.promise()}moveTo(e,t="appendChild",i){"prependChild"===t&&(e.children&&e.children.length?(t="before",e=e.children[0]):t="appendChild");let s,n=this.tree,r=this.parent,l="appendChild"===t?e:e.parent;if(this!==e){if(this.parent?l.isDescendantOf(this)&&a("Cannot move a node to its own descendant"):a("Cannot move system root"),l!==r&&r.triggerModifyChild("remove",this),1===this.parent.children.length){if(this.parent===l)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else s=this.parent.children.indexOf(this),o(s>=0,"invalid source parent"),this.parent.children.splice(s,1);if(this.parent=l,l.hasChildren())switch(t){case"appendChild":l.children.push(this);break;case"before":s=l.children.indexOf(e),o(s>=0,"invalid target parent"),l.children.splice(s,0,this);break;case"after":s=l.children.indexOf(e),o(s>=0,"invalid target parent"),l.children.splice(s+1,0,this);break;default:a("Invalid mode "+t)}else l.children=[this];i&&e.visit(i,!0),l===r?l.triggerModifyChild("move",this):l.triggerModifyChild("add",this),n!==e.tree&&(this.logWarn("Cross-tree moveTo is experimental!"),this.visit((function(t){t.tree=e.tree}),!0)),n.setModified(A.structure)}}async navigate(e,t){e=q[e]||e;const i=this.findRelatedNode(e);if(!i)return this.logWarn(`Could not find related node '${e}'.`),Promise.resolve(this);try{i.makeVisible({scrollIntoView:!1})}catch(e){}return i.setFocus(),!1===(null==t?void 0:t.activate)?Promise.resolve(this):i.setActive(!0,{event:null==t?void 0:t.event})}remove(){const e=this.tree,t=this.parent.children.indexOf(this);this.triggerModify("remove"),this.parent.children.splice(t,1),this.visit((t=>{t.removeMarkup(),e._unregisterNode(t)}),!0),e.setModified(A.structure)}removeChildren(){const e=this.tree;this.children&&(e.activeNode&&e.activeNode.isDescendantOf(this)&&e.activeNode.setActive(!1),e.focusNode&&e.focusNode.isDescendantOf(this)&&(e.focusNode=null),this.triggerModifyChild("remove",null),this.visit((t=>{e._unregisterNode(t)})),this.lazy?this.children=[]:this.children=null,this.isRootNode()||(this.expanded=!1),this.tree.setModified(A.structure))}removeMarkup(){this._rowElem&&(delete this._rowElem._wb_node,this._rowElem.remove(),this._rowElem=void 0)}_getRenderInfo(){let e={},t=0,i=this._rowElem?this._rowElem.querySelectorAll("span.wb-col"):null;for(let s of this.tree.columns)e[s.id]={id:s.id,idx:t,elem:i?i[t]:null,info:s},t++;return e}_createIcon(e,t){let i,s=this.getOption("icon");return this._errorInfo?s=O.error:this._isLoading&&(s=O.loading),!1===s?null:("string"==typeof s||(s=this.statusNodeType?O[this.statusNodeType]:this.expanded?O.folderOpen:this.children?O.folder:O.doc),s.indexOf("<")>=0?i=u(s):S.test(s)?i=u(`<img src="${s}" class="wb-icon">`):(i=document.createElement("i"),i.className="wb-icon "+s),t?e.replaceChild(i,t):e.appendChild(i),i)}_render_markup(e){const t=this.tree,i=t.options,s=!1!==this.getOption("checkbox"),n=t.columns,r=this.getLevel();let l,a,d,c,h=this._rowElem,u=null,p=null;const f=t.navMode===R.row?null:t.activeColIdx,g=!h;o(g),o(!g||e&&e.after,"opts.after expected, unless updating"),o(!this.isRootNode()),h=document.createElement("div"),h.classList.add("wb-row"),h.style.top=this._rowIdx*L+"px",this._rowElem=h,h._wb_node=this,a=document.createElement("span"),a.classList.add("wb-node","wb-col"),h.appendChild(a);let v=0;s&&(u=document.createElement("i"),u.classList.add("wb-checkbox"),a.appendChild(u),v+=20);for(let e=r-1;e>0;e--)l=document.createElement("i"),l.classList.add("wb-indent"),a.appendChild(l),v+=20;if((!i.minExpandLevel||r>i.minExpandLevel)&&(p=document.createElement("i"),p.classList.add("wb-expander"),a.appendChild(p),v+=20),c=this._createIcon(a),c&&(v+=20),d=document.createElement("span"),d.classList.add("wb-title"),a.appendChild(d),this._callEvent("enhanceTitle",{titleSpan:d}),a._ofsTitlePx=v,t.options.dnd.dragStart&&(a.draggable=!0),!this.colspan&&n.length>1){let e=0;for(let t of n){let i;e++,"*"===t.id?i=a:(i=document.createElement("span"),i.classList.add("wb-col"),h.appendChild(i)),e===f&&i.classList.add("wb-active"),t.classes&&i.classList.add(...t.classes.split(" ")),i.style.left=t._ofsPx+"px",i.style.width=t._widthPx+"px",g&&t.html&&"string"==typeof t.html&&(i.innerHTML=t.html)}}e.isNew=!0,this._render_data(e);switch(e?e.after:"last"){case"first":t.nodeListElement.prepend(h);break;case"last":t.nodeListElement.appendChild(h);break;default:e.after.after(h)}}_render_data(e){o(this._rowElem);const t=this.tree,i=t.options,s=this._rowElem,n=!!e.isNew,r=t.columns,l=this.type?t.types[this.type]:null,a=s.querySelector("span.wb-node"),d=a.querySelector("span.wb-title");if(this.titleWithHighlight?d.innerHTML=this.titleWithHighlight:d.textContent=this.title,!i.skeleton)if(this.colspan){let e=t.element.clientWidth;d.style.width=e-a._ofsTitlePx-7+"px"}else d.style.width=r[0]._widthPx-a._ofsTitlePx-7+"px";e.isDataChange=!0,this._render_status(e),this.statusNodeType?this._callEvent("renderStatusNode",{isNew:n,nodeElem:a}):this.parent&&this._callEvent("render",{isNew:n,isDataChange:!0,nodeElem:a,typeInfo:l,colInfosById:this._getRenderInfo()})}_render_status(e){const t=this.tree,i=t.options,s=this.type?t.types[this.type]:null,n=this._rowElem,r=n.querySelector("span.wb-node"),o=r.querySelector("i.wb-expander"),l=r.querySelector("i.wb-checkbox");let a=["wb-row"];if(this.expanded&&a.push("wb-expanded"),this.lazy&&a.push("wb-lazy"),this.selected&&a.push("wb-selected"),this===t.activeNode&&a.push("wb-active"),this===t.focusNode&&a.push("wb-focus"),this._errorInfo&&a.push("wb-error"),this._isLoading&&a.push("wb-loading"),this.statusNodeType&&a.push("wb-status-"+this.statusNodeType),this.match&&a.push("wb-match"),this.subMatchCount&&a.push("wb-submatch"),i.skeleton&&a.push("wb-skeleton"),n.className=a.join(" "),n.classList.add(...this.extraClasses),s&&s.classes&&n.classList.add(...s.classes),o&&(this.isExpandable(!1)?this.expanded?o.className="wb-expander "+O.expanderExpanded:o.className="wb-expander "+O.expanderCollapsed:this._isLoading?o.className="wb-expander "+O.loading:this.lazy&&null==this.children?o.className="wb-expander "+O.expanderLazy:o.classList.add("wb-indent")),l&&(this.selected?l.className="wb-checkbox "+O.checkChecked:l.className="wb-checkbox "+O.checkUnchecked),!e.isNew){let e=0;for(let i of n.children)i.classList.toggle("wb-active",e++===t.activeColIdx)}}render(e){const t=Object.assign({change:A.data},e);switch(this._rowElem||(t.change="row"),t.change){case"status":this._render_status(t);break;case"data":this._render_data(t);break;default:this._render_markup(t)}}resetLazy(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=null,this.tree.setModified(A.structure)}toDict(e=!1,t){const i={};if(se.forEach((e=>{const t=this[e];t instanceof Set?t.size&&(i[e]=Array.prototype.join.call(t.keys()," ")):(t||!1===t||0===t)&&(i[e]=t)})),b(this.data)||(i.data=m({},this.data),b(i.data)&&delete i.data),t){const s=t(i,this);if(!1===s)return!1;"skip"===s&&(e=!1)}if(e&&w(this.children)){i.children=[];for(let e=0,s=this.children.length;e<s;e++){const s=this.children[e];if(!s.isStatusNode()){const e=s.toDict(!0,t);!1!==e&&i.children.push(e)}}}return i}getOption(e,t){let i=this.tree,s=i.options;e.indexOf(".")>=0&&([s,e]=e.split("."));let n=s[e];if("function"==typeof n){let e=n.call(i,{type:"resolve",tree:i,node:this});if(void 0!==e)return e}if(void 0!==this[e])return this[e];let r=this.type?i.types[this.type]:void 0,o=r?r[e]:void 0;return void 0!==o?o:null!=n?n:t}async scrollIntoView(e){return this.tree.scrollTo(this)}async setActive(e=!0,t){const i=this.tree,s=i.activeNode,n=null==t?void 0:t.retrigger;if(!(null==t?void 0:t.noEvents)){let r=null==t?void 0:t.event;if(e){if(s!==this||n){if(!1===(null==s?void 0:s._callEvent("deactivate",{nextNode:this,orgEvent:r})))return;if(!1===this._callEvent("activate",{prevNode:s,orgEvent:r}))return i.activeNode=null,void(null==s||s.setModified())}}else(s===this||n)&&this._callEvent("deactivate",{nextNode:null,orgEvent:r})}return s!==this&&(i.activeNode=this,null==s||s.setModified(A.status),this.setModified(A.status)),t&&null!=t.colIdx&&t.colIdx!==i.activeColIdx&&i.navMode!==R.row&&i.setColumn(t.colIdx),this.scrollIntoView()}async setExpanded(e=!0,t){!e&&this.isExpanded()&&this.getLevel()<this.getOption("minExpandLevel")&&!k(t,"force")?this.logDebug("Ignored collapse request below expandLevel."):(e&&this.lazy&&null==this.children&&await this.loadLazy(),this.expanded=e,this.tree.setModified(A.structure))}setFocus(e=!0,t){const i=this.tree.focusNode;this.tree.focusNode=this,null==i||i.setModified(),this.setModified()}setIcon(){throw new Error("Not yet implemented")}setKey(e,t){throw new Error("Not yet implemented")}setModified(e=A.data){o(e===A.status||e===A.data),this.tree.setModified(e,this)}setSelected(e=!0,t){!!e!==this.selected&&this._callEvent("select",{flag:e}),this.selected=!!e,this.setModified()}setStatus(e,t,i){const s=this.tree;let n=null;const r=e=>{let t=this.children,i=t?t[0]:null;return o(e.statusNodeType),o(!i||!i.isStatusNode()),n=this.addNode(e,"firstChild"),n.match=!0,s.setModified(A.structure),n};switch((()=>{let e=this.children;e&&e.length&&e[0].isStatusNode()&&e[0].remove()})(),e){case"ok":this._isLoading=!1,this._errorInfo=null;break;case"loading":this.parent||r({statusNodeType:e,title:s.options.strings.loading+(t?" ("+t+")":""),checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!0,this._errorInfo=null;break;case"error":r({statusNodeType:e,title:s.options.strings.loadError+(t?" ("+t+")":""),checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!1,this._errorInfo={message:t,details:i};break;case"noData":r({statusNodeType:e,title:t||s.options.strings.noData,checkbox:!1,colspan:!0,tooltip:i}),this._isLoading=!1,this._errorInfo=null;break;default:a("invalid node status "+e)}return s.setModified(A.structure),n}setTitle(e){this.title=e,this.setModified()}triggerModifyChild(e,t,i){this.tree.options.modifyChild&&(t&&t.parent!==this&&a("child "+t+" is not a child of "+this),this._callEvent("modifyChild",m({operation:e,child:t},i)))}triggerModify(e,t){this.parent&&this.parent.triggerModifyChild(e,this,t)}visit(e,t=!1){let i,s,n=!0,r=this.children;if(!0===t&&(n=e(this),!1===n||"skip"===n))return n;if(r)for(i=0,s=r.length;i<s&&(n=r[i].visit(e,!0),!1!==n);i++);return n}visitParents(e,t=!1){if(t&&!1===e(this))return!1;let i=this.parent;for(;i;){if(!1===e(i))return!1;i=i.parent}return!0}visitSiblings(e,t=!1){let i,s,n,r=this.parent.children;for(i=0,s=r.length;i<s;i++)if(n=r[i],(t||n!==this)&&!1===e(n))return!1;return!0}isMatched(){return!(this.tree.filterMode&&!this.match)}}ne.sequence=0;
61
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
62
+ */const ne=new Set(["classes","expanded","icon","key","lazy","refKey","selected","title","tooltip","type"]),re=new Set(["checkbox","expanded","classes","folder","icon","iconTooltip","key","lazy","partsel","radiogroup","refKey","selected","statusNodeType","title","tooltip","type","unselectable","unselectableIgnore","unselectableStatus"]);class le{constructor(e,t,i){var s,n;this.refKey=void 0,this.children=null,this.lazy=!1,this.expanded=!1,this.selected=!1,this.classes=null,this.data={},this._isLoading=!1,this._requestId=0,this._errorInfo=null,this._partsel=!1,this._partload=!1,this.subMatchCount=0,this._rowIdx=0,this._rowElem=void 0,l(!t||t.tree===e),l(!i.children),this.tree=e,this.parent=t,this.key=""+(null!==(s=i.key)&&void 0!==s?s:++le.sequence),this.title=""+(null!==(n=i.title)&&void 0!==n?n:"<"+this.key+">"),null!=i.refKey&&(this.refKey=""+i.refKey),null!=i.statusNodeType&&(this.statusNodeType=""+i.statusNodeType),null!=i.type&&(this.type=""+i.type),null!=i.checkbox&&(this.checkbox=!!i.checkbox),null!=i.colspan&&(this.colspan=!!i.colspan),this.expanded=!0===i.expanded,null!=i.icon&&(this.icon=i.icon),this.lazy=!0===i.lazy,this.selected=!0===i.selected,i.classes&&this.setClass(i.classes);for(const[e,t]of Object.entries(i))ne.has(e)||(this.data[e]=t);t&&!this.statusNodeType&&e._registerNode(this)}toString(){return`WunderbaumNode@${this.key}<'${this.title}'>`}_callEvent(e,t){return this.tree._callEvent(e,y({node:this,typeInfo:this.type?this.tree.types[this.type]:{}},t))}addChildren(e,t){const i=this.tree,s=t?t.level:this.getLevel();let n=t?t.before:null,r=[];try{i.enableUpdate(!1),_(e)&&(e=[e]);const t=s<i.options.minExpandLevel;for(let n of e){let e=n.children;delete n.children;let l=new le(i,this,n);t&&!l.lazy&&(l.expanded=!0),r.push(l),e&&l.addChildren(e,{redraw:!1,level:s+1})}if(this.children)if(null==n||0===this.children.length)this.children=this.children.concat(r);else{n=this.findDirectChild(n);let e=this.children.indexOf(n);l(e>=0,"insertBefore must be an existing child"),this.children.splice(e,0,...r)}else this.children=r;return i.setModified(S.structure),r[0]}finally{i.enableUpdate(!0)}}addNode(e,t="child"){switch("over"===t&&(t="child"),t){case"after":return this.parent.addChildren(e,{before:this.getNextSibling()});case"before":return this.parent.addChildren(e,{before:this});case"firstChild":return this.addChildren(e,{before:0});case"child":return this.addChildren(e)}l(!1,"Invalid mode: "+t)}applyCommand(e,t){return this.tree.applyCommand(e,this,t)}setClass(e,t=!0){const i=T(e);if(t)null===this.classes&&(this.classes=new Set),i.forEach((e=>{var i;this.classes.add(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)}));else{if(null===this.classes)return;i.forEach((e=>{var i;this.classes.delete(e),null===(i=this._rowElem)||void 0===i||i.classList.toggle(e,t)})),0===this.classes.size&&(this.classes=null)}}async expandAll(e=!0){this.visit((t=>{t.setExpanded(e)}))}findAll(e){const t=x(e)?e:Z(e),i=[];return this.visit((e=>{t(e)&&i.push(e)})),i}findDirectChild(e){let t=this.children;if(!t)return null;if("string"==typeof e){for(let i=0,s=t.length;i<s;i++)if(t[i].key===e)return t[i]}else{if("number"==typeof e)return t[e];if(e.parent===this)return e}return null}findFirst(e){const t=x(e)?e:Z(e);let i=null;return this.visit((e=>{if(t(e))return i=e,!1})),i}findRelatedNode(e,t=!1){return this.tree.findRelatedNode(this,e,t)}getColElem(e){var t;"string"==typeof e&&(e=this.tree.columns.findIndex((t=>t.id===e)));const i=null===(t=this._rowElem)||void 0===t?void 0:t.querySelectorAll("span.wb-col");return i?i[e]:null}getFirstChild(){return this.children?this.children[0]:null}getLastChild(){return this.children?this.children[this.children.length-1]:null}getLevel(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}getNextSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t+1]||null}getParent(){return this.parent}getParentList(e=!1,t=!1){let i=[],s=t?this:this.parent;for(;s;)(e||s.parent)&&i.unshift(s),s=s.parent;return i}getPath(e=!0,t="title",i="/"){let s,n=[],r="function"==typeof t;return this.visitParents((e=>{e.parent&&(s=r?t(e):e[t],n.unshift(s))}),e),n.join(i)}getPrevSibling(){let e=this.parent.children,t=e.indexOf(this);return e[t-1]||null}hasChildren(){if(this.lazy){if(null==this.children)return;if(0===this.children.length)return!1;if(1===this.children.length&&this.children[0].isStatusNode())return;return!0}return!(!this.children||!this.children.length)}hasClass(e){return!!this.classes&&this.classes.has(e)}isActive(){return this.tree.activeNode===this}isChildOf(e){return this.parent&&this.parent===e}isColspan(){return!!this.getOption("colspan")}isDescendantOf(e){if(!e||e.tree!==this.tree)return!1;for(var t=this.parent;t;){if(t===e)return!0;t===t.parent&&a("Recursive parent link: "+t),t=t.parent}return!1}isExpandable(e=!1){return!(!this.children||this.expanded&&e)}isEditing(){return this.tree._callMethod("edit.isEditingTitle",this)}isExpanded(){return!!this.expanded}isFirstSibling(){var e=this.parent;return!e||e.children[0]===this}isLastSibling(){var e=this.parent;return!e||e.children[e.children.length-1]===this}isLazy(){return!!this.lazy}isLoaded(){return!this.lazy||void 0!==this.hasChildren()}isLoading(){return this._isLoading}isPagingNode(){return"paging"===this.statusNodeType}isPartload(){return!!this._partload}isPartsel(){return!this.selected&&!!this._partsel}isRendered(){return!!this._rowElem}isRootNode(){return this.tree.root===this}isSelected(){return!!this.selected}isStatusNode(){return!!this.statusNodeType}isTopLevel(){return this.tree.root===this.parent}isUnloaded(){return void 0===this.hasChildren()}isVisible(){let e,t,i,s="hide"===this.tree.filterMode,n=this.getParentList(!1,!1);if(s&&!this.match&&!this.subMatchCount)return!1;for(e=0,t=n.length;e<t;e++)if(i=n[e],!i.expanded)return!1;return!0}_loadSourceObject(e,t){const i=this.tree;null!=t||(t=this.getLevel()),this._callEvent("receive",{response:e}),w(e)&&(e={children:e}),l(_(e)),l(e.children,"If `source` is an object, it must have a `children` property"),e.types&&(i.logInfo("Redefine types",e.columns),i.setTypes(e.types,!1),delete e.types),e.columns&&(i.logInfo("Redefine columns",e.columns),i.columns=e.columns,delete e.columns,i.updateColumns({calculateCols:!1})),this.addChildren(e.children);for(const[t,s]of Object.entries(e))X.has(t)||(i.data[t]=s,i.logDebug(`Add source.${t} to tree.data.${t}`));this._callEvent("load")}async load(e){const t=this.tree,i=Date.now(),s=this.parent,n="string"==typeof e?e:e.url,r=Date.now();let l=0,o=0,d=0;this._requestId&&this.logWarn(`Recursive load request #${i} while #${this._requestId} is pending.`),this._requestId=i;try{if(n){this.setStatus(L.loading);const e=await fetch(n,{method:"GET"});e.ok||a(`GET ${n} returned ${e.status}, ${e}`);const t=await e.json();if(o=Date.now()-r,this._requestId&&this._requestId>i)return void this.logWarn(`Ignored load response #${i} because #${this._requestId} is pending.`);if(this.logDebug(`Received response for load request #${i}`),null===this.parent&&null!==s)return void this.logWarn("Lazy parent node was removed while loading: discarding response.");this.setStatus(L.ok);const l=Date.now();this._loadSourceObject(t),d=Date.now()-l}else this._loadSourceObject(e),d=Date.now()-r}catch(t){throw this.logError("Error during load()",e,t),this._callEvent("error",{error:t}),this.setStatus(L.error,{message:""+t}),t}finally{this._requestId=0,l=Date.now()-r,t.options.debugLevel>=3&&t.logInfo(`Load source took ${l/1e3} seconds (transfer: ${o/1e3}s, processing: ${d/1e3}s)`)}}async loadLazy(e=!1){const t=this.expanded;if(l(this.lazy,"load() requires a lazy node"),e||this.isUnloaded()){this.isLoaded()&&this.resetLazy(),this.setStatus(L.loading);try{const e=await this._callEvent("lazyLoad");if(!1===e)return void this.setStatus(L.ok);l(w(e)||e&&e.url,"The lazyLoad event must return a node list, `{url: ...}`, or false."),await this.load(e),t?(this.expanded=!0,this.tree.setModified(S.structure)):this.setModified()}catch(e){this.logError("Error during loadLazy()",e),this._callEvent("error",{error:e}),this.setStatus(L.error,{message:""+e})}}}log(...e){this.logDebug.apply(this,e)}logDebug(...e){this.tree.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.tree.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.tree.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logWarn(...e){this.tree.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}async makeVisible(e){let t,i=new se,s=[],n=this.getParentList(!1,!1),r=n.length,l=!(e&&!1===e.scrollIntoView);for(t=r-1;t>=0;t--){const i={noAnimation:null==e?void 0:e.noAnimation};s.push(n[t].setExpanded(!0,i))}return Promise.all(s).then((()=>{l&&this.tree?(this.tree.updatePendingModifications(),this.scrollIntoView().then((()=>{i.resolve()}))):i.resolve()})),i.promise()}moveTo(e,t="appendChild",i){"prependChild"===t&&(e.children&&e.children.length?(t="before",e=e.children[0]):t="appendChild");let s,n=this.tree,r=this.parent,o="appendChild"===t?e:e.parent;if(this!==e){if(this.parent?o.isDescendantOf(this)&&a("Cannot move a node to its own descendant"):a("Cannot move system root"),o!==r&&r.triggerModifyChild("remove",this),1===this.parent.children.length){if(this.parent===o)return;this.parent.children=this.parent.lazy?[]:null,this.parent.expanded=!1}else s=this.parent.children.indexOf(this),l(s>=0,"invalid source parent"),this.parent.children.splice(s,1);if(this.parent=o,o.hasChildren())switch(t){case"appendChild":o.children.push(this);break;case"before":s=o.children.indexOf(e),l(s>=0,"invalid target parent"),o.children.splice(s,0,this);break;case"after":s=o.children.indexOf(e),l(s>=0,"invalid target parent"),o.children.splice(s+1,0,this);break;default:a("Invalid mode "+t)}else o.children=[this];i&&e.visit(i,!0),o===r?o.triggerModifyChild("move",this):o.triggerModifyChild("add",this),n!==e.tree&&(this.logWarn("Cross-tree moveTo is experimental!"),this.visit((function(t){t.tree=e.tree}),!0)),n.setModified(S.structure)}}async navigate(e,t){e=J[e]||e;const i=this.findRelatedNode(e);if(!i)return this.logWarn(`Could not find related node '${e}'.`),Promise.resolve(this);try{i.makeVisible({scrollIntoView:!1})}catch(e){}return i.setFocus(),!1===(null==t?void 0:t.activate)?Promise.resolve(this):i.setActive(!0,{event:null==t?void 0:t.event})}remove(){const e=this.tree,t=this.parent.children.indexOf(this);this.triggerModify("remove"),this.parent.children.splice(t,1),this.visit((t=>{t.removeMarkup(),e._unregisterNode(t)}),!0),e.setModified(S.structure)}removeChildren(){const e=this.tree;this.children&&(e.activeNode&&e.activeNode.isDescendantOf(this)&&e.activeNode.setActive(!1),e.focusNode&&e.focusNode.isDescendantOf(this)&&(e.focusNode=null),this.triggerModifyChild("remove",null),this.visit((t=>{e._unregisterNode(t)})),this.lazy?this.children=[]:this.children=null,this.isRootNode()||(this.expanded=!1),this.tree.setModified(S.structure))}removeMarkup(){this._rowElem&&(delete this._rowElem._wb_node,this._rowElem.remove(),this._rowElem=void 0)}_getRenderInfo(){const e={},t={},i=this.isColspan(),s=this._rowElem?this._rowElem.querySelectorAll("span.wb-col"):null;let n=0;for(let r of this.tree.columns)e[r.id]={id:r.id,idx:n,elem:s?s[n]:null,info:r},i||"*"===r.id||(t[r.id]=e[r.id]),n++;return{allColInfosById:e,renderColInfosById:t}}_createIcon(e,t){let i,s=this.getOption("icon");return this._errorInfo?s=Y.error:this._isLoading&&(s=Y.loading),!1===s?null:("string"==typeof s||(s=this.statusNodeType?Y[this.statusNodeType]:this.expanded?Y.folderOpen:this.children?Y.folder:this.lazy?Y.folderLazy:Y.doc),s.indexOf("<")>=0?i=f(s):Q.test(s)?i=f(`<img src="${s}" class="wb-icon">`):(i=document.createElement("i"),i.className="wb-icon "+s),t?e.replaceChild(i,t):e.appendChild(i),i)}_render_markup(e){const t=this.tree,i=t.options,s=!1!==this.getOption("checkbox"),n=t.columns,r=this.getLevel();let o,a,d,c,h=this._rowElem,u=null,p=null;const f=t.isRowNav()?null:t.activeColIdx,g=!h;l(g),l(!g||e&&e.after,"opts.after expected, unless updating"),l(!this.isRootNode()),h=document.createElement("div"),h.classList.add("wb-row"),h.style.top=this._rowIdx*G+"px",this._rowElem=h,h._wb_node=this,a=document.createElement("span"),a.classList.add("wb-node","wb-col"),h.appendChild(a);let v=0;s&&(u=document.createElement("i"),u.classList.add("wb-checkbox"),a.appendChild(u),v+=20);for(let e=r-1;e>0;e--)o=document.createElement("i"),o.classList.add("wb-indent"),a.appendChild(o),v+=20;(!i.minExpandLevel||r>i.minExpandLevel)&&(p=document.createElement("i"),p.classList.add("wb-expander"),a.appendChild(p),v+=20),c=this._createIcon(a),c&&(v+=20),d=document.createElement("span"),d.classList.add("wb-title"),a.appendChild(d),this._callEvent("enhanceTitle",{titleSpan:d}),a._ofsTitlePx=v,t.options.dnd.dragStart&&(a.draggable=!0);if(!this.isColspan()&&n.length>1){let e=0;for(let t of n){let i;e++,"*"===t.id?i=a:(i=document.createElement("span"),i.classList.add("wb-col"),h.appendChild(i)),e===f&&i.classList.add("wb-active"),t.classes&&i.classList.add(...t.classes.split(" ")),i.style.left=t._ofsPx+"px",i.style.width=t._widthPx+"px",g&&t.html&&"string"==typeof t.html&&(i.innerHTML=t.html)}}switch(e?e.after:"last"){case"first":t.nodeListElement.prepend(h);break;case"last":t.nodeListElement.appendChild(h);break;default:e.after.after(h)}e.isNew=!0,this._render_data(e)}_render_data(e){l(this._rowElem);const t=this.tree,i=t.options,s=this._rowElem,n=!!e.isNew,r=t.columns,o=this.isColspan(),a=s.querySelector("span.wb-node"),d=a.querySelector("span.wb-title");if(this.titleWithHighlight?d.innerHTML=this.titleWithHighlight:d.textContent=this.title,!i.skeleton)if(o){let e=t.element.clientWidth;d.style.width=e-a._ofsTitlePx-7+"px"}else d.style.width=r[0]._widthPx-a._ofsTitlePx-7+"px";if(e.isDataChange=!0,this._render_status(e),this.statusNodeType)this._callEvent("renderStatusNode",{isNew:n,nodeElem:a});else if(this.parent){const e=this._getRenderInfo();this._callEvent("render",{isNew:n,isColspan:o,nodeElem:a,allColInfosById:e.allColInfosById,renderColInfosById:e.renderColInfosById})}}_render_status(e){const t=this.tree,i=t.options,s=this.type?t.types[this.type]:null,n=this._rowElem,r=n.querySelector("span.wb-node"),l=r.querySelector("i.wb-expander"),o=r.querySelector("i.wb-checkbox");let a=["wb-row"];if(this.expanded&&a.push("wb-expanded"),this.lazy&&a.push("wb-lazy"),this.selected&&a.push("wb-selected"),this===t.activeNode&&a.push("wb-active"),this===t.focusNode&&a.push("wb-focus"),this._errorInfo&&a.push("wb-error"),this._isLoading&&a.push("wb-loading"),this.isColspan()&&a.push("wb-colspan"),this.statusNodeType&&a.push("wb-status-"+this.statusNodeType),this.match&&a.push("wb-match"),this.subMatchCount&&a.push("wb-submatch"),i.skeleton&&a.push("wb-skeleton"),n.className=a.join(" "),this.classes&&n.classList.add(...this.classes),s&&s.classes&&n.classList.add(...s.classes),l&&(this.isExpandable(!1)?this.expanded?l.className="wb-expander "+Y.expanderExpanded:l.className="wb-expander "+Y.expanderCollapsed:this._isLoading?l.className="wb-expander "+Y.loading:this.lazy&&null==this.children?l.className="wb-expander "+Y.expanderLazy:l.classList.add("wb-indent")),o&&(this.selected?o.className="wb-checkbox "+Y.checkChecked:o.className="wb-checkbox "+Y.checkUnchecked),!e.isNew){let e=0;for(let i of n.children)i.classList.toggle("wb-active",e++===t.activeColIdx);const i=r.querySelector("i.wb-icon");i&&this._createIcon(r,i)}}render(e){const t=Object.assign({change:S.data},e);switch(this._rowElem||(t.change="row"),t.change){case"status":this._render_status(t);break;case"data":this._render_data(t);break;default:this._render_markup(t)}}resetLazy(){this.removeChildren(),this.expanded=!1,this.lazy=!0,this.children=null,this.tree.setModified(S.structure)}toDict(e=!1,t){const i={};if(re.forEach((e=>{const t=this[e];t instanceof Set?t.size&&(i[e]=Array.prototype.join.call(t.keys()," ")):(t||!1===t||0===t)&&(i[e]=t)})),E(this.data)||(i.data=y({},this.data),E(i.data)&&delete i.data),t){const s=t(i,this);if(!1===s)return!1;"skip"===s&&(e=!1)}if(e&&w(this.children)){i.children=[];for(let e=0,s=this.children.length;e<s;e++){const s=this.children[e];if(!s.isStatusNode()){const e=s.toDict(!0,t);!1!==e&&i.children.push(e)}}}return i}getOption(e,t){let i=this.tree,s=i.options;e.indexOf(".")>=0&&([s,e]=e.split("."));let n=s[e];if("function"==typeof n){let e=n.call(i,{type:"resolve",tree:i,node:this});if(void 0!==e)return e}if(void 0!==this[e])return this[e];let r=this.type?i.types[this.type]:void 0,l=r?r[e]:void 0;return void 0!==l?l:null!=n?n:t}async scrollIntoView(e){const t=Object.assign({node:this},e);return this.tree.scrollTo(t)}async setActive(e=!0,t){const i=this.tree,s=i.activeNode,n=null==t?void 0:t.retrigger,r=null==t?void 0:t.focusTree,l=!1!==(null==t?void 0:t.focusNode),o=null==t?void 0:t.noEvents,a=null==t?void 0:t.event;if(!o)if(e){if(s!==this||n){if(!1===(null==s?void 0:s._callEvent("deactivate",{nextNode:this,orgEvent:a}))||!1===this._callEvent("beforeActivate",{prevNode:s,orgEvent:a}))return;i.activeNode=null,null==s||s.setModified(S.status)}}else(s===this||n)&&this._callEvent("deactivate",{nextNode:null,orgEvent:a});return s!==this&&(e&&(i.activeNode=this,(l||r)&&(i.focusNode=this),r&&i.setFocus()),null==s||s.setModified(S.status),this.setModified(S.status)),t&&null!=t.colIdx&&t.colIdx!==i.activeColIdx&&i.isCellNav()&&i.setColumn(t.colIdx),e&&!o&&this._callEvent("activate",{prevNode:s,orgEvent:a}),this.makeVisible()}async setExpanded(e=!0,t){if(!e&&this.isExpanded()&&this.getLevel()<=this.tree.getOption("minExpandLevel")&&!M(t,"force"))return void this.logDebug("Ignored collapse request below expandLevel.");if(!e==!this.expanded)return;e&&this.lazy&&null==this.children&&await this.loadLazy(),this.expanded=e;const i={immediate:!!M(t,"immediate")};if(this.tree.setModified(S.structure,i),!1!==M(t,"scrollIntoView")){const e=this.getLastChild();e&&e.scrollIntoView({topNode:this})}}setFocus(e=!0){l(!!e,"blur is not yet implemented");const t=this.tree.focusNode;this.tree.focusNode=this,null==t||t.setModified(),this.setModified()}setIcon(){throw new Error("Not yet implemented")}setKey(e,t){throw new Error("Not yet implemented")}setModified(e=S.data){l(e===S.status||e===S.data),this.tree.setModified(e,this)}setSelected(e=!0,t){!!e!==this.selected&&this._callEvent("select",{flag:e}),this.selected=!!e,this.setModified()}setStatus(e,t){const i=this.tree,s=null==t?void 0:t.message,n=null==t?void 0:t.details;let r=null;const o=e=>{let t=this.children,s=t?t[0]:null;return l(e.statusNodeType),l(!s||!s.isStatusNode()),r=this.addNode(e,"firstChild"),r.match=!0,i.setModified(S.structure),r};switch((()=>{let e=this.children;e&&e.length&&e[0].isStatusNode()&&e[0].remove()})(),e){case"ok":this._isLoading=!1,this._errorInfo=null;break;case"loading":this.parent||o({statusNodeType:e,title:i.options.strings.loading+(s?" ("+s+")":""),checkbox:!1,colspan:!0,tooltip:n}),this._isLoading=!0,this._errorInfo=null;break;case"error":o({statusNodeType:e,title:i.options.strings.loadError+(s?" ("+s+")":""),checkbox:!1,colspan:!0,tooltip:n}),this._isLoading=!1,this._errorInfo={message:s,details:n};break;case"noData":o({statusNodeType:e,title:s||i.options.strings.noData,checkbox:!1,colspan:!0,tooltip:n}),this._isLoading=!1,this._errorInfo=null;break;default:a("invalid node status "+e)}return i.setModified(S.structure),r}setTitle(e){this.title=e,this.setModified()}triggerModifyChild(e,t,i){this.tree.options.modifyChild&&(t&&t.parent!==this&&a("child "+t+" is not a child of "+this),this._callEvent("modifyChild",y({operation:e,child:t},i)))}triggerModify(e,t){this.parent.triggerModifyChild(e,this,t)}visit(e,t=!1){let i,s,n=!0,r=this.children;if(!0===t&&(n=e(this),!1===n||"skip"===n))return n;if(r)for(i=0,s=r.length;i<s&&(n=r[i].visit(e,!0),!1!==n);i++);return n}visitParents(e,t=!1){if(t&&!1===e(this))return!1;let i=this.parent;for(;i;){if(!1===e(i))return!1;i=i.parent}return!0}visitSiblings(e,t=!1){let i,s,n,r=this.parent.children;for(i=0,s=r.length;i<s;i++)if(n=r[i],(t||n!==this)&&!1===e(n))return!1;return!0}isMatched(){return!(this.tree.filterMode&&!this.match)}}le.sequence=0;
63
63
  /*!
64
64
  * Wunderbaum - ext-edit
65
65
  * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
66
- * v0.0.4, Tue, 03 May 2022 06:21:31 GMT (https://github.com/mar10/wunderbaum)
66
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
67
67
  */
68
- class re extends z{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxlength:null,trigger:[],trim:!0,select:!0,slowClickDelay:1e3,validity:!0,beforeEdit:null,edit:null,apply:null}),this.curEditNode=null,this.relatedNode=null,this.debouncedOnChange=V(this._onChange.bind(this),this.getPluginOption("debounce"))}_applyChange(e,t,i,s){let n;t.log(`_applyChange(${e})`,s),i.classList.add("wb-dirty"),i.classList.remove("wb-error");try{n=t._callEvent(e,s)}catch(s){t.logError(`Error in ${e} event handler`,s),i.classList.add("wb-error"),i.classList.remove("wb-dirty")}return n instanceof Promise||(n=Promise.resolve(n)),n.catch((s=>{t.logError(`Error in ${e} event promise`,s),i.classList.add("wb-error")})).finally((()=>{i.classList.remove("wb-dirty")})),n}_onChange(e){const t=oe.getEventInfo(e),i=t.node,s=t.colElem;i&&0!==t.colIdx?this._applyChange("change",i,s,{info:t,event:e,inputElem:e.target,inputValue:oe.util.getValueFromElem(e.target)}):this.tree.log("Ignored change event for removed element or node title")}init(){super.init(),_(this.tree.element,"change",".contenteditable,input,textarea,select",(e=>{this.debouncedOnChange(e)}))}_preprocessKeyEvent(e){const t=e.event,s=v(t),n=this.tree,r=this.getPluginOption("trigger"),o=t.target&&t.target.closest("input,[contenteditable]");if(n.logDebug(`_preprocessKeyEvent: ${s}`),o){switch(s){case"Enter":return this._stopEditTitle(!0,{event:t}),!1;case"Escape":return this._stopEditTitle(!1,{event:t}),!1}return!1}if(n.navMode===R.row||0===n.activeColIdx){switch(s){case"Enter":if(r.indexOf("macEnter")>=0&&i)return this.startEditTitle(),!1;break;case"F2":if(r.indexOf("F2")>=0)return this.startEditTitle(),!1}return!0}return!0}isEditingTitle(e){return e?this.curEditNode===e:!!this.curEditNode}startEditTitle(e){e=null!=e?e:this.tree.getActiveNode();const t=this.getPluginOption("validity"),i=this.getPluginOption("select");if(!e)return;this.tree.logDebug(`startEditTitle(node=${e})`);let s=e._callEvent("edit.beforeEdit");if(!1===s)return void e.logInfo("beforeEdit canceled operation.");if(!s){s=`<input type=text class="wb-input-edit" value="${d(e.title)}" required autocorrect=off>`}const n=e.getColElem(0).querySelector(".wb-title");n.innerHTML=s;const r=n.firstElementChild;t&&r.addEventListener("keydown",(e=>{r.setCustomValidity(""),r.reportValidity()})),r.focus(),i&&r.select(),this.curEditNode=e,e._callEvent("edit.edit",{inputElem:r})}stopEditTitle(e){return this._stopEditTitle(e,{})}_stopEditTitle(e,t){const i=document.activeElement;let s=i?h(i):null;const n=this.curEditNode,r=!!t.forceClose,o=this.getPluginOption("validity");if(s&&this.getPluginOption("trim")&&(s=s.trim()),n)if(n.logDebug(`stopEditTitle(${e})`,t,i,s),e&&null!==s&&s!==n.title){const e=i.validationMessage;if(e)throw new Error(`Input validation failed for "${s}": ${e}.`);const t=n.getColElem(0);this._applyChange("edit.apply",n,t,{oldValue:n.title,newValue:s,inputElem:i}).then((e=>{const t=i.validationMessage;if(o&&t&&!1!==e)throw new Error(`Edit apply validation failed for "${s}": ${t}.`);(r||!1!==e)&&(null==n||n.setTitle(s),this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus())})).catch((e=>{}))}else this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus();else this.tree.logDebug("stopEditTitle: not in edit mode.")}createNode(e="after",t,i){const s=this.tree;if(o(t=null!=t?t:s.getActiveNode(),"No node was passed, or no node is currently active."),e=e||"prependChild",null==i?i={title:""}:"string"==typeof i?i={title:i}:o(E(i)),("prependChild"===e||"appendChild"===e)&&(null==t?void 0:t.isExpandable(!0)))return void t.setExpanded().then((()=>{this.createNode(e,t,i)}));const n=t.addNode(i,e);n.addClass("wb-edit-new"),this.relatedNode=t,n.match=!0,n.makeVisible({noAnimation:!0}).then((()=>{this.startEditTitle(n)}))}}
68
+ class oe extends P{constructor(e){super(e,"edit",{debounce:100,minlength:1,maxlength:null,trigger:[],trim:!0,select:!0,slowClickDelay:1e3,validity:!0,beforeEdit:null,edit:null,apply:null}),this.curEditNode=null,this.relatedNode=null,this.debouncedOnChange=z(this._onChange.bind(this),this.getPluginOption("debounce"))}_applyChange(e,t,i,s){let n;t.log(`_applyChange(${e})`,s),i.classList.add("wb-busy"),i.classList.remove("wb-error");try{n=t._callEvent(e,s)}catch(s){t.logError(`Error in ${e} event handler`,s),i.classList.add("wb-error"),i.classList.remove("wb-busy")}return n instanceof Promise||(n=Promise.resolve(n)),n.catch((s=>{t.logError(`Error in ${e} event promise`,s),i.classList.add("wb-error")})).finally((()=>{i.classList.remove("wb-busy")})),n}_onChange(e){const t=de.getEventInfo(e),i=t.node,s=t.colElem;i&&0!==t.colIdx?this._applyChange("change",i,s,{info:t,event:e,inputElem:e.target,inputValue:de.util.getValueFromElem(e.target)}):this.tree.log("Ignored change event for removed element or node title")}init(){super.init(),C(this.tree.element,"change",".contenteditable,input,textarea,select",(e=>{this.debouncedOnChange(e)}))}_preprocessKeyEvent(e){const t=e.event,s=b(t),n=this.tree,r=this.getPluginOption("trigger");if(this.isEditingTitle()){switch(s){case"Enter":return this._stopEditTitle(!0,{event:t}),!1;case"Escape":return this._stopEditTitle(!1,{event:t}),!1}return!1}if(n.isRowNav()||0===n.activeColIdx){switch(s){case"Enter":if(r.indexOf("macEnter")>=0&&i)return this.startEditTitle(),!1;break;case"F2":if(r.indexOf("F2")>=0)return this.startEditTitle(),!1}return!0}return!0}isEditingTitle(e){return e?this.curEditNode===e:!!this.curEditNode}startEditTitle(e){e=null!=e?e:this.tree.getActiveNode();const t=this.getPluginOption("validity"),i=this.getPluginOption("select");if(!e)return;this.tree.logDebug(`startEditTitle(node=${e})`);let s=e._callEvent("edit.beforeEdit");if(!1===s)return void e.logInfo("beforeEdit canceled operation.");if(!0===s||!s){s=`<input type=text class="wb-input-edit" value="${d(e.title)}" required autocorrect=off>`}const n=e.getColElem(0).querySelector(".wb-title");n.innerHTML=s;const r=n.firstElementChild;t&&r.addEventListener("keydown",(e=>{r.setCustomValidity(""),r.reportValidity()})),r.focus(),i&&r.select(),this.curEditNode=e,e._callEvent("edit.edit",{inputElem:r})}stopEditTitle(e){return this._stopEditTitle(e,{})}_stopEditTitle(e,t){const i=document.activeElement;let s=i?u(i):null;const n=this.curEditNode,r=!!t.forceClose,l=this.getPluginOption("validity");if(s&&this.getPluginOption("trim")&&(s=s.trim()),n)if(n.logDebug(`stopEditTitle(${e})`,t,i,s),e&&null!==s&&s!==n.title){const e=i.validationMessage;if(e)throw new Error(`Input validation failed for "${s}": ${e}.`);const t=n.getColElem(0);this._applyChange("edit.apply",n,t,{oldValue:n.title,newValue:s,inputElem:i}).then((e=>{const t=i.validationMessage;if(l&&t&&!1!==e)throw new Error(`Edit apply validation failed for "${s}": ${t}.`);(r||!1!==e)&&(null==n||n.setTitle(s),this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus())})).catch((e=>{}))}else this.curEditNode.render(),this.curEditNode=null,this.relatedNode=null,this.tree.setFocus();else this.tree.logDebug("stopEditTitle: not in edit mode.")}createNode(e="after",t,i){const s=this.tree;if(l(t=null!=t?t:s.getActiveNode(),"No node was passed, or no node is currently active."),e=e||"prependChild",null==i?i={title:""}:"string"==typeof i?i={title:i}:l(_(i)),("prependChild"===e||"appendChild"===e)&&(null==t?void 0:t.isExpandable(!0)))return void t.setExpanded().then((()=>{this.createNode(e,t,i)}));const n=t.addNode(i,e);n.setClass("wb-edit-new"),this.relatedNode=t,n.match=!0,n.makeVisible({noAnimation:!0}).then((()=>{this.startEditTitle(n)}))}}
69
69
  /*!
70
70
  * wunderbaum.ts
71
71
  *
72
- * A tree control.
72
+ * A treegrid control.
73
73
  *
74
74
  * Copyright (c) 2021-2022, Martin Wendt (https://wwWendt.de).
75
- * Released under the MIT license.
75
+ * https://github.com/mar10/wunderbaum
76
76
  *
77
- * @version v0.0.4
78
- * @date Tue, 03 May 2022 06:21:31 GMT
79
- */class oe{constructor(e){this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.treeRowCount=0,this._disableUpdateCount=0,this.activeNode=null,this.focusNode=null,this.types={},this.columns=[],this._columnsById={},this.changeRedrawRequestPending=!1,this._util=T,this.filterMode=null,this.activeColIdx=0,this.navMode=R.row,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this.log=this.logDebug;let t=this.options=m({id:null,source:null,element:null,debugLevel:4,header:null,headerHeightPx:L,rowHeightPx:L,columns:null,types:null,showSpinner:!1,checkbox:!0,minExpandLevel:0,updateThrottleWait:200,skeleton:!1,navigationMode:P.startRow,quicksearch:!0,change:x,enhanceTitle:x,error:x,receive:x,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e);const i=new te;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){console.error("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++oe.sequence,this.root=new ne(this,null,{key:"__root__"}),this._registerExtension(new G(this)),this._registerExtension(new re(this)),this._registerExtension(new Y(this)),this._registerExtension(new J(this)),this._registerExtension(new ee(this)),this._registerExtension(new X(this)),this.columns=t.columns,delete t.columns,!this.columns){let e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}this.types=t.types||{},delete t.types;for(let e of Object.values(this.types))e.classes&&(e.classes=N(e.classes));1===this.columns.length&&(t.navigationMode=P.row),t.navigationMode!==P.cell&&t.navigationMode!==P.startCell||(this.navMode=R.cellNav),this._updateViewportThrottled=M(this._updateViewport.bind(this),{}),this.element=f(t.element),o(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){o(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||null,text:""+t.textContent})}else if(n){const e="<span class='wb-col'></span>".repeat(this.columns.length);this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`}else this.element.innerHTML="";this.element.innerHTML+='\n <div class="wb-scroll-container">\n <div class="wb-node-list"></div>\n </div>',this.scrollContainer=this.element.querySelector("div.wb-scroll-container"),this.nodeListElement=this.scrollContainer.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.columns.length>1&&this.element.classList.add("wb-grid"),this._initExtensions(),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),setTimeout((()=>{this.updateViewport()}),50),this.scrollContainer.addEventListener("scroll",(e=>{this.setModified(A.vscroll)})),this.resizeObserver=new ResizeObserver((e=>{this.setModified(A.vscroll)})),this.resizeObserver.observe(this.element),_(this.nodeListElement,"click","div.wb-row",(e=>{const t=oe.getEventInfo(e),i=t.node;if(!1===this._callEvent("click",{event:e,node:i,info:t}))return this.lastClickTime=Date.now(),!1;if(i){const s=this.getOption("edit.trigger"),n=this.getOption("edit.slowClickDelay");s.indexOf("clickActive")>=0&&"title"===t.region&&i.isActive()&&(!n||Date.now()-this.lastClickTime<n)&&this._callMethod("edit.startEditTitle",i),t.colIdx>=0?i.setActive(!0,{colIdx:t.colIdx,event:e}):i.setActive(!0,{event:e}),t.region===D.expander?i.setExpanded(!i.isExpanded()):t.region===D.checkbox&&i.setSelected(!i.isSelected())}this.lastClickTime=Date.now()})),_(this.element,"keydown",(e=>{const t=oe.getEventInfo(e),i=v(e);this._callHook("onKeyEvent",{event:e,node:t.node,info:t,eventName:i})})),_(this.element,"focusin focusout",(e=>{const t="focusin"===e.type;this._callEvent("focus",{flag:t,event:e}),t||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof oe)return e;if(e instanceof ne)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(let t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return o(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}static getNode(e){if(!e)return null;if(e instanceof ne)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(let e of this.extensionList)e.init()}_registerNode(e){let t=e.key;o(null!=t&&!this.keyMap.has(t)),this.keyMap.set(t,e);let i=e.refKey;if(i){let t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,e.removeMarkup()}_callHook(e,t={}){let i,s=m({},{tree:this,options:this.options,result:void 0},t);for(let t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,m({type:e,tree:this,util:this._util},t))}_getNodeByRowIdx(e){let t=null;return this.visitRows((i=>{if(i._rowIdx===e)return t=i,!1})),t}getTopmostVpNode(e=!0){let t;return t=e?Math.ceil((this.scrollContainer.scrollTop-1)/L):Math.floor(this.scrollContainer.scrollTop/L),this._getNodeByRowIdx(t)}getLowestVpNode(e=!0){let t;return t=e?Math.floor((this.scrollContainer.scrollTop+this.scrollContainer.clientHeight)/L)-1:Math.ceil((this.scrollContainer.scrollTop+this.scrollContainer.clientHeight)/L)-1,t=Math.min(t,this.count(!0)-1),this._getNodeByRowIdx(t)}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof ne?s=t:(s=this.getActiveNode(),o(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:a(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.treeRowCount=0,this.activeNode=null,this.focusNode=null,this.setModified(A.structure)}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(-1===e.indexOf("."))return void(this.options[e]=t);const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}hasFocus(){return this.element.contains(document.activeElement)}runWithoutUpdate(e,t=null){try{this.enableUpdate(!1);const t=e();return o(!(t instanceof Promise)),t}finally{this.enableUpdate(!0)}}async expandAll(e=!0){const t=this.logTime("expandAll("+e+")");try{this.enableUpdate(!1),await this.root.expandAll(e)}finally{this.enableUpdate(!0),this.logTimeEnd(t)}}count(e=!1){return e?this.treeRowCount:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findNextNode(e,t){let i=null,s=this.getFirstChild(),n="string"==typeof e?function(e){e=c(e);const t=new RegExp("^"+e,"i");return function(e){return t.test(e.title)}}(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null;const n=Math.floor(this.scrollContainer.clientHeight/L);switch(t){case"parent":case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((function(e){if(e.isVisible())return s=e,!1}));break;case"last":this.visit((function(e){e.isVisible()&&(s=e)}));break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":const i=this.getLowestVpNode();s=e._rowIdx<i._rowIdx?i:this._getNextNodeInView(e,n);break;case"pageUp":if(0===e._rowIdx)s=e;else{const t=this.getTopmostVpNode();s=e._rowIdx>t._rowIdx?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){let t=e.target,i=t.classList,s=t.closest("span.wb-col"),n=oe.getNode(t),r=n?n.tree:oe.getTree(e),o={tree:r,node:n,region:D.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))o.region=D.title;else if(i.contains("wb-expander"))o.region=!1===n.hasChildren()?D.prefix:D.expander;else if(i.contains("wb-checkbox"))o.region=D.checkbox;else if(i.contains("wb-icon"))o.region=D.icon;else if(i.contains("wb-node"))o.region=D.title;else{if(!s)return"mousemove"===e.type||e instanceof KeyboardEvent||console.warn("getEventInfo(): not found",e,o),o;{o.region=D.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);o.colIdx=e}}return-1===o.colIdx&&(o.colIdx=0),o.colDef=null==r?void 0:r.columns[o.colIdx],null!=o.colDef&&(o.colId=o.colDef.id),o}toString(){return"Wunderbaum<'"+this.id+"'>"}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){var e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}scrollTo(e){const t=e.node||this.getActiveNode();o(null!=t._rowIdx);const i=this.scrollContainer.scrollTop,s=this.scrollContainer.clientHeight,n=t._rowIdx*L;let r;n>i?n+L<i+s||(r=n-s+L-1):n<i&&(r=n+1),null!=r&&(this.log("scrollTo("+n+"): "+i+" => "+r,s),this.scrollContainer.scrollTop=r,this.setModified(A.vscroll))}setColumn(e){var t;if(o(this.navMode!==R.row),o(0<=e&&e<this.columns.length),this.activeColIdx=e,this.headerElement)for(let t of this.headerElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}null===(t=this.activeNode)||void 0===t||t.setModified(A.status);for(let t of this.nodeListElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}}setFocus(e=!0){e?this.element.focus():this.element.blur()}setModified(e,t,i){if(this._disableUpdateCount)return;t instanceof ne||(i=t);const s=!!k(i,"immediate");switch(e){case A.any:case A.structure:case A.header:this.changeRedrawRequestPending=!0,this.updateViewport(s);break;case A.vscroll:this.updateViewport(s);break;case A.row:case A.data:case A.status:t._rowElem&&t.render({change:e});break;default:a(`Invalid change type ${e}`)}}setNavigationMode(e){var t;if(e===this.navMode)return;const i=this.navMode,s=e!==R.row;this.navMode=e,s&&i===R.row&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",s),this.element.classList.toggle("wb-cell-edit-mode",e===R.cellEdit),null===(t=this.activeNode)||void 0===t||t.setModified(A.status)}setStatus(e,t,i){return this.root.setStatus(e,t,i)}updateColumns(e){e=Object.assign({calculateCols:!0,updateRows:!0},e);const t=this.element.clientWidth;let i=0,s=0,n=!1;if(e.calculateCols){this._columnsById={};for(let e of this.columns){this._columnsById[e.id]=e;let t=e.width;if(t&&"*"!==t)if("number"==typeof t)e._weight=t,i+=t;else if("string"==typeof t&&t.endsWith("px")){e._weight=0;let i=parseFloat(t.slice(0,-2));e._widthPx!=i&&(n=!0,e._widthPx=i),s+=i}else a("Invalid column width: "+t);else e._weight=1,i+=1}const e=Math.max(0,t-s);let r=0;for(let t of this.columns){if(t._weight){const s=Math.max(4,e*t._weight/i);t._widthPx!=s&&(n=!0,t._widthPx=s)}t._ofsPx=r,r+=t._widthPx}}n&&(this._renderHeaderMarkup(),e.updateRows&&this._updateRows())}_renderHeaderMarkup(){if(!this.headerElement)return;const e=this.headerElement.querySelector(".wb-row");o(e),e.innerHTML="<span class='wb-col'></span>".repeat(this.columns.length);for(let t=0;t<this.columns.length;t++){const i=this.columns[t],s=e.children[t];s.style.left=i._ofsPx+"px",s.style.width=i._widthPx+"px";const n=d(i.title||i.id);s.innerHTML=`<span class="wb-col-title">${n}</span> <span class="wb-col-resizer"></span>`}}updateViewport(e=!1){e?this._updateViewport():this._updateViewportThrottled()}_updateViewport(){if(this._disableUpdateCount)return void this.log(`IGNORED _updateViewport() disable level: ${this._disableUpdateCount}`);const e=!this.changeRedrawRequestPending;this.changeRedrawRequestPending=!1;let t=this.scrollContainer.clientHeight;const i=this.options.headerHeightPx,s=this.element.clientHeight-i;Math.abs(t-s)>1&&(this.scrollContainer.style.height=s+"px",t=s),this.updateColumns({updateRows:!1}),this._updateRows({newNodesOnly:e}),this._callEvent("update")}_validateRows(){let e=this.nodeListElement.childNodes,t=0,i=-1,s=!0;return e.forEach((e=>{const n=e,r=Number.parseInt(n.style.top),o=n._wb_node;i>=0&&r!==i+L&&(o.logWarn(`TR order mismatch at index ${t}: top=${r}px != ${i+L}`),s=!1),i=r,t++})),s}_updateRows(e){const t=this.logTime("_updateRows"),i=!!(e=Object.assign({newNodesOnly:!1},e)).newNodesOnly,s=this.scrollContainer.clientHeight,n=this.scrollContainer.scrollTop;let r=Math.max(0,n/22-5);r=Math.floor(r),r%2&&r--;let o=Math.max(0,(n+s)/22+5);o=Math.ceil(o);const l=new Set;this.nodeListElement.childNodes.forEach((e=>{const t=e;l.add(t._wb_node)}));let a=0,d=0,c=!1,h="first";this.visitRows((function(e){const t=e._rowElem;e._rowIdx!==a&&(e._rowIdx=a,c=!0),a<r||a>o?t&&(h=t):t&&i?(l.delete(e),t.style.top=a*L+"px",h=t):(l.delete(e),t&&(t.style.top=a*L+"px"),e.render({top:d,after:h}),h=e._rowElem),a++,d+=22})),this.treeRowCount=a;for(const e of l)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=`${d}px`,this.logTimeEnd(t),this._validateRows(),c}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,l,a,d=0,c=!1===(t=t||{}).includeSelf,h=!!t.includeHidden,u=!h&&"hide"===this.filterMode,p=t.start||this.root.children[0];for(n=p.parent;n;){for(l=n.children,s=l.indexOf(p)+d,o(s>=0,"Could not find "+p+" in parent's children: "+n),i=s;i<l.length;i++){if(p=l[i],p===a)return!1;if(!u||p.statusNodeType||p.match||p.subMatchCount){if(!c&&!1===e(p))return!1;if(c=!1,p.children&&p.children.length&&(h||p.expanded)&&(r=p.visit((function(t){return t!==a&&(!u||t.match||t.subMatchCount?!1!==e(t)&&(h||!t.children||t.expanded?void 0:"skip"):"skip")}),!1),!1===r))return!1}}p=n,n=n.parent,d=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),o(t.start,"`wrap` option requires `start`"),a=t.start,t.wrap=!1,n=this.root,d=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=!!t.includeHidden,o=t.start||this.root.children[0];if(!1!==t.includeSelf&&!1===e(o))return!1;for(;;){if(n=o.parent,i=n.children,i[0]===o){if(o=n,!o.parent)break;i=n.children}else for(s=i.indexOf(o),o=i[s-1];(r||o.expanded)&&o.children&&o.children.length;)i=o.children,n=o,o=i[i.length-1];if((r||o.isVisible())&&!1===e(o))return!1}return!0}load(e,t={}){this.clear();return(t.columns||e.columns)&&(this.columns=t.columns,this.updateColumns({calculateCols:!1})),this.root.load(e)}enableUpdate(e){e?(o(this._disableUpdateCount>0,"enableUpdate(true) was called too often"),this._disableUpdateCount--,0===this._disableUpdateCount&&this.updateViewport()):this._disableUpdateCount++}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}oe.sequence=0,oe.version="v0.0.4",oe.util=T,e.Wunderbaum=oe,Object.defineProperty(e,"__esModule",{value:!0})}));
77
+ * Released under the MIT license.
78
+ * @version v0.0.7
79
+ * @date Sun, 11 Sep 2022 16:02:08 GMT
80
+ */class ae extends le{constructor(e){super(e,null,{key:"__root__",title:e.id})}toString(){return`WbSystemRoot@${this.key}<'${this.tree.id}'>`}}class de{constructor(e){this.enabled=!0,this.data={},this.extensionList=[],this.extensions={},this.keyMap=new Map,this.refKeyMap=new Map,this.treeRowCount=0,this._disableUpdateCount=0,this.activeNode=null,this.focusNode=null,this.types={},this.columns=[],this._columnsById={},this.changeRedrawRequestPending=!1,this.changeScrollRequestPending=!1,this._util=O,this.filterMode=null,this.activeColIdx=0,this._cellNavMode=!1,this.lastQuicksearchTime=0,this.lastQuicksearchTerm="",this.lastClickTime=0,this.log=this.logDebug;let t=this.options=y({id:null,source:null,element:null,debugLevel:4,header:null,rowHeightPx:G,columns:null,types:null,enabled:!0,fixedCol:!1,showSpinner:!1,checkbox:!1,minExpandLevel:0,updateThrottleWait:200,skeleton:!1,connectTopBreadcrumb:null,navigationModeOption:null,quicksearch:!0,change:k,enhanceTitle:k,error:k,receive:k,strings:{loadError:"Error",loading:"Loading...",noData:"No data"}},e);const i=new se;this.ready=i.promise();let s=!1;if(this.ready.then((()=>{s=!0;try{this._callEvent("init")}catch(e){console.error("Exception inside `init(e)` event:",e)}})).catch((e=>{if(s)throw e;this._callEvent("init",{error:e})})),this.id=t.id||"wb_"+ ++de.sequence,this.root=new ae(this),this._registerExtension(new W(this)),this._registerExtension(new oe(this)),this._registerExtension(new K(this)),this._registerExtension(new ee(this)),this._registerExtension(new ie(this)),this._registerExtension(new B(this)),this._updateViewportThrottled=I(this._updateViewportImmediately.bind(this),{}),this.columns=t.columns,delete t.columns,!this.columns||!this.columns.length){const e="string"==typeof t.header?t.header:this.id;this.columns=[{id:"*",title:e,width:"*"}]}t.types&&this.setTypes(t.types,!0),delete t.types,this.element=v(t.element),l(!!this.element,`Invalid 'element' option: ${t.element}`),this.element.classList.add("wunderbaum"),this.element.getAttribute("tabindex")||(this.element.tabIndex=0),this.element._wb_tree=this,this.headerElement=this.element.querySelector("div.wb-header");const n=null==t.header?this.columns.length>1:!!t.header;if(this.headerElement){l(!this.columns,"`opts.columns` must not be set if markup already contains a header"),this.columns=[];const e=this.headerElement.querySelector("div.wb-row");for(const t of e.querySelectorAll("div"))this.columns.push({id:t.dataset.id||`col_${this.columns.length}`,title:""+t.textContent,width:"*"})}else{const e="<span class='wb-col'></span>".repeat(this.columns.length);if(this.element.innerHTML=`\n <div class='wb-header'>\n <div class='wb-row'>\n ${e}\n </div>\n </div>`,!n){this.element.querySelector("div.wb-header").style.display="none"}}this.element.innerHTML+='\n <div class="wb-scroll-container">\n <div class="wb-node-list"></div>\n </div>',this.scrollContainerElement=this.element.querySelector("div.wb-scroll-container"),this.nodeListElement=this.scrollContainerElement.querySelector("div.wb-node-list"),this.headerElement=this.element.querySelector("div.wb-header"),this.element.classList.toggle("wb-grid",this.columns.length>1),this._initExtensions(),["enabled","fixedCol"].forEach((e=>{null!=t[e]&&this.setOption(e,t[e])})),t.source?(t.showSpinner&&(this.nodeListElement.innerHTML="<progress class='spinner'>loading...</progress>"),this.load(t.source).then((()=>{null==t.navigationModeOption?this.isGrid()?this.setNavigationOption(D.cell):this.setNavigationOption(D.row):this.setNavigationOption(t.navigationModeOption),i.resolve()})).catch((e=>{i.reject(e)})).finally((()=>{var e;null===(e=this.element.querySelector("progress.spinner"))||void 0===e||e.remove(),this.element.classList.remove("wb-initializing")}))):i.resolve(),this.setModified(S.any),this.element.addEventListener("scroll",(e=>{this.setModified(S.vscroll)})),this.resizeObserver=new ResizeObserver((e=>{this.setModified(S.vscroll)})),this.resizeObserver.observe(this.element),C(this.nodeListElement,"click","div.wb-row",(e=>{const t=de.getEventInfo(e),i=t.node;if(!1===this._callEvent("click",{event:e,node:i,info:t}))return this.lastClickTime=Date.now(),!1;if(i){const s=this.getOption("edit.trigger"),n=this.getOption("edit.slowClickDelay");s.indexOf("clickActive")>=0&&"title"===t.region&&i.isActive()&&(!n||Date.now()-this.lastClickTime<n)&&this._callMethod("edit.startEditTitle",i),t.colIdx>=0?i.setActive(!0,{colIdx:t.colIdx,event:e}):i.setActive(!0,{event:e}),t.region===A.expander?i.setExpanded(!i.isExpanded()):t.region===A.checkbox&&i.setSelected(!i.isSelected())}this.lastClickTime=Date.now()})),C(this.element,"keydown",(e=>{const t=de.getEventInfo(e),i=b(e),s=t.node||this.getFocusNode();this._callHook("onKeyEvent",{event:e,node:s,info:t,eventName:i})})),C(this.element,"focusin focusout",(e=>{const t="focusin"===e.type;this._callEvent("focus",{flag:t,event:e}),t||this._callMethod("edit._stopEditTitle",!0,{event:e,forceClose:!0})}))}static getTree(e){if(e instanceof de)return e;if(e instanceof le)return e.tree;if(void 0===e&&(e=0),"number"==typeof e)e=document.querySelectorAll(".wunderbaum")[e];else if("string"==typeof e){for(let t of document.querySelectorAll(".wunderbaum")){const i=t._wb_tree;if(i&&i.id===e)return i}if(!(e=document.querySelector(e)))return null}else e.target&&(e=e.target);return l(e instanceof Element),e.matches(".wunderbaum")||(e=e.closest(".wunderbaum")),e&&e._wb_tree?e._wb_tree:null}static getNode(e){if(!e)return null;if(e instanceof le)return e;for(void 0!==e.target&&(e=e.target);e;){if(e._wb_node)return e._wb_node;e=e.parentElement}return null}_registerExtension(e){this.extensionList.push(e),this.extensions[e.id]=e}_initExtensions(){for(let e of this.extensionList)e.init()}_registerNode(e){let t=e.key;l(null!=t&&!this.keyMap.has(t)),this.keyMap.set(t,e);let i=e.refKey;if(i){let t=this.refKeyMap.get(i);t?t.add(e):this.refKeyMap.set(i,new Set)}}_unregisterNode(e){const t=e.refKey;if(t){const i=this.refKeyMap.get(t);i&&i.delete(e)&&!i.size&&this.refKeyMap.delete(t)}e.tree=null,e.parent=null,e.removeMarkup()}_callHook(e,t={}){let i,s=y({},{tree:this,options:this.options,result:void 0},t);for(let t of this.extensionList){if(i=t[e].call(t,s),!1===i)break;void 0!==s.result&&(i=s.result)}return i}_callMethod(e,...t){const[i,s]=e.split("."),n=s?this.extensions[i]:this,r=n[s];if(r)return r.apply(n,t);this.logError(`Calling undefined method '${e}()'.`)}_callEvent(e,t){const[i,s]=e.split("."),n=this.options,r=s?n[i][s]:n[i];if(r)return r.call(this,y({type:e,tree:this,util:this._util},t))}_getNodeByRowIdx(e){let t=null;return this.visitRows((i=>{if(i._rowIdx===e)return t=i,!1})),t}getTopmostVpNode(e=!0){const t=this.element.scrollTop;let i;return i=e?Math.ceil((t-1)/G):Math.floor(t/G),this._getNodeByRowIdx(i)}getLowestVpNode(e=!0){const t=this.element,i=this.headerElement.clientHeight,s=t.scrollTop,n=t.clientHeight-i;let r;return r=e?Math.floor((s+n)/G)-1:Math.ceil((s+n)/G)-1,r=Math.min(r,this.count(!0)-1),this._getNodeByRowIdx(r)}_getPrevNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!0,start:e||this.getActiveNode()}),e}_getNextNodeInView(e,t=1){return this.visitRows((i=>{if(e=i,t--<=0)return!1}),{reverse:!1,start:e||this.getActiveNode()}),e}addChildren(e,t){return this.root.addChildren(e,t)}applyCommand(e,t,i){let s,n;switch(t instanceof le?s=t:(s=this.getActiveNode(),l(void 0===i),i=t),e){case"moveUp":n=s.getPrevSibling(),n&&(s.moveTo(n,"before"),s.setActive());break;case"moveDown":n=s.getNextSibling(),n&&(s.moveTo(n,"after"),s.setActive());break;case"indent":n=s.getPrevSibling(),n&&(s.moveTo(n,"appendChild"),n.setExpanded(),s.setActive());break;case"outdent":s.isTopLevel()||(s.moveTo(s.getParent(),"after"),s.setActive());break;case"remove":n=s.getPrevSibling()||s.getParent(),s.remove(),n&&n.setActive();break;case"addChild":this._callMethod("edit.createNode","prependChild");break;case"addSibling":this._callMethod("edit.createNode","after");break;case"rename":this._callMethod("edit.startEditTitle");break;case"down":case"first":case"last":case"left":case"pageDown":case"pageUp":case"parent":case"right":case"up":return s.navigate(e);default:a(`Unhandled command: '${e}'`)}}clear(){this.root.removeChildren(),this.root.children=null,this.keyMap.clear(),this.refKeyMap.clear(),this.treeRowCount=0,this.activeNode=null,this.focusNode=null,this.setModified(S.structure)}destroy(){this.logInfo("destroy()..."),this.clear(),this.resizeObserver.disconnect(),this.element.innerHTML="",this.element.outerHTML=this.element.outerHTML}getOption(e,t){let i,s=this.options;e.indexOf(".")>=0&&([i,e]=e.split("."),s=s[i]);let n=s[e];return"function"==typeof n&&(n=n({type:"resolve",tree:this})),null!=n?n:t}setOption(e,t){if(e.indexOf(".")>=0){const i=e.split(".");this.extensions[i[0]].setPluginOption(i[1],t)}else switch(this.options[e]=t,e){case"checkbox":this.setModified(S.any,{removeMarkup:!0});break;case"enabled":this.setEnabled(!!t);break;case"fixedCol":this.element.classList.toggle("wb-fixed-col",!!t)}}hasFocus(){return this.element.contains(document.activeElement)}hasHeader(){const e=this.options.header;return this.isGrid()?!1!==e:!!e}runWithoutUpdate(e,t=null){try{this.enableUpdate(!1);const t=e();return l(!(t instanceof Promise)),t}finally{this.enableUpdate(!0)}}async expandAll(e=!0){const t=this.logTime("expandAll("+e+")");try{this.enableUpdate(!1),await this.root.expandAll(e)}finally{this.enableUpdate(!0),this.logTimeEnd(t)}}selectAll(e=!0){try{this.enableUpdate(!1),this.visit((t=>{t.setSelected(e)}))}finally{this.enableUpdate(!0)}}count(e=!1){return e?this.treeRowCount:this.keyMap.size}_check(){let e=0;this.visit((t=>{e++})),this.keyMap.size!==e&&this.logWarn(`_check failed: ${this.keyMap.size} !== ${e}`)}findAll(e){return this.root.findAll(e)}findFirst(e){return this.root.findFirst(e)}findKey(e){return this.keyMap.get(e)}findNextNode(e,t){let i=null,s=this.getFirstChild(),n="string"==typeof e?function(e){e=c(e);const t=new RegExp("^"+e,"i");return function(e){return t.test(e.title)}}
81
+ /*!
82
+ * Wunderbaum - ext-dnd
83
+ * Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
84
+ * v0.0.7, Sun, 11 Sep 2022 16:02:08 GMT (https://github.com/mar10/wunderbaum)
85
+ */(e):e;function r(e){if(n(e)&&(i=e),i||e===t)return!1}return t=t||s,this.visitRows(r,{start:t,includeSelf:!1}),i||t===s||this.visitRows(r,{start:s,includeSelf:!0}),i}findRelatedNode(e,t,i=!1){let s=null;const n=Math.floor(this.scrollContainerElement.clientHeight/G);switch(t){case"parent":case"left":e.parent&&e.parent.parent&&(s=e.parent);break;case"first":this.visit((function(e){if(e.isVisible())return s=e,!1}));break;case"last":this.visit((function(e){e.isVisible()&&(s=e)}));break;case"right":e.children&&e.children.length&&(s=e.children[0]);break;case"up":s=this._getPrevNodeInView(e);break;case"down":s=this._getNextNodeInView(e);break;case"pageDown":const i=this.getLowestVpNode();s=e._rowIdx<i._rowIdx?i:this._getNextNodeInView(e,n);break;case"pageUp":if(0===e._rowIdx)s=e;else{const t=this.getTopmostVpNode();s=e._rowIdx>t._rowIdx?t:this._getPrevNodeInView(e,n)}break;default:this.logWarn("Unknown relation '"+t+"'.")}return s}getActiveColElem(){return this.activeNode&&this.activeColIdx>=0?this.activeNode.getColElem(this.activeColIdx):null}getActiveNode(){return this.activeNode}getFirstChild(){return this.root.getFirstChild()}getFocusNode(){return this.focusNode}static getEventInfo(e){let t=e.target,i=t.classList,s=t.closest("span.wb-col"),n=de.getNode(t),r=n?n.tree:de.getTree(e),l={tree:r,node:n,region:A.unknown,colDef:void 0,colIdx:-1,colId:void 0,colElem:s};if(i.contains("wb-title"))l.region=A.title;else if(i.contains("wb-expander"))l.region=!1===n.hasChildren()?A.prefix:A.expander;else if(i.contains("wb-checkbox"))l.region=A.checkbox;else if(i.contains("wb-icon"))l.region=A.icon;else if(i.contains("wb-node"))l.region=A.title;else if(s){l.region=A.column;const e=Array.prototype.indexOf.call(s.parentNode.children,s);l.colIdx=e}else{if(!i.contains("wb-row"))return"mousemove"===e.type||e instanceof KeyboardEvent||console.warn("getEventInfo(): not found",e,l),l;l.region=A.title}return-1===l.colIdx&&(l.colIdx=0),l.colDef=null==r?void 0:r.columns[l.colIdx],null!=l.colDef&&(l.colId=l.colDef.id),l}toString(){return`Wunderbaum<'${this.id}'>`}isEditing(){return this._callMethod("edit.isEditingTitle")}isLoading(){var e=!1;return this.root.visit((t=>{if(t._isLoading||t._requestId)return e=!0,!1}),!0),e}logDebug(...e){this.options.debugLevel>=4&&(Array.prototype.unshift.call(e,this.toString()),console.log.apply(console,e))}logError(...e){this.options.debugLevel>=1&&(Array.prototype.unshift.call(e,this.toString()),console.error.apply(console,e))}logInfo(...e){this.options.debugLevel>=3&&(Array.prototype.unshift.call(e,this.toString()),console.info.apply(console,e))}logTime(e){return this.options.debugLevel>=4&&console.time(this+": "+e),e}logTimeEnd(e){this.options.debugLevel>=4&&console.timeEnd(this+": "+e)}logWarn(...e){this.options.debugLevel>=2&&(Array.prototype.unshift.call(e,this.toString()),console.warn.apply(console,e))}scrollTo(e){let t,i;e instanceof le?t=e:(i=e,t=i.node),l(t&&null!=t._rowIdx);const s=this.element,n=this.headerElement.clientHeight,r=s.scrollTop,o=s.clientHeight,a=t._rowIdx*G+n,d=n,c=a-r,h=c+G,u=null==i?void 0:i.topNode;let p=null;c>=d?h<=o||(p=a+G-o+2):p=a-d-2,null!=p&&(this.log(`scrollTo(${a}): ${r} => ${p}`),s.scrollTop=p,u&&this.scrollTo(u))}scrollToHorz(){const e=this.columns[0]._widthPx,t=this.element.clientWidth,i=this.element.scrollLeft,s=this.getActiveColElem(),n=Number.parseInt(null==s?void 0:s.style.left,10),r=n+Number.parseInt(null==s?void 0:s.style.width,10);let l=i;n-i<e?l=n-e:r-i>t&&(l=r-t),this.element.scrollLeft=l}setColumn(e){var t;if(l(this.isCellNav()),l(0<=e&&e<this.columns.length),this.activeColIdx=e,this.hasHeader())for(let t of this.headerElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}null===(t=this.activeNode)||void 0===t||t.setModified(S.status);for(let t of this.nodeListElement.children){let i=0;for(let s of t.children)s.classList.toggle("wb-active",i++===e)}this.scrollToHorz()}setActiveNode(e,t=!0,i){var s;null===(s=this.findKey(e))||void 0===s||s.setActive(t,i)}setFocus(e=!0){e?this.element.focus():this.element.blur()}setModified(e,t,i){if(this._disableUpdateCount)return;t instanceof le||(i=t);const s=!!M(i,"immediate");!!M(i,"removeMarkup")&&this.visit((e=>{e.removeMarkup()}));let n=!1;switch(e){case S.any:case S.structure:case S.header:this.changeRedrawRequestPending=!0,n=!0;break;case S.vscroll:this.changeScrollRequestPending=!0,n=!0;break;case S.row:case S.data:case S.status:t._rowElem&&t.render({change:e});break;default:a(`Invalid change type ${e}`)}n&&(s?this._updateViewportImmediately():this._updateViewportThrottled())}setEnabled(e=!0){const t=this.enabled;return this.enabled=!!e,this.element.classList.toggle("wb-disabled",!e),t}isEnabled(){return this.enabled}isGrid(){return this.columns&&this.columns.length>1}isCellNav(){return!!this._cellNavMode}isRowNav(){return!this._cellNavMode}setCellNav(e=!0){var t;const i=this._cellNavMode;this._cellNavMode=!!e,e&&!i&&this.setColumn(0),this.element.classList.toggle("wb-cell-mode",e),null===(t=this.activeNode)||void 0===t||t.setModified(S.status)}setNavigationOption(e,t=!1){if(this.isGrid()||e===D.row)switch(this.options.navigationModeOption=e,e){case D.cell:this.setCellNav(!0);break;case D.row:this.setCellNav(!1);break;case D.startCell:t&&this.setCellNav(!0);break;case D.startRow:t&&this.setCellNav(!1);break;default:a(`Invalid mode '${e}'`)}else this.logWarn("Plain trees only support row navigation mode.")}setStatus(e,t){return this.root.setStatus(e,t)}setTypes(e,t=!0){l(_(e)),t?this.types=e:y(this.types,e);for(let e of Object.values(this.types))e.classes&&(e.classes=T(e.classes))}updateColumns(e){e=Object.assign({calculateCols:!0,updateRows:!0},e);const t=this.element.clientWidth,i=this.isGrid();let s=0,n=0,r=0,l=!1;if(this.element.classList.toggle("wb-grid",i),!i&&this.isCellNav()&&this.setCellNav(!1),e.calculateCols){this._columnsById={};for(let e of this.columns){this._columnsById[e.id]=e;let t=e.width;if(t&&"*"!==t)if("number"==typeof t)e._weight=t,n+=t;else if("string"==typeof t&&t.endsWith("px")){e._weight=0;let i=parseFloat(t.slice(0,-2));e._widthPx!=i&&(l=!0,e._widthPx=i),r+=i}else a(`Invalid column width: ${t}`);else e._weight=1,n+=1}const e=Math.max(0,t-r);let i=0;for(let t of this.columns){let s;if(t._weight){const i=t.minWidth;s="number"==typeof i?i:"string"==typeof i&&i.endsWith("px")?parseFloat(i.slice(0,-2)):4;const r=Math.max(s,e*t._weight/n);t._widthPx!=r&&(l=!0,t._widthPx=r)}t._ofsPx=i,i+=t._widthPx}s=i}const o=`${s}px`;this.headerElement.style.width=o,this.scrollContainerElement.style.width=o,l&&(this._renderHeaderMarkup(),e.updateRows&&this._updateRows())}_renderHeaderMarkup(){l(this.headerElement);const e=this.hasHeader();if(p(this.headerElement,e),!e)return;const t=this.columns.length,i=this.headerElement.querySelector(".wb-row");l(i),i.innerHTML="<span class='wb-col'></span>".repeat(t);for(let e=0;e<t;e++){const s=this.columns[e],n=i.children[e];n.style.left=s._ofsPx+"px",n.style.width=s._widthPx+"px";const r=d(s.title||s.id);let l="";s.tooltip&&(l=h(s.tooltip),l=` title="${l}"`);let o="";e<t-1&&(o='<span class="wb-col-resizer"></span>'),n.innerHTML=`<span class="wb-col-title"${l}>${r}</span>${o}`}}updatePendingModifications(){(this.changeRedrawRequestPending||this.changeScrollRequestPending)&&this._updateViewportImmediately()}_updateViewportImmediately(){var e;if(this._disableUpdateCount)return void this.log(`IGNORED _updateViewportImmediately() disable level: ${this._disableUpdateCount}`);const t=!this.changeRedrawRequestPending;this.changeRedrawRequestPending=!1,this.changeScrollRequestPending=!1;let i=this.scrollContainerElement.clientHeight;const s=this.headerElement.clientHeight,n=this.element.clientHeight-s;if(Math.abs(i-n)>1&&(this.scrollContainerElement.style.height=n+"px",i=n),this.updateColumns({updateRows:!1}),this._updateRows({newNodesOnly:t}),this.options.connectTopBreadcrumb){let t=null===(e=this.getTopmostVpNode(!0))||void 0===e?void 0:e.getPath(!1,"title"," > ");t=t?t+" >":"",this.options.connectTopBreadcrumb.textContent=t}this._callEvent("update")}_updateRows(e){const t=!!(e=Object.assign({newNodesOnly:!1},e)).newNodesOnly,i=this.element.clientHeight,s=this.element.scrollTop;let n=Math.max(0,s/22-5);n=Math.floor(n),n%2&&n--;let r=Math.max(0,(s+i)/22+5);r=Math.ceil(r);const l=new Set;this.nodeListElement.childNodes.forEach((e=>{const t=e;l.add(t._wb_node)}));let o=0,a=0,d=!1,c="first";this.visitRows((function(e){const i=e._rowElem;e._rowIdx!==o&&(e._rowIdx=o,d=!0),o<n||o>r?i&&(c=i):i&&t?(l.delete(e),i.style.top=o*G+"px",c=i):(l.delete(e),i&&(i.style.top=o*G+"px"),e.render({top:a,after:c}),c=e._rowElem),o++,a+=22})),this.treeRowCount=o;for(const e of l)e._callEvent("discard"),e.removeMarkup();return this.nodeListElement.style.height=`${a}px`,d}visit(e){return this.root.visit(e,!1)}visitRows(e,t){if(!this.root.hasChildren())return!1;if(t&&t.reverse)return delete t.reverse,this._visitRowsUp(e,t);let i,s,n,r,o,a,d=0,c=!1===(t=t||{}).includeSelf,h=!!t.includeHidden,u=!h&&"hide"===this.filterMode,p=t.start||this.root.children[0];for(n=p.parent;n;){for(o=n.children,s=o.indexOf(p)+d,l(s>=0,"Could not find "+p+" in parent's children: "+n),i=s;i<o.length;i++){if(p=o[i],p===a)return!1;if(!u||p.statusNodeType||p.match||p.subMatchCount){if(!c&&!1===e(p))return!1;if(c=!1,p.children&&p.children.length&&(h||p.expanded)&&(r=p.visit((function(t){return t!==a&&(!u||t.match||t.subMatchCount?!1!==e(t)&&(h||!t.children||t.expanded?void 0:"skip"):"skip")}),!1),!1===r))return!1}}p=n,n=n.parent,d=1,!n&&t.wrap&&(this.logDebug("visitRows(): wrap around"),l(t.start,"`wrap` option requires `start`"),a=t.start,t.wrap=!1,n=this.root,d=0)}return!0}_visitRowsUp(e,t){let i,s,n,r=!!t.includeHidden,l=t.start||this.root.children[0];if(!1!==t.includeSelf&&!1===e(l))return!1;for(;;){if(n=l.parent,i=n.children,i[0]===l){if(l=n,!l.parent)break;i=n.children}else for(s=i.indexOf(l),l=i[s-1];(r||l.expanded)&&l.children&&l.children.length;)i=l.children,n=l,l=i[i.length-1];if((r||l.isVisible())&&!1===e(l))return!1}return!0}load(e){return this.clear(),this.root.load(e)}enableUpdate(e){e?(l(this._disableUpdateCount>0,"enableUpdate(true) was called too often"),this._disableUpdateCount--,0===this._disableUpdateCount&&this.setModified(S.any,{immediate:!0})):this._disableUpdateCount++}clearFilter(){return this.extensions.filter.clearFilter()}isFilterActive(){return!!this.filterMode}updateFilter(){return this.extensions.filter.updateFilter()}}de.sequence=0,de.version="v0.0.7",de.util=O,e.Wunderbaum=de,Object.defineProperty(e,"__esModule",{value:!0})}));
80
86
  //# sourceMappingURL=wunderbaum.umd.min.js.map