@livenetworks/ashlar 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/ln-accordion/ln-accordion.js +1 -1
- package/js/ln-api-connector/ln-api-connector.js +1 -1
- package/js/ln-autoresize/ln-autoresize.js +1 -1
- package/js/ln-autosave/ln-autosave.js +1 -1
- package/js/ln-circular-progress/ln-circular-progress.js +1 -1
- package/js/ln-confirm/ln-confirm.js +1 -1
- package/js/ln-core/helpers.js +45 -0
- package/js/ln-core/index.js +1 -1
- package/js/ln-couchdb-connector/ln-couchdb-connector.js +1 -1
- package/js/ln-data-coordinator/ln-data-coordinator.js +1 -1
- package/js/ln-data-store/ln-data-store.js +1 -1
- package/js/ln-data-table/ln-data-table.js +1 -1
- package/js/ln-date/README.md +11 -1
- package/js/ln-date/ln-date.js +1 -1
- package/js/ln-date/src/ln-date.js +104 -1
- package/js/ln-dropdown/ln-dropdown.js +1 -1
- package/js/ln-filter/ln-filter.js +1 -1
- package/js/ln-form/ln-form.js +1 -1
- package/js/ln-modal/ln-modal.js +1 -1
- package/js/ln-number/ln-number.js +1 -1
- package/js/ln-number/src/ln-number.js +50 -2
- package/js/ln-popover/ln-popover.js +1 -1
- package/js/ln-search/ln-search.js +1 -1
- package/js/ln-sortable/ln-sortable.js +1 -1
- package/js/ln-table/ln-table.js +1 -1
- package/js/ln-tabs/ln-tabs.js +1 -1
- package/js/ln-time/ln-time.js +1 -1
- package/js/ln-toggle/ln-toggle.js +1 -1
- package/js/ln-tooltip/ln-tooltip.js +1 -1
- package/js/ln-translations/ln-translations.js +1 -1
- package/js/ln-validate/ln-validate.js +1 -1
- package/package.json +55 -55
- package/scss/components/_date.scss +21 -0
- package/scss/config/mixins/_form.scss +101 -54
- package/scss/config/mixins/_layout.scss +7 -9
- package/scss/config/mixins/_toast.scss +4 -0
- package/scss/ln-ashlar.scss +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function
|
|
1
|
+
(function(){"use strict";function O(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n||{}}))}function x(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){x(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function h(e,t,n,i){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",d=Array.from(e.querySelectorAll(u));e.matches&&e.matches(u)&&d.push(e);for(const r of d)r[n]||(r[n]=new i(r))}function C(e,t,n,i,a={}){const u=a.extraAttributes||[],d=a.onAttributeChange||null,r=a.onInit||null;function g(y){const f=y||document.body;h(f,e,t,n),r&&r(f)}return x(function(){const y=new MutationObserver(function(p){for(let l=0;l<p.length;l++){const o=p[l];if(o.type==="childList"){for(let c=0;c<o.addedNodes.length;c++){const s=o.addedNodes[c];s.nodeType===1&&(h(s,e,t,n),r&&r(s))}for(let c=0;c<o.removedNodes.length;c++){const s=o.removedNodes[c];if(s.nodeType===1){const v=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",m=Array.from(s.querySelectorAll(v));s.matches&&s.matches(v)&&m.push(s);for(let b=0;b<m.length;b++){const w=m[b][t];w&&typeof w.destroy=="function"&&w.destroy()}}}}else o.type==="attributes"&&(d&&o.target[t]?d(o.target,o.attributeName):(h(o.target,e,t,n),r&&r(o.target)))}});let f=[];if(e.indexOf("[")!==-1){const p=/\[([\w-]+)/g;let l;for(;(l=p.exec(e))!==null;)f.push(l[1])}else f.push(e);y.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:f.concat(u)})},i),window[t]=g,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){g(document.body)}):g(document.body),g}const A={};function E(e,t){A[e]=t}function M(e){return A[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=E,window.lnCore.getDataMapper=M),(function(){const e="data-ln-accordion",t="lnAccordion";if(window[t]!==void 0)return;function n(i){return this.dom=i,this._onToggleOpen=function(a){if(a.detail.target.closest("[data-ln-accordion]")!==i)return;const u=i.querySelectorAll("[data-ln-toggle]");for(const d of u)d!==a.detail.target&&d.closest("[data-ln-accordion]")===i&&d.getAttribute("data-ln-toggle")==="open"&&d.setAttribute("data-ln-toggle","close");O(i,"ln-accordion:change",{target:a.detail.target})},i.addEventListener("ln-toggle:open",this._onToggleOpen),this}n.prototype.destroy=function(){this.dom[t]&&(this.dom.removeEventListener("ln-toggle:open",this._onToggleOpen),O(this.dom,"ln-accordion:destroyed",{target:this.dom}),delete this.dom[t])},C(e,t,n,"ln-accordion")})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function c(i,o,d){i.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:d||{}}))}function
|
|
1
|
+
(function(){"use strict";function c(i,o,d){i.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:d||{}}))}function L(i,o){if(!document.body){document.addEventListener("DOMContentLoaded",function(){L(i,o)}),console.warn("["+o+'] Script loaded before <body> — add "defer" to your <script> tag');return}i()}function g(i,o,d,u){if(i.nodeType!==1)return;const m=o.indexOf("[")!==-1||o.indexOf(".")!==-1||o.indexOf("#")!==-1?o:"["+o+"]",e=Array.from(i.querySelectorAll(m));i.matches&&i.matches(m)&&e.push(i);for(const n of e)n[d]||(n[d]=new u(n))}function O(i,o,d,u,f={}){const m=f.extraAttributes||[],e=f.onAttributeChange||null,n=f.onInit||null;function t(r){const a=r||document.body;g(a,i,o,d),n&&n(a)}return L(function(){const r=new MutationObserver(function(s){for(let b=0;b<s.length;b++){const l=s[b];if(l.type==="childList"){for(let p=0;p<l.addedNodes.length;p++){const h=l.addedNodes[p];h.nodeType===1&&(g(h,i,o,d),n&&n(h))}for(let p=0;p<l.removedNodes.length;p++){const h=l.removedNodes[p];if(h.nodeType===1){const C=i.indexOf("[")!==-1||i.indexOf(".")!==-1||i.indexOf("#")!==-1?i:"["+i+"]",E=Array.from(h.querySelectorAll(C));h.matches&&h.matches(C)&&E.push(h);for(let v=0;v<E.length;v++){const T=E[v][o];T&&typeof T.destroy=="function"&&T.destroy()}}}}else l.type==="attributes"&&(e&&l.target[o]?e(l.target,l.attributeName):(g(l.target,i,o,d),n&&n(l.target)))}});let a=[];if(i.indexOf("[")!==-1){const s=/\[([\w-]+)/g;let b;for(;(b=s.exec(i))!==null;)a.push(b[1])}else a.push(i);r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:a.concat(m)})},u),window[o]=t,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){t(document.body)}):t(document.body),t}function y(...i){return i.filter(o=>o!=null&&o!=="").map((o,d)=>d===0?o.replace(/\/+$/,""):o.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function w(i,o){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},i,null)}function x(i,o="ln-core"){try{return i?JSON.parse(i):{}}catch(d){return console.error(`[${o}] Invalid headers JSON:`,d),{}}}const _={};function A(i,o){_[i]=o}function D(i){return _[i]||{ingress:o=>o,egress:o=>o}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=A,window.lnCore.getDataMapper=D),(function(){const i="data-ln-api-connector",o="lnApiConnector",d="lnConnector";if(window[o]!==void 0)return;function u(e){return this.dom=e,e[o]=this,e[d]=this,this.refreshConfig(),this._handlers=null,f(this),this}u.prototype.refreshConfig=function(){const e=this.dom;this.baseUrl=e.getAttribute("data-ln-api-base-url")||"",this.path=e.getAttribute("data-ln-api-path")||"",this.credentials="same-origin";const n=e.getAttribute("data-ln-api-headers")||"";this.headers=x(n,"ln-api-connector"),(n.toLowerCase().includes("authorization")||n.toLowerCase().includes("bearer")||n.toLowerCase().includes("basic"))&&console.warn("[ln-api-connector] Security Warning: Sensitive authorization credentials detected in data-ln-api-headers attribute. Storing secrets in HTML DOM attributes is highly discouraged and vulnerable to XSS credential extraction. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),c(e,"ln-api-connector:config-changed",{baseUrl:this.baseUrl,path:this.path,headers:this.headers})},u.prototype.fetchDelta=function(e){const n=this;let t=y(n.baseUrl,n.path);return e!=null&&e!==""&&(t+=(t.indexOf("?")!==-1?"&":"?")+"since="+encodeURIComponent(e)),window.fetch(t,{method:"GET",headers:w(n.headers),credentials:n.credentials}).then(r=>{if(!r.ok)throw new Error("HTTP "+r.status+": "+r.statusText);return r.json()})},u.prototype.create=function(e){const n=this;return window.fetch(y(n.baseUrl,n.path),{method:"POST",headers:w(n.headers),credentials:n.credentials,body:JSON.stringify(e)}).then(t=>{if(!t.ok)throw new Error("HTTP "+t.status+": "+t.statusText);return t.json()})},u.prototype.update=function(e,n){const t=this;return window.fetch(y(t.baseUrl,t.path,e),{method:"PUT",headers:w(t.headers),credentials:t.credentials,body:JSON.stringify(n)}).then(r=>{if(r.ok)return r.json();if(r.status===409)return r.json().then(a=>{const s=new Error("Conflict");throw s.status=409,s.data=a,s});throw new Error("HTTP "+r.status+": "+r.statusText)})},u.prototype.delete=function(e){const n=this;return window.fetch(y(n.baseUrl,n.path,e),{method:"DELETE",headers:w(n.headers),credentials:n.credentials}).then(t=>{if(!t.ok)throw new Error("HTTP "+t.status+": "+t.statusText);return t.json()})},u.prototype.bulkDelete=function(e){const n=this;return window.fetch(y(n.baseUrl,n.path)+"/bulk-delete",{method:"DELETE",headers:w(n.headers),credentials:n.credentials,body:JSON.stringify({ids:e})}).then(t=>{if(!t.ok)throw new Error("HTTP "+t.status+": "+t.statusText);return t.json()})};function f(e){e._handlers={sync:function(t){const r=t.detail||{};e.fetchDelta(r.since).then(function(a){c(e.dom,"ln-api-connector:fetched",{data:a,since:r.since})}).catch(function(a){c(e.dom,"ln-api-connector:error",{action:"sync",error:a.message,status:a.status||0,since:r.since})})},create:function(t){const r=t.detail||{};e.create(r.data).then(function(a){c(e.dom,"ln-api-connector:created",{record:a,tempId:r.tempId})}).catch(function(a){c(e.dom,"ln-api-connector:error",{action:"create",error:a.message,status:a.status||0,tempId:r.tempId})})},update:function(t){const r=t.detail||{},a=Object.assign({},r.data);r.expected_version!==void 0&&(a.expected_version=r.expected_version),e.update(r.id,a).then(function(s){c(e.dom,"ln-api-connector:updated",{record:s,id:r.id})}).catch(function(s){c(e.dom,"ln-api-connector:error",{action:"update",error:s.message,status:s.status||0,id:r.id,conflictData:s.status===409?s.data:null})})},delete:function(t){const r=t.detail||{};e.delete(r.id).then(function(a){c(e.dom,"ln-api-connector:deleted",{response:a,id:r.id})}).catch(function(a){c(e.dom,"ln-api-connector:error",{action:"delete",error:a.message,status:a.status||0,id:r.id})})},bulkDelete:function(t){const r=t.detail||{};e.bulkDelete(r.ids).then(function(a){c(e.dom,"ln-api-connector:bulk-deleted",{response:a,ids:r.ids})}).catch(function(a){c(e.dom,"ln-api-connector:error",{action:"bulk-delete",error:a.message,status:a.status||0,ids:r.ids})})}},["ln-api-connector","ln-rest-connector"].forEach(function(t){e.dom.addEventListener(t+":request-sync",e._handlers.sync),e.dom.addEventListener(t+":request-fetch",e._handlers.sync),e.dom.addEventListener(t+":request-create",e._handlers.create),e.dom.addEventListener(t+":request-update",e._handlers.update),e.dom.addEventListener(t+":request-delete",e._handlers.delete),e.dom.addEventListener(t+":request-bulk-delete",e._handlers.bulkDelete)})}u.prototype.destroy=function(){if(!this.dom[o])return;const e=this;e._handlers&&(["ln-api-connector","ln-rest-connector"].forEach(function(t){e.dom.removeEventListener(t+":request-sync",e._handlers.sync),e.dom.removeEventListener(t+":request-fetch",e._handlers.sync),e.dom.removeEventListener(t+":request-create",e._handlers.create),e.dom.removeEventListener(t+":request-update",e._handlers.update),e.dom.removeEventListener(t+":request-delete",e._handlers.delete),e.dom.removeEventListener(t+":request-bulk-delete",e._handlers.bulkDelete)}),e._handlers=null),c(this.dom,"ln-api-connector:destroyed",{target:this.dom}),delete this.dom[o],delete this.dom[d]};function m(e){const n=e[o];n&&n.refreshConfig()}O(i,o,u,"ln-api-connector",{extraAttributes:["data-ln-api-base-url","data-ln-api-path","data-ln-api-headers"],onAttributeChange:m})})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function
|
|
1
|
+
(function(){"use strict";function x(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){x(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function m(e,t,o,s){if(e.nodeType!==1)return;const l=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c=Array.from(e.querySelectorAll(l));e.matches&&e.matches(l)&&c.push(e);for(const i of c)i[o]||(i[o]=new s(i))}function O(e,t,o,s,u={}){const l=u.extraAttributes||[],c=u.onAttributeChange||null,i=u.onInit||null;function h(y){const a=y||document.body;m(a,e,t,o),i&&i(a)}return x(function(){const y=new MutationObserver(function(p){for(let f=0;f<p.length;f++){const n=p[f];if(n.type==="childList"){for(let d=0;d<n.addedNodes.length;d++){const r=n.addedNodes[d];r.nodeType===1&&(m(r,e,t,o),i&&i(r))}for(let d=0;d<n.removedNodes.length;d++){const r=n.removedNodes[d];if(r.nodeType===1){const C=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",g=Array.from(r.querySelectorAll(C));r.matches&&r.matches(C)&&g.push(r);for(let w=0;w<g.length;w++){const b=g[w][t];b&&typeof b.destroy=="function"&&b.destroy()}}}}else n.type==="attributes"&&(c&&n.target[t]?c(n.target,n.attributeName):(m(n.target,e,t,o),i&&i(n.target)))}});let a=[];if(e.indexOf("[")!==-1){const p=/\[([\w-]+)/g;let f;for(;(f=p.exec(e))!==null;)a.push(f[1])}else a.push(e);y.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:a.concat(l)})},s),window[t]=h,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){h(document.body)}):h(document.body),h}const A={};function v(e,t){A[e]=t}function E(e){return A[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=v,window.lnCore.getDataMapper=E),(function(){const e="data-ln-autoresize",t="lnAutoresize";if(window[t]!==void 0)return;function o(s){if(s.tagName!=="TEXTAREA")return console.warn("[ln-autoresize] Can only be applied to <textarea>, got:",s.tagName),this;this.dom=s;const u=this;return this._onInput=function(){u._resize()},s.addEventListener("input",this._onInput),this._resize(),this}o.prototype._resize=function(){this.dom.style.height="auto",this.dom.style.height=this.dom.scrollHeight+"px"},o.prototype.destroy=function(){this.dom[t]&&(this.dom.removeEventListener("input",this._onInput),this.dom.style.height="",delete this.dom[t])},O(e,t,o,"ln-autoresize")})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function E(
|
|
1
|
+
(function(){"use strict";function E(n,e,u){n.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:u||{}}))}function O(n,e,u){const s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:u||{}});return n.dispatchEvent(s),s}function L(n,e){if(!document.body){document.addEventListener("DOMContentLoaded",function(){L(n,e)}),console.warn("["+e+'] Script loaded before <body> — add "defer" to your <script> tag');return}n()}function C(n,e,u,s){if(n.nodeType!==1)return;const o=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",f=Array.from(n.querySelectorAll(o));n.matches&&n.matches(o)&&f.push(n);for(const d of f)d[u]||(d[u]=new s(d))}function S(n){const e={},u=n.elements;for(let s=0;s<u.length;s++){const i=u[s];if(!(!i.name||i.disabled||i.type==="file"||i.type==="submit"||i.type==="button"))if(i.type==="checkbox")e[i.name]||(e[i.name]=[]),i.checked&&e[i.name].push(i.value);else if(i.type==="radio")i.checked&&(e[i.name]=i.value);else if(i.type==="select-multiple"){e[i.name]=[];for(let o=0;o<i.options.length;o++)i.options[o].selected&&e[i.name].push(i.options[o].value)}else e[i.name]=i.value}return e}function T(n,e){const u=n.elements,s=[];for(let i=0;i<u.length;i++){const o=u[i];if(!o.name||!(o.name in e)||o.type==="file"||o.type==="submit"||o.type==="button")continue;const f=e[o.name];if(o.type==="checkbox")o.checked=Array.isArray(f)?f.indexOf(o.value)!==-1:!!f,s.push(o);else if(o.type==="radio")o.checked=o.value===String(f),s.push(o);else if(o.type==="select-multiple"){if(Array.isArray(f))for(let d=0;d<o.options.length;d++)o.options[d].selected=f.indexOf(o.options[d].value)!==-1;s.push(o)}else o.value=f,s.push(o)}return s}function x(n,e,u,s,i={}){const o=i.extraAttributes||[],f=i.onAttributeChange||null,d=i.onInit||null;function m(y){const t=y||document.body;C(t,n,e,u),d&&d(t)}return L(function(){const y=new MutationObserver(function(a){for(let c=0;c<a.length;c++){const h=a[c];if(h.type==="childList"){for(let v=0;v<h.addedNodes.length;v++){const p=h.addedNodes[v];p.nodeType===1&&(C(p,n,e,u),d&&d(p))}for(let v=0;v<h.removedNodes.length;v++){const p=h.removedNodes[v];if(p.nodeType===1){const l=n.indexOf("[")!==-1||n.indexOf(".")!==-1||n.indexOf("#")!==-1?n:"["+n+"]",r=Array.from(p.querySelectorAll(l));p.matches&&p.matches(l)&&r.push(p);for(let _=0;_<r.length;_++){const g=r[_][e];g&&typeof g.destroy=="function"&&g.destroy()}}}}else h.type==="attributes"&&(f&&h.target[e]?f(h.target,h.attributeName):(C(h.target,n,e,u),d&&d(h.target)))}});let t=[];if(n.indexOf("[")!==-1){const a=/\[([\w-]+)/g;let c;for(;(c=a.exec(n))!==null;)t.push(c[1])}else t.push(n);y.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:t.concat(o)})},s),window[e]=m,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){m(document.body)}):m(document.body),m}const A={};function D(n,e){A[n]=e}function k(n){return A[n]||{ingress:e=>e,egress:e=>e}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=D,window.lnCore.getDataMapper=k),(function(){const n="data-ln-autosave",e="lnAutosave",u="data-ln-autosave-clear",s="data-ln-autosave-debounce-input",i="ln-autosave:";if(window[e]!==void 0)return;function f(t){const a=d(t);if(!a){console.warn("ln-autosave: form needs an id or data-ln-autosave value",t);return}this.dom=t,this.key=a;let c=null;function h(){const l=S(t);try{localStorage.setItem(a,JSON.stringify(l))}catch{return}E(t,"ln-autosave:saved",{target:t,data:l})}function v(){let l;try{l=localStorage.getItem(a)}catch{return}if(!l)return;let r;try{r=JSON.parse(l)}catch{return}if(O(t,"ln-autosave:before-restore",{target:t,data:r}).defaultPrevented)return;const g=T(t,r);for(let b=0;b<g.length;b++)g[b].dispatchEvent(new Event("input",{bubbles:!0})),g[b].dispatchEvent(new Event("change",{bubbles:!0}));E(t,"ln-autosave:restored",{target:t,data:r})}function p(){try{localStorage.removeItem(a)}catch{return}E(t,"ln-autosave:cleared",{target:t})}this._onFocusout=function(l){const r=l.target;m(r)&&r.name&&h()},this._onChange=function(l){const r=l.target;m(r)&&r.name&&h()},this._onSubmit=function(){p()},this._onReset=function(){p()},this._onClearClick=function(l){l.target.closest("["+u+"]")&&p()},t.addEventListener("focusout",this._onFocusout),t.addEventListener("change",this._onChange),t.addEventListener("submit",this._onSubmit),t.addEventListener("reset",this._onReset),t.addEventListener("click",this._onClearClick);const w=y(t);return w>0&&(this._onInput=function(l){const r=l.target;!m(r)||!r.name||(c!==null&&clearTimeout(c),c=setTimeout(h,w))},t.addEventListener("input",this._onInput)),this._getInputTimer=function(){return c},v(),this}f.prototype.destroy=function(){if(this.dom[e]){if(this.dom.removeEventListener("focusout",this._onFocusout),this.dom.removeEventListener("change",this._onChange),this.dom.removeEventListener("submit",this._onSubmit),this.dom.removeEventListener("reset",this._onReset),this.dom.removeEventListener("click",this._onClearClick),this._onInput){this.dom.removeEventListener("input",this._onInput);const t=this._getInputTimer();t!==null&&clearTimeout(t)}E(this.dom,"ln-autosave:destroyed",{target:this.dom}),delete this.dom[e]}};function d(t){const c=t.getAttribute(n)||t.id;return c?i+window.location.pathname+":"+c:null}function m(t){const a=t.tagName;return a==="INPUT"||a==="TEXTAREA"||a==="SELECT"}function y(t){if(!t.hasAttribute(s))return 0;const a=t.getAttribute(s);if(a===""||a===null)return 1e3;const c=parseInt(a,10);return isNaN(c)||c<0?(console.warn("ln-autosave: invalid debounce value, using default",t),1e3):c}x(n,e,f,"ln-autosave")})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function
|
|
1
|
+
(function(){"use strict";function E(t,e,c){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:c||{}}))}function y(t,e){if(!document.body){document.addEventListener("DOMContentLoaded",function(){y(t,e)}),console.warn("["+e+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function m(t,e,c,a){if(t.nodeType!==1)return;const d=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",h=Array.from(t.querySelectorAll(d));t.matches&&t.matches(d)&&h.push(t);for(const n of h)n[c]||(n[c]=new a(n))}function _(t,e,c,a,f={}){const d=f.extraAttributes||[],h=f.onAttributeChange||null,n=f.onInit||null;function g(p){const u=p||document.body;m(u,t,e,c),n&&n(u)}return y(function(){const p=new MutationObserver(function(o){for(let s=0;s<o.length;s++){const r=o[s];if(r.type==="childList"){for(let i=0;i<r.addedNodes.length;i++){const l=r.addedNodes[i];l.nodeType===1&&(m(l,t,e,c),n&&n(l))}for(let i=0;i<r.removedNodes.length;i++){const l=r.removedNodes[i];if(l.nodeType===1){const x=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",b=Array.from(l.querySelectorAll(x));l.matches&&l.matches(x)&&b.push(l);for(let v=0;v<b.length;v++){const C=b[v][e];C&&typeof C.destroy=="function"&&C.destroy()}}}}else r.type==="attributes"&&(h&&r.target[e]?h(r.target,r.attributeName):(m(r.target,t,e,c),n&&n(r.target)))}});let u=[];if(t.indexOf("[")!==-1){const o=/\[([\w-]+)/g;let s;for(;(s=o.exec(t))!==null;)u.push(s[1])}else u.push(t);p.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:u.concat(d)})},a),window[e]=g,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){g(document.body)}):g(document.body),g}const w={};function A(t,e){w[t]=e}function O(t){return w[t]||{ingress:e=>e,egress:e=>e}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=A,window.lnCore.getDataMapper=O),(function(){const t="data-ln-circular-progress",e="lnCircularProgress";if(window[e]!==void 0)return;const c="http://www.w3.org/2000/svg",a=36,f=16,d=2*Math.PI*f;function h(o){return this.dom=o,this.svg=null,this.trackCircle=null,this.progressCircle=null,this.labelEl=null,this._attrObserver=null,g.call(this),u.call(this),p.call(this),o.setAttribute("data-ln-circular-progress-initialized",""),this}h.prototype.destroy=function(){this.dom[e]&&(this._attrObserver&&this._attrObserver.disconnect(),this.svg&&this.svg.remove(),this.labelEl&&this.labelEl.remove(),this.dom.removeAttribute("data-ln-circular-progress-initialized"),delete this.dom[e])};function n(o,s){const r=document.createElementNS(c,o);for(const i in s)r.setAttribute(i,s[i]);return r}function g(){this.svg=n("svg",{viewBox:"0 0 "+a+" "+a,"aria-hidden":"true"}),this.trackCircle=n("circle",{cx:a/2,cy:a/2,r:f,fill:"none","stroke-width":"3"}),this.trackCircle.classList.add("ln-circular-progress__track"),this.progressCircle=n("circle",{cx:a/2,cy:a/2,r:f,fill:"none","stroke-width":"3","stroke-linecap":"round","stroke-dasharray":d,"stroke-dashoffset":d,transform:"rotate(-90 "+a/2+" "+a/2+")"}),this.progressCircle.classList.add("ln-circular-progress__fill"),this.svg.appendChild(this.trackCircle),this.svg.appendChild(this.progressCircle),this.labelEl=document.createElement("strong"),this.labelEl.classList.add("ln-circular-progress__label"),this.dom.appendChild(this.svg),this.dom.appendChild(this.labelEl)}function p(){const o=this,s=new MutationObserver(function(r){for(const i of r)(i.attributeName==="data-ln-circular-progress"||i.attributeName==="data-ln-circular-progress-max")&&u.call(o)});s.observe(this.dom,{attributes:!0,attributeFilter:["data-ln-circular-progress","data-ln-circular-progress-max"]}),this._attrObserver=s}function u(){const o=parseFloat(this.dom.getAttribute("data-ln-circular-progress"))||0,s=parseFloat(this.dom.getAttribute("data-ln-circular-progress-max"))||100;let r=s>0?o/s*100:0;r<0&&(r=0),r>100&&(r=100);const i=d-r/100*d;this.progressCircle.setAttribute("stroke-dashoffset",i);const l=this.dom.getAttribute("data-ln-circular-progress-label");this.labelEl.textContent=l!==null?l:Math.round(r)+"%",E(this.dom,"ln-circular-progress:change",{target:this.dom,value:o,max:s,percentage:r})}_(t,e,h,"ln-circular-progress")})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function
|
|
1
|
+
(function(){"use strict";function C(t,e,a){t.dispatchEvent(new CustomEvent(e,{bubbles:!0,detail:a||{}}))}function A(t,e){if(!document.body){document.addEventListener("DOMContentLoaded",function(){A(t,e)}),console.warn("["+e+'] Script loaded before <body> — add "defer" to your <script> tag');return}t()}function g(t,e,a,c){if(t.nodeType!==1)return;const i=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]",n=Array.from(t.querySelectorAll(i));t.matches&&t.matches(i)&&n.push(t);for(const o of n)o[a]||(o[a]=new c(o))}function _(t,e,a,c,r={}){const i=r.extraAttributes||[],n=r.onAttributeChange||null,o=r.onInit||null;function h(p){const u=p||document.body;g(u,t,e,a),o&&o(u)}return A(function(){const p=new MutationObserver(function(m){for(let f=0;f<m.length;f++){const s=m[f];if(s.type==="childList"){for(let l=0;l<s.addedNodes.length;l++){const d=s.addedNodes[l];d.nodeType===1&&(g(d,t,e,a),o&&o(d))}for(let l=0;l<s.removedNodes.length;l++){const d=s.removedNodes[l];if(d.nodeType===1){const x=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",b=Array.from(d.querySelectorAll(x));d.matches&&d.matches(x)&&b.push(d);for(let T=0;T<b.length;T++){const y=b[T][e];y&&typeof y.destroy=="function"&&y.destroy()}}}}else s.type==="attributes"&&(n&&s.target[e]?n(s.target,s.attributeName):(g(s.target,t,e,a),o&&o(s.target)))}});let u=[];if(t.indexOf("[")!==-1){const m=/\[([\w-]+)/g;let f;for(;(f=m.exec(t))!==null;)u.push(f[1])}else u.push(t);p.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:u.concat(i)})},c),window[e]=h,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){h(document.body)}):h(document.body),h}const v={};function w(t,e){v[t]=e}function L(t){return v[t]||{ingress:e=>e,egress:e=>e}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=w,window.lnCore.getDataMapper=L),(function(){const t="data-ln-confirm",e="lnConfirm",a="data-ln-confirm-timeout";if(window[e]!==void 0)return;function r(i){this.dom=i,this.confirming=!1,this.originalText=i.textContent.trim(),this.confirmText=i.getAttribute(t)||"Confirm?",this.revertTimer=null,this._submitted=!1;const n=this;return this._onClick=function(o){if(!n.confirming)o.preventDefault(),o.stopImmediatePropagation(),n._enterConfirm();else{if(n._submitted)return;n._submitted=!0,n._reset()}},i.addEventListener("click",this._onClick),this}r.prototype._getTimeout=function(){const i=parseFloat(this.dom.getAttribute(a));return isNaN(i)||i<=0?3:i},r.prototype._enterConfirm=function(){this.confirming=!0,this.dom.setAttribute("data-confirming","true");var i=this.dom.querySelector("svg.ln-icon use");i&&this.originalText===""?(this.isIconButton=!0,this.originalIconHref=i.getAttribute("href"),i.setAttribute("href","#ln-check"),this.dom.classList.add("ln-confirm-tooltip"),this.dom.setAttribute("data-tooltip-text",this.confirmText),this.originalAriaLabel=this.dom.getAttribute("aria-label"),this.dom.setAttribute("aria-label",this.confirmText),this.alertNode=document.createElement("span"),this.alertNode.className="sr-only",this.alertNode.setAttribute("role","alert"),this.alertNode.textContent=this.confirmText,this.dom.appendChild(this.alertNode)):this.dom.textContent=this.confirmText,this._startTimer(),C(this.dom,"ln-confirm:waiting",{target:this.dom})},r.prototype._startTimer=function(){this.revertTimer&&clearTimeout(this.revertTimer);const i=this,n=this._getTimeout()*1e3;this.revertTimer=setTimeout(function(){i._reset()},n)},r.prototype._reset=function(){if(this._submitted=!1,this.confirming=!1,this.dom.removeAttribute("data-confirming"),this.isIconButton){var i=this.dom.querySelector("svg.ln-icon use");i&&this.originalIconHref&&i.setAttribute("href",this.originalIconHref),this.dom.classList.remove("ln-confirm-tooltip"),this.dom.removeAttribute("data-tooltip-text"),this.originalAriaLabel!==null&&this.originalAriaLabel!==void 0?this.dom.setAttribute("aria-label",this.originalAriaLabel):this.dom.removeAttribute("aria-label"),this.originalAriaLabel=null,this.alertNode&&this.alertNode.parentNode===this.dom&&this.dom.removeChild(this.alertNode),this.alertNode=null,this.isIconButton=!1,this.originalIconHref=null}else this.dom.textContent=this.originalText;this.revertTimer&&(clearTimeout(this.revertTimer),this.revertTimer=null)},r.prototype.destroy=function(){this.dom[e]&&(this._reset(),this.dom.removeEventListener("click",this._onClick),delete this.dom[e])},_(t,e,r,"ln-confirm")})()})();
|
package/js/ln-core/helpers.js
CHANGED
|
@@ -288,6 +288,34 @@ export function getLocale(el) {
|
|
|
288
288
|
return (langEl ? langEl.lang : null) || navigator.language;
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
// ─── Value Property Interception ───────────────────────────
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Intercept the programmatic `value` getter/setter on an input element.
|
|
295
|
+
* Useful for custom components that need to sync/format programmatic changes.
|
|
296
|
+
* @param {HTMLInputElement} dom - The visible input element.
|
|
297
|
+
* @param {Object} descriptor - The original property descriptor of HTMLInputElement.prototype.value.
|
|
298
|
+
* @param {Object} callbacks - Getter and setter callbacks.
|
|
299
|
+
*/
|
|
300
|
+
export function interceptValueProperty(dom, descriptor, { get, set }) {
|
|
301
|
+
Object.defineProperty(dom, 'value', {
|
|
302
|
+
get: function () {
|
|
303
|
+
if (get) {
|
|
304
|
+
return get.call(this);
|
|
305
|
+
}
|
|
306
|
+
return descriptor.get.call(this);
|
|
307
|
+
},
|
|
308
|
+
set: function (val) {
|
|
309
|
+
if (set) {
|
|
310
|
+
set.call(this, val, (originalVal) => descriptor.set.call(this, originalVal));
|
|
311
|
+
} else {
|
|
312
|
+
descriptor.set.call(this, val);
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
configurable: true
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
291
319
|
// ─── Component Registration ───────────────────────────────
|
|
292
320
|
|
|
293
321
|
export function registerComponent(selector, attribute, ComponentFn, componentTag, options = {}) {
|
|
@@ -313,6 +341,23 @@ export function registerComponent(selector, attribute, ComponentFn, componentTag
|
|
|
313
341
|
if (onInit) onInit(node);
|
|
314
342
|
}
|
|
315
343
|
}
|
|
344
|
+
for (let j = 0; j < mutation.removedNodes.length; j++) {
|
|
345
|
+
const node = mutation.removedNodes[j];
|
|
346
|
+
if (node.nodeType === 1) {
|
|
347
|
+
const isComplex = selector.indexOf('[') !== -1 || selector.indexOf('.') !== -1 || selector.indexOf('#') !== -1;
|
|
348
|
+
const query = isComplex ? selector : '[' + selector + ']';
|
|
349
|
+
const items = Array.from(node.querySelectorAll(query));
|
|
350
|
+
if (node.matches && node.matches(query)) {
|
|
351
|
+
items.push(node);
|
|
352
|
+
}
|
|
353
|
+
for (let k = 0; k < items.length; k++) {
|
|
354
|
+
const inst = items[k][attribute];
|
|
355
|
+
if (inst && typeof inst.destroy === 'function') {
|
|
356
|
+
inst.destroy();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
316
361
|
} else if (mutation.type === 'attributes') {
|
|
317
362
|
if (onAttributeChange && mutation.target[attribute]) {
|
|
318
363
|
onAttributeChange(mutation.target, mutation.attributeName);
|
package/js/ln-core/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { cloneTemplate, cloneTemplateScoped, dispatch, dispatchCancelable, fill, fillTemplate, renderList, buildDict, guardBody, findElements, isVisible, serializeForm, populateForm, getLocale, registerComponent, buildUrl, getHeaders, parseHeaders, registerDataMapper, getDataMapper } from './helpers.js';
|
|
1
|
+
export { cloneTemplate, cloneTemplateScoped, dispatch, dispatchCancelable, fill, fillTemplate, renderList, buildDict, guardBody, findElements, isVisible, serializeForm, populateForm, getLocale, registerComponent, buildUrl, getHeaders, parseHeaders, registerDataMapper, getDataMapper, interceptValueProperty } from './helpers.js';
|
|
2
2
|
export { reactiveState, deepReactive, createBatcher } from './reactive.js';
|
|
3
3
|
export { persistGet, persistSet, persistRemove, persistClear } from './persist.js';
|
|
4
4
|
export { computePlacement, teleportToBody, measureHidden } from './positioning.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function
|
|
1
|
+
(function(){"use strict";function h(c,d,l){c.dispatchEvent(new CustomEvent(d,{bubbles:!0,detail:l||{}}))}function C(c,d){if(!document.body){document.addEventListener("DOMContentLoaded",function(){C(c,d)}),console.warn("["+d+'] Script loaded before <body> — add "defer" to your <script> tag');return}c()}function _(c,d,l,f){if(c.nodeType!==1)return;const v=d.indexOf("[")!==-1||d.indexOf(".")!==-1||d.indexOf("#")!==-1?d:"["+d+"]",e=Array.from(c.querySelectorAll(v));c.matches&&c.matches(v)&&e.push(c);for(const o of e)o[l]||(o[l]=new f(o))}function j(c,d,l,f,g={}){const v=g.extraAttributes||[],e=g.onAttributeChange||null,o=g.onInit||null;function t(r){const n=r||document.body;_(n,c,d,l),o&&o(n)}return C(function(){const r=new MutationObserver(function(i){for(let s=0;s<i.length;s++){const a=i[s];if(a.type==="childList"){for(let m=0;m<a.addedNodes.length;m++){const u=a.addedNodes[m];u.nodeType===1&&(_(u,c,d,l),o&&o(u))}for(let m=0;m<a.removedNodes.length;m++){const u=a.removedNodes[m];if(u.nodeType===1){const w=c.indexOf("[")!==-1||c.indexOf(".")!==-1||c.indexOf("#")!==-1?c:"["+c+"]",E=Array.from(u.querySelectorAll(w));u.matches&&u.matches(w)&&E.push(u);for(let T=0;T<E.length;T++){const O=E[T][d];O&&typeof O.destroy=="function"&&O.destroy()}}}}else a.type==="attributes"&&(e&&a.target[d]?e(a.target,a.attributeName):(_(a.target,c,d,l),o&&o(a.target)))}});let n=[];if(c.indexOf("[")!==-1){const i=/\[([\w-]+)/g;let s;for(;(s=i.exec(c))!==null;)n.push(s[1])}else n.push(c);r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:n.concat(v)})},f),window[d]=t,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){t(document.body)}):t(document.body),t}function b(...c){return c.filter(d=>d!=null&&d!=="").map((d,l)=>l===0?d.replace(/\/+$/,""):d.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function p(c,d){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},c,d?{Authorization:d}:null)}function x(c,d="ln-core"){try{return c?JSON.parse(c):{}}catch(l){return console.error(`[${d}] Invalid headers JSON:`,l),{}}}const k={};function S(c,d){k[c]=d}function L(c){return k[c]||{ingress:d=>d,egress:d=>d}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=S,window.lnCore.getDataMapper=L),(function(){const c="data-ln-couchdb-connector",d="lnCouchDbConnector",l="lnConnector";if(window[d]!==void 0)return;function f(e){return this.dom=e,e[d]=this,e[l]=this,this.refreshConfig(),this._handlers=null,g(this),this}f.prototype.refreshConfig=function(){const e=this.dom;this.url=e.getAttribute("data-ln-couchdb-url")||"",this.db=e.getAttribute("data-ln-couchdb-db")||"",this.auth=e.getAttribute("data-ln-couchdb-auth")||"",this.credentials="same-origin";const o=e.getAttribute("data-ln-couchdb-headers")||"";this.headers=x(o,"ln-couchdb-connector"),this.auth&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-auth attribute. Storing basic authentication credentials in HTML DOM attributes is highly discouraged and vulnerable to XSS credential extraction. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),o.toLowerCase().includes("authorization")&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-headers attribute. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),h(e,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})},f.prototype.fetchDelta=function(e){const o=this,t=["include_docs=true","feed=normal"];e&&t.push("since="+encodeURIComponent(e));const r=b(o.url,o.db,"_changes")+"?"+t.join("&");return window.fetch(r,{method:"GET",headers:p(o.headers,o.auth),credentials:o.credentials}).then(n=>{if(!n.ok)throw new Error("HTTP "+n.status+": "+n.statusText);return n.json()}).then(n=>{const i=n.results||[];return{data:i.filter(s=>!s.deleted&&s.doc).map(s=>Object.assign({},s.doc,{id:s.doc._id})),deleted:i.filter(s=>s.deleted).map(s=>s.id),synced_at:n.last_seq||e||""}})},f.prototype.create=function(e){const o=this,t=Object.assign({_id:e.id},e);return t._id||delete t._id,window.fetch(b(o.url,o.db),{method:"POST",headers:p(o.headers,o.auth),credentials:o.credentials,body:JSON.stringify(t)}).then(r=>{if(!r.ok)throw new Error("HTTP "+r.status+": "+r.statusText);return r.json()}).then(r=>Object.assign({},t,{id:r.id,_id:r.id,_rev:r.rev}))},f.prototype.update=function(e,o){const t=this,r=Object.assign({id:String(e),_id:String(e)},o),n=r._rev||r.rev;return(n?Promise.resolve(n):window.fetch(b(t.url,t.db,null,e),{method:"GET",headers:p(t.headers,t.auth),credentials:t.credentials}).then(s=>{if(!s.ok)throw new Error("Could not retrieve document for revision mapping");return s.json().then(a=>a._rev)})).then(s=>{const a=Object.assign({},r,{_rev:s});delete a.rev;const m=Object.assign(p(t.headers,t.auth),{"If-Match":s});return window.fetch(b(t.url,t.db,null,e),{method:"PUT",headers:m,credentials:t.credentials,body:JSON.stringify(a)}).then(u=>{if(u.ok)return u.json().then(y=>Object.assign({},a,{_rev:y.rev}));if(u.status===409)return u.json().then(y=>{const w=new Error("Conflict");throw w.status=409,w.data=y,w});throw new Error("HTTP "+u.status+": "+u.statusText)})})},f.prototype.delete=function(e,o){const t=this;return(o?Promise.resolve(o):window.fetch(b(t.url,t.db,null,e),{method:"GET",headers:p(t.headers,t.auth),credentials:t.credentials}).then(n=>{if(!n.ok)throw new Error("Could not retrieve document for revision delete");return n.json().then(i=>i._rev)})).then(n=>{const i=b(t.url,t.db,null,e)+"?rev="+encodeURIComponent(n);return window.fetch(i,{method:"DELETE",headers:p(t.headers,t.auth),credentials:t.credentials}).then(s=>{if(!s.ok)throw new Error("HTTP "+s.status+": "+s.statusText);return s.json()})})},f.prototype.bulkDelete=function(e){const o=this;return!e||e.length===0?Promise.resolve({ok:!0,deletedCount:0}):window.fetch(b(o.url,o.db,"_all_docs"),{method:"POST",headers:p(o.headers,o.auth),credentials:o.credentials,body:JSON.stringify({keys:e})}).then(t=>{if(!t.ok)throw new Error("HTTP "+t.status+": "+t.statusText);return t.json()}).then(t=>{const n=(t.rows||[]).filter(i=>!i.error&&i.value&&i.value.rev).map(i=>({_id:i.id,_rev:i.value.rev,_deleted:!0}));return n.length===0?{ok:!0,deletedCount:0}:window.fetch(b(o.url,o.db,"_bulk_docs"),{method:"POST",headers:p(o.headers,o.auth),credentials:o.credentials,body:JSON.stringify({docs:n})}).then(i=>{if(!i.ok)throw new Error("HTTP "+i.status+": "+i.statusText);return i.json()}).then(i=>({ok:!0,results:i,deletedCount:n.length}))})};function g(e){e._handlers={sync:function(t){const r=t.detail||{};e.fetchDelta(r.since).then(function(n){h(e.dom,"ln-couchdb-connector:fetched",{data:n,since:r.since})}).catch(function(n){h(e.dom,"ln-couchdb-connector:error",{action:"sync",error:n.message,status:n.status||0,since:r.since})})},create:function(t){const r=t.detail||{};e.create(r.data).then(function(n){h(e.dom,"ln-couchdb-connector:created",{record:n,tempId:r.tempId})}).catch(function(n){h(e.dom,"ln-couchdb-connector:error",{action:"create",error:n.message,status:n.status||0,tempId:r.tempId})})},update:function(t){const r=t.detail||{},n=Object.assign({},r.data);r.expected_version!==void 0&&(n._rev=r.expected_version),e.update(r.id,n).then(function(i){h(e.dom,"ln-couchdb-connector:updated",{record:i,id:r.id})}).catch(function(i){h(e.dom,"ln-couchdb-connector:error",{action:"update",error:i.message,status:i.status||0,id:r.id,conflictData:i.status===409?i.data:null})})},delete:function(t){const r=t.detail||{};e.delete(r.id,r.rev).then(function(n){h(e.dom,"ln-couchdb-connector:deleted",{response:n,id:r.id})}).catch(function(n){h(e.dom,"ln-couchdb-connector:error",{action:"delete",error:n.message,status:n.status||0,id:r.id})})},bulkDelete:function(t){const r=t.detail||{};e.bulkDelete(r.ids).then(function(n){h(e.dom,"ln-couchdb-connector:bulk-deleted",{response:n,ids:r.ids})}).catch(function(n){h(e.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:n.message,status:n.status||0,ids:r.ids})})}},["ln-couchdb-connector","ln-api-connector","ln-rest-connector"].forEach(function(t){e.dom.addEventListener(t+":request-sync",e._handlers.sync),e.dom.addEventListener(t+":request-fetch",e._handlers.sync),e.dom.addEventListener(t+":request-create",e._handlers.create),e.dom.addEventListener(t+":request-update",e._handlers.update),e.dom.addEventListener(t+":request-delete",e._handlers.delete),e.dom.addEventListener(t+":request-bulk-delete",e._handlers.bulkDelete)})}f.prototype.destroy=function(){if(!this.dom[d])return;const e=this;e._handlers&&(["ln-couchdb-connector","ln-api-connector","ln-rest-connector"].forEach(function(t){e.dom.removeEventListener(t+":request-sync",e._handlers.sync),e.dom.removeEventListener(t+":request-fetch",e._handlers.sync),e.dom.removeEventListener(t+":request-create",e._handlers.create),e.dom.removeEventListener(t+":request-update",e._handlers.update),e.dom.removeEventListener(t+":request-delete",e._handlers.delete),e.dom.removeEventListener(t+":request-bulk-delete",e._handlers.bulkDelete)}),e._handlers=null),h(this.dom,"ln-couchdb-connector:destroyed",{target:this.dom}),delete this.dom[d],delete this.dom[l]};function v(e){const o=e[d];o&&o.refreshConfig()}j(c,d,f,"ln-couchdb-connector",{extraAttributes:["data-ln-couchdb-url","data-ln-couchdb-db","data-ln-couchdb-auth","data-ln-couchdb-headers"],onAttributeChange:v})})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function
|
|
1
|
+
(function(){"use strict";function C(a,i){if(!document.body){document.addEventListener("DOMContentLoaded",function(){C(a,i)}),console.warn("["+i+'] Script loaded before <body> — add "defer" to your <script> tag');return}a()}function y(a,i,u,p){if(a.nodeType!==1)return;const h=i.indexOf("[")!==-1||i.indexOf(".")!==-1||i.indexOf("#")!==-1?i:"["+i+"]",e=Array.from(a.querySelectorAll(h));a.matches&&a.matches(h)&&e.push(a);for(const n of e)n[u]||(n[u]=new p(n))}function A(a,i,u,p,m={}){const h=m.extraAttributes||[],e=m.onAttributeChange||null,n=m.onInit||null;function t(d){const r=d||document.body;y(r,a,i,u),n&&n(r)}return C(function(){const d=new MutationObserver(function(o){for(let c=0;c<o.length;c++){const s=o[c];if(s.type==="childList"){for(let f=0;f<s.addedNodes.length;f++){const l=s.addedNodes[f];l.nodeType===1&&(y(l,a,i,u),n&&n(l))}for(let f=0;f<s.removedNodes.length;f++){const l=s.removedNodes[f];if(l.nodeType===1){const _=a.indexOf("[")!==-1||a.indexOf(".")!==-1||a.indexOf("#")!==-1?a:"["+a+"]",g=Array.from(l.querySelectorAll(_));l.matches&&l.matches(_)&&g.push(l);for(let b=0;b<g.length;b++){const v=g[b][i];v&&typeof v.destroy=="function"&&v.destroy()}}}}else s.type==="attributes"&&(e&&s.target[i]?e(s.target,s.attributeName):(y(s.target,a,i,u),n&&n(s.target)))}});let r=[];if(a.indexOf("[")!==-1){const o=/\[([\w-]+)/g;let c;for(;(c=o.exec(a))!==null;)r.push(c[1])}else r.push(a);d.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:r.concat(h)})},p),window[i]=t,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){t(document.body)}):t(document.body),t}const M={};function D(a,i){M[a]=i}function E(a){return M[a]||{ingress:i=>i,egress:i=>i}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=D,window.lnCore.getDataMapper=E),(function(){const a="data-ln-data-coordinator",i="lnDataCoordinator",u="lnCoordinator";if(window[i]!==void 0)return;function p(e){return this.dom=e,this._name=e.getAttribute(a),e[i]=this,e[u]=this,this.mapper=null,this._handlers=null,this.refreshMapper(),m(this),this}p.prototype.refreshMapper=function(){this.mapper=null,this.dom.querySelector("script[data-ln-mapper]")&&console.error("[ln-data-coordinator] Security Error: Inline script mappers using <script data-ln-mapper> are deprecated and disabled due to XSS vulnerability risks (unsafe-eval). Please register your mappers securely via window.lnCore.registerDataMapper() instead.");const n=this.dom.getAttribute("data-ln-data-mapper")||this.dom.getAttribute("data-ln-data-coordinator");n&&window.lnCore&&typeof window.lnCore.getDataMapper=="function"&&(this.mapper=window.lnCore.getDataMapper(n)),this.mapper||(this.mapper={}),typeof this.mapper.ingress!="function"&&(this.mapper.ingress=function(t){return t}),typeof this.mapper.egress!="function"&&(this.mapper.egress=function(t){return t})},p.prototype.findChildren=function(){const e=this.dom.querySelector("[data-ln-data-store]"),n=this.dom.querySelector("[data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector], [data-ln-rest-connector]");return{storeEl:e,connectorEl:n,store:e?e.lnDataStore||e.lnStore:null,connector:n?n.lnConnector||n.lnApiConnector||n.lnCouchDbConnector:null}};function m(e){e._handlers={sync:function(n){e.refreshMapper();const t=e.findChildren();if(!t.store||!t.connector){console.warn("[ln-data-coordinator] Cannot sync: store or connector not found in subtree");return}const d=n.detail.since;t.connector.fetchDelta(d).then(function(r){let o=[],c=[],s=null;r&&Array.isArray(r)?(o=r,s=Math.floor(Date.now()/1e3)):r&&(o=Array.isArray(r.data)?r.data:[],c=Array.isArray(r.deleted)?r.deleted:[],s=r.synced_at!==void 0?r.synced_at:r.since!==void 0?r.since:null);const f=o.map(l=>e.mapper.ingress(l));t.store.applySync(f,c,s)}).catch(function(r){console.error("[ln-data-coordinator] Sync failed:",r)})},create:function(n){e.refreshMapper();const t=e.findChildren();if(!t.store||!t.connector)return;const d=n.detail.tempId,r=n.detail.data||{},o=e.mapper.egress(r);t.connector.create(o).then(function(c){const s=e.mapper.ingress(c);t.store.confirmMutation(d,s,"create")}).catch(function(c){console.error("[ln-data-coordinator] Create mutation failed:",c),t.store.revertMutation(d,"create",c.message||c)})},update:function(n){e.refreshMapper();const t=e.findChildren();if(!t.store||!t.connector)return;const d=n.detail.id,r=n.detail.expected_version;t.store.getById(d).then(function(o){if(!o)throw new Error("Record not found in cache store: "+d);const c=Object.assign({},o);delete c._pending;const s=e.mapper.egress(c);return t.connector.update(d,s,r)}).then(function(o){const c=e.mapper.ingress(o);t.store.confirmMutation(d,c,"update")}).catch(function(o){if(console.error("[ln-data-coordinator] Update mutation failed:",o),o.status===409){const c=o.data&&o.data.remote?e.mapper.ingress(o.data.remote):null,s=o.data?o.data.field_diffs:null;t.store.resolveConflict(d,c,s)}else t.store.revertMutation(d,"update",o.message||o)})},delete:function(n){e.refreshMapper();const t=e.findChildren();if(!t.store||!t.connector)return;const d=n.detail.id;t.connector.delete(d).then(function(){t.store.confirmMutation(d,null,"delete")}).catch(function(r){console.error("[ln-data-coordinator] Delete mutation failed:",r),t.store.revertMutation(d,"delete",r.message||r)})},bulkDelete:function(n){e.refreshMapper();const t=e.findChildren();if(!t.store||!t.connector)return;const d=n.detail.ids||[],r=d.join(",");t.connector.bulkDelete(d).then(function(){t.store.confirmMutation(r,null,"bulk-delete")}).catch(function(o){console.error("[ln-data-coordinator] Bulk delete mutation failed:",o),t.store.revertMutation(r,"bulk-delete",o.message||o)})}},e.dom.addEventListener("ln-store:request-remote-sync",e._handlers.sync),e.dom.addEventListener("ln-store:request-remote-create",e._handlers.create),e.dom.addEventListener("ln-store:request-remote-update",e._handlers.update),e.dom.addEventListener("ln-store:request-remote-delete",e._handlers.delete),e.dom.addEventListener("ln-store:request-remote-bulk-delete",e._handlers.bulkDelete)}p.prototype.destroy=function(){if(!this.dom[i])return;const e=this;e._handlers&&(e.dom.removeEventListener("ln-store:request-remote-sync",e._handlers.sync),e.dom.removeEventListener("ln-store:request-remote-create",e._handlers.create),e.dom.removeEventListener("ln-store:request-remote-update",e._handlers.update),e.dom.removeEventListener("ln-store:request-remote-delete",e._handlers.delete),e.dom.removeEventListener("ln-store:request-remote-bulk-delete",e._handlers.bulkDelete),e._handlers=null),delete this.dom[i],delete this.dom[u]};function h(e,n){const t=e[i];t&&n==="data-ln-data-mapper"&&t.refreshMapper()}A(a,i,p,"ln-data-coordinator",{extraAttributes:["data-ln-data-mapper"],onAttributeChange:h})})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function l(a,i,d){a.dispatchEvent(new CustomEvent(i,{bubbles:!0,detail:d||{}}))}function H(a,i){if(!document.body){document.addEventListener("DOMContentLoaded",function(){H(a,i)}),console.warn("["+i+'] Script loaded before <body> — add "defer" to your <script> tag');return}a()}function K(a,i,d,h){if(a.nodeType!==1)return;const _=i.indexOf("[")!==-1||i.indexOf(".")!==-1||i.indexOf("#")!==-1?i:"["+i+"]",m=Array.from(a.querySelectorAll(_));a.matches&&a.matches(_)&&m.push(a);for(const u of m)u[d]||(u[d]=new h(u))}function ee(a,i,d,h,p={}){const _=p.extraAttributes||[],m=p.onAttributeChange||null,u=p.onInit||null;function g(L){const A=L||document.body;K(A,a,i,d),u&&u(A)}return H(function(){const L=new MutationObserver(function(k){for(let w=0;w<k.length;w++){const y=k[w];if(y.type==="childList")for(let B=0;B<y.addedNodes.length;B++){const R=y.addedNodes[B];R.nodeType===1&&(K(R,a,i,d),u&&u(R))}else y.type==="attributes"&&(m&&y.target[i]?m(y.target,y.attributeName):(K(y.target,a,i,d),u&&u(y.target)))}});let A=[];if(a.indexOf("[")!==-1){const k=/\[([\w-]+)/g;let w;for(;(w=k.exec(a))!==null;)A.push(w[1])}else A.push(a);L.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:A.concat(_)})},h),window[i]=g,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){g(document.body)}):g(document.body),g}const V={};function te(a,i){V[a]=i}function ne(a){return V[a]||{ingress:i=>i,egress:i=>i}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=te,window.lnCore.getDataMapper=ne);let x=null;async function G(a){if(!a){x=null;return}try{const i=new TextEncoder,d=await crypto.subtle.digest("SHA-256",i.encode(a));x=await crypto.subtle.importKey("raw",d,{name:"AES-GCM"},!1,["encrypt","decrypt"])}catch(i){console.error("[ln-core/crypto] Key derivation failed:",i),x=null}}function j(){return x}async function re(a,i=x){const d=i||x;if(!d||a===void 0||a===null)return a;try{const h=new TextEncoder,p=crypto.getRandomValues(new Uint8Array(12)),_=typeof a=="string"?a:JSON.stringify(a),m=await crypto.subtle.encrypt({name:"AES-GCM",iv:p},d,h.encode(_)),u=btoa(String.fromCharCode(...p)),g=btoa(String.fromCharCode(...new Uint8Array(m)));return{encrypted:!0,iv:u,data:g}}catch(h){return console.error("[ln-core/crypto] Encryption failed:",h),a}}async function oe(a,i=x){const d=i||x;if(!a||!a.encrypted||!d)return a;try{const h=new TextDecoder,p=Uint8Array.from(atob(a.iv),g=>g.charCodeAt(0)),_=Uint8Array.from(atob(a.data),g=>g.charCodeAt(0)),m=await crypto.subtle.decrypt({name:"AES-GCM",iv:p},d,_),u=h.decode(m);try{return JSON.parse(u)}catch{return u}}catch(h){return console.error("[ln-core/crypto] Decryption failed. Key may be incorrect:",h),{...a,decryptionError:!0}}}(function(){const a="data-ln-data-store",i="lnDataStore";if(window[i]!==void 0)return;const d="ln_app_cache",h="_meta",p="1.0";let _=null,m=null;const u={};function g(){try{return crypto.randomUUID()}catch{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=Math.random()*16|0;return(t==="x"?r:r&3|8).toString(16)})}}function L(e){e&&e.name==="QuotaExceededError"&&l(document,"ln-store:quota-exceeded",{error:e})}function A(){const e={};for(const t of document.querySelectorAll(`[${a}]`)){const r=t.getAttribute(a);if(r){const n=t.getAttribute("data-ln-data-store-indexes")||t.getAttribute("data-ln-store-indexes")||"";e[r]={indexes:n.split(",").map(o=>o.trim()).filter(Boolean)}}}return e}function k(){return m||(m=new Promise(e=>{if(typeof indexedDB>"u")return console.warn("[ln-data-store] IndexedDB not available — falling back to in-memory store"),e(null);const t=A(),r=Object.keys(t),n=indexedDB.open(d);n.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed — falling back to in-memory store"),e(null)},n.onsuccess=o=>{const s=o.target.result,c=Array.from(s.objectStoreNames);if(!(!c.includes(h)||r.some(q=>!c.includes(q))))return w(s),_=s,e(s);const S=s.version;s.close();const v=indexedDB.open(d,S+1);v.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection")},v.onerror=()=>{console.warn("[ln-data-store] Database upgrade failed"),e(null)},v.onupgradeneeded=q=>{const P=q.target.result;P.objectStoreNames.contains(h)||P.createObjectStore(h,{keyPath:"key"});for(const $ of r)if(!P.objectStoreNames.contains($)){const ye=P.createObjectStore($,{keyPath:"id"});for(const I of t[$].indexes)ye.createIndex(I,I,{unique:!1})}},v.onsuccess=q=>{const P=q.target.result;w(P),_=P,e(P)}}}),m)}function w(e){e.onversionchange=()=>{e.close(),_=null,m=null}}function y(){return _?Promise.resolve(_):(m=null,k())}async function B(e){if(!j()||!e)return e;const t={...e},r=t.id,n=t._pending,o=await re(t);return!o||!o.encrypted?e:{id:r,_pending:n,encrypted:!0,iv:o.iv,data:o.data}}async function R(e){return!e||!e.encrypted||!j()?e:oe(e)}const C=(e,t)=>y().then(r=>r?r.transaction(e,t).objectStore(e):null);function E(e){return new Promise((t,r)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>{L(e.error),r(e.error)}})}const U=e=>C(e,"readonly").then(t=>t?E(t.getAll()):[]).then(t=>j()?Promise.all(t.map(r=>R(r))):t),N=(e,t)=>C(e,"readonly").then(r=>r?E(r.get(t)):null).then(r=>r?R(r):null),D=(e,t)=>(j()?B(t):Promise.resolve(t)).then(n=>C(e,"readwrite").then(o=>o?E(o.put(n)):null)),O=(e,t)=>C(e,"readwrite").then(r=>r?E(r.delete(t)):null),J=e=>C(e,"readwrite").then(t=>t?E(t.clear()):null),Q=e=>C(e,"readonly").then(t=>t?E(t.count()):0),se=e=>C(h,"readonly").then(t=>t?E(t.get(e)):null),z=(e,t)=>C(h,"readwrite").then(r=>{if(r)return t.key=e,E(r.put(t))});function b(e){this.dom=e,this._name=e.getAttribute(a);const t=e.getAttribute("data-ln-data-store-stale")||e.getAttribute("data-ln-store-stale"),r=parseInt(t,10);this._staleThreshold=t==="never"||t==="-1"?-1:isNaN(r)?300:r;const n=e.getAttribute("data-ln-data-store-search-fields")||e.getAttribute("data-ln-store-search-fields")||"";return this._searchFields=n.split(",").map(o=>o.trim()).filter(Boolean),this._handlers=null,this._pendingSnapshots={},this.isLoaded=!1,this.isSyncing=!1,this.lastSyncedAt=null,this.totalCount=0,this.presenters=null,u[this._name]=this,ae(this),de(this),this}function ae(e){e._handlers={create:t=>ie(e,t.detail),update:t=>ce(e,t.detail),delete:t=>le(e,t.detail),"bulk-delete":t=>ue(e,t.detail)};for(const[t,r]of Object.entries(e._handlers))e.dom.addEventListener(`ln-store:request-${t}`,r)}function ie(e,{data:t={}}={}){const r=`_temp_${g()}`,n={...t,id:r,_pending:!0};D(e._name,n).then(()=>{e.totalCount++,l(e.dom,"ln-store:created",{store:e._name,record:n,tempId:r}),l(e.dom,"ln-store:request-remote-create",{tempId:r,data:t})})}function ce(e,{id:t,data:r={},expected_version:n}={}){N(e._name,t).then(o=>{if(!o)throw new Error(`Record not found: ${t}`);e._pendingSnapshots[t]={...o};const s={...o,...r,_pending:!0};return D(e._name,s).then(()=>{l(e.dom,"ln-store:updated",{store:e._name,record:s,previous:e._pendingSnapshots[t]}),l(e.dom,"ln-store:request-remote-update",{id:t,data:r,expected_version:n})})}).catch(o=>console.error("[ln-data-store] Optimistic update failed:",o))}function le(e,{id:t}={}){N(e._name,t).then(r=>{if(r)return e._pendingSnapshots[t]={...r},O(e._name,t).then(()=>{e.totalCount--,l(e.dom,"ln-store:deleted",{store:e._name,id:t}),l(e.dom,"ln-store:request-remote-delete",{id:t})})}).catch(r=>console.error("[ln-data-store] Optimistic delete failed:",r))}function ue(e,{ids:t=[]}={}){t.length&&Promise.all(t.map(r=>N(e._name,r))).then(r=>{const n=r.filter(Boolean),o=n.map(s=>s.id);return e._pendingSnapshots[o.join(",")]=n,Y(e._name,o).then(()=>{e.totalCount-=o.length,l(e.dom,"ln-store:deleted",{store:e._name,ids:o}),l(e.dom,"ln-store:request-remote-bulk-delete",{ids:o})})}).catch(r=>console.error("[ln-data-store] Optimistic bulk delete failed:",r))}function de(e){k().then(()=>se(e._name)).then(t=>{t&&t.schema_version===p?(e.lastSyncedAt=t.last_synced_at||null,e.totalCount=t.record_count||0,e.totalCount>0?(e.isLoaded=!0,l(e.dom,"ln-store:ready",{store:e._name,count:e.totalCount,source:"cache"}),W(e)&&M(e)):M(e)):t&&t.schema_version!==p?J(e._name).then(()=>z(e._name,{schema_version:p,last_synced_at:null,record_count:0})).then(()=>M(e)):M(e)})}function W(e){return e._staleThreshold===-1?!1:e.lastSyncedAt?Math.floor(Date.now()/1e3)-e.lastSyncedAt>e._staleThreshold:!0}function M(e){e.isSyncing=!0,l(e.dom,"ln-store:request-remote-sync",{since:e.lastSyncedAt})}function X(e,t){return y().then(r=>r?(j()?Promise.all(t.map(o=>B(o))):Promise.resolve(t)).then(o=>new Promise((s,c)=>{const f=r.transaction(e,"readwrite"),S=f.objectStore(e);o.forEach(v=>S.put(v)),f.oncomplete=()=>s(),f.onerror=()=>{L(f.error),c(f.error)}})):void 0)}function Y(e,t){return y().then(r=>{if(r)return new Promise((n,o)=>{const s=r.transaction(e,"readwrite"),c=s.objectStore(e);t.forEach(f=>c.delete(f)),s.oncomplete=()=>n(),s.onerror=()=>o(s.error)})})}let T=()=>{document.visibilityState==="visible"&&Object.values(u).forEach(e=>{e.isLoaded&&!e.isSyncing&&W(e)&&M(e)})};document.addEventListener("visibilitychange",T);const he=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function fe(e,t){if(!t||!t.field)return e;const{field:r,direction:n}=t,o=n==="desc";return[...e].sort((s,c)=>{const f=s[r],S=c[r];if(f==null&&S==null)return 0;if(f==null)return o?1:-1;if(S==null)return o?-1:1;const v=typeof f=="string"&&typeof S=="string"?he.compare(f,S):f<S?-1:f>S?1:0;return o?-v:v})}function Z(e,t){if(!t)return e;const r=Object.keys(t).filter(n=>Array.isArray(t[n])&&t[n].length>0);return r.length?e.filter(n=>r.every(o=>t[o].map(String).includes(String(n[o])))):e}function me(e,t,r){if(!t||!r||!r.length)return e;const n=t.toLowerCase();return e.filter(o=>r.some(s=>{const c=o[s];return c!=null&&String(c).toLowerCase().includes(n)}))}function pe(e,t,r){if(!e.length)return 0;if(r==="count")return e.length;const n=e.map(s=>parseFloat(s[t])).filter(s=>!isNaN(s)),o=n.reduce((s,c)=>s+c,0);return r==="sum"?o:r==="avg"&&n.length?o/n.length:0}function F(e,t){if(!e.presenters||!e.presenters.computed)return t;const r=e.presenters.computed;return t.map(n=>{const o={...n};for(const[s,c]of Object.entries(r))try{o[s]=c(n)}catch(f){console.error(`[ln-data-store] Decorator computed field failed for ${s}`,f)}return o})}b.prototype.getAll=function(e={}){const t=this;return U(t._name).then(r=>{const n=r.length;e.filters&&(r=Z(r,e.filters)),e.search&&(r=me(r,e.search,t._searchFields));const o=r.length;if(e.sort&&(r=fe(r,e.sort)),e.offset||e.limit){const s=e.offset||0,c=e.limit||r.length;r=r.slice(s,s+c)}return{data:F(t,r),total:n,filtered:o}})},b.prototype.getById=function(e){return N(this._name,e).then(t=>t?F(this,[t])[0]:null)},b.prototype.count=function(e){return e?U(this._name).then(t=>Z(t,e).length):Q(this._name)},b.prototype.aggregate=function(e,t){return U(this._name).then(r=>pe(r,e,t))},b.prototype.setPresenters=function(e){this.presenters=e},b.prototype.applySync=function(e,t,r){const n=this,o=e.length>0||t.length>0;let s=Promise.resolve();return e.length>0&&(s=s.then(()=>X(n._name,e))),t.length>0&&(s=s.then(()=>Y(n._name,t))),s.then(()=>Q(n._name)).then(c=>(n.totalCount=c,z(n._name,{schema_version:p,last_synced_at:r,record_count:c}))).then(()=>{const c=!n.isLoaded;n.isLoaded=!0,n.isSyncing=!1,n.lastSyncedAt=r,c?(l(n.dom,"ln-store:loaded",{store:n._name,count:n.totalCount}),l(n.dom,"ln-store:ready",{store:n._name,count:n.totalCount,source:"server"})):l(n.dom,"ln-store:synced",{store:n._name,added:e.length,deleted:t.length,changed:o})}).catch(c=>{n.isSyncing=!1,console.error("[ln-data-store] applySync failed:",c)})},b.prototype.confirmMutation=function(e,t,r){const n=this,o={create:()=>O(n._name,e).then(()=>D(n._name,t)).then(()=>{delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:t,tempId:e,action:"create"})}),update:()=>D(n._name,t).then(()=>{delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:t,action:"update"})}),delete:()=>(delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:null,action:"delete"}),Promise.resolve()),"bulk-delete":()=>(delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:null,ids:e.split(","),action:"bulk-delete"}),Promise.resolve())};return o[r]?o[r]():Promise.resolve()},b.prototype.revertMutation=function(e,t,r){const n=this,o=r||`Server rejected ${t}`,s={create:()=>O(n._name,e).then(()=>{n.totalCount--,delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:null,action:"create",error:o})}),update:()=>{const c=n._pendingSnapshots[e];return c?D(n._name,c).then(()=>{delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:c,action:"update",error:o})}):Promise.resolve()},delete:()=>{const c=n._pendingSnapshots[e];return c?D(n._name,c).then(()=>{n.totalCount++,delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:c,action:"delete",error:o})}):Promise.resolve()},"bulk-delete":()=>{const c=n._pendingSnapshots[e];return!c||!c.length?Promise.resolve():X(n._name,c).then(()=>{n.totalCount+=c.length,delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:null,ids:e.split(","),action:"bulk-delete",error:o})})}};return s[t]?s[t]():Promise.resolve()},b.prototype.resolveConflict=function(e,t,r){const n=this._pendingSnapshots[e];return n?D(this._name,n).then(()=>{delete this._pendingSnapshots[e],l(this.dom,"ln-store:conflict",{store:this._name,local:n,remote:t,field_diffs:r||null})}):Promise.resolve()},b.prototype.forceSync=function(){M(this)},b.prototype.fullReload=function(){const e=this;return J(e._name).then(()=>{e.isLoaded=!1,e.lastSyncedAt=null,e.totalCount=0,M(e)})},b.prototype.destroy=function(){if(this._handlers){for(const[e,t]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-store:request-${e}`,t);this._handlers=null}delete u[this._name],Object.keys(u).length===0&&T&&(document.removeEventListener("visibilitychange",T),T=null),delete this.dom[i],l(this.dom,"ln-store:destroyed",{store:this._name})};function _e(){return y().then(e=>{if(!e)return;const t=Array.from(e.objectStoreNames);return new Promise((r,n)=>{const o=e.transaction(t,"readwrite");t.forEach(s=>o.objectStore(s).clear()),o.oncomplete=()=>r(),o.onerror=()=>n(o.error)})}).then(()=>{Object.values(u).forEach(e=>{e.isLoaded=!1,e.isSyncing=!1,e.lastSyncedAt=null,e.totalCount=0})})}ee(a,i,b,"ln-data-store"),window[i].clearAll=_e,window[i].init=window[i],window[i].setStorageKey=G,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=G)})()})();
|
|
1
|
+
(function(){"use strict";function l(s,a,d){s.dispatchEvent(new CustomEvent(a,{bubbles:!0,detail:d||{}}))}function H(s,a){if(!document.body){document.addEventListener("DOMContentLoaded",function(){H(s,a)}),console.warn("["+a+'] Script loaded before <body> — add "defer" to your <script> tag');return}s()}function K(s,a,d,h){if(s.nodeType!==1)return;const _=a.indexOf("[")!==-1||a.indexOf(".")!==-1||a.indexOf("#")!==-1?a:"["+a+"]",m=Array.from(s.querySelectorAll(_));s.matches&&s.matches(_)&&m.push(s);for(const u of m)u[d]||(u[d]=new h(u))}function ee(s,a,d,h,y={}){const _=y.extraAttributes||[],m=y.onAttributeChange||null,u=y.onInit||null;function g(N){const D=N||document.body;K(D,s,a,d),u&&u(D)}return H(function(){const N=new MutationObserver(function(B){for(let C=0;C<B.length;C++){const p=B[C];if(p.type==="childList"){for(let x=0;x<p.addedNodes.length;x++){const S=p.addedNodes[x];S.nodeType===1&&(K(S,s,a,d),u&&u(S))}for(let x=0;x<p.removedNodes.length;x++){const S=p.removedNodes[x];if(S.nodeType===1){const v=s.indexOf("[")!==-1||s.indexOf(".")!==-1||s.indexOf("#")!==-1?s:"["+s+"]",R=Array.from(S.querySelectorAll(v));S.matches&&S.matches(v)&&R.push(S);for(let M=0;M<R.length;M++){const w=R[M][a];w&&typeof w.destroy=="function"&&w.destroy()}}}}else p.type==="attributes"&&(m&&p.target[a]?m(p.target,p.attributeName):(K(p.target,s,a,d),u&&u(p.target)))}});let D=[];if(s.indexOf("[")!==-1){const B=/\[([\w-]+)/g;let C;for(;(C=B.exec(s))!==null;)D.push(C[1])}else D.push(s);N.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:D.concat(_)})},h),window[a]=g,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){g(document.body)}):g(document.body),g}const V={};function te(s,a){V[s]=a}function ne(s){return V[s]||{ingress:a=>a,egress:a=>a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=te,window.lnCore.getDataMapper=ne);let k=null;async function G(s){if(!s){k=null;return}try{const a=new TextEncoder,d=await crypto.subtle.digest("SHA-256",a.encode(s));k=await crypto.subtle.importKey("raw",d,{name:"AES-GCM"},!1,["encrypt","decrypt"])}catch(a){console.error("[ln-core/crypto] Key derivation failed:",a),k=null}}function j(){return k}async function re(s,a=k){const d=a||k;if(!d||s===void 0||s===null)return s;try{const h=new TextEncoder,y=crypto.getRandomValues(new Uint8Array(12)),_=typeof s=="string"?s:JSON.stringify(s),m=await crypto.subtle.encrypt({name:"AES-GCM",iv:y},d,h.encode(_)),u=btoa(String.fromCharCode(...y)),g=btoa(String.fromCharCode(...new Uint8Array(m)));return{encrypted:!0,iv:u,data:g}}catch(h){return console.error("[ln-core/crypto] Encryption failed:",h),s}}async function oe(s,a=k){const d=a||k;if(!s||!s.encrypted||!d)return s;try{const h=new TextDecoder,y=Uint8Array.from(atob(s.iv),g=>g.charCodeAt(0)),_=Uint8Array.from(atob(s.data),g=>g.charCodeAt(0)),m=await crypto.subtle.decrypt({name:"AES-GCM",iv:y},d,_),u=h.decode(m);try{return JSON.parse(u)}catch{return u}}catch(h){return console.error("[ln-core/crypto] Decryption failed. Key may be incorrect:",h),{...s,decryptionError:!0}}}(function(){const s="data-ln-data-store",a="lnDataStore";if(window[a]!==void 0)return;const d="ln_app_cache",h="_meta",y="1.0";let _=null,m=null;const u={};function g(){try{return crypto.randomUUID()}catch{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const r=Math.random()*16|0;return(t==="x"?r:r&3|8).toString(16)})}}function N(e){e&&e.name==="QuotaExceededError"&&l(document,"ln-store:quota-exceeded",{error:e})}function D(){const e={};for(const t of document.querySelectorAll(`[${s}]`)){const r=t.getAttribute(s);if(r){const n=t.getAttribute("data-ln-data-store-indexes")||t.getAttribute("data-ln-store-indexes")||"";e[r]={indexes:n.split(",").map(o=>o.trim()).filter(Boolean)}}}return e}function B(){return m||(m=new Promise(e=>{if(typeof indexedDB>"u")return console.warn("[ln-data-store] IndexedDB not available — falling back to in-memory store"),e(null);const t=D(),r=Object.keys(t),n=indexedDB.open(d);n.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed — falling back to in-memory store"),e(null)},n.onsuccess=o=>{const i=o.target.result,c=Array.from(i.objectStoreNames);if(!(!c.includes(h)||r.some(T=>!c.includes(T))))return C(i),_=i,e(i);const A=i.version;i.close();const P=indexedDB.open(d,A+1);P.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection")},P.onerror=()=>{console.warn("[ln-data-store] Database upgrade failed"),e(null)},P.onupgradeneeded=T=>{const L=T.target.result;L.objectStoreNames.contains(h)||L.createObjectStore(h,{keyPath:"key"});for(const $ of r)if(!L.objectStoreNames.contains($)){const _e=L.createObjectStore($,{keyPath:"id"});for(const I of t[$].indexes)_e.createIndex(I,I,{unique:!1})}},P.onsuccess=T=>{const L=T.target.result;C(L),_=L,e(L)}}}),m)}function C(e){e.onversionchange=()=>{e.close(),_=null,m=null}}function p(){return _?Promise.resolve(_):(m=null,B())}async function x(e){if(!j()||!e)return e;const t={...e},r=t.id,n=t._pending,o=await re(t);return!o||!o.encrypted?e:{id:r,_pending:n,encrypted:!0,iv:o.iv,data:o.data}}async function S(e){return!e||!e.encrypted||!j()?e:oe(e)}const E=(e,t)=>p().then(r=>r?r.transaction(e,t).objectStore(e):null);function v(e){return new Promise((t,r)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>{N(e.error),r(e.error)}})}const R=e=>E(e,"readonly").then(t=>t?v(t.getAll()):[]).then(t=>j()?Promise.all(t.map(r=>S(r))):t),M=(e,t)=>E(e,"readonly").then(r=>r?v(r.get(t)):null).then(r=>r?S(r):null),w=(e,t)=>(j()?x(t):Promise.resolve(t)).then(n=>E(e,"readwrite").then(o=>o?v(o.put(n)):null)),U=(e,t)=>E(e,"readwrite").then(r=>r?v(r.delete(t)):null),J=e=>E(e,"readwrite").then(t=>t?v(t.clear()):null),Q=e=>E(e,"readonly").then(t=>t?v(t.count()):0),se=e=>E(h,"readonly").then(t=>t?v(t.get(e)):null),z=(e,t)=>E(h,"readwrite").then(r=>{if(r)return t.key=e,v(r.put(t))});function b(e){this.dom=e,this._name=e.getAttribute(s);const t=e.getAttribute("data-ln-data-store-stale")||e.getAttribute("data-ln-store-stale"),r=parseInt(t,10);this._staleThreshold=t==="never"||t==="-1"?-1:isNaN(r)?300:r;const n=e.getAttribute("data-ln-data-store-search-fields")||e.getAttribute("data-ln-store-search-fields")||"";return this._searchFields=n.split(",").map(o=>o.trim()).filter(Boolean),this._handlers=null,this._pendingSnapshots={},this.isLoaded=!1,this.isSyncing=!1,this.lastSyncedAt=null,this.totalCount=0,this.presenters=null,u[this._name]=this,ie(this),de(this),this}function ie(e){e._handlers={create:t=>ae(e,t.detail),update:t=>ce(e,t.detail),delete:t=>le(e,t.detail),"bulk-delete":t=>ue(e,t.detail)};for(const[t,r]of Object.entries(e._handlers))e.dom.addEventListener(`ln-store:request-${t}`,r)}function ae(e,{data:t={}}={}){const r=`_temp_${g()}`,n={...t,id:r,_pending:!0};w(e._name,n).then(()=>{e.totalCount++,l(e.dom,"ln-store:created",{store:e._name,record:n,tempId:r}),l(e.dom,"ln-store:request-remote-create",{tempId:r,data:t})})}function ce(e,{id:t,data:r={},expected_version:n}={}){M(e._name,t).then(o=>{if(!o)throw new Error(`Record not found: ${t}`);e._pendingSnapshots[t]={...o};const i={...o,...r,_pending:!0};return w(e._name,i).then(()=>{l(e.dom,"ln-store:updated",{store:e._name,record:i,previous:e._pendingSnapshots[t]}),l(e.dom,"ln-store:request-remote-update",{id:t,data:r,expected_version:n})})}).catch(o=>console.error("[ln-data-store] Optimistic update failed:",o))}function le(e,{id:t}={}){M(e._name,t).then(r=>{if(r)return e._pendingSnapshots[t]={...r},U(e._name,t).then(()=>{e.totalCount--,l(e.dom,"ln-store:deleted",{store:e._name,id:t}),l(e.dom,"ln-store:request-remote-delete",{id:t})})}).catch(r=>console.error("[ln-data-store] Optimistic delete failed:",r))}function ue(e,{ids:t=[]}={}){t.length&&Promise.all(t.map(r=>M(e._name,r))).then(r=>{const n=r.filter(Boolean),o=n.map(i=>i.id);return e._pendingSnapshots[o.join(",")]=n,Y(e._name,o).then(()=>{e.totalCount-=o.length,l(e.dom,"ln-store:deleted",{store:e._name,ids:o}),l(e.dom,"ln-store:request-remote-bulk-delete",{ids:o})})}).catch(r=>console.error("[ln-data-store] Optimistic bulk delete failed:",r))}function de(e){B().then(()=>se(e._name)).then(t=>{t&&t.schema_version===y?(e.lastSyncedAt=t.last_synced_at||null,e.totalCount=t.record_count||0,e.totalCount>0?(e.isLoaded=!0,l(e.dom,"ln-store:ready",{store:e._name,count:e.totalCount,source:"cache"}),W(e)&&q(e)):q(e)):t&&t.schema_version!==y?J(e._name).then(()=>z(e._name,{schema_version:y,last_synced_at:null,record_count:0})).then(()=>q(e)):q(e)})}function W(e){return e._staleThreshold===-1?!1:e.lastSyncedAt?Math.floor(Date.now()/1e3)-e.lastSyncedAt>e._staleThreshold:!0}function q(e){e.isSyncing=!0,l(e.dom,"ln-store:request-remote-sync",{since:e.lastSyncedAt})}function X(e,t){return p().then(r=>r?(j()?Promise.all(t.map(o=>x(o))):Promise.resolve(t)).then(o=>new Promise((i,c)=>{const f=r.transaction(e,"readwrite"),A=f.objectStore(e);o.forEach(P=>A.put(P)),f.oncomplete=()=>i(),f.onerror=()=>{N(f.error),c(f.error)}})):void 0)}function Y(e,t){return p().then(r=>{if(r)return new Promise((n,o)=>{const i=r.transaction(e,"readwrite"),c=i.objectStore(e);t.forEach(f=>c.delete(f)),i.oncomplete=()=>n(),i.onerror=()=>o(i.error)})})}let O=()=>{document.visibilityState==="visible"&&Object.values(u).forEach(e=>{e.isLoaded&&!e.isSyncing&&W(e)&&q(e)})};document.addEventListener("visibilitychange",O);const he=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function fe(e,t){if(!t||!t.field)return e;const{field:r,direction:n}=t,o=n==="desc";return[...e].sort((i,c)=>{const f=i[r],A=c[r];if(f==null&&A==null)return 0;if(f==null)return o?1:-1;if(A==null)return o?-1:1;const P=typeof f=="string"&&typeof A=="string"?he.compare(f,A):f<A?-1:f>A?1:0;return o?-P:P})}function Z(e,t){if(!t)return e;const r=Object.keys(t).filter(n=>Array.isArray(t[n])&&t[n].length>0);return r.length?e.filter(n=>r.every(o=>t[o].map(String).includes(String(n[o])))):e}function me(e,t,r){if(!t||!r||!r.length)return e;const n=t.toLowerCase();return e.filter(o=>r.some(i=>{const c=o[i];return c!=null&&String(c).toLowerCase().includes(n)}))}function pe(e,t,r){if(!e.length)return 0;if(r==="count")return e.length;const n=e.map(i=>parseFloat(i[t])).filter(i=>!isNaN(i)),o=n.reduce((i,c)=>i+c,0);return r==="sum"?o:r==="avg"&&n.length?o/n.length:0}function F(e,t){if(!e.presenters||!e.presenters.computed)return t;const r=e.presenters.computed;return t.map(n=>{const o={...n};for(const[i,c]of Object.entries(r))try{o[i]=c(n)}catch(f){console.error(`[ln-data-store] Decorator computed field failed for ${i}`,f)}return o})}b.prototype.getAll=function(e={}){const t=this;return R(t._name).then(r=>{const n=r.length;e.filters&&(r=Z(r,e.filters)),e.search&&(r=me(r,e.search,t._searchFields));const o=r.length;if(e.sort&&(r=fe(r,e.sort)),e.offset||e.limit){const i=e.offset||0,c=e.limit||r.length;r=r.slice(i,i+c)}return{data:F(t,r),total:n,filtered:o}})},b.prototype.getById=function(e){return M(this._name,e).then(t=>t?F(this,[t])[0]:null)},b.prototype.count=function(e){return e?R(this._name).then(t=>Z(t,e).length):Q(this._name)},b.prototype.aggregate=function(e,t){return R(this._name).then(r=>pe(r,e,t))},b.prototype.setPresenters=function(e){this.presenters=e},b.prototype.applySync=function(e,t,r){const n=this,o=e.length>0||t.length>0;let i=Promise.resolve();return e.length>0&&(i=i.then(()=>X(n._name,e))),t.length>0&&(i=i.then(()=>Y(n._name,t))),i.then(()=>Q(n._name)).then(c=>(n.totalCount=c,z(n._name,{schema_version:y,last_synced_at:r,record_count:c}))).then(()=>{const c=!n.isLoaded;n.isLoaded=!0,n.isSyncing=!1,n.lastSyncedAt=r,c?(l(n.dom,"ln-store:loaded",{store:n._name,count:n.totalCount}),l(n.dom,"ln-store:ready",{store:n._name,count:n.totalCount,source:"server"})):l(n.dom,"ln-store:synced",{store:n._name,added:e.length,deleted:t.length,changed:o})}).catch(c=>{n.isSyncing=!1,console.error("[ln-data-store] applySync failed:",c)})},b.prototype.confirmMutation=function(e,t,r){const n=this,o={create:()=>U(n._name,e).then(()=>w(n._name,t)).then(()=>{delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:t,tempId:e,action:"create"})}),update:()=>w(n._name,t).then(()=>{delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:t,action:"update"})}),delete:()=>(delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:null,action:"delete"}),Promise.resolve()),"bulk-delete":()=>(delete n._pendingSnapshots[e],l(n.dom,"ln-store:confirmed",{store:n._name,record:null,ids:e.split(","),action:"bulk-delete"}),Promise.resolve())};return o[r]?o[r]():Promise.resolve()},b.prototype.revertMutation=function(e,t,r){const n=this,o=r||`Server rejected ${t}`,i={create:()=>U(n._name,e).then(()=>{n.totalCount--,delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:null,action:"create",error:o})}),update:()=>{const c=n._pendingSnapshots[e];return c?w(n._name,c).then(()=>{delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:c,action:"update",error:o})}):Promise.resolve()},delete:()=>{const c=n._pendingSnapshots[e];return c?w(n._name,c).then(()=>{n.totalCount++,delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:c,action:"delete",error:o})}):Promise.resolve()},"bulk-delete":()=>{const c=n._pendingSnapshots[e];return!c||!c.length?Promise.resolve():X(n._name,c).then(()=>{n.totalCount+=c.length,delete n._pendingSnapshots[e],l(n.dom,"ln-store:reverted",{store:n._name,record:null,ids:e.split(","),action:"bulk-delete",error:o})})}};return i[t]?i[t]():Promise.resolve()},b.prototype.resolveConflict=function(e,t,r){const n=this._pendingSnapshots[e];return n?w(this._name,n).then(()=>{delete this._pendingSnapshots[e],l(this.dom,"ln-store:conflict",{store:this._name,local:n,remote:t,field_diffs:r||null})}):Promise.resolve()},b.prototype.forceSync=function(){q(this)},b.prototype.fullReload=function(){const e=this;return J(e._name).then(()=>{e.isLoaded=!1,e.lastSyncedAt=null,e.totalCount=0,q(e)})},b.prototype.destroy=function(){if(this._handlers){for(const[e,t]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-store:request-${e}`,t);this._handlers=null}delete u[this._name],Object.keys(u).length===0&&O&&(document.removeEventListener("visibilitychange",O),O=null),delete this.dom[a],l(this.dom,"ln-store:destroyed",{store:this._name})};function ye(){return p().then(e=>{if(!e)return;const t=Array.from(e.objectStoreNames);return new Promise((r,n)=>{const o=e.transaction(t,"readwrite");t.forEach(i=>o.objectStore(i).clear()),o.oncomplete=()=>r(),o.onerror=()=>n(o.error)})}).then(()=>{Object.values(u).forEach(e=>{e.isLoaded=!1,e.isSyncing=!1,e.lastSyncedAt=null,e.totalCount=0})})}ee(s,a,b,"ln-data-store"),window[a].clearAll=ye,window[a].init=window[a],window[a].setStorageKey=G,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=G)})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";const x={};function F(a,r){x[a]||(x[a]=document.querySelector('[data-ln-template="'+a+'"]'));const f=x[a];return f?f.content.cloneNode(!0):(console.warn("["+r+'] Template "'+a+'" not found'),null)}function w(a,r,f){a.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:f||{}}))}function D(a,r){if(!a||!r)return a;const f=a.querySelectorAll("[data-ln-field]");for(let u=0;u<f.length;u++){const s=f[u],p=s.getAttribute("data-ln-field");r[p]!=null&&(s.textContent=r[p])}const y=a.querySelectorAll("[data-ln-attr]");for(let u=0;u<y.length;u++){const s=y[u],p=s.getAttribute("data-ln-attr").split(",");for(let e=0;e<p.length;e++){const t=p[e].trim().split(":");if(t.length!==2)continue;const n=t[0].trim(),l=t[1].trim();r[l]!=null&&s.setAttribute(n,r[l])}}const S=a.querySelectorAll("[data-ln-show]");for(let u=0;u<S.length;u++){const s=S[u],p=s.getAttribute("data-ln-show");p in r&&s.classList.toggle("hidden",!r[p])}const m=a.querySelectorAll("[data-ln-class]");for(let u=0;u<m.length;u++){const s=m[u],p=s.getAttribute("data-ln-class").split(",");for(let e=0;e<p.length;e++){const t=p[e].trim().split(":");if(t.length!==2)continue;const n=t[0].trim(),l=t[1].trim();l in r&&s.classList.toggle(n,!!r[l])}}return a}function T(a,r){if(!a||!r)return a;const f=document.createTreeWalker(a,NodeFilter.SHOW_TEXT);for(;f.nextNode();){const y=f.currentNode;y.textContent.indexOf("{{")!==-1&&(y.textContent=y.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(S,m){return r[m]!==void 0?r[m]:""}))}return a}function R(a,r){if(!document.body){document.addEventListener("DOMContentLoaded",function(){R(a,r)}),console.warn("["+r+'] Script loaded before <body> — add "defer" to your <script> tag');return}a()}function k(a,r,f){if(a){const y=a.querySelector('[data-ln-template="'+r+'"]');if(y)return y.content.cloneNode(!0)}return F(r,f)}function I(a,r,f,y){if(a.nodeType!==1)return;const m=r.indexOf("[")!==-1||r.indexOf(".")!==-1||r.indexOf("#")!==-1?r:"["+r+"]",u=Array.from(a.querySelectorAll(m));a.matches&&a.matches(m)&&u.push(a);for(const s of u)s[f]||(s[f]=new y(s))}function O(a,r,f,y,S={}){const m=S.extraAttributes||[],u=S.onAttributeChange||null,s=S.onInit||null;function p(e){const t=e||document.body;I(t,a,r,f),s&&s(t)}return R(function(){const e=new MutationObserver(function(n){for(let l=0;l<n.length;l++){const i=n[l];if(i.type==="childList")for(let o=0;o<i.addedNodes.length;o++){const c=i.addedNodes[o];c.nodeType===1&&(I(c,a,r,f),s&&s(c))}else i.type==="attributes"&&(u&&i.target[r]?u(i.target,i.attributeName):(I(i.target,a,r,f),s&&s(i.target)))}});let t=[];if(a.indexOf("[")!==-1){const n=/\[([\w-]+)/g;let l;for(;(l=n.exec(a))!==null;)t.push(l[1])}else t.push(a);e.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:t.concat(m)})},y),window[r]=p,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){p(document.body)}):p(document.body),p}const q={};function H(a,r){q[a]=r}function N(a){return q[a]||{ingress:r=>r,egress:r=>r}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=H,window.lnCore.getDataMapper=N),(function(){const a="data-ln-data-table",r="lnDataTable";if(window[r]!==void 0)return;const S=typeof Intl<"u"?new Intl.NumberFormat(document.documentElement.lang||void 0):null;function m(e){return S?S.format(e):String(e)}function u(e){let t=e.parentElement;for(;t&&t!==document.body&&t!==document.documentElement;){const l=getComputedStyle(t).overflowY;if(l==="auto"||l==="scroll")return t;t=t.parentElement}return null}function s(e){this.dom=e,this.name=e.getAttribute(a)||"",this.table=e.querySelector("table"),this.tbody=e.querySelector("[data-ln-data-table-body]")||e.querySelector("tbody"),this.thead=e.querySelector("thead"),this.ths=this.thead?Array.from(this.thead.querySelectorAll("th")):[],this.isLoaded=!1,this.totalCount=0,this.visibleCount=0,this.currentSort=null,this.currentFilters={},this.currentSearch="",this.selectedIds=new Set,this._data=[],this._lastTotal=0,this._lastFiltered=0,this._filterOptions={},this._filterableFields=this.ths.filter(function(n){return n.getAttribute("data-ln-col")&&n.querySelector("[data-ln-col-filter]")}).map(function(n){return n.getAttribute("data-ln-col")}),this._virtual=!1,this._rowHeight=0,this._vStart=-1,this._vEnd=-1,this._rafId=null,this._scrollHandler=null,this._scrollContainer=null,this._totalSpan=e.querySelector("[data-ln-data-table-total]"),this._filteredSpan=e.querySelector("[data-ln-data-table-filtered]"),this._filteredSpan&&(this._filteredWrap=this._filteredSpan.parentElement!==e?this._filteredSpan.closest("[data-ln-data-table-filtered-wrap]")||this._filteredSpan.parentNode:null),this._selectedSpan=e.querySelector("[data-ln-data-table-selected]"),this._selectedSpan&&(this._selectedWrap=this._selectedSpan.parentElement!==e?this._selectedSpan.closest("[data-ln-data-table-selected-wrap]")||this._selectedSpan.parentNode:null);const t=this;return this._onSetData=function(n){const l=n.detail||{};t._data=l.data||[],t._lastTotal=l.total!=null?l.total:t._data.length,t._lastFiltered=l.filtered!=null?l.filtered:t._data.length,t.totalCount=t._lastTotal,t.visibleCount=t._lastFiltered,t.isLoaded=!0,t._updateFilterOptions(l.filterOptions),t._vStart=-1,t._vEnd=-1,t._renderRows(),t._updateFooter(),w(e,"ln-data-table:rendered",{table:t.name,total:t.totalCount,visible:t.visibleCount})},e.addEventListener("ln-data-table:set-data",this._onSetData),this._onSetLoading=function(n){const l=n.detail&&n.detail.loading;e.classList.toggle("ln-data-table--loading",!!l),l&&(t.isLoaded=!1)},e.addEventListener("ln-data-table:set-loading",this._onSetLoading),this._sortButtons=Array.from(e.querySelectorAll("[data-ln-col-sort]")),this._onSortClick=function(n){const l=n.target.closest("[data-ln-col-sort]");if(!l)return;const i=l.closest("th");if(!i)return;const o=i.getAttribute("data-ln-col");o&&t._handleSort(o,i)},this.thead&&this.thead.addEventListener("click",this._onSortClick),this._activeDropdown=null,this._onFilterClick=function(n){const l=n.target.closest("[data-ln-col-filter]");if(!l)return;n.stopPropagation();const i=l.closest("th");if(!i)return;const o=i.getAttribute("data-ln-col");if(o){if(t._activeDropdown&&t._activeDropdown.field===o){t._closeFilterDropdown();return}t._openFilterDropdown(o,i,l)}},this.thead&&this.thead.addEventListener("click",this._onFilterClick),this._onDocClick=function(){t._activeDropdown&&t._closeFilterDropdown()},document.addEventListener("click",this._onDocClick),this._onClearAll=function(n){n.target.closest("[data-ln-data-table-clear-all]")&&(t.currentFilters={},t._updateFilterIndicators(),w(e,"ln-data-table:clear-filters",{table:t.name}),t._requestData())},e.addEventListener("click",this._onClearAll),this._selectable=e.hasAttribute("data-ln-data-table-selectable"),this._selectableActive=!1,this._selectable&&this._enableSelection(),this._onRowClick=function(n){if(n.target.closest("[data-ln-row-select]")||n.target.closest("[data-ln-row-action]")||n.target.closest("a")||n.target.closest("button")||n.ctrlKey||n.metaKey||n.button===1)return;const l=n.target.closest("[data-ln-row]");if(!l)return;const i=l.getAttribute("data-ln-row-id"),o=l._lnRecord||{};w(e,"ln-data-table:row-click",{table:t.name,id:i,record:o})},this.tbody&&this.tbody.addEventListener("click",this._onRowClick),this._onRowAction=function(n){const l=n.target.closest("[data-ln-row-action]");if(!l)return;n.stopPropagation();const i=l.closest("[data-ln-row]");if(!i)return;const o=l.getAttribute("data-ln-row-action"),c=i.getAttribute("data-ln-row-id"),d=i._lnRecord||{};w(e,"ln-data-table:row-action",{table:t.name,id:c,action:o,record:d})},this.tbody&&this.tbody.addEventListener("click",this._onRowAction),this._searchInput=e.querySelector("[data-ln-data-table-search]"),this._searchInput&&(this._onSearchInput=function(){t.currentSearch=t._searchInput.value,w(e,"ln-data-table:search",{table:t.name,query:t.currentSearch}),t._requestData()},this._searchInput.addEventListener("input",this._onSearchInput)),this._focusedRowIndex=-1,this._onKeydown=function(n){if(!e.contains(document.activeElement)&&document.activeElement!==document.body||document.activeElement&&(document.activeElement.tagName==="INPUT"||document.activeElement.tagName==="TEXTAREA"))return;if(n.key==="/"){t._searchInput&&(n.preventDefault(),t._searchInput.focus());return}const l=t.tbody?Array.from(t.tbody.querySelectorAll("[data-ln-row]")):[];if(l.length)switch(n.key){case"ArrowDown":n.preventDefault(),t._focusedRowIndex=Math.min(t._focusedRowIndex+1,l.length-1),t._focusRow(l);break;case"ArrowUp":n.preventDefault(),t._focusedRowIndex=Math.max(t._focusedRowIndex-1,0),t._focusRow(l);break;case"Home":n.preventDefault(),t._focusedRowIndex=0,t._focusRow(l);break;case"End":n.preventDefault(),t._focusedRowIndex=l.length-1,t._focusRow(l);break;case"Enter":if(t._focusedRowIndex>=0&&t._focusedRowIndex<l.length){n.preventDefault();const i=l[t._focusedRowIndex];w(e,"ln-data-table:row-click",{table:t.name,id:i.getAttribute("data-ln-row-id"),record:i._lnRecord||{}})}break;case" ":if(t._selectable&&t._focusedRowIndex>=0&&t._focusedRowIndex<l.length){n.preventDefault();const i=l[t._focusedRowIndex].querySelector("[data-ln-row-select]");i&&(i.checked=!i.checked,i.dispatchEvent(new Event("change",{bubbles:!0})))}break;case"Escape":t._activeDropdown&&t._closeFilterDropdown();break}},document.addEventListener("keydown",this._onKeydown),w(e,"ln-data-table:request-data",{table:this.name,sort:this.currentSort,filters:this.currentFilters,search:this.currentSearch}),this}s.prototype._handleSort=function(e,t){let n;!this.currentSort||this.currentSort.field!==e?n="asc":this.currentSort.direction==="asc"?n="desc":n=null;for(let l=0;l<this.ths.length;l++)this.ths[l].classList.remove("ln-sort-asc","ln-sort-desc");n?(this.currentSort={field:e,direction:n},t.classList.add(n==="asc"?"ln-sort-asc":"ln-sort-desc")):this.currentSort=null,w(this.dom,"ln-data-table:sort",{table:this.name,field:e,direction:n}),this._requestData()},s.prototype._requestData=function(){w(this.dom,"ln-data-table:request-data",{table:this.name,sort:this.currentSort,filters:this.currentFilters,search:this.currentSearch})},s.prototype._updateSelectAll=function(){if(!this._selectAllCheckbox||!this.tbody)return;const e=this.tbody.querySelectorAll("[data-ln-row]");let t=e.length>0;for(let n=0;n<e.length;n++){const l=e[n].getAttribute("data-ln-row-id");if(l!=null&&!this.selectedIds.has(l)){t=!1;break}}this._selectAllCheckbox.checked=t},Object.defineProperty(s.prototype,"selectedCount",{get:function(){return this.selectedIds.size},set:function(){}}),s.prototype._enableSelection=function(){if(this._selectableActive)return;this._selectableActive=!0;const e=this;if(this._onSelectionChange=function(t){const n=t.target.closest("[data-ln-row-select]");if(!n)return;const l=n.closest("[data-ln-row]");if(!l)return;const i=l.getAttribute("data-ln-row-id");i!=null&&(n.checked?(e.selectedIds.add(i),l.classList.add("ln-row-selected")):(e.selectedIds.delete(i),l.classList.remove("ln-row-selected")),e.selectedCount=e.selectedIds.size,e._updateSelectAll(),e._updateFooter(),w(e.dom,"ln-data-table:select",{table:e.name,selectedIds:e.selectedIds,count:e.selectedCount}))},this.tbody&&this.tbody.addEventListener("change",this._onSelectionChange),this._selectAllCheckbox=this.dom.querySelector('[data-ln-col-select] input[type="checkbox"]')||this.dom.querySelector("[data-ln-col-select]"),this._selectAllCheckbox&&this._selectAllCheckbox.tagName==="TH"){const t=document.createElement("input");t.type="checkbox",t.setAttribute("aria-label","Select all"),this._selectAllCheckbox.appendChild(t),this._selectAllCheckbox=t}if(this._selectAllCheckbox&&(this._onSelectAll=function(){const t=e._selectAllCheckbox.checked,n=e.tbody?e.tbody.querySelectorAll("[data-ln-row]"):[];for(let l=0;l<n.length;l++){const i=n[l].getAttribute("data-ln-row-id"),o=n[l].querySelector("[data-ln-row-select]");i!=null&&(t?(e.selectedIds.add(i),n[l].classList.add("ln-row-selected")):(e.selectedIds.delete(i),n[l].classList.remove("ln-row-selected")),o&&(o.checked=t))}e.selectedCount=e.selectedIds.size,w(e.dom,"ln-data-table:select-all",{table:e.name,selected:t}),w(e.dom,"ln-data-table:select",{table:e.name,selectedIds:e.selectedIds,count:e.selectedCount}),e._updateFooter()},this._selectAllCheckbox.addEventListener("change",this._onSelectAll)),this.tbody){const t=this.tbody.querySelectorAll("[data-ln-row]");for(let n=0;n<t.length;n++){const l=t[n].querySelector("[data-ln-row-select]"),i=t[n].getAttribute("data-ln-row-id");l&&l.checked&&i!=null&&(this.selectedIds.add(i),t[n].classList.add("ln-row-selected"))}this.selectedCount=this.selectedIds.size,this.selectedCount>0&&this._updateSelectAll()}},s.prototype._disableSelection=function(){if(!this._selectableActive)return;this._selectableActive=!1,this.tbody&&this._onSelectionChange&&this.tbody.removeEventListener("change",this._onSelectionChange),this._selectAllCheckbox&&this._onSelectAll&&this._selectAllCheckbox.removeEventListener("change",this._onSelectAll);const e=this.dom.querySelector("[data-ln-col-select]");if(e){const t=e.querySelector('input[type="checkbox"]');t&&t.remove()}if(this._selectAllCheckbox=null,this.selectedIds.clear(),this.selectedCount=0,this.tbody){const t=this.tbody.querySelectorAll("[data-ln-row]");for(let n=0;n<t.length;n++){t[n].classList.remove("ln-row-selected");const l=t[n].querySelector("[data-ln-row-select]");l&&(l.checked=!1)}}this._updateFooter()},s.prototype._focusRow=function(e){for(let t=0;t<e.length;t++)e[t].classList.remove("ln-row-focused"),e[t].removeAttribute("tabindex");if(this._focusedRowIndex>=0&&this._focusedRowIndex<e.length){const t=e[this._focusedRowIndex];t.classList.add("ln-row-focused"),t.setAttribute("tabindex","0"),t.focus(),t.scrollIntoView({block:"nearest"})}},s.prototype._openFilterDropdown=function(e,t,n){this._closeFilterDropdown();const l=k(this.dom,this.name+"-column-filter","ln-data-table")||k(this.dom,"column-filter","ln-data-table");if(!l)return;const i=l.firstElementChild;if(!i)return;const o=this._getUniqueValues(e),c=i.querySelector("[data-ln-filter-options]"),d=i.querySelector("[data-ln-filter-search]"),b=this.currentFilters[e]||[],g=this;if(d&&o.length<=8&&d.classList.add("hidden"),c){const C=c.querySelector("[data-ln-filter-reset]");C&&(C.checked=b.length===0);const v=k(i,this.name+"-column-filter-item","ln-data-table")||k(i,"column-filter-item","ln-data-table");if(v)for(let h=0;h<o.length;h++){const _=o[h],A=v.cloneNode(!0);D(A,{value:_});const L=A.querySelector('input[type="checkbox"]');L&&(L.value=_,L.checked=b.length>0&&b.indexOf(_)!==-1),c.appendChild(A)}c.addEventListener("change",function(h){h.target.type==="checkbox"&&(g._applyFilterMutualExclusion(h.target,c),g._onFilterChange(e,c))})}d&&d.addEventListener("input",function(){const C=d.value.toLowerCase(),v=c.querySelectorAll("li");for(let h=0;h<v.length;h++){const _=v[h].textContent.toLowerCase();v[h].classList.toggle("hidden",C&&_.indexOf(C)===-1)}});const E=i.querySelector("[data-ln-filter-clear]");E&&E.addEventListener("click",function(){delete g.currentFilters[e],g._closeFilterDropdown(),g._updateFilterIndicators(),w(g.dom,"ln-data-table:filter",{table:g.name,field:e,values:[]}),g._requestData()}),t.appendChild(i),this._activeDropdown={field:e,th:t,el:i},i.addEventListener("click",function(C){C.stopPropagation()})},s.prototype._closeFilterDropdown=function(){this._activeDropdown&&(this._activeDropdown.el&&this._activeDropdown.el.parentNode&&this._activeDropdown.el.parentNode.removeChild(this._activeDropdown.el),this._activeDropdown=null)},s.prototype._applyFilterMutualExclusion=function(e,t){const n=e.hasAttribute("data-ln-filter-reset"),l=t.querySelector("[data-ln-filter-reset]"),i=t.querySelectorAll('input[type="checkbox"]:not([data-ln-filter-reset])');if(n){e.checked=!0;for(let o=0;o<i.length;o++)i[o].checked=!1}else if(e.checked)l&&(l.checked=!1);else{let o=!1;for(let c=0;c<i.length;c++)if(i[c].checked){o=!0;break}!o&&l&&(l.checked=!0)}},s.prototype._onFilterChange=function(e,t){const n=t.querySelector("[data-ln-filter-reset]"),l=t.querySelectorAll('input[type="checkbox"]:not([data-ln-filter-reset])'),i=[];for(let c=0;c<l.length;c++)l[c].checked&&i.push(l[c].value);const o=n&&n.checked||i.length===0;o?delete this.currentFilters[e]:this.currentFilters[e]=i,this._updateFilterIndicators(),w(this.dom,"ln-data-table:filter",{table:this.name,field:e,values:o?[]:i}),this._requestData()},s.prototype._updateFilterOptions=function(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){const t=Object.keys(e);for(let n=0;n<t.length;n++){const l=t[n],i=e[l];if(!Array.isArray(i))continue;const o={},c=[];for(let d=0;d<i.length;d++){const b=String(i[d]);o[b]||(o[b]=!0,c.push(b))}this._filterOptions[l]=c.sort()}}else{const t=this._filterableFields,n=this._data;for(let l=0;l<t.length;l++){const i=t[l];this._filterOptions[i]||(this._filterOptions[i]=[]);const o=this._filterOptions[i],c={};for(let d=0;d<o.length;d++)c[o[d]]=!0;for(let d=0;d<n.length;d++){const b=n[d][i];if(b!=null){const g=String(b);c[g]||(c[g]=!0,o.push(g))}}o.sort()}}},s.prototype._getUniqueValues=function(e){return(this._filterOptions[e]||[]).slice().sort()},s.prototype._updateFilterIndicators=function(){const e=this.ths;for(let t=0;t<e.length;t++){const n=e[t],l=n.getAttribute("data-ln-col");if(!l)continue;const i=n.querySelector("[data-ln-col-filter]");if(!i)continue;const o=this.currentFilters[l]&&this.currentFilters[l].length>0;i.classList.toggle("ln-filter-active",!!o)}},s.prototype._renderRows=function(){if(!this.tbody)return;const e=this._data,t=this._lastTotal,n=this._lastFiltered;if(t===0){this._disableVirtualScroll(),this._showEmptyState(this.name+"-empty");return}if(e.length===0||n===0){this._disableVirtualScroll(),this._showEmptyState(this.name+"-empty-filtered");return}e.length>200?(this._enableVirtualScroll(),this._renderVirtual()):(this._disableVirtualScroll(),this._renderAll())},s.prototype._renderAll=function(){const e=this._data,t=document.createDocumentFragment();for(let n=0;n<e.length;n++){const l=this._buildRow(e[n]);if(!l)break;t.appendChild(l)}this.tbody.textContent="",this.tbody.appendChild(t),this._selectable&&this._updateSelectAll()},s.prototype._buildRow=function(e){const t=k(this.dom,this.name+"-row","ln-data-table");if(!t)return null;const n=t.querySelector("[data-ln-row]")||t.firstElementChild;if(!n)return null;if(this._fillRow(n,e),n._lnRecord=e,e.id!=null&&n.setAttribute("data-ln-row-id",e.id),this._selectable&&e.id!=null&&this.selectedIds.has(String(e.id))){n.classList.add("ln-row-selected");const l=n.querySelector("[data-ln-row-select]");l&&(l.checked=!0)}return n},s.prototype._enableVirtualScroll=function(){if(this._virtual)return;this._virtual=!0,this._vStart=-1,this._vEnd=-1;const e=this;if(!this._rowHeight){const n=this._buildRow(this._data[0]);n&&(this.tbody.textContent="",this.tbody.appendChild(n),this._rowHeight=n.offsetHeight||40,this.tbody.textContent="")}this._scrollContainer=u(this.dom);const t=this._scrollContainer||window;this._scrollHandler=function(){e._rafId||(e._rafId=requestAnimationFrame(function(){e._rafId=null,e._renderVirtual()}))},t.addEventListener("scroll",this._scrollHandler,{passive:!0}),window.addEventListener("resize",this._scrollHandler,{passive:!0})},s.prototype._disableVirtualScroll=function(){this._virtual&&(this._virtual=!1,this._scrollHandler&&((this._scrollContainer||window).removeEventListener("scroll",this._scrollHandler),window.removeEventListener("resize",this._scrollHandler),this._scrollHandler=null),this._scrollContainer=null,this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._vStart=-1,this._vEnd=-1)},s.prototype._renderVirtual=function(){const e=this._data,t=e.length,n=this._rowHeight;if(!n||!t)return;const l=this.thead?this.thead.offsetHeight:0,i=this._scrollContainer;let o,c;if(i){const h=this.table.getBoundingClientRect(),_=i.getBoundingClientRect(),A=h.top-_.top+i.scrollTop+l;o=i.scrollTop-A,c=i.clientHeight}else{const A=this.table.getBoundingClientRect().top+window.scrollY+l;o=window.scrollY-A,c=window.innerHeight}let d=Math.max(0,Math.floor(o/n)-15);d=Math.min(d,t);const b=Math.min(d+Math.ceil(c/n)+30,t);if(d===this._vStart&&b===this._vEnd)return;this._vStart=d,this._vEnd=b;const g=this.ths.length||1,E=d*n,C=(t-b)*n,v=document.createDocumentFragment();if(E>0){const h=document.createElement("tr");h.className="ln-data-table__spacer",h.setAttribute("aria-hidden","true");const _=document.createElement("td");_.setAttribute("colspan",g),_.style.height=E+"px",h.appendChild(_),v.appendChild(h)}for(let h=d;h<b;h++){const _=this._buildRow(e[h]);_&&v.appendChild(_)}if(C>0){const h=document.createElement("tr");h.className="ln-data-table__spacer",h.setAttribute("aria-hidden","true");const _=document.createElement("td");_.setAttribute("colspan",g),_.style.height=C+"px",h.appendChild(_),v.appendChild(h)}this.tbody.textContent="",this.tbody.appendChild(v),this._selectable&&this._updateSelectAll()},s.prototype._fillRow=function(e,t){T(e,t);const n=e.querySelectorAll("[data-ln-cell-attr]");for(let l=0;l<n.length;l++){const i=n[l],o=i.getAttribute("data-ln-cell-attr").split(",");for(let c=0;c<o.length;c++){const d=o[c].trim().split(":");if(d.length!==2)continue;const b=d[0].trim(),g=d[1].trim();t[b]!=null&&i.setAttribute(g,t[b])}}},s.prototype._showEmptyState=function(e){const t=k(this.dom,e,"ln-data-table");this.tbody.textContent="",t&&this.tbody.appendChild(t)},s.prototype._updateFooter=function(){const e=this._lastTotal,t=this._lastFiltered,n=t<e;if(this._totalSpan&&(this._totalSpan.textContent=m(e)),this._filteredSpan&&(this._filteredSpan.textContent=n?m(t):""),this._filteredWrap&&this._filteredWrap.classList.toggle("hidden",!n),this._selectedSpan){const l=this.selectedIds.size;this._selectedSpan.textContent=l>0?m(l):"",this._selectedWrap&&this._selectedWrap.classList.toggle("hidden",l===0)}},s.prototype.destroy=function(){this.dom[r]&&(this.dom.removeEventListener("ln-data-table:set-data",this._onSetData),this.dom.removeEventListener("ln-data-table:set-loading",this._onSetLoading),this.thead&&(this.thead.removeEventListener("click",this._onSortClick),this.thead.removeEventListener("click",this._onFilterClick)),document.removeEventListener("click",this._onDocClick),document.removeEventListener("keydown",this._onKeydown),this._searchInput&&this._searchInput.removeEventListener("input",this._onSearchInput),this.tbody&&(this.tbody.removeEventListener("click",this._onRowClick),this.tbody.removeEventListener("click",this._onRowAction)),this._onSelectionChange&&this.tbody&&this.tbody.removeEventListener("change",this._onSelectionChange),this._selectAllCheckbox&&this._onSelectAll&&this._selectAllCheckbox.removeEventListener("change",this._onSelectAll),this.dom.removeEventListener("click",this._onClearAll),this._closeFilterDropdown(),this._disableVirtualScroll(),this._data=[],delete this.dom[r])};function p(e,t){const n=e[r];if(n&&t==="data-ln-data-table-selectable"){const l=e.hasAttribute("data-ln-data-table-selectable");l!==n._selectable&&(n._selectable=l,l?n._enableSelection():n._disableSelection())}}O(a,r,s,"ln-data-table",{extraAttributes:["data-ln-data-table-selectable"],onAttributeChange:p})})()})();
|
|
1
|
+
(function(){"use strict";const x={};function F(o,r){x[o]||(x[o]=document.querySelector('[data-ln-template="'+o+'"]'));const _=x[o];return _?_.content.cloneNode(!0):(console.warn("["+r+'] Template "'+o+'" not found'),null)}function w(o,r,_){o.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:_||{}}))}function D(o,r){if(!o||!r)return o;const _=o.querySelectorAll("[data-ln-field]");for(let u=0;u<_.length;u++){const a=_[u],g=a.getAttribute("data-ln-field");r[g]!=null&&(a.textContent=r[g])}const y=o.querySelectorAll("[data-ln-attr]");for(let u=0;u<y.length;u++){const a=y[u],g=a.getAttribute("data-ln-attr").split(",");for(let e=0;e<g.length;e++){const t=g[e].trim().split(":");if(t.length!==2)continue;const n=t[0].trim(),l=t[1].trim();r[l]!=null&&a.setAttribute(n,r[l])}}const v=o.querySelectorAll("[data-ln-show]");for(let u=0;u<v.length;u++){const a=v[u],g=a.getAttribute("data-ln-show");g in r&&a.classList.toggle("hidden",!r[g])}const m=o.querySelectorAll("[data-ln-class]");for(let u=0;u<m.length;u++){const a=m[u],g=a.getAttribute("data-ln-class").split(",");for(let e=0;e<g.length;e++){const t=g[e].trim().split(":");if(t.length!==2)continue;const n=t[0].trim(),l=t[1].trim();l in r&&a.classList.toggle(n,!!r[l])}}return o}function T(o,r){if(!o||!r)return o;const _=document.createTreeWalker(o,NodeFilter.SHOW_TEXT);for(;_.nextNode();){const y=_.currentNode;y.textContent.indexOf("{{")!==-1&&(y.textContent=y.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(v,m){return r[m]!==void 0?r[m]:""}))}return o}function R(o,r){if(!document.body){document.addEventListener("DOMContentLoaded",function(){R(o,r)}),console.warn("["+r+'] Script loaded before <body> — add "defer" to your <script> tag');return}o()}function E(o,r,_){if(o){const y=o.querySelector('[data-ln-template="'+r+'"]');if(y)return y.content.cloneNode(!0)}return F(r,_)}function I(o,r,_,y){if(o.nodeType!==1)return;const m=r.indexOf("[")!==-1||r.indexOf(".")!==-1||r.indexOf("#")!==-1?r:"["+r+"]",u=Array.from(o.querySelectorAll(m));o.matches&&o.matches(m)&&u.push(o);for(const a of u)a[_]||(a[_]=new y(a))}function O(o,r,_,y,v={}){const m=v.extraAttributes||[],u=v.onAttributeChange||null,a=v.onInit||null;function g(e){const t=e||document.body;I(t,o,r,_),a&&a(t)}return R(function(){const e=new MutationObserver(function(n){for(let l=0;l<n.length;l++){const i=n[l];if(i.type==="childList"){for(let s=0;s<i.addedNodes.length;s++){const c=i.addedNodes[s];c.nodeType===1&&(I(c,o,r,_),a&&a(c))}for(let s=0;s<i.removedNodes.length;s++){const c=i.removedNodes[s];if(c.nodeType===1){const f=o.indexOf("[")!==-1||o.indexOf(".")!==-1||o.indexOf("#")!==-1?o:"["+o+"]",p=Array.from(c.querySelectorAll(f));c.matches&&c.matches(f)&&p.push(c);for(let A=0;A<p.length;A++){const S=p[A][r];S&&typeof S.destroy=="function"&&S.destroy()}}}}else i.type==="attributes"&&(u&&i.target[r]?u(i.target,i.attributeName):(I(i.target,o,r,_),a&&a(i.target)))}});let t=[];if(o.indexOf("[")!==-1){const n=/\[([\w-]+)/g;let l;for(;(l=n.exec(o))!==null;)t.push(l[1])}else t.push(o);e.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:t.concat(m)})},y),window[r]=g,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){g(document.body)}):g(document.body),g}const q={};function H(o,r){q[o]=r}function N(o){return q[o]||{ingress:r=>r,egress:r=>r}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=H,window.lnCore.getDataMapper=N),(function(){const o="data-ln-data-table",r="lnDataTable";if(window[r]!==void 0)return;const v=typeof Intl<"u"?new Intl.NumberFormat(document.documentElement.lang||void 0):null;function m(e){return v?v.format(e):String(e)}function u(e){let t=e.parentElement;for(;t&&t!==document.body&&t!==document.documentElement;){const l=getComputedStyle(t).overflowY;if(l==="auto"||l==="scroll")return t;t=t.parentElement}return null}function a(e){this.dom=e,this.name=e.getAttribute(o)||"",this.table=e.querySelector("table"),this.tbody=e.querySelector("[data-ln-data-table-body]")||e.querySelector("tbody"),this.thead=e.querySelector("thead"),this.ths=this.thead?Array.from(this.thead.querySelectorAll("th")):[],this.isLoaded=!1,this.totalCount=0,this.visibleCount=0,this.currentSort=null,this.currentFilters={},this.currentSearch="",this.selectedIds=new Set,this._data=[],this._lastTotal=0,this._lastFiltered=0,this._filterOptions={},this._filterableFields=this.ths.filter(function(n){return n.getAttribute("data-ln-col")&&n.querySelector("[data-ln-col-filter]")}).map(function(n){return n.getAttribute("data-ln-col")}),this._virtual=!1,this._rowHeight=0,this._vStart=-1,this._vEnd=-1,this._rafId=null,this._scrollHandler=null,this._scrollContainer=null,this._totalSpan=e.querySelector("[data-ln-data-table-total]"),this._filteredSpan=e.querySelector("[data-ln-data-table-filtered]"),this._filteredSpan&&(this._filteredWrap=this._filteredSpan.parentElement!==e?this._filteredSpan.closest("[data-ln-data-table-filtered-wrap]")||this._filteredSpan.parentNode:null),this._selectedSpan=e.querySelector("[data-ln-data-table-selected]"),this._selectedSpan&&(this._selectedWrap=this._selectedSpan.parentElement!==e?this._selectedSpan.closest("[data-ln-data-table-selected-wrap]")||this._selectedSpan.parentNode:null);const t=this;return this._onSetData=function(n){const l=n.detail||{};t._data=l.data||[],t._lastTotal=l.total!=null?l.total:t._data.length,t._lastFiltered=l.filtered!=null?l.filtered:t._data.length,t.totalCount=t._lastTotal,t.visibleCount=t._lastFiltered,t.isLoaded=!0,t._updateFilterOptions(l.filterOptions),t._vStart=-1,t._vEnd=-1,t._renderRows(),t._updateFooter(),w(e,"ln-data-table:rendered",{table:t.name,total:t.totalCount,visible:t.visibleCount})},e.addEventListener("ln-data-table:set-data",this._onSetData),this._onSetLoading=function(n){const l=n.detail&&n.detail.loading;e.classList.toggle("ln-data-table--loading",!!l),l&&(t.isLoaded=!1)},e.addEventListener("ln-data-table:set-loading",this._onSetLoading),this._sortButtons=Array.from(e.querySelectorAll("[data-ln-col-sort]")),this._onSortClick=function(n){const l=n.target.closest("[data-ln-col-sort]");if(!l)return;const i=l.closest("th");if(!i)return;const s=i.getAttribute("data-ln-col");s&&t._handleSort(s,i)},this.thead&&this.thead.addEventListener("click",this._onSortClick),this._activeDropdown=null,this._onFilterClick=function(n){const l=n.target.closest("[data-ln-col-filter]");if(!l)return;n.stopPropagation();const i=l.closest("th");if(!i)return;const s=i.getAttribute("data-ln-col");if(s){if(t._activeDropdown&&t._activeDropdown.field===s){t._closeFilterDropdown();return}t._openFilterDropdown(s,i,l)}},this.thead&&this.thead.addEventListener("click",this._onFilterClick),this._onDocClick=function(){t._activeDropdown&&t._closeFilterDropdown()},document.addEventListener("click",this._onDocClick),this._onClearAll=function(n){n.target.closest("[data-ln-data-table-clear-all]")&&(t.currentFilters={},t._updateFilterIndicators(),w(e,"ln-data-table:clear-filters",{table:t.name}),t._requestData())},e.addEventListener("click",this._onClearAll),this._selectable=e.hasAttribute("data-ln-data-table-selectable"),this._selectableActive=!1,this._selectable&&this._enableSelection(),this._onRowClick=function(n){if(n.target.closest("[data-ln-row-select]")||n.target.closest("[data-ln-row-action]")||n.target.closest("a")||n.target.closest("button")||n.ctrlKey||n.metaKey||n.button===1)return;const l=n.target.closest("[data-ln-row]");if(!l)return;const i=l.getAttribute("data-ln-row-id"),s=l._lnRecord||{};w(e,"ln-data-table:row-click",{table:t.name,id:i,record:s})},this.tbody&&this.tbody.addEventListener("click",this._onRowClick),this._onRowAction=function(n){const l=n.target.closest("[data-ln-row-action]");if(!l)return;n.stopPropagation();const i=l.closest("[data-ln-row]");if(!i)return;const s=l.getAttribute("data-ln-row-action"),c=i.getAttribute("data-ln-row-id"),d=i._lnRecord||{};w(e,"ln-data-table:row-action",{table:t.name,id:c,action:s,record:d})},this.tbody&&this.tbody.addEventListener("click",this._onRowAction),this._searchInput=e.querySelector("[data-ln-data-table-search]"),this._searchInput&&(this._onSearchInput=function(){t.currentSearch=t._searchInput.value,w(e,"ln-data-table:search",{table:t.name,query:t.currentSearch}),t._requestData()},this._searchInput.addEventListener("input",this._onSearchInput)),this._focusedRowIndex=-1,this._onKeydown=function(n){if(!e.contains(document.activeElement)&&document.activeElement!==document.body||document.activeElement&&(document.activeElement.tagName==="INPUT"||document.activeElement.tagName==="TEXTAREA"))return;if(n.key==="/"){t._searchInput&&(n.preventDefault(),t._searchInput.focus());return}const l=t.tbody?Array.from(t.tbody.querySelectorAll("[data-ln-row]")):[];if(l.length)switch(n.key){case"ArrowDown":n.preventDefault(),t._focusedRowIndex=Math.min(t._focusedRowIndex+1,l.length-1),t._focusRow(l);break;case"ArrowUp":n.preventDefault(),t._focusedRowIndex=Math.max(t._focusedRowIndex-1,0),t._focusRow(l);break;case"Home":n.preventDefault(),t._focusedRowIndex=0,t._focusRow(l);break;case"End":n.preventDefault(),t._focusedRowIndex=l.length-1,t._focusRow(l);break;case"Enter":if(t._focusedRowIndex>=0&&t._focusedRowIndex<l.length){n.preventDefault();const i=l[t._focusedRowIndex];w(e,"ln-data-table:row-click",{table:t.name,id:i.getAttribute("data-ln-row-id"),record:i._lnRecord||{}})}break;case" ":if(t._selectable&&t._focusedRowIndex>=0&&t._focusedRowIndex<l.length){n.preventDefault();const i=l[t._focusedRowIndex].querySelector("[data-ln-row-select]");i&&(i.checked=!i.checked,i.dispatchEvent(new Event("change",{bubbles:!0})))}break;case"Escape":t._activeDropdown&&t._closeFilterDropdown();break}},document.addEventListener("keydown",this._onKeydown),w(e,"ln-data-table:request-data",{table:this.name,sort:this.currentSort,filters:this.currentFilters,search:this.currentSearch}),this}a.prototype._handleSort=function(e,t){let n;!this.currentSort||this.currentSort.field!==e?n="asc":this.currentSort.direction==="asc"?n="desc":n=null;for(let l=0;l<this.ths.length;l++)this.ths[l].classList.remove("ln-sort-asc","ln-sort-desc");n?(this.currentSort={field:e,direction:n},t.classList.add(n==="asc"?"ln-sort-asc":"ln-sort-desc")):this.currentSort=null,w(this.dom,"ln-data-table:sort",{table:this.name,field:e,direction:n}),this._requestData()},a.prototype._requestData=function(){w(this.dom,"ln-data-table:request-data",{table:this.name,sort:this.currentSort,filters:this.currentFilters,search:this.currentSearch})},a.prototype._updateSelectAll=function(){if(!this._selectAllCheckbox||!this.tbody)return;const e=this.tbody.querySelectorAll("[data-ln-row]");let t=e.length>0;for(let n=0;n<e.length;n++){const l=e[n].getAttribute("data-ln-row-id");if(l!=null&&!this.selectedIds.has(l)){t=!1;break}}this._selectAllCheckbox.checked=t},Object.defineProperty(a.prototype,"selectedCount",{get:function(){return this.selectedIds.size},set:function(){}}),a.prototype._enableSelection=function(){if(this._selectableActive)return;this._selectableActive=!0;const e=this;if(this._onSelectionChange=function(t){const n=t.target.closest("[data-ln-row-select]");if(!n)return;const l=n.closest("[data-ln-row]");if(!l)return;const i=l.getAttribute("data-ln-row-id");i!=null&&(n.checked?(e.selectedIds.add(i),l.classList.add("ln-row-selected")):(e.selectedIds.delete(i),l.classList.remove("ln-row-selected")),e.selectedCount=e.selectedIds.size,e._updateSelectAll(),e._updateFooter(),w(e.dom,"ln-data-table:select",{table:e.name,selectedIds:e.selectedIds,count:e.selectedCount}))},this.tbody&&this.tbody.addEventListener("change",this._onSelectionChange),this._selectAllCheckbox=this.dom.querySelector('[data-ln-col-select] input[type="checkbox"]')||this.dom.querySelector("[data-ln-col-select]"),this._selectAllCheckbox&&this._selectAllCheckbox.tagName==="TH"){const t=document.createElement("input");t.type="checkbox",t.setAttribute("aria-label","Select all"),this._selectAllCheckbox.appendChild(t),this._selectAllCheckbox=t}if(this._selectAllCheckbox&&(this._onSelectAll=function(){const t=e._selectAllCheckbox.checked,n=e.tbody?e.tbody.querySelectorAll("[data-ln-row]"):[];for(let l=0;l<n.length;l++){const i=n[l].getAttribute("data-ln-row-id"),s=n[l].querySelector("[data-ln-row-select]");i!=null&&(t?(e.selectedIds.add(i),n[l].classList.add("ln-row-selected")):(e.selectedIds.delete(i),n[l].classList.remove("ln-row-selected")),s&&(s.checked=t))}e.selectedCount=e.selectedIds.size,w(e.dom,"ln-data-table:select-all",{table:e.name,selected:t}),w(e.dom,"ln-data-table:select",{table:e.name,selectedIds:e.selectedIds,count:e.selectedCount}),e._updateFooter()},this._selectAllCheckbox.addEventListener("change",this._onSelectAll)),this.tbody){const t=this.tbody.querySelectorAll("[data-ln-row]");for(let n=0;n<t.length;n++){const l=t[n].querySelector("[data-ln-row-select]"),i=t[n].getAttribute("data-ln-row-id");l&&l.checked&&i!=null&&(this.selectedIds.add(i),t[n].classList.add("ln-row-selected"))}this.selectedCount=this.selectedIds.size,this.selectedCount>0&&this._updateSelectAll()}},a.prototype._disableSelection=function(){if(!this._selectableActive)return;this._selectableActive=!1,this.tbody&&this._onSelectionChange&&this.tbody.removeEventListener("change",this._onSelectionChange),this._selectAllCheckbox&&this._onSelectAll&&this._selectAllCheckbox.removeEventListener("change",this._onSelectAll);const e=this.dom.querySelector("[data-ln-col-select]");if(e){const t=e.querySelector('input[type="checkbox"]');t&&t.remove()}if(this._selectAllCheckbox=null,this.selectedIds.clear(),this.selectedCount=0,this.tbody){const t=this.tbody.querySelectorAll("[data-ln-row]");for(let n=0;n<t.length;n++){t[n].classList.remove("ln-row-selected");const l=t[n].querySelector("[data-ln-row-select]");l&&(l.checked=!1)}}this._updateFooter()},a.prototype._focusRow=function(e){for(let t=0;t<e.length;t++)e[t].classList.remove("ln-row-focused"),e[t].removeAttribute("tabindex");if(this._focusedRowIndex>=0&&this._focusedRowIndex<e.length){const t=e[this._focusedRowIndex];t.classList.add("ln-row-focused"),t.setAttribute("tabindex","0"),t.focus(),t.scrollIntoView({block:"nearest"})}},a.prototype._openFilterDropdown=function(e,t,n){this._closeFilterDropdown();const l=E(this.dom,this.name+"-column-filter","ln-data-table")||E(this.dom,"column-filter","ln-data-table");if(!l)return;const i=l.firstElementChild;if(!i)return;const s=this._getUniqueValues(e),c=i.querySelector("[data-ln-filter-options]"),d=i.querySelector("[data-ln-filter-search]"),f=this.currentFilters[e]||[],p=this;if(d&&s.length<=8&&d.classList.add("hidden"),c){const S=c.querySelector("[data-ln-filter-reset]");S&&(S.checked=f.length===0);const C=E(i,this.name+"-column-filter-item","ln-data-table")||E(i,"column-filter-item","ln-data-table");if(C)for(let h=0;h<s.length;h++){const b=s[h],k=C.cloneNode(!0);D(k,{value:b});const L=k.querySelector('input[type="checkbox"]');L&&(L.value=b,L.checked=f.length>0&&f.indexOf(b)!==-1),c.appendChild(k)}c.addEventListener("change",function(h){h.target.type==="checkbox"&&(p._applyFilterMutualExclusion(h.target,c),p._onFilterChange(e,c))})}d&&d.addEventListener("input",function(){const S=d.value.toLowerCase(),C=c.querySelectorAll("li");for(let h=0;h<C.length;h++){const b=C[h].textContent.toLowerCase();C[h].classList.toggle("hidden",S&&b.indexOf(S)===-1)}});const A=i.querySelector("[data-ln-filter-clear]");A&&A.addEventListener("click",function(){delete p.currentFilters[e],p._closeFilterDropdown(),p._updateFilterIndicators(),w(p.dom,"ln-data-table:filter",{table:p.name,field:e,values:[]}),p._requestData()}),t.appendChild(i),this._activeDropdown={field:e,th:t,el:i},i.addEventListener("click",function(S){S.stopPropagation()})},a.prototype._closeFilterDropdown=function(){this._activeDropdown&&(this._activeDropdown.el&&this._activeDropdown.el.parentNode&&this._activeDropdown.el.parentNode.removeChild(this._activeDropdown.el),this._activeDropdown=null)},a.prototype._applyFilterMutualExclusion=function(e,t){const n=e.hasAttribute("data-ln-filter-reset"),l=t.querySelector("[data-ln-filter-reset]"),i=t.querySelectorAll('input[type="checkbox"]:not([data-ln-filter-reset])');if(n){e.checked=!0;for(let s=0;s<i.length;s++)i[s].checked=!1}else if(e.checked)l&&(l.checked=!1);else{let s=!1;for(let c=0;c<i.length;c++)if(i[c].checked){s=!0;break}!s&&l&&(l.checked=!0)}},a.prototype._onFilterChange=function(e,t){const n=t.querySelector("[data-ln-filter-reset]"),l=t.querySelectorAll('input[type="checkbox"]:not([data-ln-filter-reset])'),i=[];for(let c=0;c<l.length;c++)l[c].checked&&i.push(l[c].value);const s=n&&n.checked||i.length===0;s?delete this.currentFilters[e]:this.currentFilters[e]=i,this._updateFilterIndicators(),w(this.dom,"ln-data-table:filter",{table:this.name,field:e,values:s?[]:i}),this._requestData()},a.prototype._updateFilterOptions=function(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)){const t=Object.keys(e);for(let n=0;n<t.length;n++){const l=t[n],i=e[l];if(!Array.isArray(i))continue;const s={},c=[];for(let d=0;d<i.length;d++){const f=String(i[d]);s[f]||(s[f]=!0,c.push(f))}this._filterOptions[l]=c.sort()}}else{const t=this._filterableFields,n=this._data;for(let l=0;l<t.length;l++){const i=t[l];this._filterOptions[i]||(this._filterOptions[i]=[]);const s=this._filterOptions[i],c={};for(let d=0;d<s.length;d++)c[s[d]]=!0;for(let d=0;d<n.length;d++){const f=n[d][i];if(f!=null){const p=String(f);c[p]||(c[p]=!0,s.push(p))}}s.sort()}}},a.prototype._getUniqueValues=function(e){return(this._filterOptions[e]||[]).slice().sort()},a.prototype._updateFilterIndicators=function(){const e=this.ths;for(let t=0;t<e.length;t++){const n=e[t],l=n.getAttribute("data-ln-col");if(!l)continue;const i=n.querySelector("[data-ln-col-filter]");if(!i)continue;const s=this.currentFilters[l]&&this.currentFilters[l].length>0;i.classList.toggle("ln-filter-active",!!s)}},a.prototype._renderRows=function(){if(!this.tbody)return;const e=this._data,t=this._lastTotal,n=this._lastFiltered;if(t===0){this._disableVirtualScroll(),this._showEmptyState(this.name+"-empty");return}if(e.length===0||n===0){this._disableVirtualScroll(),this._showEmptyState(this.name+"-empty-filtered");return}e.length>200?(this._enableVirtualScroll(),this._renderVirtual()):(this._disableVirtualScroll(),this._renderAll())},a.prototype._renderAll=function(){const e=this._data,t=document.createDocumentFragment();for(let n=0;n<e.length;n++){const l=this._buildRow(e[n]);if(!l)break;t.appendChild(l)}this.tbody.textContent="",this.tbody.appendChild(t),this._selectable&&this._updateSelectAll()},a.prototype._buildRow=function(e){const t=E(this.dom,this.name+"-row","ln-data-table");if(!t)return null;const n=t.querySelector("[data-ln-row]")||t.firstElementChild;if(!n)return null;if(this._fillRow(n,e),n._lnRecord=e,e.id!=null&&n.setAttribute("data-ln-row-id",e.id),this._selectable&&e.id!=null&&this.selectedIds.has(String(e.id))){n.classList.add("ln-row-selected");const l=n.querySelector("[data-ln-row-select]");l&&(l.checked=!0)}return n},a.prototype._enableVirtualScroll=function(){if(this._virtual)return;this._virtual=!0,this._vStart=-1,this._vEnd=-1;const e=this;if(!this._rowHeight){const n=this._buildRow(this._data[0]);n&&(this.tbody.textContent="",this.tbody.appendChild(n),this._rowHeight=n.offsetHeight||40,this.tbody.textContent="")}this._scrollContainer=u(this.dom);const t=this._scrollContainer||window;this._scrollHandler=function(){e._rafId||(e._rafId=requestAnimationFrame(function(){e._rafId=null,e._renderVirtual()}))},t.addEventListener("scroll",this._scrollHandler,{passive:!0}),window.addEventListener("resize",this._scrollHandler,{passive:!0})},a.prototype._disableVirtualScroll=function(){this._virtual&&(this._virtual=!1,this._scrollHandler&&((this._scrollContainer||window).removeEventListener("scroll",this._scrollHandler),window.removeEventListener("resize",this._scrollHandler),this._scrollHandler=null),this._scrollContainer=null,this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._vStart=-1,this._vEnd=-1)},a.prototype._renderVirtual=function(){const e=this._data,t=e.length,n=this._rowHeight;if(!n||!t)return;const l=this.thead?this.thead.offsetHeight:0,i=this._scrollContainer;let s,c;if(i){const h=this.table.getBoundingClientRect(),b=i.getBoundingClientRect(),k=h.top-b.top+i.scrollTop+l;s=i.scrollTop-k,c=i.clientHeight}else{const k=this.table.getBoundingClientRect().top+window.scrollY+l;s=window.scrollY-k,c=window.innerHeight}let d=Math.max(0,Math.floor(s/n)-15);d=Math.min(d,t);const f=Math.min(d+Math.ceil(c/n)+30,t);if(d===this._vStart&&f===this._vEnd)return;this._vStart=d,this._vEnd=f;const p=this.ths.length||1,A=d*n,S=(t-f)*n,C=document.createDocumentFragment();if(A>0){const h=document.createElement("tr");h.className="ln-data-table__spacer",h.setAttribute("aria-hidden","true");const b=document.createElement("td");b.setAttribute("colspan",p),b.style.height=A+"px",h.appendChild(b),C.appendChild(h)}for(let h=d;h<f;h++){const b=this._buildRow(e[h]);b&&C.appendChild(b)}if(S>0){const h=document.createElement("tr");h.className="ln-data-table__spacer",h.setAttribute("aria-hidden","true");const b=document.createElement("td");b.setAttribute("colspan",p),b.style.height=S+"px",h.appendChild(b),C.appendChild(h)}this.tbody.textContent="",this.tbody.appendChild(C),this._selectable&&this._updateSelectAll()},a.prototype._fillRow=function(e,t){T(e,t);const n=e.querySelectorAll("[data-ln-cell-attr]");for(let l=0;l<n.length;l++){const i=n[l],s=i.getAttribute("data-ln-cell-attr").split(",");for(let c=0;c<s.length;c++){const d=s[c].trim().split(":");if(d.length!==2)continue;const f=d[0].trim(),p=d[1].trim();t[f]!=null&&i.setAttribute(p,t[f])}}},a.prototype._showEmptyState=function(e){const t=E(this.dom,e,"ln-data-table");this.tbody.textContent="",t&&this.tbody.appendChild(t)},a.prototype._updateFooter=function(){const e=this._lastTotal,t=this._lastFiltered,n=t<e;if(this._totalSpan&&(this._totalSpan.textContent=m(e)),this._filteredSpan&&(this._filteredSpan.textContent=n?m(t):""),this._filteredWrap&&this._filteredWrap.classList.toggle("hidden",!n),this._selectedSpan){const l=this.selectedIds.size;this._selectedSpan.textContent=l>0?m(l):"",this._selectedWrap&&this._selectedWrap.classList.toggle("hidden",l===0)}},a.prototype.destroy=function(){this.dom[r]&&(this.dom.removeEventListener("ln-data-table:set-data",this._onSetData),this.dom.removeEventListener("ln-data-table:set-loading",this._onSetLoading),this.thead&&(this.thead.removeEventListener("click",this._onSortClick),this.thead.removeEventListener("click",this._onFilterClick)),document.removeEventListener("click",this._onDocClick),document.removeEventListener("keydown",this._onKeydown),this._searchInput&&this._searchInput.removeEventListener("input",this._onSearchInput),this.tbody&&(this.tbody.removeEventListener("click",this._onRowClick),this.tbody.removeEventListener("click",this._onRowAction)),this._onSelectionChange&&this.tbody&&this.tbody.removeEventListener("change",this._onSelectionChange),this._selectAllCheckbox&&this._onSelectAll&&this._selectAllCheckbox.removeEventListener("change",this._onSelectAll),this.dom.removeEventListener("click",this._onClearAll),this._closeFilterDropdown(),this._disableVirtualScroll(),this._data=[],delete this.dom[r])};function g(e,t){const n=e[r];if(n&&t==="data-ln-data-table-selectable"){const l=e.hasAttribute("data-ln-data-table-selectable");l!==n._selectable&&(n._selectable=l,l?n._enableSelection():n._disableSelection())}}O(o,r,a,"ln-data-table",{extraAttributes:["data-ln-data-table-selectable"],onAttributeChange:g})})()})();
|