@livenetworks/ashlar 2.1.8 → 2.1.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.
Files changed (75) hide show
  1. package/components/ln-accordion/ln-accordion.js +1 -1
  2. package/components/ln-ajax/ln-ajax.js +1 -1
  3. package/components/ln-api-connector/ln-api-connector.js +1 -1
  4. package/components/ln-api-queue/ln-api-queue.js +1 -1
  5. package/components/ln-autosave/ln-autosave.js +1 -1
  6. package/components/ln-chart/ln-chart.js +1 -1
  7. package/components/ln-circular-progress/ln-circular-progress.js +1 -1
  8. package/components/ln-confirm/ln-confirm.js +1 -1
  9. package/components/ln-core/README.md +25 -0
  10. package/components/ln-core/index.js +1 -0
  11. package/components/ln-core/ln-core.schema.json +14 -4
  12. package/components/ln-core/query.js +113 -0
  13. package/components/ln-couchdb-connector/ln-couchdb-connector.js +1 -1
  14. package/components/ln-data-coordinator/README.md +4 -0
  15. package/components/ln-data-coordinator/ln-data-coordinator.js +1 -1
  16. package/components/ln-data-store/ln-data-store.js +1 -1
  17. package/components/ln-date/ln-date.js +1 -1
  18. package/components/ln-debug/ln-debug.js +1 -1
  19. package/components/ln-debug/src/generated-attributes.js +2 -0
  20. package/components/ln-dropdown/ln-dropdown.js +1 -1
  21. package/components/ln-editor/ln-editor.js +1 -1
  22. package/components/ln-external-links/ln-external-links.js +1 -1
  23. package/components/ln-fill/ln-fill.js +1 -1
  24. package/components/ln-filter/README.md +1 -0
  25. package/components/ln-filter/ln-filter.js +1 -1
  26. package/components/ln-filter/ln-filter.schema.json +8 -0
  27. package/components/ln-filter/src/ln-filter.js +67 -2
  28. package/components/ln-form/ln-form.js +1 -1
  29. package/components/ln-http/ln-http.js +1 -1
  30. package/components/ln-icon/ln-icon.js +1 -1
  31. package/components/ln-include/ln-include.js +1 -1
  32. package/components/ln-key/ln-key.js +1 -1
  33. package/components/ln-link/ln-link.js +1 -1
  34. package/components/ln-list/ln-list.js +1 -1
  35. package/components/ln-modal/ln-modal.js +1 -1
  36. package/components/ln-nav/ln-nav.js +1 -1
  37. package/components/ln-number/ln-number.js +1 -1
  38. package/components/ln-obfuscator/ln-obfuscator.js +1 -1
  39. package/components/ln-options/ln-options.js +1 -1
  40. package/components/ln-persist/ln-persist.js +1 -1
  41. package/components/ln-picklist/ln-picklist.js +1 -1
  42. package/components/ln-popover/ln-popover.js +1 -1
  43. package/components/ln-progress/ln-progress.js +1 -1
  44. package/components/ln-router/ln-router.js +1 -1
  45. package/components/ln-scroll/ln-scroll.js +1 -1
  46. package/components/ln-search/README.md +1 -0
  47. package/components/ln-search/ln-search.js +1 -1
  48. package/components/ln-search/ln-search.schema.json +8 -0
  49. package/components/ln-search/src/ln-search.js +54 -2
  50. package/components/ln-slug/ln-slug.js +1 -1
  51. package/components/ln-sort/README.md +1 -0
  52. package/components/ln-sort/ln-sort.js +1 -1
  53. package/components/ln-sort/ln-sort.schema.json +112 -104
  54. package/components/ln-sort/src/ln-sort.js +78 -3
  55. package/components/ln-sortable/ln-sortable.js +1 -1
  56. package/components/ln-stat/ln-stat.js +1 -1
  57. package/components/ln-table/README.md +22 -3
  58. package/components/ln-table/ln-table.js +1 -1
  59. package/components/ln-table/ln-table.schema.json +8 -0
  60. package/components/ln-table/src/ln-table.js +72 -5
  61. package/components/ln-table-coordinator/ln-table-coordinator.js +1 -1
  62. package/components/ln-tabs/ln-tabs.js +1 -1
  63. package/components/ln-time/ln-time.js +1 -1
  64. package/components/ln-toast/ln-toast.js +1 -1
  65. package/components/ln-toggle/ln-toggle.js +1 -1
  66. package/components/ln-tooltip/ln-tooltip.js +1 -1
  67. package/components/ln-translations/ln-translations.js +1 -1
  68. package/components/ln-ui-coordinator/ln-ui-coordinator.js +1 -1
  69. package/components/ln-upload/ln-upload.js +1 -1
  70. package/components/ln-validate/ln-validate.js +1 -1
  71. package/components/ln-websocket-connector/ln-websocket-connector.js +1 -1
  72. package/ln-ashlar.html-data.json +9 -0
  73. package/package.json +1 -1
  74. package/theme/components/_ln-table.scss +9 -0
  75. package/web-types.json +15 -1
@@ -1 +1 @@
1
- (function(){"use strict";function P(){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 q(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 r=null;for(let i=1;i<t.length;i++)if(t[i]&&t[i].nodeType===1){r=t[i];break}if(!q(r))return}e.apply(console,t)}}function v(e,t,o){const r=o||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,r),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:r}))}function L(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){L(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function ce(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function ae(e,t){const o=!!(t&&t.typed),r=t&&t.exclude,i={},c=e.elements,l={};if(o)for(let a=0;a<c.length;a++){const n=c[a];n.name&&n.type==="checkbox"&&!n.disabled&&(l[n.name]=(l[n.name]||0)+1)}for(let a=0;a<c.length;a++){const n=c[a];if(!(!n.name||n.disabled||n.type==="file"||n.type==="submit"||n.type==="button")&&!(r&&n.matches&&n.matches(r)))if(n.type==="checkbox")o&&l[n.name]===1?i[n.name]=n.checked:(i[n.name]||(i[n.name]=[]),n.checked&&i[n.name].push(n.value));else if(n.type==="radio")n.checked&&(i[n.name]=n.value);else if(n.type==="select-multiple"){i[n.name]=[];for(let f=0;f<n.options.length;f++)n.options[f].selected&&i[n.name].push(n.options[f].value)}else if(o&&n.type==="hidden")i[n.name]=n.value;else if(o&&(n.type==="number"||n.type==="range")){const f=Number(n.value);i[n.name]=n.value===""||isNaN(f)?null:f}else i[n.name]=n.value}return i}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 o=e.elements,r=[],i={};for(let c=0;c<o.length;c++){const l=o[c];l.name&&l.type==="checkbox"&&(i[l.name]=(i[l.name]||0)+1)}for(let c=0;c<o.length;c++){const l=o[c];if(l.type==="file"||l.type==="submit"||l.type==="button")continue;const a=l.getAttribute("data-ln-fill-as")||l.name;if(!a||!(a in t))continue;const n=t[a];if(l.type==="checkbox"){if(Array.isArray(n))l.checked=n.indexOf(l.value)!==-1;else if(i[l.name]>1){const f=String(n).split(",").map(function(b){return b.trim()});l.checked=f.indexOf(l.value)!==-1}else l.checked=de(n);r.push(l)}else if(l.type==="radio")l.checked=l.value===String(n),r.push(l);else if(l.type==="select-multiple"){if(Array.isArray(n))for(let f=0;f<l.options.length;f++)l.options[f].selected=n.indexOf(l.options[f].value)!==-1;r.push(l)}else l.value=n,l.tagName==="SELECT"&&n!=null&&l.setAttribute("data-ln-value",n),r.push(l)}return r}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ue,window.lnCore.serializeForm=ae,window.lnCore.resolveFormMethod=ce);function k(...e){return e.filter(t=>t!=null&&t!=="").map((t,o)=>o===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function T(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function fe(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(o){return console.error(`[${t}] Invalid headers JSON:`,o),{}}}const H={};function he(e,t){H[e]=t}function we(e){return H[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=he,window.lnCore.getDataMapper=we);function be(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,L(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const U={};function pe(e,t){if(!e||typeof t!="object")return;const o=e.toLowerCase().split("-")[0];U[o]=t}function me(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return U[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=pe,window.lnCore.getLocaleFallback=me,window.lnCore.ensureLocaleObserver=be);const I={};function ge(e,t){I[e]||(I[e]=document.querySelector('[data-ln-template="'+e+'"]'));const o=I[e];return o?o.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function W(e,t){if(!e||!t)return e;const o=e.querySelectorAll("[data-ln-field]");for(let l=0;l<o.length;l++){const a=o[l],n=a.getAttribute("data-ln-field");t[n]!=null&&(a.textContent=t[n])}const r=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<r.length;l++){const a=r[l],n=a.getAttribute("data-ln-attr").split(",");for(let f=0;f<n.length;f++){const b=n[f].trim().split(":");if(b.length!==2)continue;const m=b[0].trim(),_=b[1].trim();t[_]!=null&&a.setAttribute(m,t[_])}}const i=e.querySelectorAll("[data-ln-show]");for(let l=0;l<i.length;l++){const a=i[l],n=a.getAttribute("data-ln-show");n in t&&a.classList.toggle("hidden",!t[n])}const c=e.querySelectorAll("[data-ln-class]");for(let l=0;l<c.length;l++){const a=c[l],n=a.getAttribute("data-ln-class").split(",");for(let f=0;f<n.length;f++){const b=n[f].trim().split(":");if(b.length!==2)continue;const m=b[0].trim(),_=b[1].trim();_ in t&&a.classList.toggle(m,!!t[_])}}return e}function Ce(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 r=0;r<o.length;r++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",o[r],t??null),o[r].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)W(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let o=0;o<t.length;o++)t[o].textContent=""}})));function J(e,t){if(!e||!t)return e;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;o.nextNode();){const c=o.currentNode;c.textContent.indexOf("{{")!==-1&&(c.textContent=c.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,a){return t[a]!==void 0?t[a]:""}))}const r=function(c,l){return t[l]!==void 0?t[l]:""},i=Array.from(e.querySelectorAll("*"));e.nodeType===1&&i.push(e);for(let c=0;c<i.length;c++){const l=i[c],a=l.attributes;for(let n=0;n<a.length;n++){const f=a[n];f.value.indexOf("{{")!==-1&&l.setAttribute(f.name,f.value.replace(/\{\{\s*(\w+)\s*\}\}/g,r))}}return e}function ye(e,t,o,r,i,c){const l={};for(let n=0;n<e.children.length;n++){const f=e.children[n],b=f.getAttribute("data-ln-render-key");b&&(l[b]=f)}const a=document.createDocumentFragment();for(let n=0;n<t.length;n++){const f=t[n],b=String(r(f));let m=l[b];if(m)i(m,f,n);else{const _=ge(o,c);if(!_||(J(_,f),m=_.firstElementChild,!m))continue;m.setAttribute("data-ln-render-key",b),i(m,f,n)}a.appendChild(m)}e.textContent="",e.appendChild(a)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=J,window.lnCore.fill=W,window.lnCore.lnFill=Ce,window.lnCore.renderList=ye);function O(e,t,o){const r=e.getAttribute(t);return r===null?o:r}function V(e,t,o){const r=parseInt(e.getAttribute(t),10);return isNaN(r)?o:r}function K(e,t,o=!1){const r=e.getAttribute(t);if(r===null)return!!o;const i=r.trim().toLowerCase();return!(i==="false"||i==="0")}function G(e,t){return(e.getAttribute(t)||"").split(",").map(o=>o.trim()).filter(Boolean)}const R=new Map;function z(e,t){const o=(e?e.join("|"):"")+"::"+t;if(R.has(o))return R.get(o);const r=new Set(e||[]),i=function(c,l){const a=c.getAttribute(l);return a!==null&&r.has(a)?a:t};return R.set(o,i),i}function Q(e,t,o){const r=parseFloat(e.getAttribute(t));return isNaN(r)?o:r}function X(e,t,o){const r=e.getAttribute(t);if(!r)return o;try{return JSON.parse(r)}catch{return o}}function Y(e,t,o,r,i){if(!e||t===null)return!0;const c=r||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const a=n=>{i?console.warn(n,i):console.warn(n)};if(l==="boolean"){const n=t.trim().toLowerCase();return n!==""&&n!=="true"&&n!=="false"&&n!=="1"&&n!=="0"?(a(`[${c}] Invalid value "${t}" for boolean attribute "${o}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const n=e.values||[];return n.includes(t)?!0:(a(`[${c}] Invalid value "${t}" for attribute "${o}". Allowed: ${n.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return a(`[${c}] Invalid integer "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1;const n=parseInt(t,10);return e.min!==void 0&&n<e.min?(a(`[${c}] Value ${n} for attribute "${o}" is less than min (${e.min}).`),!1):e.max!==void 0&&n>e.max?(a(`[${c}] Value ${n} for attribute "${o}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(a(`[${c}] Invalid float "${t}" for attribute "${o}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(n){return a(`[${c}] Invalid JSON for attribute "${o}": ${n.message}. Fallback: ${e.fallback}.`),!1}return!0}function Z(e,t,o){for(const r in o){const[i,c,l]=o[r];Object.defineProperty(e,r,{get:function(){return i(t,c,l)},enumerable:!0,configurable:!0})}return e}function ee(e){const t={};for(const o in e){const r=e[o];if(!r||!r.prop)continue;let i=r.read;if(!i&&r.type)switch(r.type){case"enum":i=z(r.values,r.fallback);break;case"integer":i=V;break;case"float":i=Q;break;case"boolean":i=K;break;case"list":i=G;break;case"json":i=X;break;case"string":default:i=O;break}i||(i=O),t[r.prop]=[i,o,r.fallback]}return t}function _e(e){const t={};for(const o in e){const r=e[o];r&&r.effect&&(t[o]=r.effect)}return Object.keys(t).length?t:null}function ve(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const 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=Z,window.lnCore.attrSpec=ee,window.lnCore.attrStr=O,window.lnCore.attrInt=V,window.lnCore.attrBool=K,window.lnCore.attrList=G,window.lnCore.attrEnum=z,window.lnCore.attrFloat=Q,window.lnCore.attrJson=X);function D(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(o){console.error("["+t.attribute+"] init failed",e,o)}}}function te(e,t,o,r){if(e.nodeType!==1)return;const c=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l={selector:t,attribute:o,ComponentFn:r};if(e.matches&&e.matches(c)&&D(e,l),e.querySelectorAll){const a=e.querySelectorAll(c);for(let n=0;n<a.length;n++)D(a[n],l)}}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 ke(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function ne(){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 xe(e){const t=ne(),o=e.observed||[];for(let r=0;r<o.length;r++){const i=o[r];t.byAttr.has(i)||t.byAttr.set(i,[]),t.byAttr.get(i).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const r in e.attributes){t.byDeclaredAttr.has(r)||t.byDeclaredAttr.set(r,[]);const i=t.byDeclaredAttr.get(r);i.some(c=>c.componentTag===e.componentTag)||i.push({spec:e.attributes[r],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const r=ve(e);if(r===null)t.reactiveWildcard.push(e);else for(const i of r)t.byReactive.has(i)||t.byReactive.set(i,[]),t.byReactive.get(i).push(e)}e.persist&&t.persist.push(e)}function oe(e,t,o,r){for(let i=0;i<e.length;i++){const c=e[i];if(!t[c.attribute])continue;const l=c.effects&&c.effects[o];l?l(t,o,r):c.onAttrChange&&(!c.declared||c.declared.has(o))&&c.onAttrChange(t,o,r)}}function Se(e){const t=e.attributeName,o=t.indexOf("data-ln-")===0,r=ne(),i=r.byAttr.get(t),c=P()&&r.byDeclaredAttr&&r.byDeclaredAttr.has(t);if(!o&&!i&&!c)return;const l=e.target;if(e.oldValue!==l.getAttribute(t)){if(c&&q(l)){const a=r.byDeclaredAttr.get(t),n=l.getAttribute(t);for(let f=0;f<a.length;f++)Y(a[f].spec,n,t,a[f].componentTag,l)}if(window.lnCore._debugSink&&(o||i)&&window.lnCore._debugSink("attr",t,l,{oldValue:e.oldValue,newValue:l.getAttribute(t)}),o){const a=r.byReactive.get(t);a&&oe(a,l,t,e.oldValue),r.reactiveWildcard.length&&oe(r.reactiveWildcard,l,t,e.oldValue)}if(i)for(let a=0;a<i.length;a++){const n=i[a];if(n.handler){n.handler(l,t,e.oldValue);continue}n.onAttributeChange&&l[n.attribute]?n.onAttributeChange(l,t):(te(l,n.selector,n.attribute,n.ComponentFn),n.onInit&&n.onInit(l))}}}function Ee(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,L(function(){new MutationObserver(function(t){for(let o=0;o<t.length;o++)try{Se(t[o])}catch(r){console.error("[ln-core] mutation handler failed",t[o].target,r)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function $(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function N(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function B(e,t){if(!document.contains(e))if(t.attribute){const o=e[t.attribute];if(o&&typeof o.destroy=="function")try{o.destroy()}catch(r){console.error("["+t.attribute+"] destroy failed",e,r)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function re(e){const t=$();if(!t.length)return;const o=e.target;if(o){const i=o.nodeType===1?o:o.parentElement;if(i&&(i.isContentEditable||i.closest&&i.closest('[contenteditable]:not([contenteditable="false"])')))return}const r=N();if(e.target&&r.length)for(let i=0;i<r.length;i++){const c=r[i],l=c.query,a=e.target.nodeType===1?e.target.matches&&e.target.matches(l)?e.target:e.target.closest?e.target.closest(l):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(l):null;a&&c.onSubtreeChange(a,e)}for(let i=0;i<e.addedNodes.length;i++){const c=e.addedNodes[i];if(c.nodeType===1){const l=!!(c.firstElementChild||c.children&&c.children.length);for(let a=0;a<t.length;a++){const n=t[a];if(n.selector&&n.attribute&&n.ComponentFn){if(!l)c.matches&&c.matches(n.query)&&D(c,n);else if(c.matches&&c.matches(n.query)&&D(c,n),c.querySelectorAll){const f=c.querySelectorAll(n.query);for(let b=0;b<f.length;b++)D(f[b],n)}}n.onInit&&n.onInit(c)}}}for(let i=0;i<e.removedNodes.length;i++){const c=e.removedNodes[i];if(c.nodeType===1){if(document.contains(c))continue;const l=!!(c.firstElementChild||c.children&&c.children.length);for(let a=0;a<t.length;a++){const n=t[a],f=n.query;if(f){if(!l)c.matches&&c.matches(f)&&B(c,n);else if(c.matches&&c.matches(f)&&B(c,n),c.querySelectorAll){const b=c.querySelectorAll(f);for(let m=0;m<b.length;m++)B(b[m],n)}}}}}}function ie(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,L(function(){const e=new MutationObserver(function(t){for(let o=0;o<t.length;o++){const r=t[o];if(r.type==="childList")try{re(r)}catch(i){console.error("[ln-core] lifecycle handler failed",r.target,i)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Oe(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const o=t.takeRecords();for(let r=0;r<o.length;r++){const i=o[r];if(i.type==="childList")try{re(i)}catch(c){console.error("[ln-core] lifecycle handler failed",i.target,c)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function Te(e){$().push(e),e.onSubtreeChange&&e.query&&N().push(e),ie()}function le(e,t,o,r,i={}){const c=i.extraAttributes||[],l=i.onAttributeChange||null,a=i.onSubtreeChange||null,n=i.onInit||null,f=i.onAttrChange||null,b=i.effects||null,m=i.attributes||null,_=m?_e(m):b,M=m?new Set(Object.keys(m)):null,s=i.persist||null;function u(w){const y=w||document.body;if(te(y,e,t,o),m&&P())for(const S in m){const x=m[S],E=Array.from(y.querySelectorAll("["+S+"]"));y.matches&&y.matches("["+S+"]")&&E.push(y);for(let A=0;A<E.length;A++){const j=E[A];q(j)&&Y(x,j.getAttribute(S),S,r,j)}}n&&n(y)}const d=[];if(e.indexOf("[")!==-1){const w=/\[([\w-]+)/g;let y;for(;(y=w.exec(e))!==null;)d.push(y[1])}else d.push(e);xe({selector:e,attribute:t,componentTag:r,attributes:m,ComponentFn:o,onInit:n,observed:d.concat(c),onAttributeChange:l,onAttrChange:f,effects:_,declared:M,persist:s}),Ee();const h=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,g=i.subtreeQuery||(h?e:"["+e+"]"),C={selector:e,attribute:t,ComponentFn:o,onInit:n,onSubtreeChange:a,query:g};$().push(C),a&&g&&N().push(C),ie(),window[t]=u,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=le,window.lnCore.observeLifecycle=Te,window.lnCore.withoutLifecycle=Oe);function p(){Ae()>0?ke(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p):p(),u}function se(e){return(e||"").replace(/^#/,"")}function F(e){const t=e===void 0?location.hash:e,o={},r=se(t);if(!r)return o;const i=r.split("&");for(let c=0;c<i.length;c++){const l=i[c];if(!l)continue;const a=l.indexOf(":"),n=a>-1?l.slice(0,a):l,f=a>-1?l.slice(a+1):"";if(n)try{o[n]=decodeURIComponent(f)}catch{o[n]=f}}return o}function De(e){if(!e)return null;const t=F();return e in t?t[e]:null}function Le(e,t){if(!e)return;const o=F();t==null?delete o[e]:o[e]=String(t);const i=Object.keys(o).map(function(c){const l=o[c];return l===""?c:c+":"+encodeURIComponent(l)}).join("&");se(location.hash)!==i&&(location.hash=i)}function je(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function qe(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 r=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return r?t?r+"-"+t:r:t||null}function Ie(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Re(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 $e(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ne(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const o=e.slice(0,t),r=e.slice(t+1),i=r?r.split(",").map(function(c){try{return decodeURIComponent(c)}catch{return c}}).filter(Boolean):[];return{key:o,values:i}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=F,window.lnCore.hashGet=De,window.lnCore.hashSet=Le,window.lnCore.hashLinkClick=je,window.lnCore.resolveHashNamespace=qe,window.lnCore.hashSortEncode=Ie,window.lnCore.hashSortDecode=Re,window.lnCore.hashFilterEncode=$e,window.lnCore.hashFilterDecode=Ne);function Be(){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=Be),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",o="lnConnector";if(window[t]!==void 0)return;function r(s){const u=s[t];u&&u.refreshConfig()}const i={"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:r,description:"CouchDB server base endpoint URL"},"data-ln-couchdb-db":{prop:"db",read:O,type:"string",fallback:"",effect:r,description:"Target CouchDB database name"},"data-ln-couchdb-auth":{prop:"auth",read:O,type:"string",fallback:"",effect:r,description:"Authentication credentials for CouchDB requests"},"data-ln-couchdb-headers":{effect:r,type:"json",fallback:null,description:"Custom HTTP headers in JSON or semicolon-separated format"}},c=ee(i);function l(s){const u=s&&s.content!==void 0?s.content:s,d=s&&s.message?s.message:null;return{content:u,message:d}}function a(s){return this.dom=s,Z(this,s,c),s[t]=this,s[o]=this,this.namespace="ln-couchdb-connector",this.refreshConfig(),this._deltaController=null,this._handlers=null,M(this),this}a.prototype.refreshConfig=function(){const s=this.dom;this.credentials="same-origin";const u=s.getAttribute("data-ln-couchdb-headers")||"";this.headers=fe(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."),v(s,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function n(s,u,d){const h=Object.assign({},T(s.headers,s.auth),d||{});return u&&(h["Idempotency-Key"]=u),h}a.prototype.fetchDelta=function(s){const u=this;this._deltaController&&this._deltaController.abort(),this._deltaController=new AbortController;const d=this._deltaController.signal,h=["include_docs=true","feed=normal"];s&&h.push("since="+encodeURIComponent(s));const g=k(u.url,u.db,"_changes")+"?"+h.join("&");return window.fetch(g,{method:"GET",headers:T(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||s||""}}).finally(()=>{u._deltaController&&u._deltaController.signal===d&&(u._deltaController=null)})};function f(s,u,d){const h=Object.assign({_id:u.id},u);return h._id||delete h._id,window.fetch(k(s.url,s.db),{method:"POST",headers:n(s,d),credentials:s.credentials,body:JSON.stringify(h)}).then(g=>{if(!g.ok)throw new Error("HTTP "+g.status+": "+g.statusText);return g.json()}).then(g=>{const C=l(g),p=C.content;return{record:Object.assign({},h,{id:p.id,_id:p.id,_rev:p.rev}),message:C.message}})}a.prototype.create=function(s,u){return f(this,s,u).then(d=>d.record)};function b(s,u,d,h){const g=Object.assign({id:String(u),_id:String(u)},d),C=g._rev||g.rev;return(C?Promise.resolve(C):window.fetch(k(s.url,s.db,null,u),{method:"GET",headers:T(s.headers,s.auth),credentials:s.credentials}).then(w=>{if(!w.ok)throw new Error("Could not retrieve document for revision mapping");return w.json().then(y=>y._rev)})).then(w=>{const y=Object.assign({},g,{_rev:w});delete y.rev;const S=n(s,h,{"If-Match":w});return window.fetch(k(s.url,s.db,null,u),{method:"PUT",headers:S,credentials:s.credentials,body:JSON.stringify(y)}).then(x=>{if(x.ok)return x.json().then(E=>{const A=l(E);return{record:Object.assign({},y,{_rev:A.content.rev}),message:A.message}});if(x.status===409)return x.json().then(E=>{const A=new Error("Conflict");throw A.status=409,A.data=E,A});throw new Error("HTTP "+x.status+": "+x.statusText)})})}a.prototype.update=function(s,u,d){return b(this,s,u,d).then(h=>h.record)};function m(s,u,d,h){return(d?Promise.resolve(d):window.fetch(k(s.url,s.db,null,u),{method:"GET",headers:T(s.headers,s.auth),credentials:s.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=k(s.url,s.db,null,u)+"?rev="+encodeURIComponent(C);return window.fetch(p,{method:"DELETE",headers:n(s,h),credentials:s.credentials}).then(w=>{if(!w.ok)throw new Error("HTTP "+w.status+": "+w.statusText);return w.json()}).then(w=>{const y=l(w);return{response:y.content,message:y.message}})})}a.prototype.delete=function(s,u,d){return m(this,s,u,d).then(h=>h.response)};function _(s,u,d){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(k(s.url,s.db,"_all_docs"),{method:"POST",headers:T(s.headers,s.auth),credentials:s.credentials,body:JSON.stringify({keys:u})}).then(h=>{if(!h.ok)throw new Error("HTTP "+h.status+": "+h.statusText);return h.json()}).then(h=>{const C=(h.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(k(s.url,s.db,"_bulk_docs"),{method:"POST",headers:n(s,d),credentials:s.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=l(p);return{response:{ok:!0,results:w.content,deletedCount:C.length},message:w.message}})})}a.prototype.bulkDelete=function(s,u){return _(this,s,u).then(d=>d.response)};function M(s){s._handlers={sync:function(u){const d=u.detail||{};s.fetchDelta(d.since).then(function(h){v(s.dom,"ln-couchdb-connector:fetched",{data:h,since:d.since,meta:d.meta||null})}).catch(function(h){h&&h.name==="AbortError"||v(s.dom,"ln-couchdb-connector:error",{action:"sync",error:h.message,status:h.status||0,since:d.since,meta:d.meta||null})})},create:function(u){const d=u.detail||{};f(s,d.data,d.idempotencyKey).then(function(h){v(s.dom,"ln-couchdb-connector:created",{record:h.record,tempId:d.tempId,message:h.message,meta:d.meta||null})}).catch(function(h){v(s.dom,"ln-couchdb-connector:error",{action:"create",error:h.message,status:h.status||0,tempId:d.tempId,meta:d.meta||null})})},update:function(u){const d=u.detail||{},h=Object.assign({},d.data);d.expected_version!==void 0&&(h._rev=d.expected_version),b(s,d.id,h,d.idempotencyKey).then(function(g){v(s.dom,"ln-couchdb-connector:updated",{record:g.record,id:d.id,message:g.message,meta:d.meta||null})}).catch(function(g){v(s.dom,"ln-couchdb-connector:error",{action:"update",error:g.message,status:g.status||0,id:d.id,data:g.status===409?g.data:null,conflictData:g.status===409?g.data:null,meta:d.meta||null})})},delete:function(u){const d=u.detail||{};m(s,d.id,d.rev,d.idempotencyKey).then(function(h){v(s.dom,"ln-couchdb-connector:deleted",{response:h.response,id:d.id,message:h.message,meta:d.meta||null})}).catch(function(h){v(s.dom,"ln-couchdb-connector:error",{action:"delete",error:h.message,status:h.status||0,id:d.id,meta:d.meta||null})})},bulkDelete:function(u){const d=u.detail||{};_(s,d.ids,d.idempotencyKey).then(function(h){v(s.dom,"ln-couchdb-connector:bulk-deleted",{response:h.response,ids:d.ids,message:h.message,meta:d.meta||null})}).catch(function(h){v(s.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:h.message,status:h.status||0,ids:d.ids,meta:d.meta||null})})}},s.dom.addEventListener("ln-couchdb-connector:request-sync",s._handlers.sync),s.dom.addEventListener("ln-couchdb-connector:request-create",s._handlers.create),s.dom.addEventListener("ln-couchdb-connector:request-update",s._handlers.update),s.dom.addEventListener("ln-couchdb-connector:request-delete",s._handlers.delete),s.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",s._handlers.bulkDelete)}a.prototype.destroy=function(){if(!this.dom[t])return;const s=this;s._deltaController&&(s._deltaController.abort(),s._deltaController=null),s._handlers&&(s.dom.removeEventListener("ln-couchdb-connector:request-sync",s._handlers.sync),s.dom.removeEventListener("ln-couchdb-connector:request-create",s._handlers.create),s.dom.removeEventListener("ln-couchdb-connector:request-update",s._handlers.update),s.dom.removeEventListener("ln-couchdb-connector:request-delete",s._handlers.delete),s.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",s._handlers.bulkDelete),s._handlers=null),delete this.dom[t],delete this.dom[o]},le(e,t,a,"ln-couchdb-connector",{attributes:i})})()})();
1
+ (function(){"use strict";function M(){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 j(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 i=1;i<t.length;i++)if(t[i]&&t[i].nodeType===1){o=t[i];break}if(!j(o))return}e.apply(console,t)}}function v(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 L(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){L(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function le(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function ae(e,t){const n=!!(t&&t.typed),o=t&&t.exclude,i={},l=e.elements,c={};if(n)for(let a=0;a<l.length;a++){const r=l[a];r.name&&r.type==="checkbox"&&!r.disabled&&(c[r.name]=(c[r.name]||0)+1)}for(let a=0;a<l.length;a++){const r=l[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&&c[r.name]===1?i[r.name]=r.checked:(i[r.name]||(i[r.name]=[]),r.checked&&i[r.name].push(r.value));else if(r.type==="radio")r.checked&&(i[r.name]=r.value);else if(r.type==="select-multiple"){i[r.name]=[];for(let f=0;f<r.options.length;f++)r.options[f].selected&&i[r.name].push(r.options[f].value)}else if(n&&r.type==="hidden")i[r.name]=r.value;else if(n&&(r.type==="number"||r.type==="range")){const f=Number(r.value);i[r.name]=r.value===""||isNaN(f)?null:f}else i[r.name]=r.value}return i}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 n=e.elements,o=[],i={};for(let l=0;l<n.length;l++){const c=n[l];c.name&&c.type==="checkbox"&&(i[c.name]=(i[c.name]||0)+1)}for(let l=0;l<n.length;l++){const c=n[l];if(c.type==="file"||c.type==="submit"||c.type==="button")continue;const a=c.getAttribute("data-ln-fill-as")||c.name;if(!a||!(a in t))continue;const r=t[a];if(c.type==="checkbox"){if(Array.isArray(r))c.checked=r.indexOf(c.value)!==-1;else if(i[c.name]>1){const f=String(r).split(",").map(function(b){return b.trim()});c.checked=f.indexOf(c.value)!==-1}else c.checked=de(r);o.push(c)}else if(c.type==="radio")c.checked=c.value===String(r),o.push(c);else if(c.type==="select-multiple"){if(Array.isArray(r))for(let f=0;f<c.options.length;f++)c.options[f].selected=r.indexOf(c.options[f].value)!==-1;o.push(c)}else c.value=r,c.tagName==="SELECT"&&r!=null&&c.setAttribute("data-ln-value",r),o.push(c)}return o}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=ue,window.lnCore.serializeForm=ae,window.lnCore.resolveFormMethod=le);function k(...e){return e.filter(t=>t!=null&&t!=="").map((t,n)=>n===0?t.replace(/\/+$/,""):t.replace(/^\/+/,"").replace(/\/+$/,"")).filter(Boolean).join("/")}function T(e,t){return Object.assign({"Content-Type":"application/json",Accept:"application/json"},e,t?{Authorization:t}:null)}function fe(e,t="ln-core"){try{return e?JSON.parse(e):{}}catch(n){return console.error(`[${t}] Invalid headers JSON:`,n),{}}}const U={};function he(e,t){U[e]=t}function we(e){return U[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=he,window.lnCore.getDataMapper=we);function be(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,L(function(){new MutationObserver(function(){v(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const H={};function pe(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];H[n]=t}function me(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return H[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=pe,window.lnCore.getLocaleFallback=me,window.lnCore.ensureLocaleObserver=be);const I={};function ge(e,t){I[e]||(I[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=I[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function W(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let c=0;c<n.length;c++){const a=n[c],r=a.getAttribute("data-ln-field");t[r]!=null&&(a.textContent=t[r])}const o=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<o.length;c++){const a=o[c],r=a.getAttribute("data-ln-attr").split(",");for(let f=0;f<r.length;f++){const b=r[f].trim().split(":");if(b.length!==2)continue;const m=b[0].trim(),_=b[1].trim();t[_]!=null&&a.setAttribute(m,t[_])}}const i=e.querySelectorAll("[data-ln-show]");for(let c=0;c<i.length;c++){const a=i[c],r=a.getAttribute("data-ln-show");r in t&&a.classList.toggle("hidden",!t[r])}const l=e.querySelectorAll("[data-ln-class]");for(let c=0;c<l.length;c++){const a=l[c],r=a.getAttribute("data-ln-class").split(",");for(let f=0;f<r.length;f++){const b=r[f].trim().split(":");if(b.length!==2)continue;const m=b[0].trim(),_=b[1].trim();_ in t&&a.classList.toggle(m,!!t[_])}}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 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)W(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 J(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const l=n.currentNode;l.textContent.indexOf("{{")!==-1&&(l.textContent=l.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,a){return t[a]!==void 0?t[a]:""}))}const o=function(l,c){return t[c]!==void 0?t[c]:""},i=Array.from(e.querySelectorAll("*"));e.nodeType===1&&i.push(e);for(let l=0;l<i.length;l++){const c=i[l],a=c.attributes;for(let r=0;r<a.length;r++){const f=a[r];f.value.indexOf("{{")!==-1&&c.setAttribute(f.name,f.value.replace(/\{\{\s*(\w+)\s*\}\}/g,o))}}return e}function Ce(e,t,n,o,i,l){const c={};for(let r=0;r<e.children.length;r++){const f=e.children[r],b=f.getAttribute("data-ln-render-key");b&&(c[b]=f)}const a=document.createDocumentFragment();for(let r=0;r<t.length;r++){const f=t[r],b=String(o(f));let m=c[b];if(m)i(m,f,r);else{const _=ge(n,l);if(!_||(J(_,f),m=_.firstElementChild,!m))continue;m.setAttribute("data-ln-render-key",b),i(m,f,r)}a.appendChild(m)}e.textContent="",e.appendChild(a)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=J,window.lnCore.fill=W,window.lnCore.lnFill=ye,window.lnCore.renderList=Ce);function O(e,t,n){const o=e.getAttribute(t);return o===null?n:o}function V(e,t,n){const o=parseInt(e.getAttribute(t),10);return isNaN(o)?n:o}function G(e,t,n=!1){const o=e.getAttribute(t);if(o===null)return!!n;const i=o.trim().toLowerCase();return!(i==="false"||i==="0")}function K(e,t){return(e.getAttribute(t)||"").split(",").map(n=>n.trim()).filter(Boolean)}const R=new Map;function Q(e,t){const n=(e?e.join("|"):"")+"::"+t;if(R.has(n))return R.get(n);const o=new Set(e||[]),i=function(l,c){const a=l.getAttribute(c);return a!==null&&o.has(a)?a:t};return R.set(n,i),i}function z(e,t,n){const o=parseFloat(e.getAttribute(t));return isNaN(o)?n:o}function X(e,t,n){const o=e.getAttribute(t);if(!o)return n;try{return JSON.parse(o)}catch{return n}}function Y(e,t,n,o,i){if(!e||t===null)return!0;const l=o||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const a=r=>{i?console.warn(r,i):console.warn(r)};if(c==="boolean"){const r=t.trim().toLowerCase();return r!==""&&r!=="true"&&r!=="false"&&r!=="1"&&r!=="0"?(a(`[${l}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const r=e.values||[];return r.includes(t)?!0:(a(`[${l}] Invalid value "${t}" for attribute "${n}". Allowed: ${r.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return a(`[${l}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const r=parseInt(t,10);return e.min!==void 0&&r<e.min?(a(`[${l}] Value ${r} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&r>e.max?(a(`[${l}] Value ${r} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(a(`[${l}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(r){return a(`[${l}] Invalid JSON for attribute "${n}": ${r.message}. Fallback: ${e.fallback}.`),!1}return!0}function Z(e,t,n){for(const o in n){const[i,l,c]=n[o];Object.defineProperty(e,o,{get:function(){return i(t,l,c)},enumerable:!0,configurable:!0})}return e}function ee(e){const t={};for(const n in e){const o=e[n];if(!o||!o.prop)continue;let i=o.read;if(!i&&o.type)switch(o.type){case"enum":i=Q(o.values,o.fallback);break;case"integer":i=V;break;case"float":i=z;break;case"boolean":i=G;break;case"list":i=K;break;case"json":i=X;break;case"string":default:i=O;break}i||(i=O),t[o.prop]=[i,n,o.fallback]}return t}function _e(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 ve(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=ee,window.lnCore.attrStr=O,window.lnCore.attrInt=V,window.lnCore.attrBool=G,window.lnCore.attrList=K,window.lnCore.attrEnum=Q,window.lnCore.attrFloat=z,window.lnCore.attrJson=X);function D(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(n){console.error("["+t.attribute+"] init failed",e,n)}}}function te(e,t,n,o){if(e.nodeType!==1)return;const l=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:n,ComponentFn:o};if(e.matches&&e.matches(l)&&D(e,c),e.querySelectorAll){const a=e.querySelectorAll(l);for(let r=0;r<a.length;r++)D(a[r],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 ke(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function ne(){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 Se(e){const t=ne(),n=e.observed||[];for(let o=0;o<n.length;o++){const i=n[o];t.byAttr.has(i)||t.byAttr.set(i,[]),t.byAttr.get(i).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 i=t.byDeclaredAttr.get(o);i.some(l=>l.componentTag===e.componentTag)||i.push({spec:e.attributes[o],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const o=ve(e);if(o===null)t.reactiveWildcard.push(e);else for(const i of o)t.byReactive.has(i)||t.byReactive.set(i,[]),t.byReactive.get(i).push(e)}e.persist&&t.persist.push(e)}function re(e,t,n,o){for(let i=0;i<e.length;i++){const l=e[i];if(!t[l.attribute])continue;const c=l.effects&&l.effects[n];c?c(t,n,o):l.onAttrChange&&(!l.declared||l.declared.has(n))&&l.onAttrChange(t,n,o)}}function xe(e){const t=e.attributeName,n=t.indexOf("data-ln-")===0,o=ne(),i=o.byAttr.get(t),l=M()&&o.byDeclaredAttr&&o.byDeclaredAttr.has(t);if(!n&&!i&&!l)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(l&&j(c)){const a=o.byDeclaredAttr.get(t),r=c.getAttribute(t);for(let f=0;f<a.length;f++)Y(a[f].spec,r,t,a[f].componentTag,c)}if(window.lnCore._debugSink&&(n||i)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),n){const a=o.byReactive.get(t);a&&re(a,c,t,e.oldValue),o.reactiveWildcard.length&&re(o.reactiveWildcard,c,t,e.oldValue)}if(i)for(let a=0;a<i.length;a++){const r=i[a];if(r.handler){r.handler(c,t,e.oldValue);continue}r.onAttributeChange&&c[r.attribute]?r.onAttributeChange(c,t):(te(c,r.selector,r.attribute,r.ComponentFn),r.onInit&&r.onInit(c))}}}function Ee(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,L(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{xe(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 F(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function $(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function N(e,t){if(!document.contains(e))if(t.attribute){const n=e[t.attribute];if(n&&typeof n.destroy=="function")try{n.destroy()}catch(o){console.error("["+t.attribute+"] destroy failed",e,o)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function oe(e){const t=F();if(!t.length)return;const n=e.target;if(n){const i=n.nodeType===1?n:n.parentElement;if(i&&(i.isContentEditable||i.closest&&i.closest('[contenteditable]:not([contenteditable="false"])')))return}const o=$();if(e.target&&o.length)for(let i=0;i<o.length;i++){const l=o[i],c=l.query,a=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;a&&l.onSubtreeChange(a,e)}for(let i=0;i<e.addedNodes.length;i++){const l=e.addedNodes[i];if(l.nodeType===1){const c=!!(l.firstElementChild||l.children&&l.children.length);for(let a=0;a<t.length;a++){const r=t[a];if(r.selector&&r.attribute&&r.ComponentFn){if(!c)l.matches&&l.matches(r.query)&&D(l,r);else if(l.matches&&l.matches(r.query)&&D(l,r),l.querySelectorAll){const f=l.querySelectorAll(r.query);for(let b=0;b<f.length;b++)D(f[b],r)}}r.onInit&&r.onInit(l)}}}for(let i=0;i<e.removedNodes.length;i++){const l=e.removedNodes[i];if(l.nodeType===1){if(document.contains(l))continue;const c=!!(l.firstElementChild||l.children&&l.children.length);for(let a=0;a<t.length;a++){const r=t[a],f=r.query;if(f){if(!c)l.matches&&l.matches(f)&&N(l,r);else if(l.matches&&l.matches(f)&&N(l,r),l.querySelectorAll){const b=l.querySelectorAll(f);for(let m=0;m<b.length;m++)N(b[m],r)}}}}}}function ie(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,L(function(){const e=new MutationObserver(function(t){for(let n=0;n<t.length;n++){const o=t[n];if(o.type==="childList")try{oe(o)}catch(i){console.error("[ln-core] lifecycle handler failed",o.target,i)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Oe(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const n=t.takeRecords();for(let o=0;o<n.length;o++){const i=n[o];if(i.type==="childList")try{oe(i)}catch(l){console.error("[ln-core] lifecycle handler failed",i.target,l)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function Te(e){F().push(e),e.onSubtreeChange&&e.query&&$().push(e),ie()}function ce(e,t,n,o,i={}){const l=i.extraAttributes||[],c=i.onAttributeChange||null,a=i.onSubtreeChange||null,r=i.onInit||null,f=i.onAttrChange||null,b=i.effects||null,m=i.attributes||null,_=m?_e(m):b,P=m?new Set(Object.keys(m)):null,s=i.persist||null;function u(w){const C=w||document.body;if(te(C,e,t,n),m&&M())for(const x in m){const S=m[x],E=Array.from(C.querySelectorAll("["+x+"]"));C.matches&&C.matches("["+x+"]")&&E.push(C);for(let A=0;A<E.length;A++){const q=E[A];j(q)&&Y(S,q.getAttribute(x),x,o,q)}}r&&r(C)}const d=[];if(e.indexOf("[")!==-1){const w=/\[([\w-]+)/g;let C;for(;(C=w.exec(e))!==null;)d.push(C[1])}else d.push(e);Se({selector:e,attribute:t,componentTag:o,attributes:m,ComponentFn:n,onInit:r,observed:d.concat(l),onAttributeChange:c,onAttrChange:f,effects:_,declared:P,persist:s}),Ee();const h=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,g=i.subtreeQuery||(h?e:"["+e+"]"),y={selector:e,attribute:t,ComponentFn:n,onInit:r,onSubtreeChange:a,query:g};F().push(y),a&&g&&$().push(y),ie(),window[t]=u,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ce,window.lnCore.observeLifecycle=Te,window.lnCore.withoutLifecycle=Oe);function p(){Ae()>0?ke(function(){u(document.body)}):u(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",p):p(),u}function se(e){return(e||"").replace(/^#/,"")}function B(e){const t=e===void 0?location.hash:e,n={},o=se(t);if(!o)return n;const i=o.split("&");for(let l=0;l<i.length;l++){const c=i[l];if(!c)continue;const a=c.indexOf(":"),r=a>-1?c.slice(0,a):c,f=a>-1?c.slice(a+1):"";if(r)try{n[r]=decodeURIComponent(f)}catch{n[r]=f}}return n}function De(e){if(!e)return null;const t=B();return e in t?t[e]:null}function Le(e,t){if(!e)return;const n=B();t==null?delete n[e]:n[e]=String(t);const i=Object.keys(n).map(function(l){const c=n[l];return c===""?l:l+":"+encodeURIComponent(c)}).join("&");se(location.hash)!==i&&(location.hash=i)}function qe(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function je(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 Ie(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Re(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 Fe(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 n=e.slice(0,t),o=e.slice(t+1),i=o?o.split(",").map(function(l){try{return decodeURIComponent(l)}catch{return l}}).filter(Boolean):[];return{key:n,values:i}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=B,window.lnCore.hashGet=De,window.lnCore.hashSet=Le,window.lnCore.hashLinkClick=qe,window.lnCore.resolveHashNamespace=je,window.lnCore.hashSortEncode=Ie,window.lnCore.hashSortDecode=Re,window.lnCore.hashFilterEncode=Fe,window.lnCore.hashFilterDecode=$e);function Ne(e){return(e||"").replace(/^\?/,"")}function Be(e){const t=e===void 0?typeof window<"u"?window.location.search:"":e,n={},o=Ne(t);if(!o)return n;const i=new URLSearchParams(o);for(const[l,c]of i.entries())n[l]=c;return n}function Pe(e){if(!e||typeof window>"u")return null;const t=new URLSearchParams(window.location.search);return t.has(e)?t.get(e):null}function Me(e,t){if(!e||typeof window>"u")return;const n=new URL(window.location.href);if(t==null||t===""?n.searchParams.delete(e):n.searchParams.set(e,String(t)),n.search===window.location.search)return;const o=n.pathname+n.search+n.hash;window.history.replaceState(window.history.state,"",o)}function Ue(e,t){if(!e||!e.hasAttribute("data-ln-query"))return null;const n=e.getAttribute("data-ln-query");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 He(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function We(e,t){if(e&&typeof e=="string"){if(e.endsWith(".asc"))return{fieldOrColumn:e.slice(0,-4),direction:"asc"};if(e.endsWith(".desc"))return{fieldOrColumn:e.slice(0,-5),direction:"desc"}}if(t&&typeof t=="object"){const n=t.sort_field||t.sort_by;if(n){const o=t.sort_dir&&String(t.sort_dir).toLowerCase()==="desc"?"desc":"asc";return{fieldOrColumn:n,direction:o}}}return null}function Je(e){return!Array.isArray(e)||e.length===0?null:e.map(encodeURIComponent).join(",")}function Ve(e){return!e||typeof e!="string"?[]:e.split(",").map(function(t){try{return decodeURIComponent(t.trim())}catch{return t.trim()}}).filter(Boolean)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.queryParse=Be,window.lnCore.queryGet=Pe,window.lnCore.querySet=Me,window.lnCore.resolveQueryParam=Ue,window.lnCore.querySortEncode=He,window.lnCore.querySortDecode=We,window.lnCore.queryFilterEncode=Je,window.lnCore.queryFilterDecode=Ve);function Ge(){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=Ge),(function(){const e="data-ln-couchdb-connector",t="lnCouchDbConnector",n="lnConnector";if(window[t]!==void 0)return;function o(s){const u=s[t];u&&u.refreshConfig()}const i={"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"}},l=ee(i);function c(s){const u=s&&s.content!==void 0?s.content:s,d=s&&s.message?s.message:null;return{content:u,message:d}}function a(s){return this.dom=s,Z(this,s,l),s[t]=this,s[n]=this,this.namespace="ln-couchdb-connector",this.refreshConfig(),this._deltaController=null,this._handlers=null,P(this),this}a.prototype.refreshConfig=function(){const s=this.dom;this.credentials="same-origin";const u=s.getAttribute("data-ln-couchdb-headers")||"";this.headers=fe(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."),v(s,"ln-couchdb-connector:config-changed",{url:this.url,db:this.db,auth:this.auth?"[REDACTED]":"",headers:this.headers})};function r(s,u,d){const h=Object.assign({},T(s.headers,s.auth),d||{});return u&&(h["Idempotency-Key"]=u),h}a.prototype.fetchDelta=function(s){const u=this;this._deltaController&&this._deltaController.abort(),this._deltaController=new AbortController;const d=this._deltaController.signal,h=["include_docs=true","feed=normal"];s&&h.push("since="+encodeURIComponent(s));const g=k(u.url,u.db,"_changes")+"?"+h.join("&");return window.fetch(g,{method:"GET",headers:T(u.headers,u.auth),credentials:u.credentials,signal:d}).then(y=>{if(!y.ok)throw new Error("HTTP "+y.status+": "+y.statusText);return y.json()}).then(y=>{const p=y.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:y.last_seq||s||""}}).finally(()=>{u._deltaController&&u._deltaController.signal===d&&(u._deltaController=null)})};function f(s,u,d){const h=Object.assign({_id:u.id},u);return h._id||delete h._id,window.fetch(k(s.url,s.db),{method:"POST",headers:r(s,d),credentials:s.credentials,body:JSON.stringify(h)}).then(g=>{if(!g.ok)throw new Error("HTTP "+g.status+": "+g.statusText);return g.json()}).then(g=>{const y=c(g),p=y.content;return{record:Object.assign({},h,{id:p.id,_id:p.id,_rev:p.rev}),message:y.message}})}a.prototype.create=function(s,u){return f(this,s,u).then(d=>d.record)};function b(s,u,d,h){const g=Object.assign({id:String(u),_id:String(u)},d),y=g._rev||g.rev;return(y?Promise.resolve(y):window.fetch(k(s.url,s.db,null,u),{method:"GET",headers:T(s.headers,s.auth),credentials:s.credentials}).then(w=>{if(!w.ok)throw new Error("Could not retrieve document for revision mapping");return w.json().then(C=>C._rev)})).then(w=>{const C=Object.assign({},g,{_rev:w});delete C.rev;const x=r(s,h,{"If-Match":w});return window.fetch(k(s.url,s.db,null,u),{method:"PUT",headers:x,credentials:s.credentials,body:JSON.stringify(C)}).then(S=>{if(S.ok)return S.json().then(E=>{const A=c(E);return{record:Object.assign({},C,{_rev:A.content.rev}),message:A.message}});if(S.status===409)return S.json().then(E=>{const A=new Error("Conflict");throw A.status=409,A.data=E,A});throw new Error("HTTP "+S.status+": "+S.statusText)})})}a.prototype.update=function(s,u,d){return b(this,s,u,d).then(h=>h.record)};function m(s,u,d,h){return(d?Promise.resolve(d):window.fetch(k(s.url,s.db,null,u),{method:"GET",headers:T(s.headers,s.auth),credentials:s.credentials}).then(y=>{if(!y.ok)throw new Error("Could not retrieve document for revision delete");return y.json().then(p=>p._rev)})).then(y=>{const p=k(s.url,s.db,null,u)+"?rev="+encodeURIComponent(y);return window.fetch(p,{method:"DELETE",headers:r(s,h),credentials:s.credentials}).then(w=>{if(!w.ok)throw new Error("HTTP "+w.status+": "+w.statusText);return w.json()}).then(w=>{const C=c(w);return{response:C.content,message:C.message}})})}a.prototype.delete=function(s,u,d){return m(this,s,u,d).then(h=>h.response)};function _(s,u,d){return!u||u.length===0?Promise.resolve({response:{ok:!0,deletedCount:0},message:null}):window.fetch(k(s.url,s.db,"_all_docs"),{method:"POST",headers:T(s.headers,s.auth),credentials:s.credentials,body:JSON.stringify({keys:u})}).then(h=>{if(!h.ok)throw new Error("HTTP "+h.status+": "+h.statusText);return h.json()}).then(h=>{const y=(h.rows||[]).filter(p=>!p.error&&p.value&&p.value.rev).map(p=>({_id:p.id,_rev:p.value.rev,_deleted:!0}));return y.length===0?{response:{ok:!0,deletedCount:0},message:null}:window.fetch(k(s.url,s.db,"_bulk_docs"),{method:"POST",headers:r(s,d),credentials:s.credentials,body:JSON.stringify({docs:y})}).then(p=>{if(!p.ok)throw new Error("HTTP "+p.status+": "+p.statusText);return p.json()}).then(p=>{const w=c(p);return{response:{ok:!0,results:w.content,deletedCount:y.length},message:w.message}})})}a.prototype.bulkDelete=function(s,u){return _(this,s,u).then(d=>d.response)};function P(s){s._handlers={sync:function(u){const d=u.detail||{};s.fetchDelta(d.since).then(function(h){v(s.dom,"ln-couchdb-connector:fetched",{data:h,since:d.since,meta:d.meta||null})}).catch(function(h){h&&h.name==="AbortError"||v(s.dom,"ln-couchdb-connector:error",{action:"sync",error:h.message,status:h.status||0,since:d.since,meta:d.meta||null})})},create:function(u){const d=u.detail||{};f(s,d.data,d.idempotencyKey).then(function(h){v(s.dom,"ln-couchdb-connector:created",{record:h.record,tempId:d.tempId,message:h.message,meta:d.meta||null})}).catch(function(h){v(s.dom,"ln-couchdb-connector:error",{action:"create",error:h.message,status:h.status||0,tempId:d.tempId,meta:d.meta||null})})},update:function(u){const d=u.detail||{},h=Object.assign({},d.data);d.expected_version!==void 0&&(h._rev=d.expected_version),b(s,d.id,h,d.idempotencyKey).then(function(g){v(s.dom,"ln-couchdb-connector:updated",{record:g.record,id:d.id,message:g.message,meta:d.meta||null})}).catch(function(g){v(s.dom,"ln-couchdb-connector:error",{action:"update",error:g.message,status:g.status||0,id:d.id,data:g.status===409?g.data:null,conflictData:g.status===409?g.data:null,meta:d.meta||null})})},delete:function(u){const d=u.detail||{};m(s,d.id,d.rev,d.idempotencyKey).then(function(h){v(s.dom,"ln-couchdb-connector:deleted",{response:h.response,id:d.id,message:h.message,meta:d.meta||null})}).catch(function(h){v(s.dom,"ln-couchdb-connector:error",{action:"delete",error:h.message,status:h.status||0,id:d.id,meta:d.meta||null})})},bulkDelete:function(u){const d=u.detail||{};_(s,d.ids,d.idempotencyKey).then(function(h){v(s.dom,"ln-couchdb-connector:bulk-deleted",{response:h.response,ids:d.ids,message:h.message,meta:d.meta||null})}).catch(function(h){v(s.dom,"ln-couchdb-connector:error",{action:"bulk-delete",error:h.message,status:h.status||0,ids:d.ids,meta:d.meta||null})})}},s.dom.addEventListener("ln-couchdb-connector:request-sync",s._handlers.sync),s.dom.addEventListener("ln-couchdb-connector:request-create",s._handlers.create),s.dom.addEventListener("ln-couchdb-connector:request-update",s._handlers.update),s.dom.addEventListener("ln-couchdb-connector:request-delete",s._handlers.delete),s.dom.addEventListener("ln-couchdb-connector:request-bulk-delete",s._handlers.bulkDelete)}a.prototype.destroy=function(){if(!this.dom[t])return;const s=this;s._deltaController&&(s._deltaController.abort(),s._deltaController=null),s._handlers&&(s.dom.removeEventListener("ln-couchdb-connector:request-sync",s._handlers.sync),s.dom.removeEventListener("ln-couchdb-connector:request-create",s._handlers.create),s.dom.removeEventListener("ln-couchdb-connector:request-update",s._handlers.update),s.dom.removeEventListener("ln-couchdb-connector:request-delete",s._handlers.delete),s.dom.removeEventListener("ln-couchdb-connector:request-bulk-delete",s._handlers.bulkDelete),s._handlers=null),delete this.dom[t],delete this.dom[n]},ce(e,t,a,"ln-couchdb-connector",{attributes:i})})()})();
@@ -190,6 +190,10 @@ The re-query is **not** triggered from these handlers. It is declared once, as a
190
190
  the four query attributes (`extraAttributes` + `onAttributeChange`), and batched — so one
191
191
  sort change, which writes two attributes, still re-queries once.
192
192
 
193
+ #### URL Query Synchronization (`data-ln-query`)
194
+
195
+ Query controls (`ln-search`, `ln-filter`, `ln-sort`) targeting the coordinator's store or table can carry `data-ln-query` (e.g. `data-ln-query="search"`, `data-ln-query="status"`, `data-ln-query="sort"`). The controls synchronize the browser's URL query string (`?search=term&status=active&sort=field.asc`) via `history.replaceState` while emitting bubbled events to the coordinator. On initial load or bookmarked visits, the controls automatically restore from the query string during boot (`queueBoot`) and seed the coordinator without requiring any bespoke page coordinator script.
196
+
193
197
  ### 0. Form Write Intake (native `submit`, claimed via `preventDefault()`)
194
198
 
195
199
  The coordinator listens for the native `submit` event on `document`
@@ -1 +1 @@
1
- (function(){"use strict";function G(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function T(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let a=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){a=t[l];break}if(!T(a))return}e.apply(console,t)}}function g(e,t,r){const a=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,a),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:a}))}function D(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){D(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function K(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function P(e,t){const r=!!(t&&t.typed),a=t&&t.exclude,l={},u=e.elements,c={};if(r)for(let p=0;p<u.length;p++){const i=u[p];i.name&&i.type==="checkbox"&&!i.disabled&&(c[i.name]=(c[i.name]||0)+1)}for(let p=0;p<u.length;p++){const i=u[p];if(!(!i.name||i.disabled||i.type==="file"||i.type==="submit"||i.type==="button")&&!(a&&i.matches&&i.matches(a)))if(i.type==="checkbox")r&&c[i.name]===1?l[i.name]=i.checked:(l[i.name]||(l[i.name]=[]),i.checked&&l[i.name].push(i.value));else if(i.type==="radio")i.checked&&(l[i.name]=i.value);else if(i.type==="select-multiple"){l[i.name]=[];for(let m=0;m<i.options.length;m++)i.options[m].selected&&l[i.name].push(i.options[m].value)}else if(r&&i.type==="hidden")l[i.name]=i.value;else if(r&&(i.type==="number"||i.type==="range")){const m=Number(i.value);l[i.name]=i.value===""||isNaN(m)?null:m}else l[i.name]=i.value}return l}function we(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function me(e,t){const r=e.elements,a=[],l={};for(let u=0;u<r.length;u++){const c=r[u];c.name&&c.type==="checkbox"&&(l[c.name]=(l[c.name]||0)+1)}for(let u=0;u<r.length;u++){const c=r[u];if(c.type==="file"||c.type==="submit"||c.type==="button")continue;const p=c.getAttribute("data-ln-fill-as")||c.name;if(!p||!(p in t))continue;const i=t[p];if(c.type==="checkbox"){if(Array.isArray(i))c.checked=i.indexOf(c.value)!==-1;else if(l[c.name]>1){const m=String(i).split(",").map(function(A){return A.trim()});c.checked=m.indexOf(c.value)!==-1}else c.checked=we(i);a.push(c)}else if(c.type==="radio")c.checked=c.value===String(i),a.push(c);else if(c.type==="select-multiple"){if(Array.isArray(i))for(let m=0;m<c.options.length;m++)c.options[m].selected=i.indexOf(c.options[m].value)!==-1;a.push(c)}else c.value=i,c.tagName==="SELECT"&&i!=null&&c.setAttribute("data-ln-value",i),a.push(c)}return a}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=me,window.lnCore.serializeForm=P,window.lnCore.resolveFormMethod=K);const V={};function be(e,t){V[e]=t}function ye(e){return V[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=be,window.lnCore.getDataMapper=ye);function ge(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,D(function(){new MutationObserver(function(){g(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const z={};function Ce(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];z[r]=t}function _e(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return z[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ce,window.lnCore.getLocaleFallback=_e,window.lnCore.ensureLocaleObserver=ge);const L={};function Ae(e,t){L[e]||(L[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=L[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function H(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let c=0;c<r.length;c++){const p=r[c],i=p.getAttribute("data-ln-field");t[i]!=null&&(p.textContent=t[i])}const a=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<a.length;c++){const p=a[c],i=p.getAttribute("data-ln-attr").split(",");for(let m=0;m<i.length;m++){const A=i[m].trim().split(":");if(A.length!==2)continue;const _=A[0].trim(),C=A[1].trim();t[C]!=null&&p.setAttribute(_,t[C])}}const l=e.querySelectorAll("[data-ln-show]");for(let c=0;c<l.length;c++){const p=l[c],i=p.getAttribute("data-ln-show");i in t&&p.classList.toggle("hidden",!t[i])}const u=e.querySelectorAll("[data-ln-class]");for(let c=0;c<u.length;c++){const p=u[c],i=p.getAttribute("data-ln-class").split(",");for(let m=0;m<i.length;m++){const A=i[m].trim().split(":");if(A.length!==2)continue;const _=A[0].trim(),C=A[1].trim();C in t&&p.classList.toggle(_,!!t[C])}}return e}function ve(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let a=0;a<r.length;a++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[a],t??null),r[a].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)H(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<t.length;r++)t[r].textContent=""}})));function J(e,t){if(!e||!t)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const u=r.currentNode;u.textContent.indexOf("{{")!==-1&&(u.textContent=u.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,p){return t[p]!==void 0?t[p]:""}))}const a=function(u,c){return t[c]!==void 0?t[c]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let u=0;u<l.length;u++){const c=l[u],p=c.attributes;for(let i=0;i<p.length;i++){const m=p[i];m.value.indexOf("{{")!==-1&&c.setAttribute(m.name,m.value.replace(/\{\{\s*(\w+)\s*\}\}/g,a))}}return e}function Ee(e,t,r,a,l,u){const c={};for(let i=0;i<e.children.length;i++){const m=e.children[i],A=m.getAttribute("data-ln-render-key");A&&(c[A]=m)}const p=document.createDocumentFragment();for(let i=0;i<t.length;i++){const m=t[i],A=String(a(m));let _=c[A];if(_)l(_,m,i);else{const C=Ae(r,u);if(!C||(J(C,m),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",A),l(_,m,i)}p.appendChild(_)}e.textContent="",e.appendChild(p)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=J,window.lnCore.fill=H,window.lnCore.lnFill=ve,window.lnCore.renderList=Ee);function F(e,t,r){const a=e.getAttribute(t);return a===null?r:a}function X(e,t,r){const a=parseInt(e.getAttribute(t),10);return isNaN(a)?r:a}function Y(e,t,r=!1){const a=e.getAttribute(t);if(a===null)return!!r;const l=a.trim().toLowerCase();return!(l==="false"||l==="0")}function Z(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const j=new Map;function ee(e,t){const r=(e?e.join("|"):"")+"::"+t;if(j.has(r))return j.get(r);const a=new Set(e||[]),l=function(u,c){const p=u.getAttribute(c);return p!==null&&a.has(p)?p:t};return j.set(r,l),l}function te(e,t,r){const a=parseFloat(e.getAttribute(t));return isNaN(a)?r:a}function ne(e,t,r){const a=e.getAttribute(t);if(!a)return r;try{return JSON.parse(a)}catch{return r}}function re(e,t,r,a,l){if(!e||t===null)return!0;const u=a||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const p=i=>{l?console.warn(i,l):console.warn(i)};if(c==="boolean"){const i=t.trim().toLowerCase();return i!==""&&i!=="true"&&i!=="false"&&i!=="1"&&i!=="0"?(p(`[${u}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const i=e.values||[];return i.includes(t)?!0:(p(`[${u}] Invalid value "${t}" for attribute "${r}". Allowed: ${i.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return p(`[${u}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const i=parseInt(t,10);return e.min!==void 0&&i<e.min?(p(`[${u}] Value ${i} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&i>e.max?(p(`[${u}] Value ${i} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(p(`[${u}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(i){return p(`[${u}] Invalid JSON for attribute "${r}": ${i.message}. Fallback: ${e.fallback}.`),!1}return!0}function oe(e,t,r){for(const a in r){const[l,u,c]=r[a];Object.defineProperty(e,a,{get:function(){return l(t,u,c)},enumerable:!0,configurable:!0})}return e}function ie(e){const t={};for(const r in e){const a=e[r];if(!a||!a.prop)continue;let l=a.read;if(!l&&a.type)switch(a.type){case"enum":l=ee(a.values,a.fallback);break;case"integer":l=X;break;case"float":l=te;break;case"boolean":l=Y;break;case"list":l=Z;break;case"json":l=ne;break;case"string":default:l=F;break}l||(l=F),t[a.prop]=[l,r,a.fallback]}return t}function qe(e){const t={};for(const r in e){const a=e[r];a&&a.effect&&(t[r]=a.effect)}return Object.keys(t).length?t:null}function Se(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const r in e.effects)t.add(r);if(e.onAttrChange&&e.declared)for(const r of e.declared)t.add(r);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=oe,window.lnCore.attrSpec=ie,window.lnCore.attrStr=F,window.lnCore.attrInt=X,window.lnCore.attrBool=Y,window.lnCore.attrList=Z,window.lnCore.attrEnum=ee,window.lnCore.attrFloat=te,window.lnCore.attrJson=ne);function I(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(r){console.error("["+t.attribute+"] init failed",e,r)}}}function ae(e,t,r,a){if(e.nodeType!==1)return;const u=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:r,ComponentFn:a};if(e.matches&&e.matches(u)&&I(e,c),e.querySelectorAll){const p=e.querySelectorAll(u);for(let i=0;i<p.length;i++)I(p[i],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function xe(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ke(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function le(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function Ie(e){const t=le(),r=e.observed||[];for(let a=0;a<r.length;a++){const l=r[a];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const a in e.attributes){t.byDeclaredAttr.has(a)||t.byDeclaredAttr.set(a,[]);const l=t.byDeclaredAttr.get(a);l.some(u=>u.componentTag===e.componentTag)||l.push({spec:e.attributes[a],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const a=Se(e);if(a===null)t.reactiveWildcard.push(e);else for(const l of a)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function se(e,t,r,a){for(let l=0;l<e.length;l++){const u=e[l];if(!t[u.attribute])continue;const c=u.effects&&u.effects[r];c?c(t,r,a):u.onAttrChange&&(!u.declared||u.declared.has(r))&&u.onAttrChange(t,r,a)}}function Oe(e){const t=e.attributeName,r=t.indexOf("data-ln-")===0,a=le(),l=a.byAttr.get(t),u=G()&&a.byDeclaredAttr&&a.byDeclaredAttr.has(t);if(!r&&!l&&!u)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(u&&T(c)){const p=a.byDeclaredAttr.get(t),i=c.getAttribute(t);for(let m=0;m<p.length;m++)re(p[m].spec,i,t,p[m].componentTag,c)}if(window.lnCore._debugSink&&(r||l)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),r){const p=a.byReactive.get(t);p&&se(p,c,t,e.oldValue),a.reactiveWildcard.length&&se(a.reactiveWildcard,c,t,e.oldValue)}if(l)for(let p=0;p<l.length;p++){const i=l[p];if(i.handler){i.handler(c,t,e.oldValue);continue}i.onAttributeChange&&c[i.attribute]?i.onAttributeChange(c,t):(ae(c,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(c))}}}function De(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{Oe(t[r])}catch(a){console.error("[ln-core] mutation handler failed",t[r].target,a)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function $(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function M(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function B(e,t){if(!document.contains(e))if(t.attribute){const r=e[t.attribute];if(r&&typeof r.destroy=="function")try{r.destroy()}catch(a){console.error("["+t.attribute+"] destroy failed",e,a)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function ce(e){const t=$();if(!t.length)return;const r=e.target;if(r){const l=r.nodeType===1?r:r.parentElement;if(l&&(l.isContentEditable||l.closest&&l.closest('[contenteditable]:not([contenteditable="false"])')))return}const a=M();if(e.target&&a.length)for(let l=0;l<a.length;l++){const u=a[l],c=u.query,p=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;p&&u.onSubtreeChange(p,e)}for(let l=0;l<e.addedNodes.length;l++){const u=e.addedNodes[l];if(u.nodeType===1){const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const i=t[p];if(i.selector&&i.attribute&&i.ComponentFn){if(!c)u.matches&&u.matches(i.query)&&I(u,i);else if(u.matches&&u.matches(i.query)&&I(u,i),u.querySelectorAll){const m=u.querySelectorAll(i.query);for(let A=0;A<m.length;A++)I(m[A],i)}}i.onInit&&i.onInit(u)}}}for(let l=0;l<e.removedNodes.length;l++){const u=e.removedNodes[l];if(u.nodeType===1){if(document.contains(u))continue;const c=!!(u.firstElementChild||u.children&&u.children.length);for(let p=0;p<t.length;p++){const i=t[p],m=i.query;if(m){if(!c)u.matches&&u.matches(m)&&B(u,i);else if(u.matches&&u.matches(m)&&B(u,i),u.querySelectorAll){const A=u.querySelectorAll(m);for(let _=0;_<A.length;_++)B(A[_],i)}}}}}}function de(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){const e=new MutationObserver(function(t){for(let r=0;r<t.length;r++){const a=t[r];if(a.type==="childList")try{ce(a)}catch(l){console.error("[ln-core] lifecycle handler failed",a.target,l)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Re(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const r=t.takeRecords();for(let a=0;a<r.length;a++){const l=r[a];if(l.type==="childList")try{ce(l)}catch(u){console.error("[ln-core] lifecycle handler failed",l.target,u)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function Te(e){$().push(e),e.onSubtreeChange&&e.query&&M().push(e),de()}function ue(e,t,r,a,l={}){const u=l.extraAttributes||[],c=l.onAttributeChange||null,p=l.onSubtreeChange||null,i=l.onInit||null,m=l.onAttrChange||null,A=l.effects||null,_=l.attributes||null,C=_?qe(_):A,N=_?new Set(Object.keys(_)):null,Q=l.persist||null;function n(q){const E=q||document.body;if(ae(E,e,t,r),_&&G())for(const d in _){const h=_[d],b=Array.from(E.querySelectorAll("["+d+"]"));E.matches&&E.matches("["+d+"]")&&b.push(E);for(let v=0;v<b.length;v++){const S=b[v];T(S)&&re(h,S.getAttribute(d),d,a,S)}}i&&i(E)}const o=[];if(e.indexOf("[")!==-1){const q=/\[([\w-]+)/g;let E;for(;(E=q.exec(e))!==null;)o.push(E[1])}else o.push(e);Ie({selector:e,attribute:t,componentTag:a,attributes:_,ComponentFn:r,onInit:i,observed:o.concat(u),onAttributeChange:c,onAttrChange:m,effects:C,declared:N,persist:Q}),De();const s=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,f=l.subtreeQuery||(s?e:"["+e+"]"),w={selector:e,attribute:t,ComponentFn:r,onInit:i,onSubtreeChange:p,query:f};$().push(w),p&&f&&M().push(w),de(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ue,window.lnCore.observeLifecycle=Te,window.lnCore.withoutLifecycle=Re);function y(){xe()>0?ke(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y):y(),n}function Le(e,t){let r=!1;return function(){r||(r=!0,queueMicrotask(function(){r=!1,e()}))}}function fe(e){return(e||"").replace(/^#/,"")}function W(e){const t=e===void 0?location.hash:e,r={},a=fe(t);if(!a)return r;const l=a.split("&");for(let u=0;u<l.length;u++){const c=l[u];if(!c)continue;const p=c.indexOf(":"),i=p>-1?c.slice(0,p):c,m=p>-1?c.slice(p+1):"";if(i)try{r[i]=decodeURIComponent(m)}catch{r[i]=m}}return r}function Fe(e){if(!e)return null;const t=W();return e in t?t[e]:null}function je(e,t){if(!e)return;const r=W();t==null?delete r[e]:r[e]=String(t);const l=Object.keys(r).map(function(u){const c=r[u];return c===""?u:u+":"+encodeURIComponent(c)}).join("&");fe(location.hash)!==l&&(location.hash=l)}function $e(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Me(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const a=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return a?t?a+"-"+t:a:t||null}function Be(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function We(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function Ne(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Qe(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),a=e.slice(t+1),l=a?a.split(",").map(function(u){try{return decodeURIComponent(u)}catch{return u}}).filter(Boolean):[];return{key:r,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=W,window.lnCore.hashGet=Fe,window.lnCore.hashSet=je,window.lnCore.hashLinkClick=$e,window.lnCore.resolveHashNamespace=Me,window.lnCore.hashSortEncode=Be,window.lnCore.hashSortDecode=We,window.lnCore.hashFilterEncode=Ne,window.lnCore.hashFilterDecode=Qe);function k(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=k);function Ue(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Ge(e,t){const r=!e||!!e.initializationError,a=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||a)?"remote":e&&!e.initializationError?"store":"none"}function pe(e,t){const r=Object.assign({},e);return t&&(r.filters=t.filters,r.search=t.search,r.sort=t.sort),r}class Ke{constructor(){this._pending=new Map}wait(t){return new Promise((r,a)=>{this._pending.set(t,{resolve:r,reject:a})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const r=t||new Error("Mutation receipt registry closed");for(const a of this._pending.values())a.reject(r);this._pending.clear()}_settle(t,r){const a=t&&t.requestId;if(!a)return!1;const l=this._pending.get(a);return l?(this._pending.delete(a),r?l.reject(t.error||new Error("Store mutation failed")):l.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",r="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const a="data-ln-data-coordinator-search",l="data-ln-data-coordinator-filters",u="data-ln-data-coordinator-sort-field",c="data-ln-data-coordinator-sort-direction",i=ie({"data-ln-data-coordinator":{prop:"_name",type:"string",description:"Coordinator name or identifier for data routing"},"data-ln-data-coordinator-scope":{type:"string",description:"Scope name addressing the bound data store and connector"},"data-ln-data-coordinator-connector":{type:"string",description:"Selector, identifier, or namespace of the bound connector"},"data-ln-data-coordinator-mapper":{type:"string",description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{prop:"_searchAttr",type:"string",description:"Active search query term"},"data-ln-data-coordinator-filters":{prop:"_filtersAttr",type:"string",description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{prop:"_sortFieldAttr",type:"string",description:"Sort field name"},"data-ln-data-coordinator-sort-direction":{prop:"_sortDirAttr",type:"enum",values:["asc","desc"],fallback:"asc",description:"Sort direction"},"data-ln-data-coordinator-stale":{type:"marker",description:"Flag indicating data needs re-synchronization"},"data-ln-data-coordinator-no-autosync":{type:"boolean",description:"Disables automatic synchronization upon state changes"}}),m=[["[data-ln-table-source]","data-ln-table-source","table"],["[data-ln-list-source]","data-ln-list-source","list"],["[data-ln-chart-source]","data-ln-chart-source","chart"],["[data-ln-options]","data-ln-options","options"],["[data-ln-stat]","data-ln-stat","stat"]];function A(n){const o=n.getAttribute("data-ln-data-coordinator-connector");if(o)return n.querySelector(o)||document.querySelector(o)||document.getElementById(o);const s=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(s)return s;for(const f of n.querySelectorAll("*")){if(f.lnConnector)return f;for(const w of f.attributes)if(w.name.startsWith("data-ln-")&&w.name.endsWith("-connector"))return f}return null}function _(n){var s;if(!n)return"ln-connector";if((s=n.lnConnector)!=null&&s.namespace)return n.lnConnector.namespace;const o=n.getAttribute("data-ln-connector");if(o&&o!=="true")return o.startsWith("ln-")?o:"ln-"+o+(o.endsWith("-connector")?"":"-connector");for(const f of n.attributes)if(f.name.startsWith("data-ln-")&&f.name.endsWith("-connector"))return f.name.replace(/^data-/,"");return"ln-connector"}function C(n){const o=this;return this.dom=n,oe(this,n,i),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",n),n[t]=this,this._destroyed=!1,this.mapper=null,this._unsubs=[],this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._mutationReceipts=new Ke,this._queueQueryRefresh=Le(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),N(this),this._checkInitialSync(),this}C.prototype._noAutosync=function(n){var o;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||!!((o=n.storeEl)!=null&&o.hasAttribute("data-ln-data-store-no-autosync"))},C.prototype._isStale=function(n){var s,f;const o=this.dom.getAttribute("data-ln-data-coordinator-stale")||((s=n.storeEl)==null?void 0:s.getAttribute("data-ln-data-store-stale"));return o==="never"||o==="-1"?!1:!((f=n.store)!=null&&f.lastSyncedAt)||Date.now()/1e3-n.store.lastSyncedAt>(parseInt(o,10)||300)},C.prototype._checkInitialSync=function(){const n=this,o=this.findChildren();o.store&&Promise.resolve(o.store.ready).then(()=>{if(n._destroyed)return;const s=n.findChildren();s.store&&s.connector&&!n._noAutosync(s)&&!s.store.isSyncing&&(!s.store.hasCache||n._isStale(s))&&s.store.forceSync()}).catch(s=>n._reportError("store-initialize",s,null))},C.prototype.refreshMapper=function(){var s,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,o=n&&((f=(s=window.lnCore)==null?void 0:s.getDataMapper)==null?void 0:f.call(s,n))||null;this.mapper={ingress:(o==null?void 0:o.ingress)||(w=>w),egress:(o==null?void 0:o.egress)||(w=>w)}},C.prototype.findChildren=function(){const n=this.dom.querySelector("[data-ln-data-store]"),o=A(this.dom),s=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:o,queueEl:s,store:(n==null?void 0:n.lnDataStore)||null,connector:(o==null?void 0:o.lnConnector)||(o==null?void 0:o.lnApiConnector)||(o==null?void 0:o.lnCouchDbConnector)||(o==null?void 0:o.lnWebsocketConnector)||null,queue:(s==null?void 0:s.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,o,s,f){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",s):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+o,f)},C.prototype._fanOutCreate=function(n,o,s){const f="_temp_"+k(),w=this.mapper.egress(o);n.storeEl&&g(n.storeEl,"ln-data-store:request-create",{tempId:f,data:w}),this._fanOutRemote(n,"create",{chainKey:f,op:"create",targetId:null,payload:w,expectedVersion:null,meta:{tempId:f,action:s}},{data:w,url:s,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},C.prototype._fanOutUpdate=function(n,o,s,f,w){const y=this.mapper.egress(s);n.storeEl&&g(n.storeEl,"ln-data-store:request-update",{id:o,data:y}),this._fanOutRemote(n,"update",{chainKey:o,op:"update",targetId:o,payload:y,expectedVersion:f,meta:{id:o,action:w}},{id:o,data:y,expected_version:f,url:w,meta:{entryId:k(),queued:!1,op:"update",id:o}})},C.prototype._fanOutDelete=function(n,o){n.storeEl&&g(n.storeEl,"ln-data-store:request-delete",{id:o}),this._fanOutRemote(n,"delete",{chainKey:o,op:"delete",targetId:o,payload:null,expectedVersion:null,meta:{id:o}},{id:o,meta:{entryId:k(),queued:!1,op:"delete",id:o}})},C.prototype._fanOutBulkDelete=function(n,o){const s=o.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:o}),this._fanOutRemote(n,"bulk-delete",{chainKey:s,op:"bulk-delete",targetId:null,payload:{ids:o},expectedVersion:null,meta:{bulkKey:s,ids:o}},{ids:o,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:s}})},C.prototype._requestStoreMutation=function(n,o,s){if(!n.storeEl)return Promise.reject(new Error("Store element not found"));const f=k(),w=this._mutationReceipts.wait(f);return g(n.storeEl,"ln-data-store:request-"+o,Object.assign({},s,{requestId:f})),w},C.prototype._reportError=function(n,o,s){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:o,meta:s||null})},C.prototype._owns=function(n){var s;const o=this._name||((s=this.findChildren().storeEl)==null?void 0:s.id);return!!n&&n===o},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(u),o=this.dom.getAttribute(c),s=new URLSearchParams(this.dom.getAttribute(l)||""),f={};for(const w of new Set(s.keys()))f[w]=s.getAll(w);return{search:this.dom.getAttribute(a)||"",filters:f,sort:n&&o?{field:n,direction:o}:null}},C.prototype._refreshAll=function(n,o){for(const[s,f,w]of m)for(const y of this.dom.ownerDocument.querySelectorAll(s))if(this._owns(y.getAttribute(f))){if((w==="table"||w==="list")&&y.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){g(y,"ln-"+w+(o?":request-invalidate":":request-revalidate"),{query:this._currentQuery()});continue}this._serveElement(y,w,null,n)}},C.prototype._serveElement=function(n,o,s,f){const w=this.findChildren(),y=w.store;if(!y)return;s&&this._boundQueries.set(n,s);const q=this._boundQueries.get(n)||{sort:null,filters:{},search:""},E=pe(q,this._currentQuery()),d=this;return Promise.resolve(y.ready).then(()=>{if(d._destroyed)return;const h=Ge(y,w.connector);if(o==="table"||o==="list"||o==="chart")return h==="remote"?(g(n,"ln-"+o+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:E,meta:{targetEl:n,kind:o,offset:E.offset,limit:E.limit,queryGen:q.queryGen}})):h!=="store"?g(n,"ln-"+o+":set-loading",{loading:!1}):y.getAll(E).then(b=>{d._destroyed||!d._boundDelivered||(g(n,"ln-"+o+":set-loading",{loading:!1}),g(n,"ln-"+o+":set-data",{data:b.data,total:(f==null?void 0:f.total)??b.total,filtered:(f==null?void 0:f.filtered)??b.filtered,offset:b.offset??(f==null?void 0:f.offset)??q.offset,queryGen:q.queryGen!==void 0?q.queryGen:(f==null?void 0:f.queryGen)??b.queryGen,provisional:b.provisional===!0}),d._boundDelivered.set(n,!0))});if(o==="options"){if(h==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:o}});if(h==="store")return y.getAll({}).then(b=>!d._destroyed&&g(n,"ln-options:set-data",{data:b.data}))}if(o==="stat"){let b=s==null?void 0:s.filters;if(!b){const S=n.getAttribute("data-ln-stat-filter");if(S!=null&&S.includes(":")){const x=S.split(":");b={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const v=w.connector&&y&&(y.windowed&&b&&Object.keys(b).length||y.noLocalQuery)?"remote":h;if(v==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:b},meta:{targetEl:n,kind:o}});if(v==="store")return y.count(b).then(S=>!d._destroyed&&g(n,"ln-stat:set-count",{count:S}))}}).catch(h=>{d._destroyed||((o==="table"||o==="list"||o==="chart")&&g(n,"ln-"+o+":set-loading",{loading:!1}),d._reportError(o+"-query",h,{targetEl:n,kind:o}))})};function N(n){const o=n._unsubs=[],s=(d,h,b)=>{d.addEventListener(h,b),o.push(()=>d.removeEventListener(h,b))};s(n.dom,"ln-data-store:request-remote-sync",d=>{n.refreshMapper();const h=n.findChildren();h.store&&h.connector&&g(h.connectorEl,_(h.connectorEl)+":request-sync",{since:d.detail.since,meta:{op:"sync"}})}),s(n.dom,"ln-data-store:request-page",d=>{const h=n.findChildren(),b=d.detail||{};if(!h.connectorEl)return;const v=pe(b.query||{},n._currentQuery());g(h.connectorEl,_(h.connectorEl)+":request-query",{query:Object.assign({},v,{offset:b.offset,limit:b.limit,queryGen:b.queryGen})})}),s(n.dom,"ln-data-coordinator:request-create",d=>n._fanOutCreate(n.findChildren(),d.detail.data||{},d.detail.action)),s(n.dom,"ln-data-coordinator:request-update",d=>n._fanOutUpdate(n.findChildren(),d.detail.id,d.detail.data||{},d.detail.expected_version,d.detail.action)),s(n.dom,"ln-data-coordinator:request-delete",d=>n._fanOutDelete(n.findChildren(),d.detail.id)),s(n.dom,"ln-data-coordinator:request-bulk-delete",d=>n._fanOutBulkDelete(n.findChildren(),d.detail.ids||[])),s(n.dom,"ln-api-queue:send",d=>n._onQueueSend(d.detail||{})),s(n.dom,"ln-api-queue:failed",d=>{var h;return n._reportError("queue-failed",((h=d==null?void 0:d.detail)==null?void 0:h.error)||new Error("Queue failed"),(d==null?void 0:d.detail)||null)}),s(n.dom,"ln-data-store:initialized",d=>{var b;const h=n.findChildren();h.store&&!h.store.initializationError&&h.connector&&!n._noAutosync(h)&&!h.store.isSyncing&&(!((b=d.detail)!=null&&b.hasCache)||n._isStale(h))&&h.store.forceSync()});const f=()=>{const d=n.findChildren();d.store&&!d.store.initializationError&&d.connector&&!n._noAutosync(d)&&d.store.isInitialized&&!d.store.isSyncing&&d.store.forceSync()};s(n.dom,"ln-websocket-connector:connected",f),s(document,"submit",d=>n._onFormSubmit(d));const w=(d,h,b)=>{var v;n._owns(d.target.getAttribute(b))&&n._serveElement(d.target,h,h==="stat"?{filters:((v=d.detail)==null?void 0:v.filters)||null}:h==="options"?null:Ue(d.detail||{}),null)};s(document,"ln-table:request-data",d=>w(d,"table","data-ln-table-source")),s(document,"ln-list:request-data",d=>w(d,"list","data-ln-list-source")),s(document,"ln-chart:request-data",d=>w(d,"chart","data-ln-chart-source")),s(document,"ln-options:request-data",d=>w(d,"options","data-ln-options")),s(document,"ln-stat:request-count",d=>w(d,"stat","data-ln-stat"));const y=d=>{n._mutationReceipts.resolve(d.detail),n._refreshAll(null,!1)};s(n.dom,"ln-data-store:ready",y),s(n.dom,"ln-data-store:created",y),s(n.dom,"ln-data-store:updated",y),s(n.dom,"ln-data-store:deleted",y),s(n.dom,"ln-data-store:mutation-error",d=>n._mutationReceipts.reject(d.detail)),s(n.dom,"ln-data-store:synced",d=>{var h;(h=d.detail)!=null&&h.changed&&n._refreshAll(d.detail.meta,!1)}),s(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),s(n.dom,"ln-search:change",d=>{var b;d.preventDefault();const h=((b=d.detail)==null?void 0:b.term)!=null?d.detail.term:"";h!==(n.dom.getAttribute(a)||"")&&n.dom.setAttribute(a,h)}),s(n.dom,"ln-filter:change",d=>{var he;d.preventDefault();const h=(he=d.detail)==null?void 0:he.key;if(!h)return;const b=(d.detail.values||[]).slice(),v=n._currentQuery().filters,S=v[h];if(S?S.length===b.length&&S.every((R,U)=>R===b[U]):!b.length)return;b.length?v[h]=b:delete v[h];const x=new URLSearchParams;Object.keys(v).forEach(R=>v[R].forEach(U=>x.append(R,U)));const O=x.toString();O?n.dom.setAttribute(l,O):n.dom.removeAttribute(l)}),s(n.dom,"ln-sort:change",d=>{var x,O;d.preventDefault();const h=(x=d.detail)==null?void 0:x.field,b=(O=d.detail)==null?void 0:O.direction,v=h&&b&&b!=="none"?{field:h,direction:b}:null,S=n._currentQuery().sort;!S&&!v||S&&v&&S.field===v.field&&S.direction===v.direction||(v?(n.dom.setAttribute(u,v.field),n.dom.setAttribute(c,v.direction)):(n.dom.removeAttribute(u),n.dom.removeAttribute(c)))});const q=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),E=n.findChildren().connectorEl;if(E){const d=_(E);q.add(d),s(n.dom,d+":connected",f)}q.forEach(d=>{s(n.dom,d+":fetched",h=>n._reconcileServerFetch(h.detail)),s(n.dom,d+":created",h=>n._reconcileServerMutation("create",h.detail)),s(n.dom,d+":updated",h=>n._reconcileServerMutation("update",h.detail)),s(n.dom,d+":deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,d+":bulk-deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,d+":error",h=>n._reconcileServerMutation("error",h.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const o=this.findChildren();if(!o.store||!o.connector||!o.queue)return;const s=n.meta||{},f=_(o.connectorEl),w=n.idempotencyKey||n.entryId,y={create:()=>g(o.connectorEl,f+":request-create",{data:n.payload,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:s.tempId}}),update:()=>g(o.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"update",id:n.targetId}}),delete:()=>g(o.connectorEl,f+":request-delete",{id:n.targetId,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"delete",id:n.targetId}}),"bulk-delete":()=>{var q;return g(o.connectorEl,f+":request-bulk-delete",{ids:((q=n.payload)==null?void 0:q.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:s.bulkKey}})}};y[n.op]&&y[n.op]()},C.prototype._onFormSubmit=function(n){const o=n.target;if(n.defaultPrevented)return;const s=o.hasAttribute(r)?o.getAttribute(r):null;if(s===null||(s?!this._owns(s):o.closest("["+e+"]")!==this.dom))return;const f=K(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=P(o);delete w._method,delete w._token;const y=w.id,q=w.expected_version,E=o.getAttribute("action")||"",d=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(d,w,E):this._fanOutUpdate(d,y,w,q,E)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const o=n.meta||{},s=this.findChildren(),f=n.data;this.refreshMapper();const w=Array.isArray(f)?f:(f==null?void 0:f.data)||[],y=Array.isArray(f==null?void 0:f.deleted)?f.deleted:[],q=Array.isArray(f)?Math.floor(Date.now()/1e3):(f==null?void 0:f.synced_at)??(f==null?void 0:f.since)??Math.floor(Date.now()/1e3),E=w.map(d=>this.mapper.ingress(d));if(!(!s.store||s.store.initializationError)){if(!o.kind)return s.store.applySync(E,y,q,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:o.targetEl});s.store.applyQuery(E,{total:n.total}).then(d=>{const h=o.kind;h==="table"||h==="list"||h==="chart"?(g(o.targetEl,"ln-"+h+":set-loading",{loading:!1}),g(o.targetEl,"ln-"+h+":set-data",{data:d,total:n.total??d.length,filtered:n.filtered??d.length,offset:n.offset,queryGen:o.queryGen}),this._boundDelivered.set(o.targetEl,!0)):h==="options"?s.store.getAll({}).then(b=>g(o.targetEl,"ln-options:set-data",{data:b.data})):h==="stat"&&g(o.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??E.length})})}},C.prototype._reconcileServerMutation=function(n,o){var w;if(!o)return;const s=this.findChildren(),f=o.meta||{};if(n==="create"){if(!o.record)return this._reportError("create-empty-response",new Error("Create response missing record payload"),f);const y=this.mapper.ingress(o.record);(s.storeEl?this._requestStoreMutation(s,"update",{id:f.tempId,data:y}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:y.id})}).catch(q=>this._reportError("create-reconcile",q,f))}else if(n==="update"){const y=o.record?this.mapper.ingress(o.record):null;(s.storeEl&&y?this._requestStoreMutation(s,"update",{id:f.id,data:y}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(q=>this._reportError("update-reconcile",q,f))}else if(n==="ack")f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId});else if(n==="error"){const y=o.status||((w=o.error)==null?void 0:w.status)||0;f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:y===401||y===419?"auth":y===0||y>=500?"retry":"drop"}),s.storeEl&&g(s.storeEl,"ln-data-store:request-sync-failed",{error:o.error||o,status:y}),this._reportError("connector-error",o.error||o,f)}},C.prototype.destroy=function(){var n;if(this.dom[t]){for(this._destroyed=!0;(n=this._unsubs)!=null&&n.length;)this._unsubs.pop()();this._unsubs=this._boundQueries=this._boundDelivered=this._queueQueryRefresh=null,this._mutationReceipts.close(new Error("Data coordinator destroyed")),this._mutationReceipts=null,delete this.dom[t]}};function Q(n,o){const s=n[t];s&&(o==="data-ln-data-coordinator-mapper"?s.refreshMapper():(o===a||o===l||o===u||o===c)&&s._queueQueryRefresh())}ue(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",a,l,u,c],onAttributeChange:Q}),window[t].init=window[t]})()})();
1
+ (function(){"use strict";function G(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function L(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let i=null;for(let l=1;l<t.length;l++)if(t[l]&&t[l].nodeType===1){i=t[l];break}if(!L(i))return}e.apply(console,t)}}function g(e,t,r){const i=r||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,i),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:i}))}function D(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){D(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function P(e){const t=e.querySelector('input[name="_method"]');return((t&&t.value!==""?t.value:e.method)||"").toUpperCase()}function K(e,t){const r=!!(t&&t.typed),i=t&&t.exclude,l={},d=e.elements,c={};if(r)for(let p=0;p<d.length;p++){const a=d[p];a.name&&a.type==="checkbox"&&!a.disabled&&(c[a.name]=(c[a.name]||0)+1)}for(let p=0;p<d.length;p++){const a=d[p];if(!(!a.name||a.disabled||a.type==="file"||a.type==="submit"||a.type==="button")&&!(i&&a.matches&&a.matches(i)))if(a.type==="checkbox")r&&c[a.name]===1?l[a.name]=a.checked:(l[a.name]||(l[a.name]=[]),a.checked&&l[a.name].push(a.value));else if(a.type==="radio")a.checked&&(l[a.name]=a.value);else if(a.type==="select-multiple"){l[a.name]=[];for(let m=0;m<a.options.length;m++)a.options[m].selected&&l[a.name].push(a.options[m].value)}else if(r&&a.type==="hidden")l[a.name]=a.value;else if(r&&(a.type==="number"||a.type==="range")){const m=Number(a.value);l[a.name]=a.value===""||isNaN(m)?null:m}else l[a.name]=a.value}return l}function we(e){if(typeof e!="string")return!!e;const t=e.trim().toLowerCase();return t!=="false"&&t!=="0"&&t!==""&&t!=="off"&&t!=="no"}function me(e,t){const r=e.elements,i=[],l={};for(let d=0;d<r.length;d++){const c=r[d];c.name&&c.type==="checkbox"&&(l[c.name]=(l[c.name]||0)+1)}for(let d=0;d<r.length;d++){const c=r[d];if(c.type==="file"||c.type==="submit"||c.type==="button")continue;const p=c.getAttribute("data-ln-fill-as")||c.name;if(!p||!(p in t))continue;const a=t[p];if(c.type==="checkbox"){if(Array.isArray(a))c.checked=a.indexOf(c.value)!==-1;else if(l[c.name]>1){const m=String(a).split(",").map(function(A){return A.trim()});c.checked=m.indexOf(c.value)!==-1}else c.checked=we(a);i.push(c)}else if(c.type==="radio")c.checked=c.value===String(a),i.push(c);else if(c.type==="select-multiple"){if(Array.isArray(a))for(let m=0;m<c.options.length;m++)c.options[m].selected=a.indexOf(c.options[m].value)!==-1;i.push(c)}else c.value=a,c.tagName==="SELECT"&&a!=null&&c.setAttribute("data-ln-value",a),i.push(c)}return i}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.populateForm=me,window.lnCore.serializeForm=K,window.lnCore.resolveFormMethod=P);const V={};function ye(e,t){V[e]=t}function be(e){return V[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=ye,window.lnCore.getDataMapper=be);function ge(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,D(function(){new MutationObserver(function(){g(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const z={};function Ce(e,t){if(!e||typeof t!="object")return;const r=e.toLowerCase().split("-")[0];z[r]=t}function _e(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return z[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Ce,window.lnCore.getLocaleFallback=_e,window.lnCore.ensureLocaleObserver=ge);const T={};function Ae(e,t){T[e]||(T[e]=document.querySelector('[data-ln-template="'+e+'"]'));const r=T[e];return r?r.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function H(e,t){if(!e||!t)return e;const r=e.querySelectorAll("[data-ln-field]");for(let c=0;c<r.length;c++){const p=r[c],a=p.getAttribute("data-ln-field");t[a]!=null&&(p.textContent=t[a])}const i=e.querySelectorAll("[data-ln-attr]");for(let c=0;c<i.length;c++){const p=i[c],a=p.getAttribute("data-ln-attr").split(",");for(let m=0;m<a.length;m++){const A=a[m].trim().split(":");if(A.length!==2)continue;const _=A[0].trim(),C=A[1].trim();t[C]!=null&&p.setAttribute(_,t[C])}}const l=e.querySelectorAll("[data-ln-show]");for(let c=0;c<l.length;c++){const p=l[c],a=p.getAttribute("data-ln-show");a in t&&p.classList.toggle("hidden",!t[a])}const d=e.querySelectorAll("[data-ln-class]");for(let c=0;c<d.length;c++){const p=d[c],a=p.getAttribute("data-ln-class").split(",");for(let m=0;m<a.length;m++){const A=a[m].trim().split(":");if(A.length!==2)continue;const _=A[0].trim(),C=A[1].trim();C in t&&p.classList.toggle(_,!!t[C])}}return e}function qe(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const r=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let i=0;i<r.length;i++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",r[i],t??null),r[i].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)H(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let r=0;r<t.length;r++)t[r].textContent=""}})));function J(e,t){if(!e||!t)return e;const r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;r.nextNode();){const d=r.currentNode;d.textContent.indexOf("{{")!==-1&&(d.textContent=d.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(c,p){return t[p]!==void 0?t[p]:""}))}const i=function(d,c){return t[c]!==void 0?t[c]:""},l=Array.from(e.querySelectorAll("*"));e.nodeType===1&&l.push(e);for(let d=0;d<l.length;d++){const c=l[d],p=c.attributes;for(let a=0;a<p.length;a++){const m=p[a];m.value.indexOf("{{")!==-1&&c.setAttribute(m.name,m.value.replace(/\{\{\s*(\w+)\s*\}\}/g,i))}}return e}function Ee(e,t,r,i,l,d){const c={};for(let a=0;a<e.children.length;a++){const m=e.children[a],A=m.getAttribute("data-ln-render-key");A&&(c[A]=m)}const p=document.createDocumentFragment();for(let a=0;a<t.length;a++){const m=t[a],A=String(i(m));let _=c[A];if(_)l(_,m,a);else{const C=Ae(r,d);if(!C||(J(C,m),_=C.firstElementChild,!_))continue;_.setAttribute("data-ln-render-key",A),l(_,m,a)}p.appendChild(_)}e.textContent="",e.appendChild(p)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=J,window.lnCore.fill=H,window.lnCore.lnFill=qe,window.lnCore.renderList=Ee);function F(e,t,r){const i=e.getAttribute(t);return i===null?r:i}function X(e,t,r){const i=parseInt(e.getAttribute(t),10);return isNaN(i)?r:i}function Y(e,t,r=!1){const i=e.getAttribute(t);if(i===null)return!!r;const l=i.trim().toLowerCase();return!(l==="false"||l==="0")}function Z(e,t){return(e.getAttribute(t)||"").split(",").map(r=>r.trim()).filter(Boolean)}const j=new Map;function ee(e,t){const r=(e?e.join("|"):"")+"::"+t;if(j.has(r))return j.get(r);const i=new Set(e||[]),l=function(d,c){const p=d.getAttribute(c);return p!==null&&i.has(p)?p:t};return j.set(r,l),l}function te(e,t,r){const i=parseFloat(e.getAttribute(t));return isNaN(i)?r:i}function ne(e,t,r){const i=e.getAttribute(t);if(!i)return r;try{return JSON.parse(i)}catch{return r}}function re(e,t,r,i,l){if(!e||t===null)return!0;const d=i||"ln-component",c=e.type;if(c==="trigger"||c==="marker"||c==="string"||c==="list"||!c||t===""&&e.fallback!==void 0)return!0;const p=a=>{l?console.warn(a,l):console.warn(a)};if(c==="boolean"){const a=t.trim().toLowerCase();return a!==""&&a!=="true"&&a!=="false"&&a!=="1"&&a!=="0"?(p(`[${d}] Invalid value "${t}" for boolean attribute "${r}". Allowed: "true", "false", or presence-only.`),!1):!0}if(c==="enum"){const a=e.values||[];return a.includes(t)?!0:(p(`[${d}] Invalid value "${t}" for attribute "${r}". Allowed: ${a.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(c==="integer"){if(!/^-?\d+$/.test(t))return p(`[${d}] Invalid integer "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1;const a=parseInt(t,10);return e.min!==void 0&&a<e.min?(p(`[${d}] Value ${a} for attribute "${r}" is less than min (${e.min}).`),!1):e.max!==void 0&&a>e.max?(p(`[${d}] Value ${a} for attribute "${r}" is greater than max (${e.max}).`),!1):!0}if(c==="float")return isNaN(Number(t))?(p(`[${d}] Invalid float "${t}" for attribute "${r}". Fallback: ${e.fallback}.`),!1):!0;if(c==="json")try{return JSON.parse(t),!0}catch(a){return p(`[${d}] Invalid JSON for attribute "${r}": ${a.message}. Fallback: ${e.fallback}.`),!1}return!0}function oe(e,t,r){for(const i in r){const[l,d,c]=r[i];Object.defineProperty(e,i,{get:function(){return l(t,d,c)},enumerable:!0,configurable:!0})}return e}function ie(e){const t={};for(const r in e){const i=e[r];if(!i||!i.prop)continue;let l=i.read;if(!l&&i.type)switch(i.type){case"enum":l=ee(i.values,i.fallback);break;case"integer":l=X;break;case"float":l=te;break;case"boolean":l=Y;break;case"list":l=Z;break;case"json":l=ne;break;case"string":default:l=F;break}l||(l=F),t[i.prop]=[l,r,i.fallback]}return t}function Se(e){const t={};for(const r in e){const i=e[r];i&&i.effect&&(t[r]=i.effect)}return Object.keys(t).length?t:null}function ve(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const r in e.effects)t.add(r);if(e.onAttrChange&&e.declared)for(const r of e.declared)t.add(r);return t}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.defineAttrs=oe,window.lnCore.attrSpec=ie,window.lnCore.attrStr=F,window.lnCore.attrInt=X,window.lnCore.attrBool=Y,window.lnCore.attrList=Z,window.lnCore.attrEnum=ee,window.lnCore.attrFloat=te,window.lnCore.attrJson=ne);function I(e,t){if(!e[t.attribute]){window.lnCore._persistSink&&e.hasAttribute&&e.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(e,t.selector);try{e[t.attribute]=new t.ComponentFn(e)}catch(r){console.error("["+t.attribute+"] init failed",e,r)}}}function ae(e,t,r,i){if(e.nodeType!==1)return;const d=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",c={selector:t,attribute:r,ComponentFn:i};if(e.matches&&e.matches(d)&&I(e,c),e.querySelectorAll){const p=e.querySelectorAll(d);for(let a=0;a<p.length;a++)I(p[a],c)}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function xe(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function ke(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function le(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function Ie(e){const t=le(),r=e.observed||[];for(let i=0;i<r.length;i++){const l=r[i];t.byAttr.has(l)||t.byAttr.set(l,[]),t.byAttr.get(l).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const i in e.attributes){t.byDeclaredAttr.has(i)||t.byDeclaredAttr.set(i,[]);const l=t.byDeclaredAttr.get(i);l.some(d=>d.componentTag===e.componentTag)||l.push({spec:e.attributes[i],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const i=ve(e);if(i===null)t.reactiveWildcard.push(e);else for(const l of i)t.byReactive.has(l)||t.byReactive.set(l,[]),t.byReactive.get(l).push(e)}e.persist&&t.persist.push(e)}function se(e,t,r,i){for(let l=0;l<e.length;l++){const d=e[l];if(!t[d.attribute])continue;const c=d.effects&&d.effects[r];c?c(t,r,i):d.onAttrChange&&(!d.declared||d.declared.has(r))&&d.onAttrChange(t,r,i)}}function Oe(e){const t=e.attributeName,r=t.indexOf("data-ln-")===0,i=le(),l=i.byAttr.get(t),d=G()&&i.byDeclaredAttr&&i.byDeclaredAttr.has(t);if(!r&&!l&&!d)return;const c=e.target;if(e.oldValue!==c.getAttribute(t)){if(d&&L(c)){const p=i.byDeclaredAttr.get(t),a=c.getAttribute(t);for(let m=0;m<p.length;m++)re(p[m].spec,a,t,p[m].componentTag,c)}if(window.lnCore._debugSink&&(r||l)&&window.lnCore._debugSink("attr",t,c,{oldValue:e.oldValue,newValue:c.getAttribute(t)}),r){const p=i.byReactive.get(t);p&&se(p,c,t,e.oldValue),i.reactiveWildcard.length&&se(i.reactiveWildcard,c,t,e.oldValue)}if(l)for(let p=0;p<l.length;p++){const a=l[p];if(a.handler){a.handler(c,t,e.oldValue);continue}a.onAttributeChange&&c[a.attribute]?a.onAttributeChange(c,t):(ae(c,a.selector,a.attribute,a.ComponentFn),a.onInit&&a.onInit(c))}}}function De(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,D(function(){new MutationObserver(function(t){for(let r=0;r<t.length;r++)try{Oe(t[r])}catch(i){console.error("[ln-core] mutation handler failed",t[r].target,i)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function $(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function M(){return window.lnCore=window.lnCore||{},window.lnCore._subtreeRegistry=window.lnCore._subtreeRegistry||[]}function W(e,t){if(!document.contains(e))if(t.attribute){const r=e[t.attribute];if(r&&typeof r.destroy=="function")try{r.destroy()}catch(i){console.error("["+t.attribute+"] destroy failed",e,i)}delete e[t.attribute]}else t.onDestroy&&t.onDestroy(e)}function ce(e){const t=$();if(!t.length)return;const r=e.target;if(r){const l=r.nodeType===1?r:r.parentElement;if(l&&(l.isContentEditable||l.closest&&l.closest('[contenteditable]:not([contenteditable="false"])')))return}const i=M();if(e.target&&i.length)for(let l=0;l<i.length;l++){const d=i[l],c=d.query,p=e.target.nodeType===1?e.target.matches&&e.target.matches(c)?e.target:e.target.closest?e.target.closest(c):null:e.target.parentElement&&e.target.parentElement.closest?e.target.parentElement.closest(c):null;p&&d.onSubtreeChange(p,e)}for(let l=0;l<e.addedNodes.length;l++){const d=e.addedNodes[l];if(d.nodeType===1){const c=!!(d.firstElementChild||d.children&&d.children.length);for(let p=0;p<t.length;p++){const a=t[p];if(a.selector&&a.attribute&&a.ComponentFn){if(!c)d.matches&&d.matches(a.query)&&I(d,a);else if(d.matches&&d.matches(a.query)&&I(d,a),d.querySelectorAll){const m=d.querySelectorAll(a.query);for(let A=0;A<m.length;A++)I(m[A],a)}}a.onInit&&a.onInit(d)}}}for(let l=0;l<e.removedNodes.length;l++){const d=e.removedNodes[l];if(d.nodeType===1){if(document.contains(d))continue;const c=!!(d.firstElementChild||d.children&&d.children.length);for(let p=0;p<t.length;p++){const a=t[p],m=a.query;if(m){if(!c)d.matches&&d.matches(m)&&W(d,a);else if(d.matches&&d.matches(m)&&W(d,a),d.querySelectorAll){const A=d.querySelectorAll(m);for(let _=0;_<A.length;_++)W(A[_],a)}}}}}}function de(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,D(function(){const e=new MutationObserver(function(t){for(let r=0;r<t.length;r++){const i=t[r];if(i.type==="childList")try{ce(i)}catch(l){console.error("[ln-core] lifecycle handler failed",i.target,l)}}});window.lnCore._lifecycleObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function Re(e){if(typeof window>"u")return e();window.lnCore=window.lnCore||{};const t=window.lnCore._lifecycleObserver;if(!t)return e();const r=t.takeRecords();for(let i=0;i<r.length;i++){const l=r[i];if(l.type==="childList")try{ce(l)}catch(d){console.error("[ln-core] lifecycle handler failed",l.target,d)}}t.disconnect();try{return e()}finally{t.observe(document.body,{childList:!0,subtree:!0})}}function Le(e){$().push(e),e.onSubtreeChange&&e.query&&M().push(e),de()}function ue(e,t,r,i,l={}){const d=l.extraAttributes||[],c=l.onAttributeChange||null,p=l.onSubtreeChange||null,a=l.onInit||null,m=l.onAttrChange||null,A=l.effects||null,_=l.attributes||null,C=_?Se(_):A,U=_?new Set(Object.keys(_)):null,N=l.persist||null;function n(S){const E=S||document.body;if(ae(E,e,t,r),_&&G())for(const u in _){const h=_[u],y=Array.from(E.querySelectorAll("["+u+"]"));E.matches&&E.matches("["+u+"]")&&y.push(E);for(let q=0;q<y.length;q++){const v=y[q];L(v)&&re(h,v.getAttribute(u),u,i,v)}}a&&a(E)}const o=[];if(e.indexOf("[")!==-1){const S=/\[([\w-]+)/g;let E;for(;(E=S.exec(e))!==null;)o.push(E[1])}else o.push(e);Ie({selector:e,attribute:t,componentTag:i,attributes:_,ComponentFn:r,onInit:a,observed:o.concat(d),onAttributeChange:c,onAttrChange:m,effects:C,declared:U,persist:N}),De();const s=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1,f=l.subtreeQuery||(s?e:"["+e+"]"),w={selector:e,attribute:t,ComponentFn:r,onInit:a,onSubtreeChange:p,query:f};$().push(w),p&&f&&M().push(w),de(),window[t]=n,typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerComponent=ue,window.lnCore.observeLifecycle=Le,window.lnCore.withoutLifecycle=Re);function b(){xe()>0?ke(function(){n(document.body)}):n(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",b):b(),n}function Te(e,t){let r=!1;return function(){r||(r=!0,queueMicrotask(function(){r=!1,e()}))}}function fe(e){return(e||"").replace(/^#/,"")}function B(e){const t=e===void 0?location.hash:e,r={},i=fe(t);if(!i)return r;const l=i.split("&");for(let d=0;d<l.length;d++){const c=l[d];if(!c)continue;const p=c.indexOf(":"),a=p>-1?c.slice(0,p):c,m=p>-1?c.slice(p+1):"";if(a)try{r[a]=decodeURIComponent(m)}catch{r[a]=m}}return r}function Fe(e){if(!e)return null;const t=B();return e in t?t[e]:null}function je(e,t){if(!e)return;const r=B();t==null?delete r[e]:r[e]=String(t);const l=Object.keys(r).map(function(d){const c=r[d];return c===""?d:d+":"+encodeURIComponent(c)}).join("&");fe(location.hash)!==l&&(location.hash=l)}function $e(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function Me(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const r=e.getAttribute("data-ln-hash");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"-"+t:i:t||null}function We(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Be(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function Ue(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ne(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const r=e.slice(0,t),i=e.slice(t+1),l=i?i.split(",").map(function(d){try{return decodeURIComponent(d)}catch{return d}}).filter(Boolean):[];return{key:r,values:l}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=B,window.lnCore.hashGet=Fe,window.lnCore.hashSet=je,window.lnCore.hashLinkClick=$e,window.lnCore.resolveHashNamespace=Me,window.lnCore.hashSortEncode=We,window.lnCore.hashSortDecode=Be,window.lnCore.hashFilterEncode=Ue,window.lnCore.hashFilterDecode=Ne);function Qe(e){return(e||"").replace(/^\?/,"")}function Ge(e){const t=e===void 0?typeof window<"u"?window.location.search:"":e,r={},i=Qe(t);if(!i)return r;const l=new URLSearchParams(i);for(const[d,c]of l.entries())r[d]=c;return r}function Pe(e){if(!e||typeof window>"u")return null;const t=new URLSearchParams(window.location.search);return t.has(e)?t.get(e):null}function Ke(e,t){if(!e||typeof window>"u")return;const r=new URL(window.location.href);if(t==null||t===""?r.searchParams.delete(e):r.searchParams.set(e,String(t)),r.search===window.location.search)return;const i=r.pathname+r.search+r.hash;window.history.replaceState(window.history.state,"",i)}function Ve(e,t){if(!e||!e.hasAttribute("data-ln-query"))return null;const r=e.getAttribute("data-ln-query");if(r&&r.trim()!=="")return r.trim();const i=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return i?t?i+"_"+t:i:t||null}function ze(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function He(e,t){if(e&&typeof e=="string"){if(e.endsWith(".asc"))return{fieldOrColumn:e.slice(0,-4),direction:"asc"};if(e.endsWith(".desc"))return{fieldOrColumn:e.slice(0,-5),direction:"desc"}}if(t&&typeof t=="object"){const r=t.sort_field||t.sort_by;if(r){const i=t.sort_dir&&String(t.sort_dir).toLowerCase()==="desc"?"desc":"asc";return{fieldOrColumn:r,direction:i}}}return null}function Je(e){return!Array.isArray(e)||e.length===0?null:e.map(encodeURIComponent).join(",")}function Xe(e){return!e||typeof e!="string"?[]:e.split(",").map(function(t){try{return decodeURIComponent(t.trim())}catch{return t.trim()}}).filter(Boolean)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.queryParse=Ge,window.lnCore.queryGet=Pe,window.lnCore.querySet=Ke,window.lnCore.resolveQueryParam=Ve,window.lnCore.querySortEncode=ze,window.lnCore.querySortDecode=He,window.lnCore.queryFilterEncode=Je,window.lnCore.queryFilterDecode=Xe);function k(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.uuid=k);function Ye(e){return e=e||{},{sort:e.sort,filters:e.filters,search:e.search,offset:e.offset,limit:e.limit,queryGen:e.queryGen}}function Ze(e,t){const r=!e||!!e.initializationError,i=!!(e&&e.noLocalQuery&&!e.windowed);return t&&(r||!e.canServe||i)?"remote":e&&!e.initializationError?"store":"none"}function pe(e,t){const r=Object.assign({},e);return t&&(r.filters=t.filters,r.search=t.search,r.sort=t.sort),r}class et{constructor(){this._pending=new Map}wait(t){return new Promise((r,i)=>{this._pending.set(t,{resolve:r,reject:i})})}resolve(t){return this._settle(t,!1)}reject(t){return this._settle(t,!0)}close(t){const r=t||new Error("Mutation receipt registry closed");for(const i of this._pending.values())i.reject(r);this._pending.clear()}_settle(t,r){const i=t&&t.requestId;if(!i)return!1;const l=this._pending.get(i);return l?(this._pending.delete(i),r?l.reject(t.error||new Error("Store mutation failed")):l.resolve(t),!0):!1}}(function(){const e="data-ln-data-coordinator",t="lnDataCoordinator",r="data-ln-data-coordinator-scope";if(window[t]!==void 0)return;const i="data-ln-data-coordinator-search",l="data-ln-data-coordinator-filters",d="data-ln-data-coordinator-sort-field",c="data-ln-data-coordinator-sort-direction",a=ie({"data-ln-data-coordinator":{prop:"_name",type:"string",description:"Coordinator name or identifier for data routing"},"data-ln-data-coordinator-scope":{type:"string",description:"Scope name addressing the bound data store and connector"},"data-ln-data-coordinator-connector":{type:"string",description:"Selector, identifier, or namespace of the bound connector"},"data-ln-data-coordinator-mapper":{type:"string",description:"Name of the registered data mapper transform"},"data-ln-data-coordinator-search":{prop:"_searchAttr",type:"string",description:"Active search query term"},"data-ln-data-coordinator-filters":{prop:"_filtersAttr",type:"string",description:"Active encoded filter parameters"},"data-ln-data-coordinator-sort-field":{prop:"_sortFieldAttr",type:"string",description:"Sort field name"},"data-ln-data-coordinator-sort-direction":{prop:"_sortDirAttr",type:"enum",values:["asc","desc"],fallback:"asc",description:"Sort direction"},"data-ln-data-coordinator-stale":{type:"marker",description:"Flag indicating data needs re-synchronization"},"data-ln-data-coordinator-no-autosync":{type:"boolean",description:"Disables automatic synchronization upon state changes"}}),m=[["[data-ln-table-source]","data-ln-table-source","table"],["[data-ln-list-source]","data-ln-list-source","list"],["[data-ln-chart-source]","data-ln-chart-source","chart"],["[data-ln-options]","data-ln-options","options"],["[data-ln-stat]","data-ln-stat","stat"]];function A(n){const o=n.getAttribute("data-ln-data-coordinator-connector");if(o)return n.querySelector(o)||document.querySelector(o)||document.getElementById(o);const s=n.querySelector("[data-ln-connector], [data-ln-api-connector], [data-ln-couchdb-connector], [data-ln-websocket-connector]");if(s)return s;for(const f of n.querySelectorAll("*")){if(f.lnConnector)return f;for(const w of f.attributes)if(w.name.startsWith("data-ln-")&&w.name.endsWith("-connector"))return f}return null}function _(n){var s;if(!n)return"ln-connector";if((s=n.lnConnector)!=null&&s.namespace)return n.lnConnector.namespace;const o=n.getAttribute("data-ln-connector");if(o&&o!=="true")return o.startsWith("ln-")?o:"ln-"+o+(o.endsWith("-connector")?"":"-connector");for(const f of n.attributes)if(f.name.startsWith("data-ln-")&&f.name.endsWith("-connector"))return f.name.replace(/^data-/,"");return"ln-connector"}function C(n){const o=this;return this.dom=n,oe(this,n,a),this._name||console.warn("[ln-data-coordinator] missing id — the coordinator cannot be addressed",n),n[t]=this,this._destroyed=!1,this.mapper=null,this._unsubs=[],this._boundQueries=new WeakMap,this._boundDelivered=new WeakMap,this._mutationReceipts=new et,this._queueQueryRefresh=Te(()=>{o._destroyed||o._refreshAll(null,!0)}),this.refreshMapper(),U(this),this._checkInitialSync(),this}C.prototype._noAutosync=function(n){var o;return this.dom.hasAttribute("data-ln-data-coordinator-no-autosync")||!!((o=n.storeEl)!=null&&o.hasAttribute("data-ln-data-store-no-autosync"))},C.prototype._isStale=function(n){var s,f;const o=this.dom.getAttribute("data-ln-data-coordinator-stale")||((s=n.storeEl)==null?void 0:s.getAttribute("data-ln-data-store-stale"));return o==="never"||o==="-1"?!1:!((f=n.store)!=null&&f.lastSyncedAt)||Date.now()/1e3-n.store.lastSyncedAt>(parseInt(o,10)||300)},C.prototype._checkInitialSync=function(){const n=this,o=this.findChildren();o.store&&Promise.resolve(o.store.ready).then(()=>{if(n._destroyed)return;const s=n.findChildren();s.store&&s.connector&&!n._noAutosync(s)&&!s.store.isSyncing&&(!s.store.hasCache||n._isStale(s))&&s.store.forceSync()}).catch(s=>n._reportError("store-initialize",s,null))},C.prototype.refreshMapper=function(){var s,f;const n=this.dom.getAttribute("data-ln-data-coordinator-mapper")||this.dom.id,o=n&&((f=(s=window.lnCore)==null?void 0:s.getDataMapper)==null?void 0:f.call(s,n))||null;this.mapper={ingress:(o==null?void 0:o.ingress)||(w=>w),egress:(o==null?void 0:o.egress)||(w=>w)}},C.prototype.findChildren=function(){const n=this.dom.querySelector("[data-ln-data-store]"),o=A(this.dom),s=this.dom.querySelector("[data-ln-api-queue]");return{storeEl:n,connectorEl:o,queueEl:s,store:(n==null?void 0:n.lnDataStore)||null,connector:(o==null?void 0:o.lnConnector)||(o==null?void 0:o.lnApiConnector)||(o==null?void 0:o.lnCouchDbConnector)||(o==null?void 0:o.lnWebsocketConnector)||null,queue:(s==null?void 0:s.lnApiQueue)||null}},C.prototype._fanOutRemote=function(n,o,s,f){this.refreshMapper(),n.queue?g(n.queueEl,"ln-api-queue:request-enqueue",s):n.connector&&g(n.connectorEl,_(n.connectorEl)+":request-"+o,f)},C.prototype._fanOutCreate=function(n,o,s){const f="_temp_"+k(),w=this.mapper.egress(o);n.storeEl&&g(n.storeEl,"ln-data-store:request-create",{tempId:f,data:w}),this._fanOutRemote(n,"create",{chainKey:f,op:"create",targetId:null,payload:w,expectedVersion:null,meta:{tempId:f,action:s}},{data:w,url:s,meta:{entryId:k(),queued:!1,op:"create",tempId:f}})},C.prototype._fanOutUpdate=function(n,o,s,f,w){const b=this.mapper.egress(s);n.storeEl&&g(n.storeEl,"ln-data-store:request-update",{id:o,data:b}),this._fanOutRemote(n,"update",{chainKey:o,op:"update",targetId:o,payload:b,expectedVersion:f,meta:{id:o,action:w}},{id:o,data:b,expected_version:f,url:w,meta:{entryId:k(),queued:!1,op:"update",id:o}})},C.prototype._fanOutDelete=function(n,o){n.storeEl&&g(n.storeEl,"ln-data-store:request-delete",{id:o}),this._fanOutRemote(n,"delete",{chainKey:o,op:"delete",targetId:o,payload:null,expectedVersion:null,meta:{id:o}},{id:o,meta:{entryId:k(),queued:!1,op:"delete",id:o}})},C.prototype._fanOutBulkDelete=function(n,o){const s=o.join(",");n.storeEl&&g(n.storeEl,"ln-data-store:request-bulk-delete",{ids:o}),this._fanOutRemote(n,"bulk-delete",{chainKey:s,op:"bulk-delete",targetId:null,payload:{ids:o},expectedVersion:null,meta:{bulkKey:s,ids:o}},{ids:o,meta:{entryId:k(),queued:!1,op:"bulk-delete",bulkKey:s}})},C.prototype._requestStoreMutation=function(n,o,s){if(!n.storeEl)return Promise.reject(new Error("Store element not found"));const f=k(),w=this._mutationReceipts.wait(f);return g(n.storeEl,"ln-data-store:request-"+o,Object.assign({},s,{requestId:f})),w},C.prototype._reportError=function(n,o,s){this._destroyed||g(this.dom,"ln-data-coordinator:error",{operation:n,error:o,meta:s||null})},C.prototype._owns=function(n){var s;const o=this._name||((s=this.findChildren().storeEl)==null?void 0:s.id);return!!n&&n===o},C.prototype._currentQuery=function(){const n=this.dom.getAttribute(d),o=this.dom.getAttribute(c),s=new URLSearchParams(this.dom.getAttribute(l)||""),f={};for(const w of new Set(s.keys()))f[w]=s.getAll(w);return{search:this.dom.getAttribute(i)||"",filters:f,sort:n&&o?{field:n,direction:o}:null}},C.prototype._refreshAll=function(n,o){for(const[s,f,w]of m)for(const b of this.dom.ownerDocument.querySelectorAll(s))if(this._owns(b.getAttribute(f))){if((w==="table"||w==="list")&&b.hasAttribute(w==="table"?"data-ln-table-window":"data-ln-list-window")){g(b,"ln-"+w+(o?":request-invalidate":":request-revalidate"),{query:this._currentQuery()});continue}this._serveElement(b,w,null,n)}},C.prototype._serveElement=function(n,o,s,f){const w=this.findChildren(),b=w.store;if(!b)return;s&&this._boundQueries.set(n,s);const S=this._boundQueries.get(n)||{sort:null,filters:{},search:""},E=pe(S,this._currentQuery()),u=this;return Promise.resolve(b.ready).then(()=>{if(u._destroyed)return;const h=Ze(b,w.connector);if(o==="table"||o==="list"||o==="chart")return h==="remote"?(g(n,"ln-"+o+":set-loading",{loading:!0}),g(w.connectorEl,_(w.connectorEl)+":request-query",{query:E,meta:{targetEl:n,kind:o,offset:E.offset,limit:E.limit,queryGen:S.queryGen}})):h!=="store"?g(n,"ln-"+o+":set-loading",{loading:!1}):b.getAll(E).then(y=>{u._destroyed||!u._boundDelivered||(g(n,"ln-"+o+":set-loading",{loading:!1}),g(n,"ln-"+o+":set-data",{data:y.data,total:(f==null?void 0:f.total)??y.total,filtered:(f==null?void 0:f.filtered)??y.filtered,offset:y.offset??(f==null?void 0:f.offset)??S.offset,queryGen:S.queryGen!==void 0?S.queryGen:(f==null?void 0:f.queryGen)??y.queryGen,provisional:y.provisional===!0}),u._boundDelivered.set(n,!0))});if(o==="options"){if(h==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{},meta:{targetEl:n,kind:o}});if(h==="store")return b.getAll({}).then(y=>!u._destroyed&&g(n,"ln-options:set-data",{data:y.data}))}if(o==="stat"){let y=s==null?void 0:s.filters;if(!y){const v=n.getAttribute("data-ln-stat-filter");if(v!=null&&v.includes(":")){const x=v.split(":");y={[x[0].trim()]:[x.slice(1).join(":").trim()]}}}const q=w.connector&&b&&(b.windowed&&y&&Object.keys(y).length||b.noLocalQuery)?"remote":h;if(q==="remote")return g(w.connectorEl,_(w.connectorEl)+":request-query",{query:{filters:y},meta:{targetEl:n,kind:o}});if(q==="store")return b.count(y).then(v=>!u._destroyed&&g(n,"ln-stat:set-count",{count:v}))}}).catch(h=>{u._destroyed||((o==="table"||o==="list"||o==="chart")&&g(n,"ln-"+o+":set-loading",{loading:!1}),u._reportError(o+"-query",h,{targetEl:n,kind:o}))})};function U(n){const o=n._unsubs=[],s=(u,h,y)=>{u.addEventListener(h,y),o.push(()=>u.removeEventListener(h,y))};s(n.dom,"ln-data-store:request-remote-sync",u=>{n.refreshMapper();const h=n.findChildren();h.store&&h.connector&&g(h.connectorEl,_(h.connectorEl)+":request-sync",{since:u.detail.since,meta:{op:"sync"}})}),s(n.dom,"ln-data-store:request-page",u=>{const h=n.findChildren(),y=u.detail||{};if(!h.connectorEl)return;const q=pe(y.query||{},n._currentQuery());g(h.connectorEl,_(h.connectorEl)+":request-query",{query:Object.assign({},q,{offset:y.offset,limit:y.limit,queryGen:y.queryGen})})}),s(n.dom,"ln-data-coordinator:request-create",u=>n._fanOutCreate(n.findChildren(),u.detail.data||{},u.detail.action)),s(n.dom,"ln-data-coordinator:request-update",u=>n._fanOutUpdate(n.findChildren(),u.detail.id,u.detail.data||{},u.detail.expected_version,u.detail.action)),s(n.dom,"ln-data-coordinator:request-delete",u=>n._fanOutDelete(n.findChildren(),u.detail.id)),s(n.dom,"ln-data-coordinator:request-bulk-delete",u=>n._fanOutBulkDelete(n.findChildren(),u.detail.ids||[])),s(n.dom,"ln-api-queue:send",u=>n._onQueueSend(u.detail||{})),s(n.dom,"ln-api-queue:failed",u=>{var h;return n._reportError("queue-failed",((h=u==null?void 0:u.detail)==null?void 0:h.error)||new Error("Queue failed"),(u==null?void 0:u.detail)||null)}),s(n.dom,"ln-data-store:initialized",u=>{var y;const h=n.findChildren();h.store&&!h.store.initializationError&&h.connector&&!n._noAutosync(h)&&!h.store.isSyncing&&(!((y=u.detail)!=null&&y.hasCache)||n._isStale(h))&&h.store.forceSync()});const f=()=>{const u=n.findChildren();u.store&&!u.store.initializationError&&u.connector&&!n._noAutosync(u)&&u.store.isInitialized&&!u.store.isSyncing&&u.store.forceSync()};s(n.dom,"ln-websocket-connector:connected",f),s(document,"submit",u=>n._onFormSubmit(u));const w=(u,h,y)=>{var q;n._owns(u.target.getAttribute(y))&&n._serveElement(u.target,h,h==="stat"?{filters:((q=u.detail)==null?void 0:q.filters)||null}:h==="options"?null:Ye(u.detail||{}),null)};s(document,"ln-table:request-data",u=>w(u,"table","data-ln-table-source")),s(document,"ln-list:request-data",u=>w(u,"list","data-ln-list-source")),s(document,"ln-chart:request-data",u=>w(u,"chart","data-ln-chart-source")),s(document,"ln-options:request-data",u=>w(u,"options","data-ln-options")),s(document,"ln-stat:request-count",u=>w(u,"stat","data-ln-stat"));const b=u=>{n._mutationReceipts.resolve(u.detail),n._refreshAll(null,!1)};s(n.dom,"ln-data-store:ready",b),s(n.dom,"ln-data-store:created",b),s(n.dom,"ln-data-store:updated",b),s(n.dom,"ln-data-store:deleted",b),s(n.dom,"ln-data-store:mutation-error",u=>n._mutationReceipts.reject(u.detail)),s(n.dom,"ln-data-store:synced",u=>{var h;(h=u.detail)!=null&&h.changed&&n._refreshAll(u.detail.meta,!1)}),s(n.dom,"ln-data-store:query-changed",()=>n._refreshAll(null,!0)),s(n.dom,"ln-search:change",u=>{var y;u.preventDefault();const h=((y=u.detail)==null?void 0:y.term)!=null?u.detail.term:"";h!==(n.dom.getAttribute(i)||"")&&n.dom.setAttribute(i,h)}),s(n.dom,"ln-filter:change",u=>{var he;u.preventDefault();const h=(he=u.detail)==null?void 0:he.key;if(!h)return;const y=(u.detail.values||[]).slice(),q=n._currentQuery().filters,v=q[h];if(v?v.length===y.length&&v.every((R,Q)=>R===y[Q]):!y.length)return;y.length?q[h]=y:delete q[h];const x=new URLSearchParams;Object.keys(q).forEach(R=>q[R].forEach(Q=>x.append(R,Q)));const O=x.toString();O?n.dom.setAttribute(l,O):n.dom.removeAttribute(l)}),s(n.dom,"ln-sort:change",u=>{var x,O;u.preventDefault();const h=(x=u.detail)==null?void 0:x.field,y=(O=u.detail)==null?void 0:O.direction,q=h&&y&&y!=="none"?{field:h,direction:y}:null,v=n._currentQuery().sort;!v&&!q||v&&q&&v.field===q.field&&v.direction===q.direction||(q?(n.dom.setAttribute(d,q.field),n.dom.setAttribute(c,q.direction)):(n.dom.removeAttribute(d),n.dom.removeAttribute(c)))});const S=new Set(["ln-api-connector","ln-couchdb-connector","ln-websocket-connector","ln-connector"]),E=n.findChildren().connectorEl;if(E){const u=_(E);S.add(u),s(n.dom,u+":connected",f)}S.forEach(u=>{s(n.dom,u+":fetched",h=>n._reconcileServerFetch(h.detail)),s(n.dom,u+":created",h=>n._reconcileServerMutation("create",h.detail)),s(n.dom,u+":updated",h=>n._reconcileServerMutation("update",h.detail)),s(n.dom,u+":deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,u+":bulk-deleted",h=>n._reconcileServerMutation("ack",h.detail)),s(n.dom,u+":error",h=>n._reconcileServerMutation("error",h.detail))})}C.prototype._onQueueSend=function(n){this.refreshMapper();const o=this.findChildren();if(!o.store||!o.connector||!o.queue)return;const s=n.meta||{},f=_(o.connectorEl),w=n.idempotencyKey||n.entryId,b={create:()=>g(o.connectorEl,f+":request-create",{data:n.payload,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"create",tempId:s.tempId}}),update:()=>g(o.connectorEl,f+":request-update",{id:n.targetId,data:n.payload,expected_version:n.expectedVersion,url:s.action||null,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"update",id:n.targetId}}),delete:()=>g(o.connectorEl,f+":request-delete",{id:n.targetId,idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"delete",id:n.targetId}}),"bulk-delete":()=>{var S;return g(o.connectorEl,f+":request-bulk-delete",{ids:((S=n.payload)==null?void 0:S.ids)||[],idempotencyKey:w,meta:{entryId:n.entryId,queued:!0,op:"bulk-delete",bulkKey:s.bulkKey}})}};b[n.op]&&b[n.op]()},C.prototype._onFormSubmit=function(n){const o=n.target;if(n.defaultPrevented)return;const s=o.hasAttribute(r)?o.getAttribute(r):null;if(s===null||(s?!this._owns(s):o.closest("["+e+"]")!==this.dom))return;const f=P(o);if(f!=="POST"&&f!=="PUT"&&f!=="PATCH")return;n.preventDefault();const w=K(o);delete w._method,delete w._token;const b=w.id,S=w.expected_version,E=o.getAttribute("action")||"",u=this.findChildren();delete w.id,delete w.expected_version,f==="POST"?this._fanOutCreate(u,w,E):this._fanOutUpdate(u,b,w,S,E)},C.prototype._reconcileServerFetch=function(n){if(!n)return;const o=n.meta||{},s=this.findChildren(),f=n.data;this.refreshMapper();const w=Array.isArray(f)?f:(f==null?void 0:f.data)||[],b=Array.isArray(f==null?void 0:f.deleted)?f.deleted:[],S=Array.isArray(f)?Math.floor(Date.now()/1e3):(f==null?void 0:f.synced_at)??(f==null?void 0:f.since)??Math.floor(Date.now()/1e3),E=w.map(u=>this.mapper.ingress(u));if(!(!s.store||s.store.initializationError)){if(!o.kind)return s.store.applySync(E,b,S,{total:n.total,filtered:n.filtered,offset:n.offset,queryGen:n.queryGen,targetEl:o.targetEl});s.store.applyQuery(E,{total:n.total}).then(u=>{const h=o.kind;h==="table"||h==="list"||h==="chart"?(g(o.targetEl,"ln-"+h+":set-loading",{loading:!1}),g(o.targetEl,"ln-"+h+":set-data",{data:u,total:n.total??u.length,filtered:n.filtered??u.length,offset:n.offset,queryGen:o.queryGen}),this._boundDelivered.set(o.targetEl,!0)):h==="options"?s.store.getAll({}).then(y=>g(o.targetEl,"ln-options:set-data",{data:y.data})):h==="stat"&&g(o.targetEl,"ln-stat:set-count",{count:n.filtered??n.total??E.length})})}},C.prototype._reconcileServerMutation=function(n,o){var w;if(!o)return;const s=this.findChildren(),f=o.meta||{};if(n==="create"){if(!o.record)return this._reportError("create-empty-response",new Error("Create response missing record payload"),f);const b=this.mapper.ingress(o.record);(s.storeEl?this._requestStoreMutation(s,"update",{id:f.tempId,data:b}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:resolve-create",{entryId:f.entryId,oldKey:f.tempId,newId:b.id})}).catch(S=>this._reportError("create-reconcile",S,f))}else if(n==="update"){const b=o.record?this.mapper.ingress(o.record):null;(s.storeEl&&b?this._requestStoreMutation(s,"update",{id:f.id,data:b}):Promise.resolve()).then(()=>{f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId})}).catch(S=>this._reportError("update-reconcile",S,f))}else if(n==="ack")f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:ack",{entryId:f.entryId});else if(n==="error"){const b=o.status||((w=o.error)==null?void 0:w.status)||0;f.queued&&s.queue&&g(s.queueEl,"ln-api-queue:nack",{entryId:f.entryId,reason:b===401||b===419?"auth":b===0||b>=500?"retry":"drop"}),s.storeEl&&g(s.storeEl,"ln-data-store:request-sync-failed",{error:o.error||o,status:b}),this._reportError("connector-error",o.error||o,f)}},C.prototype.destroy=function(){var n;if(this.dom[t]){for(this._destroyed=!0;(n=this._unsubs)!=null&&n.length;)this._unsubs.pop()();this._unsubs=this._boundQueries=this._boundDelivered=this._queueQueryRefresh=null,this._mutationReceipts.close(new Error("Data coordinator destroyed")),this._mutationReceipts=null,delete this.dom[t]}};function N(n,o){const s=n[t];s&&(o==="data-ln-data-coordinator-mapper"?s.refreshMapper():(o===i||o===l||o===d||o===c)&&s._queueQueryRefresh())}ue(e,t,C,"ln-data-coordinator",{extraAttributes:["data-ln-data-coordinator-mapper",i,l,d,c],onAttributeChange:N}),window[t].init=window[t]})()})();