@livenetworks/ashlar 2.1.11 → 2.1.13

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