@livenetworks/ashlar 2.1.4 → 2.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ln-accordion/ln-accordion.js +1 -1
- package/components/ln-ajax/ln-ajax.js +1 -1
- package/components/ln-api-connector/README.md +7 -1
- package/components/ln-api-connector/ln-api-connector.js +1 -1
- package/components/ln-api-connector/src/ln-api-connector.js +6 -2
- package/components/ln-api-queue/ln-api-queue.js +1 -1
- package/components/ln-autosave/ln-autosave.js +1 -1
- package/components/ln-chart/ln-chart.js +1 -1
- package/components/ln-circular-progress/ln-circular-progress.js +1 -1
- package/components/ln-confirm/ln-confirm.js +1 -1
- package/components/ln-core/helpers.js +1 -1
- package/components/ln-core/index.js +1 -1
- package/components/ln-core/lifecycle.js +41 -0
- package/components/ln-couchdb-connector/ln-couchdb-connector.js +1 -1
- package/components/ln-data-coordinator/ln-data-coordinator.js +1 -1
- package/components/ln-data-store/ln-data-store.js +1 -1
- package/components/ln-date/ln-date.js +1 -1
- package/components/ln-debug/ln-debug.js +1 -1
- package/components/ln-dropdown/ln-dropdown.js +1 -1
- package/components/ln-editor/ln-editor.js +1 -1
- package/components/ln-external-links/ln-external-links.js +1 -1
- package/components/ln-filter/ln-filter.js +1 -1
- package/components/ln-form/ln-form.js +1 -1
- package/components/ln-icon/ln-icon.js +1 -1
- package/components/ln-include/ln-include.js +1 -1
- package/components/ln-key/ln-key.js +1 -1
- package/components/ln-link/ln-link.js +1 -1
- package/components/ln-list/ln-list.js +1 -1
- package/components/ln-modal/ln-modal.js +1 -1
- package/components/ln-nav/ln-nav.js +1 -1
- package/components/ln-number/ln-number.js +1 -1
- package/components/ln-obfuscator/ln-obfuscator.js +1 -1
- package/components/ln-options/ln-options.js +1 -1
- package/components/ln-picklist/ln-picklist.js +1 -1
- package/components/ln-popover/ln-popover.js +1 -1
- package/components/ln-progress/ln-progress.js +1 -1
- package/components/ln-router/ln-router.js +1 -1
- package/components/ln-scroll/ln-scroll.js +1 -1
- package/components/ln-search/ln-search.js +1 -1
- package/components/ln-slug/ln-slug.js +1 -1
- package/components/ln-sort/ln-sort.js +1 -1
- package/components/ln-sort/src/ln-sort.js +13 -11
- package/components/ln-sortable/ln-sortable.js +1 -1
- package/components/ln-stat/ln-stat.js +1 -1
- package/components/ln-table/ln-table.js +1 -1
- package/components/ln-table-coordinator/ln-table-coordinator.js +1 -1
- package/components/ln-tabs/ln-tabs.js +1 -1
- package/components/ln-time/ln-time.js +1 -1
- package/components/ln-toast/ln-toast.js +1 -1
- package/components/ln-toggle/ln-toggle.js +1 -1
- package/components/ln-tooltip/ln-tooltip.js +1 -1
- package/components/ln-translations/ln-translations.js +1 -1
- package/components/ln-ui-coordinator/ln-ui-coordinator.js +1 -1
- package/components/ln-upload/ln-upload.js +1 -1
- package/components/ln-validate/ln-validate.js +1 -1
- package/components/ln-websocket-connector/ln-websocket-connector.js +1 -1
- package/package.json +1 -1
- package/web-types.json +2337 -2337
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function K(){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 T(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 a=null;for(let s=1;s<t.length;s++)if(t[s]&&t[s].nodeType===1){a=t[s];break}if(!T(a))return}e.apply(console,t)}}function g(e,t,o){const a=o||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,a),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:a}))}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 Q(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function P(e,t){const o=!!(t&&t.typed),a=t&&t.exclude,s={},u=e.elements,c={};if(o)for(let p=0;p<u.length;p++){const i=u[p];i.name&&i.type==="checkbox"&&!i.disabled&&(c[i.name]=(c[i.name]||0)+1)}for(let p=0;p<u.length;p++){const i=u[p];if(!(!i.name||i.disabled||i.type==="file"||i.type==="submit"||i.type==="button")&&!(a&&i.matches&&i.matches(a)))if(i.type==="checkbox")o&&c[i.name]===1?s[i.name]=i.checked:(s[i.name]||(s[i.name]=[]),i.checked&&s[i.name].push(i.value));else if(i.type==="radio")i.checked&&(s[i.name]=i.value);else if(i.type==="select-multiple"){s[i.name]=[];for(let m=0;m<i.options.length;m++)i.options[m].selected&&s[i.name].push(i.options[m].value)}else if(o&&i.type==="hidden")s[i.name]=i.value;else if(o&&(i.type==="number"||i.type==="range")){const m=Number(i.value);s[i.name]=i.value===""||isNaN(m)?null:m}else s[i.name]=i.value}return s}function he(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 o=e.elements,a=[],s={};for(let u=0;u<o.length;u++){const c=o[u];c.name&&c.type==="checkbox"&&(s[c.name]=(s[c.name]||0)+1)}for(let u=0;u<o.length;u++){const c=o[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 i=t[p];if(c.type==="checkbox"){if(Array.isArray(i))c.checked=i.indexOf(c.value)!==-1;else if(s[c.name]>1){const m=String(i).split(",").map(function(A){return A.trim()});c.checked=m.indexOf(c.value)!==-1}else c.checked=he(i);a.push(c)}else if(c.type==="radio")c.checked=c.value===String(i),a.push(c);else if(c.type==="select-multiple"){if(Array.isArray(i))for(let m=0;m<c.options.length;m++)c.options[m].selected=i.indexOf(c.options[m].value)!==-1;a.push(c)}else c.value=i,c.tagName==="SELECT"&&i!=null&&c.setAttribute("data-ln-value",i),a.push(c)}return a}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=we,window.lnCore.serializeForm=P,window.lnCore.resolveFormMethod=Q);const V={};function me(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=me,window.lnCore.getDataMapper=be);function ye(){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 ge(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];z[o]=t}function Ce(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=ge,window.lnCore.getLocaleFallback=Ce,window.lnCore.ensureLocaleObserver=ye);const L={};function _e(e,t){L[e]||(L[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=L[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function H(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let c=0;c<o.length;c++){const p=o[c],i=p.getAttribute("data-ln-field");t[i]!=null&&(p.textContent=t[i])}const a=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<a.length;c++){const p=a[c],i=p.getAttribute("data-ln-attr").split(",");for(let m=0;m<i.length;m++){const A=i[m].trim().split(":");if(A.length!==2)continue;const _=A[0].trim(),C=A[1].trim();t[C]!=null&&p.setAttribute(_,t[C])}}const s=e.querySelectorAll("[data-ln-show]");for(let c=0;c<s.length;c++){const p=s[c],i=p.getAttribute("data-ln-show");i in t&&p.classList.toggle("hidden",!t[i])}const u=e.querySelectorAll("[data-ln-class]");for(let c=0;c<u.length;c++){const p=u[c],i=p.getAttribute("data-ln-class").split(",");for(let m=0;m<i.length;m++){const A=i[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 Ae(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 o=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let a=0;a<o.length;a++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",o[a],t??null),o[a].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 o=0;o<t.length;o++)t[o].textContent=""}})));function J(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const u=o.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 a=function(u,c){return t[c]!==void 0?t[c]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let u=0;u<s.length;u++){const c=s[u],p=c.attributes;for(let i=0;i<p.length;i++){const m=p[i];m.value.indexOf("{{")!==-1&&c.setAttribute(m.name,m.value.replace(/\{\{\s*(\w+)\s*\}\}/g,a))}}return e}function ve(e,t,o,a,s,u){const c={};for(let i=0;i<e.children.length;i++){const m=e.children[i],A=m.getAttribute("data-ln-render-key");A&&(c[A]=m)}const p=document.createDocumentFragment();for(let i=0;i<t.length;i++){const m=t[i],A=String(a(m));let _=c[A];if(_)s(_,m,i);else{const C=_e(o,u);if(!C||(J(C,m),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",A),s(_,m,i)}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=Ae,window.lnCore.renderList=ve);function F(e,t,o){const a=e.getAttribute(t);return a===null?o:a}function X(e,t,o){const a=parseInt(e.getAttribute(t),10);return isNaN(a)?o:a}function Y(e,t,o=!1){const a=e.getAttribute(t);if(a===null)return!!o;const s=a.trim().toLowerCase();return!(s==="false"||s==="0")}function Z(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const j=new Map;function ee(e,t){const o=(e?e.join("|"):"")+"::"+t;if(j.has(o))return j.get(o);const a=new Set(e||[]),s=function(u,c){const p=u.getAttribute(c);return p!==null&&a.has(p)?p:t};return j.set(o,s),s}function te(e,t,o){const a=parseFloat(e.getAttribute(t));return isNaN(a)?o:a}function ne(e,t,o){const a=e.getAttribute(t);if(!a)return o;try{return JSON.parse(a)}catch{return o}}function re(e,t,o,a,s){if(!e||t===null)return!0;const u=a||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const p=i=>{s?console.warn(i,s):console.warn(i)};if(c==="boolean"){const i=t.trim().toLowerCase();return i!==""&&i!=="true"&&i!=="false"&&i!=="1"&&i!=="0"?(p(`[${u}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const i=e.values||[];return i.includes(t)?!0:(p(`[${u}] Invalid value "${t}" for attribute "${o}". Allowed: ${i.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return p(`[${u}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const i=parseInt(t,10);return e.min!==void 0&&i<e.min?(p(`[${u}] Value ${i} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&i>e.max?(p(`[${u}] Value ${i} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(p(`[${u}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(i){return p(`[${u}] Invalid JSON for attribute "${o}": ${i.message}. Fallback: ${e.fallback}.`),!1}return!0}function oe(e,t,o){for(const a in o){const[s,u,c]=o[a];Object.defineProperty(e,a,{get:function(){return s(t,u,c)},enumerable:!0,configurable:!0})}return e}function ie(e){const t={};for(const o in e){const a=e[o];if(!a||!a.prop)continue;let s=a.read;if(!s&&a.type)switch(a.type){case"enum":s=ee(a.values,a.fallback);break;case"integer":s=X;break;case"float":s=te;break;case"boolean":s=Y;break;case"list":s=Z;break;case"json":s=ne;break;case"string":default:s=F;break}s||(s=F),t[a.prop]=[s,o,a.fallback]}return t}function Ee(e){const t={};for(const o in e){const a=e[o];a&&a.effect&&(t[o]=a.effect)}return Object.keys(t).length?t:null}function qe(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const o in e.effects)t.add(o);if(e.onAttrChange&&e.declared)for(const o of e.declared)t.add(o);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(o){console.error("["+t.attribute+"] init failed",e,o)}}}function ae(e,t,o,a){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:o,ComponentFn:a};if(e.matches&&e.matches(u)&&I(e,c),e.querySelectorAll){const p=e.querySelectorAll(u);for(let i=0;i<p.length;i++)I(p[i],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Se(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function xe(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 ke(e){const t=le(),o=e.observed||[];for(let a=0;a<o.length;a++){const s=o[a];t.byAttr.has(s)||t.byAttr.set(s,[]),t.byAttr.get(s).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const a in e.attributes){t.byDeclaredAttr.has(a)||t.byDeclaredAttr.set(a,[]);const s=t.byDeclaredAttr.get(a);s.some(u=>u.componentTag===e.componentTag)||s.push({spec:e.attributes[a],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const a=qe(e);if(a===null)t.reactiveWildcard.push(e);else for(const s of a)t.byReactive.has(s)||t.byReactive.set(s,[]),t.byReactive.get(s).push(e)}e.persist&&t.persist.push(e)}function se(e,t,o,a){for(let s=0;s<e.length;s++){const u=e[s];if(!t[u.attribute])continue;const c=u.effects&&u.effects[o];c?c(t,o,a):u.onAttrChange&&(!u.declared||u.declared.has(o))&&u.onAttrChange(t,o,a)}}function Ie(e){const t=e.attributeName,o=t.indexOf("data-ln-")===0,a=le(),s=a.byAttr.get(t),u=K()&&a.byDeclaredAttr&&a.byDeclaredAttr.has(t);if(!o&&!s&&!u)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(u&&T(c)){const p=a.byDeclaredAttr.get(t),i=c.getAttribute(t);for(let m=0;m<p.length;m++)re(p[m].spec,i,t,p[m].componentTag,c)}if(window.lnCore._debugSink&&(o||s)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),o){const p=a.byReactive.get(t);p&&se(p,c,t,e.oldValue),a.reactiveWildcard.length&&se(a.reactiveWildcard,c,t,e.oldValue)}if(s)for(let p=0;p<s.length;p++){const i=s[p];if(i.handler){i.handler(c,t,e.oldValue);continue}i.onAttributeChange&&c[i.attribute]?i.onAttributeChange(c,t):(ae(c,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(c))}}}function Oe(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{Ie(t[o])}catch(a){console.error("[ln-core] mutation handler failed",t[o].target,a)}}).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 B(e,t){if(!document.contains(e))if(t.attribute){const o=e[t.attribute];if(o&&typeof o.destroy=="function")try{o.destroy()}catch(a){console.error("["+t.attribute+"] destroy failed",e,a)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function De(e){const t=$();if(!t.length)return;const o=e.target;if(o){const s=o.nodeType===1?o:o.parentElement;if(s&&(s.isContentEditable||s.closest&&s.closest('[contenteditable]:not([contenteditable="false"])')))return}const a=M();if(e.target&&a.length)for(let s=0;s<a.length;s++){const u=a[s],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 s=0;s<e.addedNodes.length;s++){const u=e.addedNodes[s];if(u.nodeType===1){const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const i=t[p];if(i.selector&&i.attribute&&i.ComponentFn){if(!c)u.matches&&u.matches(i.query)&&I(u,i);else if(u.matches&&u.matches(i.query)&&I(u,i),u.querySelectorAll){const m=u.querySelectorAll(i.query);for(let A=0;A<m.length;A++)I(m[A],i)}}i.onInit&&i.onInit(u)}}}for(let s=0;s<e.removedNodes.length;s++){const u=e.removedNodes[s];if(u.nodeType===1){const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const i=t[p],m=i.query;if(m){if(!c)u.matches&&u.matches(m)&&B(u,i);else if(u.matches&&u.matches(m)&&B(u,i),u.querySelectorAll){const A=u.querySelectorAll(m);for(let _=0;_<A.length;_++)B(A[_],i)}}}}}}function ce(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++){const a=t[o];if(a.type==="childList")try{De(a)}catch(s){console.error("[ln-core] lifecycle handler failed",a.target,s)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Re(e){$().push(e),e.onSubtreeChange&&e.query&&M().push(e),ce()}function de(e,t,o,a,s={}){const u=s.extraAttributes||[],c=s.onAttributeChange||null,p=s.onSubtreeChange||null,i=s.onInit||null,m=s.onAttrChange||null,A=s.effects||null,_=s.attributes||null,C=_?Ee(_):A,N=_?new Set(Object.keys(_)):null,U=s.persist||null;function n(q){const E=q||document.body;if(ae(E,e,t,o),_&&K())for(const d in _){const h=_[d],b=Array.from(E.querySelectorAll("["+d+"]"));E.matches&&E.matches("["+d+"]")&&b.push(E);for(let v=0;v<b.length;v++){const S=b[v];T(S)&&re(h,S.getAttribute(d),d,a,S)}}i&&i(E)}const r=[];if(e.indexOf("[")!==-1){const q=/\[([\w-]+)/g;let E;for(;(E=q.exec(e))!==null;)r.push(E[1])}else r.push(e);ke({selector:e,attribute:t,componentTag:a,attributes:_,ComponentFn:o,onInit:i,observed:r.concat(u),onAttributeChange:c,onAttrChange:m,effects:C,declared:N,persist:U}),Oe();const l=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,f=s.subtreeQuery||(l?e:"["+e+"]"),w={selector:e,attribute:t,ComponentFn:o,onInit:i,onSubtreeChange:p,query:f};$().push(w),p&&f&&M().push(w),ce(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=de,window.lnCore.observeLifecycle=Re);function y(){Se()>0?xe(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y):y(),n}function Te(e,t){let o=!1;return function(){o||(o=!0,queueMicrotask(function(){o=!1,e()}))}}function ue(e){return(e||"").replace(/^#/,"")}function W(e){const t=e===void 0?location.hash:e,o={},a=ue(t);if(!a)return o;const s=a.split("&");for(let u=0;u<s.length;u++){const c=s[u];if(!c)continue;const p=c.indexOf(":"),i=p>-1?c.slice(0,p):c,m=p>-1?c.slice(p+1):"";if(i)try{o[i]=decodeURIComponent(m)}catch{o[i]=m}}return o}function Le(e){if(!e)return null;const t=W();return e in t?t[e]:null}function Fe(e,t){if(!e)return;const o=W();t==null?delete o[e]:o[e]=String(t);const s=Object.keys(o).map(function(u){const c=o[u];return c===""?u:u+":"+encodeURIComponent(c)}).join("&");ue(location.hash)!==s&&(location.hash=s)}function je(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function $e(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const o=e.getAttribute("data-ln-hash");if(o&&o.trim()!=="")return o.trim();const a=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return a?t?a+"-"+t:a:t||null}function Me(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 We(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 o=e.slice(0,t),a=e.slice(t+1),s=a?a.split(",").map(function(u){try{return decodeURIComponent(u)}catch{return u}}).filter(Boolean):[];return{key:o,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=W,window.lnCore.hashGet=Le,window.lnCore.hashSet=Fe,window.lnCore.hashLinkClick=je,window.lnCore.resolveHashNamespace=$e,window.lnCore.hashSortEncode=Me,window.lnCore.hashSortDecode=Be,window.lnCore.hashFilterEncode=We,window.lnCore.hashFilterDecode=Ne);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 Ue(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Ge(e,t){const o=!e||!!e.initializationError,a=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(o||!e.canServe||a)?"remote":e&&!e.initializationError?"store":"none"}function fe(e,t){const o=Object.assign({},e);return t&&(o.filters=t.filters,o.search=t.search,o.sort=t.sort),o}class Ke{constructor(){this._pending=new Map}wait(t){return new Promise((o,a)=>{this._pending.set(t,{resolve:o,reject:a})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const o=t||new Error("Mutation receipt registry closed");for(const a of this._pending.values())a.reject(o);this._pending.clear()}_settle(t,o){const a=t&&t.requestId;if(!a)return!1;const s=this._pending.get(a);return s?(this._pending.delete(a),o?s.reject(t.error||new Error("Store mutation failed")):s.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",o="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const a="data-ln-data-coordinator-search",s="data-ln-data-coordinator-filters",u="data-ln-data-coordinator-sort-field",c="data-ln-data-coordinator-sort-direction",i=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 r=n.getAttribute("data-ln-data-coordinator-connector");if(r)return n.querySelector(r)||document.querySelector(r)||document.getElementById(r);const l=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(l)return l;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 l;if(!n)return"ln-connector";if((l=n.lnConnector)!=null&&l.namespace)return n.lnConnector.namespace;const r=n.getAttribute("data-ln-connector");if(r&&r!=="true")return r.startsWith("ln-")?r:"ln-"+r+(r.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 r=this;return this.dom=n,oe(this,n,i),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 Ke,this._queueQueryRefresh=Te(()=>{r._destroyed||r._refreshAll(null,!0)}),this.refreshMapper(),N(this),this._checkInitialSync(),this}C.prototype._noAutosync=function(n){var r;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||!!((r=n.storeEl)!=null&&r.hasAttribute("data-ln-data-store-no-autosync"))},C.prototype._isStale=function(n){var l,f;const r=this.dom.getAttribute("data-ln-data-coordinator-stale")||((l=n.storeEl)==null?void 0:l.getAttribute("data-ln-data-store-stale"));return r==="never"||r==="-1"?!1:!((f=n.store)!=null&&f.lastSyncedAt)||Date.now()/1e3-n.store.lastSyncedAt>(parseInt(r,10)||300)},C.prototype._checkInitialSync=function(){const n=this,r=this.findChildren();r.store&&Promise.resolve(r.store.ready).then(()=>{if(n._destroyed)return;const l=n.findChildren();l.store&&l.connector&&!n._noAutosync(l)&&!l.store.isSyncing&&(!l.store.hasCache||n._isStale(l))&&l.store.forceSync()}).catch(l=>n._reportError("store-initialize",l,null))},C.prototype.refreshMapper=function(){var l,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,r=n&&((f=(l=window.lnCore)==null?void 0:l.getDataMapper)==null?void 0:f.call(l,n))||null;this.mapper={ingress:(r==null?void 0:r.ingress)||(w=>w),egress:(r==null?void 0:r.egress)||(w=>w)}},C.prototype.findChildren=function(){const n=this.dom.querySelector("[data-ln-data-store]"),r=A(this.dom),l=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:r,queueEl:l,store:(n==null?void 0:n.lnDataStore)||null,connector:(r==null?void 0:r.lnConnector)||(r==null?void 0:r.lnApiConnector)||(r==null?void 0:r.lnCouchDbConnector)||(r==null?void 0:r.lnWebsocketConnector)||null,queue:(l==null?void 0:l.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,r,l,f){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",l):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+r,f)},C.prototype._fanOutCreate=function(n,r,l){const f="_temp_"+k(),w=this.mapper.egress(r);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:l}},{data:w,url:l,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},C.prototype._fanOutUpdate=function(n,r,l,f,w){const y=this.mapper.egress(l);n.storeEl&&g(n.storeEl,"ln-data-store:request-update",{id:r,data:y}),this._fanOutRemote(n,"update",{chainKey:r,op:"update",targetId:r,payload:y,expectedVersion:f,meta:{id:r,action:w}},{id:r,data:y,expected_version:f,url:w,meta:{entryId:k(),queued:!1,op:"update",id:r}})},C.prototype._fanOutDelete=function(n,r){n.storeEl&&g(n.storeEl,"ln-data-store:request-delete",{id:r}),this._fanOutRemote(n,"delete",{chainKey:r,op:"delete",targetId:r,payload:null,expectedVersion:null,meta:{id:r}},{id:r,meta:{entryId:k(),queued:!1,op:"delete",id:r}})},C.prototype._fanOutBulkDelete=function(n,r){const l=r.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:r}),this._fanOutRemote(n,"bulk-delete",{chainKey:l,op:"bulk-delete",targetId:null,payload:{ids:r},expectedVersion:null,meta:{bulkKey:l,ids:r}},{ids:r,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:l}})},C.prototype._requestStoreMutation=function(n,r,l){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-"+r,Object.assign({},l,{requestId:f})),w},C.prototype._reportError=function(n,r,l){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:r,meta:l||null})},C.prototype._owns=function(n){var l;const r=this._name||((l=this.findChildren().storeEl)==null?void 0:l.id);return!!n&&n===r},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(u),r=this.dom.getAttribute(c),l=new URLSearchParams(this.dom.getAttribute(s)||""),f={};for(const w of new Set(l.keys()))f[w]=l.getAll(w);return{search:this.dom.getAttribute(a)||"",filters:f,sort:n&&r?{field:n,direction:r}:null}},C.prototype._refreshAll=function(n,r){for(const[l,f,w]of m)for(const y of this.dom.ownerDocument.querySelectorAll(l))if(this._owns(y.getAttribute(f))){if((w==="table"||w==="list")&&y.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){g(y,"ln-"+w+(r?":request-invalidate":":request-revalidate"),{});continue}this._serveElement(y,w,null,n)}},C.prototype._serveElement=function(n,r,l,f){const w=this.findChildren(),y=w.store;if(!y)return;l&&this._boundQueries.set(n,l);const q=this._boundQueries.get(n)||{sort:null,filters:{},search:""},E=fe(q,this._currentQuery()),d=this;return Promise.resolve(y.ready).then(()=>{if(d._destroyed)return;const h=Ge(y,w.connector);if(r==="table"||r==="list"||r==="chart")return h==="remote"?(g(n,"ln-"+r+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:E,meta:{targetEl:n,kind:r,offset:E.offset,limit:E.limit,queryGen:q.queryGen}})):h!=="store"?g(n,"ln-"+r+":set-loading",{loading:!1}):y.getAll(E).then(b=>{d._destroyed||!d._boundDelivered||(g(n,"ln-"+r+":set-loading",{loading:!1}),g(n,"ln-"+r+":set-data",{data:b.data,total:(f==null?void 0:f.total)??b.total,filtered:(f==null?void 0:f.filtered)??b.filtered,offset:b.offset??(f==null?void 0:f.offset)??q.offset,queryGen:q.queryGen!==void 0?q.queryGen:(f==null?void 0:f.queryGen)??b.queryGen,provisional:b.provisional===!0}),d._boundDelivered.set(n,!0))});if(r==="options"){if(h==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:r}});if(h==="store")return y.getAll({}).then(b=>!d._destroyed&&g(n,"ln-options:set-data",{data:b.data}))}if(r==="stat"){let b=l==null?void 0:l.filters;if(!b){const S=n.getAttribute("data-ln-stat-filter");if(S!=null&&S.includes(":")){const x=S.split(":");b={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const v=w.connector&&y&&(y.windowed&&b&&Object.keys(b).length||y.noLocalQuery)?"remote":h;if(v==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:b},meta:{targetEl:n,kind:r}});if(v==="store")return y.count(b).then(S=>!d._destroyed&&g(n,"ln-stat:set-count",{count:S}))}}).catch(h=>{d._destroyed||((r==="table"||r==="list"||r==="chart")&&g(n,"ln-"+r+":set-loading",{loading:!1}),d._reportError(r+"-query",h,{targetEl:n,kind:r}))})};function N(n){const r=n._unsubs=[],l=(d,h,b)=>{d.addEventListener(h,b),r.push(()=>d.removeEventListener(h,b))};l(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const h=n.findChildren();h.store&&h.connector&&g(h.connectorEl,_(h.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),l(n.dom,"ln-data-store:request-page",d=>{const h=n.findChildren(),b=d.detail||{};if(!h.connectorEl)return;const v=fe(b.query||{},n._currentQuery());g(h.connectorEl,_(h.connectorEl)+":request-query",{query:Object.assign({},v,{offset:b.offset,limit:b.limit,queryGen:b.queryGen})})}),l(n.dom,"ln-data-coordinator:request-create",d=>n._fanOutCreate(n.findChildren(),d.detail.data||{},d.detail.action)),l(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)),l(n.dom,"ln-data-coordinator:request-delete",d=>n._fanOutDelete(n.findChildren(),d.detail.id)),l(n.dom,"ln-data-coordinator:request-bulk-delete",d=>n._fanOutBulkDelete(n.findChildren(),d.detail.ids||[])),l(n.dom,"ln-api-queue:send",d=>n._onQueueSend(d.detail||{})),l(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)}),l(n.dom,"ln-data-store:initialized",d=>{var b;const h=n.findChildren();h.store&&!h.store.initializationError&&h.connector&&!n._noAutosync(h)&&!h.store.isSyncing&&(!((b=d.detail)!=null&&b.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()};l(n.dom,"ln-websocket-connector:connected",f),l(document,"submit",d=>n._onFormSubmit(d));const w=(d,h,b)=>{var v;n._owns(d.target.getAttribute(b))&&n._serveElement(d.target,h,h==="stat"?{filters:((v=d.detail)==null?void 0:v.filters)||null}:h==="options"?null:Ue(d.detail||{}),null)};l(document,"ln-table:request-data",d=>w(d,"table","data-ln-table-source")),l(document,"ln-list:request-data",d=>w(d,"list","data-ln-list-source")),l(document,"ln-chart:request-data",d=>w(d,"chart","data-ln-chart-source")),l(document,"ln-options:request-data",d=>w(d,"options","data-ln-options")),l(document,"ln-stat:request-count",d=>w(d,"stat","data-ln-stat"));const y=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};l(n.dom,"ln-data-store:ready",y),l(n.dom,"ln-data-store:created",y),l(n.dom,"ln-data-store:updated",y),l(n.dom,"ln-data-store:deleted",y),l(n.dom,"ln-data-store:mutation-error",d=>n._mutationReceipts.reject(d.detail)),l(n.dom,"ln-data-store:synced",d=>{var h;(h=d.detail)!=null&&h.changed&&n._refreshAll(d.detail.meta,!1)}),l(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),l(n.dom,"ln-search:change",d=>{var b;d.preventDefault();const h=((b=d.detail)==null?void 0:b.term)!=null?d.detail.term:"";h!==(n.dom.getAttribute(a)||"")&&n.dom.setAttribute(a,h)}),l(n.dom,"ln-filter:change",d=>{var pe;d.preventDefault();const h=(pe=d.detail)==null?void 0:pe.key;if(!h)return;const b=(d.detail.values||[]).slice(),v=n._currentQuery().filters,S=v[h];if(S?S.length===b.length&&S.every((R,G)=>R===b[G]):!b.length)return;b.length?v[h]=b:delete v[h];const x=new URLSearchParams;Object.keys(v).forEach(R=>v[R].forEach(G=>x.append(R,G)));const O=x.toString();O?n.dom.setAttribute(s,O):n.dom.removeAttribute(s)}),l(n.dom,"ln-sort:change",d=>{var x,O;d.preventDefault();const h=(x=d.detail)==null?void 0:x.field,b=(O=d.detail)==null?void 0:O.direction,v=h&&b&&b!=="none"?{field:h,direction:b}:null,S=n._currentQuery().sort;!S&&!v||S&&v&&S.field===v.field&&S.direction===v.direction||(v?(n.dom.setAttribute(u,v.field),n.dom.setAttribute(c,v.direction)):(n.dom.removeAttribute(u),n.dom.removeAttribute(c)))});const q=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),E=n.findChildren().connectorEl;if(E){const d=_(E);q.add(d),l(n.dom,d+":connected",f)}q.forEach(d=>{l(n.dom,d+":fetched",h=>n._reconcileServerFetch(h.detail)),l(n.dom,d+":created",h=>n._reconcileServerMutation("create",h.detail)),l(n.dom,d+":updated",h=>n._reconcileServerMutation("update",h.detail)),l(n.dom,d+":deleted",h=>n._reconcileServerMutation("ack",h.detail)),l(n.dom,d+":bulk-deleted",h=>n._reconcileServerMutation("ack",h.detail)),l(n.dom,d+":error",h=>n._reconcileServerMutation("error",h.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const r=this.findChildren();if(!r.store||!r.connector||!r.queue)return;const l=n.meta||{},f=_(r.connectorEl),w=n.idempotencyKey||n.entryId,y={create:()=>g(r.connectorEl,f+":request-create",{data:n.payload,url:l.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:l.tempId}}),update:()=>g(r.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:l.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"update",id:n.targetId}}),delete:()=>g(r.connectorEl,f+":request-delete",{id:n.targetId,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"delete",id:n.targetId}}),"bulk-delete":()=>{var q;return g(r.connectorEl,f+":request-bulk-delete",{ids:((q=n.payload)==null?void 0:q.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:l.bulkKey}})}};y[n.op]&&y[n.op]()},C.prototype._onFormSubmit=function(n){const r=n.target;if(n.defaultPrevented)return;const l=r.hasAttribute(o)?r.getAttribute(o):null;if(l===null||(l?!this._owns(l):r.closest("["+e+"]")!==this.dom))return;const f=Q(r);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=P(r);delete w._method,delete w._token;const y=w.id,q=w.expected_version,E=r.getAttribute("action")||"",d=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(d,w,E):this._fanOutUpdate(d,y,w,q,E)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const r=n.meta||{},l=this.findChildren(),f=n.data;this.refreshMapper();const w=Array.isArray(f)?f:(f==null?void 0:f.data)||[],y=Array.isArray(f==null?void 0:f.deleted)?f.deleted:[],q=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(!(!l.store||l.store.initializationError)){if(!r.kind)return l.store.applySync(E,y,q,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:r.targetEl});l.store.applyQuery(E,{total:n.total}).then(d=>{const h=r.kind;h==="table"||h==="list"||h==="chart"?(g(r.targetEl,"ln-"+h+":set-loading",{loading:!1}),g(r.targetEl,"ln-"+h+":set-data",{data:d,total:n.total??d.length,filtered:n.filtered??d.length,offset:n.offset,queryGen:r.queryGen}),this._boundDelivered.set(r.targetEl,!0)):h==="options"?l.store.getAll({}).then(b=>g(r.targetEl,"ln-options:set-data",{data:b.data})):h==="stat"&&g(r.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??E.length})})}},C.prototype._reconcileServerMutation=function(n,r){var w;if(!r)return;const l=this.findChildren(),f=r.meta||{};if(n==="create"){if(!r.record)return this._reportError("create-empty-response",new Error("Create response missing record payload"),f);const y=this.mapper.ingress(r.record);(l.storeEl?this._requestStoreMutation(l,"update",{id:f.tempId,data:y}):Promise.resolve()).then(()=>{f.queued&&l.queue&&g(l.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:y.id})}).catch(q=>this._reportError("create-reconcile",q,f))}else if(n==="update"){const y=r.record?this.mapper.ingress(r.record):null;(l.storeEl&&y?this._requestStoreMutation(l,"update",{id:f.id,data:y}):Promise.resolve()).then(()=>{f.queued&&l.queue&&g(l.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(q=>this._reportError("update-reconcile",q,f))}else if(n==="ack")f.queued&&l.queue&&g(l.queueEl,"ln-api-queue:ack",{entryId:f.entryId});else if(n==="error"){const y=r.status||((w=r.error)==null?void 0:w.status)||0;f.queued&&l.queue&&g(l.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:y===401||y===419?"auth":y===0||y>=500?"retry":"drop"}),l.storeEl&&g(l.storeEl,"ln-data-store:request-sync-failed",{error:r.error||r,status:y}),this._reportError("connector-error",r.error||r,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 U(n,r){const l=n[t];l&&(r==="data-ln-data-coordinator-mapper"?l.refreshMapper():(r===a||r===s||r===u||r===c)&&l._queueQueryRefresh())}de(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",a,s,u,c],onAttributeChange:U}),window[t].init=window[t]})()})();
|
|
1
|
+
(function(){"use strict";function K(){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 T(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 a=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){a=t[l];break}if(!T(a))return}e.apply(console,t)}}function g(e,t,r){const a=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,a),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:a}))}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 Q(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),a=t&&t.exclude,l={},u=e.elements,c={};if(r)for(let p=0;p<u.length;p++){const i=u[p];i.name&&i.type==="checkbox"&&!i.disabled&&(c[i.name]=(c[i.name]||0)+1)}for(let p=0;p<u.length;p++){const i=u[p];if(!(!i.name||i.disabled||i.type==="file"||i.type==="submit"||i.type==="button")&&!(a&&i.matches&&i.matches(a)))if(i.type==="checkbox")r&&c[i.name]===1?l[i.name]=i.checked:(l[i.name]||(l[i.name]=[]),i.checked&&l[i.name].push(i.value));else if(i.type==="radio")i.checked&&(l[i.name]=i.value);else if(i.type==="select-multiple"){l[i.name]=[];for(let m=0;m<i.options.length;m++)i.options[m].selected&&l[i.name].push(i.options[m].value)}else if(r&&i.type==="hidden")l[i.name]=i.value;else if(r&&(i.type==="number"||i.type==="range")){const m=Number(i.value);l[i.name]=i.value===""||isNaN(m)?null:m}else l[i.name]=i.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,a=[],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 i=t[p];if(c.type==="checkbox"){if(Array.isArray(i))c.checked=i.indexOf(c.value)!==-1;else if(l[c.name]>1){const m=String(i).split(",").map(function(A){return A.trim()});c.checked=m.indexOf(c.value)!==-1}else c.checked=we(i);a.push(c)}else if(c.type==="radio")c.checked=c.value===String(i),a.push(c);else if(c.type==="select-multiple"){if(Array.isArray(i))for(let m=0;m<c.options.length;m++)c.options[m].selected=i.indexOf(c.options[m].value)!==-1;a.push(c)}else c.value=i,c.tagName==="SELECT"&&i!=null&&c.setAttribute("data-ln-value",i),a.push(c)}return a}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=me,window.lnCore.serializeForm=P,window.lnCore.resolveFormMethod=Q);const V={};function be(e,t){V[e]=t}function ye(e){return V[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=be,window.lnCore.getDataMapper=ye);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 L={};function Ae(e,t){L[e]||(L[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=L[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],i=p.getAttribute("data-ln-field");t[i]!=null&&(p.textContent=t[i])}const a=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<a.length;c++){const p=a[c],i=p.getAttribute("data-ln-attr").split(",");for(let m=0;m<i.length;m++){const A=i[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],i=p.getAttribute("data-ln-show");i in t&&p.classList.toggle("hidden",!t[i])}const u=e.querySelectorAll("[data-ln-class]");for(let c=0;c<u.length;c++){const p=u[c],i=p.getAttribute("data-ln-class").split(",");for(let m=0;m<i.length;m++){const A=i[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 ve(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 a=0;a<r.length;a++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[a],t??null),r[a].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 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 a=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 i=0;i<p.length;i++){const m=p[i];m.value.indexOf("{{")!==-1&&c.setAttribute(m.name,m.value.replace(/\{\{\s*(\w+)\s*\}\}/g,a))}}return e}function Ee(e,t,r,a,l,u){const c={};for(let i=0;i<e.children.length;i++){const m=e.children[i],A=m.getAttribute("data-ln-render-key");A&&(c[A]=m)}const p=document.createDocumentFragment();for(let i=0;i<t.length;i++){const m=t[i],A=String(a(m));let _=c[A];if(_)l(_,m,i);else{const C=Ae(r,u);if(!C||(J(C,m),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",A),l(_,m,i)}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=ve,window.lnCore.renderList=Ee);function F(e,t,r){const a=e.getAttribute(t);return a===null?r:a}function X(e,t,r){const a=parseInt(e.getAttribute(t),10);return isNaN(a)?r:a}function Y(e,t,r=!1){const a=e.getAttribute(t);if(a===null)return!!r;const l=a.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 a=new Set(e||[]),l=function(u,c){const p=u.getAttribute(c);return p!==null&&a.has(p)?p:t};return j.set(r,l),l}function te(e,t,r){const a=parseFloat(e.getAttribute(t));return isNaN(a)?r:a}function ne(e,t,r){const a=e.getAttribute(t);if(!a)return r;try{return JSON.parse(a)}catch{return r}}function re(e,t,r,a,l){if(!e||t===null)return!0;const u=a||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const p=i=>{l?console.warn(i,l):console.warn(i)};if(c==="boolean"){const i=t.trim().toLowerCase();return i!==""&&i!=="true"&&i!=="false"&&i!=="1"&&i!=="0"?(p(`[${u}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const i=e.values||[];return i.includes(t)?!0:(p(`[${u}] Invalid value "${t}" for attribute "${r}". Allowed: ${i.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 i=parseInt(t,10);return e.min!==void 0&&i<e.min?(p(`[${u}] Value ${i} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&i>e.max?(p(`[${u}] Value ${i} 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(i){return p(`[${u}] Invalid JSON for attribute "${r}": ${i.message}. Fallback: ${e.fallback}.`),!1}return!0}function oe(e,t,r){for(const a in r){const[l,u,c]=r[a];Object.defineProperty(e,a,{get:function(){return l(t,u,c)},enumerable:!0,configurable:!0})}return e}function ie(e){const t={};for(const r in e){const a=e[r];if(!a||!a.prop)continue;let l=a.read;if(!l&&a.type)switch(a.type){case"enum":l=ee(a.values,a.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[a.prop]=[l,r,a.fallback]}return t}function qe(e){const t={};for(const r in e){const a=e[r];a&&a.effect&&(t[r]=a.effect)}return Object.keys(t).length?t:null}function Se(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,a){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:r,ComponentFn:a};if(e.matches&&e.matches(u)&&I(e,c),e.querySelectorAll){const p=e.querySelectorAll(u);for(let i=0;i<p.length;i++)I(p[i],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 a=0;a<r.length;a++){const l=r[a];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 a in e.attributes){t.byDeclaredAttr.has(a)||t.byDeclaredAttr.set(a,[]);const l=t.byDeclaredAttr.get(a);l.some(u=>u.componentTag===e.componentTag)||l.push({spec:e.attributes[a],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const a=Se(e);if(a===null)t.reactiveWildcard.push(e);else for(const l of a)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,a){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,a):u.onAttrChange&&(!u.declared||u.declared.has(r))&&u.onAttrChange(t,r,a)}}function Oe(e){const t=e.attributeName,r=t.indexOf("data-ln-")===0,a=le(),l=a.byAttr.get(t),u=K()&&a.byDeclaredAttr&&a.byDeclaredAttr.has(t);if(!r&&!l&&!u)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(u&&T(c)){const p=a.byDeclaredAttr.get(t),i=c.getAttribute(t);for(let m=0;m<p.length;m++)re(p[m].spec,i,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=a.byReactive.get(t);p&&se(p,c,t,e.oldValue),a.reactiveWildcard.length&&se(a.reactiveWildcard,c,t,e.oldValue)}if(l)for(let p=0;p<l.length;p++){const i=l[p];if(i.handler){i.handler(c,t,e.oldValue);continue}i.onAttributeChange&&c[i.attribute]?i.onAttributeChange(c,t):(ae(c,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.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(a){console.error("[ln-core] mutation handler failed",t[r].target,a)}}).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 B(e,t){if(!document.contains(e))if(t.attribute){const r=e[t.attribute];if(r&&typeof r.destroy=="function")try{r.destroy()}catch(a){console.error("["+t.attribute+"] destroy failed",e,a)}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 a=M();if(e.target&&a.length)for(let l=0;l<a.length;l++){const u=a[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){const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const i=t[p];if(i.selector&&i.attribute&&i.ComponentFn){if(!c)u.matches&&u.matches(i.query)&&I(u,i);else if(u.matches&&u.matches(i.query)&&I(u,i),u.querySelectorAll){const m=u.querySelectorAll(i.query);for(let A=0;A<m.length;A++)I(m[A],i)}}i.onInit&&i.onInit(u)}}}for(let l=0;l<e.removedNodes.length;l++){const u=e.removedNodes[l];if(u.nodeType===1){if(document.contains(u))continue;const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const i=t[p],m=i.query;if(m){if(!c)u.matches&&u.matches(m)&&B(u,i);else if(u.matches&&u.matches(m)&&B(u,i),u.querySelectorAll){const A=u.querySelectorAll(m);for(let _=0;_<A.length;_++)B(A[_],i)}}}}}}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 a=t[r];if(a.type==="childList")try{ce(a)}catch(l){console.error("[ln-core] lifecycle handler failed",a.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 a=0;a<r.length;a++){const l=r[a];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 Te(e){$().push(e),e.onSubtreeChange&&e.query&&M().push(e),de()}function ue(e,t,r,a,l={}){const u=l.extraAttributes||[],c=l.onAttributeChange||null,p=l.onSubtreeChange||null,i=l.onInit||null,m=l.onAttrChange||null,A=l.effects||null,_=l.attributes||null,C=_?qe(_):A,N=_?new Set(Object.keys(_)):null,U=l.persist||null;function n(q){const E=q||document.body;if(ae(E,e,t,r),_&&K())for(const d in _){const h=_[d],b=Array.from(E.querySelectorAll("["+d+"]"));E.matches&&E.matches("["+d+"]")&&b.push(E);for(let v=0;v<b.length;v++){const S=b[v];T(S)&&re(h,S.getAttribute(d),d,a,S)}}i&&i(E)}const o=[];if(e.indexOf("[")!==-1){const q=/\[([\w-]+)/g;let E;for(;(E=q.exec(e))!==null;)o.push(E[1])}else o.push(e);Ie({selector:e,attribute:t,componentTag:a,attributes:_,ComponentFn:r,onInit:i,observed:o.concat(u),onAttributeChange:c,onAttrChange:m,effects:C,declared:N,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:i,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=Te,window.lnCore.withoutLifecycle=Re);function y(){xe()>0?ke(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y):y(),n}function Le(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={},a=fe(t);if(!a)return r;const l=a.split("&");for(let u=0;u<l.length;u++){const c=l[u];if(!c)continue;const p=c.indexOf(":"),i=p>-1?c.slice(0,p):c,m=p>-1?c.slice(p+1):"";if(i)try{r[i]=decodeURIComponent(m)}catch{r[i]=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 a=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return a?t?a+"-"+t:a:t||null}function Be(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function We(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 Ne(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ue(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),a=e.slice(t+1),l=a?a.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=Be,window.lnCore.hashSortDecode=We,window.lnCore.hashFilterEncode=Ne,window.lnCore.hashFilterDecode=Ue);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 Ge(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Ke(e,t){const r=!e||!!e.initializationError,a=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||a)?"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 Qe{constructor(){this._pending=new Map}wait(t){return new Promise((r,a)=>{this._pending.set(t,{resolve:r,reject:a})})}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 a of this._pending.values())a.reject(r);this._pending.clear()}_settle(t,r){const a=t&&t.requestId;if(!a)return!1;const l=this._pending.get(a);return l?(this._pending.delete(a),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 a="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",i=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,i),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 Qe,this._queueQueryRefresh=Le(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),N(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 y=this.mapper.egress(s);n.storeEl&&g(n.storeEl,"ln-data-store:request-update",{id:o,data:y}),this._fanOutRemote(n,"update",{chainKey:o,op:"update",targetId:o,payload:y,expectedVersion:f,meta:{id:o,action:w}},{id:o,data:y,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(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(a)||"",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 y of this.dom.ownerDocument.querySelectorAll(s))if(this._owns(y.getAttribute(f))){if((w==="table"||w==="list")&&y.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){g(y,"ln-"+w+(o?":request-invalidate":":request-revalidate"),{});continue}this._serveElement(y,w,null,n)}},C.prototype._serveElement=function(n,o,s,f){const w=this.findChildren(),y=w.store;if(!y)return;s&&this._boundQueries.set(n,s);const q=this._boundQueries.get(n)||{sort:null,filters:{},search:""},E=pe(q,this._currentQuery()),d=this;return Promise.resolve(y.ready).then(()=>{if(d._destroyed)return;const h=Ke(y,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:q.queryGen}})):h!=="store"?g(n,"ln-"+o+":set-loading",{loading:!1}):y.getAll(E).then(b=>{d._destroyed||!d._boundDelivered||(g(n,"ln-"+o+":set-loading",{loading:!1}),g(n,"ln-"+o+":set-data",{data:b.data,total:(f==null?void 0:f.total)??b.total,filtered:(f==null?void 0:f.filtered)??b.filtered,offset:b.offset??(f==null?void 0:f.offset)??q.offset,queryGen:q.queryGen!==void 0?q.queryGen:(f==null?void 0:f.queryGen)??b.queryGen,provisional:b.provisional===!0}),d._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 y.getAll({}).then(b=>!d._destroyed&&g(n,"ln-options:set-data",{data:b.data}))}if(o==="stat"){let b=s==null?void 0:s.filters;if(!b){const S=n.getAttribute("data-ln-stat-filter");if(S!=null&&S.includes(":")){const x=S.split(":");b={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const v=w.connector&&y&&(y.windowed&&b&&Object.keys(b).length||y.noLocalQuery)?"remote":h;if(v==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:b},meta:{targetEl:n,kind:o}});if(v==="store")return y.count(b).then(S=>!d._destroyed&&g(n,"ln-stat:set-count",{count:S}))}}).catch(h=>{d._destroyed||((o==="table"||o==="list"||o==="chart")&&g(n,"ln-"+o+":set-loading",{loading:!1}),d._reportError(o+"-query",h,{targetEl:n,kind:o}))})};function N(n){const o=n._unsubs=[],s=(d,h,b)=>{d.addEventListener(h,b),o.push(()=>d.removeEventListener(h,b))};s(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const h=n.findChildren();h.store&&h.connector&&g(h.connectorEl,_(h.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),s(n.dom,"ln-data-store:request-page",d=>{const h=n.findChildren(),b=d.detail||{};if(!h.connectorEl)return;const v=pe(b.query||{},n._currentQuery());g(h.connectorEl,_(h.connectorEl)+":request-query",{query:Object.assign({},v,{offset:b.offset,limit:b.limit,queryGen:b.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 b;const h=n.findChildren();h.store&&!h.store.initializationError&&h.connector&&!n._noAutosync(h)&&!h.store.isSyncing&&(!((b=d.detail)!=null&&b.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,b)=>{var v;n._owns(d.target.getAttribute(b))&&n._serveElement(d.target,h,h==="stat"?{filters:((v=d.detail)==null?void 0:v.filters)||null}:h==="options"?null:Ge(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 y=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};s(n.dom,"ln-data-store:ready",y),s(n.dom,"ln-data-store:created",y),s(n.dom,"ln-data-store:updated",y),s(n.dom,"ln-data-store:deleted",y),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 b;d.preventDefault();const h=((b=d.detail)==null?void 0:b.term)!=null?d.detail.term:"";h!==(n.dom.getAttribute(a)||"")&&n.dom.setAttribute(a,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 b=(d.detail.values||[]).slice(),v=n._currentQuery().filters,S=v[h];if(S?S.length===b.length&&S.every((R,G)=>R===b[G]):!b.length)return;b.length?v[h]=b:delete v[h];const x=new URLSearchParams;Object.keys(v).forEach(R=>v[R].forEach(G=>x.append(R,G)));const O=x.toString();O?n.dom.setAttribute(l,O):n.dom.removeAttribute(l)}),s(n.dom,"ln-sort:change",d=>{var x,O;d.preventDefault();const h=(x=d.detail)==null?void 0:x.field,b=(O=d.detail)==null?void 0:O.direction,v=h&&b&&b!=="none"?{field:h,direction:b}:null,S=n._currentQuery().sort;!S&&!v||S&&v&&S.field===v.field&&S.direction===v.direction||(v?(n.dom.setAttribute(u,v.field),n.dom.setAttribute(c,v.direction)):(n.dom.removeAttribute(u),n.dom.removeAttribute(c)))});const q=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),E=n.findChildren().connectorEl;if(E){const d=_(E);q.add(d),s(n.dom,d+":connected",f)}q.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))})}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,y={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 q;return g(o.connectorEl,f+":request-bulk-delete",{ids:((q=n.payload)==null?void 0:q.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:s.bulkKey}})}};y[n.op]&&y[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=Q(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=P(o);delete w._method,delete w._token;const y=w.id,q=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,y,w,q,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)||[],y=Array.isArray(f==null?void 0:f.deleted)?f.deleted:[],q=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,y,q,{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"?(g(o.targetEl,"ln-"+h+":set-loading",{loading:!1}),g(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(b=>g(o.targetEl,"ln-options:set-data",{data:b.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 y=this.mapper.ingress(o.record);(s.storeEl?this._requestStoreMutation(s,"update",{id:f.tempId,data:y}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:y.id})}).catch(q=>this._reportError("create-reconcile",q,f))}else if(n==="update"){const y=o.record?this.mapper.ingress(o.record):null;(s.storeEl&&y?this._requestStoreMutation(s,"update",{id:f.id,data:y}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(q=>this._reportError("update-reconcile",q,f))}else if(n==="ack")f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId});else if(n==="error"){const y=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:y===401||y===419?"auth":y===0||y>=500?"retry":"drop"}),s.storeEl&&g(s.storeEl,"ln-data-store:request-sync-failed",{error:o.error||o,status:y}),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 U(n,o){const s=n[t];s&&(o==="data-ln-data-coordinator-mapper"?s.refreshMapper():(o===a||o===l||o===u||o===c)&&s._queueQueryRefresh())}ue(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",a,l,u,c],onAttributeChange:U}),window[t].init=window[t]})()})();
|
|
@@ -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 s=1;s<t.length;s++)if(t[s]&&t[s].nodeType===1){i=t[s];break}if(!oe(i))return}e.apply(console,t)}}function v(e,t,o){const i=o||{};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 Ve(e,t){const o=!!(t&&t.typed),i=t&&t.exclude,s={},l=e.elements,c={};if(o)for(let d=0;d<l.length;d++){const a=l[d];a.name&&a.type==="checkbox"&&!a.disabled&&(c[a.name]=(c[a.name]||0)+1)}for(let d=0;d<l.length;d++){const a=l[d];if(!(!a.name||a.disabled||a.type==="file"||a.type==="submit"||a.type==="button")&&!(i&&a.matches&&a.matches(i)))if(a.type==="checkbox")o&&c[a.name]===1?s[a.name]=a.checked:(s[a.name]||(s[a.name]=[]),a.checked&&s[a.name].push(a.value));else if(a.type==="radio")a.checked&&(s[a.name]=a.value);else if(a.type==="select-multiple"){s[a.name]=[];for(let w=0;w<a.options.length;w++)a.options[w].selected&&s[a.name].push(a.options[w].value)}else if(o&&a.type==="hidden")s[a.name]=a.value;else if(o&&(a.type==="number"||a.type==="range")){const w=Number(a.value);s[a.name]=a.value===""||isNaN(w)?null:w}else s[a.name]=a.value}return s}function Ge(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function He(e,t){const o=e.elements,i=[],s={};for(let l=0;l<o.length;l++){const c=o[l];c.name&&c.type==="checkbox"&&(s[c.name]=(s[c.name]||0)+1)}for(let l=0;l<o.length;l++){const c=o[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 a=t[d];if(c.type==="checkbox"){if(Array.isArray(a))c.checked=a.indexOf(c.value)!==-1;else if(s[c.name]>1){const w=String(a).split(",").map(function(b){return b.trim()});c.checked=w.indexOf(c.value)!==-1}else c.checked=Ge(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 w=0;w<c.options.length;w++)c.options[w].selected=a.indexOf(c.options[w].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=He,window.lnCore.serializeForm=Ve,window.lnCore.resolveFormMethod=Ue);const ge={};function We(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=We,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(){v(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 o=e.toLowerCase().split("-")[0];me[o]=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 o=ie[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function be(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let c=0;c<o.length;c++){const d=o[c],a=d.getAttribute("data-ln-field");t[a]!=null&&(d.textContent=t[a])}const i=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<i.length;c++){const d=i[c],a=d.getAttribute("data-ln-attr").split(",");for(let w=0;w<a.length;w++){const b=a[w].trim().split(":");if(b.length!==2)continue;const _=b[0].trim(),x=b[1].trim();t[x]!=null&&d.setAttribute(_,t[x])}}const s=e.querySelectorAll("[data-ln-show]");for(let c=0;c<s.length;c++){const d=s[c],a=d.getAttribute("data-ln-show");a in t&&d.classList.toggle("hidden",!t[a])}const l=e.querySelectorAll("[data-ln-class]");for(let c=0;c<l.length;c++){const d=l[c],a=d.getAttribute("data-ln-class").split(",");for(let w=0;w<a.length;w++){const b=a[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 o=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<o.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",o[i],t??null),o[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 o=0;o<t.length;o++)t[o].textContent=""}})));function _e(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const l=o.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]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let l=0;l<s.length;l++){const c=s[l],d=c.attributes;for(let a=0;a<d.length;a++){const w=d[a];w.value.indexOf("{{")!==-1&&c.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function tt(e,t,o,i,s,l){const c={};for(let a=0;a<e.children.length;a++){const w=e.children[a],b=w.getAttribute("data-ln-render-key");b&&(c[b]=w)}const d=document.createDocumentFragment();for(let a=0;a<t.length;a++){const w=t[a],b=String(i(w));let _=c[b];if(_)s(_,w,a);else{const x=Ye(o,l);if(!x||(_e(x,w),_=x.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",b),s(_,w,a)}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,o){const i=e.getAttribute(t);return i===null?o:i}function X(e,t,o){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?o:i}function se(e,t,o=!1){const i=e.getAttribute(t);if(i===null)return!!o;const s=i.trim().toLowerCase();return!(s==="false"||s==="0")}function le(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const ce=new Map;function Ce(e,t){const o=(e?e.join("|"):"")+"::"+t;if(ce.has(o))return ce.get(o);const i=new Set(e||[]),s=function(l,c){const d=l.getAttribute(c);return d!==null&&i.has(d)?d:t};return ce.set(o,s),s}function Se(e,t,o){const i=parseFloat(e.getAttribute(t));return isNaN(i)?o:i}function ve(e,t,o){const i=e.getAttribute(t);if(!i)return o;try{return JSON.parse(i)}catch{return o}}function Ae(e,t,o,i,s){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=a=>{s?console.warn(a,s):console.warn(a)};if(c==="boolean"){const a=t.trim().toLowerCase();return a!==""&&a!=="true"&&a!=="false"&&a!=="1"&&a!=="0"?(d(`[${l}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const a=e.values||[];return a.includes(t)?!0:(d(`[${l}] Invalid value "${t}" for attribute "${o}". Allowed: ${a.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return d(`[${l}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const a=parseInt(t,10);return e.min!==void 0&&a<e.min?(d(`[${l}] Value ${a} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&a>e.max?(d(`[${l}] Value ${a} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(d(`[${l}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(a){return d(`[${l}] Invalid JSON for attribute "${o}": ${a.message}. Fallback: ${e.fallback}.`),!1}return!0}function xe(e,t,o){for(const i in o){const[s,l,c]=o[i];Object.defineProperty(e,i,{get:function(){return s(t,l,c)},enumerable:!0,configurable:!0})}return e}function ke(e){const t={};for(const o in e){const i=e[o];if(!i||!i.prop)continue;let s=i.read;if(!s&&i.type)switch(i.type){case"enum":s=Ce(i.values,i.fallback);break;case"integer":s=X;break;case"float":s=Se;break;case"boolean":s=se;break;case"list":s=le;break;case"json":s=ve;break;case"string":default:s=ae;break}s||(s=ae),t[i.prop]=[s,o,i.fallback]}return t}function nt(e){const t={};for(const o in e){const i=e[o];i&&i.effect&&(t[o]=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 o in e.effects)t.add(o);if(e.onAttrChange&&e.declared)for(const o of e.declared)t.add(o);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=ve);function G(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(o){console.error("["+t.attribute+"] init failed",e,o)}}}function Ee(e,t,o,i){if(e.nodeType!==1)return;const l=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:o,ComponentFn:i};if(e.matches&&e.matches(l)&&G(e,c),e.querySelectorAll){const d=e.querySelectorAll(l);for(let a=0;a<d.length;a++)G(d[a],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 Ie(){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=Ie(),o=e.observed||[];for(let i=0;i<o.length;i++){const s=o[i];t.byAttr.has(s)||t.byAttr.set(s,[]),t.byAttr.get(s).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 s=t.byDeclaredAttr.get(i);s.some(l=>l.componentTag===e.componentTag)||s.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 s of i)t.byReactive.has(s)||t.byReactive.set(s,[]),t.byReactive.get(s).push(e)}e.persist&&t.persist.push(e)}function qe(e,t,o,i){for(let s=0;s<e.length;s++){const l=e[s];if(!t[l.attribute])continue;const c=l.effects&&l.effects[o];c?c(t,o,i):l.onAttrChange&&(!l.declared||l.declared.has(o))&&l.onAttrChange(t,o,i)}}function st(e){const t=e.attributeName,o=t.indexOf("data-ln-")===0,i=Ie(),s=i.byAttr.get(t),l=pe()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(t);if(!o&&!s&&!l)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(l&&oe(c)){const d=i.byDeclaredAttr.get(t),a=c.getAttribute(t);for(let w=0;w<d.length;w++)Ae(d[w].spec,a,t,d[w].componentTag,c)}if(window.lnCore._debugSink&&(o||s)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),o){const d=i.byReactive.get(t);d&&qe(d,c,t,e.oldValue),i.reactiveWildcard.length&&qe(i.reactiveWildcard,c,t,e.oldValue)}if(s)for(let d=0;d<s.length;d++){const a=s[d];if(a.handler){a.handler(c,t,e.oldValue);continue}a.onAttributeChange&&c[a.attribute]?a.onAttributeChange(c,t):(Ee(c,a.selector,a.attribute,a.ComponentFn),a.onInit&&a.onInit(c))}}}function lt(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,Z(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{st(t[o])}catch(i){console.error("[ln-core] mutation handler failed",t[o].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 o=e[t.attribute];if(o&&typeof o.destroy=="function")try{o.destroy()}catch(i){console.error("["+t.attribute+"] destroy failed",e,i)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function ct(e){const t=ue();if(!t.length)return;const o=e.target;if(o){const s=o.nodeType===1?o:o.parentElement;if(s&&(s.isContentEditable||s.closest&&s.closest('[contenteditable]:not([contenteditable="false"])')))return}const i=de();if(e.target&&i.length)for(let s=0;s<i.length;s++){const l=i[s],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 s=0;s<e.addedNodes.length;s++){const l=e.addedNodes[s];if(l.nodeType===1){const c=!!(l.firstElementChild||l.children&&l.children.length);for(let d=0;d<t.length;d++){const a=t[d];if(a.selector&&a.attribute&&a.ComponentFn){if(!c)l.matches&&l.matches(a.query)&&G(l,a);else if(l.matches&&l.matches(a.query)&&G(l,a),l.querySelectorAll){const w=l.querySelectorAll(a.query);for(let b=0;b<w.length;b++)G(w[b],a)}}a.onInit&&a.onInit(l)}}}for(let s=0;s<e.removedNodes.length;s++){const l=e.removedNodes[s];if(l.nodeType===1){const c=!!(l.firstElementChild||l.children&&l.children.length);for(let d=0;d<t.length;d++){const a=t[d],w=a.query;if(w){if(!c)l.matches&&l.matches(w)&&fe(l,a);else if(l.matches&&l.matches(w)&&fe(l,a),l.querySelectorAll){const b=l.querySelectorAll(w);for(let _=0;_<b.length;_++)fe(b[_],a)}}}}}}function De(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,Z(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++){const i=t[o];if(i.type==="childList")try{ct(i)}catch(s){console.error("[ln-core] lifecycle handler failed",i.target,s)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ut(e){ue().push(e),e.onSubtreeChange&&e.query&&de().push(e),De()}function Le(e,t,o,i,s={}){const l=s.extraAttributes||[],c=s.onAttributeChange||null,d=s.onSubtreeChange||null,a=s.onInit||null,w=s.onAttrChange||null,b=s.effects||null,_=s.attributes||null,x=_?nt(_):b,j=_?new Set(Object.keys(_)):null,$=s.persist||null;function g(D){const L=D||document.body;if(Ee(L,e,t,o),_&&pe())for(const F in _){const we=_[F],U=Array.from(L.querySelectorAll("["+F+"]"));L.matches&&L.matches("["+F+"]")&&U.push(L);for(let P=0;P<U.length;P++){const W=U[P];oe(W)&&Ae(we,W.getAttribute(F),F,i,W)}}a&&a(L)}const S=[];if(e.indexOf("[")!==-1){const D=/\[([\w-]+)/g;let L;for(;(L=D.exec(e))!==null;)S.push(L[1])}else S.push(e);at({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:o,onInit:a,observed:S.concat(l),onAttributeChange:c,onAttrChange:w,effects:x,declared:j,persist:$}),lt();const q=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,k=s.subtreeQuery||(q?e:"["+e+"]"),A={selector:e,attribute:t,ComponentFn:o,onInit:a,onSubtreeChange:d,query:k};ue().push(A),d&&k&&de().push(A),De(),window[t]=g,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=Le,window.lnCore.observeLifecycle=ut);function E(){ot()>0?it(function(){g(document.body)}):g(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E):E(),g}function dt(e){let t=!1;for(let o=0;o<e.length;o++){const i=e[o];if(!(i===""||i==null)&&(t=!0,!Number.isFinite(Number(i))))return"string"}return t?"number":"string"}function ft(e,t,o,i){if(o==="number"){const c=parseFloat(e),d=parseFloat(t);return(isNaN(c)?0:c)-(isNaN(d)?0:d)}const s=e!=null?String(e):"",l=t!=null?String(t):"";return i?i.compare(s,l):s<l?-1:s>l?1:0}function Ne(e){return(e||"").replace(/^#/,"")}function he(e){const t=e===void 0?location.hash:e,o={},i=Ne(t);if(!i)return o;const s=i.split("&");for(let l=0;l<s.length;l++){const c=s[l];if(!c)continue;const d=c.indexOf(":"),a=d>-1?c.slice(0,d):c,w=d>-1?c.slice(d+1):"";if(a)try{o[a]=decodeURIComponent(w)}catch{o[a]=w}}return o}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 o=he();t==null?delete o[e]:o[e]=String(t);const s=Object.keys(o).map(function(l){const c=o[l];return c===""?l:l+":"+encodeURIComponent(c)}).join("&");Ne(location.hash)!==s&&(location.hash=s)}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 o=e.getAttribute("data-ln-hash");if(o&&o.trim()!=="")return o.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 o=e.slice(0,t),i=e.slice(t+1),s=i?i.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:o,values:s}}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);let H=null;const Ct="ln-ashlar:storage-salt:v1",Te=32768;function ze(e){let t="";const o=e.byteLength;for(let i=0;i<o;i+=Te)t+=String.fromCharCode.apply(null,e.subarray(i,Math.min(i+Te,o)));return btoa(t)}function Re(e){const t=atob(e),o=t.length,i=new Uint8Array(o);for(let s=0;s<o;s++)i[s]=t.charCodeAt(s);return i}function Oe(e,t){let o=H,i={};return typeof CryptoKey<"u"&&e instanceof CryptoKey?o=e:e&&typeof e=="object"&&(i=e,typeof CryptoKey<"u"&&i.key instanceof CryptoKey&&(o=i.key)),{key:o,options:i}}async function St(e,t={}){if(!e)throw new Error("[ln-crypto] Key derivation failed: Secret string is required");const o=t.method||"pbkdf2",i=new TextEncoder;if(o==="sha256"){const a=await crypto.subtle.digest("SHA-256",i.encode(e));return crypto.subtle.importKey("raw",a,{name:"AES-GCM"},!1,["encrypt","decrypt"])}const s=t.salt||Ct,l=typeof s=="string"?i.encode(s):s,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 Me(e,t={}){if(!e){H=null;return}try{const o=t.method||"sha256";H=await St(e,{...t,method:o})}catch(o){throw console.error("[ln-core/crypto] Key derivation failed:",o),H=null,o}}function B(){return H}async function vt(e,t,o){const{key:i}=Oe(t);if(e==null)return e;if(!i)throw new Error("[ln-crypto] Encryption failed: No active cryptographic key provided");try{const s=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,s.encode(c));return{v:1,alg:"AES-GCM",encrypted:!0,iv:ze(l),data:ze(new Uint8Array(d))}}catch(s){throw console.error("[ln-core/crypto] Encryption failed:",s),new Error("[ln-crypto] Encryption failed: "+(s&&s.message?s.message:String(s)))}}async function At(e,t,o){const{key:i,options:s}=Oe(t),l=s.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=Re(e.iv),a=Re(e.data),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:d},i,a),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 xt(){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=xt);function kt(e){return String(e||"").trim().toLowerCase()}function Et(e){const t=kt(e);return t?t.split(/\s+/).filter(Boolean):[]}function It(e,t){if(!t||t.length===0)return!0;if(!e)return!1;const o=String(e).toLowerCase();for(let i=0;i<t.length;i++)if(o.indexOf(t[i])===-1)return!1;return!0}function qt(e,t){if(!t||t.length===0)return!0;if(e==null)return!1;const o=String(e).trim().toLowerCase();for(let i=0;i<t.length;i++)if(String(t[i]).trim().toLowerCase()===o)return!0;return!1}function Dt(e={}){let t=e.windowSize>0?e.windowSize:1e3,o=e.pageSize>0?e.pageSize:200,i=e.fetchDebounce!=null?e.fetchDebounce:120;const s=typeof e.requestPage=="function"?e.requestPage:()=>{},l=new Map,c=new Set;let d=0,a=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 q=l.keys().next().value;g.push(l.get(q)),l.delete(q)}const S=new Set(l.values());return g.filter(q=>!S.has(q))}function $(g,S){c.add(g),clearTimeout(_),_=setTimeout(()=>s(g,o,S),i)}return{get logicalTotal(){return d},set logicalTotal(g){d=g},get grandTotal(){return a},set grandTotal(g){a=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,q)=>{if(!b&&!c.has(0))return $(0,q);if(d<=0)return;const k=Math.max(0,g),A=Math.min(d,S);for(let E=k;E<A;E++)if(!l.has(E)){const D=Math.floor(E/o)*o;if(!c.has(D))return $(D,q)}},ingest:(g,S,q,k,A)=>{if(A!=null&&A!==w)return[];b=!0,q!=null&&(a=q),k!=null&&(d=k);for(let E=0;E<S.length;E++)x(g+E,S[E]);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&&(o=g.pageSize),g.fetchDebounce>=0&&(i=g.fetchDebounce),S}}}function Lt(e,t,o){if(!Array.isArray(e)||!t||!t.field)return e;const{field:i,direction:s}=t,l=s==="desc",c=e.map(a=>a?a[i]:void 0),d=dt(c);return[...e].sort((a,w)=>{const b=a?a[i]:void 0,_=w?w[i]:void 0,x=ft(b,_,d,o);return l?-x:x})}function Be(e,t){if(!Array.isArray(e)||!t||typeof t!="object")return e;const o=Object.keys(t).filter(i=>Array.isArray(t[i])&&t[i].length>0);return o.length?e.filter(i=>i?o.every(s=>qt(i[s],t[s])):!1):e}function Nt(e,t,o){if(!Array.isArray(e)||!t||!o||!o.length)return e;const i=Et(t);return i.length?e.filter(s=>s?i.every(l=>o.some(c=>{const d=s[c];return d!=null&&It(String(d),[l])})):!1):e}function Tt(e,t,o){if(!Array.isArray(e)||!e.length)return 0;if(o==="count")return e.length;const i=e.map(l=>l&&l[t]!=null?parseFloat(l[t]):NaN).filter(l=>Number.isFinite(l)),s=i.reduce((l,c)=>l+c,0);return o==="sum"?s:o==="avg"&&i.length?s/i.length:0}function zt(e,t={},o=[],i){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const s=e.length;let l=e;t.filters&&(l=Be(l,t.filters)),t.search&&(l=Nt(l,t.search,o));const c=l.length;if(t.sort&&(l=Lt(l,t.sort,i)),t.offset||t.limit){const d=t.offset||0,a=t.limit||l.length;l=l.slice(d,d+a)}return{records:l,total:s,filtered:c}}function Rt(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(o=>{if(!o)return null;const i={...o};for(const[s,l]of Object.entries(t))if(typeof l=="function")try{i[s]=l(o)}catch{i[s]=void 0}return i})}function Ot(e,t,o,i="_meta"){if(!Array.isArray(e)||!e.includes(i))return!0;for(const s of Object.keys(t||{})){if(!e.includes(s))return!0;const l=t[s]&&t[s].indexes||[],c=o&&o[s]||[];if(l.some(d=>!c.includes(d)))return!0}return!1}function Mt(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 o(n,r,u){const f=n.getAttribute(r);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:o,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:nn,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:rn,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"}},s=ke(i),l="ln_app_cache",c="_meta",d="1.0";let a=null,w=null;const b={};function _(n){n&&n.name==="QuotaExceededError"&&v(document,"ln-data-store:quota-exceeded",{error:n})}function x(){const n={};for(const r of document.querySelectorAll(`[${e}]`)){const u=r.id;if(u){const f=r.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 r=x(),u=Object.keys(r),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 z of m)C[z]=Array.from(T.objectStore(z).indexNames)}if(!Ot(p,r,C,c))return $(y),a=y,n(y);const K=y.version;y.close();const M=indexedDB.open(l,K+1);let R=!1,O=null;M.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),v(document,"ln-data-store:blocked",{db:l}),O||(O=setTimeout(()=>{R||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),R=!0,w=null,n(null))},5e3))},M.onerror=()=>{R||(O&&clearTimeout(O),R=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},M.onupgradeneeded=T=>{const z=T.target.result,on=T.target.transaction;z.objectStoreNames.contains(c)||z.createObjectStore(c,{keyPath:"key"});for(const J of u)if(z.objectStoreNames.contains(J)){const re=on.objectStore(J);for(const V of r[J].indexes)re.indexNames.contains(V)||re.createIndex(V,V,{unique:!1})}else{const re=z.createObjectStore(J,{keyPath:"id"});for(const V of r[J].indexes)re.createIndex(V,V,{unique:!1})}},M.onsuccess=T=>{if(R){T.target.result&&T.target.result.close();return}O&&clearTimeout(O),R=!0;const z=T.target.result;$(z),a=z,n(z)}}}),w)}function $(n){n.onversionchange=()=>{n.close(),a=null,w=null}}function g(){return a?Promise.resolve(a):(w=null,j())}async function S(n){if(!B()||!n)return n;const r={...n},u=r.id,f=await vt(r);return!f||!f.encrypted?n:{...f,id:u}}async function q(n){return!n||!n.encrypted||!B()?n:At(n,{silent:!0})}const k=(n,r)=>g().then(u=>u?u.transaction(n,r).objectStore(n):null);function A(n){return new Promise((r,u)=>{n.onsuccess=()=>r(n.result),n.onerror=()=>{_(n.error),u(n.error)}})}const E=n=>k(n,"readonly").then(r=>r?A(r.getAll()):[]).then(r=>B()?Promise.all(r.map(u=>q(u))):r),D=(n,r)=>k(n,"readonly").then(u=>u?A(u.get(r)).then(f=>f!==void 0?f:typeof r=="string"&&r.trim()!==""&&!isNaN(Number(r))?A(u.get(Number(r))):typeof r=="number"?A(u.get(String(r))):null):null).then(u=>u?q(u):null),L=(n,r)=>g().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=r.map(p=>A(h.get(p)).then(m=>m!==void 0?m:typeof p=="string"&&p.trim()!==""&&!isNaN(Number(p))?A(h.get(Number(p))):typeof p=="number"?A(h.get(String(p))):null));return Promise.all(y).then(p=>B()?Promise.all(p.map(m=>m?q(m):null)):p)}),F=(n,r)=>(B()?S(r):Promise.resolve(r)).then(f=>k(n,"readwrite").then(h=>h?A(h.put(f)):null)),we=(n,r)=>k(n,"readwrite").then(u=>u?A(u.delete(r)).then(()=>{if(typeof r=="string"&&r.trim()!==""&&!isNaN(Number(r)))return A(u.delete(Number(r)));if(typeof r=="number")return A(u.delete(String(r)))}):null),U=n=>k(n,"readwrite").then(r=>r?A(r.clear()):null),P=n=>k(n,"readonly").then(r=>r?A(r.count()):0),W=n=>k(c,"readonly").then(r=>r?A(r.get(n)):null),Y=(n,r)=>k(c,"readwrite").then(u=>{if(u)return r.key=n,A(u.put(r))});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,s),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=Dt({windowSize:this._windowSize,pageSize:this._windowPageSize,requestPage:(r,u,f)=>{v(this.dom,"ln-data-store:request-page",{store:this._name,offset:r,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,Bt(this),this.ready=Ut(this),this}function Bt(n){n._handlers={create:r=>ee(n,"create",r.detail,()=>Ft(n,r.detail)),update:r=>ee(n,"update",r.detail,()=>Pt(n,r.detail)),delete:r=>ee(n,"delete",r.detail,()=>jt(n,r.detail)),"bulk-delete":r=>ee(n,"bulk-delete",r.detail,()=>$t(n,r.detail)),"sync-failed":r=>{n.isSyncing=!1,v(n.dom,"ln-data-store:sync-error",{store:n._name,error:r.detail&&r.detail.error,status:r.detail&&r.detail.status})}};for(const[r,u]of Object.entries(n._handlers))n.dom.addEventListener(`ln-data-store:request-${r}`,u);n._queryHandlers={"ln-search:change":r=>{r.preventDefault();const u=r.detail&&r.detail.term!=null?r.detail.term:"";u!==n.query.search&&(n.query.search=u,ye(n))},"ln-filter:change":r=>{r.preventDefault();const u=r.detail&&r.detail.key;if(!u)return;const f=(r.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":r=>{r.preventDefault();const u=r.detail&&r.detail.field,f=r.detail&&r.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[r,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(r,u)}function ee(n,r,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=>Kt(n,r,h,y)),n._mutationChain}function te(n,r=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+r)}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 Ft(n,{tempId:r,data:u={},requestId:f}={}){const h={...u,id:r};return F(n._name,h).then(()=>te(n,1)).then(()=>{v(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:r,requestId:f})})}function Pt(n,{id:r,data:u={},requestId:f}={}){return D(n._name,r).then(h=>{if(!h)throw new Error(`Record not found: ${r}`);const y=h.id,p={...h,...u,id:y},m=u.id,C=m!==void 0&&m!==y;return(C?Vt(n._name,y,{...p,id:m}):F(n._name,p)).then(()=>te(n,0)).then(()=>{v(n.dom,"ln-data-store:updated",{store:n._name,record:C?{...p,id:m}:p,previous:h,requestId:f})})})}function jt(n,{id:r,requestId:u}={}){return D(n._name,r).then(f=>{if(!f){v(n.dom,"ln-data-store:deleted",{store:n._name,id:r,requestId:u,missing:!0});return}const h=f.id;return we(n._name,h).then(()=>te(n,-1)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function $t(n,{ids:r=[],requestId:u}={}){return r.length?Promise.all(r.map(f=>D(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(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,ids:h,requestId:u})})}):(v(n.dom,"ln-data-store:deleted",{store:n._name,ids:[],requestId:u}),Promise.resolve())}function Kt(n,r,u,f){console.error("[ln-data-store] "+r+" failed:",f),v(n.dom,"ln-data-store:mutation-error",{store:n._name,action:r,requestId:u,error:f})}function Ut(n){return j().then(r=>{if(!r)throw new Error("IndexedDB is unavailable");return W(n._name)}).then(r=>{if(n.initializationError=null,r&&r.schema_version===d)n.lastSyncedAt=r.last_synced_at||null,n.totalCount=r.record_count||0,n.hasCache=r.has_cache===!0||n.totalCount>0,n.hasCache&&(n.isLoaded=!0,n.canServe=!0,v(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"cache"})),n.isInitialized=!0,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:n.hasCache,lastSyncedAt:n.lastSyncedAt,count:n.totalCount});else{if(r&&r.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,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})});n.isInitialized=!0,n.hasCache=!1,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})}}).catch(r=>(n.isInitialized=!0,n.isLoaded=!1,n.canServe=!1,n.hasCache=!1,n.isSyncing=!1,n.initializationError=r,v(n.dom,"ln-data-store:initialization-error",{store:n._name,error:r}),{ok:!1,error:r}))}function Fe(n){n.isSyncing=!0,v(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function Pe(n,r){return g().then(u=>u?(B()?Promise.all(r.map(h=>S(h))):Promise.resolve(r)).then(h=>new Promise((y,p)=>{const m=u.transaction(n,"readwrite"),C=m.objectStore(n);h.forEach(I=>C.put(I)),m.oncomplete=()=>y(),m.onerror=()=>{_(m.error),p(m.error)}})):void 0)}function ne(n,r){return g().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);r.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 Vt(n,r,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"),I=C.objectStore(n);I.put(h),I.delete(r),C.oncomplete=()=>p(),C.onerror=()=>{_(C.error),m(C.error)}})}))}const Gt=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Ht(n){return n?Object.keys(n).filter(r=>Array.isArray(n[r])&&n[r].length>0):[]}function Wt(n,r,u){return r.every(f=>u[f].map(String).includes(String(n[f])))}function Qt(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function Jt(n,r,u){return r.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function Zt(n,r,u){return Tt(n,r,u)}function Q(n,r){return Rt(r,n.presenters&&n.presenters.computed)}function Xt(n){return!n.sort&&!B()}function Yt(n,r,u){const f=Ht(r.filters),h=r.search?Qt(r.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return k(n._name,"readonly").then(m=>m?new Promise((C,I)=>{const K=[],M=m.openCursor();M.onsuccess=()=>{const R=M.result;if(!R||K.length>=u){C(K);return}const O=R.value;(!f.length||Wt(O,f,r.filters))&&(!p||Jt(O,h,y))&&K.push(O),R.continue()},M.onerror=()=>I(M.error)}):[])}function je(n,r,u){return zt(r,u,n._searchFields,Gt)}function $e(n,r,u){const f=[];for(let y=r;y<r+u;y++){const p=n._windowIndex.getId(y);f.push(p)}const h=Array.from(new Set(f.filter(y=>y!==void 0)));return L(n._name,h).then(y=>{const p=new Map;for(let C=0;C<y.length;C++){const I=y[C];I&&p.set(String(I.id),I)}const m=[];for(let C=0;C<f.length;C++){const I=f[C];if(I===void 0)m.push(null);else{const K=p.get(String(I));m.push(K||null)}}return{data:Q(n,m),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:r,queryGen:n._windowIndex.queryGen}})}N.prototype.getAll=function(n={}){const r=this;if(r._windowIndex){const u=n.offset||0,f=n.limit||200;if(r._windowIndex.ensure(u,u+f,n),!r._windowIndex.hasLoaded&&!r.noLocalQuery){const h=u+f,y=p=>p.length?{data:Q(r,p),offset:u,queryGen:r._windowIndex.queryGen,provisional:!0}:$e(r,u,f);return Xt(n)?Yt(r,n,h).then(p=>y(p.slice(u,h))):E(r._name).then(p=>y(je(r,p,n).records))}return $e(r,u,f)}return E(r._name).then(u=>{const f=je(r,u,n);return{data:Q(r,f.records),total:f.total,filtered:f.filtered}})},N.prototype.getById=function(n){return D(this._name,n).then(r=>r?Q(this,[r])[0]:null)},N.prototype.count=function(n){return n&&Object.keys(n).length>0?E(this._name).then(u=>Be(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):P(this._name)},N.prototype.aggregate=function(n,r){return E(this._name).then(u=>Zt(u,n,r))},N.prototype.setPresenters=function(n){this.presenters=n},N.prototype.applySync=function(n,r,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(()=>Pe(h._name,n))),r.length>0&&(y=y.then(()=>ne(h._name,r))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,m=n.map(I=>I.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?(v(h.dom,"ln-data-store:loaded",{store:h._name,count:h.totalCount,meta:f}),v(h.dom,"ln-data-store:ready",{store:h._name,count:h.totalCount,source:"server",meta:f})):v(h.dom,"ln-data-store:synced",{store:h._name,added:n.length,deleted:r.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),v(h.dom,"ln-data-store:sync-error",{store:h._name,error:m}),Mt(p)})},N.prototype.applyQuery=function(n,r){r=r||{};const u=this;let f=Promise.resolve();return n.length>0&&(f=f.then(()=>Pe(u._name,n))),f.then(()=>P(u._name)).then(h=>(u.totalCount=r.total!==void 0?r.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||Fe(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,Fe(n)})},N.prototype.destroy=function(){if(this._windowIndex&&(this._windowIndex.clear(),this._windowIndex=null,this.windowed=!1),this._handlers){for(const[n,r]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-data-store:request-${n}`,r);this._handlers=null}if(this._queryHandlers){for(const[n,r]of Object.entries(this._queryHandlers))this.dom.removeEventListener(n,r);this._queryHandlers=null}delete b[this._name],delete this.dom[t]};function en(){return g().then(n=>{if(!n)return;const r=Array.from(n.objectStoreNames);return new Promise((u,f)=>{const h=n.transaction(r,"readwrite");r.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(),v(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 tn="data-ln-data-store-frozen";function Ke(n,r){n.setAttribute(tn,r)}function nn(n){const r=n[t];if(!r._windowIndex)return;const u=r._windowIndex.configure({windowSize:r._windowSize});u.length&&ne(r._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function rn(n){const r=n[t];r._windowIndex&&r._windowIndex.configure({pageSize:r._windowPageSize})}Le(e,t,N,"ln-data-store",{attributes:i}),window[t].clearAll=en,window[t].init=window[t],window[t].setStorageKey=Me,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=Me)})()})();
|
|
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 v(e,t,o){const i=o||{};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 Ve(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Ge(e,t){const o=!!(t&&t.typed),i=t&&t.exclude,a={},l=e.elements,c={};if(o)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")o&&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(o&&s.type==="hidden")a[s.name]=s.value;else if(o&&(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 He(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 o=e.elements,i=[],a={};for(let l=0;l<o.length;l++){const c=o[l];c.name&&c.type==="checkbox"&&(a[c.name]=(a[c.name]||0)+1)}for(let l=0;l<o.length;l++){const c=o[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=He(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=Ve);const ge={};function Qe(e,t){ge[e]=t}function Je(e){return ge[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=Qe,window.lnCore.getDataMapper=Je);function Ze(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,Z(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const me={};function Xe(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];me[o]=t}function Ye(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=Xe,window.lnCore.getLocaleFallback=Ye,window.lnCore.ensureLocaleObserver=Ze);const ie={};function et(e,t){ie[e]||(ie[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=ie[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function be(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let c=0;c<o.length;c++){const d=o[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 tt(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 o=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<o.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",o[i],t??null),o[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 o=0;o<t.length;o++)t[o].textContent=""}})));function _e(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const l=o.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 nt(e,t,o,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=et(o,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=tt,window.lnCore.renderList=nt);function ae(e,t,o){const i=e.getAttribute(t);return i===null?o:i}function X(e,t,o){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?o:i}function se(e,t,o=!1){const i=e.getAttribute(t);if(i===null)return!!o;const a=i.trim().toLowerCase();return!(a==="false"||a==="0")}function le(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const ce=new Map;function Ce(e,t){const o=(e?e.join("|"):"")+"::"+t;if(ce.has(o))return ce.get(o);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(o,a),a}function Se(e,t,o){const i=parseFloat(e.getAttribute(t));return isNaN(i)?o:i}function ve(e,t,o){const i=e.getAttribute(t);if(!i)return o;try{return JSON.parse(i)}catch{return o}}function Ae(e,t,o,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 "${o}". 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 "${o}". Allowed: ${s.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return d(`[${l}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const s=parseInt(t,10);return e.min!==void 0&&s<e.min?(d(`[${l}] Value ${s} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&s>e.max?(d(`[${l}] Value ${s} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(d(`[${l}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(s){return d(`[${l}] Invalid JSON for attribute "${o}": ${s.message}. Fallback: ${e.fallback}.`),!1}return!0}function xe(e,t,o){for(const i in o){const[a,l,c]=o[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 o in e){const i=e[o];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=ve;break;case"string":default:a=ae;break}a||(a=ae),t[i.prop]=[a,o,i.fallback]}return t}function rt(e){const t={};for(const o in e){const i=e[o];i&&i.effect&&(t[o]=i.effect)}return Object.keys(t).length?t:null}function ot(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const o in e.effects)t.add(o);if(e.onAttrChange&&e.declared)for(const o of e.declared)t.add(o);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=ve);function G(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(o){console.error("["+t.attribute+"] init failed",e,o)}}}function Ee(e,t,o,i){if(e.nodeType!==1)return;const l=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:o,ComponentFn:i};if(e.matches&&e.matches(l)&&G(e,c),e.querySelectorAll){const d=e.querySelectorAll(l);for(let s=0;s<d.length;s++)G(d[s],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function it(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function at(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 Ie(){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 st(e){const t=Ie(),o=e.observed||[];for(let i=0;i<o.length;i++){const a=o[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=ot(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 qe(e,t,o,i){for(let a=0;a<e.length;a++){const l=e[a];if(!t[l.attribute])continue;const c=l.effects&&l.effects[o];c?c(t,o,i):l.onAttrChange&&(!l.declared||l.declared.has(o))&&l.onAttrChange(t,o,i)}}function lt(e){const t=e.attributeName,o=t.indexOf("data-ln-")===0,i=Ie(),a=i.byAttr.get(t),l=pe()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(t);if(!o&&!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++)Ae(d[w].spec,s,t,d[w].componentTag,c)}if(window.lnCore._debugSink&&(o||a)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),o){const d=i.byReactive.get(t);d&&qe(d,c,t,e.oldValue),i.reactiveWildcard.length&&qe(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):(Ee(c,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(c))}}}function ct(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,Z(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{lt(t[o])}catch(i){console.error("[ln-core] mutation handler failed",t[o].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 o=e[t.attribute];if(o&&typeof o.destroy=="function")try{o.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 o=e.target;if(o){const a=o.nodeType===1?o:o.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)&&G(l,s);else if(l.matches&&l.matches(s.query)&&G(l,s),l.querySelectorAll){const w=l.querySelectorAll(s.query);for(let b=0;b<w.length;b++)G(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 o=0;o<t.length;o++){const i=t[o];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 ut(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const o=t.takeRecords();for(let i=0;i<o.length;i++){const a=o[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 dt(e){ue().push(e),e.onSubtreeChange&&e.query&&de().push(e),De()}function Ne(e,t,o,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=_?rt(_):b,j=_?new Set(Object.keys(_)):null,$=a.persist||null;function g(L){const D=L||document.body;if(Ee(D,e,t,o),_&&pe())for(const F in _){const we=_[F],U=Array.from(D.querySelectorAll("["+F+"]"));D.matches&&D.matches("["+F+"]")&&U.push(D);for(let P=0;P<U.length;P++){const W=U[P];oe(W)&&Ae(we,W.getAttribute(F),F,i,W)}}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);st({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:o,onInit:s,observed:S.concat(l),onAttributeChange:c,onAttrChange:w,effects:x,declared:j,persist:$}),ct();const q=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,k=a.subtreeQuery||(q?e:"["+e+"]"),A={selector:e,attribute:t,ComponentFn:o,onInit:s,onSubtreeChange:d,query:k};ue().push(A),d&&k&&de().push(A),De(),window[t]=g,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=Ne,window.lnCore.observeLifecycle=dt,window.lnCore.withoutLifecycle=ut);function E(){it()>0?at(function(){g(document.body)}):g(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",E):E(),g}function ft(e){let t=!1;for(let o=0;o<e.length;o++){const i=e[o];if(!(i===""||i==null)&&(t=!0,!Number.isFinite(Number(i))))return"string"}return t?"number":"string"}function ht(e,t,o,i){if(o==="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,o={},i=Te(t);if(!i)return o;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{o[s]=decodeURIComponent(w)}catch{o[s]=w}}return o}function wt(e){if(!e)return null;const t=he();return e in t?t[e]:null}function yt(e,t){if(!e)return;const o=he();t==null?delete o[e]:o[e]=String(t);const a=Object.keys(o).map(function(l){const c=o[l];return c===""?l:l+":"+encodeURIComponent(c)}).join("&");Te(location.hash)!==a&&(location.hash=a)}function pt(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function gt(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const o=e.getAttribute("data-ln-hash");if(o&&o.trim()!=="")return o.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 bt(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 _t(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ct(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const o=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:o,values:a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=he,window.lnCore.hashGet=wt,window.lnCore.hashSet=yt,window.lnCore.hashLinkClick=pt,window.lnCore.resolveHashNamespace=gt,window.lnCore.hashSortEncode=mt,window.lnCore.hashSortDecode=bt,window.lnCore.hashFilterEncode=_t,window.lnCore.hashFilterDecode=Ct);let H=null;const St="ln-ashlar:storage-salt:v1",ze=32768;function Re(e){let t="";const o=e.byteLength;for(let i=0;i<o;i+=ze)t+=String.fromCharCode.apply(null,e.subarray(i,Math.min(i+ze,o)));return btoa(t)}function Oe(e){const t=atob(e),o=t.length,i=new Uint8Array(o);for(let a=0;a<o;a++)i[a]=t.charCodeAt(a);return i}function Me(e,t){let o=H,i={};return typeof CryptoKey<"u"&&e instanceof CryptoKey?o=e:e&&typeof e=="object"&&(i=e,typeof CryptoKey<"u"&&i.key instanceof CryptoKey&&(o=i.key)),{key:o,options:i}}async function vt(e,t={}){if(!e)throw new Error("[ln-crypto] Key derivation failed: Secret string is required");const o=t.method||"pbkdf2",i=new TextEncoder;if(o==="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||St,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){H=null;return}try{const o=t.method||"sha256";H=await vt(e,{...t,method:o})}catch(o){throw console.error("[ln-core/crypto] Key derivation failed:",o),H=null,o}}function B(){return H}async function At(e,t,o){const{key:i}=Me(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:Re(l),data:Re(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 xt(e,t,o){const{key:i,options:a}=Me(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 kt(){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=kt);function Et(e){return String(e||"").trim().toLowerCase()}function It(e){const t=Et(e);return t?t.split(/\s+/).filter(Boolean):[]}function qt(e,t){if(!t||t.length===0)return!0;if(!e)return!1;const o=String(e).toLowerCase();for(let i=0;i<t.length;i++)if(o.indexOf(t[i])===-1)return!1;return!0}function Lt(e,t){if(!t||t.length===0)return!0;if(e==null)return!1;const o=String(e).trim().toLowerCase();for(let i=0;i<t.length;i++)if(String(t[i]).trim().toLowerCase()===o)return!0;return!1}function Dt(e={}){let t=e.windowSize>0?e.windowSize:1e3,o=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 q=l.keys().next().value;g.push(l.get(q)),l.delete(q)}const S=new Set(l.values());return g.filter(q=>!S.has(q))}function $(g,S){c.add(g),clearTimeout(_),_=setTimeout(()=>a(g,o,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,q)=>{if(!b&&!c.has(0))return $(0,q);if(d<=0)return;const k=Math.max(0,g),A=Math.min(d,S);for(let E=k;E<A;E++)if(!l.has(E)){const L=Math.floor(E/o)*o;if(!c.has(L))return $(L,q)}},ingest:(g,S,q,k,A)=>{if(A!=null&&A!==w)return[];b=!0,q!=null&&(s=q),k!=null&&(d=k);for(let E=0;E<S.length;E++)x(g+E,S[E]);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&&(o=g.pageSize),g.fetchDebounce>=0&&(i=g.fetchDebounce),S}}}function Nt(e,t,o){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=ft(c);return[...e].sort((s,w)=>{const b=s?s[i]:void 0,_=w?w[i]:void 0,x=ht(b,_,d,o);return l?-x:x})}function Fe(e,t){if(!Array.isArray(e)||!t||typeof t!="object")return e;const o=Object.keys(t).filter(i=>Array.isArray(t[i])&&t[i].length>0);return o.length?e.filter(i=>i?o.every(a=>Lt(i[a],t[a])):!1):e}function Tt(e,t,o){if(!Array.isArray(e)||!t||!o||!o.length)return e;const i=It(t);return i.length?e.filter(a=>a?i.every(l=>o.some(c=>{const d=a[c];return d!=null&&qt(String(d),[l])})):!1):e}function zt(e,t,o){if(!Array.isArray(e)||!e.length)return 0;if(o==="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 o==="sum"?a:o==="avg"&&i.length?a/i.length:0}function Rt(e,t={},o=[],i){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const a=e.length;let l=e;t.filters&&(l=Fe(l,t.filters)),t.search&&(l=Tt(l,t.search,o));const c=l.length;if(t.sort&&(l=Nt(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 Ot(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(o=>{if(!o)return null;const i={...o};for(const[a,l]of Object.entries(t))if(typeof l=="function")try{i[a]=l(o)}catch{i[a]=void 0}return i})}function Mt(e,t,o,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=o&&o[a]||[];if(l.some(d=>!c.includes(d)))return!0}return!1}function Bt(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 o(n,r,u){const f=n.getAttribute(r);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:Ue,description:"Identifies the element as a data-store definition container"},"data-ln-data-store-indexes":{type:"list",effect:Ue,description:"Comma-separated index field names for the IndexedDB store"},"data-ln-data-store-stale":{prop:"_staleThreshold",type:"integer",read:o,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:rn,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:on,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"&&v(document,"ln-data-store:quota-exceeded",{error:n})}function x(){const n={};for(const r of document.querySelectorAll(`[${e}]`)){const u=r.id;if(u){const f=r.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 r=x(),u=Object.keys(r),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 z of m)C[z]=Array.from(T.objectStore(z).indexNames)}if(!Mt(p,r,C,c))return $(y),s=y,n(y);const K=y.version;y.close();const M=indexedDB.open(l,K+1);let R=!1,O=null;M.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),v(document,"ln-data-store:blocked",{db:l}),O||(O=setTimeout(()=>{R||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),R=!0,w=null,n(null))},5e3))},M.onerror=()=>{R||(O&&clearTimeout(O),R=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},M.onupgradeneeded=T=>{const z=T.target.result,an=T.target.transaction;z.objectStoreNames.contains(c)||z.createObjectStore(c,{keyPath:"key"});for(const J of u)if(z.objectStoreNames.contains(J)){const re=an.objectStore(J);for(const V of r[J].indexes)re.indexNames.contains(V)||re.createIndex(V,V,{unique:!1})}else{const re=z.createObjectStore(J,{keyPath:"id"});for(const V of r[J].indexes)re.createIndex(V,V,{unique:!1})}},M.onsuccess=T=>{if(R){T.target.result&&T.target.result.close();return}O&&clearTimeout(O),R=!0;const z=T.target.result;$(z),s=z,n(z)}}}),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 r={...n},u=r.id,f=await At(r);return!f||!f.encrypted?n:{...f,id:u}}async function q(n){return!n||!n.encrypted||!B()?n:xt(n,{silent:!0})}const k=(n,r)=>g().then(u=>u?u.transaction(n,r).objectStore(n):null);function A(n){return new Promise((r,u)=>{n.onsuccess=()=>r(n.result),n.onerror=()=>{_(n.error),u(n.error)}})}const E=n=>k(n,"readonly").then(r=>r?A(r.getAll()):[]).then(r=>B()?Promise.all(r.map(u=>q(u))):r),L=(n,r)=>k(n,"readonly").then(u=>u?A(u.get(r)).then(f=>f!==void 0?f:typeof r=="string"&&r.trim()!==""&&!isNaN(Number(r))?A(u.get(Number(r))):typeof r=="number"?A(u.get(String(r))):null):null).then(u=>u?q(u):null),D=(n,r)=>g().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=r.map(p=>A(h.get(p)).then(m=>m!==void 0?m:typeof p=="string"&&p.trim()!==""&&!isNaN(Number(p))?A(h.get(Number(p))):typeof p=="number"?A(h.get(String(p))):null));return Promise.all(y).then(p=>B()?Promise.all(p.map(m=>m?q(m):null)):p)}),F=(n,r)=>(B()?S(r):Promise.resolve(r)).then(f=>k(n,"readwrite").then(h=>h?A(h.put(f)):null)),we=(n,r)=>k(n,"readwrite").then(u=>u?A(u.delete(r)).then(()=>{if(typeof r=="string"&&r.trim()!==""&&!isNaN(Number(r)))return A(u.delete(Number(r)));if(typeof r=="number")return A(u.delete(String(r)))}):null),U=n=>k(n,"readwrite").then(r=>r?A(r.clear()):null),P=n=>k(n,"readonly").then(r=>r?A(r.count()):0),W=n=>k(c,"readonly").then(r=>r?A(r.get(n)):null),Y=(n,r)=>k(c,"readwrite").then(u=>{if(u)return r.key=n,A(u.put(r))});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=Dt({windowSize:this._windowSize,pageSize:this._windowPageSize,requestPage:(r,u,f)=>{v(this.dom,"ln-data-store:request-page",{store:this._name,offset:r,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,Ft(this),this.ready=Vt(this),this}function Ft(n){n._handlers={create:r=>ee(n,"create",r.detail,()=>Pt(n,r.detail)),update:r=>ee(n,"update",r.detail,()=>jt(n,r.detail)),delete:r=>ee(n,"delete",r.detail,()=>$t(n,r.detail)),"bulk-delete":r=>ee(n,"bulk-delete",r.detail,()=>Kt(n,r.detail)),"sync-failed":r=>{n.isSyncing=!1,v(n.dom,"ln-data-store:sync-error",{store:n._name,error:r.detail&&r.detail.error,status:r.detail&&r.detail.status})}};for(const[r,u]of Object.entries(n._handlers))n.dom.addEventListener(`ln-data-store:request-${r}`,u);n._queryHandlers={"ln-search:change":r=>{r.preventDefault();const u=r.detail&&r.detail.term!=null?r.detail.term:"";u!==n.query.search&&(n.query.search=u,ye(n))},"ln-filter:change":r=>{r.preventDefault();const u=r.detail&&r.detail.key;if(!u)return;const f=(r.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":r=>{r.preventDefault();const u=r.detail&&r.detail.field,f=r.detail&&r.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[r,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(r,u)}function ee(n,r,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=>Ut(n,r,h,y)),n._mutationChain}function te(n,r=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+r)}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 Pt(n,{tempId:r,data:u={},requestId:f}={}){const h={...u,id:r};return F(n._name,h).then(()=>te(n,1)).then(()=>{v(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:r,requestId:f})})}function jt(n,{id:r,data:u={},requestId:f}={}){return L(n._name,r).then(h=>{if(!h)throw new Error(`Record not found: ${r}`);const y=h.id,p={...h,...u,id:y},m=u.id,C=m!==void 0&&m!==y;return(C?Gt(n._name,y,{...p,id:m}):F(n._name,p)).then(()=>te(n,0)).then(()=>{v(n.dom,"ln-data-store:updated",{store:n._name,record:C?{...p,id:m}:p,previous:h,requestId:f})})})}function $t(n,{id:r,requestId:u}={}){return L(n._name,r).then(f=>{if(!f){v(n.dom,"ln-data-store:deleted",{store:n._name,id:r,requestId:u,missing:!0});return}const h=f.id;return we(n._name,h).then(()=>te(n,-1)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function Kt(n,{ids:r=[],requestId:u}={}){return r.length?Promise.all(r.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(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,ids:h,requestId:u})})}):(v(n.dom,"ln-data-store:deleted",{store:n._name,ids:[],requestId:u}),Promise.resolve())}function Ut(n,r,u,f){console.error("[ln-data-store] "+r+" failed:",f),v(n.dom,"ln-data-store:mutation-error",{store:n._name,action:r,requestId:u,error:f})}function Vt(n){return j().then(r=>{if(!r)throw new Error("IndexedDB is unavailable");return W(n._name)}).then(r=>{if(n.initializationError=null,r&&r.schema_version===d)n.lastSyncedAt=r.last_synced_at||null,n.totalCount=r.record_count||0,n.hasCache=r.has_cache===!0||n.totalCount>0,n.hasCache&&(n.isLoaded=!0,n.canServe=!0,v(n.dom,"ln-data-store:ready",{store:n._name,count:n.totalCount,source:"cache"})),n.isInitialized=!0,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:n.hasCache,lastSyncedAt:n.lastSyncedAt,count:n.totalCount});else{if(r&&r.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,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})});n.isInitialized=!0,n.hasCache=!1,v(n.dom,"ln-data-store:initialized",{store:n._name,hasCache:!1,lastSyncedAt:null,count:0})}}).catch(r=>(n.isInitialized=!0,n.isLoaded=!1,n.canServe=!1,n.hasCache=!1,n.isSyncing=!1,n.initializationError=r,v(n.dom,"ln-data-store:initialization-error",{store:n._name,error:r}),{ok:!1,error:r}))}function Pe(n){n.isSyncing=!0,v(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function je(n,r){return g().then(u=>u?(B()?Promise.all(r.map(h=>S(h))):Promise.resolve(r)).then(h=>new Promise((y,p)=>{const m=u.transaction(n,"readwrite"),C=m.objectStore(n);h.forEach(I=>C.put(I)),m.oncomplete=()=>y(),m.onerror=()=>{_(m.error),p(m.error)}})):void 0)}function ne(n,r){return g().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);r.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 Gt(n,r,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"),I=C.objectStore(n);I.put(h),I.delete(r),C.oncomplete=()=>p(),C.onerror=()=>{_(C.error),m(C.error)}})}))}const Ht=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Wt(n){return n?Object.keys(n).filter(r=>Array.isArray(n[r])&&n[r].length>0):[]}function Qt(n,r,u){return r.every(f=>u[f].map(String).includes(String(n[f])))}function Jt(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function Zt(n,r,u){return r.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function Xt(n,r,u){return zt(n,r,u)}function Q(n,r){return Ot(r,n.presenters&&n.presenters.computed)}function Yt(n){return!n.sort&&!B()}function en(n,r,u){const f=Wt(r.filters),h=r.search?Jt(r.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return k(n._name,"readonly").then(m=>m?new Promise((C,I)=>{const K=[],M=m.openCursor();M.onsuccess=()=>{const R=M.result;if(!R||K.length>=u){C(K);return}const O=R.value;(!f.length||Qt(O,f,r.filters))&&(!p||Zt(O,h,y))&&K.push(O),R.continue()},M.onerror=()=>I(M.error)}):[])}function $e(n,r,u){return Rt(r,u,n._searchFields,Ht)}function Ke(n,r,u){const f=[];for(let y=r;y<r+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 I=y[C];I&&p.set(String(I.id),I)}const m=[];for(let C=0;C<f.length;C++){const I=f[C];if(I===void 0)m.push(null);else{const K=p.get(String(I));m.push(K||null)}}return{data:Q(n,m),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:r,queryGen:n._windowIndex.queryGen}})}N.prototype.getAll=function(n={}){const r=this;if(r._windowIndex){const u=n.offset||0,f=n.limit||200;if(r._windowIndex.ensure(u,u+f,n),!r._windowIndex.hasLoaded&&!r.noLocalQuery){const h=u+f,y=p=>p.length?{data:Q(r,p),offset:u,queryGen:r._windowIndex.queryGen,provisional:!0}:Ke(r,u,f);return Yt(n)?en(r,n,h).then(p=>y(p.slice(u,h))):E(r._name).then(p=>y($e(r,p,n).records))}return Ke(r,u,f)}return E(r._name).then(u=>{const f=$e(r,u,n);return{data:Q(r,f.records),total:f.total,filtered:f.filtered}})},N.prototype.getById=function(n){return L(this._name,n).then(r=>r?Q(this,[r])[0]:null)},N.prototype.count=function(n){return n&&Object.keys(n).length>0?E(this._name).then(u=>Fe(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):P(this._name)},N.prototype.aggregate=function(n,r){return E(this._name).then(u=>Xt(u,n,r))},N.prototype.setPresenters=function(n){this.presenters=n},N.prototype.applySync=function(n,r,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))),r.length>0&&(y=y.then(()=>ne(h._name,r))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,m=n.map(I=>I.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?(v(h.dom,"ln-data-store:loaded",{store:h._name,count:h.totalCount,meta:f}),v(h.dom,"ln-data-store:ready",{store:h._name,count:h.totalCount,source:"server",meta:f})):v(h.dom,"ln-data-store:synced",{store:h._name,added:n.length,deleted:r.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),v(h.dom,"ln-data-store:sync-error",{store:h._name,error:m}),Bt(p)})},N.prototype.applyQuery=function(n,r){r=r||{};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=r.total!==void 0?r.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,r]of Object.entries(this._handlers))this.dom.removeEventListener(`ln-data-store:request-${n}`,r);this._handlers=null}if(this._queryHandlers){for(const[n,r]of Object.entries(this._queryHandlers))this.dom.removeEventListener(n,r);this._queryHandlers=null}delete b[this._name],delete this.dom[t]};function tn(){return g().then(n=>{if(!n)return;const r=Array.from(n.objectStoreNames);return new Promise((u,f)=>{const h=n.transaction(r,"readwrite");r.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(),v(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 nn="data-ln-data-store-frozen";function Ue(n,r){n.setAttribute(nn,r)}function rn(n){const r=n[t];if(!r._windowIndex)return;const u=r._windowIndex.configure({windowSize:r._windowSize});u.length&&ne(r._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function on(n){const r=n[t];r._windowIndex&&r._windowIndex.configure({pageSize:r._windowPageSize})}Ne(e,t,N,"ln-data-store",{attributes:i}),window[t].clearAll=tn,window[t].init=window[t],window[t].setStorageKey=Be,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=Be)})()})();
|