@livenetworks/ashlar 2.1.10 → 2.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/components/COMPONENTS.md +1 -1
  2. package/components/ln-accordion/ln-accordion.js +1 -1
  3. package/components/ln-ajax/ln-ajax.js +1 -1
  4. package/components/ln-api-connector/ln-api-connector.js +1 -1
  5. package/components/ln-api-queue/ln-api-queue.js +1 -1
  6. package/components/ln-autosave/ln-autosave.js +1 -1
  7. package/components/ln-chart/ln-chart.js +1 -1
  8. package/components/ln-circular-progress/ln-circular-progress.js +1 -1
  9. package/components/ln-confirm/ln-confirm.js +1 -1
  10. package/components/ln-core/events.js +5 -2
  11. package/components/ln-core/lifecycle.js +25 -44
  12. package/components/ln-couchdb-connector/ln-couchdb-connector.js +1 -1
  13. package/components/ln-data-coordinator/ln-data-coordinator.js +1 -1
  14. package/components/ln-data-store/README.md +19 -0
  15. package/components/ln-data-store/ln-data-store.js +1 -1
  16. package/components/ln-data-store/ln-data-store.schema.json +92 -84
  17. package/components/ln-data-store/src/data-store-model.js +17 -0
  18. package/components/ln-data-store/src/ln-data-store.js +77 -1
  19. package/components/ln-date/ln-date.js +1 -1
  20. package/components/ln-debug/ln-debug.js +1 -1
  21. package/components/ln-debug/ln-debug.schema.json +28 -28
  22. package/components/ln-debug/src/debug-verifier.js +24 -30
  23. package/components/ln-debug/src/generated-attributes.js +1 -3
  24. package/components/ln-debug/src/ln-debug.js +3 -11
  25. package/components/ln-dropdown/ln-dropdown.js +1 -1
  26. package/components/ln-editor/ln-editor.js +1 -1
  27. package/components/ln-external-links/ln-external-links.js +1 -1
  28. package/components/ln-filter/ln-filter.js +1 -1
  29. package/components/ln-form/ln-form.js +1 -1
  30. package/components/ln-icon/ln-icon.js +1 -1
  31. package/components/ln-include/ln-include.js +1 -1
  32. package/components/ln-key/ln-key.js +1 -1
  33. package/components/ln-link/ln-link.js +1 -1
  34. package/components/ln-list/ln-list.js +1 -1
  35. package/components/ln-modal/ln-modal.js +1 -1
  36. package/components/ln-nav/ln-nav.js +1 -1
  37. package/components/ln-number/ln-number.js +1 -1
  38. package/components/ln-obfuscator/ln-obfuscator.js +1 -1
  39. package/components/ln-options/ln-options.js +1 -1
  40. package/components/ln-persist/ln-persist.js +1 -1
  41. package/components/ln-picklist/ln-picklist.js +1 -1
  42. package/components/ln-popover/ln-popover.js +1 -1
  43. package/components/ln-progress/ln-progress.js +1 -1
  44. package/components/ln-router/ln-router.js +1 -1
  45. package/components/ln-scroll/ln-scroll.js +1 -1
  46. package/components/ln-search/ln-search.js +1 -1
  47. package/components/ln-slug/ln-slug.js +1 -1
  48. package/components/ln-sort/ln-sort.js +1 -1
  49. package/components/ln-sortable/ln-sortable.js +1 -1
  50. package/components/ln-stat/ln-stat.js +1 -1
  51. package/components/ln-table/README.md +69 -38
  52. package/components/ln-table/ln-table.js +1 -1
  53. package/components/ln-table/ln-table.schema.json +11 -35
  54. package/components/ln-table/src/ln-table.js +306 -414
  55. package/components/ln-table/src/table-model.js +31 -0
  56. package/components/ln-table-coordinator/ln-table-coordinator.js +1 -1
  57. package/components/ln-tabs/ln-tabs.js +1 -1
  58. package/components/ln-time/ln-time.js +1 -1
  59. package/components/ln-toast/ln-toast.js +1 -1
  60. package/components/ln-toggle/ln-toggle.js +1 -1
  61. package/components/ln-tooltip/ln-tooltip.js +1 -1
  62. package/components/ln-translations/ln-translations.js +1 -1
  63. package/components/ln-ui-coordinator/ln-ui-coordinator.js +1 -1
  64. package/components/ln-upload/ln-upload.js +1 -1
  65. package/components/ln-validate/ln-validate.js +1 -1
  66. package/components/ln-websocket-connector/ln-websocket-connector.js +1 -1
  67. package/ln-ashlar.html-data.json +7 -17
  68. package/package.json +1 -1
  69. package/theme/config/mixins/_ln-table.scss +18 -10
  70. package/theme/config/mixins/_table.scss +15 -2
  71. package/web-types.json +14 -28
@@ -1 +1 @@
1
- (function(){"use strict";function G(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function L(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let i=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){i=t[l];break}if(!L(i))return}e.apply(console,t)}}function g(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function D(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){D(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function P(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function K(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,l={},d=e.elements,c={};if(r)for(let p=0;p<d.length;p++){const a=d[p];a.name&&a.type==="checkbox"&&!a.disabled&&(c[a.name]=(c[a.name]||0)+1)}for(let p=0;p<d.length;p++){const a=d[p];if(!(!a.name||a.disabled||a.type==="file"||a.type==="submit"||a.type==="button")&&!(i&&a.matches&&a.matches(i)))if(a.type==="checkbox")r&&c[a.name]===1?l[a.name]=a.checked:(l[a.name]||(l[a.name]=[]),a.checked&&l[a.name].push(a.value));else if(a.type==="radio")a.checked&&(l[a.name]=a.value);else if(a.type==="select-multiple"){l[a.name]=[];for(let m=0;m<a.options.length;m++)a.options[m].selected&&l[a.name].push(a.options[m].value)}else if(r&&a.type==="hidden")l[a.name]=a.value;else if(r&&(a.type==="number"||a.type==="range")){const m=Number(a.value);l[a.name]=a.value===""||isNaN(m)?null:m}else l[a.name]=a.value}return l}function we(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function me(e,t){const r=e.elements,i=[],l={};for(let d=0;d<r.length;d++){const c=r[d];c.name&&c.type==="checkbox"&&(l[c.name]=(l[c.name]||0)+1)}for(let d=0;d<r.length;d++){const c=r[d];if(c.type==="file"||c.type==="submit"||c.type==="button")continue;const p=c.getAttribute("data-ln-fill-as")||c.name;if(!p||!(p in t))continue;const a=t[p];if(c.type==="checkbox"){if(Array.isArray(a))c.checked=a.indexOf(c.value)!==-1;else if(l[c.name]>1){const m=String(a).split(",").map(function(A){return A.trim()});c.checked=m.indexOf(c.value)!==-1}else c.checked=we(a);i.push(c)}else if(c.type==="radio")c.checked=c.value===String(a),i.push(c);else if(c.type==="select-multiple"){if(Array.isArray(a))for(let m=0;m<c.options.length;m++)c.options[m].selected=a.indexOf(c.options[m].value)!==-1;i.push(c)}else c.value=a,c.tagName==="SELECT"&&a!=null&&c.setAttribute("data-ln-value",a),i.push(c)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=me,window.lnCore.serializeForm=K,window.lnCore.resolveFormMethod=P);const V={};function ye(e,t){V[e]=t}function be(e){return V[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=ye,window.lnCore.getDataMapper=be);function ge(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,D(function(){new MutationObserver(function(){g(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const z={};function Ce(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];z[r]=t}function _e(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return z[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ce,window.lnCore.getLocaleFallback=_e,window.lnCore.ensureLocaleObserver=ge);const T={};function Ae(e,t){T[e]||(T[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=T[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function H(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let c=0;c<r.length;c++){const p=r[c],a=p.getAttribute("data-ln-field");t[a]!=null&&(p.textContent=t[a])}const i=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<i.length;c++){const p=i[c],a=p.getAttribute("data-ln-attr").split(",");for(let m=0;m<a.length;m++){const A=a[m].trim().split(":");if(A.length!==2)continue;const _=A[0].trim(),C=A[1].trim();t[C]!=null&&p.setAttribute(_,t[C])}}const l=e.querySelectorAll("[data-ln-show]");for(let c=0;c<l.length;c++){const p=l[c],a=p.getAttribute("data-ln-show");a in t&&p.classList.toggle("hidden",!t[a])}const d=e.querySelectorAll("[data-ln-class]");for(let c=0;c<d.length;c++){const p=d[c],a=p.getAttribute("data-ln-class").split(",");for(let m=0;m<a.length;m++){const A=a[m].trim().split(":");if(A.length!==2)continue;const _=A[0].trim(),C=A[1].trim();C in t&&p.classList.toggle(_,!!t[C])}}return e}function qe(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)H(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<t.length;r++)t[r].textContent=""}})));function J(e,t){if(!e||!t)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const d=r.currentNode;d.textContent.indexOf("{{")!==-1&&(d.textContent=d.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,p){return t[p]!==void 0?t[p]:""}))}const i=function(d,c){return t[c]!==void 0?t[c]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let d=0;d<l.length;d++){const c=l[d],p=c.attributes;for(let a=0;a<p.length;a++){const m=p[a];m.value.indexOf("{{")!==-1&&c.setAttribute(m.name,m.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function Ee(e,t,r,i,l,d){const c={};for(let a=0;a<e.children.length;a++){const m=e.children[a],A=m.getAttribute("data-ln-render-key");A&&(c[A]=m)}const p=document.createDocumentFragment();for(let a=0;a<t.length;a++){const m=t[a],A=String(i(m));let _=c[A];if(_)l(_,m,a);else{const C=Ae(r,d);if(!C||(J(C,m),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",A),l(_,m,a)}p.appendChild(_)}e.textContent="",e.appendChild(p)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=J,window.lnCore.fill=H,window.lnCore.lnFill=qe,window.lnCore.renderList=Ee);function F(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function X(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function Y(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const l=i.trim().toLowerCase();return!(l==="false"||l==="0")}function Z(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const j=new Map;function ee(e,t){const r=(e?e.join("|"):"")+"::"+t;if(j.has(r))return j.get(r);const i=new Set(e||[]),l=function(d,c){const p=d.getAttribute(c);return p!==null&&i.has(p)?p:t};return j.set(r,l),l}function te(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function ne(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function re(e,t,r,i,l){if(!e||t===null)return!0;const d=i||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const p=a=>{l?console.warn(a,l):console.warn(a)};if(c==="boolean"){const a=t.trim().toLowerCase();return a!==""&&a!=="true"&&a!=="false"&&a!=="1"&&a!=="0"?(p(`[${d}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const a=e.values||[];return a.includes(t)?!0:(p(`[${d}] Invalid value "${t}" for attribute "${r}". Allowed: ${a.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return p(`[${d}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const a=parseInt(t,10);return e.min!==void 0&&a<e.min?(p(`[${d}] Value ${a} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&a>e.max?(p(`[${d}] Value ${a} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(p(`[${d}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(a){return p(`[${d}] Invalid JSON for attribute "${r}": ${a.message}. Fallback: ${e.fallback}.`),!1}return!0}function oe(e,t,r){for(const i in r){const[l,d,c]=r[i];Object.defineProperty(e,i,{get:function(){return l(t,d,c)},enumerable:!0,configurable:!0})}return e}function ie(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let l=i.read;if(!l&&i.type)switch(i.type){case"enum":l=ee(i.values,i.fallback);break;case"integer":l=X;break;case"float":l=te;break;case"boolean":l=Y;break;case"list":l=Z;break;case"json":l=ne;break;case"string":default:l=F;break}l||(l=F),t[i.prop]=[l,r,i.fallback]}return t}function Se(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function ve(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const r in e.effects)t.add(r);if(e.onAttrChange&&e.declared)for(const r of e.declared)t.add(r);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=oe,window.lnCore.attrSpec=ie,window.lnCore.attrStr=F,window.lnCore.attrInt=X,window.lnCore.attrBool=Y,window.lnCore.attrList=Z,window.lnCore.attrEnum=ee,window.lnCore.attrFloat=te,window.lnCore.attrJson=ne);function I(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(r){console.error("["+t.attribute+"] init failed",e,r)}}}function ae(e,t,r,i){if(e.nodeType!==1)return;const d=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:r,ComponentFn:i};if(e.matches&&e.matches(d)&&I(e,c),e.querySelectorAll){const p=e.querySelectorAll(d);for(let a=0;a<p.length;a++)I(p[a],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function xe(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ke(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function le(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function Ie(e){const t=le(),r=e.observed||[];for(let i=0;i<r.length;i++){const l=r[i];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const l=t.byDeclaredAttr.get(i);l.some(d=>d.componentTag===e.componentTag)||l.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=ve(e);if(i===null)t.reactiveWildcard.push(e);else for(const l of i)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function se(e,t,r,i){for(let l=0;l<e.length;l++){const d=e[l];if(!t[d.attribute])continue;const c=d.effects&&d.effects[r];c?c(t,r,i):d.onAttrChange&&(!d.declared||d.declared.has(r))&&d.onAttrChange(t,r,i)}}function Oe(e){const t=e.attributeName,r=t.indexOf("data-ln-")===0,i=le(),l=i.byAttr.get(t),d=G()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(t);if(!r&&!l&&!d)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(d&&L(c)){const p=i.byDeclaredAttr.get(t),a=c.getAttribute(t);for(let m=0;m<p.length;m++)re(p[m].spec,a,t,p[m].componentTag,c)}if(window.lnCore._debugSink&&(r||l)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),r){const p=i.byReactive.get(t);p&&se(p,c,t,e.oldValue),i.reactiveWildcard.length&&se(i.reactiveWildcard,c,t,e.oldValue)}if(l)for(let p=0;p<l.length;p++){const a=l[p];if(a.handler){a.handler(c,t,e.oldValue);continue}a.onAttributeChange&&c[a.attribute]?a.onAttributeChange(c,t):(ae(c,a.selector,a.attribute,a.ComponentFn),a.onInit&&a.onInit(c))}}}function De(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{Oe(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function $(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function M(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function W(e,t){if(!document.contains(e))if(t.attribute){const r=e[t.attribute];if(r&&typeof r.destroy=="function")try{r.destroy()}catch(i){console.error("["+t.attribute+"] destroy failed",e,i)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function ce(e){const t=$();if(!t.length)return;const r=e.target;if(r){const l=r.nodeType===1?r:r.parentElement;if(l&&(l.isContentEditable||l.closest&&l.closest('[contenteditable]:not([contenteditable="false"])')))return}const i=M();if(e.target&&i.length)for(let l=0;l<i.length;l++){const d=i[l],c=d.query,p=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;p&&d.onSubtreeChange(p,e)}for(let l=0;l<e.addedNodes.length;l++){const d=e.addedNodes[l];if(d.nodeType===1){const c=!!(d.firstElementChild||d.children&&d.children.length);for(let p=0;p<t.length;p++){const a=t[p];if(a.selector&&a.attribute&&a.ComponentFn){if(!c)d.matches&&d.matches(a.query)&&I(d,a);else if(d.matches&&d.matches(a.query)&&I(d,a),d.querySelectorAll){const m=d.querySelectorAll(a.query);for(let A=0;A<m.length;A++)I(m[A],a)}}a.onInit&&a.onInit(d)}}}for(let l=0;l<e.removedNodes.length;l++){const d=e.removedNodes[l];if(d.nodeType===1){if(document.contains(d))continue;const c=!!(d.firstElementChild||d.children&&d.children.length);for(let p=0;p<t.length;p++){const a=t[p],m=a.query;if(m){if(!c)d.matches&&d.matches(m)&&W(d,a);else if(d.matches&&d.matches(m)&&W(d,a),d.querySelectorAll){const A=d.querySelectorAll(m);for(let _=0;_<A.length;_++)W(A[_],a)}}}}}}function de(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){const e=new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{ce(i)}catch(l){console.error("[ln-core] lifecycle handler failed",i.target,l)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Re(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const r=t.takeRecords();for(let i=0;i<r.length;i++){const l=r[i];if(l.type==="childList")try{ce(l)}catch(d){console.error("[ln-core] lifecycle handler failed",l.target,d)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function Le(e){$().push(e),e.onSubtreeChange&&e.query&&M().push(e),de()}function ue(e,t,r,i,l={}){const d=l.extraAttributes||[],c=l.onAttributeChange||null,p=l.onSubtreeChange||null,a=l.onInit||null,m=l.onAttrChange||null,A=l.effects||null,_=l.attributes||null,C=_?Se(_):A,U=_?new Set(Object.keys(_)):null,N=l.persist||null;function n(S){const E=S||document.body;if(ae(E,e,t,r),_&&G())for(const u in _){const h=_[u],y=Array.from(E.querySelectorAll("["+u+"]"));E.matches&&E.matches("["+u+"]")&&y.push(E);for(let q=0;q<y.length;q++){const v=y[q];L(v)&&re(h,v.getAttribute(u),u,i,v)}}a&&a(E)}const o=[];if(e.indexOf("[")!==-1){const S=/\[([\w-]+)/g;let E;for(;(E=S.exec(e))!==null;)o.push(E[1])}else o.push(e);Ie({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:r,onInit:a,observed:o.concat(d),onAttributeChange:c,onAttrChange:m,effects:C,declared:U,persist:N}),De();const s=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,f=l.subtreeQuery||(s?e:"["+e+"]"),w={selector:e,attribute:t,ComponentFn:r,onInit:a,onSubtreeChange:p,query:f};$().push(w),p&&f&&M().push(w),de(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ue,window.lnCore.observeLifecycle=Le,window.lnCore.withoutLifecycle=Re);function b(){xe()>0?ke(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",b):b(),n}function Te(e,t){let r=!1;return function(){r||(r=!0,queueMicrotask(function(){r=!1,e()}))}}function fe(e){return(e||"").replace(/^#/,"")}function B(e){const t=e===void 0?location.hash:e,r={},i=fe(t);if(!i)return r;const l=i.split("&");for(let d=0;d<l.length;d++){const c=l[d];if(!c)continue;const p=c.indexOf(":"),a=p>-1?c.slice(0,p):c,m=p>-1?c.slice(p+1):"";if(a)try{r[a]=decodeURIComponent(m)}catch{r[a]=m}}return r}function Fe(e){if(!e)return null;const t=B();return e in t?t[e]:null}function je(e,t){if(!e)return;const r=B();t==null?delete r[e]:r[e]=String(t);const l=Object.keys(r).map(function(d){const c=r[d];return c===""?d:d+":"+encodeURIComponent(c)}).join("&");fe(location.hash)!==l&&(location.hash=l)}function $e(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Me(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function We(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Be(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function Ue(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ne(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),l=i?i.split(",").map(function(d){try{return decodeURIComponent(d)}catch{return d}}).filter(Boolean):[];return{key:r,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=B,window.lnCore.hashGet=Fe,window.lnCore.hashSet=je,window.lnCore.hashLinkClick=$e,window.lnCore.resolveHashNamespace=Me,window.lnCore.hashSortEncode=We,window.lnCore.hashSortDecode=Be,window.lnCore.hashFilterEncode=Ue,window.lnCore.hashFilterDecode=Ne);function Qe(e){return(e||"").replace(/^\?/,"")}function Ge(e){const t=e===void 0?typeof window<"u"?window.location.search:"":e,r={},i=Qe(t);if(!i)return r;const l=new URLSearchParams(i);for(const[d,c]of l.entries())r[d]=c;return r}function Pe(e){if(!e||typeof window>"u")return null;const t=new URLSearchParams(window.location.search);return t.has(e)?t.get(e):null}function Ke(e,t){if(!e||typeof window>"u")return;const r=new URL(window.location.href);if(t==null||t===""?r.searchParams.delete(e):r.searchParams.set(e,String(t)),r.search===window.location.search)return;const i=r.pathname+r.search+r.hash;window.history.replaceState(window.history.state,"",i)}function Ve(e,t){if(!e||!e.hasAttribute("data-ln-query"))return null;const r=e.getAttribute("data-ln-query");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"_"+t:i:t||null}function ze(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function He(e,t){if(e&&typeof e=="string"){if(e.endsWith(".asc"))return{fieldOrColumn:e.slice(0,-4),direction:"asc"};if(e.endsWith(".desc"))return{fieldOrColumn:e.slice(0,-5),direction:"desc"}}if(t&&typeof t=="object"){const r=t.sort_field||t.sort_by;if(r){const i=t.sort_dir&&String(t.sort_dir).toLowerCase()==="desc"?"desc":"asc";return{fieldOrColumn:r,direction:i}}}return null}function Je(e){return!Array.isArray(e)||e.length===0?null:e.map(encodeURIComponent).join(",")}function Xe(e){return!e||typeof e!="string"?[]:e.split(",").map(function(t){try{return decodeURIComponent(t.trim())}catch{return t.trim()}}).filter(Boolean)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.queryParse=Ge,window.lnCore.queryGet=Pe,window.lnCore.querySet=Ke,window.lnCore.resolveQueryParam=Ve,window.lnCore.querySortEncode=ze,window.lnCore.querySortDecode=He,window.lnCore.queryFilterEncode=Je,window.lnCore.queryFilterDecode=Xe);function k(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=k);function Ye(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Ze(e,t){const r=!e||!!e.initializationError,i=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||i)?"remote":e&&!e.initializationError?"store":"none"}function pe(e,t){const r=Object.assign({},e);return t&&(r.filters=t.filters,r.search=t.search,r.sort=t.sort),r}class et{constructor(){this._pending=new Map}wait(t){return new Promise((r,i)=>{this._pending.set(t,{resolve:r,reject:i})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const r=t||new Error("Mutation receipt registry closed");for(const i of this._pending.values())i.reject(r);this._pending.clear()}_settle(t,r){const i=t&&t.requestId;if(!i)return!1;const l=this._pending.get(i);return l?(this._pending.delete(i),r?l.reject(t.error||new Error("Store mutation failed")):l.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",r="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const i="data-ln-data-coordinator-search",l="data-ln-data-coordinator-filters",d="data-ln-data-coordinator-sort-field",c="data-ln-data-coordinator-sort-direction",a=ie({"data-ln-data-coordinator":{prop:"_name",type:"string",description:"Coordinator name or identifier for data routing"},"data-ln-data-coordinator-scope":{type:"string",description:"Scope name addressing the bound data store and connector"},"data-ln-data-coordinator-connector":{type:"string",description:"Selector, identifier, or namespace of the bound connector"},"data-ln-data-coordinator-mapper":{type:"string",description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{prop:"_searchAttr",type:"string",description:"Active search query term"},"data-ln-data-coordinator-filters":{prop:"_filtersAttr",type:"string",description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{prop:"_sortFieldAttr",type:"string",description:"Sort field name"},"data-ln-data-coordinator-sort-direction":{prop:"_sortDirAttr",type:"enum",values:["asc","desc"],fallback:"asc",description:"Sort direction"},"data-ln-data-coordinator-stale":{type:"marker",description:"Flag indicating data needs re-synchronization"},"data-ln-data-coordinator-no-autosync":{type:"boolean",description:"Disables automatic synchronization upon state changes"}}),m=[["[data-ln-table-source]","data-ln-table-source","table"],["[data-ln-list-source]","data-ln-list-source","list"],["[data-ln-chart-source]","data-ln-chart-source","chart"],["[data-ln-options]","data-ln-options","options"],["[data-ln-stat]","data-ln-stat","stat"]];function A(n){const o=n.getAttribute("data-ln-data-coordinator-connector");if(o)return n.querySelector(o)||document.querySelector(o)||document.getElementById(o);const s=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(s)return s;for(const f of n.querySelectorAll("*")){if(f.lnConnector)return f;for(const w of f.attributes)if(w.name.startsWith("data-ln-")&&w.name.endsWith("-connector"))return f}return null}function _(n){var s;if(!n)return"ln-connector";if((s=n.lnConnector)!=null&&s.namespace)return n.lnConnector.namespace;const o=n.getAttribute("data-ln-connector");if(o&&o!=="true")return o.startsWith("ln-")?o:"ln-"+o+(o.endsWith("-connector")?"":"-connector");for(const f of n.attributes)if(f.name.startsWith("data-ln-")&&f.name.endsWith("-connector"))return f.name.replace(/^data-/,"");return"ln-connector"}function C(n){const o=this;return this.dom=n,oe(this,n,a),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",n),n[t]=this,this._destroyed=!1,this.mapper=null,this._unsubs=[],this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._mutationReceipts=new et,this._queueQueryRefresh=Te(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),U(this),this._checkInitialSync(),this}C.prototype._noAutosync=function(n){var o;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||!!((o=n.storeEl)!=null&&o.hasAttribute("data-ln-data-store-no-autosync"))},C.prototype._isStale=function(n){var s,f;const o=this.dom.getAttribute("data-ln-data-coordinator-stale")||((s=n.storeEl)==null?void 0:s.getAttribute("data-ln-data-store-stale"));return o==="never"||o==="-1"?!1:!((f=n.store)!=null&&f.lastSyncedAt)||Date.now()/1e3-n.store.lastSyncedAt>(parseInt(o,10)||300)},C.prototype._checkInitialSync=function(){const n=this,o=this.findChildren();o.store&&Promise.resolve(o.store.ready).then(()=>{if(n._destroyed)return;const s=n.findChildren();s.store&&s.connector&&!n._noAutosync(s)&&!s.store.isSyncing&&(!s.store.hasCache||n._isStale(s))&&s.store.forceSync()}).catch(s=>n._reportError("store-initialize",s,null))},C.prototype.refreshMapper=function(){var s,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,o=n&&((f=(s=window.lnCore)==null?void 0:s.getDataMapper)==null?void 0:f.call(s,n))||null;this.mapper={ingress:(o==null?void 0:o.ingress)||(w=>w),egress:(o==null?void 0:o.egress)||(w=>w)}},C.prototype.findChildren=function(){const n=this.dom.querySelector("[data-ln-data-store]"),o=A(this.dom),s=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:o,queueEl:s,store:(n==null?void 0:n.lnDataStore)||null,connector:(o==null?void 0:o.lnConnector)||(o==null?void 0:o.lnApiConnector)||(o==null?void 0:o.lnCouchDbConnector)||(o==null?void 0:o.lnWebsocketConnector)||null,queue:(s==null?void 0:s.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,o,s,f){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",s):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+o,f)},C.prototype._fanOutCreate=function(n,o,s){const f="_temp_"+k(),w=this.mapper.egress(o);n.storeEl&&g(n.storeEl,"ln-data-store:request-create",{tempId:f,data:w}),this._fanOutRemote(n,"create",{chainKey:f,op:"create",targetId:null,payload:w,expectedVersion:null,meta:{tempId:f,action:s}},{data:w,url:s,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},C.prototype._fanOutUpdate=function(n,o,s,f,w){const b=this.mapper.egress(s);n.storeEl&&g(n.storeEl,"ln-data-store:request-update",{id:o,data:b}),this._fanOutRemote(n,"update",{chainKey:o,op:"update",targetId:o,payload:b,expectedVersion:f,meta:{id:o,action:w}},{id:o,data:b,expected_version:f,url:w,meta:{entryId:k(),queued:!1,op:"update",id:o}})},C.prototype._fanOutDelete=function(n,o){n.storeEl&&g(n.storeEl,"ln-data-store:request-delete",{id:o}),this._fanOutRemote(n,"delete",{chainKey:o,op:"delete",targetId:o,payload:null,expectedVersion:null,meta:{id:o}},{id:o,meta:{entryId:k(),queued:!1,op:"delete",id:o}})},C.prototype._fanOutBulkDelete=function(n,o){const s=o.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:o}),this._fanOutRemote(n,"bulk-delete",{chainKey:s,op:"bulk-delete",targetId:null,payload:{ids:o},expectedVersion:null,meta:{bulkKey:s,ids:o}},{ids:o,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:s}})},C.prototype._requestStoreMutation=function(n,o,s){if(!n.storeEl)return Promise.reject(new Error("Store element not found"));const f=k(),w=this._mutationReceipts.wait(f);return g(n.storeEl,"ln-data-store:request-"+o,Object.assign({},s,{requestId:f})),w},C.prototype._reportError=function(n,o,s){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:o,meta:s||null})},C.prototype._owns=function(n){var s;const o=this._name||((s=this.findChildren().storeEl)==null?void 0:s.id);return!!n&&n===o},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(d),o=this.dom.getAttribute(c),s=new URLSearchParams(this.dom.getAttribute(l)||""),f={};for(const w of new Set(s.keys()))f[w]=s.getAll(w);return{search:this.dom.getAttribute(i)||"",filters:f,sort:n&&o?{field:n,direction:o}:null}},C.prototype._refreshAll=function(n,o){for(const[s,f,w]of m)for(const b of this.dom.ownerDocument.querySelectorAll(s))if(this._owns(b.getAttribute(f))){if((w==="table"||w==="list")&&b.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){g(b,"ln-"+w+(o?":request-invalidate":":request-revalidate"),{query:this._currentQuery()});continue}this._serveElement(b,w,null,n)}},C.prototype._serveElement=function(n,o,s,f){const w=this.findChildren(),b=w.store;if(!b)return;s&&this._boundQueries.set(n,s);const S=this._boundQueries.get(n)||{sort:null,filters:{},search:""},E=pe(S,this._currentQuery()),u=this;return Promise.resolve(b.ready).then(()=>{if(u._destroyed)return;const h=Ze(b,w.connector);if(o==="table"||o==="list"||o==="chart")return h==="remote"?(g(n,"ln-"+o+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:E,meta:{targetEl:n,kind:o,offset:E.offset,limit:E.limit,queryGen:S.queryGen}})):h!=="store"?g(n,"ln-"+o+":set-loading",{loading:!1}):b.getAll(E).then(y=>{u._destroyed||!u._boundDelivered||(g(n,"ln-"+o+":set-loading",{loading:!1}),g(n,"ln-"+o+":set-data",{data:y.data,total:(f==null?void 0:f.total)??y.total,filtered:(f==null?void 0:f.filtered)??y.filtered,offset:y.offset??(f==null?void 0:f.offset)??S.offset,queryGen:S.queryGen!==void 0?S.queryGen:(f==null?void 0:f.queryGen)??y.queryGen,provisional:y.provisional===!0}),u._boundDelivered.set(n,!0))});if(o==="options"){if(h==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:o}});if(h==="store")return b.getAll({}).then(y=>!u._destroyed&&g(n,"ln-options:set-data",{data:y.data}))}if(o==="stat"){let y=s==null?void 0:s.filters;if(!y){const v=n.getAttribute("data-ln-stat-filter");if(v!=null&&v.includes(":")){const x=v.split(":");y={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const q=w.connector&&b&&(b.windowed&&y&&Object.keys(y).length||b.noLocalQuery)?"remote":h;if(q==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:y},meta:{targetEl:n,kind:o}});if(q==="store")return b.count(y).then(v=>!u._destroyed&&g(n,"ln-stat:set-count",{count:v}))}}).catch(h=>{u._destroyed||((o==="table"||o==="list"||o==="chart")&&g(n,"ln-"+o+":set-loading",{loading:!1}),u._reportError(o+"-query",h,{targetEl:n,kind:o}))})};function U(n){const o=n._unsubs=[],s=(u,h,y)=>{u.addEventListener(h,y),o.push(()=>u.removeEventListener(h,y))};s(n.dom,"ln-data-store:request-remote-sync",u=>{n.refreshMapper();const h=n.findChildren();h.store&&h.connector&&g(h.connectorEl,_(h.connectorEl)+":request-sync",{since:u.detail.since,meta:{op:"sync"}})}),s(n.dom,"ln-data-store:request-page",u=>{const h=n.findChildren(),y=u.detail||{};if(!h.connectorEl)return;const q=pe(y.query||{},n._currentQuery());g(h.connectorEl,_(h.connectorEl)+":request-query",{query:Object.assign({},q,{offset:y.offset,limit:y.limit,queryGen:y.queryGen})})}),s(n.dom,"ln-data-coordinator:request-create",u=>n._fanOutCreate(n.findChildren(),u.detail.data||{},u.detail.action)),s(n.dom,"ln-data-coordinator:request-update",u=>n._fanOutUpdate(n.findChildren(),u.detail.id,u.detail.data||{},u.detail.expected_version,u.detail.action)),s(n.dom,"ln-data-coordinator:request-delete",u=>n._fanOutDelete(n.findChildren(),u.detail.id)),s(n.dom,"ln-data-coordinator:request-bulk-delete",u=>n._fanOutBulkDelete(n.findChildren(),u.detail.ids||[])),s(n.dom,"ln-api-queue:send",u=>n._onQueueSend(u.detail||{})),s(n.dom,"ln-api-queue:failed",u=>{var h;return n._reportError("queue-failed",((h=u==null?void 0:u.detail)==null?void 0:h.error)||new Error("Queue failed"),(u==null?void 0:u.detail)||null)}),s(n.dom,"ln-data-store:initialized",u=>{var y;const h=n.findChildren();h.store&&!h.store.initializationError&&h.connector&&!n._noAutosync(h)&&!h.store.isSyncing&&(!((y=u.detail)!=null&&y.hasCache)||n._isStale(h))&&h.store.forceSync()});const f=()=>{const u=n.findChildren();u.store&&!u.store.initializationError&&u.connector&&!n._noAutosync(u)&&u.store.isInitialized&&!u.store.isSyncing&&u.store.forceSync()};s(n.dom,"ln-websocket-connector:connected",f),s(document,"submit",u=>n._onFormSubmit(u));const w=(u,h,y)=>{var q;n._owns(u.target.getAttribute(y))&&n._serveElement(u.target,h,h==="stat"?{filters:((q=u.detail)==null?void 0:q.filters)||null}:h==="options"?null:Ye(u.detail||{}),null)};s(document,"ln-table:request-data",u=>w(u,"table","data-ln-table-source")),s(document,"ln-list:request-data",u=>w(u,"list","data-ln-list-source")),s(document,"ln-chart:request-data",u=>w(u,"chart","data-ln-chart-source")),s(document,"ln-options:request-data",u=>w(u,"options","data-ln-options")),s(document,"ln-stat:request-count",u=>w(u,"stat","data-ln-stat"));const b=u=>{n._mutationReceipts.resolve(u.detail),n._refreshAll(null,!1)};s(n.dom,"ln-data-store:ready",b),s(n.dom,"ln-data-store:created",b),s(n.dom,"ln-data-store:updated",b),s(n.dom,"ln-data-store:deleted",b),s(n.dom,"ln-data-store:mutation-error",u=>n._mutationReceipts.reject(u.detail)),s(n.dom,"ln-data-store:synced",u=>{var h;(h=u.detail)!=null&&h.changed&&n._refreshAll(u.detail.meta,!1)}),s(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),s(n.dom,"ln-search:change",u=>{var y;u.preventDefault();const h=((y=u.detail)==null?void 0:y.term)!=null?u.detail.term:"";h!==(n.dom.getAttribute(i)||"")&&n.dom.setAttribute(i,h)}),s(n.dom,"ln-filter:change",u=>{var he;u.preventDefault();const h=(he=u.detail)==null?void 0:he.key;if(!h)return;const y=(u.detail.values||[]).slice(),q=n._currentQuery().filters,v=q[h];if(v?v.length===y.length&&v.every((R,Q)=>R===y[Q]):!y.length)return;y.length?q[h]=y:delete q[h];const x=new URLSearchParams;Object.keys(q).forEach(R=>q[R].forEach(Q=>x.append(R,Q)));const O=x.toString();O?n.dom.setAttribute(l,O):n.dom.removeAttribute(l)}),s(n.dom,"ln-sort:change",u=>{var x,O;u.preventDefault();const h=(x=u.detail)==null?void 0:x.field,y=(O=u.detail)==null?void 0:O.direction,q=h&&y&&y!=="none"?{field:h,direction:y}:null,v=n._currentQuery().sort;!v&&!q||v&&q&&v.field===q.field&&v.direction===q.direction||(q?(n.dom.setAttribute(d,q.field),n.dom.setAttribute(c,q.direction)):(n.dom.removeAttribute(d),n.dom.removeAttribute(c)))});const S=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),E=n.findChildren().connectorEl;if(E){const u=_(E);S.add(u),s(n.dom,u+":connected",f)}S.forEach(u=>{s(n.dom,u+":fetched",h=>n._reconcileServerFetch(h.detail)),s(n.dom,u+":created",h=>n._reconcileServerMutation("create",h.detail)),s(n.dom,u+":updated",h=>n._reconcileServerMutation("update",h.detail)),s(n.dom,u+":deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,u+":bulk-deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,u+":error",h=>n._reconcileServerMutation("error",h.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const o=this.findChildren();if(!o.store||!o.connector||!o.queue)return;const s=n.meta||{},f=_(o.connectorEl),w=n.idempotencyKey||n.entryId,b={create:()=>g(o.connectorEl,f+":request-create",{data:n.payload,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:s.tempId}}),update:()=>g(o.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"update",id:n.targetId}}),delete:()=>g(o.connectorEl,f+":request-delete",{id:n.targetId,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"delete",id:n.targetId}}),"bulk-delete":()=>{var S;return g(o.connectorEl,f+":request-bulk-delete",{ids:((S=n.payload)==null?void 0:S.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:s.bulkKey}})}};b[n.op]&&b[n.op]()},C.prototype._onFormSubmit=function(n){const o=n.target;if(n.defaultPrevented)return;const s=o.hasAttribute(r)?o.getAttribute(r):null;if(s===null||(s?!this._owns(s):o.closest("["+e+"]")!==this.dom))return;const f=P(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=K(o);delete w._method,delete w._token;const b=w.id,S=w.expected_version,E=o.getAttribute("action")||"",u=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(u,w,E):this._fanOutUpdate(u,b,w,S,E)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const o=n.meta||{},s=this.findChildren(),f=n.data;this.refreshMapper();const w=Array.isArray(f)?f:(f==null?void 0:f.data)||[],b=Array.isArray(f==null?void 0:f.deleted)?f.deleted:[],S=Array.isArray(f)?Math.floor(Date.now()/1e3):(f==null?void 0:f.synced_at)??(f==null?void 0:f.since)??Math.floor(Date.now()/1e3),E=w.map(u=>this.mapper.ingress(u));if(!(!s.store||s.store.initializationError)){if(!o.kind)return s.store.applySync(E,b,S,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:o.targetEl});s.store.applyQuery(E,{total:n.total}).then(u=>{const h=o.kind;h==="table"||h==="list"||h==="chart"?(g(o.targetEl,"ln-"+h+":set-loading",{loading:!1}),g(o.targetEl,"ln-"+h+":set-data",{data:u,total:n.total??u.length,filtered:n.filtered??u.length,offset:n.offset,queryGen:o.queryGen}),this._boundDelivered.set(o.targetEl,!0)):h==="options"?s.store.getAll({}).then(y=>g(o.targetEl,"ln-options:set-data",{data:y.data})):h==="stat"&&g(o.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??E.length})})}},C.prototype._reconcileServerMutation=function(n,o){var w;if(!o)return;const s=this.findChildren(),f=o.meta||{};if(n==="create"){if(!o.record)return this._reportError("create-empty-response",new Error("Create response missing record payload"),f);const b=this.mapper.ingress(o.record);(s.storeEl?this._requestStoreMutation(s,"update",{id:f.tempId,data:b}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:b.id})}).catch(S=>this._reportError("create-reconcile",S,f))}else if(n==="update"){const b=o.record?this.mapper.ingress(o.record):null;(s.storeEl&&b?this._requestStoreMutation(s,"update",{id:f.id,data:b}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(S=>this._reportError("update-reconcile",S,f))}else if(n==="ack")f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId});else if(n==="error"){const b=o.status||((w=o.error)==null?void 0:w.status)||0;f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:b===401||b===419?"auth":b===0||b>=500?"retry":"drop"}),s.storeEl&&g(s.storeEl,"ln-data-store:request-sync-failed",{error:o.error||o,status:b}),this._reportError("connector-error",o.error||o,f)}},C.prototype.destroy=function(){var n;if(this.dom[t]){for(this._destroyed=!0;(n=this._unsubs)!=null&&n.length;)this._unsubs.pop()();this._unsubs=this._boundQueries=this._boundDelivered=this._queueQueryRefresh=null,this._mutationReceipts.close(new Error("Data coordinator destroyed")),this._mutationReceipts=null,delete this.dom[t]}};function N(n,o){const s=n[t];s&&(o==="data-ln-data-coordinator-mapper"?s.refreshMapper():(o===i||o===l||o===d||o===c)&&s._queueQueryRefresh())}ue(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",i,l,d,c],onAttributeChange:N}),window[t].init=window[t]})()})();
1
+ (function(){"use strict";function Q(){if(typeof window>"u")return!1;if(window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink)return!0;if(typeof document<"u"){if(document.documentElement&&document.documentElement.hasAttribute("data-ln-debug"))return!0;if(document.body)return document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null}return!1}function L(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let i=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){i=t[l];break}if(!L(i))return}e.apply(console,t)}}function C(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function O(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){O(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function G(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function P(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,l={},u=e.elements,c={};if(r)for(let p=0;p<u.length;p++){const a=u[p];a.name&&a.type==="checkbox"&&!a.disabled&&(c[a.name]=(c[a.name]||0)+1)}for(let p=0;p<u.length;p++){const a=u[p];if(!(!a.name||a.disabled||a.type==="file"||a.type==="submit"||a.type==="button")&&!(i&&a.matches&&a.matches(i)))if(a.type==="checkbox")r&&c[a.name]===1?l[a.name]=a.checked:(l[a.name]||(l[a.name]=[]),a.checked&&l[a.name].push(a.value));else if(a.type==="radio")a.checked&&(l[a.name]=a.value);else if(a.type==="select-multiple"){l[a.name]=[];for(let m=0;m<a.options.length;m++)a.options[m].selected&&l[a.name].push(a.options[m].value)}else if(r&&a.type==="hidden")l[a.name]=a.value;else if(r&&(a.type==="number"||a.type==="range")){const m=Number(a.value);l[a.name]=a.value===""||isNaN(m)?null:m}else l[a.name]=a.value}return l}function we(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function me(e,t){const r=e.elements,i=[],l={};for(let u=0;u<r.length;u++){const c=r[u];c.name&&c.type==="checkbox"&&(l[c.name]=(l[c.name]||0)+1)}for(let u=0;u<r.length;u++){const c=r[u];if(c.type==="file"||c.type==="submit"||c.type==="button")continue;const p=c.getAttribute("data-ln-fill-as")||c.name;if(!p||!(p in t))continue;const a=t[p];if(c.type==="checkbox"){if(Array.isArray(a))c.checked=a.indexOf(c.value)!==-1;else if(l[c.name]>1){const m=String(a).split(",").map(function(A){return A.trim()});c.checked=m.indexOf(c.value)!==-1}else c.checked=we(a);i.push(c)}else if(c.type==="radio")c.checked=c.value===String(a),i.push(c);else if(c.type==="select-multiple"){if(Array.isArray(a))for(let m=0;m<c.options.length;m++)c.options[m].selected=a.indexOf(c.options[m].value)!==-1;i.push(c)}else c.value=a,c.tagName==="SELECT"&&a!=null&&c.setAttribute("data-ln-value",a),i.push(c)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=me,window.lnCore.serializeForm=P,window.lnCore.resolveFormMethod=G);const K={};function ye(e,t){K[e]=t}function be(e){return K[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=ye,window.lnCore.getDataMapper=be);function ge(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,O(function(){new MutationObserver(function(){C(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const V={};function Ce(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];V[r]=t}function _e(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return V[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ce,window.lnCore.getLocaleFallback=_e,window.lnCore.ensureLocaleObserver=ge);const T={};function Ae(e,t){T[e]||(T[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=T[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function z(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let c=0;c<r.length;c++){const p=r[c],a=p.getAttribute("data-ln-field");t[a]!=null&&(p.textContent=t[a])}const i=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<i.length;c++){const p=i[c],a=p.getAttribute("data-ln-attr").split(",");for(let m=0;m<a.length;m++){const A=a[m].trim().split(":");if(A.length!==2)continue;const g=A[0].trim(),_=A[1].trim();t[_]!=null&&p.setAttribute(g,t[_])}}const l=e.querySelectorAll("[data-ln-show]");for(let c=0;c<l.length;c++){const p=l[c],a=p.getAttribute("data-ln-show");a in t&&p.classList.toggle("hidden",!t[a])}const u=e.querySelectorAll("[data-ln-class]");for(let c=0;c<u.length;c++){const p=u[c],a=p.getAttribute("data-ln-class").split(",");for(let m=0;m<a.length;m++){const A=a[m].trim().split(":");if(A.length!==2)continue;const g=A[0].trim(),_=A[1].trim();_ in t&&p.classList.toggle(g,!!t[_])}}return e}function qe(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)z(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<t.length;r++)t[r].textContent=""}})));function H(e,t){if(!e||!t)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const u=r.currentNode;u.textContent.indexOf("{{")!==-1&&(u.textContent=u.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,p){return t[p]!==void 0?t[p]:""}))}const i=function(u,c){return t[c]!==void 0?t[c]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let u=0;u<l.length;u++){const c=l[u],p=c.attributes;for(let a=0;a<p.length;a++){const m=p[a];m.value.indexOf("{{")!==-1&&c.setAttribute(m.name,m.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function Ee(e,t,r,i,l,u){const c={};for(let a=0;a<e.children.length;a++){const m=e.children[a],A=m.getAttribute("data-ln-render-key");A&&(c[A]=m)}const p=document.createDocumentFragment();for(let a=0;a<t.length;a++){const m=t[a],A=String(i(m));let g=c[A];if(g)l(g,m,a);else{const _=Ae(r,u);if(!_||(H(_,m),g=_.firstElementChild,!g))continue;g.setAttribute("data-ln-render-key",A),l(g,m,a)}p.appendChild(g)}e.textContent="",e.appendChild(p)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=H,window.lnCore.fill=z,window.lnCore.lnFill=qe,window.lnCore.renderList=Ee);function F(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function J(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function X(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const l=i.trim().toLowerCase();return!(l==="false"||l==="0")}function Y(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const j=new Map;function Z(e,t){const r=(e?e.join("|"):"")+"::"+t;if(j.has(r))return j.get(r);const i=new Set(e||[]),l=function(u,c){const p=u.getAttribute(c);return p!==null&&i.has(p)?p:t};return j.set(r,l),l}function ee(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function te(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function ne(e,t,r,i,l){if(!e||t===null)return!0;const u=i||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const p=a=>{l?console.warn(a,l):console.warn(a)};if(c==="boolean"){const a=t.trim().toLowerCase();return a!==""&&a!=="true"&&a!=="false"&&a!=="1"&&a!=="0"?(p(`[${u}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const a=e.values||[];return a.includes(t)?!0:(p(`[${u}] Invalid value "${t}" for attribute "${r}". Allowed: ${a.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return p(`[${u}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const a=parseInt(t,10);return e.min!==void 0&&a<e.min?(p(`[${u}] Value ${a} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&a>e.max?(p(`[${u}] Value ${a} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(p(`[${u}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(a){return p(`[${u}] Invalid JSON for attribute "${r}": ${a.message}. Fallback: ${e.fallback}.`),!1}return!0}function re(e,t,r){for(const i in r){const[l,u,c]=r[i];Object.defineProperty(e,i,{get:function(){return l(t,u,c)},enumerable:!0,configurable:!0})}return e}function oe(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let l=i.read;if(!l&&i.type)switch(i.type){case"enum":l=Z(i.values,i.fallback);break;case"integer":l=J;break;case"float":l=ee;break;case"boolean":l=X;break;case"list":l=Y;break;case"json":l=te;break;case"string":default:l=F;break}l||(l=F),t[i.prop]=[l,r,i.fallback]}return t}function Se(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function ve(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const r in e.effects)t.add(r);if(e.onAttrChange&&e.declared)for(const r of e.declared)t.add(r);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=re,window.lnCore.attrSpec=oe,window.lnCore.attrStr=F,window.lnCore.attrInt=J,window.lnCore.attrBool=X,window.lnCore.attrList=Y,window.lnCore.attrEnum=Z,window.lnCore.attrFloat=ee,window.lnCore.attrJson=te);function D(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(r){console.error("["+t.attribute+"] init failed",e,r)}}}function ie(e,t,r,i){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:r,ComponentFn:i};if(e.matches&&e.matches(u)&&D(e,c),e.querySelectorAll){const p=e.querySelectorAll(u);for(let a=0;a<p.length;a++)D(p[a],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function xe(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ke(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function ae(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function Ie(e){const t=ae(),r=e.observed||[];for(let i=0;i<r.length;i++){const l=r[i];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const l=t.byDeclaredAttr.get(i);l.some(u=>u.componentTag===e.componentTag)||l.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=ve(e);if(i===null)t.reactiveWildcard.push(e);else for(const l of i)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function le(e,t,r,i){for(let l=0;l<e.length;l++){const u=e[l];if(!t[u.attribute])continue;const c=u.effects&&u.effects[r];c?c(t,r,i):u.onAttrChange&&(!u.declared||u.declared.has(r))&&u.onAttrChange(t,r,i)}}function Oe(e){const t=e.attributeName,r=t.indexOf("data-ln-")===0,i=ae(),l=i.byAttr.get(t),u=Q()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(t);if(!r&&!l&&!u)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(u&&L(c)){const p=i.byDeclaredAttr.get(t),a=c.getAttribute(t);for(let m=0;m<p.length;m++)ne(p[m].spec,a,t,p[m].componentTag,c)}if(window.lnCore._debugSink&&(r||l)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),r){const p=i.byReactive.get(t);p&&le(p,c,t,e.oldValue),i.reactiveWildcard.length&&le(i.reactiveWildcard,c,t,e.oldValue)}if(l)for(let p=0;p<l.length;p++){const a=l[p];if(a.handler){a.handler(c,t,e.oldValue);continue}a.onAttributeChange&&c[a.attribute]?a.onAttributeChange(c,t):(ie(c,a.selector,a.attribute,a.ComponentFn),a.onInit&&a.onInit(c))}}}function De(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,O(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{Oe(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function $(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function M(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function se(e,t){if(!document.contains(e))if(t.attribute){const r=e[t.attribute];if(r&&typeof r.destroy=="function")try{r.destroy()}catch(i){console.error("["+t.attribute+"] destroy failed",e,i)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function ce(e){const t=$();if(!t.length)return;const r=e.target;if(r){const l=r.nodeType===1?r:r.parentElement;if(l&&(l.isContentEditable||l.closest&&l.closest('[contenteditable]:not([contenteditable="false"])')))return}const i=M();if(e.target&&i.length)for(let l=0;l<i.length;l++){const u=i[l],c=u.query,p=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;p&&u.onSubtreeChange(p,e)}for(let l=0;l<e.addedNodes.length;l++){const u=e.addedNodes[l];if(u.nodeType!==1)continue;const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const a=t[p],m=a.query;if(m&&(u.matches&&u.matches(m)&&(a.ComponentFn&&D(u,a),a.onInit&&a.onInit(u)),c&&u.querySelectorAll)){const A=u.querySelectorAll(m);for(let g=0;g<A.length;g++)a.ComponentFn&&D(A[g],a),a.onInit&&a.onInit(A[g])}}}for(let l=0;l<e.removedNodes.length;l++){const u=e.removedNodes[l];if(u.nodeType!==1||document.contains(u))continue;const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const a=t[p],m=a.query;if(m&&(u.matches&&u.matches(m)&&se(u,a),c&&u.querySelectorAll)){const A=u.querySelectorAll(m);for(let g=0;g<A.length;g++)se(A[g],a)}}}}function de(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,O(function(){const e=new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{ce(i)}catch(l){console.error("[ln-core] lifecycle handler failed",i.target,l)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Re(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const r=t.takeRecords();for(let i=0;i<r.length;i++){const l=r[i];if(l.type==="childList")try{ce(l)}catch(u){console.error("[ln-core] lifecycle handler failed",l.target,u)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function Le(e){$().push(e),e.onSubtreeChange&&e.query&&M().push(e),de()}function ue(e,t,r,i,l={}){const u=l.extraAttributes||[],c=l.onAttributeChange||null,p=l.onSubtreeChange||null,a=l.onInit||null,m=l.onAttrChange||null,A=l.effects||null,g=l.attributes||null,_=g?Se(g):A,B=g?new Set(Object.keys(g)):null,U=l.persist||null;function n(S){const E=S||document.body;if(ie(E,e,t,r),g&&Q())for(const d in g){const h=g[d],y=Array.from(E.querySelectorAll("["+d+"]"));E.matches&&E.matches("["+d+"]")&&y.push(E);for(let q=0;q<y.length;q++){const v=y[q];L(v)&&ne(h,v.getAttribute(d),d,i,v)}}a&&a(E)}const o=[];if(e.indexOf("[")!==-1){const S=/\[([\w-]+)/g;let E;for(;(E=S.exec(e))!==null;)o.push(E[1])}else o.push(e);Ie({selector:e,attribute:t,componentTag:i,attributes:g,ComponentFn:r,onInit:a,observed:o.concat(u),onAttributeChange:c,onAttrChange:m,effects:_,declared:B,persist:U}),De();const s=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,f=l.subtreeQuery||(s?e:"["+e+"]"),w={selector:e,attribute:t,ComponentFn:r,onInit:a,onSubtreeChange:p,query:f};$().push(w),p&&f&&M().push(w),de(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ue,window.lnCore.observeLifecycle=Le,window.lnCore.withoutLifecycle=Re);function b(){xe()>0?ke(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",b):b(),n}function Te(e,t){let r=!1;return function(){r||(r=!0,queueMicrotask(function(){r=!1,e()}))}}function fe(e){return(e||"").replace(/^#/,"")}function W(e){const t=e===void 0?location.hash:e,r={},i=fe(t);if(!i)return r;const l=i.split("&");for(let u=0;u<l.length;u++){const c=l[u];if(!c)continue;const p=c.indexOf(":"),a=p>-1?c.slice(0,p):c,m=p>-1?c.slice(p+1):"";if(a)try{r[a]=decodeURIComponent(m)}catch{r[a]=m}}return r}function Fe(e){if(!e)return null;const t=W();return e in t?t[e]:null}function je(e,t){if(!e)return;const r=W();t==null?delete r[e]:r[e]=String(t);const l=Object.keys(r).map(function(u){const c=r[u];return c===""?u:u+":"+encodeURIComponent(c)}).join("&");fe(location.hash)!==l&&(location.hash=l)}function $e(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Me(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function We(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Be(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function Ue(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ne(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),l=i?i.split(",").map(function(u){try{return decodeURIComponent(u)}catch{return u}}).filter(Boolean):[];return{key:r,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=W,window.lnCore.hashGet=Fe,window.lnCore.hashSet=je,window.lnCore.hashLinkClick=$e,window.lnCore.resolveHashNamespace=Me,window.lnCore.hashSortEncode=We,window.lnCore.hashSortDecode=Be,window.lnCore.hashFilterEncode=Ue,window.lnCore.hashFilterDecode=Ne);function Qe(e){return(e||"").replace(/^\?/,"")}function Ge(e){const t=e===void 0?typeof window<"u"?window.location.search:"":e,r={},i=Qe(t);if(!i)return r;const l=new URLSearchParams(i);for(const[u,c]of l.entries())r[u]=c;return r}function Pe(e){if(!e||typeof window>"u")return null;const t=new URLSearchParams(window.location.search);return t.has(e)?t.get(e):null}function Ke(e,t){if(!e||typeof window>"u")return;const r=new URL(window.location.href);if(t==null||t===""?r.searchParams.delete(e):r.searchParams.set(e,String(t)),r.search===window.location.search)return;const i=r.pathname+r.search+r.hash;window.history.replaceState(window.history.state,"",i)}function Ve(e,t){if(!e||!e.hasAttribute("data-ln-query"))return null;const r=e.getAttribute("data-ln-query");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"_"+t:i:t||null}function ze(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function He(e,t){if(e&&typeof e=="string"){if(e.endsWith(".asc"))return{fieldOrColumn:e.slice(0,-4),direction:"asc"};if(e.endsWith(".desc"))return{fieldOrColumn:e.slice(0,-5),direction:"desc"}}if(t&&typeof t=="object"){const r=t.sort_field||t.sort_by;if(r){const i=t.sort_dir&&String(t.sort_dir).toLowerCase()==="desc"?"desc":"asc";return{fieldOrColumn:r,direction:i}}}return null}function Je(e){return!Array.isArray(e)||e.length===0?null:e.map(encodeURIComponent).join(",")}function Xe(e){return!e||typeof e!="string"?[]:e.split(",").map(function(t){try{return decodeURIComponent(t.trim())}catch{return t.trim()}}).filter(Boolean)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.queryParse=Ge,window.lnCore.queryGet=Pe,window.lnCore.querySet=Ke,window.lnCore.resolveQueryParam=Ve,window.lnCore.querySortEncode=ze,window.lnCore.querySortDecode=He,window.lnCore.queryFilterEncode=Je,window.lnCore.queryFilterDecode=Xe);function k(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=k);function Ye(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Ze(e,t){const r=!e||!!e.initializationError,i=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||i)?"remote":e&&!e.initializationError?"store":"none"}function pe(e,t){const r=Object.assign({},e);return t&&(r.filters=t.filters,r.search=t.search,r.sort=t.sort),r}class et{constructor(){this._pending=new Map}wait(t){return new Promise((r,i)=>{this._pending.set(t,{resolve:r,reject:i})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const r=t||new Error("Mutation receipt registry closed");for(const i of this._pending.values())i.reject(r);this._pending.clear()}_settle(t,r){const i=t&&t.requestId;if(!i)return!1;const l=this._pending.get(i);return l?(this._pending.delete(i),r?l.reject(t.error||new Error("Store mutation failed")):l.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",r="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const i="data-ln-data-coordinator-search",l="data-ln-data-coordinator-filters",u="data-ln-data-coordinator-sort-field",c="data-ln-data-coordinator-sort-direction",a=oe({"data-ln-data-coordinator":{prop:"_name",type:"string",description:"Coordinator name or identifier for data routing"},"data-ln-data-coordinator-scope":{type:"string",description:"Scope name addressing the bound data store and connector"},"data-ln-data-coordinator-connector":{type:"string",description:"Selector, identifier, or namespace of the bound connector"},"data-ln-data-coordinator-mapper":{type:"string",description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{prop:"_searchAttr",type:"string",description:"Active search query term"},"data-ln-data-coordinator-filters":{prop:"_filtersAttr",type:"string",description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{prop:"_sortFieldAttr",type:"string",description:"Sort field name"},"data-ln-data-coordinator-sort-direction":{prop:"_sortDirAttr",type:"enum",values:["asc","desc"],fallback:"asc",description:"Sort direction"},"data-ln-data-coordinator-stale":{type:"marker",description:"Flag indicating data needs re-synchronization"},"data-ln-data-coordinator-no-autosync":{type:"boolean",description:"Disables automatic synchronization upon state changes"}}),m=[["[data-ln-table-source]","data-ln-table-source","table"],["[data-ln-list-source]","data-ln-list-source","list"],["[data-ln-chart-source]","data-ln-chart-source","chart"],["[data-ln-options]","data-ln-options","options"],["[data-ln-stat]","data-ln-stat","stat"]];function A(n){const o=n.getAttribute("data-ln-data-coordinator-connector");if(o)return n.querySelector(o)||document.querySelector(o)||document.getElementById(o);const s=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(s)return s;for(const f of n.querySelectorAll("*")){if(f.lnConnector)return f;for(const w of f.attributes)if(w.name.startsWith("data-ln-")&&w.name.endsWith("-connector"))return f}return null}function g(n){var s;if(!n)return"ln-connector";if((s=n.lnConnector)!=null&&s.namespace)return n.lnConnector.namespace;const o=n.getAttribute("data-ln-connector");if(o&&o!=="true")return o.startsWith("ln-")?o:"ln-"+o+(o.endsWith("-connector")?"":"-connector");for(const f of n.attributes)if(f.name.startsWith("data-ln-")&&f.name.endsWith("-connector"))return f.name.replace(/^data-/,"");return"ln-connector"}function _(n){const o=this;return this.dom=n,re(this,n,a),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",n),n[t]=this,this._destroyed=!1,this.mapper=null,this._unsubs=[],this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._mutationReceipts=new et,this._queueQueryRefresh=Te(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),B(this),this._checkInitialSync(),this}_.prototype._noAutosync=function(n){var o;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||!!((o=n.storeEl)!=null&&o.hasAttribute("data-ln-data-store-no-autosync"))},_.prototype._isStale=function(n){var s,f;const o=this.dom.getAttribute("data-ln-data-coordinator-stale")||((s=n.storeEl)==null?void 0:s.getAttribute("data-ln-data-store-stale"));return o==="never"||o==="-1"?!1:!((f=n.store)!=null&&f.lastSyncedAt)||Date.now()/1e3-n.store.lastSyncedAt>(parseInt(o,10)||300)},_.prototype._checkInitialSync=function(){const n=this,o=this.findChildren();o.store&&Promise.resolve(o.store.ready).then(()=>{if(n._destroyed)return;const s=n.findChildren();s.store&&s.connector&&!n._noAutosync(s)&&!s.store.isSyncing&&(!s.store.hasCache||n._isStale(s))&&s.store.forceSync()}).catch(s=>n._reportError("store-initialize",s,null))},_.prototype.refreshMapper=function(){var s,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,o=n&&((f=(s=window.lnCore)==null?void 0:s.getDataMapper)==null?void 0:f.call(s,n))||null;this.mapper={ingress:(o==null?void 0:o.ingress)||(w=>w),egress:(o==null?void 0:o.egress)||(w=>w)}},_.prototype.findChildren=function(){const n=this.dom.querySelector("[data-ln-data-store]"),o=A(this.dom),s=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:o,queueEl:s,store:(n==null?void 0:n.lnDataStore)||null,connector:(o==null?void 0:o.lnConnector)||(o==null?void 0:o.lnApiConnector)||(o==null?void 0:o.lnCouchDbConnector)||(o==null?void 0:o.lnWebsocketConnector)||null,queue:(s==null?void 0:s.lnApiQueue)||null}},_.prototype._fanOutRemote=function(n,o,s,f){this.refreshMapper(),n.queue?C(n.queueEl,"ln-api-queue:request-enqueue",s):n.connector&&C(n.connectorEl,g(n.connectorEl)+":request-"+o,f)},_.prototype._fanOutCreate=function(n,o,s){const f="_temp_"+k(),w=this.mapper.egress(o);n.storeEl&&C(n.storeEl,"ln-data-store:request-create",{tempId:f,data:w}),this._fanOutRemote(n,"create",{chainKey:f,op:"create",targetId:null,payload:w,expectedVersion:null,meta:{tempId:f,action:s}},{data:w,url:s,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},_.prototype._fanOutUpdate=function(n,o,s,f,w){const b=this.mapper.egress(s);n.storeEl&&C(n.storeEl,"ln-data-store:request-update",{id:o,data:b}),this._fanOutRemote(n,"update",{chainKey:o,op:"update",targetId:o,payload:b,expectedVersion:f,meta:{id:o,action:w}},{id:o,data:b,expected_version:f,url:w,meta:{entryId:k(),queued:!1,op:"update",id:o}})},_.prototype._fanOutDelete=function(n,o){n.storeEl&&C(n.storeEl,"ln-data-store:request-delete",{id:o}),this._fanOutRemote(n,"delete",{chainKey:o,op:"delete",targetId:o,payload:null,expectedVersion:null,meta:{id:o}},{id:o,meta:{entryId:k(),queued:!1,op:"delete",id:o}})},_.prototype._fanOutBulkDelete=function(n,o){const s=o.join(",");n.storeEl&&C(n.storeEl,"ln-data-store:request-bulk-delete",{ids:o}),this._fanOutRemote(n,"bulk-delete",{chainKey:s,op:"bulk-delete",targetId:null,payload:{ids:o},expectedVersion:null,meta:{bulkKey:s,ids:o}},{ids:o,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:s}})},_.prototype._requestStoreMutation=function(n,o,s){if(!n.storeEl)return Promise.reject(new Error("Store element not found"));const f=k(),w=this._mutationReceipts.wait(f);return C(n.storeEl,"ln-data-store:request-"+o,Object.assign({},s,{requestId:f})),w},_.prototype._reportError=function(n,o,s){this._destroyed||C(this.dom,"ln-data-coordinator:error",{operation:n,error:o,meta:s||null})},_.prototype._owns=function(n){var s;const o=this._name||((s=this.findChildren().storeEl)==null?void 0:s.id);return!!n&&n===o},_.prototype._currentQuery=function(){const n=this.dom.getAttribute(u),o=this.dom.getAttribute(c),s=new URLSearchParams(this.dom.getAttribute(l)||""),f={};for(const w of new Set(s.keys()))f[w]=s.getAll(w);return{search:this.dom.getAttribute(i)||"",filters:f,sort:n&&o?{field:n,direction:o}:null}},_.prototype._refreshAll=function(n,o){for(const[s,f,w]of m)for(const b of this.dom.ownerDocument.querySelectorAll(s))if(this._owns(b.getAttribute(f))){if((w==="table"||w==="list")&&b.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){C(b,"ln-"+w+(o?":request-invalidate":":request-revalidate"),{query:this._currentQuery()});continue}this._serveElement(b,w,null,n)}},_.prototype._serveElement=function(n,o,s,f){const w=this.findChildren(),b=w.store;if(!b)return;s&&this._boundQueries.set(n,s);const S=this._boundQueries.get(n)||{sort:null,filters:{},search:""},E=pe(S,this._currentQuery()),d=this;return Promise.resolve(b.ready).then(()=>{if(d._destroyed)return;const h=Ze(b,w.connector);if(o==="table"||o==="list"||o==="chart")return h==="remote"?(C(n,"ln-"+o+":set-loading",{loading:!0}),C(w.connectorEl,g(w.connectorEl)+":request-query",{query:E,meta:{targetEl:n,kind:o,offset:E.offset,limit:E.limit,queryGen:S.queryGen}})):h!=="store"?C(n,"ln-"+o+":set-loading",{loading:!1}):b.getAll(E).then(y=>{d._destroyed||!d._boundDelivered||(C(n,"ln-"+o+":set-loading",{loading:!1}),C(n,"ln-"+o+":set-data",{data:y.data,total:(f==null?void 0:f.total)??y.total,filtered:(f==null?void 0:f.filtered)??y.filtered,offset:y.offset??(f==null?void 0:f.offset)??S.offset,queryGen:S.queryGen!==void 0?S.queryGen:(f==null?void 0:f.queryGen)??y.queryGen,provisional:y.provisional===!0}),d._boundDelivered.set(n,!0))});if(o==="options"){if(h==="remote")return C(w.connectorEl,g(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:o}});if(h==="store")return b.getAll({}).then(y=>!d._destroyed&&C(n,"ln-options:set-data",{data:y.data}))}if(o==="stat"){let y=s==null?void 0:s.filters;if(!y){const v=n.getAttribute("data-ln-stat-filter");if(v!=null&&v.includes(":")){const x=v.split(":");y={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const q=w.connector&&b&&(b.windowed&&y&&Object.keys(y).length||b.noLocalQuery)?"remote":h;if(q==="remote")return C(w.connectorEl,g(w.connectorEl)+":request-query",{query:{filters:y},meta:{targetEl:n,kind:o}});if(q==="store")return b.count(y).then(v=>!d._destroyed&&C(n,"ln-stat:set-count",{count:v}))}}).catch(h=>{d._destroyed||((o==="table"||o==="list"||o==="chart")&&C(n,"ln-"+o+":set-loading",{loading:!1}),d._reportError(o+"-query",h,{targetEl:n,kind:o}))})};function B(n){const o=n._unsubs=[],s=(d,h,y)=>{d.addEventListener(h,y),o.push(()=>d.removeEventListener(h,y))};s(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const h=n.findChildren();h.store&&h.connector&&C(h.connectorEl,g(h.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),s(n.dom,"ln-data-store:request-page",d=>{const h=n.findChildren(),y=d.detail||{};if(!h.connectorEl)return;const q=pe(y.query||{},n._currentQuery());C(h.connectorEl,g(h.connectorEl)+":request-query",{query:Object.assign({},q,{offset:y.offset,limit:y.limit,queryGen:y.queryGen})})}),s(n.dom,"ln-data-coordinator:request-create",d=>n._fanOutCreate(n.findChildren(),d.detail.data||{},d.detail.action)),s(n.dom,"ln-data-coordinator:request-update",d=>n._fanOutUpdate(n.findChildren(),d.detail.id,d.detail.data||{},d.detail.expected_version,d.detail.action)),s(n.dom,"ln-data-coordinator:request-delete",d=>n._fanOutDelete(n.findChildren(),d.detail.id)),s(n.dom,"ln-data-coordinator:request-bulk-delete",d=>n._fanOutBulkDelete(n.findChildren(),d.detail.ids||[])),s(n.dom,"ln-api-queue:send",d=>n._onQueueSend(d.detail||{})),s(n.dom,"ln-api-queue:failed",d=>{var h;return n._reportError("queue-failed",((h=d==null?void 0:d.detail)==null?void 0:h.error)||new Error("Queue failed"),(d==null?void 0:d.detail)||null)}),s(n.dom,"ln-data-store:initialized",d=>{var y;const h=n.findChildren();h.store&&!h.store.initializationError&&h.connector&&!n._noAutosync(h)&&!h.store.isSyncing&&(!((y=d.detail)!=null&&y.hasCache)||n._isStale(h))&&h.store.forceSync()});const f=()=>{const d=n.findChildren();d.store&&!d.store.initializationError&&d.connector&&!n._noAutosync(d)&&d.store.isInitialized&&!d.store.isSyncing&&d.store.forceSync()};s(n.dom,"ln-websocket-connector:connected",f),s(document,"submit",d=>n._onFormSubmit(d));const w=(d,h,y)=>{var q;n._owns(d.target.getAttribute(y))&&n._serveElement(d.target,h,h==="stat"?{filters:((q=d.detail)==null?void 0:q.filters)||null}:h==="options"?null:Ye(d.detail||{}),null)};s(document,"ln-table:request-data",d=>w(d,"table","data-ln-table-source")),s(document,"ln-list:request-data",d=>w(d,"list","data-ln-list-source")),s(document,"ln-chart:request-data",d=>w(d,"chart","data-ln-chart-source")),s(document,"ln-options:request-data",d=>w(d,"options","data-ln-options")),s(document,"ln-stat:request-count",d=>w(d,"stat","data-ln-stat"));const b=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};s(n.dom,"ln-data-store:ready",b),s(n.dom,"ln-data-store:created",b),s(n.dom,"ln-data-store:updated",b),s(n.dom,"ln-data-store:deleted",b),s(n.dom,"ln-data-store:mutation-error",d=>n._mutationReceipts.reject(d.detail)),s(n.dom,"ln-data-store:synced",d=>{var h;(h=d.detail)!=null&&h.changed&&n._refreshAll(d.detail.meta,!1)}),s(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),s(n.dom,"ln-search:change",d=>{var y;d.preventDefault();const h=((y=d.detail)==null?void 0:y.term)!=null?d.detail.term:"";h!==(n.dom.getAttribute(i)||"")&&n.dom.setAttribute(i,h)}),s(n.dom,"ln-filter:change",d=>{var he;d.preventDefault();const h=(he=d.detail)==null?void 0:he.key;if(!h)return;const y=(d.detail.values||[]).slice(),q=n._currentQuery().filters,v=q[h];if(v?v.length===y.length&&v.every((R,N)=>R===y[N]):!y.length)return;y.length?q[h]=y:delete q[h];const x=new URLSearchParams;Object.keys(q).forEach(R=>q[R].forEach(N=>x.append(R,N)));const I=x.toString();I?n.dom.setAttribute(l,I):n.dom.removeAttribute(l)}),s(n.dom,"ln-sort:change",d=>{var x,I;d.preventDefault();const h=(x=d.detail)==null?void 0:x.field,y=(I=d.detail)==null?void 0:I.direction,q=h&&y&&y!=="none"?{field:h,direction:y}:null,v=n._currentQuery().sort;!v&&!q||v&&q&&v.field===q.field&&v.direction===q.direction||(q?(n.dom.setAttribute(u,q.field),n.dom.setAttribute(c,q.direction)):(n.dom.removeAttribute(u),n.dom.removeAttribute(c)))});const S=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),E=n.findChildren().connectorEl;if(E){const d=g(E);S.add(d),s(n.dom,d+":connected",f)}S.forEach(d=>{s(n.dom,d+":fetched",h=>n._reconcileServerFetch(h.detail)),s(n.dom,d+":created",h=>n._reconcileServerMutation("create",h.detail)),s(n.dom,d+":updated",h=>n._reconcileServerMutation("update",h.detail)),s(n.dom,d+":deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,d+":bulk-deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,d+":error",h=>n._reconcileServerMutation("error",h.detail))})}_.prototype._onQueueSend=function(n){this.refreshMapper();const o=this.findChildren();if(!o.store||!o.connector||!o.queue)return;const s=n.meta||{},f=g(o.connectorEl),w=n.idempotencyKey||n.entryId,b={create:()=>C(o.connectorEl,f+":request-create",{data:n.payload,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:s.tempId}}),update:()=>C(o.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"update",id:n.targetId}}),delete:()=>C(o.connectorEl,f+":request-delete",{id:n.targetId,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"delete",id:n.targetId}}),"bulk-delete":()=>{var S;return C(o.connectorEl,f+":request-bulk-delete",{ids:((S=n.payload)==null?void 0:S.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:s.bulkKey}})}};b[n.op]&&b[n.op]()},_.prototype._onFormSubmit=function(n){const o=n.target;if(n.defaultPrevented)return;const s=o.hasAttribute(r)?o.getAttribute(r):null;if(s===null||(s?!this._owns(s):o.closest("["+e+"]")!==this.dom))return;const f=G(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=P(o);delete w._method,delete w._token;const b=w.id,S=w.expected_version,E=o.getAttribute("action")||"",d=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(d,w,E):this._fanOutUpdate(d,b,w,S,E)},_.prototype._reconcileServerFetch=function(n){if(!n)return;const o=n.meta||{},s=this.findChildren(),f=n.data;this.refreshMapper();const w=Array.isArray(f)?f:(f==null?void 0:f.data)||[],b=Array.isArray(f==null?void 0:f.deleted)?f.deleted:[],S=Array.isArray(f)?Math.floor(Date.now()/1e3):(f==null?void 0:f.synced_at)??(f==null?void 0:f.since)??Math.floor(Date.now()/1e3),E=w.map(d=>this.mapper.ingress(d));if(!(!s.store||s.store.initializationError)){if(!o.kind)return s.store.applySync(E,b,S,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:o.targetEl});s.store.applyQuery(E,{total:n.total}).then(d=>{const h=o.kind;h==="table"||h==="list"||h==="chart"?(C(o.targetEl,"ln-"+h+":set-loading",{loading:!1}),C(o.targetEl,"ln-"+h+":set-data",{data:d,total:n.total??d.length,filtered:n.filtered??d.length,offset:n.offset,queryGen:o.queryGen}),this._boundDelivered.set(o.targetEl,!0)):h==="options"?s.store.getAll({}).then(y=>C(o.targetEl,"ln-options:set-data",{data:y.data})):h==="stat"&&C(o.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??E.length})})}},_.prototype._reconcileServerMutation=function(n,o){var w;if(!o)return;const s=this.findChildren(),f=o.meta||{};if(n==="create"){if(!o.record)return this._reportError("create-empty-response",new Error("Create response missing record payload"),f);const b=this.mapper.ingress(o.record);(s.storeEl?this._requestStoreMutation(s,"update",{id:f.tempId,data:b}):Promise.resolve()).then(()=>{f.queued&&s.queue&&C(s.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:b.id})}).catch(S=>this._reportError("create-reconcile",S,f))}else if(n==="update"){const b=o.record?this.mapper.ingress(o.record):null;(s.storeEl&&b?this._requestStoreMutation(s,"update",{id:f.id,data:b}):Promise.resolve()).then(()=>{f.queued&&s.queue&&C(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(S=>this._reportError("update-reconcile",S,f))}else if(n==="ack")f.queued&&s.queue&&C(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId});else if(n==="error"){const b=o.status||((w=o.error)==null?void 0:w.status)||0;f.queued&&s.queue&&C(s.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:b===401||b===419?"auth":b===0||b>=500?"retry":"drop"}),s.storeEl&&C(s.storeEl,"ln-data-store:request-sync-failed",{error:o.error||o,status:b}),this._reportError("connector-error",o.error||o,f)}},_.prototype.destroy=function(){var n;if(this.dom[t]){for(this._destroyed=!0;(n=this._unsubs)!=null&&n.length;)this._unsubs.pop()();this._unsubs=this._boundQueries=this._boundDelivered=this._queueQueryRefresh=null,this._mutationReceipts.close(new Error("Data coordinator destroyed")),this._mutationReceipts=null,delete this.dom[t]}};function U(n,o){const s=n[t];s&&(o==="data-ln-data-coordinator-mapper"?s.refreshMapper():(o===i||o===l||o===u||o===c)&&s._queueQueryRefresh())}ue(e,t,_,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",i,l,u,c],onAttributeChange:U}),window[t].init=window[t]})()})();
@@ -19,6 +19,24 @@
19
19
  </ul>
20
20
  ```
21
21
 
22
+ ### ⚡ Server-Rendered (SSR) Instant Seed
23
+ Embed authoritative server data directly in a `<script type="application/json">` child (or point to it via `data-ln-data-store-seed="#my-seed"`). The store parses the array on initialization and serves reads with zero network latency:
24
+
25
+ ```html
26
+ <ul id="tenants"
27
+ data-ln-data-store
28
+ data-ln-data-store-indexes="status,package_id"
29
+ data-ln-data-store-search-fields="name,slug"
30
+ hidden>
31
+ <script type="application/json">
32
+ [
33
+ {"id": 1, "name": "Acme Corp", "slug": "acme", "status": "active"},
34
+ {"id": 2, "name": "Globex", "slug": "globex", "status": "pending"}
35
+ ]
36
+ </script>
37
+ </ul>
38
+ ```
39
+
22
40
  ---
23
41
 
24
42
  ## 🌐 Declarative Attributes
@@ -27,6 +45,7 @@
27
45
  |---|---|---|
28
46
  | `id="name"` | Unique identifier of the store (the store name). | *Required* |
29
47
  | `data-ln-data-store` | Marker attribute to declare the component. | *Required* |
48
+ | `data-ln-data-store-seed="…"` | Selector or element ID of an external seed script block containing an initial JSON records array. | *Optional* |
30
49
  | `data-ln-data-store-stale="N"` | Seconds before cache is considered stale. Set to `never` or `-1` to disable staleness. | `300` |
31
50
  | `data-ln-data-store-indexes="…"` | Comma-separated list of IndexedDB index fields. | `""` |
32
51
  | `data-ln-data-store-search-fields="…"` | Comma-separated list of text-search fields for local query search matching. | `""` |
@@ -1 +1 @@
1
- (function(){"use strict";function pe(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function oe(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let i=null;for(let a=1;a<t.length;a++)if(t[a]&&t[a].nodeType===1){i=t[a];break}if(!oe(i))return}e.apply(console,t)}}function A(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function Z(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){Z(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function Ue(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Ge(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,a={},l=e.elements,c={};if(r)for(let d=0;d<l.length;d++){const s=l[d];s.name&&s.type==="checkbox"&&!s.disabled&&(c[s.name]=(c[s.name]||0)+1)}for(let d=0;d<l.length;d++){const s=l[d];if(!(!s.name||s.disabled||s.type==="file"||s.type==="submit"||s.type==="button")&&!(i&&s.matches&&s.matches(i)))if(s.type==="checkbox")r&&c[s.name]===1?a[s.name]=s.checked:(a[s.name]||(a[s.name]=[]),s.checked&&a[s.name].push(s.value));else if(s.type==="radio")s.checked&&(a[s.name]=s.value);else if(s.type==="select-multiple"){a[s.name]=[];for(let w=0;w<s.options.length;w++)s.options[w].selected&&a[s.name].push(s.options[w].value)}else if(r&&s.type==="hidden")a[s.name]=s.value;else if(r&&(s.type==="number"||s.type==="range")){const w=Number(s.value);a[s.name]=s.value===""||isNaN(w)?null:w}else a[s.name]=s.value}return a}function Ve(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function We(e,t){const r=e.elements,i=[],a={};for(let l=0;l<r.length;l++){const c=r[l];c.name&&c.type==="checkbox"&&(a[c.name]=(a[c.name]||0)+1)}for(let l=0;l<r.length;l++){const c=r[l];if(c.type==="file"||c.type==="submit"||c.type==="button")continue;const d=c.getAttribute("data-ln-fill-as")||c.name;if(!d||!(d in t))continue;const s=t[d];if(c.type==="checkbox"){if(Array.isArray(s))c.checked=s.indexOf(c.value)!==-1;else if(a[c.name]>1){const w=String(s).split(",").map(function(b){return b.trim()});c.checked=w.indexOf(c.value)!==-1}else c.checked=Ve(s);i.push(c)}else if(c.type==="radio")c.checked=c.value===String(s),i.push(c);else if(c.type==="select-multiple"){if(Array.isArray(s))for(let w=0;w<c.options.length;w++)c.options[w].selected=s.indexOf(c.options[w].value)!==-1;i.push(c)}else c.value=s,c.tagName==="SELECT"&&s!=null&&c.setAttribute("data-ln-value",s),i.push(c)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=We,window.lnCore.serializeForm=Ge,window.lnCore.resolveFormMethod=Ue);const ge={};function He(e,t){ge[e]=t}function Qe(e){return ge[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=He,window.lnCore.getDataMapper=Qe);function Je(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,Z(function(){new MutationObserver(function(){A(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const me={};function Ze(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];me[r]=t}function Xe(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return me[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ze,window.lnCore.getLocaleFallback=Xe,window.lnCore.ensureLocaleObserver=Je);const ie={};function Ye(e,t){ie[e]||(ie[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=ie[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function be(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let c=0;c<r.length;c++){const d=r[c],s=d.getAttribute("data-ln-field");t[s]!=null&&(d.textContent=t[s])}const i=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<i.length;c++){const d=i[c],s=d.getAttribute("data-ln-attr").split(",");for(let w=0;w<s.length;w++){const b=s[w].trim().split(":");if(b.length!==2)continue;const _=b[0].trim(),x=b[1].trim();t[x]!=null&&d.setAttribute(_,t[x])}}const a=e.querySelectorAll("[data-ln-show]");for(let c=0;c<a.length;c++){const d=a[c],s=d.getAttribute("data-ln-show");s in t&&d.classList.toggle("hidden",!t[s])}const l=e.querySelectorAll("[data-ln-class]");for(let c=0;c<l.length;c++){const d=l[c],s=d.getAttribute("data-ln-class").split(",");for(let w=0;w<s.length;w++){const b=s[w].trim().split(":");if(b.length!==2)continue;const _=b[0].trim(),x=b[1].trim();x in t&&d.classList.toggle(_,!!t[x])}}return e}function et(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)be(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<t.length;r++)t[r].textContent=""}})));function _e(e,t){if(!e||!t)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const l=r.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,d){return t[d]!==void 0?t[d]:""}))}const i=function(l,c){return t[c]!==void 0?t[c]:""},a=Array.from(e.querySelectorAll("*"));e.nodeType===1&&a.push(e);for(let l=0;l<a.length;l++){const c=a[l],d=c.attributes;for(let s=0;s<d.length;s++){const w=d[s];w.value.indexOf("{{")!==-1&&c.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function tt(e,t,r,i,a,l){const c={};for(let s=0;s<e.children.length;s++){const w=e.children[s],b=w.getAttribute("data-ln-render-key");b&&(c[b]=w)}const d=document.createDocumentFragment();for(let s=0;s<t.length;s++){const w=t[s],b=String(i(w));let _=c[b];if(_)a(_,w,s);else{const x=Ye(r,l);if(!x||(_e(x,w),_=x.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",b),a(_,w,s)}d.appendChild(_)}e.textContent="",e.appendChild(d)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=_e,window.lnCore.fill=be,window.lnCore.lnFill=et,window.lnCore.renderList=tt);function ae(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function X(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function se(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const a=i.trim().toLowerCase();return!(a==="false"||a==="0")}function le(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const ce=new Map;function Ce(e,t){const r=(e?e.join("|"):"")+"::"+t;if(ce.has(r))return ce.get(r);const i=new Set(e||[]),a=function(l,c){const d=l.getAttribute(c);return d!==null&&i.has(d)?d:t};return ce.set(r,a),a}function Se(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function Ae(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function ve(e,t,r,i,a){if(!e||t===null)return!0;const l=i||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const d=s=>{a?console.warn(s,a):console.warn(s)};if(c==="boolean"){const s=t.trim().toLowerCase();return s!==""&&s!=="true"&&s!=="false"&&s!=="1"&&s!=="0"?(d(`[${l}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const s=e.values||[];return s.includes(t)?!0:(d(`[${l}] Invalid value "${t}" for attribute "${r}". Allowed: ${s.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return d(`[${l}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const s=parseInt(t,10);return e.min!==void 0&&s<e.min?(d(`[${l}] Value ${s} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&s>e.max?(d(`[${l}] Value ${s} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(d(`[${l}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(s){return d(`[${l}] Invalid JSON for attribute "${r}": ${s.message}. Fallback: ${e.fallback}.`),!1}return!0}function xe(e,t,r){for(const i in r){const[a,l,c]=r[i];Object.defineProperty(e,i,{get:function(){return a(t,l,c)},enumerable:!0,configurable:!0})}return e}function ke(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let a=i.read;if(!a&&i.type)switch(i.type){case"enum":a=Ce(i.values,i.fallback);break;case"integer":a=X;break;case"float":a=Se;break;case"boolean":a=se;break;case"list":a=le;break;case"json":a=Ae;break;case"string":default:a=ae;break}a||(a=ae),t[i.prop]=[a,r,i.fallback]}return t}function nt(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function rt(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const r in e.effects)t.add(r);if(e.onAttrChange&&e.declared)for(const r of e.declared)t.add(r);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=xe,window.lnCore.attrSpec=ke,window.lnCore.attrStr=ae,window.lnCore.attrInt=X,window.lnCore.attrBool=se,window.lnCore.attrList=le,window.lnCore.attrEnum=Ce,window.lnCore.attrFloat=Se,window.lnCore.attrJson=Ae);function V(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(r){console.error("["+t.attribute+"] init failed",e,r)}}}function qe(e,t,r,i){if(e.nodeType!==1)return;const l=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:r,ComponentFn:i};if(e.matches&&e.matches(l)&&V(e,c),e.querySelectorAll){const d=e.querySelectorAll(l);for(let s=0;s<d.length;s++)V(d[s],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function ot(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function it(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function Ee(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function at(e){const t=Ee(),r=e.observed||[];for(let i=0;i<r.length;i++){const a=r[i];t.byAttr.has(a)||t.byAttr.set(a,[]),t.byAttr.get(a).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const a=t.byDeclaredAttr.get(i);a.some(l=>l.componentTag===e.componentTag)||a.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=rt(e);if(i===null)t.reactiveWildcard.push(e);else for(const a of i)t.byReactive.has(a)||t.byReactive.set(a,[]),t.byReactive.get(a).push(e)}e.persist&&t.persist.push(e)}function Ie(e,t,r,i){for(let a=0;a<e.length;a++){const l=e[a];if(!t[l.attribute])continue;const c=l.effects&&l.effects[r];c?c(t,r,i):l.onAttrChange&&(!l.declared||l.declared.has(r))&&l.onAttrChange(t,r,i)}}function st(e){const t=e.attributeName,r=t.indexOf("data-ln-")===0,i=Ee(),a=i.byAttr.get(t),l=pe()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(t);if(!r&&!a&&!l)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(l&&oe(c)){const d=i.byDeclaredAttr.get(t),s=c.getAttribute(t);for(let w=0;w<d.length;w++)ve(d[w].spec,s,t,d[w].componentTag,c)}if(window.lnCore._debugSink&&(r||a)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),r){const d=i.byReactive.get(t);d&&Ie(d,c,t,e.oldValue),i.reactiveWildcard.length&&Ie(i.reactiveWildcard,c,t,e.oldValue)}if(a)for(let d=0;d<a.length;d++){const s=a[d];if(s.handler){s.handler(c,t,e.oldValue);continue}s.onAttributeChange&&c[s.attribute]?s.onAttributeChange(c,t):(qe(c,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(c))}}}function lt(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,Z(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{st(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function ue(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function de(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function fe(e,t){if(!document.contains(e))if(t.attribute){const r=e[t.attribute];if(r&&typeof r.destroy=="function")try{r.destroy()}catch(i){console.error("["+t.attribute+"] destroy failed",e,i)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function Le(e){const t=ue();if(!t.length)return;const r=e.target;if(r){const a=r.nodeType===1?r:r.parentElement;if(a&&(a.isContentEditable||a.closest&&a.closest('[contenteditable]:not([contenteditable="false"])')))return}const i=de();if(e.target&&i.length)for(let a=0;a<i.length;a++){const l=i[a],c=l.query,d=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;d&&l.onSubtreeChange(d,e)}for(let a=0;a<e.addedNodes.length;a++){const l=e.addedNodes[a];if(l.nodeType===1){const c=!!(l.firstElementChild||l.children&&l.children.length);for(let d=0;d<t.length;d++){const s=t[d];if(s.selector&&s.attribute&&s.ComponentFn){if(!c)l.matches&&l.matches(s.query)&&V(l,s);else if(l.matches&&l.matches(s.query)&&V(l,s),l.querySelectorAll){const w=l.querySelectorAll(s.query);for(let b=0;b<w.length;b++)V(w[b],s)}}s.onInit&&s.onInit(l)}}}for(let a=0;a<e.removedNodes.length;a++){const l=e.removedNodes[a];if(l.nodeType===1){if(document.contains(l))continue;const c=!!(l.firstElementChild||l.children&&l.children.length);for(let d=0;d<t.length;d++){const s=t[d],w=s.query;if(w){if(!c)l.matches&&l.matches(w)&&fe(l,s);else if(l.matches&&l.matches(w)&&fe(l,s),l.querySelectorAll){const b=l.querySelectorAll(w);for(let _=0;_<b.length;_++)fe(b[_],s)}}}}}}function De(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,Z(function(){const e=new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{Le(i)}catch(a){console.error("[ln-core] lifecycle handler failed",i.target,a)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ct(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const r=t.takeRecords();for(let i=0;i<r.length;i++){const a=r[i];if(a.type==="childList")try{Le(a)}catch(l){console.error("[ln-core] lifecycle handler failed",a.target,l)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function ut(e){ue().push(e),e.onSubtreeChange&&e.query&&de().push(e),De()}function Ne(e,t,r,i,a={}){const l=a.extraAttributes||[],c=a.onAttributeChange||null,d=a.onSubtreeChange||null,s=a.onInit||null,w=a.onAttrChange||null,b=a.effects||null,_=a.attributes||null,x=_?nt(_):b,j=_?new Set(Object.keys(_)):null,$=a.persist||null;function g(L){const D=L||document.body;if(qe(D,e,t,r),_&&pe())for(const M in _){const we=_[M],U=Array.from(D.querySelectorAll("["+M+"]"));D.matches&&D.matches("["+M+"]")&&U.push(D);for(let P=0;P<U.length;P++){const H=U[P];oe(H)&&ve(we,H.getAttribute(M),M,i,H)}}s&&s(D)}const S=[];if(e.indexOf("[")!==-1){const L=/\[([\w-]+)/g;let D;for(;(D=L.exec(e))!==null;)S.push(D[1])}else S.push(e);at({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:r,onInit:s,observed:S.concat(l),onAttributeChange:c,onAttrChange:w,effects:x,declared:j,persist:$}),lt();const I=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,k=a.subtreeQuery||(I?e:"["+e+"]"),v={selector:e,attribute:t,ComponentFn:r,onInit:s,onSubtreeChange:d,query:k};ue().push(v),d&&k&&de().push(v),De(),window[t]=g,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=Ne,window.lnCore.observeLifecycle=ut,window.lnCore.withoutLifecycle=ct);function q(){ot()>0?it(function(){g(document.body)}):g(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",q):q(),g}function dt(e){let t=!1;for(let r=0;r<e.length;r++){const i=e[r];if(!(i===""||i==null)&&(t=!0,!Number.isFinite(Number(i))))return"string"}return t?"number":"string"}function ft(e,t,r,i){if(r==="number"){const c=parseFloat(e),d=parseFloat(t);return(isNaN(c)?0:c)-(isNaN(d)?0:d)}const a=e!=null?String(e):"",l=t!=null?String(t):"";return i?i.compare(a,l):a<l?-1:a>l?1:0}function Te(e){return(e||"").replace(/^#/,"")}function he(e){const t=e===void 0?location.hash:e,r={},i=Te(t);if(!i)return r;const a=i.split("&");for(let l=0;l<a.length;l++){const c=a[l];if(!c)continue;const d=c.indexOf(":"),s=d>-1?c.slice(0,d):c,w=d>-1?c.slice(d+1):"";if(s)try{r[s]=decodeURIComponent(w)}catch{r[s]=w}}return r}function ht(e){if(!e)return null;const t=he();return e in t?t[e]:null}function wt(e,t){if(!e)return;const r=he();t==null?delete r[e]:r[e]=String(t);const a=Object.keys(r).map(function(l){const c=r[l];return c===""?l:l+":"+encodeURIComponent(c)}).join("&");Te(location.hash)!==a&&(location.hash=a)}function yt(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function pt(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function gt(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function mt(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function bt(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function _t(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),a=i?i.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:r,values:a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=he,window.lnCore.hashGet=ht,window.lnCore.hashSet=wt,window.lnCore.hashLinkClick=yt,window.lnCore.resolveHashNamespace=pt,window.lnCore.hashSortEncode=gt,window.lnCore.hashSortDecode=mt,window.lnCore.hashFilterEncode=bt,window.lnCore.hashFilterDecode=_t);function Ct(e){return(e||"").replace(/^\?/,"")}function St(e){const t=e===void 0?typeof window<"u"?window.location.search:"":e,r={},i=Ct(t);if(!i)return r;const a=new URLSearchParams(i);for(const[l,c]of a.entries())r[l]=c;return r}function At(e){if(!e||typeof window>"u")return null;const t=new URLSearchParams(window.location.search);return t.has(e)?t.get(e):null}function vt(e,t){if(!e||typeof window>"u")return;const r=new URL(window.location.href);if(t==null||t===""?r.searchParams.delete(e):r.searchParams.set(e,String(t)),r.search===window.location.search)return;const i=r.pathname+r.search+r.hash;window.history.replaceState(window.history.state,"",i)}function xt(e,t){if(!e||!e.hasAttribute("data-ln-query"))return null;const r=e.getAttribute("data-ln-query");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"_"+t:i:t||null}function kt(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function qt(e,t){if(e&&typeof e=="string"){if(e.endsWith(".asc"))return{fieldOrColumn:e.slice(0,-4),direction:"asc"};if(e.endsWith(".desc"))return{fieldOrColumn:e.slice(0,-5),direction:"desc"}}if(t&&typeof t=="object"){const r=t.sort_field||t.sort_by;if(r){const i=t.sort_dir&&String(t.sort_dir).toLowerCase()==="desc"?"desc":"asc";return{fieldOrColumn:r,direction:i}}}return null}function Et(e){return!Array.isArray(e)||e.length===0?null:e.map(encodeURIComponent).join(",")}function It(e){return!e||typeof e!="string"?[]:e.split(",").map(function(t){try{return decodeURIComponent(t.trim())}catch{return t.trim()}}).filter(Boolean)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.queryParse=St,window.lnCore.queryGet=At,window.lnCore.querySet=vt,window.lnCore.resolveQueryParam=xt,window.lnCore.querySortEncode=kt,window.lnCore.querySortDecode=qt,window.lnCore.queryFilterEncode=Et,window.lnCore.queryFilterDecode=It);let W=null;const Lt="ln-ashlar:storage-salt:v1",Re=32768;function ze(e){let t="";const r=e.byteLength;for(let i=0;i<r;i+=Re)t+=String.fromCharCode.apply(null,e.subarray(i,Math.min(i+Re,r)));return btoa(t)}function Oe(e){const t=atob(e),r=t.length,i=new Uint8Array(r);for(let a=0;a<r;a++)i[a]=t.charCodeAt(a);return i}function Fe(e,t){let r=W,i={};return typeof CryptoKey<"u"&&e instanceof CryptoKey?r=e:e&&typeof e=="object"&&(i=e,typeof CryptoKey<"u"&&i.key instanceof CryptoKey&&(r=i.key)),{key:r,options:i}}async function Dt(e,t={}){if(!e)throw new Error("[ln-crypto] Key derivation failed: Secret string is required");const r=t.method||"pbkdf2",i=new TextEncoder;if(r==="sha256"){const s=await crypto.subtle.digest("SHA-256",i.encode(e));return crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["encrypt","decrypt"])}const a=t.salt||Lt,l=typeof a=="string"?i.encode(a):a,c=t.iterations||1e5,d=await crypto.subtle.importKey("raw",i.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:l,iterations:c,hash:"SHA-256"},d,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Be(e,t={}){if(!e){W=null;return}try{const r=t.method||"sha256";W=await Dt(e,{...t,method:r})}catch(r){throw console.error("[ln-core/crypto] Key derivation failed:",r),W=null,r}}function B(){return W}async function Nt(e,t,r){const{key:i}=Fe(t);if(e==null)return e;if(!i)throw new Error("[ln-crypto] Encryption failed: No active cryptographic key provided");try{const a=new TextEncoder,l=crypto.getRandomValues(new Uint8Array(12)),c=typeof e=="string"?e:JSON.stringify(e),d=await crypto.subtle.encrypt({name:"AES-GCM",iv:l},i,a.encode(c));return{v:1,alg:"AES-GCM",encrypted:!0,iv:ze(l),data:ze(new Uint8Array(d))}}catch(a){throw console.error("[ln-core/crypto] Encryption failed:",a),new Error("[ln-crypto] Encryption failed: "+(a&&a.message?a.message:String(a)))}}async function Tt(e,t,r){const{key:i,options:a}=Fe(t),l=a.silent===!0;if(!e||!e.encrypted)return e;if(!i){if(l)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: No active cryptographic key provided")}if(!e.iv||!e.data){if(l)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: Malformed envelope (missing iv or data)")}try{const c=new TextDecoder,d=Oe(e.iv),s=Oe(e.data),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:d},i,s),b=c.decode(w);try{return JSON.parse(b)}catch{return b}}catch(c){if(l)return{...e,decryptionError:!0};throw console.error("[ln-core/crypto] Decryption failed. Key may be incorrect or payload tampered:",c),new Error("[ln-crypto] Decryption failed. Key may be incorrect or payload tampered: "+(c&&c.message?c.message:String(c)))}}function Rt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=Rt);function zt(e){return String(e||"").trim().toLowerCase()}function Ot(e){const t=zt(e);return t?t.split(/\s+/).filter(Boolean):[]}function Ft(e,t){if(!t||t.length===0)return!0;if(!e)return!1;const r=String(e).toLowerCase();for(let i=0;i<t.length;i++)if(r.indexOf(t[i])===-1)return!1;return!0}function Bt(e,t){if(!t||t.length===0)return!0;if(e==null)return!1;const r=String(e).trim().toLowerCase();for(let i=0;i<t.length;i++)if(String(t[i]).trim().toLowerCase()===r)return!0;return!1}function Mt(e={}){let t=e.windowSize>0?e.windowSize:1e3,r=e.pageSize>0?e.pageSize:200,i=e.fetchDebounce!=null?e.fetchDebounce:120;const a=typeof e.requestPage=="function"?e.requestPage:()=>{},l=new Map,c=new Set;let d=0,s=0,w=0,b=!1,_=null;function x(g,S){l.delete(g),l.set(g,S)}function j(){if(l.size<=t)return[];const g=[];for(;l.size>t;){const I=l.keys().next().value;g.push(l.get(I)),l.delete(I)}const S=new Set(l.values());return g.filter(I=>!S.has(I))}function $(g,S){c.add(g),clearTimeout(_),_=setTimeout(()=>a(g,r,S),i)}return{get logicalTotal(){return d},set logicalTotal(g){d=g},get grandTotal(){return s},set grandTotal(g){s=g},get queryGen(){return w},set queryGen(g){w=g},get size(){return l.size},get hasLoaded(){return b},getId:g=>{if(!l.has(g))return;const S=l.get(g);return x(g,S),S},ensure:(g,S,I)=>{if(!b&&!c.has(0))return $(0,I);if(d<=0)return;const k=Math.max(0,g),v=Math.min(d,S);for(let q=k;q<v;q++)if(!l.has(q)){const L=Math.floor(q/r)*r;if(!c.has(L))return $(L,I)}},ingest:(g,S,I,k,v)=>{if(v!=null&&v!==w)return[];b=!0,I!=null&&(s=I),k!=null&&(d=k);for(let q=0;q<S.length;q++)x(g+q,S[q]);return c.delete(g),j()},reset:function(){w++,this.clear()},clear:()=>{b=!1,l.clear(),c.clear(),clearTimeout(_)},configure:(g={})=>{let S=[];return g.windowSize>0&&g.windowSize!==t&&(t=g.windowSize,S=j()),g.pageSize>0&&(r=g.pageSize),g.fetchDebounce>=0&&(i=g.fetchDebounce),S}}}function Pt(e,t,r){if(!Array.isArray(e)||!t||!t.field)return e;const{field:i,direction:a}=t,l=a==="desc",c=e.map(s=>s?s[i]:void 0),d=dt(c);return[...e].sort((s,w)=>{const b=s?s[i]:void 0,_=w?w[i]:void 0,x=ft(b,_,d,r);return l?-x:x})}function Me(e,t){if(!Array.isArray(e)||!t||typeof t!="object")return e;const r=Object.keys(t).filter(i=>Array.isArray(t[i])&&t[i].length>0);return r.length?e.filter(i=>i?r.every(a=>Bt(i[a],t[a])):!1):e}function jt(e,t,r){if(!Array.isArray(e)||!t||!r||!r.length)return e;const i=Ot(t);return i.length?e.filter(a=>a?i.every(l=>r.some(c=>{const d=a[c];return d!=null&&Ft(String(d),[l])})):!1):e}function $t(e,t,r){if(!Array.isArray(e)||!e.length)return 0;if(r==="count")return e.length;const i=e.map(l=>l&&l[t]!=null?parseFloat(l[t]):NaN).filter(l=>Number.isFinite(l)),a=i.reduce((l,c)=>l+c,0);return r==="sum"?a:r==="avg"&&i.length?a/i.length:0}function Kt(e,t={},r=[],i){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const a=e.length;let l=e;t.filters&&(l=Me(l,t.filters)),t.search&&(l=jt(l,t.search,r));const c=l.length;if(t.sort&&(l=Pt(l,t.sort,i)),t.offset||t.limit){const d=t.offset||0,s=t.limit||l.length;l=l.slice(d,d+s)}return{records:l,total:a,filtered:c}}function Ut(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(r=>{if(!r)return null;const i={...r};for(const[a,l]of Object.entries(t))if(typeof l=="function")try{i[a]=l(r)}catch{i[a]=void 0}return i})}function Gt(e,t,r,i="_meta"){if(!Array.isArray(e)||!e.includes(i))return!0;for(const a of Object.keys(t||{})){if(!e.includes(a))return!0;const l=t[a]&&t[a].indexes||[],c=r&&r[a]||[];if(l.some(d=>!c.includes(d)))return!0}return!1}function Vt(e){return{ok:!1,error:e&&e.message?e.message:String(e)}}(function(){const e="data-ln-data-store",t="lnDataStore";if(window[t]!==void 0)return;function r(n,o,u){const f=n.getAttribute(o);if(f==="never"||f==="-1")return-1;const h=parseInt(f,10);return isNaN(h)?u:h}const i={"data-ln-data-store":{type:"marker",effect:Ke,description:"Identifies the element as a data-store definition container"},"data-ln-data-store-indexes":{type:"list",effect:Ke,description:"Comma-separated index field names for the IndexedDB store"},"data-ln-data-store-stale":{prop:"_staleThreshold",type:"integer",read:r,fallback:300,description:"Cache staleness threshold in seconds, or -1/never"},"data-ln-data-store-search-fields":{prop:"_searchFields",type:"list",read:le,description:"Record fields to index for client-side search"},"data-ln-data-store-no-local-query":{prop:"noLocalQuery",type:"boolean",read:se,description:"Bypasses local IndexedDB query resolution, forcing remote fetching"},"data-ln-data-store-window":{prop:"_windowSize",type:"integer",read:X,fallback:1e3,min:10,effect:hn,description:"Virtual scrolling cache window size in records"},"data-ln-data-store-window-page":{prop:"_windowPageSize",type:"integer",read:X,fallback:200,min:5,effect:wn,description:"Virtual scrolling slice page size"},"data-ln-data-store-frozen":{type:"marker",description:"Applied at runtime to indicate store schema is locked in IndexedDB"}},a=ke(i),l="ln_app_cache",c="_meta",d="1.0";let s=null,w=null;const b={};function _(n){n&&n.name==="QuotaExceededError"&&A(document,"ln-data-store:quota-exceeded",{error:n})}function x(){const n={};for(const o of document.querySelectorAll(`[${e}]`)){const u=o.id;if(u){const f=o.getAttribute("data-ln-data-store-indexes")||"";n[u]={indexes:f.split(",").map(h=>h.trim()).filter(Boolean)}}}return n}function j(){return w||(w=new Promise(n=>{if(typeof indexedDB>"u")return console.warn("[ln-data-store] IndexedDB is not available in this environment"),n(null);const o=x(),u=Object.keys(o),f=indexedDB.open(l);f.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed"),n(null)},f.onsuccess=h=>{const y=h.target.result,p=Array.from(y.objectStoreNames),m=u.filter(T=>p.includes(T));let C={};if(m.length>0){const T=y.transaction(m,"readonly");for(const R of m)C[R]=Array.from(T.objectStore(R).indexNames)}if(!Gt(p,o,C,c))return $(y),s=y,n(y);const K=y.version;y.close();const F=indexedDB.open(l,K+1);let z=!1,O=null;F.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),A(document,"ln-data-store:blocked",{db:l}),O||(O=setTimeout(()=>{z||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),z=!0,w=null,n(null))},5e3))},F.onerror=()=>{z||(O&&clearTimeout(O),z=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},F.onupgradeneeded=T=>{const R=T.target.result,yn=T.target.transaction;R.objectStoreNames.contains(c)||R.createObjectStore(c,{keyPath:"key"});for(const J of u)if(R.objectStoreNames.contains(J)){const re=yn.objectStore(J);for(const G of o[J].indexes)re.indexNames.contains(G)||re.createIndex(G,G,{unique:!1})}else{const re=R.createObjectStore(J,{keyPath:"id"});for(const G of o[J].indexes)re.createIndex(G,G,{unique:!1})}},F.onsuccess=T=>{if(z){T.target.result&&T.target.result.close();return}O&&clearTimeout(O),z=!0;const R=T.target.result;$(R),s=R,n(R)}}}),w)}function $(n){n.onversionchange=()=>{n.close(),s=null,w=null}}function g(){return s?Promise.resolve(s):(w=null,j())}async function S(n){if(!B()||!n)return n;const o={...n},u=o.id,f=await Nt(o);return!f||!f.encrypted?n:{...f,id:u}}async function I(n){return!n||!n.encrypted||!B()?n:Tt(n,{silent:!0})}const k=(n,o)=>g().then(u=>u?u.transaction(n,o).objectStore(n):null);function v(n){return new Promise((o,u)=>{n.onsuccess=()=>o(n.result),n.onerror=()=>{_(n.error),u(n.error)}})}const q=n=>k(n,"readonly").then(o=>o?v(o.getAll()):[]).then(o=>B()?Promise.all(o.map(u=>I(u))):o),L=(n,o)=>k(n,"readonly").then(u=>u?v(u.get(o)).then(f=>f!==void 0?f:typeof o=="string"&&o.trim()!==""&&!isNaN(Number(o))?v(u.get(Number(o))):typeof o=="number"?v(u.get(String(o))):null):null).then(u=>u?I(u):null),D=(n,o)=>g().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=o.map(p=>v(h.get(p)).then(m=>m!==void 0?m:typeof p=="string"&&p.trim()!==""&&!isNaN(Number(p))?v(h.get(Number(p))):typeof p=="number"?v(h.get(String(p))):null));return Promise.all(y).then(p=>B()?Promise.all(p.map(m=>m?I(m):null)):p)}),M=(n,o)=>(B()?S(o):Promise.resolve(o)).then(f=>k(n,"readwrite").then(h=>h?v(h.put(f)):null)),we=(n,o)=>k(n,"readwrite").then(u=>u?v(u.delete(o)).then(()=>{if(typeof o=="string"&&o.trim()!==""&&!isNaN(Number(o)))return v(u.delete(Number(o)));if(typeof o=="number")return v(u.delete(String(o)))}):null),U=n=>k(n,"readwrite").then(o=>o?v(o.clear()):null),P=n=>k(n,"readonly").then(o=>o?v(o.count()):0),H=n=>k(c,"readonly").then(o=>o?v(o.get(n)):null),Y=(n,o)=>k(c,"readwrite").then(u=>{if(u)return o.key=n,v(u.put(o))});function N(n){return this.dom=n,this._name=n.id,this._name||console.warn("[ln-data-store] missing id — the store cannot be addressed",n),xe(this,n,a),this._handlers=null,this.isLoaded=!1,this.canServe=!1,this.isInitialized=!1,this.initializationError=null,this.hasCache=!1,this.isSyncing=!1,this.lastSyncedAt=null,this.query={filters:{},search:"",sort:null},n.hasAttribute("data-ln-data-store-window")?this._windowIndex=Mt({windowSize:this._windowSize,pageSize:this._windowPageSize,requestPage:(o,u,f)=>{A(this.dom,"ln-data-store:request-page",{store:this._name,offset:o,limit:u,query:f,queryGen:this._windowIndex.queryGen})}}):this._windowIndex=null,this.windowed=this._windowIndex!==null,this.totalCount=0,this.presenters=null,this._mutationChain=Promise.resolve(),b[this._name]=this,Wt(this),this.ready=Yt(this),this}function Wt(n){n._handlers={create:o=>ee(n,"create",o.detail,()=>Ht(n,o.detail)),update:o=>ee(n,"update",o.detail,()=>Qt(n,o.detail)),delete:o=>ee(n,"delete",o.detail,()=>Jt(n,o.detail)),"bulk-delete":o=>ee(n,"bulk-delete",o.detail,()=>Zt(n,o.detail)),"sync-failed":o=>{n.isSyncing=!1,A(n.dom,"ln-data-store:sync-error",{store:n._name,error:o.detail&&o.detail.error,status:o.detail&&o.detail.status})}};for(const[o,u]of Object.entries(n._handlers))n.dom.addEventListener(`ln-data-store:request-${o}`,u);n._queryHandlers={"ln-search:change":o=>{o.preventDefault();const u=o.detail&&o.detail.term!=null?o.detail.term:"";u!==n.query.search&&(n.query.search=u,ye(n))},"ln-filter:change":o=>{o.preventDefault();const u=o.detail&&o.detail.key;if(!u)return;const f=(o.detail.values||[]).slice(),h=n.query.filters[u];(h?h.length===f.length&&h.every((p,m)=>p===f[m]):!f.length)||(f.length?n.query.filters[u]=f:delete n.query.filters[u],ye(n))},"ln-sort:change":o=>{o.preventDefault();const u=o.detail&&o.detail.field,f=o.detail&&o.detail.direction,h=f&&f!=="none"?{field:u,direction:f}:null,y=n.query.sort;!y&&!h||y&&h&&y.field===h.field&&y.direction===h.direction||(n.query.sort=h,ye(n))}};for(const[o,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(o,u)}function ee(n,o,u,f){const h=u&&u.requestId;return n._mutationChain=n._mutationChain.then(()=>n.ready).then(()=>{if(n.initializationError)throw n.initializationError;return f()}).catch(y=>Xt(n,o,h,y)),n._mutationChain}function te(n,o=0){return P(n._name).then(u=>{if(n._windowIndex||n.windowed){const f=n.totalCount!=null?n.totalCount:u;n.totalCount=Math.max(0,f+o)}else n.totalCount=u;return n.hasCache=!0,n.isLoaded=!0,n.canServe=!0,Y(n._name,{schema_version:d,last_synced_at:n.lastSyncedAt,has_cache:!0,record_count:n.totalCount})})}function Ht(n,{tempId:o,data:u={},requestId:f}={}){const h={...u,id:o};return M(n._name,h).then(()=>te(n,1)).then(()=>{A(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:o,requestId:f})})}function Qt(n,{id:o,data:u={},requestId:f}={}){return L(n._name,o).then(h=>{if(!h)throw new Error(`Record not found: ${o}`);const y=h.id,p={...h,...u,id:y},m=u.id,C=m!==void 0&&m!==y;return(C?en(n._name,y,{...p,id:m}):M(n._name,p)).then(()=>te(n,0)).then(()=>{A(n.dom,"ln-data-store:updated",{store:n._name,record:C?{...p,id:m}:p,previous:h,requestId:f})})})}function Jt(n,{id:o,requestId:u}={}){return L(n._name,o).then(f=>{if(!f){A(n.dom,"ln-data-store:deleted",{store:n._name,id:o,requestId:u,missing:!0});return}const h=f.id;return we(n._name,h).then(()=>te(n,-1)).then(()=>{A(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function Zt(n,{ids:o=[],requestId:u}={}){return o.length?Promise.all(o.map(f=>L(n._name,f))).then(f=>{const h=f.filter(Boolean).map(y=>y.id);return ne(n._name,h).then(()=>te(n,-h.length)).then(()=>{A(n.dom,"ln-data-store:deleted",{store:n._name,ids:h,requestId:u})})}):(A(n.dom,"ln-data-store:deleted",{store:n._name,ids:[],requestId:u}),Promise.resolve())}function Xt(n,o,u,f){console.error("[ln-data-store] "+o+" failed:",f),A(n.dom,"ln-data-store:mutation-error",{store:n._name,action:o,requestId:u,error:f})}function Yt(n){return j().then(o=>{if(!o)throw new Error("IndexedDB is unavailable");return H(n._name)}).then(o=>{if(n.initializationError=null,o&&o.schema_version===d)n.lastSyncedAt=o.last_synced_at||null,n.totalCount=o.record_count||0,n.hasCache=o.has_cache===!0||n.totalCount>0,n.hasCache&&(n.isLoaded=!0,n.canServe=!0,A(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"cache"})),n.isInitialized=!0,A(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:n.hasCache,lastSyncedAt:n.lastSyncedAt,count:n.totalCount});else{if(o&&o.schema_version!==d)return U(n._name).then(()=>Y(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isInitialized=!0,n.hasCache=!1,A(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})});n.isInitialized=!0,n.hasCache=!1,A(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})}}).catch(o=>(n.isInitialized=!0,n.isLoaded=!1,n.canServe=!1,n.hasCache=!1,n.isSyncing=!1,n.initializationError=o,A(n.dom,"ln-data-store:initialization-error",{store:n._name,error:o}),{ok:!1,error:o}))}function Pe(n){n.isSyncing=!0,A(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function je(n,o){return g().then(u=>u?(B()?Promise.all(o.map(h=>S(h))):Promise.resolve(o)).then(h=>new Promise((y,p)=>{const m=u.transaction(n,"readwrite"),C=m.objectStore(n);h.forEach(E=>C.put(E)),m.oncomplete=()=>y(),m.onerror=()=>{_(m.error),p(m.error)}})):void 0)}function ne(n,o){return g().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);o.forEach(m=>{p.delete(m),typeof m=="string"&&m.trim()!==""&&!isNaN(Number(m))?p.delete(Number(m)):typeof m=="number"&&p.delete(String(m))}),y.oncomplete=()=>f(),y.onerror=()=>h(y.error)})})}function en(n,o,u){return(B()?S(u):Promise.resolve(u)).then(h=>g().then(y=>{if(y)return new Promise((p,m)=>{const C=y.transaction(n,"readwrite"),E=C.objectStore(n);E.put(h),E.delete(o),C.oncomplete=()=>p(),C.onerror=()=>{_(C.error),m(C.error)}})}))}const tn=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function nn(n){return n?Object.keys(n).filter(o=>Array.isArray(n[o])&&n[o].length>0):[]}function rn(n,o,u){return o.every(f=>u[f].map(String).includes(String(n[f])))}function on(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function an(n,o,u){return o.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function sn(n,o,u){return $t(n,o,u)}function Q(n,o){return Ut(o,n.presenters&&n.presenters.computed)}function ln(n){return!n.sort&&!B()}function cn(n,o,u){const f=nn(o.filters),h=o.search?on(o.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return k(n._name,"readonly").then(m=>m?new Promise((C,E)=>{const K=[],F=m.openCursor();F.onsuccess=()=>{const z=F.result;if(!z||K.length>=u){C(K);return}const O=z.value;(!f.length||rn(O,f,o.filters))&&(!p||an(O,h,y))&&K.push(O),z.continue()},F.onerror=()=>E(F.error)}):[])}function $e(n,o,u){return Kt(o,u,n._searchFields,tn)}function un(n,o,u){const f=[];for(let y=o;y<o+u;y++){const p=n._windowIndex.getId(y);f.push(p)}const h=Array.from(new Set(f.filter(y=>y!==void 0)));return D(n._name,h).then(y=>{const p=new Map;for(let C=0;C<y.length;C++){const E=y[C];E&&p.set(String(E.id),E)}const m=[];for(let C=0;C<f.length;C++){const E=f[C];if(E===void 0)m.push(null);else{const K=p.get(String(E));m.push(K||null)}}return{data:Q(n,m),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:o,queryGen:n._windowIndex.queryGen}})}N.prototype.getAll=function(n={}){const o=this;if(o._windowIndex){const u=n.offset||0,f=n.limit||200;if(o._windowIndex.ensure(u,u+f,n),!o._windowIndex.hasLoaded&&!o.noLocalQuery){const h=u+f,y=p=>({data:Q(o,p),offset:u,queryGen:o._windowIndex.queryGen,provisional:!0});return ln(n)?cn(o,n,h).then(p=>y(p.slice(u,h))):q(o._name).then(p=>y($e(o,p,n).records))}return un(o,u,f)}return q(o._name).then(u=>{const f=$e(o,u,n);return{data:Q(o,f.records),total:f.total,filtered:f.filtered}})},N.prototype.getById=function(n){return L(this._name,n).then(o=>o?Q(this,[o])[0]:null)},N.prototype.count=function(n){return n&&Object.keys(n).length>0?q(this._name).then(u=>Me(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):P(this._name)},N.prototype.aggregate=function(n,o){return q(this._name).then(u=>sn(u,n,o))},N.prototype.setPresenters=function(n){this.presenters=n},N.prototype.applySync=function(n,o,u,f){f=f||{};const h=this;if(h._windowIndex&&f.queryGen!=null&&f.queryGen!==h._windowIndex.queryGen)return Promise.resolve({ok:!0,stale:!0});let y=g().then(p=>{if(!p)throw new Error("IndexedDB unavailable")});return n.length>0&&(y=y.then(()=>je(h._name,n))),o.length>0&&(y=y.then(()=>ne(h._name,o))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,m=n.map(E=>E.id),C=h._windowIndex.ingest(p,m,f.total,f.filtered,f.queryGen);if(C&&C.length)return ne(h._name,C)}}).then(()=>P(h._name)).then(p=>(h.totalCount=f.total!==void 0?f.total:p,h.hasCache=!0,Y(h._name,{schema_version:d,last_synced_at:u,has_cache:!0,record_count:h.totalCount}))).then(()=>{const p=!h.isLoaded;return h.isLoaded=!0,h.canServe=!0,h.isSyncing=!1,h.lastSyncedAt=u,p?(A(h.dom,"ln-data-store:loaded",{store:h._name,count:h.totalCount,meta:f}),A(h.dom,"ln-data-store:ready",{store:h._name,count:h.totalCount,source:"server",meta:f})):A(h.dom,"ln-data-store:synced",{store:h._name,added:n.length,deleted:o.length,changed:!0,meta:f}),{ok:!0}}).catch(p=>{h.isSyncing=!1;const m=p&&p.message?p.message:String(p);return console.error("[ln-data-store] applySync failed:",p),A(h.dom,"ln-data-store:sync-error",{store:h._name,error:m}),Vt(p)})},N.prototype.applyQuery=function(n,o){o=o||{};const u=this;let f=Promise.resolve();return n.length>0&&(f=f.then(()=>je(u._name,n))),f.then(()=>P(u._name)).then(h=>(u.totalCount=o.total!==void 0?o.total:h,n.length>0&&(u.canServe=!0),Q(u,n))).catch(h=>(console.error("[ln-data-store] applyQuery failed:",h),[]))},N.prototype.forceSync=function(){this.isSyncing||Pe(this)},N.prototype.fullReload=function(){const n=this;return U(n._name).then(()=>Y(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isLoaded=!1,n.hasCache=!1,n.lastSyncedAt=null,n.totalCount=0,Pe(n)})},N.prototype.destroy=function(){if(this._windowIndex&&(this._windowIndex.clear(),this._windowIndex=null,this.windowed=!1),this._handlers){for(const[n,o]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-data-store:request-${n}`,o);this._handlers=null}if(this._queryHandlers){for(const[n,o]of Object.entries(this._queryHandlers))this.dom.removeEventListener(n,o);this._queryHandlers=null}delete b[this._name],delete this.dom[t]};function dn(){return g().then(n=>{if(!n)return;const o=Array.from(n.objectStoreNames);return new Promise((u,f)=>{const h=n.transaction(o,"readwrite");o.forEach(y=>h.objectStore(y).clear()),h.oncomplete=()=>u(),h.onerror=()=>f(h.error)})}).then(()=>{Object.values(b).forEach(n=>{n.isLoaded=!1,n.canServe=!1,n.isInitialized=!1,n.initializationError=null,n.hasCache=!1,n.isSyncing=!1,n.lastSyncedAt=null,n.totalCount=0})})}function ye(n){n._windowIndex&&n._windowIndex.reset(),A(n.dom,"ln-data-store:query-changed",{store:n._name,query:{filters:Object.assign({},n.query.filters),search:n.query.search,sort:n.query.sort?Object.assign({},n.query.sort):null}})}const fn="data-ln-data-store-frozen";function Ke(n,o){n.setAttribute(fn,o)}function hn(n){const o=n[t];if(!o._windowIndex)return;const u=o._windowIndex.configure({windowSize:o._windowSize});u.length&&ne(o._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function wn(n){const o=n[t];o._windowIndex&&o._windowIndex.configure({pageSize:o._windowPageSize})}Ne(e,t,N,"ln-data-store",{attributes:i}),window[t].clearAll=dn,window[t].init=window[t],window[t].setStorageKey=Be,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=Be)})()})();
1
+ (function(){"use strict";function ge(){if(typeof window>"u")return!1;if(window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink)return!0;if(typeof document<"u"){if(document.documentElement&&document.documentElement.hasAttribute("data-ln-debug"))return!0;if(document.body)return document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null}return!1}function oe(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let i=null;for(let a=1;a<t.length;a++)if(t[a]&&t[a].nodeType===1){i=t[a];break}if(!oe(i))return}e.apply(console,t)}}function C(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function Z(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){Z(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function Ue(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Ge(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,a={},l=e.elements,c={};if(r)for(let d=0;d<l.length;d++){const s=l[d];s.name&&s.type==="checkbox"&&!s.disabled&&(c[s.name]=(c[s.name]||0)+1)}for(let d=0;d<l.length;d++){const s=l[d];if(!(!s.name||s.disabled||s.type==="file"||s.type==="submit"||s.type==="button")&&!(i&&s.matches&&s.matches(i)))if(s.type==="checkbox")r&&c[s.name]===1?a[s.name]=s.checked:(a[s.name]||(a[s.name]=[]),s.checked&&a[s.name].push(s.value));else if(s.type==="radio")s.checked&&(a[s.name]=s.value);else if(s.type==="select-multiple"){a[s.name]=[];for(let w=0;w<s.options.length;w++)s.options[w].selected&&a[s.name].push(s.options[w].value)}else if(r&&s.type==="hidden")a[s.name]=s.value;else if(r&&(s.type==="number"||s.type==="range")){const w=Number(s.value);a[s.name]=s.value===""||isNaN(w)?null:w}else a[s.name]=s.value}return a}function Ve(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function We(e,t){const r=e.elements,i=[],a={};for(let l=0;l<r.length;l++){const c=r[l];c.name&&c.type==="checkbox"&&(a[c.name]=(a[c.name]||0)+1)}for(let l=0;l<r.length;l++){const c=r[l];if(c.type==="file"||c.type==="submit"||c.type==="button")continue;const d=c.getAttribute("data-ln-fill-as")||c.name;if(!d||!(d in t))continue;const s=t[d];if(c.type==="checkbox"){if(Array.isArray(s))c.checked=s.indexOf(c.value)!==-1;else if(a[c.name]>1){const w=String(s).split(",").map(function(_){return _.trim()});c.checked=w.indexOf(c.value)!==-1}else c.checked=Ve(s);i.push(c)}else if(c.type==="radio")c.checked=c.value===String(s),i.push(c);else if(c.type==="select-multiple"){if(Array.isArray(s))for(let w=0;w<c.options.length;w++)c.options[w].selected=s.indexOf(c.options[w].value)!==-1;i.push(c)}else c.value=s,c.tagName==="SELECT"&&s!=null&&c.setAttribute("data-ln-value",s),i.push(c)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=We,window.lnCore.serializeForm=Ge,window.lnCore.resolveFormMethod=Ue);const be={};function He(e,t){be[e]=t}function Qe(e){return be[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=He,window.lnCore.getDataMapper=Qe);function Je(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,Z(function(){new MutationObserver(function(){C(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const _e={};function Ze(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];_e[r]=t}function Xe(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return _e[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ze,window.lnCore.getLocaleFallback=Xe,window.lnCore.ensureLocaleObserver=Je);const ie={};function Ye(e,t){ie[e]||(ie[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=ie[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function Ce(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let c=0;c<r.length;c++){const d=r[c],s=d.getAttribute("data-ln-field");t[s]!=null&&(d.textContent=t[s])}const i=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<i.length;c++){const d=i[c],s=d.getAttribute("data-ln-attr").split(",");for(let w=0;w<s.length;w++){const _=s[w].trim().split(":");if(_.length!==2)continue;const b=_[0].trim(),x=_[1].trim();t[x]!=null&&d.setAttribute(b,t[x])}}const a=e.querySelectorAll("[data-ln-show]");for(let c=0;c<a.length;c++){const d=a[c],s=d.getAttribute("data-ln-show");s in t&&d.classList.toggle("hidden",!t[s])}const l=e.querySelectorAll("[data-ln-class]");for(let c=0;c<l.length;c++){const d=l[c],s=d.getAttribute("data-ln-class").split(",");for(let w=0;w<s.length;w++){const _=s[w].trim().split(":");if(_.length!==2)continue;const b=_[0].trim(),x=_[1].trim();x in t&&d.classList.toggle(b,!!t[x])}}return e}function et(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)Ce(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<t.length;r++)t[r].textContent=""}})));function Se(e,t){if(!e||!t)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const l=r.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,d){return t[d]!==void 0?t[d]:""}))}const i=function(l,c){return t[c]!==void 0?t[c]:""},a=Array.from(e.querySelectorAll("*"));e.nodeType===1&&a.push(e);for(let l=0;l<a.length;l++){const c=a[l],d=c.attributes;for(let s=0;s<d.length;s++){const w=d[s];w.value.indexOf("{{")!==-1&&c.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function tt(e,t,r,i,a,l){const c={};for(let s=0;s<e.children.length;s++){const w=e.children[s],_=w.getAttribute("data-ln-render-key");_&&(c[_]=w)}const d=document.createDocumentFragment();for(let s=0;s<t.length;s++){const w=t[s],_=String(i(w));let b=c[_];if(b)a(b,w,s);else{const x=Ye(r,l);if(!x||(Se(x,w),b=x.firstElementChild,!b))continue;b.setAttribute("data-ln-render-key",_),a(b,w,s)}d.appendChild(b)}e.textContent="",e.appendChild(d)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=Se,window.lnCore.fill=Ce,window.lnCore.lnFill=et,window.lnCore.renderList=tt);function ae(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function X(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function se(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const a=i.trim().toLowerCase();return!(a==="false"||a==="0")}function le(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const ce=new Map;function Ae(e,t){const r=(e?e.join("|"):"")+"::"+t;if(ce.has(r))return ce.get(r);const i=new Set(e||[]),a=function(l,c){const d=l.getAttribute(c);return d!==null&&i.has(d)?d:t};return ce.set(r,a),a}function ve(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function xe(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function ke(e,t,r,i,a){if(!e||t===null)return!0;const l=i||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const d=s=>{a?console.warn(s,a):console.warn(s)};if(c==="boolean"){const s=t.trim().toLowerCase();return s!==""&&s!=="true"&&s!=="false"&&s!=="1"&&s!=="0"?(d(`[${l}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const s=e.values||[];return s.includes(t)?!0:(d(`[${l}] Invalid value "${t}" for attribute "${r}". Allowed: ${s.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return d(`[${l}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const s=parseInt(t,10);return e.min!==void 0&&s<e.min?(d(`[${l}] Value ${s} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&s>e.max?(d(`[${l}] Value ${s} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(d(`[${l}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(s){return d(`[${l}] Invalid JSON for attribute "${r}": ${s.message}. Fallback: ${e.fallback}.`),!1}return!0}function Ee(e,t,r){for(const i in r){const[a,l,c]=r[i];Object.defineProperty(e,i,{get:function(){return a(t,l,c)},enumerable:!0,configurable:!0})}return e}function qe(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let a=i.read;if(!a&&i.type)switch(i.type){case"enum":a=Ae(i.values,i.fallback);break;case"integer":a=X;break;case"float":a=ve;break;case"boolean":a=se;break;case"list":a=le;break;case"json":a=xe;break;case"string":default:a=ae;break}a||(a=ae),t[i.prop]=[a,r,i.fallback]}return t}function nt(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function rt(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const r in e.effects)t.add(r);if(e.onAttrChange&&e.declared)for(const r of e.declared)t.add(r);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=Ee,window.lnCore.attrSpec=qe,window.lnCore.attrStr=ae,window.lnCore.attrInt=X,window.lnCore.attrBool=se,window.lnCore.attrList=le,window.lnCore.attrEnum=Ae,window.lnCore.attrFloat=ve,window.lnCore.attrJson=xe);function Y(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(r){console.error("["+t.attribute+"] init failed",e,r)}}}function Ie(e,t,r,i){if(e.nodeType!==1)return;const l=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:r,ComponentFn:i};if(e.matches&&e.matches(l)&&Y(e,c),e.querySelectorAll){const d=e.querySelectorAll(l);for(let s=0;s<d.length;s++)Y(d[s],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function ot(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function it(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function Le(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function at(e){const t=Le(),r=e.observed||[];for(let i=0;i<r.length;i++){const a=r[i];t.byAttr.has(a)||t.byAttr.set(a,[]),t.byAttr.get(a).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const a=t.byDeclaredAttr.get(i);a.some(l=>l.componentTag===e.componentTag)||a.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=rt(e);if(i===null)t.reactiveWildcard.push(e);else for(const a of i)t.byReactive.has(a)||t.byReactive.set(a,[]),t.byReactive.get(a).push(e)}e.persist&&t.persist.push(e)}function De(e,t,r,i){for(let a=0;a<e.length;a++){const l=e[a];if(!t[l.attribute])continue;const c=l.effects&&l.effects[r];c?c(t,r,i):l.onAttrChange&&(!l.declared||l.declared.has(r))&&l.onAttrChange(t,r,i)}}function st(e){const t=e.attributeName,r=t.indexOf("data-ln-")===0,i=Le(),a=i.byAttr.get(t),l=ge()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(t);if(!r&&!a&&!l)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(l&&oe(c)){const d=i.byDeclaredAttr.get(t),s=c.getAttribute(t);for(let w=0;w<d.length;w++)ke(d[w].spec,s,t,d[w].componentTag,c)}if(window.lnCore._debugSink&&(r||a)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),r){const d=i.byReactive.get(t);d&&De(d,c,t,e.oldValue),i.reactiveWildcard.length&&De(i.reactiveWildcard,c,t,e.oldValue)}if(a)for(let d=0;d<a.length;d++){const s=a[d];if(s.handler){s.handler(c,t,e.oldValue);continue}s.onAttributeChange&&c[s.attribute]?s.onAttributeChange(c,t):(Ie(c,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(c))}}}function lt(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,Z(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{st(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function ue(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function de(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function Re(e,t){if(!document.contains(e))if(t.attribute){const r=e[t.attribute];if(r&&typeof r.destroy=="function")try{r.destroy()}catch(i){console.error("["+t.attribute+"] destroy failed",e,i)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function Ne(e){const t=ue();if(!t.length)return;const r=e.target;if(r){const a=r.nodeType===1?r:r.parentElement;if(a&&(a.isContentEditable||a.closest&&a.closest('[contenteditable]:not([contenteditable="false"])')))return}const i=de();if(e.target&&i.length)for(let a=0;a<i.length;a++){const l=i[a],c=l.query,d=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;d&&l.onSubtreeChange(d,e)}for(let a=0;a<e.addedNodes.length;a++){const l=e.addedNodes[a];if(l.nodeType!==1)continue;const c=!!(l.firstElementChild||l.children&&l.children.length);for(let d=0;d<t.length;d++){const s=t[d],w=s.query;if(w&&(l.matches&&l.matches(w)&&(s.ComponentFn&&Y(l,s),s.onInit&&s.onInit(l)),c&&l.querySelectorAll)){const _=l.querySelectorAll(w);for(let b=0;b<_.length;b++)s.ComponentFn&&Y(_[b],s),s.onInit&&s.onInit(_[b])}}}for(let a=0;a<e.removedNodes.length;a++){const l=e.removedNodes[a];if(l.nodeType!==1||document.contains(l))continue;const c=!!(l.firstElementChild||l.children&&l.children.length);for(let d=0;d<t.length;d++){const s=t[d],w=s.query;if(w&&(l.matches&&l.matches(w)&&Re(l,s),c&&l.querySelectorAll)){const _=l.querySelectorAll(w);for(let b=0;b<_.length;b++)Re(_[b],s)}}}}function Te(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,Z(function(){const e=new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{Ne(i)}catch(a){console.error("[ln-core] lifecycle handler failed",i.target,a)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ct(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const r=t.takeRecords();for(let i=0;i<r.length;i++){const a=r[i];if(a.type==="childList")try{Ne(a)}catch(l){console.error("[ln-core] lifecycle handler failed",a.target,l)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function ut(e){ue().push(e),e.onSubtreeChange&&e.query&&de().push(e),Te()}function ze(e,t,r,i,a={}){const l=a.extraAttributes||[],c=a.onAttributeChange||null,d=a.onSubtreeChange||null,s=a.onInit||null,w=a.onAttrChange||null,_=a.effects||null,b=a.attributes||null,x=b?nt(b):_,M=b?new Set(Object.keys(b)):null,$=a.persist||null;function m(L){const D=L||document.body;if(Ie(D,e,t,r),b&&ge())for(const B in b){const we=b[B],K=Array.from(D.querySelectorAll("["+B+"]"));D.matches&&D.matches("["+B+"]")&&K.push(D);for(let j=0;j<K.length;j++){const H=K[j];oe(H)&&ke(we,H.getAttribute(B),B,i,H)}}s&&s(D)}const A=[];if(e.indexOf("[")!==-1){const L=/\[([\w-]+)/g;let D;for(;(D=L.exec(e))!==null;)A.push(D[1])}else A.push(e);at({selector:e,attribute:t,componentTag:i,attributes:b,ComponentFn:r,onInit:s,observed:A.concat(l),onAttributeChange:c,onAttrChange:w,effects:x,declared:M,persist:$}),lt();const I=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,k=a.subtreeQuery||(I?e:"["+e+"]"),v={selector:e,attribute:t,ComponentFn:r,onInit:s,onSubtreeChange:d,query:k};ue().push(v),d&&k&&de().push(v),Te(),window[t]=m,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ze,window.lnCore.observeLifecycle=ut,window.lnCore.withoutLifecycle=ct);function E(){ot()>0?it(function(){m(document.body)}):m(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E):E(),m}function dt(e){let t=!1;for(let r=0;r<e.length;r++){const i=e[r];if(!(i===""||i==null)&&(t=!0,!Number.isFinite(Number(i))))return"string"}return t?"number":"string"}function ft(e,t,r,i){if(r==="number"){const c=parseFloat(e),d=parseFloat(t);return(isNaN(c)?0:c)-(isNaN(d)?0:d)}const a=e!=null?String(e):"",l=t!=null?String(t):"";return i?i.compare(a,l):a<l?-1:a>l?1:0}function Oe(e){return(e||"").replace(/^#/,"")}function fe(e){const t=e===void 0?location.hash:e,r={},i=Oe(t);if(!i)return r;const a=i.split("&");for(let l=0;l<a.length;l++){const c=a[l];if(!c)continue;const d=c.indexOf(":"),s=d>-1?c.slice(0,d):c,w=d>-1?c.slice(d+1):"";if(s)try{r[s]=decodeURIComponent(w)}catch{r[s]=w}}return r}function ht(e){if(!e)return null;const t=fe();return e in t?t[e]:null}function wt(e,t){if(!e)return;const r=fe();t==null?delete r[e]:r[e]=String(t);const a=Object.keys(r).map(function(l){const c=r[l];return c===""?l:l+":"+encodeURIComponent(c)}).join("&");Oe(location.hash)!==a&&(location.hash=a)}function yt(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function pt(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function mt(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function gt(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function bt(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function _t(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),a=i?i.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:r,values:a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=fe,window.lnCore.hashGet=ht,window.lnCore.hashSet=wt,window.lnCore.hashLinkClick=yt,window.lnCore.resolveHashNamespace=pt,window.lnCore.hashSortEncode=mt,window.lnCore.hashSortDecode=gt,window.lnCore.hashFilterEncode=bt,window.lnCore.hashFilterDecode=_t);function Ct(e){return(e||"").replace(/^\?/,"")}function St(e){const t=e===void 0?typeof window<"u"?window.location.search:"":e,r={},i=Ct(t);if(!i)return r;const a=new URLSearchParams(i);for(const[l,c]of a.entries())r[l]=c;return r}function At(e){if(!e||typeof window>"u")return null;const t=new URLSearchParams(window.location.search);return t.has(e)?t.get(e):null}function vt(e,t){if(!e||typeof window>"u")return;const r=new URL(window.location.href);if(t==null||t===""?r.searchParams.delete(e):r.searchParams.set(e,String(t)),r.search===window.location.search)return;const i=r.pathname+r.search+r.hash;window.history.replaceState(window.history.state,"",i)}function xt(e,t){if(!e||!e.hasAttribute("data-ln-query"))return null;const r=e.getAttribute("data-ln-query");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"_"+t:i:t||null}function kt(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Et(e,t){if(e&&typeof e=="string"){if(e.endsWith(".asc"))return{fieldOrColumn:e.slice(0,-4),direction:"asc"};if(e.endsWith(".desc"))return{fieldOrColumn:e.slice(0,-5),direction:"desc"}}if(t&&typeof t=="object"){const r=t.sort_field||t.sort_by;if(r){const i=t.sort_dir&&String(t.sort_dir).toLowerCase()==="desc"?"desc":"asc";return{fieldOrColumn:r,direction:i}}}return null}function qt(e){return!Array.isArray(e)||e.length===0?null:e.map(encodeURIComponent).join(",")}function It(e){return!e||typeof e!="string"?[]:e.split(",").map(function(t){try{return decodeURIComponent(t.trim())}catch{return t.trim()}}).filter(Boolean)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.queryParse=St,window.lnCore.queryGet=At,window.lnCore.querySet=vt,window.lnCore.resolveQueryParam=xt,window.lnCore.querySortEncode=kt,window.lnCore.querySortDecode=Et,window.lnCore.queryFilterEncode=qt,window.lnCore.queryFilterDecode=It);let W=null;const Lt="ln-ashlar:storage-salt:v1",Fe=32768;function Pe(e){let t="";const r=e.byteLength;for(let i=0;i<r;i+=Fe)t+=String.fromCharCode.apply(null,e.subarray(i,Math.min(i+Fe,r)));return btoa(t)}function Me(e){const t=atob(e),r=t.length,i=new Uint8Array(r);for(let a=0;a<r;a++)i[a]=t.charCodeAt(a);return i}function Be(e,t){let r=W,i={};return typeof CryptoKey<"u"&&e instanceof CryptoKey?r=e:e&&typeof e=="object"&&(i=e,typeof CryptoKey<"u"&&i.key instanceof CryptoKey&&(r=i.key)),{key:r,options:i}}async function Dt(e,t={}){if(!e)throw new Error("[ln-crypto] Key derivation failed: Secret string is required");const r=t.method||"pbkdf2",i=new TextEncoder;if(r==="sha256"){const s=await crypto.subtle.digest("SHA-256",i.encode(e));return crypto.subtle.importKey("raw",s,{name:"AES-GCM"},!1,["encrypt","decrypt"])}const a=t.salt||Lt,l=typeof a=="string"?i.encode(a):a,c=t.iterations||1e5,d=await crypto.subtle.importKey("raw",i.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:l,iterations:c,hash:"SHA-256"},d,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function je(e,t={}){if(!e){W=null;return}try{const r=t.method||"sha256";W=await Dt(e,{...t,method:r})}catch(r){throw console.error("[ln-core/crypto] Key derivation failed:",r),W=null,r}}function P(){return W}async function Rt(e,t,r){const{key:i}=Be(t);if(e==null)return e;if(!i)throw new Error("[ln-crypto] Encryption failed: No active cryptographic key provided");try{const a=new TextEncoder,l=crypto.getRandomValues(new Uint8Array(12)),c=typeof e=="string"?e:JSON.stringify(e),d=await crypto.subtle.encrypt({name:"AES-GCM",iv:l},i,a.encode(c));return{v:1,alg:"AES-GCM",encrypted:!0,iv:Pe(l),data:Pe(new Uint8Array(d))}}catch(a){throw console.error("[ln-core/crypto] Encryption failed:",a),new Error("[ln-crypto] Encryption failed: "+(a&&a.message?a.message:String(a)))}}async function Nt(e,t,r){const{key:i,options:a}=Be(t),l=a.silent===!0;if(!e||!e.encrypted)return e;if(!i){if(l)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: No active cryptographic key provided")}if(!e.iv||!e.data){if(l)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: Malformed envelope (missing iv or data)")}try{const c=new TextDecoder,d=Me(e.iv),s=Me(e.data),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:d},i,s),_=c.decode(w);try{return JSON.parse(_)}catch{return _}}catch(c){if(l)return{...e,decryptionError:!0};throw console.error("[ln-core/crypto] Decryption failed. Key may be incorrect or payload tampered:",c),new Error("[ln-crypto] Decryption failed. Key may be incorrect or payload tampered: "+(c&&c.message?c.message:String(c)))}}function Tt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=Tt);function zt(e){return String(e||"").trim().toLowerCase()}function Ot(e){const t=zt(e);return t?t.split(/\s+/).filter(Boolean):[]}function Ft(e,t){if(!t||t.length===0)return!0;if(!e)return!1;const r=String(e).toLowerCase();for(let i=0;i<t.length;i++)if(r.indexOf(t[i])===-1)return!1;return!0}function Pt(e,t){if(!t||t.length===0)return!0;if(e==null)return!1;const r=String(e).trim().toLowerCase();for(let i=0;i<t.length;i++)if(String(t[i]).trim().toLowerCase()===r)return!0;return!1}function Mt(e={}){let t=e.windowSize>0?e.windowSize:1e3,r=e.pageSize>0?e.pageSize:200,i=e.fetchDebounce!=null?e.fetchDebounce:120;const a=typeof e.requestPage=="function"?e.requestPage:()=>{},l=new Map,c=new Set;let d=0,s=0,w=0,_=!1,b=null;function x(m,A){l.delete(m),l.set(m,A)}function M(){if(l.size<=t)return[];const m=[];for(;l.size>t;){const I=l.keys().next().value;m.push(l.get(I)),l.delete(I)}const A=new Set(l.values());return m.filter(I=>!A.has(I))}function $(m,A){c.add(m),clearTimeout(b),b=setTimeout(()=>a(m,r,A),i)}return{get logicalTotal(){return d},set logicalTotal(m){d=m},get grandTotal(){return s},set grandTotal(m){s=m},get queryGen(){return w},set queryGen(m){w=m},get size(){return l.size},get hasLoaded(){return _},getId:m=>{if(!l.has(m))return;const A=l.get(m);return x(m,A),A},ensure:(m,A,I)=>{if(!_&&!c.has(0))return $(0,I);if(d<=0)return;const k=Math.max(0,m),v=Math.min(d,A);for(let E=k;E<v;E++)if(!l.has(E)){const L=Math.floor(E/r)*r;if(!c.has(L))return $(L,I)}},ingest:(m,A,I,k,v)=>{if(v!=null&&v!==w)return[];_=!0,I!=null&&(s=I),k!=null&&(d=k);for(let E=0;E<A.length;E++)x(m+E,A[E]);return c.delete(m),M()},reset:function(){w++,this.clear()},clear:()=>{_=!1,l.clear(),c.clear(),clearTimeout(b)},configure:(m={})=>{let A=[];return m.windowSize>0&&m.windowSize!==t&&(t=m.windowSize,A=M()),m.pageSize>0&&(r=m.pageSize),m.fetchDebounce>=0&&(i=m.fetchDebounce),A}}}function Bt(e,t,r){if(!Array.isArray(e)||!t||!t.field)return e;const{field:i,direction:a}=t,l=a==="desc",c=e.map(s=>s?s[i]:void 0),d=dt(c);return[...e].sort((s,w)=>{const _=s?s[i]:void 0,b=w?w[i]:void 0,x=ft(_,b,d,r);return l?-x:x})}function he(e,t){if(!Array.isArray(e)||!t||typeof t!="object")return e;const r=Object.keys(t).filter(i=>Array.isArray(t[i])&&t[i].length>0);return r.length?e.filter(i=>i?r.every(a=>Pt(i[a],t[a])):!1):e}function jt(e,t,r){if(!Array.isArray(e)||!t||!r||!r.length)return e;const i=Ot(t);return i.length?e.filter(a=>a?i.every(l=>r.some(c=>{const d=a[c];return d!=null&&Ft(String(d),[l])})):!1):e}function $t(e,t,r){if(!Array.isArray(e)||!e.length)return 0;if(r==="count")return e.length;const i=e.map(l=>l&&l[t]!=null?parseFloat(l[t]):NaN).filter(l=>Number.isFinite(l)),a=i.reduce((l,c)=>l+c,0);return r==="sum"?a:r==="avg"&&i.length?a/i.length:0}function Kt(e,t={},r=[],i){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const a=e.length;let l=e;t.filters&&(l=he(l,t.filters)),t.search&&(l=jt(l,t.search,r));const c=l.length;if(t.sort&&(l=Bt(l,t.sort,i)),t.offset||t.limit){const d=t.offset||0,s=t.limit||l.length;l=l.slice(d,d+s)}return{records:l,total:a,filtered:c}}function Ut(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(r=>{if(!r)return null;const i={...r};for(const[a,l]of Object.entries(t))if(typeof l=="function")try{i[a]=l(r)}catch{i[a]=void 0}return i})}function Gt(e,t,r,i="_meta"){if(!Array.isArray(e)||!e.includes(i))return!0;for(const a of Object.keys(t||{})){if(!e.includes(a))return!0;const l=t[a]&&t[a].indexes||[],c=r&&r[a]||[];if(l.some(d=>!c.includes(d)))return!0}return!1}function Vt(e){return{ok:!1,error:e&&e.message?e.message:String(e)}}function Wt(e){if(!e||typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const r=JSON.parse(t);return Array.isArray(r)?r:null}catch{return null}}(function(){const e="data-ln-data-store",t="lnDataStore";if(window[t]!==void 0)return;function r(n,o,u){const f=n.getAttribute(o);if(f==="never"||f==="-1")return-1;const h=parseInt(f,10);return isNaN(h)?u:h}const i={"data-ln-data-store":{type:"marker",effect:Ke,description:"Identifies the element as a data-store definition container"},"data-ln-data-store-indexes":{type:"list",effect:Ke,description:"Comma-separated index field names for the IndexedDB store"},"data-ln-data-store-seed":{type:"string",description:"Selector or element ID of an external seed script block"},"data-ln-data-store-stale":{prop:"_staleThreshold",type:"integer",read:r,fallback:300,description:"Cache staleness threshold in seconds, or -1/never"},"data-ln-data-store-search-fields":{prop:"_searchFields",type:"list",read:le,description:"Record fields to index for client-side search"},"data-ln-data-store-no-local-query":{prop:"noLocalQuery",type:"boolean",read:se,description:"Bypasses local IndexedDB query resolution, forcing remote fetching"},"data-ln-data-store-window":{prop:"_windowSize",type:"integer",read:X,fallback:1e3,min:10,effect:yn,description:"Virtual scrolling cache window size in records"},"data-ln-data-store-window-page":{prop:"_windowPageSize",type:"integer",read:X,fallback:200,min:5,effect:pn,description:"Virtual scrolling slice page size"},"data-ln-data-store-frozen":{type:"marker",description:"Applied at runtime to indicate store schema is locked in IndexedDB"}},a=qe(i),l="ln_app_cache",c="_meta",d="1.0";let s=null,w=null;const _={};function b(n){n&&n.name==="QuotaExceededError"&&C(document,"ln-data-store:quota-exceeded",{error:n})}function x(){const n={};for(const o of document.querySelectorAll(`[${e}]`)){const u=o.id;if(u){const f=o.getAttribute("data-ln-data-store-indexes")||"";n[u]={indexes:f.split(",").map(h=>h.trim()).filter(Boolean)}}}return n}function M(){return w||(w=new Promise(n=>{if(typeof indexedDB>"u")return console.warn("[ln-data-store] IndexedDB is not available in this environment"),n(null);const o=x(),u=Object.keys(o),f=indexedDB.open(l);f.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed"),n(null)},f.onsuccess=h=>{const y=h.target.result,p=Array.from(y.objectStoreNames),g=u.filter(N=>p.includes(N));let S={};if(g.length>0){const N=y.transaction(g,"readonly");for(const T of g)S[T]=Array.from(N.objectStore(T).indexNames)}if(!Gt(p,o,S,c))return $(y),s=y,n(y);const U=y.version;y.close();const F=indexedDB.open(l,U+1);let z=!1,O=null;F.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),C(document,"ln-data-store:blocked",{db:l}),O||(O=setTimeout(()=>{z||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),z=!0,w=null,n(null))},5e3))},F.onerror=()=>{z||(O&&clearTimeout(O),z=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},F.onupgradeneeded=N=>{const T=N.target.result,mn=N.target.transaction;T.objectStoreNames.contains(c)||T.createObjectStore(c,{keyPath:"key"});for(const J of u)if(T.objectStoreNames.contains(J)){const re=mn.objectStore(J);for(const V of o[J].indexes)re.indexNames.contains(V)||re.createIndex(V,V,{unique:!1})}else{const re=T.createObjectStore(J,{keyPath:"id"});for(const V of o[J].indexes)re.createIndex(V,V,{unique:!1})}},F.onsuccess=N=>{if(z){N.target.result&&N.target.result.close();return}O&&clearTimeout(O),z=!0;const T=N.target.result;$(T),s=T,n(T)}}}),w)}function $(n){n.onversionchange=()=>{n.close(),s=null,w=null}}function m(){return s?Promise.resolve(s):(w=null,M())}async function A(n){if(!P()||!n)return n;const o={...n},u=o.id,f=await Rt(o);return!f||!f.encrypted?n:{...f,id:u}}async function I(n){return!n||!n.encrypted||!P()?n:Nt(n,{silent:!0})}const k=(n,o)=>m().then(u=>u?u.transaction(n,o).objectStore(n):null);function v(n){return new Promise((o,u)=>{n.onsuccess=()=>o(n.result),n.onerror=()=>{b(n.error),u(n.error)}})}const E=n=>k(n,"readonly").then(o=>o?v(o.getAll()):[]).then(o=>P()?Promise.all(o.map(u=>I(u))):o),L=(n,o)=>k(n,"readonly").then(u=>u?v(u.get(o)).then(f=>f!==void 0?f:typeof o=="string"&&o.trim()!==""&&!isNaN(Number(o))?v(u.get(Number(o))):typeof o=="number"?v(u.get(String(o))):null):null).then(u=>u?I(u):null),D=(n,o)=>m().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=o.map(p=>v(h.get(p)).then(g=>g!==void 0?g:typeof p=="string"&&p.trim()!==""&&!isNaN(Number(p))?v(h.get(Number(p))):typeof p=="number"?v(h.get(String(p))):null));return Promise.all(y).then(p=>P()?Promise.all(p.map(g=>g?I(g):null)):p)}),B=(n,o)=>(P()?A(o):Promise.resolve(o)).then(f=>k(n,"readwrite").then(h=>h?v(h.put(f)):null)),we=(n,o)=>k(n,"readwrite").then(u=>u?v(u.delete(o)).then(()=>{if(typeof o=="string"&&o.trim()!==""&&!isNaN(Number(o)))return v(u.delete(Number(o)));if(typeof o=="number")return v(u.delete(String(o)))}):null),K=n=>k(n,"readwrite").then(o=>o?v(o.clear()):null),j=n=>k(n,"readonly").then(o=>o?v(o.count()):0),H=n=>k(c,"readonly").then(o=>o?v(o.get(n)):null),Q=(n,o)=>k(c,"readwrite").then(u=>{if(u)return o.key=n,v(u.put(o))});function R(n){return this.dom=n,this._name=n.id,this._name||console.warn("[ln-data-store] missing id — the store cannot be addressed",n),Ee(this,n,a),this._handlers=null,this.isLoaded=!1,this.canServe=!1,this.isInitialized=!1,this.initializationError=null,this.hasCache=!1,this.isSyncing=!1,this.lastSyncedAt=null,this.query={filters:{},search:"",sort:null},n.hasAttribute("data-ln-data-store-window")?this._windowIndex=Mt({windowSize:this._windowSize,pageSize:this._windowPageSize,requestPage:(o,u,f)=>{C(this.dom,"ln-data-store:request-page",{store:this._name,offset:o,limit:u,query:f,queryGen:this._windowIndex.queryGen})}}):this._windowIndex=null,this.windowed=this._windowIndex!==null,this.totalCount=0,this.presenters=null,this._mutationChain=Promise.resolve(),_[this._name]=this,Ht(this),this.ready=tn(this),this}function Ht(n){n._handlers={create:o=>ee(n,"create",o.detail,()=>Qt(n,o.detail)),update:o=>ee(n,"update",o.detail,()=>Jt(n,o.detail)),delete:o=>ee(n,"delete",o.detail,()=>Zt(n,o.detail)),"bulk-delete":o=>ee(n,"bulk-delete",o.detail,()=>Xt(n,o.detail)),"sync-failed":o=>{n.isSyncing=!1,C(n.dom,"ln-data-store:sync-error",{store:n._name,error:o.detail&&o.detail.error,status:o.detail&&o.detail.status})}};for(const[o,u]of Object.entries(n._handlers))n.dom.addEventListener(`ln-data-store:request-${o}`,u);n._queryHandlers={"ln-search:change":o=>{o.preventDefault();const u=o.detail&&o.detail.term!=null?o.detail.term:"";u!==n.query.search&&(n.query.search=u,me(n))},"ln-filter:change":o=>{o.preventDefault();const u=o.detail&&o.detail.key;if(!u)return;const f=(o.detail.values||[]).slice(),h=n.query.filters[u];(h?h.length===f.length&&h.every((p,g)=>p===f[g]):!f.length)||(f.length?n.query.filters[u]=f:delete n.query.filters[u],me(n))},"ln-sort:change":o=>{o.preventDefault();const u=o.detail&&o.detail.field,f=o.detail&&o.detail.direction,h=f&&f!=="none"?{field:u,direction:f}:null,y=n.query.sort;!y&&!h||y&&h&&y.field===h.field&&y.direction===h.direction||(n.query.sort=h,me(n))}};for(const[o,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(o,u)}function ee(n,o,u,f){const h=u&&u.requestId;return n._mutationChain=n._mutationChain.then(()=>n.ready).then(()=>{if(n.initializationError)throw n.initializationError;return f()}).catch(y=>Yt(n,o,h,y)),n._mutationChain}function te(n,o=0){return j(n._name).then(u=>{if(n._windowIndex||n.windowed){const f=n.totalCount!=null?n.totalCount:u;n.totalCount=Math.max(0,f+o)}else n.totalCount=u;return n.hasCache=!0,n.isLoaded=!0,n.canServe=!0,Q(n._name,{schema_version:d,last_synced_at:n.lastSyncedAt,has_cache:!0,record_count:n.totalCount})})}function Qt(n,{tempId:o,data:u={},requestId:f}={}){const h={...u,id:o};return B(n._name,h).then(()=>te(n,1)).then(()=>{C(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:o,requestId:f})})}function Jt(n,{id:o,data:u={},requestId:f}={}){return L(n._name,o).then(h=>{if(!h)throw new Error(`Record not found: ${o}`);const y=h.id,p={...h,...u,id:y},g=u.id,S=g!==void 0&&g!==y;return(S?nn(n._name,y,{...p,id:g}):B(n._name,p)).then(()=>te(n,0)).then(()=>{C(n.dom,"ln-data-store:updated",{store:n._name,record:S?{...p,id:g}:p,previous:h,requestId:f})})})}function Zt(n,{id:o,requestId:u}={}){return L(n._name,o).then(f=>{if(!f){C(n.dom,"ln-data-store:deleted",{store:n._name,id:o,requestId:u,missing:!0});return}const h=f.id;return we(n._name,h).then(()=>te(n,-1)).then(()=>{C(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function Xt(n,{ids:o=[],requestId:u}={}){return o.length?Promise.all(o.map(f=>L(n._name,f))).then(f=>{const h=f.filter(Boolean).map(y=>y.id);return ne(n._name,h).then(()=>te(n,-h.length)).then(()=>{C(n.dom,"ln-data-store:deleted",{store:n._name,ids:h,requestId:u})})}):(C(n.dom,"ln-data-store:deleted",{store:n._name,ids:[],requestId:u}),Promise.resolve())}function Yt(n,o,u,f){console.error("[ln-data-store] "+o+" failed:",f),C(n.dom,"ln-data-store:mutation-error",{store:n._name,action:o,requestId:u,error:f})}function en(n){let o=null;const u=n.dom.getAttribute("data-ln-data-store-seed");if(u&&(o=document.getElementById(u),!o))try{o=document.querySelector(u)}catch{}return o||(o=n.dom.querySelector('script[type="application/json"]')||n.dom.querySelector("script")),o&&o.textContent?Wt(o.textContent):null}function tn(n){const o=en(n);return n._seedRecords=o,o?(n.lastSyncedAt=Math.floor(Date.now()/1e3),n.totalCount=o.length,n.hasCache=!0,n.isLoaded=!0,n.canServe=!0,n.isInitialized=!0,setTimeout(()=>{C(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"seed"}),C(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!0,lastSyncedAt:n.lastSyncedAt,count:n.totalCount,source:"seed"})},0),M().then(u=>{if(u)return K(n._name).then(()=>ye(n._name,o)).then(()=>Q(n._name,{schema_version:d,last_synced_at:n.lastSyncedAt,has_cache:!0,record_count:n.totalCount}))}).catch(()=>{}),Promise.resolve({ok:!0,source:"seed"})):M().then(u=>{if(!u)throw new Error("IndexedDB is unavailable");return H(n._name)}).then(u=>{if(!o)if(n.initializationError=null,u&&u.schema_version===d)n.lastSyncedAt=u.last_synced_at||null,n.totalCount=u.record_count||0,n.hasCache=u.has_cache===!0||n.totalCount>0,n.hasCache&&(n.isLoaded=!0,n.canServe=!0,C(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"cache"})),n.isInitialized=!0,C(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:n.hasCache,lastSyncedAt:n.lastSyncedAt,count:n.totalCount});else{if(u&&u.schema_version!==d)return K(n._name).then(()=>Q(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isInitialized=!0,n.hasCache=!1,C(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})});n.isInitialized=!0,n.hasCache=!1,C(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})}}).catch(u=>o?(n.lastSyncedAt=Math.floor(Date.now()/1e3),n.totalCount=o.length,n.hasCache=!0,n.isLoaded=!0,n.canServe=!0,n.isInitialized=!0,C(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"seed"}),C(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!0,lastSyncedAt:n.lastSyncedAt,count:n.totalCount,source:"seed"}),{ok:!0,source:"seed"}):(n.isInitialized=!0,n.isLoaded=!1,n.canServe=!1,n.hasCache=!1,n.isSyncing=!1,n.initializationError=u,C(n.dom,"ln-data-store:initialization-error",{store:n._name,error:u}),{ok:!1,error:u}))}function $e(n){n.isSyncing=!0,C(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function ye(n,o){return m().then(u=>u?(P()?Promise.all(o.map(h=>A(h))):Promise.resolve(o)).then(h=>new Promise((y,p)=>{const g=u.transaction(n,"readwrite"),S=g.objectStore(n);h.forEach(q=>S.put(q)),g.oncomplete=()=>y(),g.onerror=()=>{b(g.error),p(g.error)}})):void 0)}function ne(n,o){return m().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);o.forEach(g=>{p.delete(g),typeof g=="string"&&g.trim()!==""&&!isNaN(Number(g))?p.delete(Number(g)):typeof g=="number"&&p.delete(String(g))}),y.oncomplete=()=>f(),y.onerror=()=>h(y.error)})})}function nn(n,o,u){return(P()?A(u):Promise.resolve(u)).then(h=>m().then(y=>{if(y)return new Promise((p,g)=>{const S=y.transaction(n,"readwrite"),q=S.objectStore(n);q.put(h),q.delete(o),S.oncomplete=()=>p(),S.onerror=()=>{b(S.error),g(S.error)}})}))}const rn=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function on(n){return n?Object.keys(n).filter(o=>Array.isArray(n[o])&&n[o].length>0):[]}function an(n,o,u){return o.every(f=>u[f].map(String).includes(String(n[f])))}function sn(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function ln(n,o,u){return o.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function cn(n,o,u){return $t(n,o,u)}function G(n,o){return Ut(o,n.presenters&&n.presenters.computed)}function un(n){return!n.sort&&!P()}function dn(n,o,u){const f=on(o.filters),h=o.search?sn(o.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return k(n._name,"readonly").then(g=>g?new Promise((S,q)=>{const U=[],F=g.openCursor();F.onsuccess=()=>{const z=F.result;if(!z||U.length>=u){S(U);return}const O=z.value;(!f.length||an(O,f,o.filters))&&(!p||ln(O,h,y))&&U.push(O),z.continue()},F.onerror=()=>q(F.error)}):[])}function pe(n,o,u){return Kt(o,u,n._searchFields,rn)}function fn(n,o,u){const f=[];for(let y=o;y<o+u;y++){const p=n._windowIndex.getId(y);f.push(p)}const h=Array.from(new Set(f.filter(y=>y!==void 0)));return D(n._name,h).then(y=>{const p=new Map;for(let S=0;S<y.length;S++){const q=y[S];q&&p.set(String(q.id),q)}const g=[];for(let S=0;S<f.length;S++){const q=f[S];if(q===void 0)g.push(null);else{const U=p.get(String(q));g.push(U||null)}}return{data:G(n,g),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:o,queryGen:n._windowIndex.queryGen}})}R.prototype.getAll=function(n={}){const o=this;if(o._seedRecords){const u=pe(o,o._seedRecords,n);return Promise.resolve({data:G(o,u.records),total:u.total,filtered:u.filtered})}if(o._windowIndex){const u=n.offset||0,f=n.limit||200;if(o._windowIndex.ensure(u,u+f,n),!o._windowIndex.hasLoaded&&!o.noLocalQuery){const h=u+f,y=p=>({data:G(o,p),offset:u,queryGen:o._windowIndex.queryGen,provisional:!0});return un(n)?dn(o,n,h).then(p=>y(p.slice(u,h))):E(o._name).then(p=>y(pe(o,p,n).records))}return fn(o,u,f)}return E(o._name).then(u=>{const f=pe(o,u,n);return{data:G(o,f.records),total:f.total,filtered:f.filtered}})},R.prototype.getById=function(n){return L(this._name,n).then(o=>o?G(this,[o])[0]:null)},R.prototype.count=function(n){if(this._seedRecords){const u=n&&Object.keys(n).length>0;return Promise.resolve(u?he(this._seedRecords,n).length:this._seedRecords.length)}return n&&Object.keys(n).length>0?E(this._name).then(u=>he(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):j(this._name)},R.prototype.aggregate=function(n,o){return E(this._name).then(u=>cn(u,n,o))},R.prototype.setPresenters=function(n){this.presenters=n},R.prototype.applySync=function(n,o,u,f){f=f||{};const h=this;if(h._windowIndex&&f.queryGen!=null&&f.queryGen!==h._windowIndex.queryGen)return Promise.resolve({ok:!0,stale:!0});let y=m().then(p=>{if(!p)throw new Error("IndexedDB unavailable")});return n.length>0&&(y=y.then(()=>ye(h._name,n))),o.length>0&&(y=y.then(()=>ne(h._name,o))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,g=n.map(q=>q.id),S=h._windowIndex.ingest(p,g,f.total,f.filtered,f.queryGen);if(S&&S.length)return ne(h._name,S)}}).then(()=>j(h._name)).then(p=>(h.totalCount=f.total!==void 0?f.total:p,h.hasCache=!0,Q(h._name,{schema_version:d,last_synced_at:u,has_cache:!0,record_count:h.totalCount}))).then(()=>{const p=!h.isLoaded;return h.isLoaded=!0,h.canServe=!0,h.isSyncing=!1,h.lastSyncedAt=u,p?(C(h.dom,"ln-data-store:loaded",{store:h._name,count:h.totalCount,meta:f}),C(h.dom,"ln-data-store:ready",{store:h._name,count:h.totalCount,source:"server",meta:f})):C(h.dom,"ln-data-store:synced",{store:h._name,added:n.length,deleted:o.length,changed:!0,meta:f}),{ok:!0}}).catch(p=>{h.isSyncing=!1;const g=p&&p.message?p.message:String(p);return console.error("[ln-data-store] applySync failed:",p),C(h.dom,"ln-data-store:sync-error",{store:h._name,error:g}),Vt(p)})},R.prototype.applyQuery=function(n,o){o=o||{};const u=this;let f=Promise.resolve();return n.length>0&&(f=f.then(()=>ye(u._name,n))),f.then(()=>j(u._name)).then(h=>(u.totalCount=o.total!==void 0?o.total:h,n.length>0&&(u.canServe=!0),G(u,n))).catch(h=>(console.error("[ln-data-store] applyQuery failed:",h),[]))},R.prototype.forceSync=function(){this.isSyncing||$e(this)},R.prototype.fullReload=function(){const n=this;return K(n._name).then(()=>Q(n._name,{schema_version:d,last_synced_at:null,has_cache:!1,record_count:0})).then(()=>{n.isLoaded=!1,n.hasCache=!1,n.lastSyncedAt=null,n.totalCount=0,$e(n)})},R.prototype.destroy=function(){if(this._windowIndex&&(this._windowIndex.clear(),this._windowIndex=null,this.windowed=!1),this._handlers){for(const[n,o]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-data-store:request-${n}`,o);this._handlers=null}if(this._queryHandlers){for(const[n,o]of Object.entries(this._queryHandlers))this.dom.removeEventListener(n,o);this._queryHandlers=null}delete _[this._name],delete this.dom[t]};function hn(){return m().then(n=>{if(!n)return;const o=Array.from(n.objectStoreNames);return new Promise((u,f)=>{const h=n.transaction(o,"readwrite");o.forEach(y=>h.objectStore(y).clear()),h.oncomplete=()=>u(),h.onerror=()=>f(h.error)})}).then(()=>{Object.values(_).forEach(n=>{n.isLoaded=!1,n.canServe=!1,n.isInitialized=!1,n.initializationError=null,n.hasCache=!1,n.isSyncing=!1,n.lastSyncedAt=null,n.totalCount=0})})}function me(n){n._windowIndex&&n._windowIndex.reset(),C(n.dom,"ln-data-store:query-changed",{store:n._name,query:{filters:Object.assign({},n.query.filters),search:n.query.search,sort:n.query.sort?Object.assign({},n.query.sort):null}})}const wn="data-ln-data-store-frozen";function Ke(n,o){n.setAttribute(wn,o)}function yn(n){const o=n[t];if(!o._windowIndex)return;const u=o._windowIndex.configure({windowSize:o._windowSize});u.length&&ne(o._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function pn(n){const o=n[t];o._windowIndex&&o._windowIndex.configure({pageSize:o._windowPageSize})}ze(e,t,R,"ln-data-store",{attributes:i}),window[t].clearAll=hn,window[t].init=window[t],window[t].setStorageKey=je,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=je)})()})();