@livenetworks/ashlar 2.0.9 → 2.0.10
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-api-connector/ln-api-connector.js +1 -1
- package/components/ln-api-queue/ln-api-queue.js +1 -1
- package/components/ln-autoresize/ln-autoresize.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/lifecycle.js +1 -1
- 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-debug/src/generated-attributes.js +1 -0
- package/components/ln-dropdown/ln-dropdown.js +1 -1
- package/components/ln-editor/ln-editor.js +1 -1
- package/components/ln-filter/ln-filter.js +1 -1
- package/components/ln-filter/ln-filter.schema.json +161 -153
- package/components/ln-filter/src/ln-filter.js +77 -5
- package/components/ln-form/ln-form.js +1 -1
- package/components/ln-include/ln-include.js +1 -1
- package/components/ln-key/ln-key.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-search/src/ln-search.js +17 -1
- package/components/ln-slug/ln-slug.js +1 -1
- package/components/ln-sort/ln-sort.js +1 -1
- 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/ln-ashlar.html-data.json +5 -0
- package/package.json +1 -1
- package/web-types.json +8 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function B(){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 D(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 o=null;for(let s=1;s<t.length;s++)if(t[s]&&t[s].nodeType===1){o=t[s];break}if(!D(o))return}e.apply(console,t)}}function _(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}function T(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){T(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function ne(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function oe(e,t){const n=!!(t&&t.typed),o=t&&t.exclude,s={},c=e.elements,i={};if(n)for(let a=0;a<c.length;a++){const r=c[a];r.name&&r.type==="checkbox"&&!r.disabled&&(i[r.name]=(i[r.name]||0)+1)}for(let a=0;a<c.length;a++){const r=c[a];if(!(!r.name||r.disabled||r.type==="file"||r.type==="submit"||r.type==="button")&&!(o&&r.matches&&r.matches(o)))if(r.type==="checkbox")n&&i[r.name]===1?s[r.name]=r.checked:(s[r.name]||(s[r.name]=[]),r.checked&&s[r.name].push(r.value));else if(r.type==="radio")r.checked&&(s[r.name]=r.value);else if(r.type==="select-multiple"){s[r.name]=[];for(let h=0;h<r.options.length;h++)r.options[h].selected&&s[r.name].push(r.options[h].value)}else if(n&&r.type==="hidden")s[r.name]=r.value;else if(n&&(r.type==="number"||r.type==="range")){const h=Number(r.value);s[r.name]=r.value===""||isNaN(h)?null:h}else s[r.name]=r.value}return s}function re(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function ie(e,t){const n=e.elements,o=[],s={};for(let c=0;c<n.length;c++){const i=n[c];i.name&&i.type==="checkbox"&&(s[i.name]=(s[i.name]||0)+1)}for(let c=0;c<n.length;c++){const i=n[c];if(i.type==="file"||i.type==="submit"||i.type==="button")continue;const a=i.getAttribute("data-ln-fill-as")||i.name;if(!a||!(a in t))continue;const r=t[a];if(i.type==="checkbox"){if(Array.isArray(r))i.checked=r.indexOf(i.value)!==-1;else if(s[i.name]>1){const h=String(r).split(",").map(function(m){return m.trim()});i.checked=h.indexOf(i.value)!==-1}else i.checked=re(r);o.push(i)}else if(i.type==="radio")i.checked=i.value===String(r),o.push(i);else if(i.type==="select-multiple"){if(Array.isArray(r))for(let h=0;h<i.options.length;h++)i.options[h].selected=r.indexOf(i.options[h].value)!==-1;o.push(i)}else i.value=r,i.tagName==="SELECT"&&r!=null&&i.setAttribute("data-ln-value",r),o.push(i)}return o}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ie,window.lnCore.serializeForm=oe,window.lnCore.resolveFormMethod=ne);function x(...e){return e.filter(t=>t!=null&&t!=="").map((t,n)=>n===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function E(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function le(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(n){return console.error(`[${t}] Invalid headers JSON:`,n),{}}}const R={};function se(e,t){R[e]=t}function ce(e){return R[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=se,window.lnCore.getDataMapper=ce);function ae(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,T(function(){new MutationObserver(function(){_(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const F={};function de(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];F[n]=t}function ue(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return F[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=de,window.lnCore.getLocaleFallback=ue,window.lnCore.ensureLocaleObserver=ae);const L={};function fe(e,t){L[e]||(L[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=L[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function M(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let i=0;i<n.length;i++){const a=n[i],r=a.getAttribute("data-ln-field");t[r]!=null&&(a.textContent=t[r])}const o=e.querySelectorAll("[data-ln-attr]");for(let i=0;i<o.length;i++){const a=o[i],r=a.getAttribute("data-ln-attr").split(",");for(let h=0;h<r.length;h++){const m=r[h].trim().split(":");if(m.length!==2)continue;const g=m[0].trim(),y=m[1].trim();t[y]!=null&&a.setAttribute(g,t[y])}}const s=e.querySelectorAll("[data-ln-show]");for(let i=0;i<s.length;i++){const a=s[i],r=a.getAttribute("data-ln-show");r in t&&a.classList.toggle("hidden",!t[r])}const c=e.querySelectorAll("[data-ln-class]");for(let i=0;i<c.length;i++){const a=c[i],r=a.getAttribute("data-ln-class").split(",");for(let h=0;h<r.length;h++){const m=r[h].trim().split(":");if(m.length!==2)continue;const g=m[0].trim(),y=m[1].trim();y in t&&a.classList.toggle(g,!!t[y])}}return e}function he(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 n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let o=0;o<n.length;o++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[o],t??null),n[o].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)M(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function P(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const c=n.currentNode;c.textContent.indexOf("{{")!==-1&&(c.textContent=c.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(i,a){return t[a]!==void 0?t[a]:""}))}const o=function(c,i){return t[i]!==void 0?t[i]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let c=0;c<s.length;c++){const i=s[c],a=i.attributes;for(let r=0;r<a.length;r++){const h=a[r];h.value.indexOf("{{")!==-1&&i.setAttribute(h.name,h.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function we(e,t,n,o,s,c){const i={};for(let r=0;r<e.children.length;r++){const h=e.children[r],m=h.getAttribute("data-ln-render-key");m&&(i[m]=h)}const a=document.createDocumentFragment();for(let r=0;r<t.length;r++){const h=t[r],m=String(o(h));let g=i[m];if(g)s(g,h,r);else{const y=fe(n,c);if(!y||(P(y,h),g=y.firstElementChild,!g))continue;g.setAttribute("data-ln-render-key",m),s(g,h,r)}a.appendChild(g)}e.textContent="",e.appendChild(a)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=P,window.lnCore.fill=M,window.lnCore.lnFill=he,window.lnCore.renderList=we);function O(e,t,n){const o=e.getAttribute(t);return o===null?n:o}function H(e,t,n){const o=parseInt(e.getAttribute(t),10);return isNaN(o)?n:o}function U(e,t,n=!1){const o=e.getAttribute(t);if(o===null)return!!n;const s=o.trim().toLowerCase();return!(s==="false"||s==="0")}function W(e,t){return(e.getAttribute(t)||"").split(",").map(n=>n.trim()).filter(Boolean)}const j=new Map;function J(e,t){const n=(e?e.join("|"):"")+"::"+t;if(j.has(n))return j.get(n);const o=new Set(e||[]),s=function(c,i){const a=c.getAttribute(i);return a!==null&&o.has(a)?a:t};return j.set(n,s),s}function V(e,t,n){const o=parseFloat(e.getAttribute(t));return isNaN(o)?n:o}function K(e,t,n){const o=e.getAttribute(t);if(!o)return n;try{return JSON.parse(o)}catch{return n}}function G(e,t,n,o,s){if(!e||t===null)return!0;const c=o||"ln-component",i=e.type;if(i==="trigger"||i==="marker"||i==="string"||i==="list"||!i||t===""&&e.fallback!==void 0)return!0;const a=r=>{s?console.warn(r,s):console.warn(r)};if(i==="boolean"){const r=t.trim().toLowerCase();return r!==""&&r!=="true"&&r!=="false"&&r!=="1"&&r!=="0"?(a(`[${c}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(i==="enum"){const r=e.values||[];return r.includes(t)?!0:(a(`[${c}] Invalid value "${t}" for attribute "${n}". Allowed: ${r.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(i==="integer"){if(!/^-?\d+$/.test(t))return a(`[${c}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const r=parseInt(t,10);return e.min!==void 0&&r<e.min?(a(`[${c}] Value ${r} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&r>e.max?(a(`[${c}] Value ${r} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(i==="float")return isNaN(Number(t))?(a(`[${c}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(i==="json")try{return JSON.parse(t),!0}catch(r){return a(`[${c}] Invalid JSON for attribute "${n}": ${r.message}. Fallback: ${e.fallback}.`),!1}return!0}function z(e,t,n){for(const o in n){const[s,c,i]=n[o];Object.defineProperty(e,o,{get:function(){return s(t,c,i)},enumerable:!0,configurable:!0})}return e}function Q(e){const t={};for(const n in e){const o=e[n];if(!o||!o.prop)continue;let s=o.read;if(!s&&o.type)switch(o.type){case"enum":s=J(o.values,o.fallback);break;case"integer":s=H;break;case"float":s=V;break;case"boolean":s=U;break;case"list":s=W;break;case"json":s=K;break;case"string":default:s=O;break}s||(s=O),t[o.prop]=[s,n,o.fallback]}return t}function pe(e){const t={};for(const n in e){const o=e[n];o&&o.effect&&(t[n]=o.effect)}return Object.keys(t).length?t:null}function be(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=z,window.lnCore.attrSpec=Q,window.lnCore.attrStr=O,window.lnCore.attrInt=H,window.lnCore.attrBool=U,window.lnCore.attrList=W,window.lnCore.attrEnum=J,window.lnCore.attrFloat=V,window.lnCore.attrJson=K);function I(e,t,n,o){if(e.nodeType!==1)return;const c=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",i=Array.from(e.querySelectorAll(c));e.matches&&e.matches(c)&&i.push(e);for(const a of i)if(!a[n]){window.lnCore._persistSink&&a.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(a,t);try{a[n]=new o(a)}catch(r){console.error("["+n+"] init failed",a,r)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function me(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ge(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 X(){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 Ce(e){const t=X(),n=e.observed||[];for(let o=0;o<n.length;o++){const s=n[o];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 o in e.attributes){t.byDeclaredAttr.has(o)||t.byDeclaredAttr.set(o,[]);const s=t.byDeclaredAttr.get(o);s.some(c=>c.componentTag===e.componentTag)||s.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=be(e);if(o===null)t.reactiveWildcard.push(e);else for(const s of o)t.byReactive.has(s)||t.byReactive.set(s,[]),t.byReactive.get(s).push(e)}e.persist&&t.persist.push(e)}function Y(e,t,n,o){for(let s=0;s<e.length;s++){const c=e[s];if(!t[c.attribute])continue;const i=c.effects&&c.effects[n];i?i(t,n,o):c.onAttrChange&&(!c.declared||c.declared.has(n))&&c.onAttrChange(t,n,o)}}function ye(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const o=X(),s=o.byAttr.get(n);if(B()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(n)&&D(t)){const c=o.byDeclaredAttr.get(n),i=t.getAttribute(n);for(let a=0;a<c.length;a++)G(c[a].spec,i,n,c[a].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||s)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const c=o.byReactive.get(n);c&&Y(c,t,n,e.oldValue),o.reactiveWildcard.length&&Y(o.reactiveWildcard,t,n,e.oldValue)}if(s)for(let c=0;c<s.length;c++){const i=s[c];if(i.handler){i.handler(t,n,e.oldValue);continue}i.onAttributeChange&&t[i.attribute]?i.onAttributeChange(t,n):(I(t,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(t))}}function ve(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,T(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{ye(t[n])}catch(o){console.error("[ln-core] mutation handler failed",t[n].target,o)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function Z(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function _e(e){const t=Z();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const o=t[n];if(o.onSubtreeChange){const s=o.query,c=e.target.nodeType===1?e.target.matches(s)?e.target:e.target.closest(s):e.target.parentElement?e.target.parentElement.closest(s):null;c&&o.onSubtreeChange(c,e)}}for(let n=0;n<e.addedNodes.length;n++){const o=e.addedNodes[n];if(o.nodeType===1)for(let s=0;s<t.length;s++){const c=t[s];I(o,c.selector,c.attribute,c.ComponentFn),c.onInit&&c.onInit(o)}}for(let n=0;n<e.removedNodes.length;n++){const o=e.removedNodes[n];if(o.nodeType===1)for(let s=0;s<t.length;s++){const c=t[s],i=c.query,a=Array.from(o.querySelectorAll(i));o.matches&&o.matches(i)&&a.push(o);for(let r=0;r<a.length;r++){const h=a[r];if(!document.contains(h)){const m=h[c.attribute];if(m&&typeof m.destroy=="function")try{m.destroy()}catch(g){console.error("["+c.attribute+"] destroy failed",h,g)}delete h[c.attribute]}}}}}}function Ae(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,T(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{_e(o)}catch(s){console.error("[ln-core] lifecycle handler failed",o.target,s)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ee(e,t,n,o,s={}){const c=s.extraAttributes||[],i=s.onAttributeChange||null,a=s.onSubtreeChange||null,r=s.onInit||null,h=s.onAttrChange||null,m=s.effects||null,g=s.attributes||null,y=g?pe(g):m,$=g?new Set(Object.keys(g)):null,l=s.persist||null;function u(p){const w=p||document.body;if(I(w,e,t,n),g&&B())for(const v in g){const N=g[v],A=Array.from(w.querySelectorAll("["+v+"]"));w.matches&&w.matches("["+v+"]")&&A.push(w);for(let S=0;S<A.length;S++){const k=A[S];D(k)&&G(N,k.getAttribute(v),v,o,k)}}r&&r(w)}const d=[];if(e.indexOf("[")!==-1){const p=/\[([\w-]+)/g;let w;for(;(w=p.exec(e))!==null;)d.push(w[1])}else d.push(e);Ce({selector:e,attribute:t,componentTag:o,attributes:g,ComponentFn:n,onInit:r,observed:d.concat(c),onAttributeChange:i,onAttrChange:h,effects:y,declared:$,persist:l}),ve();const b=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";Z().push({selector:e,attribute:t,ComponentFn:n,onInit:r,onSubtreeChange:a,query:b}),Ae(),window[t]=u,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ee);function C(){me()>0?ge(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C):C(),u}function te(e){return(e||"").replace(/^#/,"")}function q(e){const t=e===void 0?location.hash:e,n={},o=te(t);if(!o)return n;const s=o.split("&");for(let c=0;c<s.length;c++){const i=s[c];if(!i)continue;const a=i.indexOf(":"),r=a>-1?i.slice(0,a):i,h=a>-1?i.slice(a+1):"";if(r)try{n[r]=decodeURIComponent(h)}catch{n[r]=h}}return n}function ke(e){if(!e)return null;const t=q();return e in t?t[e]:null}function xe(e,t){if(!e)return;const n=q();t==null?delete n[e]:n[e]=String(t);const s=Object.keys(n).map(function(c){const i=n[c];return i===""?c:c+":"+encodeURIComponent(i)}).join("&");te(location.hash)!==s&&(location.hash=s)}function Se(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Oe(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const o=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return o?t?o+"-"+t:o:t||null}function Ee(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Te(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 De(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Le(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),o=e.slice(t+1),s=o?o.split(",").map(function(c){try{return decodeURIComponent(c)}catch{return c}}).filter(Boolean):[];return{key:n,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=q,window.lnCore.hashGet=ke,window.lnCore.hashSet=xe,window.lnCore.hashLinkClick=Se,window.lnCore.resolveHashNamespace=Oe,window.lnCore.hashSortEncode=Ee,window.lnCore.hashSortDecode=Te,window.lnCore.hashFilterEncode=De,window.lnCore.hashFilterDecode=Le);function je(){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=je),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",n="lnConnector";if(window[t]!==void 0)return;function o(l){const u=l[t];u&&u.refreshConfig()}const s={"data-ln-couchdb-connector":{type:"marker",description:"Mounts CouchDB/PouchDB connector bridging database and ln-ashlar data coordinators"},"data-ln-couchdb-url":{prop:"url",read:O,type:"string",fallback:"",effect:o,description:"CouchDB server base endpoint URL"},"data-ln-couchdb-db":{prop:"db",read:O,type:"string",fallback:"",effect:o,description:"Target CouchDB database name"},"data-ln-couchdb-auth":{prop:"auth",read:O,type:"string",fallback:"",effect:o,description:"Authentication credentials for CouchDB requests"},"data-ln-couchdb-headers":{effect:o,type:"json",fallback:null,description:"Custom HTTP headers in JSON or semicolon-separated format"}},c=Q(s);function i(l){const u=l&&l.content!==void 0?l.content:l,d=l&&l.message?l.message:null;return{content:u,message:d}}function a(l){return this.dom=l,z(this,l,c),l[t]=this,l[n]=this,this.namespace="ln-couchdb-connector",this.refreshConfig(),this._deltaController=null,this._handlers=null,$(this),this}a.prototype.refreshConfig=function(){const l=this.dom;this.credentials="same-origin";const u=l.getAttribute("data-ln-couchdb-headers")||"";this.headers=le(u,"ln-couchdb-connector"),this.auth&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-auth attribute. Storing basic authentication credentials in HTML DOM attributes is highly discouraged and vulnerable to XSS credential extraction. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),u.toLowerCase().includes("authorization")&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-headers attribute. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),_(l,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function r(l,u,d){const f=Object.assign({},E(l.headers,l.auth),d||{});return u&&(f["Idempotency-Key"]=u),f}a.prototype.fetchDelta=function(l){const u=this;this._deltaController&&this._deltaController.abort(),this._deltaController=new AbortController;const d=this._deltaController.signal,f=["include_docs=true","feed=normal"];l&&f.push("since="+encodeURIComponent(l));const b=x(u.url,u.db,"_changes")+"?"+f.join("&");return window.fetch(b,{method:"GET",headers:E(u.headers,u.auth),credentials:u.credentials,signal:d}).then(C=>{if(!C.ok)throw new Error("HTTP "+C.status+": "+C.statusText);return C.json()}).then(C=>{const p=C.results||[];return{data:p.filter(w=>!w.deleted&&w.doc).map(w=>Object.assign({},w.doc,{id:w.doc._id})),deleted:p.filter(w=>w.deleted).map(w=>w.id),synced_at:C.last_seq||l||""}}).finally(()=>{u._deltaController&&u._deltaController.signal===d&&(u._deltaController=null)})};function h(l,u,d){const f=Object.assign({_id:u.id},u);return f._id||delete f._id,window.fetch(x(l.url,l.db),{method:"POST",headers:r(l,d),credentials:l.credentials,body:JSON.stringify(f)}).then(b=>{if(!b.ok)throw new Error("HTTP "+b.status+": "+b.statusText);return b.json()}).then(b=>{const C=i(b),p=C.content;return{record:Object.assign({},f,{id:p.id,_id:p.id,_rev:p.rev}),message:C.message}})}a.prototype.create=function(l,u){return h(this,l,u).then(d=>d.record)};function m(l,u,d,f){const b=Object.assign({id:String(u),_id:String(u)},d),C=b._rev||b.rev;return(C?Promise.resolve(C):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:E(l.headers,l.auth),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("Could not retrieve document for revision mapping");return w.json().then(v=>v._rev)})).then(w=>{const v=Object.assign({},b,{_rev:w});delete v.rev;const N=r(l,f,{"If-Match":w});return window.fetch(x(l.url,l.db,null,u),{method:"PUT",headers:N,credentials:l.credentials,body:JSON.stringify(v)}).then(A=>{if(A.ok)return A.json().then(S=>{const k=i(S);return{record:Object.assign({},v,{_rev:k.content.rev}),message:k.message}});if(A.status===409)return A.json().then(S=>{const k=new Error("Conflict");throw k.status=409,k.data=S,k});throw new Error("HTTP "+A.status+": "+A.statusText)})})}a.prototype.update=function(l,u,d){return m(this,l,u,d).then(f=>f.record)};function g(l,u,d,f){return(d?Promise.resolve(d):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:E(l.headers,l.auth),credentials:l.credentials}).then(C=>{if(!C.ok)throw new Error("Could not retrieve document for revision delete");return C.json().then(p=>p._rev)})).then(C=>{const p=x(l.url,l.db,null,u)+"?rev="+encodeURIComponent(C);return window.fetch(p,{method:"DELETE",headers:r(l,f),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("HTTP "+w.status+": "+w.statusText);return w.json()}).then(w=>{const v=i(w);return{response:v.content,message:v.message}})})}a.prototype.delete=function(l,u,d){return g(this,l,u,d).then(f=>f.response)};function y(l,u,d){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(x(l.url,l.db,"_all_docs"),{method:"POST",headers:E(l.headers,l.auth),credentials:l.credentials,body:JSON.stringify({keys:u})}).then(f=>{if(!f.ok)throw new Error("HTTP "+f.status+": "+f.statusText);return f.json()}).then(f=>{const C=(f.rows||[]).filter(p=>!p.error&&p.value&&p.value.rev).map(p=>({_id:p.id,_rev:p.value.rev,_deleted:!0}));return C.length===0?{response:{ok:!0,deletedCount:0},message:null}:window.fetch(x(l.url,l.db,"_bulk_docs"),{method:"POST",headers:r(l,d),credentials:l.credentials,body:JSON.stringify({docs:C})}).then(p=>{if(!p.ok)throw new Error("HTTP "+p.status+": "+p.statusText);return p.json()}).then(p=>{const w=i(p);return{response:{ok:!0,results:w.content,deletedCount:C.length},message:w.message}})})}a.prototype.bulkDelete=function(l,u){return y(this,l,u).then(d=>d.response)};function $(l){l._handlers={sync:function(u){const d=u.detail||{};l.fetchDelta(d.since).then(function(f){_(l.dom,"ln-couchdb-connector:fetched",{data:f,since:d.since,meta:d.meta||null})}).catch(function(f){f&&f.name==="AbortError"||_(l.dom,"ln-couchdb-connector:error",{action:"sync",error:f.message,status:f.status||0,since:d.since,meta:d.meta||null})})},create:function(u){const d=u.detail||{};h(l,d.data,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:created",{record:f.record,tempId:d.tempId,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"create",error:f.message,status:f.status||0,tempId:d.tempId,meta:d.meta||null})})},update:function(u){const d=u.detail||{},f=Object.assign({},d.data);d.expected_version!==void 0&&(f._rev=d.expected_version),m(l,d.id,f,d.idempotencyKey).then(function(b){_(l.dom,"ln-couchdb-connector:updated",{record:b.record,id:d.id,message:b.message,meta:d.meta||null})}).catch(function(b){_(l.dom,"ln-couchdb-connector:error",{action:"update",error:b.message,status:b.status||0,id:d.id,data:b.status===409?b.data:null,conflictData:b.status===409?b.data:null,meta:d.meta||null})})},delete:function(u){const d=u.detail||{};g(l,d.id,d.rev,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:deleted",{response:f.response,id:d.id,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"delete",error:f.message,status:f.status||0,id:d.id,meta:d.meta||null})})},bulkDelete:function(u){const d=u.detail||{};y(l,d.ids,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:bulk-deleted",{response:f.response,ids:d.ids,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:f.message,status:f.status||0,ids:d.ids,meta:d.meta||null})})}},l.dom.addEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.addEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.addEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.addEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete)}a.prototype.destroy=function(){if(!this.dom[t])return;const l=this;l._deltaController&&(l._deltaController.abort(),l._deltaController=null),l._handlers&&(l.dom.removeEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.removeEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.removeEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.removeEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete),l._handlers=null),delete this.dom[t],delete this.dom[n]},ee(e,t,a,"ln-couchdb-connector",{attributes:s})})()})();
|
|
1
|
+
(function(){"use strict";function B(){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 D(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 o=null;for(let s=1;s<t.length;s++)if(t[s]&&t[s].nodeType===1){o=t[s];break}if(!D(o))return}e.apply(console,t)}}function _(e,t,n){const o=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,o),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:o}))}function T(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){T(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function ne(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function oe(e,t){const n=!!(t&&t.typed),o=t&&t.exclude,s={},c=e.elements,i={};if(n)for(let a=0;a<c.length;a++){const r=c[a];r.name&&r.type==="checkbox"&&!r.disabled&&(i[r.name]=(i[r.name]||0)+1)}for(let a=0;a<c.length;a++){const r=c[a];if(!(!r.name||r.disabled||r.type==="file"||r.type==="submit"||r.type==="button")&&!(o&&r.matches&&r.matches(o)))if(r.type==="checkbox")n&&i[r.name]===1?s[r.name]=r.checked:(s[r.name]||(s[r.name]=[]),r.checked&&s[r.name].push(r.value));else if(r.type==="radio")r.checked&&(s[r.name]=r.value);else if(r.type==="select-multiple"){s[r.name]=[];for(let h=0;h<r.options.length;h++)r.options[h].selected&&s[r.name].push(r.options[h].value)}else if(n&&r.type==="hidden")s[r.name]=r.value;else if(n&&(r.type==="number"||r.type==="range")){const h=Number(r.value);s[r.name]=r.value===""||isNaN(h)?null:h}else s[r.name]=r.value}return s}function re(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function ie(e,t){const n=e.elements,o=[],s={};for(let c=0;c<n.length;c++){const i=n[c];i.name&&i.type==="checkbox"&&(s[i.name]=(s[i.name]||0)+1)}for(let c=0;c<n.length;c++){const i=n[c];if(i.type==="file"||i.type==="submit"||i.type==="button")continue;const a=i.getAttribute("data-ln-fill-as")||i.name;if(!a||!(a in t))continue;const r=t[a];if(i.type==="checkbox"){if(Array.isArray(r))i.checked=r.indexOf(i.value)!==-1;else if(s[i.name]>1){const h=String(r).split(",").map(function(m){return m.trim()});i.checked=h.indexOf(i.value)!==-1}else i.checked=re(r);o.push(i)}else if(i.type==="radio")i.checked=i.value===String(r),o.push(i);else if(i.type==="select-multiple"){if(Array.isArray(r))for(let h=0;h<i.options.length;h++)i.options[h].selected=r.indexOf(i.options[h].value)!==-1;o.push(i)}else i.value=r,i.tagName==="SELECT"&&r!=null&&i.setAttribute("data-ln-value",r),o.push(i)}return o}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ie,window.lnCore.serializeForm=oe,window.lnCore.resolveFormMethod=ne);function x(...e){return e.filter(t=>t!=null&&t!=="").map((t,n)=>n===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function E(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function le(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(n){return console.error(`[${t}] Invalid headers JSON:`,n),{}}}const R={};function se(e,t){R[e]=t}function ce(e){return R[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=se,window.lnCore.getDataMapper=ce);function ae(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,T(function(){new MutationObserver(function(){_(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const F={};function de(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];F[n]=t}function ue(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return F[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=de,window.lnCore.getLocaleFallback=ue,window.lnCore.ensureLocaleObserver=ae);const L={};function fe(e,t){L[e]||(L[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=L[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function M(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let i=0;i<n.length;i++){const a=n[i],r=a.getAttribute("data-ln-field");t[r]!=null&&(a.textContent=t[r])}const o=e.querySelectorAll("[data-ln-attr]");for(let i=0;i<o.length;i++){const a=o[i],r=a.getAttribute("data-ln-attr").split(",");for(let h=0;h<r.length;h++){const m=r[h].trim().split(":");if(m.length!==2)continue;const g=m[0].trim(),y=m[1].trim();t[y]!=null&&a.setAttribute(g,t[y])}}const s=e.querySelectorAll("[data-ln-show]");for(let i=0;i<s.length;i++){const a=s[i],r=a.getAttribute("data-ln-show");r in t&&a.classList.toggle("hidden",!t[r])}const c=e.querySelectorAll("[data-ln-class]");for(let i=0;i<c.length;i++){const a=c[i],r=a.getAttribute("data-ln-class").split(",");for(let h=0;h<r.length;h++){const m=r[h].trim().split(":");if(m.length!==2)continue;const g=m[0].trim(),y=m[1].trim();y in t&&a.classList.toggle(g,!!t[y])}}return e}function he(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 n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let o=0;o<n.length;o++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[o],t??null),n[o].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)M(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function P(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const c=n.currentNode;c.textContent.indexOf("{{")!==-1&&(c.textContent=c.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(i,a){return t[a]!==void 0?t[a]:""}))}const o=function(c,i){return t[i]!==void 0?t[i]:""},s=Array.from(e.querySelectorAll("*"));e.nodeType===1&&s.push(e);for(let c=0;c<s.length;c++){const i=s[c],a=i.attributes;for(let r=0;r<a.length;r++){const h=a[r];h.value.indexOf("{{")!==-1&&i.setAttribute(h.name,h.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function we(e,t,n,o,s,c){const i={};for(let r=0;r<e.children.length;r++){const h=e.children[r],m=h.getAttribute("data-ln-render-key");m&&(i[m]=h)}const a=document.createDocumentFragment();for(let r=0;r<t.length;r++){const h=t[r],m=String(o(h));let g=i[m];if(g)s(g,h,r);else{const y=fe(n,c);if(!y||(P(y,h),g=y.firstElementChild,!g))continue;g.setAttribute("data-ln-render-key",m),s(g,h,r)}a.appendChild(g)}e.textContent="",e.appendChild(a)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=P,window.lnCore.fill=M,window.lnCore.lnFill=he,window.lnCore.renderList=we);function O(e,t,n){const o=e.getAttribute(t);return o===null?n:o}function H(e,t,n){const o=parseInt(e.getAttribute(t),10);return isNaN(o)?n:o}function U(e,t,n=!1){const o=e.getAttribute(t);if(o===null)return!!n;const s=o.trim().toLowerCase();return!(s==="false"||s==="0")}function W(e,t){return(e.getAttribute(t)||"").split(",").map(n=>n.trim()).filter(Boolean)}const j=new Map;function J(e,t){const n=(e?e.join("|"):"")+"::"+t;if(j.has(n))return j.get(n);const o=new Set(e||[]),s=function(c,i){const a=c.getAttribute(i);return a!==null&&o.has(a)?a:t};return j.set(n,s),s}function V(e,t,n){const o=parseFloat(e.getAttribute(t));return isNaN(o)?n:o}function K(e,t,n){const o=e.getAttribute(t);if(!o)return n;try{return JSON.parse(o)}catch{return n}}function G(e,t,n,o,s){if(!e||t===null)return!0;const c=o||"ln-component",i=e.type;if(i==="trigger"||i==="marker"||i==="string"||i==="list"||!i||t===""&&e.fallback!==void 0)return!0;const a=r=>{s?console.warn(r,s):console.warn(r)};if(i==="boolean"){const r=t.trim().toLowerCase();return r!==""&&r!=="true"&&r!=="false"&&r!=="1"&&r!=="0"?(a(`[${c}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(i==="enum"){const r=e.values||[];return r.includes(t)?!0:(a(`[${c}] Invalid value "${t}" for attribute "${n}". Allowed: ${r.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(i==="integer"){if(!/^-?\d+$/.test(t))return a(`[${c}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const r=parseInt(t,10);return e.min!==void 0&&r<e.min?(a(`[${c}] Value ${r} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&r>e.max?(a(`[${c}] Value ${r} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(i==="float")return isNaN(Number(t))?(a(`[${c}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(i==="json")try{return JSON.parse(t),!0}catch(r){return a(`[${c}] Invalid JSON for attribute "${n}": ${r.message}. Fallback: ${e.fallback}.`),!1}return!0}function z(e,t,n){for(const o in n){const[s,c,i]=n[o];Object.defineProperty(e,o,{get:function(){return s(t,c,i)},enumerable:!0,configurable:!0})}return e}function Q(e){const t={};for(const n in e){const o=e[n];if(!o||!o.prop)continue;let s=o.read;if(!s&&o.type)switch(o.type){case"enum":s=J(o.values,o.fallback);break;case"integer":s=H;break;case"float":s=V;break;case"boolean":s=U;break;case"list":s=W;break;case"json":s=K;break;case"string":default:s=O;break}s||(s=O),t[o.prop]=[s,n,o.fallback]}return t}function be(e){const t={};for(const n in e){const o=e[n];o&&o.effect&&(t[n]=o.effect)}return Object.keys(t).length?t:null}function pe(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=z,window.lnCore.attrSpec=Q,window.lnCore.attrStr=O,window.lnCore.attrInt=H,window.lnCore.attrBool=U,window.lnCore.attrList=W,window.lnCore.attrEnum=J,window.lnCore.attrFloat=V,window.lnCore.attrJson=K);function I(e,t,n,o){if(e.nodeType!==1)return;const c=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",i=Array.from(e.querySelectorAll(c));e.matches&&e.matches(c)&&i.push(e);for(const a of i)if(!a[n]){window.lnCore._persistSink&&a.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(a,t);try{a[n]=new o(a)}catch(r){console.error("["+n+"] init failed",a,r)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function me(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ge(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 X(){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 Ce(e){const t=X(),n=e.observed||[];for(let o=0;o<n.length;o++){const s=n[o];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 o in e.attributes){t.byDeclaredAttr.has(o)||t.byDeclaredAttr.set(o,[]);const s=t.byDeclaredAttr.get(o);s.some(c=>c.componentTag===e.componentTag)||s.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=pe(e);if(o===null)t.reactiveWildcard.push(e);else for(const s of o)t.byReactive.has(s)||t.byReactive.set(s,[]),t.byReactive.get(s).push(e)}e.persist&&t.persist.push(e)}function Y(e,t,n,o){for(let s=0;s<e.length;s++){const c=e[s];if(!t[c.attribute])continue;const i=c.effects&&c.effects[n];i?i(t,n,o):c.onAttrChange&&(!c.declared||c.declared.has(n))&&c.onAttrChange(t,n,o)}}function ye(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const o=X(),s=o.byAttr.get(n);if(B()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(n)&&D(t)){const c=o.byDeclaredAttr.get(n),i=t.getAttribute(n);for(let a=0;a<c.length;a++)G(c[a].spec,i,n,c[a].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||s)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const c=o.byReactive.get(n);c&&Y(c,t,n,e.oldValue),o.reactiveWildcard.length&&Y(o.reactiveWildcard,t,n,e.oldValue)}if(s)for(let c=0;c<s.length;c++){const i=s[c];if(i.handler){i.handler(t,n,e.oldValue);continue}i.onAttributeChange&&t[i.attribute]?i.onAttributeChange(t,n):(I(t,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(t))}}function ve(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,T(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{ye(t[n])}catch(o){console.error("[ln-core] mutation handler failed",t[n].target,o)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function Z(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function _e(e){const t=Z();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const o=t[n];if(o.onSubtreeChange){const s=o.query,c=e.target.nodeType===1?e.target.matches(s)?e.target:e.target.closest(s):e.target.parentElement?e.target.parentElement.closest(s):null;c&&o.onSubtreeChange(c,e)}}for(let n=0;n<e.addedNodes.length;n++){const o=e.addedNodes[n];if(o.nodeType===1)for(let s=0;s<t.length;s++){const c=t[s];I(o,c.selector,c.attribute,c.ComponentFn),c.onInit&&c.onInit(o)}}for(let n=0;n<e.removedNodes.length;n++){const o=e.removedNodes[n];if(o.nodeType===1)for(let s=0;s<t.length;s++){const c=t[s],i=c.query,a=Array.from(o.querySelectorAll(i));o.matches&&o.matches(i)&&a.push(o);for(let r=0;r<a.length;r++){const h=a[r];if(!document.contains(h)){const m=h[c.attribute];if(m&&typeof m.destroy=="function")try{m.destroy()}catch(g){console.error("["+c.attribute+"] destroy failed",h,g)}delete h[c.attribute]}}}}}}function Ae(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,T(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{_e(o)}catch(s){console.error("[ln-core] lifecycle handler failed",o.target,s)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ee(e,t,n,o,s={}){const c=s.extraAttributes||[],i=s.onAttributeChange||null,a=s.onSubtreeChange||null,r=s.onInit||null,h=s.onAttrChange||null,m=s.effects||null,g=s.attributes||null,y=g?be(g):m,$=g?new Set(Object.keys(g)):null,l=s.persist||null;function u(b){const w=b||document.body;if(I(w,e,t,n),g&&B())for(const v in g){const N=g[v],A=Array.from(w.querySelectorAll("["+v+"]"));w.matches&&w.matches("["+v+"]")&&A.push(w);for(let S=0;S<A.length;S++){const k=A[S];D(k)&&G(N,k.getAttribute(v),v,o,k)}}r&&r(w)}const d=[];if(e.indexOf("[")!==-1){const b=/\[([\w-]+)/g;let w;for(;(w=b.exec(e))!==null;)d.push(w[1])}else d.push(e);Ce({selector:e,attribute:t,componentTag:o,attributes:g,ComponentFn:n,onInit:r,observed:d.concat(c),onAttributeChange:i,onAttrChange:h,effects:y,declared:$,persist:l}),ve();const f=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,p=s.subtreeQuery||(f?e:"["+e+"]");Z().push({selector:e,attribute:t,ComponentFn:n,onInit:r,onSubtreeChange:a,query:p}),Ae(),window[t]=u,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ee);function C(){me()>0?ge(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",C):C(),u}function te(e){return(e||"").replace(/^#/,"")}function q(e){const t=e===void 0?location.hash:e,n={},o=te(t);if(!o)return n;const s=o.split("&");for(let c=0;c<s.length;c++){const i=s[c];if(!i)continue;const a=i.indexOf(":"),r=a>-1?i.slice(0,a):i,h=a>-1?i.slice(a+1):"";if(r)try{n[r]=decodeURIComponent(h)}catch{n[r]=h}}return n}function ke(e){if(!e)return null;const t=q();return e in t?t[e]:null}function xe(e,t){if(!e)return;const n=q();t==null?delete n[e]:n[e]=String(t);const s=Object.keys(n).map(function(c){const i=n[c];return i===""?c:c+":"+encodeURIComponent(i)}).join("&");te(location.hash)!==s&&(location.hash=s)}function Se(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Oe(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const o=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return o?t?o+"-"+t:o:t||null}function Ee(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Te(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 De(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Le(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),o=e.slice(t+1),s=o?o.split(",").map(function(c){try{return decodeURIComponent(c)}catch{return c}}).filter(Boolean):[];return{key:n,values:s}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=q,window.lnCore.hashGet=ke,window.lnCore.hashSet=xe,window.lnCore.hashLinkClick=Se,window.lnCore.resolveHashNamespace=Oe,window.lnCore.hashSortEncode=Ee,window.lnCore.hashSortDecode=Te,window.lnCore.hashFilterEncode=De,window.lnCore.hashFilterDecode=Le);function je(){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=je),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",n="lnConnector";if(window[t]!==void 0)return;function o(l){const u=l[t];u&&u.refreshConfig()}const s={"data-ln-couchdb-connector":{type:"marker",description:"Mounts CouchDB/PouchDB connector bridging database and ln-ashlar data coordinators"},"data-ln-couchdb-url":{prop:"url",read:O,type:"string",fallback:"",effect:o,description:"CouchDB server base endpoint URL"},"data-ln-couchdb-db":{prop:"db",read:O,type:"string",fallback:"",effect:o,description:"Target CouchDB database name"},"data-ln-couchdb-auth":{prop:"auth",read:O,type:"string",fallback:"",effect:o,description:"Authentication credentials for CouchDB requests"},"data-ln-couchdb-headers":{effect:o,type:"json",fallback:null,description:"Custom HTTP headers in JSON or semicolon-separated format"}},c=Q(s);function i(l){const u=l&&l.content!==void 0?l.content:l,d=l&&l.message?l.message:null;return{content:u,message:d}}function a(l){return this.dom=l,z(this,l,c),l[t]=this,l[n]=this,this.namespace="ln-couchdb-connector",this.refreshConfig(),this._deltaController=null,this._handlers=null,$(this),this}a.prototype.refreshConfig=function(){const l=this.dom;this.credentials="same-origin";const u=l.getAttribute("data-ln-couchdb-headers")||"";this.headers=le(u,"ln-couchdb-connector"),this.auth&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-auth attribute. Storing basic authentication credentials in HTML DOM attributes is highly discouraged and vulnerable to XSS credential extraction. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),u.toLowerCase().includes("authorization")&&console.warn("[ln-couchdb-connector] Security Warning: Sensitive authorization credentials detected in data-ln-couchdb-headers attribute. Please use HttpOnly session cookies or a Backend Proxy Gateway instead."),_(l,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function r(l,u,d){const f=Object.assign({},E(l.headers,l.auth),d||{});return u&&(f["Idempotency-Key"]=u),f}a.prototype.fetchDelta=function(l){const u=this;this._deltaController&&this._deltaController.abort(),this._deltaController=new AbortController;const d=this._deltaController.signal,f=["include_docs=true","feed=normal"];l&&f.push("since="+encodeURIComponent(l));const p=x(u.url,u.db,"_changes")+"?"+f.join("&");return window.fetch(p,{method:"GET",headers:E(u.headers,u.auth),credentials:u.credentials,signal:d}).then(C=>{if(!C.ok)throw new Error("HTTP "+C.status+": "+C.statusText);return C.json()}).then(C=>{const b=C.results||[];return{data:b.filter(w=>!w.deleted&&w.doc).map(w=>Object.assign({},w.doc,{id:w.doc._id})),deleted:b.filter(w=>w.deleted).map(w=>w.id),synced_at:C.last_seq||l||""}}).finally(()=>{u._deltaController&&u._deltaController.signal===d&&(u._deltaController=null)})};function h(l,u,d){const f=Object.assign({_id:u.id},u);return f._id||delete f._id,window.fetch(x(l.url,l.db),{method:"POST",headers:r(l,d),credentials:l.credentials,body:JSON.stringify(f)}).then(p=>{if(!p.ok)throw new Error("HTTP "+p.status+": "+p.statusText);return p.json()}).then(p=>{const C=i(p),b=C.content;return{record:Object.assign({},f,{id:b.id,_id:b.id,_rev:b.rev}),message:C.message}})}a.prototype.create=function(l,u){return h(this,l,u).then(d=>d.record)};function m(l,u,d,f){const p=Object.assign({id:String(u),_id:String(u)},d),C=p._rev||p.rev;return(C?Promise.resolve(C):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:E(l.headers,l.auth),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("Could not retrieve document for revision mapping");return w.json().then(v=>v._rev)})).then(w=>{const v=Object.assign({},p,{_rev:w});delete v.rev;const N=r(l,f,{"If-Match":w});return window.fetch(x(l.url,l.db,null,u),{method:"PUT",headers:N,credentials:l.credentials,body:JSON.stringify(v)}).then(A=>{if(A.ok)return A.json().then(S=>{const k=i(S);return{record:Object.assign({},v,{_rev:k.content.rev}),message:k.message}});if(A.status===409)return A.json().then(S=>{const k=new Error("Conflict");throw k.status=409,k.data=S,k});throw new Error("HTTP "+A.status+": "+A.statusText)})})}a.prototype.update=function(l,u,d){return m(this,l,u,d).then(f=>f.record)};function g(l,u,d,f){return(d?Promise.resolve(d):window.fetch(x(l.url,l.db,null,u),{method:"GET",headers:E(l.headers,l.auth),credentials:l.credentials}).then(C=>{if(!C.ok)throw new Error("Could not retrieve document for revision delete");return C.json().then(b=>b._rev)})).then(C=>{const b=x(l.url,l.db,null,u)+"?rev="+encodeURIComponent(C);return window.fetch(b,{method:"DELETE",headers:r(l,f),credentials:l.credentials}).then(w=>{if(!w.ok)throw new Error("HTTP "+w.status+": "+w.statusText);return w.json()}).then(w=>{const v=i(w);return{response:v.content,message:v.message}})})}a.prototype.delete=function(l,u,d){return g(this,l,u,d).then(f=>f.response)};function y(l,u,d){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(x(l.url,l.db,"_all_docs"),{method:"POST",headers:E(l.headers,l.auth),credentials:l.credentials,body:JSON.stringify({keys:u})}).then(f=>{if(!f.ok)throw new Error("HTTP "+f.status+": "+f.statusText);return f.json()}).then(f=>{const C=(f.rows||[]).filter(b=>!b.error&&b.value&&b.value.rev).map(b=>({_id:b.id,_rev:b.value.rev,_deleted:!0}));return C.length===0?{response:{ok:!0,deletedCount:0},message:null}:window.fetch(x(l.url,l.db,"_bulk_docs"),{method:"POST",headers:r(l,d),credentials:l.credentials,body:JSON.stringify({docs:C})}).then(b=>{if(!b.ok)throw new Error("HTTP "+b.status+": "+b.statusText);return b.json()}).then(b=>{const w=i(b);return{response:{ok:!0,results:w.content,deletedCount:C.length},message:w.message}})})}a.prototype.bulkDelete=function(l,u){return y(this,l,u).then(d=>d.response)};function $(l){l._handlers={sync:function(u){const d=u.detail||{};l.fetchDelta(d.since).then(function(f){_(l.dom,"ln-couchdb-connector:fetched",{data:f,since:d.since,meta:d.meta||null})}).catch(function(f){f&&f.name==="AbortError"||_(l.dom,"ln-couchdb-connector:error",{action:"sync",error:f.message,status:f.status||0,since:d.since,meta:d.meta||null})})},create:function(u){const d=u.detail||{};h(l,d.data,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:created",{record:f.record,tempId:d.tempId,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"create",error:f.message,status:f.status||0,tempId:d.tempId,meta:d.meta||null})})},update:function(u){const d=u.detail||{},f=Object.assign({},d.data);d.expected_version!==void 0&&(f._rev=d.expected_version),m(l,d.id,f,d.idempotencyKey).then(function(p){_(l.dom,"ln-couchdb-connector:updated",{record:p.record,id:d.id,message:p.message,meta:d.meta||null})}).catch(function(p){_(l.dom,"ln-couchdb-connector:error",{action:"update",error:p.message,status:p.status||0,id:d.id,data:p.status===409?p.data:null,conflictData:p.status===409?p.data:null,meta:d.meta||null})})},delete:function(u){const d=u.detail||{};g(l,d.id,d.rev,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:deleted",{response:f.response,id:d.id,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"delete",error:f.message,status:f.status||0,id:d.id,meta:d.meta||null})})},bulkDelete:function(u){const d=u.detail||{};y(l,d.ids,d.idempotencyKey).then(function(f){_(l.dom,"ln-couchdb-connector:bulk-deleted",{response:f.response,ids:d.ids,message:f.message,meta:d.meta||null})}).catch(function(f){_(l.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:f.message,status:f.status||0,ids:d.ids,meta:d.meta||null})})}},l.dom.addEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.addEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.addEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.addEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete)}a.prototype.destroy=function(){if(!this.dom[t])return;const l=this;l._deltaController&&(l._deltaController.abort(),l._deltaController=null),l._handlers&&(l.dom.removeEventListener("ln-couchdb-connector:request-sync",l._handlers.sync),l.dom.removeEventListener("ln-couchdb-connector:request-create",l._handlers.create),l.dom.removeEventListener("ln-couchdb-connector:request-update",l._handlers.update),l.dom.removeEventListener("ln-couchdb-connector:request-delete",l._handlers.delete),l.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",l._handlers.bulkDelete),l._handlers=null),delete this.dom[t],delete this.dom[n]},ee(e,t,a,"ln-couchdb-connector",{attributes:s})})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function N(){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 R(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let i=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){i=t[l];break}if(!R(i))return}e.apply(console,t)}}function g(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function O(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){O(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function U(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function G(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,l={},u=e.elements,s={};if(r)for(let h=0;h<u.length;h++){const c=u[h];c.name&&c.type==="checkbox"&&!c.disabled&&(s[c.name]=(s[c.name]||0)+1)}for(let h=0;h<u.length;h++){const c=u[h];if(!(!c.name||c.disabled||c.type==="file"||c.type==="submit"||c.type==="button")&&!(i&&c.matches&&c.matches(i)))if(c.type==="checkbox")r&&s[c.name]===1?l[c.name]=c.checked:(l[c.name]||(l[c.name]=[]),c.checked&&l[c.name].push(c.value));else if(c.type==="radio")c.checked&&(l[c.name]=c.value);else if(c.type==="select-multiple"){l[c.name]=[];for(let b=0;b<c.options.length;b++)c.options[b].selected&&l[c.name].push(c.options[b].value)}else if(r&&c.type==="hidden")l[c.name]=c.value;else if(r&&(c.type==="number"||c.type==="range")){const b=Number(c.value);l[c.name]=c.value===""||isNaN(b)?null:b}else l[c.name]=c.value}return l}function de(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function ue(e,t){const r=e.elements,i=[],l={};for(let u=0;u<r.length;u++){const s=r[u];s.name&&s.type==="checkbox"&&(l[s.name]=(l[s.name]||0)+1)}for(let u=0;u<r.length;u++){const s=r[u];if(s.type==="file"||s.type==="submit"||s.type==="button")continue;const h=s.getAttribute("data-ln-fill-as")||s.name;if(!h||!(h in t))continue;const c=t[h];if(s.type==="checkbox"){if(Array.isArray(c))s.checked=c.indexOf(s.value)!==-1;else if(l[s.name]>1){const b=String(c).split(",").map(function(E){return E.trim()});s.checked=b.indexOf(s.value)!==-1}else s.checked=de(c);i.push(s)}else if(s.type==="radio")s.checked=s.value===String(c),i.push(s);else if(s.type==="select-multiple"){if(Array.isArray(c))for(let b=0;b<s.options.length;b++)s.options[b].selected=c.indexOf(s.options[b].value)!==-1;i.push(s)}else s.value=c,s.tagName==="SELECT"&&c!=null&&s.setAttribute("data-ln-value",c),i.push(s)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ue,window.lnCore.serializeForm=G,window.lnCore.resolveFormMethod=U);const K={};function fe(e,t){K[e]=t}function pe(e){return K[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=fe,window.lnCore.getDataMapper=pe);function he(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,O(function(){new MutationObserver(function(){g(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const P={};function we(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];P[r]=t}function me(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return P[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=we,window.lnCore.getLocaleFallback=me,window.lnCore.ensureLocaleObserver=he);const T={};function be(e,t){T[e]||(T[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=T[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function Q(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let s=0;s<r.length;s++){const h=r[s],c=h.getAttribute("data-ln-field");t[c]!=null&&(h.textContent=t[c])}const i=e.querySelectorAll("[data-ln-attr]");for(let s=0;s<i.length;s++){const h=i[s],c=h.getAttribute("data-ln-attr").split(",");for(let b=0;b<c.length;b++){const E=c[b].trim().split(":");if(E.length!==2)continue;const _=E[0].trim(),C=E[1].trim();t[C]!=null&&h.setAttribute(_,t[C])}}const l=e.querySelectorAll("[data-ln-show]");for(let s=0;s<l.length;s++){const h=l[s],c=h.getAttribute("data-ln-show");c in t&&h.classList.toggle("hidden",!t[c])}const u=e.querySelectorAll("[data-ln-class]");for(let s=0;s<u.length;s++){const h=u[s],c=h.getAttribute("data-ln-class").split(",");for(let b=0;b<c.length;b++){const E=c[b].trim().split(":");if(E.length!==2)continue;const _=E[0].trim(),C=E[1].trim();C in t&&h.classList.toggle(_,!!t[C])}}return e}function ye(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)Q(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 V(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(s,h){return t[h]!==void 0?t[h]:""}))}const i=function(u,s){return t[s]!==void 0?t[s]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let u=0;u<l.length;u++){const s=l[u],h=s.attributes;for(let c=0;c<h.length;c++){const b=h[c];b.value.indexOf("{{")!==-1&&s.setAttribute(b.name,b.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function ge(e,t,r,i,l,u){const s={};for(let c=0;c<e.children.length;c++){const b=e.children[c],E=b.getAttribute("data-ln-render-key");E&&(s[E]=b)}const h=document.createDocumentFragment();for(let c=0;c<t.length;c++){const b=t[c],E=String(i(b));let _=s[E];if(_)l(_,b,c);else{const C=be(r,u);if(!C||(V(C,b),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",E),l(_,b,c)}h.appendChild(_)}e.textContent="",e.appendChild(h)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=V,window.lnCore.fill=Q,window.lnCore.lnFill=ye,window.lnCore.renderList=ge);function L(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function z(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function H(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const l=i.trim().toLowerCase();return!(l==="false"||l==="0")}function J(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const F=new Map;function X(e,t){const r=(e?e.join("|"):"")+"::"+t;if(F.has(r))return F.get(r);const i=new Set(e||[]),l=function(u,s){const h=u.getAttribute(s);return h!==null&&i.has(h)?h:t};return F.set(r,l),l}function Y(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function Z(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function ee(e,t,r,i,l){if(!e||t===null)return!0;const u=i||"ln-component",s=e.type;if(s==="trigger"||s==="marker"||s==="string"||s==="list"||!s||t===""&&e.fallback!==void 0)return!0;const h=c=>{l?console.warn(c,l):console.warn(c)};if(s==="boolean"){const c=t.trim().toLowerCase();return c!==""&&c!=="true"&&c!=="false"&&c!=="1"&&c!=="0"?(h(`[${u}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(s==="enum"){const c=e.values||[];return c.includes(t)?!0:(h(`[${u}] Invalid value "${t}" for attribute "${r}". Allowed: ${c.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(s==="integer"){if(!/^-?\d+$/.test(t))return h(`[${u}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const c=parseInt(t,10);return e.min!==void 0&&c<e.min?(h(`[${u}] Value ${c} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&c>e.max?(h(`[${u}] Value ${c} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(s==="float")return isNaN(Number(t))?(h(`[${u}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(s==="json")try{return JSON.parse(t),!0}catch(c){return h(`[${u}] Invalid JSON for attribute "${r}": ${c.message}. Fallback: ${e.fallback}.`),!1}return!0}function te(e,t,r){for(const i in r){const[l,u,s]=r[i];Object.defineProperty(e,i,{get:function(){return l(t,u,s)},enumerable:!0,configurable:!0})}return e}function ne(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let l=i.read;if(!l&&i.type)switch(i.type){case"enum":l=X(i.values,i.fallback);break;case"integer":l=z;break;case"float":l=Y;break;case"boolean":l=H;break;case"list":l=J;break;case"json":l=Z;break;case"string":default:l=L;break}l||(l=L),t[i.prop]=[l,r,i.fallback]}return t}function Ce(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function _e(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=te,window.lnCore.attrSpec=ne,window.lnCore.attrStr=L,window.lnCore.attrInt=z,window.lnCore.attrBool=H,window.lnCore.attrList=J,window.lnCore.attrEnum=X,window.lnCore.attrFloat=Y,window.lnCore.attrJson=Z);function j(e,t,r,i){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",s=Array.from(e.querySelectorAll(u));e.matches&&e.matches(u)&&s.push(e);for(const h of s)if(!h[r]){window.lnCore._persistSink&&h.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(h,t);try{h[r]=new i(h)}catch(c){console.error("["+r+"] init failed",h,c)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Ae(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ve(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 re(){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 Ee(e){const t=re(),r=e.observed||[];for(let i=0;i<r.length;i++){const l=r[i];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const l=t.byDeclaredAttr.get(i);l.some(u=>u.componentTag===e.componentTag)||l.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=_e(e);if(i===null)t.reactiveWildcard.push(e);else for(const l of i)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function oe(e,t,r,i){for(let l=0;l<e.length;l++){const u=e[l];if(!t[u.attribute])continue;const s=u.effects&&u.effects[r];s?s(t,r,i):u.onAttrChange&&(!u.declared||u.declared.has(r))&&u.onAttrChange(t,r,i)}}function qe(e){const t=e.target,r=e.attributeName;if(e.oldValue===t.getAttribute(r))return;const i=re(),l=i.byAttr.get(r);if(N()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(r)&&R(t)){const u=i.byDeclaredAttr.get(r),s=t.getAttribute(r);for(let h=0;h<u.length;h++)ee(u[h].spec,s,r,u[h].componentTag,t)}if(window.lnCore._debugSink&&(r.indexOf("data-ln-")===0||l)&&window.lnCore._debugSink("attr",r,t,{oldValue:e.oldValue,newValue:t.getAttribute(r)}),r.indexOf("data-ln-")===0){const u=i.byReactive.get(r);u&&oe(u,t,r,e.oldValue),i.reactiveWildcard.length&&oe(i.reactiveWildcard,t,r,e.oldValue)}if(l)for(let u=0;u<l.length;u++){const s=l[u];if(s.handler){s.handler(t,r,e.oldValue);continue}s.onAttributeChange&&t[s.attribute]?s.onAttributeChange(t,r):(j(t,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(t))}}function Se(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,O(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{qe(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function ie(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function xe(e){const t=ie();if(t.length){if(e.target)for(let r=0;r<t.length;r++){const i=t[r];if(i.onSubtreeChange){const l=i.query,u=e.target.nodeType===1?e.target.matches(l)?e.target:e.target.closest(l):e.target.parentElement?e.target.parentElement.closest(l):null;u&&i.onSubtreeChange(u,e)}}for(let r=0;r<e.addedNodes.length;r++){const i=e.addedNodes[r];if(i.nodeType===1)for(let l=0;l<t.length;l++){const u=t[l];j(i,u.selector,u.attribute,u.ComponentFn),u.onInit&&u.onInit(i)}}for(let r=0;r<e.removedNodes.length;r++){const i=e.removedNodes[r];if(i.nodeType===1)for(let l=0;l<t.length;l++){const u=t[l],s=u.query,h=Array.from(i.querySelectorAll(s));i.matches&&i.matches(s)&&h.push(i);for(let c=0;c<h.length;c++){const b=h[c];if(!document.contains(b)){const E=b[u.attribute];if(E&&typeof E.destroy=="function")try{E.destroy()}catch(_){console.error("["+u.attribute+"] destroy failed",b,_)}delete b[u.attribute]}}}}}}function ke(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,O(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{xe(i)}catch(l){console.error("[ln-core] lifecycle handler failed",i.target,l)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ae(e,t,r,i,l={}){const u=l.extraAttributes||[],s=l.onAttributeChange||null,h=l.onSubtreeChange||null,c=l.onInit||null,b=l.onAttrChange||null,E=l.effects||null,_=l.attributes||null,C=_?Ce(_):E,M=_?new Set(Object.keys(_)):null,B=l.persist||null;function n(y){const A=y||document.body;if(j(A,e,t,r),_&&N())for(const q in _){const d=_[q],p=Array.from(A.querySelectorAll("["+q+"]"));A.matches&&A.matches("["+q+"]")&&p.push(A);for(let m=0;m<p.length;m++){const v=p[m];R(v)&&ee(d,v.getAttribute(q),q,i,v)}}c&&c(A)}const o=[];if(e.indexOf("[")!==-1){const y=/\[([\w-]+)/g;let A;for(;(A=y.exec(e))!==null;)o.push(A[1])}else o.push(e);Ee({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:r,onInit:c,observed:o.concat(u),onAttributeChange:s,onAttrChange:b,effects:C,declared:M,persist:B}),Se();const f=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";ie().push({selector:e,attribute:t,ComponentFn:r,onInit:c,onSubtreeChange:h,query:f}),ke(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ae);function w(){Ae()>0?ve(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",w):w(),n}function Ie(e,t){let r=!1;return function(){r||(r=!0,queueMicrotask(function(){r=!1,e()}))}}function le(e){return(e||"").replace(/^#/,"")}function $(e){const t=e===void 0?location.hash:e,r={},i=le(t);if(!i)return r;const l=i.split("&");for(let u=0;u<l.length;u++){const s=l[u];if(!s)continue;const h=s.indexOf(":"),c=h>-1?s.slice(0,h):s,b=h>-1?s.slice(h+1):"";if(c)try{r[c]=decodeURIComponent(b)}catch{r[c]=b}}return r}function Oe(e){if(!e)return null;const t=$();return e in t?t[e]:null}function De(e,t){if(!e)return;const r=$();t==null?delete r[e]:r[e]=String(t);const l=Object.keys(r).map(function(u){const s=r[u];return s===""?u:u+":"+encodeURIComponent(s)}).join("&");le(location.hash)!==l&&(location.hash=l)}function Re(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Te(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function Le(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Fe(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 je(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function $e(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),l=i?i.split(",").map(function(u){try{return decodeURIComponent(u)}catch{return u}}).filter(Boolean):[];return{key:r,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=$,window.lnCore.hashGet=Oe,window.lnCore.hashSet=De,window.lnCore.hashLinkClick=Re,window.lnCore.resolveHashNamespace=Te,window.lnCore.hashSortEncode=Le,window.lnCore.hashSortDecode=Fe,window.lnCore.hashFilterEncode=je,window.lnCore.hashFilterDecode=$e);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 Me(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Be(e,t){const r=!e||!!e.initializationError,i=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||i)?"remote":e&&!e.initializationError?"store":"none"}function se(e,t){const r=Object.assign({},e);return t&&(r.filters=t.filters,r.search=t.search,r.sort=t.sort),r}class We{constructor(){this._pending=new Map}wait(t){return new Promise((r,i)=>{this._pending.set(t,{resolve:r,reject:i})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const r=t||new Error("Mutation receipt registry closed");for(const i of this._pending.values())i.reject(r);this._pending.clear()}_settle(t,r){const i=t&&t.requestId;if(!i)return!1;const l=this._pending.get(i);return l?(this._pending.delete(i),r?l.reject(t.error||new Error("Store mutation failed")):l.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",r="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const i="data-ln-data-coordinator-search",l="data-ln-data-coordinator-filters",u="data-ln-data-coordinator-sort-field",s="data-ln-data-coordinator-sort-direction",c=ne({"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"}}),b=[["[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 E(n){const o=n.getAttribute("data-ln-data-coordinator-connector");if(o)return n.querySelector(o)||document.querySelector(o)||document.getElementById(o);const a=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(a)return a;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 a;if(!n)return"ln-connector";if((a=n.lnConnector)!=null&&a.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,te(this,n,c),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 We,this._queueQueryRefresh=Ie(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),M(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 a,f;const o=this.dom.getAttribute("data-ln-data-coordinator-stale")||((a=n.storeEl)==null?void 0:a.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 a=n.findChildren();a.store&&a.connector&&!n._noAutosync(a)&&!a.store.isSyncing&&(!a.store.hasCache||n._isStale(a))&&a.store.forceSync()}).catch(a=>n._reportError("store-initialize",a,null))},C.prototype.refreshMapper=function(){var a,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,o=n&&((f=(a=window.lnCore)==null?void 0:a.getDataMapper)==null?void 0:f.call(a,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=E(this.dom),a=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:o,queueEl:a,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:(a==null?void 0:a.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,o,a,f){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",a):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+o,f)},C.prototype._fanOutCreate=function(n,o,a){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:a}},{data:w,url:a,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},C.prototype._fanOutUpdate=function(n,o,a,f,w){const y=this.mapper.egress(a);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 a=o.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:o}),this._fanOutRemote(n,"bulk-delete",{chainKey:a,op:"bulk-delete",targetId:null,payload:{ids:o},expectedVersion:null,meta:{bulkKey:a,ids:o}},{ids:o,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:a}})},C.prototype._requestStoreMutation=function(n,o,a){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({},a,{requestId:f})),w},C.prototype._reportError=function(n,o,a){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:o,meta:a||null})},C.prototype._owns=function(n){var a;const o=this._name||((a=this.findChildren().storeEl)==null?void 0:a.id);return!!n&&n===o},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(u),o=this.dom.getAttribute(s),a=new URLSearchParams(this.dom.getAttribute(l)||""),f={};for(const w of new Set(a.keys()))f[w]=a.getAll(w);return{search:this.dom.getAttribute(i)||"",filters:f,sort:n&&o?{field:n,direction:o}:null}},C.prototype._refreshAll=function(n,o){for(const[a,f,w]of b)for(const y of this.dom.ownerDocument.querySelectorAll(a))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,a,f){const w=this.findChildren(),y=w.store;if(!y)return;a&&this._boundQueries.set(n,a);const A=this._boundQueries.get(n)||{sort:null,filters:{},search:""},q=se(A,this._currentQuery()),d=this;return Promise.resolve(y.ready).then(()=>{if(d._destroyed)return;const p=Be(y,w.connector);if(o==="table"||o==="list"||o==="chart")return p==="remote"?(g(n,"ln-"+o+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:q,meta:{targetEl:n,kind:o,offset:q.offset,limit:q.limit,queryGen:A.queryGen}})):p!=="store"?g(n,"ln-"+o+":set-loading",{loading:!1}):y.getAll(q).then(m=>{d._destroyed||!d._boundDelivered||(g(n,"ln-"+o+":set-loading",{loading:!1}),g(n,"ln-"+o+":set-data",{data:m.data,total:(f==null?void 0:f.total)??m.total,filtered:(f==null?void 0:f.filtered)??m.filtered,offset:m.offset??(f==null?void 0:f.offset)??A.offset,queryGen:A.queryGen!==void 0?A.queryGen:(f==null?void 0:f.queryGen)??m.queryGen,provisional:m.provisional===!0}),d._boundDelivered.set(n,!0))});if(o==="options"){if(p==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:o}});if(p==="store")return y.getAll({}).then(m=>!d._destroyed&&g(n,"ln-options:set-data",{data:m.data}))}if(o==="stat"){let m=a==null?void 0:a.filters;if(!m){const S=n.getAttribute("data-ln-stat-filter");if(S!=null&&S.includes(":")){const x=S.split(":");m={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const v=w.connector&&y&&(y.windowed&&m&&Object.keys(m).length||y.noLocalQuery)?"remote":p;if(v==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:m},meta:{targetEl:n,kind:o}});if(v==="store")return y.count(m).then(S=>!d._destroyed&&g(n,"ln-stat:set-count",{count:S}))}}).catch(p=>{d._destroyed||((o==="table"||o==="list"||o==="chart")&&g(n,"ln-"+o+":set-loading",{loading:!1}),d._reportError(o+"-query",p,{targetEl:n,kind:o}))})};function M(n){const o=n._unsubs=[],a=(d,p,m)=>{d.addEventListener(p,m),o.push(()=>d.removeEventListener(p,m))};a(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const p=n.findChildren();p.store&&p.connector&&g(p.connectorEl,_(p.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),a(n.dom,"ln-data-store:request-page",d=>{const p=n.findChildren(),m=d.detail||{};if(!p.connectorEl)return;const v=se(m.query||{},n._currentQuery());g(p.connectorEl,_(p.connectorEl)+":request-query",{query:Object.assign({},v,{offset:m.offset,limit:m.limit,queryGen:m.queryGen})})}),a(n.dom,"ln-data-coordinator:request-create",d=>n._fanOutCreate(n.findChildren(),d.detail.data||{},d.detail.action)),a(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)),a(n.dom,"ln-data-coordinator:request-delete",d=>n._fanOutDelete(n.findChildren(),d.detail.id)),a(n.dom,"ln-data-coordinator:request-bulk-delete",d=>n._fanOutBulkDelete(n.findChildren(),d.detail.ids||[])),a(n.dom,"ln-api-queue:send",d=>n._onQueueSend(d.detail||{})),a(n.dom,"ln-api-queue:failed",d=>{var p;return n._reportError("queue-failed",((p=d==null?void 0:d.detail)==null?void 0:p.error)||new Error("Queue failed"),(d==null?void 0:d.detail)||null)}),a(n.dom,"ln-data-store:initialized",d=>{var m;const p=n.findChildren();p.store&&!p.store.initializationError&&p.connector&&!n._noAutosync(p)&&!p.store.isSyncing&&(!((m=d.detail)!=null&&m.hasCache)||n._isStale(p))&&p.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()};a(n.dom,"ln-websocket-connector:connected",f),a(document,"submit",d=>n._onFormSubmit(d));const w=(d,p,m)=>{var v;n._owns(d.target.getAttribute(m))&&n._serveElement(d.target,p,p==="stat"?{filters:((v=d.detail)==null?void 0:v.filters)||null}:p==="options"?null:Me(d.detail||{}),null)};a(document,"ln-table:request-data",d=>w(d,"table","data-ln-table-source")),a(document,"ln-list:request-data",d=>w(d,"list","data-ln-list-source")),a(document,"ln-chart:request-data",d=>w(d,"chart","data-ln-chart-source")),a(document,"ln-options:request-data",d=>w(d,"options","data-ln-options")),a(document,"ln-stat:request-count",d=>w(d,"stat","data-ln-stat"));const y=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};a(n.dom,"ln-data-store:ready",y),a(n.dom,"ln-data-store:created",y),a(n.dom,"ln-data-store:updated",y),a(n.dom,"ln-data-store:deleted",y),a(n.dom,"ln-data-store:mutation-error",d=>n._mutationReceipts.reject(d.detail)),a(n.dom,"ln-data-store:synced",d=>{var p;(p=d.detail)!=null&&p.changed&&n._refreshAll(d.detail.meta,!1)}),a(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),a(n.dom,"ln-search:change",d=>{var m;d.preventDefault();const p=((m=d.detail)==null?void 0:m.term)!=null?d.detail.term:"";p!==(n.dom.getAttribute(i)||"")&&n.dom.setAttribute(i,p)}),a(n.dom,"ln-filter:change",d=>{var ce;d.preventDefault();const p=(ce=d.detail)==null?void 0:ce.key;if(!p)return;const m=(d.detail.values||[]).slice(),v=n._currentQuery().filters,S=v[p];if(S?S.length===m.length&&S.every((D,W)=>D===m[W]):!m.length)return;m.length?v[p]=m:delete v[p];const x=new URLSearchParams;Object.keys(v).forEach(D=>v[D].forEach(W=>x.append(D,W)));const I=x.toString();I?n.dom.setAttribute(l,I):n.dom.removeAttribute(l)}),a(n.dom,"ln-sort:change",d=>{var x,I;d.preventDefault();const p=(x=d.detail)==null?void 0:x.field,m=(I=d.detail)==null?void 0:I.direction,v=p&&m&&m!=="none"?{field:p,direction:m}: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(s,v.direction)):(n.dom.removeAttribute(u),n.dom.removeAttribute(s)))});const A=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),q=n.findChildren().connectorEl;if(q){const d=_(q);A.add(d),a(n.dom,d+":connected",f)}A.forEach(d=>{a(n.dom,d+":fetched",p=>n._reconcileServerFetch(p.detail)),a(n.dom,d+":created",p=>n._reconcileServerMutation("create",p.detail)),a(n.dom,d+":updated",p=>n._reconcileServerMutation("update",p.detail)),a(n.dom,d+":deleted",p=>n._reconcileServerMutation("ack",p.detail)),a(n.dom,d+":bulk-deleted",p=>n._reconcileServerMutation("ack",p.detail)),a(n.dom,d+":error",p=>n._reconcileServerMutation("error",p.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const o=this.findChildren();if(!o.store||!o.connector||!o.queue)return;const a=n.meta||{},f=_(o.connectorEl),w=n.idempotencyKey||n.entryId,y={create:()=>g(o.connectorEl,f+":request-create",{data:n.payload,url:a.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:a.tempId}}),update:()=>g(o.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:a.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 A;return g(o.connectorEl,f+":request-bulk-delete",{ids:((A=n.payload)==null?void 0:A.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:a.bulkKey}})}};y[n.op]&&y[n.op]()},C.prototype._onFormSubmit=function(n){const o=n.target;if(n.defaultPrevented)return;const a=o.hasAttribute(r)?o.getAttribute(r):null;if(a===null||(a?!this._owns(a):o.closest("["+e+"]")!==this.dom))return;const f=U(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=G(o);delete w._method,delete w._token;const y=w.id,A=w.expected_version,q=o.getAttribute("action")||"",d=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(d,w,q):this._fanOutUpdate(d,y,w,A,q)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const o=n.meta||{},a=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:[],A=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),q=w.map(d=>this.mapper.ingress(d));if(!(!a.store||a.store.initializationError)){if(!o.kind)return a.store.applySync(q,y,A,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:o.targetEl});a.store.applyQuery(q,{total:n.total}).then(d=>{const p=o.kind;p==="table"||p==="list"||p==="chart"?(g(o.targetEl,"ln-"+p+":set-loading",{loading:!1}),g(o.targetEl,"ln-"+p+":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)):p==="options"?a.store.getAll({}).then(m=>g(o.targetEl,"ln-options:set-data",{data:m.data})):p==="stat"&&g(o.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??q.length})})}},C.prototype._reconcileServerMutation=function(n,o){var w;if(!o)return;const a=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);(a.storeEl?this._requestStoreMutation(a,"update",{id:f.tempId,data:y}):Promise.resolve()).then(()=>{f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:y.id})}).catch(A=>this._reportError("create-reconcile",A,f))}else if(n==="update"){const y=o.record?this.mapper.ingress(o.record):null;(a.storeEl&&y?this._requestStoreMutation(a,"update",{id:f.id,data:y}):Promise.resolve()).then(()=>{f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(A=>this._reportError("update-reconcile",A,f))}else if(n==="ack")f.queued&&a.queue&&g(a.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&&a.queue&&g(a.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:y===401||y===419?"auth":y===0||y>=500?"retry":"drop"}),a.storeEl&&g(a.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 B(n,o){const a=n[t];a&&(o==="data-ln-data-coordinator-mapper"?a.refreshMapper():(o===i||o===l||o===u||o===s)&&a._queueQueryRefresh())}ae(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",i,l,u,s],onAttributeChange:B}),window[t].init=window[t]})()})();
|
|
1
|
+
(function(){"use strict";function N(){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 R(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let i=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){i=t[l];break}if(!R(i))return}e.apply(console,t)}}function g(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function O(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){O(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function U(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function G(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,l={},u=e.elements,s={};if(r)for(let h=0;h<u.length;h++){const c=u[h];c.name&&c.type==="checkbox"&&!c.disabled&&(s[c.name]=(s[c.name]||0)+1)}for(let h=0;h<u.length;h++){const c=u[h];if(!(!c.name||c.disabled||c.type==="file"||c.type==="submit"||c.type==="button")&&!(i&&c.matches&&c.matches(i)))if(c.type==="checkbox")r&&s[c.name]===1?l[c.name]=c.checked:(l[c.name]||(l[c.name]=[]),c.checked&&l[c.name].push(c.value));else if(c.type==="radio")c.checked&&(l[c.name]=c.value);else if(c.type==="select-multiple"){l[c.name]=[];for(let b=0;b<c.options.length;b++)c.options[b].selected&&l[c.name].push(c.options[b].value)}else if(r&&c.type==="hidden")l[c.name]=c.value;else if(r&&(c.type==="number"||c.type==="range")){const b=Number(c.value);l[c.name]=c.value===""||isNaN(b)?null:b}else l[c.name]=c.value}return l}function de(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function ue(e,t){const r=e.elements,i=[],l={};for(let u=0;u<r.length;u++){const s=r[u];s.name&&s.type==="checkbox"&&(l[s.name]=(l[s.name]||0)+1)}for(let u=0;u<r.length;u++){const s=r[u];if(s.type==="file"||s.type==="submit"||s.type==="button")continue;const h=s.getAttribute("data-ln-fill-as")||s.name;if(!h||!(h in t))continue;const c=t[h];if(s.type==="checkbox"){if(Array.isArray(c))s.checked=c.indexOf(s.value)!==-1;else if(l[s.name]>1){const b=String(c).split(",").map(function(E){return E.trim()});s.checked=b.indexOf(s.value)!==-1}else s.checked=de(c);i.push(s)}else if(s.type==="radio")s.checked=s.value===String(c),i.push(s);else if(s.type==="select-multiple"){if(Array.isArray(c))for(let b=0;b<s.options.length;b++)s.options[b].selected=c.indexOf(s.options[b].value)!==-1;i.push(s)}else s.value=c,s.tagName==="SELECT"&&c!=null&&s.setAttribute("data-ln-value",c),i.push(s)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ue,window.lnCore.serializeForm=G,window.lnCore.resolveFormMethod=U);const K={};function fe(e,t){K[e]=t}function pe(e){return K[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=fe,window.lnCore.getDataMapper=pe);function he(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,O(function(){new MutationObserver(function(){g(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const Q={};function we(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];Q[r]=t}function me(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return Q[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=we,window.lnCore.getLocaleFallback=me,window.lnCore.ensureLocaleObserver=he);const T={};function be(e,t){T[e]||(T[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=T[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function P(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let s=0;s<r.length;s++){const h=r[s],c=h.getAttribute("data-ln-field");t[c]!=null&&(h.textContent=t[c])}const i=e.querySelectorAll("[data-ln-attr]");for(let s=0;s<i.length;s++){const h=i[s],c=h.getAttribute("data-ln-attr").split(",");for(let b=0;b<c.length;b++){const E=c[b].trim().split(":");if(E.length!==2)continue;const _=E[0].trim(),C=E[1].trim();t[C]!=null&&h.setAttribute(_,t[C])}}const l=e.querySelectorAll("[data-ln-show]");for(let s=0;s<l.length;s++){const h=l[s],c=h.getAttribute("data-ln-show");c in t&&h.classList.toggle("hidden",!t[c])}const u=e.querySelectorAll("[data-ln-class]");for(let s=0;s<u.length;s++){const h=u[s],c=h.getAttribute("data-ln-class").split(",");for(let b=0;b<c.length;b++){const E=c[b].trim().split(":");if(E.length!==2)continue;const _=E[0].trim(),C=E[1].trim();C in t&&h.classList.toggle(_,!!t[C])}}return e}function ye(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)P(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 V(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(s,h){return t[h]!==void 0?t[h]:""}))}const i=function(u,s){return t[s]!==void 0?t[s]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let u=0;u<l.length;u++){const s=l[u],h=s.attributes;for(let c=0;c<h.length;c++){const b=h[c];b.value.indexOf("{{")!==-1&&s.setAttribute(b.name,b.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function ge(e,t,r,i,l,u){const s={};for(let c=0;c<e.children.length;c++){const b=e.children[c],E=b.getAttribute("data-ln-render-key");E&&(s[E]=b)}const h=document.createDocumentFragment();for(let c=0;c<t.length;c++){const b=t[c],E=String(i(b));let _=s[E];if(_)l(_,b,c);else{const C=be(r,u);if(!C||(V(C,b),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",E),l(_,b,c)}h.appendChild(_)}e.textContent="",e.appendChild(h)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=V,window.lnCore.fill=P,window.lnCore.lnFill=ye,window.lnCore.renderList=ge);function L(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function z(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function H(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const l=i.trim().toLowerCase();return!(l==="false"||l==="0")}function J(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const F=new Map;function X(e,t){const r=(e?e.join("|"):"")+"::"+t;if(F.has(r))return F.get(r);const i=new Set(e||[]),l=function(u,s){const h=u.getAttribute(s);return h!==null&&i.has(h)?h:t};return F.set(r,l),l}function Y(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function Z(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function ee(e,t,r,i,l){if(!e||t===null)return!0;const u=i||"ln-component",s=e.type;if(s==="trigger"||s==="marker"||s==="string"||s==="list"||!s||t===""&&e.fallback!==void 0)return!0;const h=c=>{l?console.warn(c,l):console.warn(c)};if(s==="boolean"){const c=t.trim().toLowerCase();return c!==""&&c!=="true"&&c!=="false"&&c!=="1"&&c!=="0"?(h(`[${u}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(s==="enum"){const c=e.values||[];return c.includes(t)?!0:(h(`[${u}] Invalid value "${t}" for attribute "${r}". Allowed: ${c.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(s==="integer"){if(!/^-?\d+$/.test(t))return h(`[${u}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const c=parseInt(t,10);return e.min!==void 0&&c<e.min?(h(`[${u}] Value ${c} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&c>e.max?(h(`[${u}] Value ${c} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(s==="float")return isNaN(Number(t))?(h(`[${u}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(s==="json")try{return JSON.parse(t),!0}catch(c){return h(`[${u}] Invalid JSON for attribute "${r}": ${c.message}. Fallback: ${e.fallback}.`),!1}return!0}function te(e,t,r){for(const i in r){const[l,u,s]=r[i];Object.defineProperty(e,i,{get:function(){return l(t,u,s)},enumerable:!0,configurable:!0})}return e}function ne(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let l=i.read;if(!l&&i.type)switch(i.type){case"enum":l=X(i.values,i.fallback);break;case"integer":l=z;break;case"float":l=Y;break;case"boolean":l=H;break;case"list":l=J;break;case"json":l=Z;break;case"string":default:l=L;break}l||(l=L),t[i.prop]=[l,r,i.fallback]}return t}function Ce(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function _e(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=te,window.lnCore.attrSpec=ne,window.lnCore.attrStr=L,window.lnCore.attrInt=z,window.lnCore.attrBool=H,window.lnCore.attrList=J,window.lnCore.attrEnum=X,window.lnCore.attrFloat=Y,window.lnCore.attrJson=Z);function j(e,t,r,i){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",s=Array.from(e.querySelectorAll(u));e.matches&&e.matches(u)&&s.push(e);for(const h of s)if(!h[r]){window.lnCore._persistSink&&h.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(h,t);try{h[r]=new i(h)}catch(c){console.error("["+r+"] init failed",h,c)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Ae(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ve(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 re(){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 Ee(e){const t=re(),r=e.observed||[];for(let i=0;i<r.length;i++){const l=r[i];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const l=t.byDeclaredAttr.get(i);l.some(u=>u.componentTag===e.componentTag)||l.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=_e(e);if(i===null)t.reactiveWildcard.push(e);else for(const l of i)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function oe(e,t,r,i){for(let l=0;l<e.length;l++){const u=e[l];if(!t[u.attribute])continue;const s=u.effects&&u.effects[r];s?s(t,r,i):u.onAttrChange&&(!u.declared||u.declared.has(r))&&u.onAttrChange(t,r,i)}}function qe(e){const t=e.target,r=e.attributeName;if(e.oldValue===t.getAttribute(r))return;const i=re(),l=i.byAttr.get(r);if(N()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(r)&&R(t)){const u=i.byDeclaredAttr.get(r),s=t.getAttribute(r);for(let h=0;h<u.length;h++)ee(u[h].spec,s,r,u[h].componentTag,t)}if(window.lnCore._debugSink&&(r.indexOf("data-ln-")===0||l)&&window.lnCore._debugSink("attr",r,t,{oldValue:e.oldValue,newValue:t.getAttribute(r)}),r.indexOf("data-ln-")===0){const u=i.byReactive.get(r);u&&oe(u,t,r,e.oldValue),i.reactiveWildcard.length&&oe(i.reactiveWildcard,t,r,e.oldValue)}if(l)for(let u=0;u<l.length;u++){const s=l[u];if(s.handler){s.handler(t,r,e.oldValue);continue}s.onAttributeChange&&t[s.attribute]?s.onAttributeChange(t,r):(j(t,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(t))}}function Se(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,O(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{qe(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function ie(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function xe(e){const t=ie();if(t.length){if(e.target)for(let r=0;r<t.length;r++){const i=t[r];if(i.onSubtreeChange){const l=i.query,u=e.target.nodeType===1?e.target.matches(l)?e.target:e.target.closest(l):e.target.parentElement?e.target.parentElement.closest(l):null;u&&i.onSubtreeChange(u,e)}}for(let r=0;r<e.addedNodes.length;r++){const i=e.addedNodes[r];if(i.nodeType===1)for(let l=0;l<t.length;l++){const u=t[l];j(i,u.selector,u.attribute,u.ComponentFn),u.onInit&&u.onInit(i)}}for(let r=0;r<e.removedNodes.length;r++){const i=e.removedNodes[r];if(i.nodeType===1)for(let l=0;l<t.length;l++){const u=t[l],s=u.query,h=Array.from(i.querySelectorAll(s));i.matches&&i.matches(s)&&h.push(i);for(let c=0;c<h.length;c++){const b=h[c];if(!document.contains(b)){const E=b[u.attribute];if(E&&typeof E.destroy=="function")try{E.destroy()}catch(_){console.error("["+u.attribute+"] destroy failed",b,_)}delete b[u.attribute]}}}}}}function ke(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,O(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{xe(i)}catch(l){console.error("[ln-core] lifecycle handler failed",i.target,l)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ae(e,t,r,i,l={}){const u=l.extraAttributes||[],s=l.onAttributeChange||null,h=l.onSubtreeChange||null,c=l.onInit||null,b=l.onAttrChange||null,E=l.effects||null,_=l.attributes||null,C=_?Ce(_):E,M=_?new Set(Object.keys(_)):null,B=l.persist||null;function n(y){const A=y||document.body;if(j(A,e,t,r),_&&N())for(const q in _){const d=_[q],p=Array.from(A.querySelectorAll("["+q+"]"));A.matches&&A.matches("["+q+"]")&&p.push(A);for(let m=0;m<p.length;m++){const v=p[m];R(v)&&ee(d,v.getAttribute(q),q,i,v)}}c&&c(A)}const o=[];if(e.indexOf("[")!==-1){const y=/\[([\w-]+)/g;let A;for(;(A=y.exec(e))!==null;)o.push(A[1])}else o.push(e);Ee({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:r,onInit:c,observed:o.concat(u),onAttributeChange:s,onAttrChange:b,effects:C,declared:M,persist:B}),Se();const a=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,f=l.subtreeQuery||(a?e:"["+e+"]");ie().push({selector:e,attribute:t,ComponentFn:r,onInit:c,onSubtreeChange:h,query:f}),ke(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ae);function w(){Ae()>0?ve(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",w):w(),n}function Ie(e,t){let r=!1;return function(){r||(r=!0,queueMicrotask(function(){r=!1,e()}))}}function le(e){return(e||"").replace(/^#/,"")}function $(e){const t=e===void 0?location.hash:e,r={},i=le(t);if(!i)return r;const l=i.split("&");for(let u=0;u<l.length;u++){const s=l[u];if(!s)continue;const h=s.indexOf(":"),c=h>-1?s.slice(0,h):s,b=h>-1?s.slice(h+1):"";if(c)try{r[c]=decodeURIComponent(b)}catch{r[c]=b}}return r}function Oe(e){if(!e)return null;const t=$();return e in t?t[e]:null}function De(e,t){if(!e)return;const r=$();t==null?delete r[e]:r[e]=String(t);const l=Object.keys(r).map(function(u){const s=r[u];return s===""?u:u+":"+encodeURIComponent(s)}).join("&");le(location.hash)!==l&&(location.hash=l)}function Re(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Te(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function Le(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Fe(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 je(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function $e(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),l=i?i.split(",").map(function(u){try{return decodeURIComponent(u)}catch{return u}}).filter(Boolean):[];return{key:r,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=$,window.lnCore.hashGet=Oe,window.lnCore.hashSet=De,window.lnCore.hashLinkClick=Re,window.lnCore.resolveHashNamespace=Te,window.lnCore.hashSortEncode=Le,window.lnCore.hashSortDecode=Fe,window.lnCore.hashFilterEncode=je,window.lnCore.hashFilterDecode=$e);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 Me(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Be(e,t){const r=!e||!!e.initializationError,i=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||i)?"remote":e&&!e.initializationError?"store":"none"}function se(e,t){const r=Object.assign({},e);return t&&(r.filters=t.filters,r.search=t.search,r.sort=t.sort),r}class We{constructor(){this._pending=new Map}wait(t){return new Promise((r,i)=>{this._pending.set(t,{resolve:r,reject:i})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const r=t||new Error("Mutation receipt registry closed");for(const i of this._pending.values())i.reject(r);this._pending.clear()}_settle(t,r){const i=t&&t.requestId;if(!i)return!1;const l=this._pending.get(i);return l?(this._pending.delete(i),r?l.reject(t.error||new Error("Store mutation failed")):l.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",r="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const i="data-ln-data-coordinator-search",l="data-ln-data-coordinator-filters",u="data-ln-data-coordinator-sort-field",s="data-ln-data-coordinator-sort-direction",c=ne({"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"}}),b=[["[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 E(n){const o=n.getAttribute("data-ln-data-coordinator-connector");if(o)return n.querySelector(o)||document.querySelector(o)||document.getElementById(o);const a=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(a)return a;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 a;if(!n)return"ln-connector";if((a=n.lnConnector)!=null&&a.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,te(this,n,c),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 We,this._queueQueryRefresh=Ie(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),M(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 a,f;const o=this.dom.getAttribute("data-ln-data-coordinator-stale")||((a=n.storeEl)==null?void 0:a.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 a=n.findChildren();a.store&&a.connector&&!n._noAutosync(a)&&!a.store.isSyncing&&(!a.store.hasCache||n._isStale(a))&&a.store.forceSync()}).catch(a=>n._reportError("store-initialize",a,null))},C.prototype.refreshMapper=function(){var a,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,o=n&&((f=(a=window.lnCore)==null?void 0:a.getDataMapper)==null?void 0:f.call(a,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=E(this.dom),a=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:o,queueEl:a,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:(a==null?void 0:a.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,o,a,f){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",a):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+o,f)},C.prototype._fanOutCreate=function(n,o,a){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:a}},{data:w,url:a,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},C.prototype._fanOutUpdate=function(n,o,a,f,w){const y=this.mapper.egress(a);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 a=o.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:o}),this._fanOutRemote(n,"bulk-delete",{chainKey:a,op:"bulk-delete",targetId:null,payload:{ids:o},expectedVersion:null,meta:{bulkKey:a,ids:o}},{ids:o,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:a}})},C.prototype._requestStoreMutation=function(n,o,a){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({},a,{requestId:f})),w},C.prototype._reportError=function(n,o,a){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:o,meta:a||null})},C.prototype._owns=function(n){var a;const o=this._name||((a=this.findChildren().storeEl)==null?void 0:a.id);return!!n&&n===o},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(u),o=this.dom.getAttribute(s),a=new URLSearchParams(this.dom.getAttribute(l)||""),f={};for(const w of new Set(a.keys()))f[w]=a.getAll(w);return{search:this.dom.getAttribute(i)||"",filters:f,sort:n&&o?{field:n,direction:o}:null}},C.prototype._refreshAll=function(n,o){for(const[a,f,w]of b)for(const y of this.dom.ownerDocument.querySelectorAll(a))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,a,f){const w=this.findChildren(),y=w.store;if(!y)return;a&&this._boundQueries.set(n,a);const A=this._boundQueries.get(n)||{sort:null,filters:{},search:""},q=se(A,this._currentQuery()),d=this;return Promise.resolve(y.ready).then(()=>{if(d._destroyed)return;const p=Be(y,w.connector);if(o==="table"||o==="list"||o==="chart")return p==="remote"?(g(n,"ln-"+o+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:q,meta:{targetEl:n,kind:o,offset:q.offset,limit:q.limit,queryGen:A.queryGen}})):p!=="store"?g(n,"ln-"+o+":set-loading",{loading:!1}):y.getAll(q).then(m=>{d._destroyed||!d._boundDelivered||(g(n,"ln-"+o+":set-loading",{loading:!1}),g(n,"ln-"+o+":set-data",{data:m.data,total:(f==null?void 0:f.total)??m.total,filtered:(f==null?void 0:f.filtered)??m.filtered,offset:m.offset??(f==null?void 0:f.offset)??A.offset,queryGen:A.queryGen!==void 0?A.queryGen:(f==null?void 0:f.queryGen)??m.queryGen,provisional:m.provisional===!0}),d._boundDelivered.set(n,!0))});if(o==="options"){if(p==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:o}});if(p==="store")return y.getAll({}).then(m=>!d._destroyed&&g(n,"ln-options:set-data",{data:m.data}))}if(o==="stat"){let m=a==null?void 0:a.filters;if(!m){const S=n.getAttribute("data-ln-stat-filter");if(S!=null&&S.includes(":")){const x=S.split(":");m={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const v=w.connector&&y&&(y.windowed&&m&&Object.keys(m).length||y.noLocalQuery)?"remote":p;if(v==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:m},meta:{targetEl:n,kind:o}});if(v==="store")return y.count(m).then(S=>!d._destroyed&&g(n,"ln-stat:set-count",{count:S}))}}).catch(p=>{d._destroyed||((o==="table"||o==="list"||o==="chart")&&g(n,"ln-"+o+":set-loading",{loading:!1}),d._reportError(o+"-query",p,{targetEl:n,kind:o}))})};function M(n){const o=n._unsubs=[],a=(d,p,m)=>{d.addEventListener(p,m),o.push(()=>d.removeEventListener(p,m))};a(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const p=n.findChildren();p.store&&p.connector&&g(p.connectorEl,_(p.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),a(n.dom,"ln-data-store:request-page",d=>{const p=n.findChildren(),m=d.detail||{};if(!p.connectorEl)return;const v=se(m.query||{},n._currentQuery());g(p.connectorEl,_(p.connectorEl)+":request-query",{query:Object.assign({},v,{offset:m.offset,limit:m.limit,queryGen:m.queryGen})})}),a(n.dom,"ln-data-coordinator:request-create",d=>n._fanOutCreate(n.findChildren(),d.detail.data||{},d.detail.action)),a(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)),a(n.dom,"ln-data-coordinator:request-delete",d=>n._fanOutDelete(n.findChildren(),d.detail.id)),a(n.dom,"ln-data-coordinator:request-bulk-delete",d=>n._fanOutBulkDelete(n.findChildren(),d.detail.ids||[])),a(n.dom,"ln-api-queue:send",d=>n._onQueueSend(d.detail||{})),a(n.dom,"ln-api-queue:failed",d=>{var p;return n._reportError("queue-failed",((p=d==null?void 0:d.detail)==null?void 0:p.error)||new Error("Queue failed"),(d==null?void 0:d.detail)||null)}),a(n.dom,"ln-data-store:initialized",d=>{var m;const p=n.findChildren();p.store&&!p.store.initializationError&&p.connector&&!n._noAutosync(p)&&!p.store.isSyncing&&(!((m=d.detail)!=null&&m.hasCache)||n._isStale(p))&&p.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()};a(n.dom,"ln-websocket-connector:connected",f),a(document,"submit",d=>n._onFormSubmit(d));const w=(d,p,m)=>{var v;n._owns(d.target.getAttribute(m))&&n._serveElement(d.target,p,p==="stat"?{filters:((v=d.detail)==null?void 0:v.filters)||null}:p==="options"?null:Me(d.detail||{}),null)};a(document,"ln-table:request-data",d=>w(d,"table","data-ln-table-source")),a(document,"ln-list:request-data",d=>w(d,"list","data-ln-list-source")),a(document,"ln-chart:request-data",d=>w(d,"chart","data-ln-chart-source")),a(document,"ln-options:request-data",d=>w(d,"options","data-ln-options")),a(document,"ln-stat:request-count",d=>w(d,"stat","data-ln-stat"));const y=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};a(n.dom,"ln-data-store:ready",y),a(n.dom,"ln-data-store:created",y),a(n.dom,"ln-data-store:updated",y),a(n.dom,"ln-data-store:deleted",y),a(n.dom,"ln-data-store:mutation-error",d=>n._mutationReceipts.reject(d.detail)),a(n.dom,"ln-data-store:synced",d=>{var p;(p=d.detail)!=null&&p.changed&&n._refreshAll(d.detail.meta,!1)}),a(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),a(n.dom,"ln-search:change",d=>{var m;d.preventDefault();const p=((m=d.detail)==null?void 0:m.term)!=null?d.detail.term:"";p!==(n.dom.getAttribute(i)||"")&&n.dom.setAttribute(i,p)}),a(n.dom,"ln-filter:change",d=>{var ce;d.preventDefault();const p=(ce=d.detail)==null?void 0:ce.key;if(!p)return;const m=(d.detail.values||[]).slice(),v=n._currentQuery().filters,S=v[p];if(S?S.length===m.length&&S.every((D,W)=>D===m[W]):!m.length)return;m.length?v[p]=m:delete v[p];const x=new URLSearchParams;Object.keys(v).forEach(D=>v[D].forEach(W=>x.append(D,W)));const I=x.toString();I?n.dom.setAttribute(l,I):n.dom.removeAttribute(l)}),a(n.dom,"ln-sort:change",d=>{var x,I;d.preventDefault();const p=(x=d.detail)==null?void 0:x.field,m=(I=d.detail)==null?void 0:I.direction,v=p&&m&&m!=="none"?{field:p,direction:m}: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(s,v.direction)):(n.dom.removeAttribute(u),n.dom.removeAttribute(s)))});const A=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),q=n.findChildren().connectorEl;if(q){const d=_(q);A.add(d),a(n.dom,d+":connected",f)}A.forEach(d=>{a(n.dom,d+":fetched",p=>n._reconcileServerFetch(p.detail)),a(n.dom,d+":created",p=>n._reconcileServerMutation("create",p.detail)),a(n.dom,d+":updated",p=>n._reconcileServerMutation("update",p.detail)),a(n.dom,d+":deleted",p=>n._reconcileServerMutation("ack",p.detail)),a(n.dom,d+":bulk-deleted",p=>n._reconcileServerMutation("ack",p.detail)),a(n.dom,d+":error",p=>n._reconcileServerMutation("error",p.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const o=this.findChildren();if(!o.store||!o.connector||!o.queue)return;const a=n.meta||{},f=_(o.connectorEl),w=n.idempotencyKey||n.entryId,y={create:()=>g(o.connectorEl,f+":request-create",{data:n.payload,url:a.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:a.tempId}}),update:()=>g(o.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:a.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 A;return g(o.connectorEl,f+":request-bulk-delete",{ids:((A=n.payload)==null?void 0:A.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:a.bulkKey}})}};y[n.op]&&y[n.op]()},C.prototype._onFormSubmit=function(n){const o=n.target;if(n.defaultPrevented)return;const a=o.hasAttribute(r)?o.getAttribute(r):null;if(a===null||(a?!this._owns(a):o.closest("["+e+"]")!==this.dom))return;const f=U(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=G(o);delete w._method,delete w._token;const y=w.id,A=w.expected_version,q=o.getAttribute("action")||"",d=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(d,w,q):this._fanOutUpdate(d,y,w,A,q)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const o=n.meta||{},a=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:[],A=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),q=w.map(d=>this.mapper.ingress(d));if(!(!a.store||a.store.initializationError)){if(!o.kind)return a.store.applySync(q,y,A,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:o.targetEl});a.store.applyQuery(q,{total:n.total}).then(d=>{const p=o.kind;p==="table"||p==="list"||p==="chart"?(g(o.targetEl,"ln-"+p+":set-loading",{loading:!1}),g(o.targetEl,"ln-"+p+":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)):p==="options"?a.store.getAll({}).then(m=>g(o.targetEl,"ln-options:set-data",{data:m.data})):p==="stat"&&g(o.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??q.length})})}},C.prototype._reconcileServerMutation=function(n,o){var w;if(!o)return;const a=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);(a.storeEl?this._requestStoreMutation(a,"update",{id:f.tempId,data:y}):Promise.resolve()).then(()=>{f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:y.id})}).catch(A=>this._reportError("create-reconcile",A,f))}else if(n==="update"){const y=o.record?this.mapper.ingress(o.record):null;(a.storeEl&&y?this._requestStoreMutation(a,"update",{id:f.id,data:y}):Promise.resolve()).then(()=>{f.queued&&a.queue&&g(a.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(A=>this._reportError("update-reconcile",A,f))}else if(n==="ack")f.queued&&a.queue&&g(a.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&&a.queue&&g(a.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:y===401||y===419?"auth":y===0||y>=500?"retry":"drop"}),a.storeEl&&g(a.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 B(n,o){const a=n[t];a&&(o==="data-ln-data-coordinator-mapper"?a.refreshMapper():(o===i||o===l||o===u||o===s)&&a._queueQueryRefresh())}ae(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",i,l,u,s],onAttributeChange:B}),window[t].init=window[t]})()})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";function fe(){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 re(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(!re(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 Q(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){Q(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function Pe(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Fe(e,t){const o=!!(t&&t.typed),i=t&&t.exclude,a={},s=e.elements,l={};if(o)for(let d=0;d<s.length;d++){const c=s[d];c.name&&c.type==="checkbox"&&!c.disabled&&(l[c.name]=(l[c.name]||0)+1)}for(let d=0;d<s.length;d++){const c=s[d];if(!(!c.name||c.disabled||c.type==="file"||c.type==="submit"||c.type==="button")&&!(i&&c.matches&&c.matches(i)))if(c.type==="checkbox")o&&l[c.name]===1?a[c.name]=c.checked:(a[c.name]||(a[c.name]=[]),c.checked&&a[c.name].push(c.value));else if(c.type==="radio")c.checked&&(a[c.name]=c.value);else if(c.type==="select-multiple"){a[c.name]=[];for(let w=0;w<c.options.length;w++)c.options[w].selected&&a[c.name].push(c.options[w].value)}else if(o&&c.type==="hidden")a[c.name]=c.value;else if(o&&(c.type==="number"||c.type==="range")){const w=Number(c.value);a[c.name]=c.value===""||isNaN(w)?null:w}else a[c.name]=c.value}return a}function je(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function $e(e,t){const o=e.elements,i=[],a={};for(let s=0;s<o.length;s++){const l=o[s];l.name&&l.type==="checkbox"&&(a[l.name]=(a[l.name]||0)+1)}for(let s=0;s<o.length;s++){const l=o[s];if(l.type==="file"||l.type==="submit"||l.type==="button")continue;const d=l.getAttribute("data-ln-fill-as")||l.name;if(!d||!(d in t))continue;const c=t[d];if(l.type==="checkbox"){if(Array.isArray(c))l.checked=c.indexOf(l.value)!==-1;else if(a[l.name]>1){const w=String(c).split(",").map(function(b){return b.trim()});l.checked=w.indexOf(l.value)!==-1}else l.checked=je(c);i.push(l)}else if(l.type==="radio")l.checked=l.value===String(c),i.push(l);else if(l.type==="select-multiple"){if(Array.isArray(c))for(let w=0;w<l.options.length;w++)l.options[w].selected=c.indexOf(l.options[w].value)!==-1;i.push(l)}else l.value=c,l.tagName==="SELECT"&&c!=null&&l.setAttribute("data-ln-value",c),i.push(l)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=$e,window.lnCore.serializeForm=Fe,window.lnCore.resolveFormMethod=Pe);const he={};function Ke(e,t){he[e]=t}function Ue(e){return he[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=Ke,window.lnCore.getDataMapper=Ue);function Ve(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,Q(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const we={};function Ge(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];we[o]=t}function He(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return we[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ge,window.lnCore.getLocaleFallback=He,window.lnCore.ensureLocaleObserver=Ve);const oe={};function We(e,t){oe[e]||(oe[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=oe[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function ye(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let l=0;l<o.length;l++){const d=o[l],c=d.getAttribute("data-ln-field");t[c]!=null&&(d.textContent=t[c])}const i=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<i.length;l++){const d=i[l],c=d.getAttribute("data-ln-attr").split(",");for(let w=0;w<c.length;w++){const b=c[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 l=0;l<a.length;l++){const d=a[l],c=d.getAttribute("data-ln-show");c in t&&d.classList.toggle("hidden",!t[c])}const s=e.querySelectorAll("[data-ln-class]");for(let l=0;l<s.length;l++){const d=s[l],c=d.getAttribute("data-ln-class").split(",");for(let w=0;w<c.length;w++){const b=c[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 Qe(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const 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)ye(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 pe(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const s=o.currentNode;s.textContent.indexOf("{{")!==-1&&(s.textContent=s.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,d){return t[d]!==void 0?t[d]:""}))}const i=function(s,l){return t[l]!==void 0?t[l]:""},a=Array.from(e.querySelectorAll("*"));e.nodeType===1&&a.push(e);for(let s=0;s<a.length;s++){const l=a[s],d=l.attributes;for(let c=0;c<d.length;c++){const w=d[c];w.value.indexOf("{{")!==-1&&l.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function Je(e,t,o,i,a,s){const l={};for(let c=0;c<e.children.length;c++){const w=e.children[c],b=w.getAttribute("data-ln-render-key");b&&(l[b]=w)}const d=document.createDocumentFragment();for(let c=0;c<t.length;c++){const w=t[c],b=String(i(w));let _=l[b];if(_)a(_,w,c);else{const x=We(o,s);if(!x||(pe(x,w),_=x.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",b),a(_,w,c)}d.appendChild(_)}e.textContent="",e.appendChild(d)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=pe,window.lnCore.fill=ye,window.lnCore.lnFill=Qe,window.lnCore.renderList=Je);function ie(e,t,o){const i=e.getAttribute(t);return i===null?o:i}function J(e,t,o){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?o:i}function ae(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 se(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const le=new Map;function me(e,t){const o=(e?e.join("|"):"")+"::"+t;if(le.has(o))return le.get(o);const i=new Set(e||[]),a=function(s,l){const d=s.getAttribute(l);return d!==null&&i.has(d)?d:t};return le.set(o,a),a}function ge(e,t,o){const i=parseFloat(e.getAttribute(t));return isNaN(i)?o:i}function be(e,t,o){const i=e.getAttribute(t);if(!i)return o;try{return JSON.parse(i)}catch{return o}}function _e(e,t,o,i,a){if(!e||t===null)return!0;const s=i||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const d=c=>{a?console.warn(c,a):console.warn(c)};if(l==="boolean"){const c=t.trim().toLowerCase();return c!==""&&c!=="true"&&c!=="false"&&c!=="1"&&c!=="0"?(d(`[${s}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const c=e.values||[];return c.includes(t)?!0:(d(`[${s}] Invalid value "${t}" for attribute "${o}". Allowed: ${c.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return d(`[${s}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const c=parseInt(t,10);return e.min!==void 0&&c<e.min?(d(`[${s}] Value ${c} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&c>e.max?(d(`[${s}] Value ${c} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(d(`[${s}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(c){return d(`[${s}] Invalid JSON for attribute "${o}": ${c.message}. Fallback: ${e.fallback}.`),!1}return!0}function Ce(e,t,o){for(const i in o){const[a,s,l]=o[i];Object.defineProperty(e,i,{get:function(){return a(t,s,l)},enumerable:!0,configurable:!0})}return e}function Se(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=me(i.values,i.fallback);break;case"integer":a=J;break;case"float":a=ge;break;case"boolean":a=ae;break;case"list":a=se;break;case"json":a=be;break;case"string":default:a=ie;break}a||(a=ie),t[i.prop]=[a,o,i.fallback]}return t}function Ze(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 Xe(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=Ce,window.lnCore.attrSpec=Se,window.lnCore.attrStr=ie,window.lnCore.attrInt=J,window.lnCore.attrBool=ae,window.lnCore.attrList=se,window.lnCore.attrEnum=me,window.lnCore.attrFloat=ge,window.lnCore.attrJson=be);function ce(e,t,o,i){if(e.nodeType!==1)return;const s=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l=Array.from(e.querySelectorAll(s));e.matches&&e.matches(s)&&l.push(e);for(const d of l)if(!d[o]){window.lnCore._persistSink&&d.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(d,t);try{d[o]=new i(d)}catch(c){console.error("["+o+"] init failed",d,c)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Ye(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function et(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 ve(){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 tt(e){const t=ve(),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(s=>s.componentTag===e.componentTag)||a.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=Xe(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 Ae(e,t,o,i){for(let a=0;a<e.length;a++){const s=e[a];if(!t[s.attribute])continue;const l=s.effects&&s.effects[o];l?l(t,o,i):s.onAttrChange&&(!s.declared||s.declared.has(o))&&s.onAttrChange(t,o,i)}}function nt(e){const t=e.target,o=e.attributeName;if(e.oldValue===t.getAttribute(o))return;const i=ve(),a=i.byAttr.get(o);if(fe()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(o)&&re(t)){const s=i.byDeclaredAttr.get(o),l=t.getAttribute(o);for(let d=0;d<s.length;d++)_e(s[d].spec,l,o,s[d].componentTag,t)}if(window.lnCore._debugSink&&(o.indexOf("data-ln-")===0||a)&&window.lnCore._debugSink("attr",o,t,{oldValue:e.oldValue,newValue:t.getAttribute(o)}),o.indexOf("data-ln-")===0){const s=i.byReactive.get(o);s&&Ae(s,t,o,e.oldValue),i.reactiveWildcard.length&&Ae(i.reactiveWildcard,t,o,e.oldValue)}if(a)for(let s=0;s<a.length;s++){const l=a[s];if(l.handler){l.handler(t,o,e.oldValue);continue}l.onAttributeChange&&t[l.attribute]?l.onAttributeChange(t,o):(ce(t,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(t))}}function rt(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,Q(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{nt(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 xe(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function ot(e){const t=xe();if(t.length){if(e.target)for(let o=0;o<t.length;o++){const i=t[o];if(i.onSubtreeChange){const a=i.query,s=e.target.nodeType===1?e.target.matches(a)?e.target:e.target.closest(a):e.target.parentElement?e.target.parentElement.closest(a):null;s&&i.onSubtreeChange(s,e)}}for(let o=0;o<e.addedNodes.length;o++){const i=e.addedNodes[o];if(i.nodeType===1)for(let a=0;a<t.length;a++){const s=t[a];ce(i,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(i)}}for(let o=0;o<e.removedNodes.length;o++){const i=e.removedNodes[o];if(i.nodeType===1)for(let a=0;a<t.length;a++){const s=t[a],l=s.query,d=Array.from(i.querySelectorAll(l));i.matches&&i.matches(l)&&d.push(i);for(let c=0;c<d.length;c++){const w=d[c];if(!document.contains(w)){const b=w[s.attribute];if(b&&typeof b.destroy=="function")try{b.destroy()}catch(_){console.error("["+s.attribute+"] destroy failed",w,_)}delete w[s.attribute]}}}}}}function it(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,Q(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++){const i=t[o];if(i.type==="childList")try{ot(i)}catch(a){console.error("[ln-core] lifecycle handler failed",i.target,a)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ke(e,t,o,i,a={}){const s=a.extraAttributes||[],l=a.onAttributeChange||null,d=a.onSubtreeChange||null,c=a.onInit||null,w=a.onAttrChange||null,b=a.effects||null,_=a.attributes||null,x=_?Ze(_):b,P=_?new Set(Object.keys(_)):null,F=a.persist||null;function m(k){const I=k||document.body;if(ce(I,e,t,o),_&&fe())for(const j in _){const Z=_[j],G=Array.from(I.querySelectorAll("["+j+"]"));I.matches&&I.matches("["+j+"]")&&G.push(I);for(let K=0;K<G.length;K++){const B=G[K];re(B)&&_e(Z,B.getAttribute(j),j,i,B)}}c&&c(I)}const S=[];if(e.indexOf("[")!==-1){const k=/\[([\w-]+)/g;let I;for(;(I=k.exec(e))!==null;)S.push(I[1])}else S.push(e);tt({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:o,onInit:c,observed:S.concat(s),onAttributeChange:l,onAttrChange:w,effects:x,declared:P,persist:F}),rt();const q=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";xe().push({selector:e,attribute:t,ComponentFn:o,onInit:c,onSubtreeChange:d,query:q}),it(),window[t]=m,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ke);function A(){Ye()>0?et(function(){m(document.body)}):m(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A):A(),m}function at(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 st(e,t,o,i){if(o==="number"){const l=parseFloat(e),d=parseFloat(t);return(isNaN(l)?0:l)-(isNaN(d)?0:d)}const a=e!=null?String(e):"",s=t!=null?String(t):"";return i?i.compare(a,s):a<s?-1:a>s?1:0}function Ie(e){return(e||"").replace(/^#/,"")}function ue(e){const t=e===void 0?location.hash:e,o={},i=Ie(t);if(!i)return o;const a=i.split("&");for(let s=0;s<a.length;s++){const l=a[s];if(!l)continue;const d=l.indexOf(":"),c=d>-1?l.slice(0,d):l,w=d>-1?l.slice(d+1):"";if(c)try{o[c]=decodeURIComponent(w)}catch{o[c]=w}}return o}function lt(e){if(!e)return null;const t=ue();return e in t?t[e]:null}function ct(e,t){if(!e)return;const o=ue();t==null?delete o[e]:o[e]=String(t);const a=Object.keys(o).map(function(s){const l=o[s];return l===""?s:s+":"+encodeURIComponent(l)}).join("&");Ie(location.hash)!==a&&(location.hash=a)}function ut(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function dt(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 ft(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function ht(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 wt(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function yt(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(s){try{return decodeURIComponent(s)}catch{return s}}).filter(Boolean):[];return{key:o,values:a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=ue,window.lnCore.hashGet=lt,window.lnCore.hashSet=ct,window.lnCore.hashLinkClick=ut,window.lnCore.resolveHashNamespace=dt,window.lnCore.hashSortEncode=ft,window.lnCore.hashSortDecode=ht,window.lnCore.hashFilterEncode=wt,window.lnCore.hashFilterDecode=yt);let V=null;const pt="ln-ashlar:storage-salt:v1",Ee=32768;function qe(e){let t="";const o=e.byteLength;for(let i=0;i<o;i+=Ee)t+=String.fromCharCode.apply(null,e.subarray(i,Math.min(i+Ee,o)));return btoa(t)}function Ne(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 Le(e,t){let o=V,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 mt(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 c=await crypto.subtle.digest("SHA-256",i.encode(e));return crypto.subtle.importKey("raw",c,{name:"AES-GCM"},!1,["encrypt","decrypt"])}const a=t.salt||pt,s=typeof a=="string"?i.encode(a):a,l=t.iterations||1e5,d=await crypto.subtle.importKey("raw",i.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:s,iterations:l,hash:"SHA-256"},d,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Te(e,t={}){if(!e){V=null;return}try{const o=t.method||"sha256";V=await mt(e,{...t,method:o})}catch(o){throw console.error("[ln-core/crypto] Key derivation failed:",o),V=null,o}}function M(){return V}async function gt(e,t,o){const{key:i}=Le(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,s=crypto.getRandomValues(new Uint8Array(12)),l=typeof e=="string"?e:JSON.stringify(e),d=await crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,a.encode(l));return{v:1,alg:"AES-GCM",encrypted:!0,iv:qe(s),data:qe(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 bt(e,t,o){const{key:i,options:a}=Le(t),s=a.silent===!0;if(!e||!e.encrypted)return e;if(!i){if(s)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: No active cryptographic key provided")}if(!e.iv||!e.data){if(s)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: Malformed envelope (missing iv or data)")}try{const l=new TextDecoder,d=Ne(e.iv),c=Ne(e.data),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:d},i,c),b=l.decode(w);try{return JSON.parse(b)}catch{return b}}catch(l){if(s)return{...e,decryptionError:!0};throw console.error("[ln-core/crypto] Decryption failed. Key may be incorrect or payload tampered:",l),new Error("[ln-crypto] Decryption failed. Key may be incorrect or payload tampered: "+(l&&l.message?l.message:String(l)))}}function _t(){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=_t);function Ct(e){return String(e||"").trim().toLowerCase()}function St(e){const t=Ct(e);return t?t.split(/\s+/).filter(Boolean):[]}function vt(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 At(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 xt(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:()=>{},s=new Map,l=new Set;let d=0,c=0,w=0,b=!1,_=null;function x(m,S){s.delete(m),s.set(m,S)}function P(){if(s.size<=t)return[];const m=[];for(;s.size>t;){const N=s.keys().next().value;m.push(s.get(N)),s.delete(N)}const S=new Set(s.values());return m.filter(N=>!S.has(N))}function F(m,S){l.add(m),clearTimeout(_),_=setTimeout(()=>a(m,o,S),i)}return{get logicalTotal(){return d},set logicalTotal(m){d=m},get grandTotal(){return c},set grandTotal(m){c=m},get queryGen(){return w},set queryGen(m){w=m},get size(){return s.size},get hasLoaded(){return b},getId:m=>{if(!s.has(m))return;const S=s.get(m);return x(m,S),S},ensure:(m,S,N)=>{if(!b&&!l.has(0))return F(0,N);if(d<=0)return;const q=Math.max(0,m),A=Math.min(d,S);for(let k=q;k<A;k++)if(!s.has(k)){const I=Math.floor(k/o)*o;if(!l.has(I))return F(I,N)}},ingest:(m,S,N,q,A)=>{if(A!=null&&A!==w)return[];b=!0,N!=null&&(c=N),q!=null&&(d=q);for(let k=0;k<S.length;k++)x(m+k,S[k]);return l.delete(m),P()},reset:function(){w++,this.clear()},clear:()=>{b=!1,s.clear(),l.clear(),clearTimeout(_)},configure:(m={})=>{let S=[];return m.windowSize>0&&m.windowSize!==t&&(t=m.windowSize,S=P()),m.pageSize>0&&(o=m.pageSize),m.fetchDebounce>=0&&(i=m.fetchDebounce),S}}}function kt(e,t,o){if(!Array.isArray(e)||!t||!t.field)return e;const{field:i,direction:a}=t,s=a==="desc",l=e.map(c=>c?c[i]:void 0),d=at(l);return[...e].sort((c,w)=>{const b=c?c[i]:void 0,_=w?w[i]:void 0,x=st(b,_,d,o);return s?-x:x})}function De(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=>At(i[a],t[a])):!1):e}function It(e,t,o){if(!Array.isArray(e)||!t||!o||!o.length)return e;const i=St(t);return i.length?e.filter(a=>a?i.every(s=>o.some(l=>{const d=a[l];return d!=null&&vt(String(d),[s])})):!1):e}function Et(e,t,o){if(!Array.isArray(e)||!e.length)return 0;if(o==="count")return e.length;const i=e.map(s=>s&&s[t]!=null?parseFloat(s[t]):NaN).filter(s=>Number.isFinite(s)),a=i.reduce((s,l)=>s+l,0);return o==="sum"?a:o==="avg"&&i.length?a/i.length:0}function qt(e,t={},o=[],i){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const a=e.length;let s=e;t.filters&&(s=De(s,t.filters)),t.search&&(s=It(s,t.search,o));const l=s.length;if(t.sort&&(s=kt(s,t.sort,i)),t.offset||t.limit){const d=t.offset||0,c=t.limit||s.length;s=s.slice(d,d+c)}return{records:s,total:a,filtered:l}}function Nt(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(o=>{if(!o)return null;const i={...o};for(const[a,s]of Object.entries(t))if(typeof s=="function")try{i[a]=s(o)}catch{i[a]=void 0}return i})}function Lt(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 s=t[a]&&t[a].indexes||[],l=o&&o[a]||[];if(s.some(d=>!l.includes(d)))return!0}return!1}function Tt(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:Be,description:"Identifies the element as a data-store definition container"},"data-ln-data-store-indexes":{type:"list",effect:Be,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:se,description:"Record fields to index for client-side search"},"data-ln-data-store-no-local-query":{prop:"noLocalQuery",type:"boolean",read:ae,description:"Bypasses local IndexedDB query resolution, forcing remote fetching"},"data-ln-data-store-window":{prop:"_windowSize",type:"integer",read:J,fallback:1e3,min:10,effect:Xt,description:"Virtual scrolling cache window size in records"},"data-ln-data-store-window-page":{prop:"_windowPageSize",type:"integer",read:J,fallback:200,min:5,effect:Yt,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=Se(i),s="ln_app_cache",l="_meta",d="1.0";let c=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 P(){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(s);f.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed"),n(null)},f.onsuccess=h=>{const y=h.target.result,p=Array.from(y.objectStoreNames),g=u.filter(T=>p.includes(T));let C={};if(g.length>0){const T=y.transaction(g,"readonly");for(const D of g)C[D]=Array.from(T.objectStore(D).indexNames)}if(!Lt(p,r,C,l))return F(y),c=y,n(y);const $=y.version;y.close();const R=indexedDB.open(s,$+1);let z=!1,O=null;R.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),v(document,"ln-data-store:blocked",{db:s}),O||(O=setTimeout(()=>{z||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),z=!0,w=null,n(null))},5e3))},R.onerror=()=>{z||(O&&clearTimeout(O),z=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},R.onupgradeneeded=T=>{const D=T.target.result,en=T.target.transaction;D.objectStoreNames.contains(l)||D.createObjectStore(l,{keyPath:"key"});for(const W of u)if(D.objectStoreNames.contains(W)){const ne=en.objectStore(W);for(const U of r[W].indexes)ne.indexNames.contains(U)||ne.createIndex(U,U,{unique:!1})}else{const ne=D.createObjectStore(W,{keyPath:"id"});for(const U of r[W].indexes)ne.createIndex(U,U,{unique:!1})}},R.onsuccess=T=>{if(z){T.target.result&&T.target.result.close();return}O&&clearTimeout(O),z=!0;const D=T.target.result;F(D),c=D,n(D)}}}),w)}function F(n){n.onversionchange=()=>{n.close(),c=null,w=null}}function m(){return c?Promise.resolve(c):(w=null,P())}async function S(n){if(!M()||!n)return n;const r={...n},u=r.id,f=await gt(r);return!f||!f.encrypted?n:{...f,id:u}}async function N(n){return!n||!n.encrypted||!M()?n:bt(n,{silent:!0})}const q=(n,r)=>m().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 k=n=>q(n,"readonly").then(r=>r?A(r.getAll()):[]).then(r=>M()?Promise.all(r.map(u=>N(u))):r),I=(n,r)=>q(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?N(u):null),j=(n,r)=>m().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=r.map(p=>A(h.get(p)).then(g=>g!==void 0?g: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=>M()?Promise.all(p.map(g=>g?N(g):null)):p)}),Z=(n,r)=>(M()?S(r):Promise.resolve(r)).then(f=>q(n,"readwrite").then(h=>h?A(h.put(f)):null)),G=(n,r)=>q(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),K=n=>q(n,"readwrite").then(r=>r?A(r.clear()):null),B=n=>q(n,"readonly").then(r=>r?A(r.count()):0),Dt=n=>q(l,"readonly").then(r=>r?A(r.get(n)):null),X=(n,r)=>q(l,"readwrite").then(u=>{if(u)return r.key=n,A(u.put(r))});function L(n){return this.dom=n,this._name=n.id,this._name||console.warn("[ln-data-store] missing id — the store cannot be addressed",n),Ce(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=xt({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,zt(this),this.ready=Ft(this),this}function zt(n){n._handlers={create:r=>Y(n,"create",r.detail,()=>Ot(n,r.detail)),update:r=>Y(n,"update",r.detail,()=>Rt(n,r.detail)),delete:r=>Y(n,"delete",r.detail,()=>Mt(n,r.detail)),"bulk-delete":r=>Y(n,"bulk-delete",r.detail,()=>Bt(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,de(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,g)=>p===f[g]):!f.length)||(f.length?n.query.filters[u]=f:delete n.query.filters[u],de(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,de(n))}};for(const[r,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(r,u)}function Y(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=>Pt(n,r,h,y)),n._mutationChain}function ee(n,r=0){return B(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,X(n._name,{schema_version:d,last_synced_at:n.lastSyncedAt,has_cache:!0,record_count:n.totalCount})})}function Ot(n,{tempId:r,data:u={},requestId:f}={}){const h={...u,id:r};return Z(n._name,h).then(()=>ee(n,1)).then(()=>{v(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:r,requestId:f})})}function Rt(n,{id:r,data:u={},requestId:f}={}){return I(n._name,r).then(h=>{if(!h)throw new Error(`Record not found: ${r}`);const y=h.id,p={...h,...u,id:y},g=u.id,C=g!==void 0&&g!==y;return(C?jt(n._name,y,{...p,id:g}):Z(n._name,p)).then(()=>ee(n,0)).then(()=>{v(n.dom,"ln-data-store:updated",{store:n._name,record:C?{...p,id:g}:p,previous:h,requestId:f})})})}function Mt(n,{id:r,requestId:u}={}){return I(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 G(n._name,h).then(()=>ee(n,-1)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function Bt(n,{ids:r=[],requestId:u}={}){return r.length?Promise.all(r.map(f=>I(n._name,f))).then(f=>{const h=f.filter(Boolean).map(y=>y.id);return te(n._name,h).then(()=>ee(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 Pt(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 Ft(n){return P().then(r=>{if(!r)throw new Error("IndexedDB is unavailable");return Dt(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 K(n._name).then(()=>X(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 ze(n){n.isSyncing=!0,v(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function Oe(n,r){return m().then(u=>u?(M()?Promise.all(r.map(h=>S(h))):Promise.resolve(r)).then(h=>new Promise((y,p)=>{const g=u.transaction(n,"readwrite"),C=g.objectStore(n);h.forEach(E=>C.put(E)),g.oncomplete=()=>y(),g.onerror=()=>{_(g.error),p(g.error)}})):void 0)}function te(n,r){return m().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);r.forEach(g=>{p.delete(g),typeof g=="string"&&g.trim()!==""&&!isNaN(Number(g))?p.delete(Number(g)):typeof g=="number"&&p.delete(String(g))}),y.oncomplete=()=>f(),y.onerror=()=>h(y.error)})})}function jt(n,r,u){return(M()?S(u):Promise.resolve(u)).then(h=>m().then(y=>{if(y)return new Promise((p,g)=>{const C=y.transaction(n,"readwrite"),E=C.objectStore(n);E.put(h),E.delete(r),C.oncomplete=()=>p(),C.onerror=()=>{_(C.error),g(C.error)}})}))}const $t=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Kt(n){return n?Object.keys(n).filter(r=>Array.isArray(n[r])&&n[r].length>0):[]}function Ut(n,r,u){return r.every(f=>u[f].map(String).includes(String(n[f])))}function Vt(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function Gt(n,r,u){return r.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function Ht(n,r,u){return Et(n,r,u)}function H(n,r){return Nt(r,n.presenters&&n.presenters.computed)}function Wt(n){return!n.sort&&!M()}function Qt(n,r,u){const f=Kt(r.filters),h=r.search?Vt(r.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return q(n._name,"readonly").then(g=>g?new Promise((C,E)=>{const $=[],R=g.openCursor();R.onsuccess=()=>{const z=R.result;if(!z||$.length>=u){C($);return}const O=z.value;(!f.length||Ut(O,f,r.filters))&&(!p||Gt(O,h,y))&&$.push(O),z.continue()},R.onerror=()=>E(R.error)}):[])}function Re(n,r,u){return qt(r,u,n._searchFields,$t)}function Me(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 j(n._name,h).then(y=>{const p=new Map;for(let C=0;C<y.length;C++){const E=y[C];E&&p.set(String(E.id),E)}const g=[];for(let C=0;C<f.length;C++){const E=f[C];if(E===void 0)g.push(null);else{const $=p.get(String(E));g.push($||null)}}return{data:H(n,g),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:r,queryGen:n._windowIndex.queryGen}})}L.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:H(r,p),offset:u,queryGen:r._windowIndex.queryGen,provisional:!0}:Me(r,u,f);return Wt(n)?Qt(r,n,h).then(p=>y(p.slice(u,h))):k(r._name).then(p=>y(Re(r,p,n).records))}return Me(r,u,f)}return k(r._name).then(u=>{const f=Re(r,u,n);return{data:H(r,f.records),total:f.total,filtered:f.filtered}})},L.prototype.getById=function(n){return I(this._name,n).then(r=>r?H(this,[r])[0]:null)},L.prototype.count=function(n){return n&&Object.keys(n).length>0?k(this._name).then(u=>De(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):B(this._name)},L.prototype.aggregate=function(n,r){return k(this._name).then(u=>Ht(u,n,r))},L.prototype.setPresenters=function(n){this.presenters=n},L.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=m().then(p=>{if(!p)throw new Error("IndexedDB unavailable")});return n.length>0&&(y=y.then(()=>Oe(h._name,n))),r.length>0&&(y=y.then(()=>te(h._name,r))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,g=n.map(E=>E.id),C=h._windowIndex.ingest(p,g,f.total,f.filtered,f.queryGen);if(C&&C.length)return te(h._name,C)}}).then(()=>B(h._name)).then(p=>(h.totalCount=f.total!==void 0?f.total:p,h.hasCache=!0,X(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 g=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:g}),Tt(p)})},L.prototype.applyQuery=function(n,r){r=r||{};const u=this;let f=Promise.resolve();return n.length>0&&(f=f.then(()=>Oe(u._name,n))),f.then(()=>B(u._name)).then(h=>(u.totalCount=r.total!==void 0?r.total:h,n.length>0&&(u.canServe=!0),H(u,n))).catch(h=>(console.error("[ln-data-store] applyQuery failed:",h),[]))},L.prototype.forceSync=function(){this.isSyncing||ze(this)},L.prototype.fullReload=function(){const n=this;return K(n._name).then(()=>X(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,ze(n)})},L.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 Jt(){return m().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 de(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 Zt="data-ln-data-store-frozen";function Be(n,r){n.setAttribute(Zt,r)}function Xt(n){const r=n[t];if(!r._windowIndex)return;const u=r._windowIndex.configure({windowSize:r._windowSize});u.length&&te(r._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function Yt(n){const r=n[t];r._windowIndex&&r._windowIndex.configure({pageSize:r._windowPageSize})}ke(e,t,L,"ln-data-store",{attributes:i}),window[t].clearAll=Jt,window[t].init=window[t],window[t].setStorageKey=Te,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=Te)})()})();
|
|
1
|
+
(function(){"use strict";function fe(){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 re(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(!re(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 Q(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){Q(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function Pe(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function Fe(e,t){const o=!!(t&&t.typed),i=t&&t.exclude,a={},s=e.elements,l={};if(o)for(let d=0;d<s.length;d++){const c=s[d];c.name&&c.type==="checkbox"&&!c.disabled&&(l[c.name]=(l[c.name]||0)+1)}for(let d=0;d<s.length;d++){const c=s[d];if(!(!c.name||c.disabled||c.type==="file"||c.type==="submit"||c.type==="button")&&!(i&&c.matches&&c.matches(i)))if(c.type==="checkbox")o&&l[c.name]===1?a[c.name]=c.checked:(a[c.name]||(a[c.name]=[]),c.checked&&a[c.name].push(c.value));else if(c.type==="radio")c.checked&&(a[c.name]=c.value);else if(c.type==="select-multiple"){a[c.name]=[];for(let w=0;w<c.options.length;w++)c.options[w].selected&&a[c.name].push(c.options[w].value)}else if(o&&c.type==="hidden")a[c.name]=c.value;else if(o&&(c.type==="number"||c.type==="range")){const w=Number(c.value);a[c.name]=c.value===""||isNaN(w)?null:w}else a[c.name]=c.value}return a}function je(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function $e(e,t){const o=e.elements,i=[],a={};for(let s=0;s<o.length;s++){const l=o[s];l.name&&l.type==="checkbox"&&(a[l.name]=(a[l.name]||0)+1)}for(let s=0;s<o.length;s++){const l=o[s];if(l.type==="file"||l.type==="submit"||l.type==="button")continue;const d=l.getAttribute("data-ln-fill-as")||l.name;if(!d||!(d in t))continue;const c=t[d];if(l.type==="checkbox"){if(Array.isArray(c))l.checked=c.indexOf(l.value)!==-1;else if(a[l.name]>1){const w=String(c).split(",").map(function(b){return b.trim()});l.checked=w.indexOf(l.value)!==-1}else l.checked=je(c);i.push(l)}else if(l.type==="radio")l.checked=l.value===String(c),i.push(l);else if(l.type==="select-multiple"){if(Array.isArray(c))for(let w=0;w<l.options.length;w++)l.options[w].selected=c.indexOf(l.options[w].value)!==-1;i.push(l)}else l.value=c,l.tagName==="SELECT"&&c!=null&&l.setAttribute("data-ln-value",c),i.push(l)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=$e,window.lnCore.serializeForm=Fe,window.lnCore.resolveFormMethod=Pe);const he={};function Ke(e,t){he[e]=t}function Ue(e){return he[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=Ke,window.lnCore.getDataMapper=Ue);function Ve(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,Q(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const we={};function Ge(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];we[o]=t}function He(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return we[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ge,window.lnCore.getLocaleFallback=He,window.lnCore.ensureLocaleObserver=Ve);const oe={};function We(e,t){oe[e]||(oe[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=oe[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function ye(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let l=0;l<o.length;l++){const d=o[l],c=d.getAttribute("data-ln-field");t[c]!=null&&(d.textContent=t[c])}const i=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<i.length;l++){const d=i[l],c=d.getAttribute("data-ln-attr").split(",");for(let w=0;w<c.length;w++){const b=c[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 l=0;l<a.length;l++){const d=a[l],c=d.getAttribute("data-ln-show");c in t&&d.classList.toggle("hidden",!t[c])}const s=e.querySelectorAll("[data-ln-class]");for(let l=0;l<s.length;l++){const d=s[l],c=d.getAttribute("data-ln-class").split(",");for(let w=0;w<c.length;w++){const b=c[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 Qe(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const 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)ye(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 pe(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const s=o.currentNode;s.textContent.indexOf("{{")!==-1&&(s.textContent=s.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,d){return t[d]!==void 0?t[d]:""}))}const i=function(s,l){return t[l]!==void 0?t[l]:""},a=Array.from(e.querySelectorAll("*"));e.nodeType===1&&a.push(e);for(let s=0;s<a.length;s++){const l=a[s],d=l.attributes;for(let c=0;c<d.length;c++){const w=d[c];w.value.indexOf("{{")!==-1&&l.setAttribute(w.name,w.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function Je(e,t,o,i,a,s){const l={};for(let c=0;c<e.children.length;c++){const w=e.children[c],b=w.getAttribute("data-ln-render-key");b&&(l[b]=w)}const d=document.createDocumentFragment();for(let c=0;c<t.length;c++){const w=t[c],b=String(i(w));let _=l[b];if(_)a(_,w,c);else{const x=We(o,s);if(!x||(pe(x,w),_=x.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",b),a(_,w,c)}d.appendChild(_)}e.textContent="",e.appendChild(d)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=pe,window.lnCore.fill=ye,window.lnCore.lnFill=Qe,window.lnCore.renderList=Je);function ie(e,t,o){const i=e.getAttribute(t);return i===null?o:i}function J(e,t,o){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?o:i}function ae(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 se(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const le=new Map;function me(e,t){const o=(e?e.join("|"):"")+"::"+t;if(le.has(o))return le.get(o);const i=new Set(e||[]),a=function(s,l){const d=s.getAttribute(l);return d!==null&&i.has(d)?d:t};return le.set(o,a),a}function ge(e,t,o){const i=parseFloat(e.getAttribute(t));return isNaN(i)?o:i}function be(e,t,o){const i=e.getAttribute(t);if(!i)return o;try{return JSON.parse(i)}catch{return o}}function _e(e,t,o,i,a){if(!e||t===null)return!0;const s=i||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const d=c=>{a?console.warn(c,a):console.warn(c)};if(l==="boolean"){const c=t.trim().toLowerCase();return c!==""&&c!=="true"&&c!=="false"&&c!=="1"&&c!=="0"?(d(`[${s}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const c=e.values||[];return c.includes(t)?!0:(d(`[${s}] Invalid value "${t}" for attribute "${o}". Allowed: ${c.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return d(`[${s}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const c=parseInt(t,10);return e.min!==void 0&&c<e.min?(d(`[${s}] Value ${c} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&c>e.max?(d(`[${s}] Value ${c} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(d(`[${s}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(c){return d(`[${s}] Invalid JSON for attribute "${o}": ${c.message}. Fallback: ${e.fallback}.`),!1}return!0}function Ce(e,t,o){for(const i in o){const[a,s,l]=o[i];Object.defineProperty(e,i,{get:function(){return a(t,s,l)},enumerable:!0,configurable:!0})}return e}function Se(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=me(i.values,i.fallback);break;case"integer":a=J;break;case"float":a=ge;break;case"boolean":a=ae;break;case"list":a=se;break;case"json":a=be;break;case"string":default:a=ie;break}a||(a=ie),t[i.prop]=[a,o,i.fallback]}return t}function Ze(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 Xe(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=Ce,window.lnCore.attrSpec=Se,window.lnCore.attrStr=ie,window.lnCore.attrInt=J,window.lnCore.attrBool=ae,window.lnCore.attrList=se,window.lnCore.attrEnum=me,window.lnCore.attrFloat=ge,window.lnCore.attrJson=be);function ce(e,t,o,i){if(e.nodeType!==1)return;const s=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l=Array.from(e.querySelectorAll(s));e.matches&&e.matches(s)&&l.push(e);for(const d of l)if(!d[o]){window.lnCore._persistSink&&d.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(d,t);try{d[o]=new i(d)}catch(c){console.error("["+o+"] init failed",d,c)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function Ye(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function et(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 ve(){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 tt(e){const t=ve(),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(s=>s.componentTag===e.componentTag)||a.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=Xe(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 Ae(e,t,o,i){for(let a=0;a<e.length;a++){const s=e[a];if(!t[s.attribute])continue;const l=s.effects&&s.effects[o];l?l(t,o,i):s.onAttrChange&&(!s.declared||s.declared.has(o))&&s.onAttrChange(t,o,i)}}function nt(e){const t=e.target,o=e.attributeName;if(e.oldValue===t.getAttribute(o))return;const i=ve(),a=i.byAttr.get(o);if(fe()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(o)&&re(t)){const s=i.byDeclaredAttr.get(o),l=t.getAttribute(o);for(let d=0;d<s.length;d++)_e(s[d].spec,l,o,s[d].componentTag,t)}if(window.lnCore._debugSink&&(o.indexOf("data-ln-")===0||a)&&window.lnCore._debugSink("attr",o,t,{oldValue:e.oldValue,newValue:t.getAttribute(o)}),o.indexOf("data-ln-")===0){const s=i.byReactive.get(o);s&&Ae(s,t,o,e.oldValue),i.reactiveWildcard.length&&Ae(i.reactiveWildcard,t,o,e.oldValue)}if(a)for(let s=0;s<a.length;s++){const l=a[s];if(l.handler){l.handler(t,o,e.oldValue);continue}l.onAttributeChange&&t[l.attribute]?l.onAttributeChange(t,o):(ce(t,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(t))}}function rt(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,Q(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{nt(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 xe(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function ot(e){const t=xe();if(t.length){if(e.target)for(let o=0;o<t.length;o++){const i=t[o];if(i.onSubtreeChange){const a=i.query,s=e.target.nodeType===1?e.target.matches(a)?e.target:e.target.closest(a):e.target.parentElement?e.target.parentElement.closest(a):null;s&&i.onSubtreeChange(s,e)}}for(let o=0;o<e.addedNodes.length;o++){const i=e.addedNodes[o];if(i.nodeType===1)for(let a=0;a<t.length;a++){const s=t[a];ce(i,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(i)}}for(let o=0;o<e.removedNodes.length;o++){const i=e.removedNodes[o];if(i.nodeType===1)for(let a=0;a<t.length;a++){const s=t[a],l=s.query,d=Array.from(i.querySelectorAll(l));i.matches&&i.matches(l)&&d.push(i);for(let c=0;c<d.length;c++){const w=d[c];if(!document.contains(w)){const b=w[s.attribute];if(b&&typeof b.destroy=="function")try{b.destroy()}catch(_){console.error("["+s.attribute+"] destroy failed",w,_)}delete w[s.attribute]}}}}}}function it(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,Q(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++){const i=t[o];if(i.type==="childList")try{ot(i)}catch(a){console.error("[ln-core] lifecycle handler failed",i.target,a)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function ke(e,t,o,i,a={}){const s=a.extraAttributes||[],l=a.onAttributeChange||null,d=a.onSubtreeChange||null,c=a.onInit||null,w=a.onAttrChange||null,b=a.effects||null,_=a.attributes||null,x=_?Ze(_):b,P=_?new Set(Object.keys(_)):null,F=a.persist||null;function m(k){const I=k||document.body;if(ce(I,e,t,o),_&&fe())for(const j in _){const Z=_[j],G=Array.from(I.querySelectorAll("["+j+"]"));I.matches&&I.matches("["+j+"]")&&G.push(I);for(let K=0;K<G.length;K++){const B=G[K];re(B)&&_e(Z,B.getAttribute(j),j,i,B)}}c&&c(I)}const S=[];if(e.indexOf("[")!==-1){const k=/\[([\w-]+)/g;let I;for(;(I=k.exec(e))!==null;)S.push(I[1])}else S.push(e);tt({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:o,onInit:c,observed:S.concat(s),onAttributeChange:l,onAttrChange:w,effects:x,declared:P,persist:F}),rt();const q=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,N=a.subtreeQuery||(q?e:"["+e+"]");xe().push({selector:e,attribute:t,ComponentFn:o,onInit:c,onSubtreeChange:d,query:N}),it(),window[t]=m,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ke);function A(){Ye()>0?et(function(){m(document.body)}):m(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",A):A(),m}function at(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 st(e,t,o,i){if(o==="number"){const l=parseFloat(e),d=parseFloat(t);return(isNaN(l)?0:l)-(isNaN(d)?0:d)}const a=e!=null?String(e):"",s=t!=null?String(t):"";return i?i.compare(a,s):a<s?-1:a>s?1:0}function Ie(e){return(e||"").replace(/^#/,"")}function ue(e){const t=e===void 0?location.hash:e,o={},i=Ie(t);if(!i)return o;const a=i.split("&");for(let s=0;s<a.length;s++){const l=a[s];if(!l)continue;const d=l.indexOf(":"),c=d>-1?l.slice(0,d):l,w=d>-1?l.slice(d+1):"";if(c)try{o[c]=decodeURIComponent(w)}catch{o[c]=w}}return o}function lt(e){if(!e)return null;const t=ue();return e in t?t[e]:null}function ct(e,t){if(!e)return;const o=ue();t==null?delete o[e]:o[e]=String(t);const a=Object.keys(o).map(function(s){const l=o[s];return l===""?s:s+":"+encodeURIComponent(l)}).join("&");Ie(location.hash)!==a&&(location.hash=a)}function ut(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function dt(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 ft(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function ht(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 wt(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function yt(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(s){try{return decodeURIComponent(s)}catch{return s}}).filter(Boolean):[];return{key:o,values:a}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=ue,window.lnCore.hashGet=lt,window.lnCore.hashSet=ct,window.lnCore.hashLinkClick=ut,window.lnCore.resolveHashNamespace=dt,window.lnCore.hashSortEncode=ft,window.lnCore.hashSortDecode=ht,window.lnCore.hashFilterEncode=wt,window.lnCore.hashFilterDecode=yt);let V=null;const pt="ln-ashlar:storage-salt:v1",Ee=32768;function qe(e){let t="";const o=e.byteLength;for(let i=0;i<o;i+=Ee)t+=String.fromCharCode.apply(null,e.subarray(i,Math.min(i+Ee,o)));return btoa(t)}function Ne(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 Le(e,t){let o=V,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 mt(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 c=await crypto.subtle.digest("SHA-256",i.encode(e));return crypto.subtle.importKey("raw",c,{name:"AES-GCM"},!1,["encrypt","decrypt"])}const a=t.salt||pt,s=typeof a=="string"?i.encode(a):a,l=t.iterations||1e5,d=await crypto.subtle.importKey("raw",i.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:s,iterations:l,hash:"SHA-256"},d,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Te(e,t={}){if(!e){V=null;return}try{const o=t.method||"sha256";V=await mt(e,{...t,method:o})}catch(o){throw console.error("[ln-core/crypto] Key derivation failed:",o),V=null,o}}function M(){return V}async function gt(e,t,o){const{key:i}=Le(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,s=crypto.getRandomValues(new Uint8Array(12)),l=typeof e=="string"?e:JSON.stringify(e),d=await crypto.subtle.encrypt({name:"AES-GCM",iv:s},i,a.encode(l));return{v:1,alg:"AES-GCM",encrypted:!0,iv:qe(s),data:qe(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 bt(e,t,o){const{key:i,options:a}=Le(t),s=a.silent===!0;if(!e||!e.encrypted)return e;if(!i){if(s)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: No active cryptographic key provided")}if(!e.iv||!e.data){if(s)return{...e,decryptionError:!0};throw new Error("[ln-crypto] Decryption failed: Malformed envelope (missing iv or data)")}try{const l=new TextDecoder,d=Ne(e.iv),c=Ne(e.data),w=await crypto.subtle.decrypt({name:"AES-GCM",iv:d},i,c),b=l.decode(w);try{return JSON.parse(b)}catch{return b}}catch(l){if(s)return{...e,decryptionError:!0};throw console.error("[ln-core/crypto] Decryption failed. Key may be incorrect or payload tampered:",l),new Error("[ln-crypto] Decryption failed. Key may be incorrect or payload tampered: "+(l&&l.message?l.message:String(l)))}}function _t(){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=_t);function Ct(e){return String(e||"").trim().toLowerCase()}function St(e){const t=Ct(e);return t?t.split(/\s+/).filter(Boolean):[]}function vt(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 At(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 xt(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:()=>{},s=new Map,l=new Set;let d=0,c=0,w=0,b=!1,_=null;function x(m,S){s.delete(m),s.set(m,S)}function P(){if(s.size<=t)return[];const m=[];for(;s.size>t;){const q=s.keys().next().value;m.push(s.get(q)),s.delete(q)}const S=new Set(s.values());return m.filter(q=>!S.has(q))}function F(m,S){l.add(m),clearTimeout(_),_=setTimeout(()=>a(m,o,S),i)}return{get logicalTotal(){return d},set logicalTotal(m){d=m},get grandTotal(){return c},set grandTotal(m){c=m},get queryGen(){return w},set queryGen(m){w=m},get size(){return s.size},get hasLoaded(){return b},getId:m=>{if(!s.has(m))return;const S=s.get(m);return x(m,S),S},ensure:(m,S,q)=>{if(!b&&!l.has(0))return F(0,q);if(d<=0)return;const N=Math.max(0,m),A=Math.min(d,S);for(let k=N;k<A;k++)if(!s.has(k)){const I=Math.floor(k/o)*o;if(!l.has(I))return F(I,q)}},ingest:(m,S,q,N,A)=>{if(A!=null&&A!==w)return[];b=!0,q!=null&&(c=q),N!=null&&(d=N);for(let k=0;k<S.length;k++)x(m+k,S[k]);return l.delete(m),P()},reset:function(){w++,this.clear()},clear:()=>{b=!1,s.clear(),l.clear(),clearTimeout(_)},configure:(m={})=>{let S=[];return m.windowSize>0&&m.windowSize!==t&&(t=m.windowSize,S=P()),m.pageSize>0&&(o=m.pageSize),m.fetchDebounce>=0&&(i=m.fetchDebounce),S}}}function kt(e,t,o){if(!Array.isArray(e)||!t||!t.field)return e;const{field:i,direction:a}=t,s=a==="desc",l=e.map(c=>c?c[i]:void 0),d=at(l);return[...e].sort((c,w)=>{const b=c?c[i]:void 0,_=w?w[i]:void 0,x=st(b,_,d,o);return s?-x:x})}function De(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=>At(i[a],t[a])):!1):e}function It(e,t,o){if(!Array.isArray(e)||!t||!o||!o.length)return e;const i=St(t);return i.length?e.filter(a=>a?i.every(s=>o.some(l=>{const d=a[l];return d!=null&&vt(String(d),[s])})):!1):e}function Et(e,t,o){if(!Array.isArray(e)||!e.length)return 0;if(o==="count")return e.length;const i=e.map(s=>s&&s[t]!=null?parseFloat(s[t]):NaN).filter(s=>Number.isFinite(s)),a=i.reduce((s,l)=>s+l,0);return o==="sum"?a:o==="avg"&&i.length?a/i.length:0}function qt(e,t={},o=[],i){if(!Array.isArray(e))return{records:[],total:0,filtered:0};const a=e.length;let s=e;t.filters&&(s=De(s,t.filters)),t.search&&(s=It(s,t.search,o));const l=s.length;if(t.sort&&(s=kt(s,t.sort,i)),t.offset||t.limit){const d=t.offset||0,c=t.limit||s.length;s=s.slice(d,d+c)}return{records:s,total:a,filtered:l}}function Nt(e,t){return!Array.isArray(e)||!t||typeof t!="object"?e:e.map(o=>{if(!o)return null;const i={...o};for(const[a,s]of Object.entries(t))if(typeof s=="function")try{i[a]=s(o)}catch{i[a]=void 0}return i})}function Lt(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 s=t[a]&&t[a].indexes||[],l=o&&o[a]||[];if(s.some(d=>!l.includes(d)))return!0}return!1}function Tt(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:Be,description:"Identifies the element as a data-store definition container"},"data-ln-data-store-indexes":{type:"list",effect:Be,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:se,description:"Record fields to index for client-side search"},"data-ln-data-store-no-local-query":{prop:"noLocalQuery",type:"boolean",read:ae,description:"Bypasses local IndexedDB query resolution, forcing remote fetching"},"data-ln-data-store-window":{prop:"_windowSize",type:"integer",read:J,fallback:1e3,min:10,effect:Xt,description:"Virtual scrolling cache window size in records"},"data-ln-data-store-window-page":{prop:"_windowPageSize",type:"integer",read:J,fallback:200,min:5,effect:Yt,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=Se(i),s="ln_app_cache",l="_meta",d="1.0";let c=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 P(){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(s);f.onerror=()=>{console.warn("[ln-data-store] IndexedDB open failed"),n(null)},f.onsuccess=h=>{const y=h.target.result,p=Array.from(y.objectStoreNames),g=u.filter(T=>p.includes(T));let C={};if(g.length>0){const T=y.transaction(g,"readonly");for(const D of g)C[D]=Array.from(T.objectStore(D).indexNames)}if(!Lt(p,r,C,l))return F(y),c=y,n(y);const $=y.version;y.close();const R=indexedDB.open(s,$+1);let z=!1,O=null;R.onblocked=()=>{console.warn("[ln-data-store] Database upgrade blocked — waiting for other tabs to close connection"),v(document,"ln-data-store:blocked",{db:s}),O||(O=setTimeout(()=>{z||(console.warn("[ln-data-store] Database upgrade timed out while blocked"),z=!0,w=null,n(null))},5e3))},R.onerror=()=>{z||(O&&clearTimeout(O),z=!0,w=null,console.warn("[ln-data-store] Database upgrade failed"),n(null))},R.onupgradeneeded=T=>{const D=T.target.result,en=T.target.transaction;D.objectStoreNames.contains(l)||D.createObjectStore(l,{keyPath:"key"});for(const W of u)if(D.objectStoreNames.contains(W)){const ne=en.objectStore(W);for(const U of r[W].indexes)ne.indexNames.contains(U)||ne.createIndex(U,U,{unique:!1})}else{const ne=D.createObjectStore(W,{keyPath:"id"});for(const U of r[W].indexes)ne.createIndex(U,U,{unique:!1})}},R.onsuccess=T=>{if(z){T.target.result&&T.target.result.close();return}O&&clearTimeout(O),z=!0;const D=T.target.result;F(D),c=D,n(D)}}}),w)}function F(n){n.onversionchange=()=>{n.close(),c=null,w=null}}function m(){return c?Promise.resolve(c):(w=null,P())}async function S(n){if(!M()||!n)return n;const r={...n},u=r.id,f=await gt(r);return!f||!f.encrypted?n:{...f,id:u}}async function q(n){return!n||!n.encrypted||!M()?n:bt(n,{silent:!0})}const N=(n,r)=>m().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 k=n=>N(n,"readonly").then(r=>r?A(r.getAll()):[]).then(r=>M()?Promise.all(r.map(u=>q(u))):r),I=(n,r)=>N(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),j=(n,r)=>m().then(u=>{if(!u)return[];const h=u.transaction(n,"readonly").objectStore(n),y=r.map(p=>A(h.get(p)).then(g=>g!==void 0?g: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=>M()?Promise.all(p.map(g=>g?q(g):null)):p)}),Z=(n,r)=>(M()?S(r):Promise.resolve(r)).then(f=>N(n,"readwrite").then(h=>h?A(h.put(f)):null)),G=(n,r)=>N(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),K=n=>N(n,"readwrite").then(r=>r?A(r.clear()):null),B=n=>N(n,"readonly").then(r=>r?A(r.count()):0),Dt=n=>N(l,"readonly").then(r=>r?A(r.get(n)):null),X=(n,r)=>N(l,"readwrite").then(u=>{if(u)return r.key=n,A(u.put(r))});function L(n){return this.dom=n,this._name=n.id,this._name||console.warn("[ln-data-store] missing id — the store cannot be addressed",n),Ce(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=xt({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,zt(this),this.ready=Ft(this),this}function zt(n){n._handlers={create:r=>Y(n,"create",r.detail,()=>Ot(n,r.detail)),update:r=>Y(n,"update",r.detail,()=>Rt(n,r.detail)),delete:r=>Y(n,"delete",r.detail,()=>Mt(n,r.detail)),"bulk-delete":r=>Y(n,"bulk-delete",r.detail,()=>Bt(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,de(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,g)=>p===f[g]):!f.length)||(f.length?n.query.filters[u]=f:delete n.query.filters[u],de(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,de(n))}};for(const[r,u]of Object.entries(n._queryHandlers))n.dom.addEventListener(r,u)}function Y(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=>Pt(n,r,h,y)),n._mutationChain}function ee(n,r=0){return B(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,X(n._name,{schema_version:d,last_synced_at:n.lastSyncedAt,has_cache:!0,record_count:n.totalCount})})}function Ot(n,{tempId:r,data:u={},requestId:f}={}){const h={...u,id:r};return Z(n._name,h).then(()=>ee(n,1)).then(()=>{v(n.dom,"ln-data-store:created",{store:n._name,record:h,tempId:r,requestId:f})})}function Rt(n,{id:r,data:u={},requestId:f}={}){return I(n._name,r).then(h=>{if(!h)throw new Error(`Record not found: ${r}`);const y=h.id,p={...h,...u,id:y},g=u.id,C=g!==void 0&&g!==y;return(C?jt(n._name,y,{...p,id:g}):Z(n._name,p)).then(()=>ee(n,0)).then(()=>{v(n.dom,"ln-data-store:updated",{store:n._name,record:C?{...p,id:g}:p,previous:h,requestId:f})})})}function Mt(n,{id:r,requestId:u}={}){return I(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 G(n._name,h).then(()=>ee(n,-1)).then(()=>{v(n.dom,"ln-data-store:deleted",{store:n._name,id:h,requestId:u})})})}function Bt(n,{ids:r=[],requestId:u}={}){return r.length?Promise.all(r.map(f=>I(n._name,f))).then(f=>{const h=f.filter(Boolean).map(y=>y.id);return te(n._name,h).then(()=>ee(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 Pt(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 Ft(n){return P().then(r=>{if(!r)throw new Error("IndexedDB is unavailable");return Dt(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 K(n._name).then(()=>X(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 ze(n){n.isSyncing=!0,v(n.dom,"ln-data-store:request-remote-sync",{since:n.lastSyncedAt})}function Oe(n,r){return m().then(u=>u?(M()?Promise.all(r.map(h=>S(h))):Promise.resolve(r)).then(h=>new Promise((y,p)=>{const g=u.transaction(n,"readwrite"),C=g.objectStore(n);h.forEach(E=>C.put(E)),g.oncomplete=()=>y(),g.onerror=()=>{_(g.error),p(g.error)}})):void 0)}function te(n,r){return m().then(u=>{if(u)return new Promise((f,h)=>{const y=u.transaction(n,"readwrite"),p=y.objectStore(n);r.forEach(g=>{p.delete(g),typeof g=="string"&&g.trim()!==""&&!isNaN(Number(g))?p.delete(Number(g)):typeof g=="number"&&p.delete(String(g))}),y.oncomplete=()=>f(),y.onerror=()=>h(y.error)})})}function jt(n,r,u){return(M()?S(u):Promise.resolve(u)).then(h=>m().then(y=>{if(y)return new Promise((p,g)=>{const C=y.transaction(n,"readwrite"),E=C.objectStore(n);E.put(h),E.delete(r),C.oncomplete=()=>p(),C.onerror=()=>{_(C.error),g(C.error)}})}))}const $t=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});function Kt(n){return n?Object.keys(n).filter(r=>Array.isArray(n[r])&&n[r].length>0):[]}function Ut(n,r,u){return r.every(f=>u[f].map(String).includes(String(n[f])))}function Vt(n){return String(n||"").toLowerCase().split(/\s+/).filter(Boolean)}function Gt(n,r,u){return r.every(f=>u.some(h=>{const y=n[h];return y!=null&&String(y).toLowerCase().includes(f)}))}function Ht(n,r,u){return Et(n,r,u)}function H(n,r){return Nt(r,n.presenters&&n.presenters.computed)}function Wt(n){return!n.sort&&!M()}function Qt(n,r,u){const f=Kt(r.filters),h=r.search?Vt(r.search):[],y=n._searchFields,p=h.length>0&&y&&y.length>0;return N(n._name,"readonly").then(g=>g?new Promise((C,E)=>{const $=[],R=g.openCursor();R.onsuccess=()=>{const z=R.result;if(!z||$.length>=u){C($);return}const O=z.value;(!f.length||Ut(O,f,r.filters))&&(!p||Gt(O,h,y))&&$.push(O),z.continue()},R.onerror=()=>E(R.error)}):[])}function Re(n,r,u){return qt(r,u,n._searchFields,$t)}function Me(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 j(n._name,h).then(y=>{const p=new Map;for(let C=0;C<y.length;C++){const E=y[C];E&&p.set(String(E.id),E)}const g=[];for(let C=0;C<f.length;C++){const E=f[C];if(E===void 0)g.push(null);else{const $=p.get(String(E));g.push($||null)}}return{data:H(n,g),total:n._windowIndex.grandTotal,filtered:n._windowIndex.logicalTotal,offset:r,queryGen:n._windowIndex.queryGen}})}L.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:H(r,p),offset:u,queryGen:r._windowIndex.queryGen,provisional:!0}:Me(r,u,f);return Wt(n)?Qt(r,n,h).then(p=>y(p.slice(u,h))):k(r._name).then(p=>y(Re(r,p,n).records))}return Me(r,u,f)}return k(r._name).then(u=>{const f=Re(r,u,n);return{data:H(r,f.records),total:f.total,filtered:f.filtered}})},L.prototype.getById=function(n){return I(this._name,n).then(r=>r?H(this,[r])[0]:null)},L.prototype.count=function(n){return n&&Object.keys(n).length>0?k(this._name).then(u=>De(u,n).length):this.windowed&&this.totalCount!=null?Promise.resolve(this.totalCount):B(this._name)},L.prototype.aggregate=function(n,r){return k(this._name).then(u=>Ht(u,n,r))},L.prototype.setPresenters=function(n){this.presenters=n},L.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=m().then(p=>{if(!p)throw new Error("IndexedDB unavailable")});return n.length>0&&(y=y.then(()=>Oe(h._name,n))),r.length>0&&(y=y.then(()=>te(h._name,r))),y.then(()=>{if(h._windowIndex&&(f.offset!=null||f.total!=null)){const p=f.offset!=null?f.offset:0,g=n.map(E=>E.id),C=h._windowIndex.ingest(p,g,f.total,f.filtered,f.queryGen);if(C&&C.length)return te(h._name,C)}}).then(()=>B(h._name)).then(p=>(h.totalCount=f.total!==void 0?f.total:p,h.hasCache=!0,X(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 g=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:g}),Tt(p)})},L.prototype.applyQuery=function(n,r){r=r||{};const u=this;let f=Promise.resolve();return n.length>0&&(f=f.then(()=>Oe(u._name,n))),f.then(()=>B(u._name)).then(h=>(u.totalCount=r.total!==void 0?r.total:h,n.length>0&&(u.canServe=!0),H(u,n))).catch(h=>(console.error("[ln-data-store] applyQuery failed:",h),[]))},L.prototype.forceSync=function(){this.isSyncing||ze(this)},L.prototype.fullReload=function(){const n=this;return K(n._name).then(()=>X(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,ze(n)})},L.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 Jt(){return m().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 de(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 Zt="data-ln-data-store-frozen";function Be(n,r){n.setAttribute(Zt,r)}function Xt(n){const r=n[t];if(!r._windowIndex)return;const u=r._windowIndex.configure({windowSize:r._windowSize});u.length&&te(r._name,u).catch(f=>{console.error("[ln-data-store] window shrink eviction failed:",f)})}function Yt(n){const r=n[t];r._windowIndex&&r._windowIndex.configure({pageSize:r._windowPageSize})}ke(e,t,L,"ln-data-store",{attributes:i}),window[t].clearAll=Jt,window[t].init=window[t],window[t].setStorageKey=Te,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.setStorageKey=Te)})()})();
|