@kodaris/krubble-app-components 1.0.0

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.
@@ -0,0 +1,3577 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@kodaris/krubble-components')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@kodaris/krubble-components'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.krApp = {}, global.kr));
5
+ })(this, (function (exports, krubbleComponents) { 'use strict';
6
+
7
+ /**
8
+ * @license
9
+ * Copyright 2019 Google LLC
10
+ * SPDX-License-Identifier: BSD-3-Clause
11
+ */
12
+ const t$3=globalThis,e$5=t$3.ShadowRoot&&(void 0===t$3.ShadyCSS||t$3.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$5=new WeakMap;let n$3 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$5&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$4=t=>new n$3("string"==typeof t?t:t+"",void 0,s$2),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(true===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$3(o,t,s$2)},S$1=(s,o)=>{if(e$5)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$3.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$5?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$4(e)})(t):t;
13
+
14
+ /**
15
+ * @license
16
+ * Copyright 2017 Google LLC
17
+ * SPDX-License-Identifier: BSD-3-Clause
18
+ */const{is:i$3,defineProperty:e$4,getOwnPropertyDescriptor:h$1,getOwnPropertyNames:r$3,getOwnPropertySymbols:o$4,getPrototypeOf:n$2}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),b={attribute:true,type:String,converter:u$1,reflect:false,useDefault:false,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let y$1 = class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$4(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h$1(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$2(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...r$3(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f$1)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}};y$1.elementStyles=[],y$1.shadowRootOptions={mode:"open"},y$1[d$1("elementProperties")]=new Map,y$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:y$1}),(a$1.reactiveElementVersions??=[]).push("2.1.1");
19
+
20
+ /**
21
+ * @license
22
+ * Copyright 2017 Google LLC
23
+ * SPDX-License-Identifier: BSD-3-Clause
24
+ */
25
+ const t$2=globalThis,i$2=t$2.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$3="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$1=`<${o$3}>`,r$2=document,l=()=>r$2.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),T=Symbol.for("lit-noChange"),E=Symbol.for("lit-nothing"),A=new WeakMap,C=r$2.createTreeWalker(r$2,129);function P(t,i){if(!a(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":3===i?"<math>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$1:d>=0?(o.push(a),s.slice(0,d)+e$3+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [P(t,l+(t[s]||"<?>")+(2===i?"</svg>":3===i?"</math>":"")),o]};class N{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=V(t,s);if(this.el=N.createElement(f,n),C.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=C.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$3)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?H:"?"===e[1]?I:"@"===e[1]?L:k}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),C.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$2.createElement("template");return s.innerHTML=t,s}}function S(t,i,s=t,e){if(i===T)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(false),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=S(t,h._$AS(t,i.values),h,e)),i}class M{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$2).importNode(i,true);C.currentNode=e;let h=C.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new R(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new z(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=C.nextNode(),o++);}return C.currentNode=r$2,e}p(t){let i=0;for(const s of this._$AV) void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class R{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=E,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??true;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=S(this,t,i),c(t)?t===E||null==t||""===t?(this._$AH!==E&&this._$AR(),this._$AH=E):t!==this._$AH&&t!==T&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t));}_(t){this._$AH!==E&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$2.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=N.createElement(P(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new M(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new N(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new R(this.O(l()),this.O(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(false,true,i);t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){ void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=E,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=E;}_$AI(t,i=this,s,e){const h=this.strings;let o=false;if(void 0===h)t=S(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==T,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=S(this,e[s+n],i,n),r===T&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===E?t=E:t!==E&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===E?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class H extends k{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===E?void 0:t;}}class I extends k{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==E);}}class L extends k{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=S(this,t,i,0)??E)===T)return;const s=this._$AH,e=t===E&&s!==E||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==E&&(s===E||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t);}}const j=t$2.litHtmlPolyfillSupport;j?.(N,R),(t$2.litHtmlVersions??=[]).push("3.3.1");const B=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new R(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
26
+
27
+ /**
28
+ * @license
29
+ * Copyright 2017 Google LLC
30
+ * SPDX-License-Identifier: BSD-3-Clause
31
+ */const s=globalThis;let i$1 = class i extends y$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const r=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=B(r,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(true);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(false);}render(){return T}};i$1._$litElement$=true,i$1["finalized"]=true,s.litElementHydrateSupport?.({LitElement:i$1});const o$2=s.litElementPolyfillSupport;o$2?.({LitElement:i$1});(s.litElementVersions??=[]).push("4.2.1");
32
+
33
+ /**
34
+ * @license
35
+ * Copyright 2017 Google LLC
36
+ * SPDX-License-Identifier: BSD-3-Clause
37
+ */
38
+ const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
39
+
40
+ /**
41
+ * @license
42
+ * Copyright 2017 Google LLC
43
+ * SPDX-License-Identifier: BSD-3-Clause
44
+ */const o$1={attribute:true,type:String,converter:u$1,reflect:false,hasChanged:f$1},r$1=(t=o$1,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
45
+
46
+ /**
47
+ * @license
48
+ * Copyright 2017 Google LLC
49
+ * SPDX-License-Identifier: BSD-3-Clause
50
+ */function r(r){return n({...r,state:true,attribute:false})}
51
+
52
+ /**
53
+ * @license
54
+ * Copyright 2017 Google LLC
55
+ * SPDX-License-Identifier: BSD-3-Clause
56
+ */
57
+ const t={ATTRIBUTE:1,CHILD:2},e$2=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i;}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
58
+
59
+ /**
60
+ * @license
61
+ * Copyright 2018 Google LLC
62
+ * SPDX-License-Identifier: BSD-3-Clause
63
+ */const e$1=e$2(class extends i{constructor(t$1){if(super(t$1),t$1.type!==t.ATTRIBUTE||"class"!==t$1.name||t$1.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(t){return " "+Object.keys(t).filter((s=>t[s])).join(" ")+" "}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter((t=>""!==t))));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)));}return T}});
64
+
65
+ /**
66
+ * @license
67
+ * Copyright 2017 Google LLC
68
+ * SPDX-License-Identifier: BSD-3-Clause
69
+ */class e extends i{constructor(i){if(super(i),this.it=E,i.type!==t.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(r){if(r===E||null==r)return this._t=void 0,this.it=r;if(r===T)return r;if("string"!=typeof r)throw Error(this.constructor.directiveName+"() called with a non-string value");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName="unsafeHTML",e.resultType=1;const o=e$2(e);
70
+
71
+ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
72
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
73
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
74
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
75
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
76
+ };
77
+ /**
78
+ * Global shell component with app bar for app switching.
79
+ *
80
+ * The shell provides a horizontal app bar across the top of the viewport containing:
81
+ * - Logo/home link on the left
82
+ * - App switcher icons in the middle
83
+ * - User avatar/menu on the right
84
+ *
85
+ * This allows individual apps (using kr-scaffold) to utilize the full width
86
+ * of the browser window while maintaining consistent global navigation.
87
+ *
88
+ * @slot - The main content (typically kr-scaffold with the app)
89
+ *
90
+ * @property {string} logo - URL for the logo image
91
+ * @property {KRApp[]} apps - Available applications for the switcher
92
+ * @property {string} activeAppId - ID of the currently active app
93
+ * @property {KRShellUser} user - User profile data
94
+ * @property {KRShellMenuItem[]} menuItems - Custom menu items for user menu
95
+ *
96
+ * @fires app-click - When an app icon is clicked. Detail: { app: KRApp }
97
+ * @fires menu-item-click - When a menu item is clicked. Detail: { item: KRShellMenuItem }
98
+ * @fires logout - When logout is clicked
99
+ */
100
+ exports.KRShell = class KRShell extends i$1 {
101
+ constructor() {
102
+ super(...arguments);
103
+ this.logo = 'https://s3.amazonaws.com/kodariscom/kodariscom/content/website/kodaris-logo-icon-light-53.png';
104
+ this.apps = [];
105
+ this.activeAppId = '';
106
+ this.user = null;
107
+ this.menuItems = [];
108
+ this.isUserMenuOpen = false;
109
+ this.isAppsMenuOpen = false;
110
+ this.pendingRequests = 0;
111
+ this.originalFetch = null;
112
+ this.originalXhrOpen = null;
113
+ // Default icons
114
+ this.defaultLogoutIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z"/></svg>';
115
+ this.appsGridIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M4 8h4V4H4v4zm6 12h4v-4h-4v4zm-6 0h4v-4H4v4zm0-6h4v-4H4v4zm6 0h4v-4h-4v4zm6-10v4h4V4h-4zm-6 4h4V4h-4v4zm6 6h4v-4h-4v4zm0 6h4v-4h-4v4z"/></svg>';
116
+ this.closeIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';
117
+ }
118
+ connectedCallback() {
119
+ super.connectedCallback();
120
+ this.installFetchInterceptor();
121
+ }
122
+ disconnectedCallback() {
123
+ super.disconnectedCallback();
124
+ this.uninstallFetchInterceptor();
125
+ }
126
+ /**
127
+ * Installs global interceptors for fetch and XMLHttpRequest to track pending HTTP requests.
128
+ * Updates `pendingRequests` state when requests start/complete.
129
+ */
130
+ installFetchInterceptor() {
131
+ if (this.originalFetch)
132
+ return;
133
+ const shell = this;
134
+ // Intercept fetch
135
+ this.originalFetch = window.fetch.bind(window);
136
+ const originalFetch = this.originalFetch;
137
+ window.fetch = function (...args) {
138
+ shell.pendingRequests++;
139
+ return originalFetch(...args).finally(() => {
140
+ shell.pendingRequests--;
141
+ });
142
+ };
143
+ // Intercept XMLHttpRequest
144
+ this.originalXhrOpen = XMLHttpRequest.prototype.open;
145
+ const originalXhrOpen = this.originalXhrOpen;
146
+ XMLHttpRequest.prototype.open = function (method, url, async = true, username, password) {
147
+ shell.pendingRequests++;
148
+ this.addEventListener('loadend', () => {
149
+ shell.pendingRequests--;
150
+ }, { once: true });
151
+ return originalXhrOpen.call(this, method, url, async, username, password);
152
+ };
153
+ }
154
+ /**
155
+ * Restores the original fetch and XMLHttpRequest functions.
156
+ */
157
+ uninstallFetchInterceptor() {
158
+ if (this.originalFetch) {
159
+ window.fetch = this.originalFetch;
160
+ this.originalFetch = null;
161
+ }
162
+ if (this.originalXhrOpen) {
163
+ XMLHttpRequest.prototype.open = this.originalXhrOpen;
164
+ this.originalXhrOpen = null;
165
+ }
166
+ }
167
+ handleLogoClick() {
168
+ this.dispatchEvent(new CustomEvent('logo-click', {
169
+ bubbles: true,
170
+ composed: true,
171
+ }));
172
+ }
173
+ toggleUserMenu() {
174
+ this.isUserMenuOpen = !this.isUserMenuOpen;
175
+ this.isAppsMenuOpen = false;
176
+ }
177
+ closeUserMenu() {
178
+ this.isUserMenuOpen = false;
179
+ }
180
+ toggleAppsMenu() {
181
+ this.isAppsMenuOpen = !this.isAppsMenuOpen;
182
+ this.isUserMenuOpen = false;
183
+ }
184
+ closeAppsMenu() {
185
+ this.isAppsMenuOpen = false;
186
+ }
187
+ handleMenuItemClick(item) {
188
+ this.closeUserMenu();
189
+ this.dispatchEvent(new CustomEvent('menu-item-click', {
190
+ detail: { item },
191
+ bubbles: true,
192
+ composed: true,
193
+ }));
194
+ }
195
+ handleLogout() {
196
+ this.closeUserMenu();
197
+ this.dispatchEvent(new CustomEvent('logout', {
198
+ bubbles: true,
199
+ composed: true,
200
+ }));
201
+ }
202
+ renderAppsMenu() {
203
+ return x `
204
+ <div class="appbar-apps">
205
+ ${this.isAppsMenuOpen ? x `
206
+ <div class="menu-backdrop" @click=${this.closeAppsMenu}></div>
207
+ ` : E}
208
+
209
+ <button
210
+ class=${e$1({
211
+ 'appbar-apps-btn': true,
212
+ 'appbar-apps-btn--open': this.isAppsMenuOpen,
213
+ })}
214
+ @click=${this.toggleAppsMenu}
215
+ >
216
+ <span class="appbar-apps-btn__icon">${o(this.appsGridIcon)}</span>
217
+ </button>
218
+
219
+ <div class=${e$1({
220
+ 'appbar-apps-menu': true,
221
+ 'appbar-apps-menu--open': this.isAppsMenuOpen,
222
+ })}>
223
+ <div class="appbar-apps-menu__header">
224
+ <h2 class="appbar-apps-menu__title">Applications</h2>
225
+ <button class="appbar-apps-menu__close" @click=${this.closeAppsMenu}>
226
+ ${o(this.closeIcon)}
227
+ </button>
228
+ </div>
229
+ <div class="appbar-apps-menu__content">
230
+ <div class="appbar-apps-menu__list">
231
+ ${this.apps.map((app) => x `
232
+ <a
233
+ class="appbar-apps-menu__item"
234
+ href=${app.url}
235
+ @click=${(e) => {
236
+ this.closeAppsMenu();
237
+ const event = new CustomEvent('app-click', {
238
+ detail: { app },
239
+ bubbles: true,
240
+ composed: true,
241
+ cancelable: true,
242
+ });
243
+ this.dispatchEvent(event);
244
+ if (event.defaultPrevented) {
245
+ e.preventDefault();
246
+ }
247
+ }}
248
+ >
249
+ ${app.name}
250
+ </a>
251
+ `)}
252
+ </div>
253
+ </div>
254
+ </div>
255
+ </div>
256
+ `;
257
+ }
258
+ renderUserMenu() {
259
+ if (!this.user)
260
+ return E;
261
+ const initials = this.user.name
262
+ .split(' ')
263
+ .map((part) => part[0])
264
+ .join('')
265
+ .toUpperCase()
266
+ .slice(0, 2);
267
+ return x `
268
+ <div class="appbar-user">
269
+ ${this.isUserMenuOpen ? x `
270
+ <div class="menu-backdrop" @click=${this.closeUserMenu}></div>
271
+ ` : E}
272
+
273
+ <div
274
+ class="appbar-user__avatar"
275
+ @click=${this.toggleUserMenu}
276
+ >
277
+ ${this.user.avatar
278
+ ? x `<img src=${this.user.avatar} alt=${this.user.name} />`
279
+ : initials}
280
+ </div>
281
+
282
+ <div class=${e$1({
283
+ 'appbar-user__menu': true,
284
+ 'appbar-user__menu--open': this.isUserMenuOpen,
285
+ })}>
286
+ <div class="appbar-user__header">
287
+ <p class="appbar-user__name">${this.user.name}</p>
288
+ ${this.user.email ? x `
289
+ <p class="appbar-user__email">${this.user.email}</p>
290
+ ` : E}
291
+ </div>
292
+
293
+ ${this.menuItems.map((item) => item.divider
294
+ ? x `<div class="appbar-user__menu-divider"></div>`
295
+ : x `
296
+ <button
297
+ class="appbar-user__menu-item"
298
+ @click=${() => this.handleMenuItemClick(item)}
299
+ >
300
+ ${item.icon ? x `
301
+ <span class="appbar-user__menu-item__icon">${o(item.icon)}</span>
302
+ ` : E}
303
+ ${item.label}
304
+ </button>
305
+ `)}
306
+
307
+ ${this.menuItems.length > 0 ? x `
308
+ <div class="appbar-user__menu-divider"></div>
309
+ ` : E}
310
+
311
+ <button
312
+ class="appbar-user__menu-item appbar-user__menu-item--danger"
313
+ @click=${this.handleLogout}
314
+ >
315
+ <span class="appbar-user__menu-item__icon">${o(this.defaultLogoutIcon)}</span>
316
+ Sign Out
317
+ </button>
318
+ </div>
319
+ </div>
320
+ `;
321
+ }
322
+ render() {
323
+ return x `
324
+ <div class=${e$1({
325
+ 'progress': true,
326
+ 'progress--loading': this.pendingRequests > 0,
327
+ })}>
328
+ <div class="progress__track"></div>
329
+ <div class="progress__bar progress__bar--primary">
330
+ <span class="progress__bar-inner"></span>
331
+ </div>
332
+ <div class="progress__bar progress__bar--secondary">
333
+ <span class="progress__bar-inner"></span>
334
+ </div>
335
+ </div>
336
+
337
+ <header class="appbar">
338
+ <!-- Logo -->
339
+ ${this.logo ? x `
340
+ <div class="appbar-logo" @click=${this.handleLogoClick}>
341
+ <img src=${this.logo} alt="Home" />
342
+ </div>
343
+ <div class="appbar-divider"></div>
344
+ ` : E}
345
+
346
+ <!-- App Switcher -->
347
+ ${this.renderAppsMenu()}
348
+
349
+ <div class="appbar-spacer"></div>
350
+
351
+ <!-- User -->
352
+ ${this.renderUserMenu()}
353
+ </header>
354
+
355
+ <div class="subbar">
356
+ <nav class="breadcrumbs">
357
+ <a href="#">Home</a>
358
+ <span class="breadcrumbs__separator">/</span>
359
+ <a href="#">Companies</a>
360
+ <span class="breadcrumbs__separator">/</span>
361
+ <span>Acme Corp</span>
362
+ </nav>
363
+ </div>
364
+
365
+ <main class="main">
366
+ <slot></slot>
367
+ </main>
368
+ `;
369
+ }
370
+ };
371
+ exports.KRShell.styles = i$4 `
372
+ :host {
373
+ display: flex;
374
+ flex-direction: column;
375
+ height: 100vh;
376
+ width: 100vw;
377
+ --kr-shell-bar-height: 48px;
378
+ --kr-shell-bar-bg: #10172a; /* matches scaffold nav-bg */
379
+ /* --kr-shell-bar-bg: #0a0f1a; */ /* original darker bg */
380
+ --kr-shell-bar-border: rgba(255, 255, 255, 0.08);
381
+ --kr-shell-icon-size: 36px;
382
+ --kr-shell-icon-color: rgba(255, 255, 255, 0.7);
383
+ --kr-shell-icon-color-hover: rgba(255, 255, 255, 1);
384
+ --kr-shell-icon-color-active: #beea4e;
385
+ --kr-shell-icon-bg-hover: rgba(255, 255, 255, 0.08);
386
+ --kr-shell-icon-bg-active: rgba(190, 234, 78, 0.15);
387
+ --kr-shell-tooltip-bg: #1a2332;
388
+ --kr-shell-tooltip-color: #ffffff;
389
+ --kr-shell-menu-bg: #1a2332;
390
+ --kr-shell-menu-border: rgba(255, 255, 255, 0.1);
391
+ --kr-shell-menu-hover: rgba(255, 255, 255, 0.08);
392
+ }
393
+
394
+ *,
395
+ *::before,
396
+ *::after {
397
+ box-sizing: border-box;
398
+ }
399
+
400
+ /* App Bar */
401
+ .appbar {
402
+ height: var(--kr-shell-bar-height);
403
+ background: var(--kr-shell-bar-bg);
404
+ border-bottom: 1px solid var(--kr-shell-bar-border);
405
+ display: flex;
406
+ align-items: center;
407
+ padding: 0 16px;
408
+ flex-shrink: 0;
409
+ z-index: 100;
410
+ }
411
+
412
+ /* Logo */
413
+ .appbar-logo {
414
+ cursor: pointer;
415
+ margin-right: 8px;
416
+ }
417
+
418
+ .appbar-logo img {
419
+ display: block;
420
+ max-width: 24px;
421
+ max-height: 24px;
422
+ object-fit: contain;
423
+ }
424
+
425
+ /* Divider */
426
+ .appbar-divider {
427
+ width: 1px;
428
+ height: 24px;
429
+ background: #ffffff4f;
430
+ margin: 0 10px;
431
+ }
432
+
433
+ /* Apps Button */
434
+ .appbar-apps {
435
+ position: relative;
436
+ }
437
+
438
+ .appbar-apps-btn {
439
+ width: var(--kr-shell-icon-size);
440
+ height: var(--kr-shell-icon-size);
441
+ display: flex;
442
+ align-items: center;
443
+ justify-content: center;
444
+ border-radius: 6px;
445
+ cursor: pointer;
446
+ color: var(--kr-shell-icon-color);
447
+ background: transparent;
448
+ border: none;
449
+ padding: 0;
450
+ transition: all 0.15s ease;
451
+ }
452
+
453
+ .appbar-apps-btn:hover {
454
+ color: var(--kr-shell-icon-color-hover);
455
+ background: var(--kr-shell-icon-bg-hover);
456
+ }
457
+
458
+ .appbar-apps-btn--open {
459
+ color: var(--kr-shell-icon-color-hover);
460
+ background: var(--kr-shell-icon-bg-hover);
461
+ }
462
+
463
+ .appbar-apps-btn__icon {
464
+ width: 24px;
465
+ height: 24px;
466
+ display: flex;
467
+ align-items: center;
468
+ justify-content: center;
469
+ color: #ffffff;
470
+ }
471
+
472
+ .appbar-apps-btn__icon svg {
473
+ width: 100%;
474
+ height: 100%;
475
+ fill: currentColor;
476
+ }
477
+
478
+ /* Apps Megamenu */
479
+ .appbar-apps-menu {
480
+ position: absolute;
481
+ left: 0;
482
+ top: 100%;
483
+ margin-top: 6px;
484
+ min-width: 320px;
485
+ min-height: 90vh;
486
+ max-height: calc(100vh - var(--kr-shell-bar-height));
487
+ background: #10172a;
488
+ border: 1px solid var(--kr-shell-menu-border);
489
+ border-top: none;
490
+ border-radius: 0 0 8px 8px;
491
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
492
+ z-index: 1000;
493
+ opacity: 0;
494
+ visibility: hidden;
495
+ transform: translateY(-10px);
496
+ transition: all 0.15s ease;
497
+ overflow-y: auto;
498
+ }
499
+
500
+ .appbar-apps-menu--open {
501
+ opacity: 1;
502
+ visibility: visible;
503
+ transform: translateY(0);
504
+ }
505
+
506
+ .appbar-apps-menu__header {
507
+ display: flex;
508
+ align-items: center;
509
+ justify-content: space-between;
510
+ padding: 16px 16px 16px 24px;
511
+ border-bottom: 1px solid var(--kr-shell-menu-border);
512
+ }
513
+
514
+ .appbar-apps-menu__title {
515
+ font-size: 16px;
516
+ font-weight: 500;
517
+ color: #ffffff;
518
+ margin: 0;
519
+ }
520
+
521
+ .appbar-apps-menu__close {
522
+ width: 32px;
523
+ height: 32px;
524
+ display: flex;
525
+ align-items: center;
526
+ justify-content: center;
527
+ background: none;
528
+ border: none;
529
+ color: rgba(255, 255, 255, 0.6);
530
+ cursor: pointer;
531
+ border-radius: 6px;
532
+ transition: all 0.15s ease;
533
+ }
534
+
535
+ .appbar-apps-menu__close:hover {
536
+ background: var(--kr-shell-menu-hover);
537
+ color: #ffffff;
538
+ }
539
+
540
+ .appbar-apps-menu__close svg {
541
+ width: 24px;
542
+ height: 24px;
543
+ fill: #ffffff;
544
+ }
545
+
546
+ .appbar-apps-menu__content {
547
+ padding: 16px 8px;
548
+ }
549
+
550
+ .appbar-apps-menu__list {
551
+ display: flex;
552
+ flex-direction: column;
553
+ gap: 2px;
554
+ max-width: 320px;
555
+ }
556
+
557
+ .appbar-apps-menu__item {
558
+ display: block;
559
+ width: 100%;
560
+ padding: 12px 16px;
561
+ background: none;
562
+ border: none;
563
+ color: #ffffff;
564
+ font-size: 14px;
565
+ font-family: inherit;
566
+ text-align: left;
567
+ text-decoration: none;
568
+ cursor: pointer;
569
+ border-radius: 6px;
570
+ transition: all 0.15s ease;
571
+ }
572
+
573
+ .appbar-apps-menu__item:hover {
574
+ background: var(--kr-shell-menu-hover);
575
+ }
576
+
577
+ .appbar-apps-menu__item--active,
578
+ .appbar-apps-menu__item--active:hover {
579
+ color: var(--kr-shell-icon-color-active);
580
+ }
581
+
582
+ /* Spacer to push user to the right */
583
+ .appbar-spacer {
584
+ flex: 1;
585
+ }
586
+
587
+ /* User Section */
588
+ .appbar-user {
589
+ position: relative;
590
+ margin-left: 8px;
591
+ }
592
+
593
+ .appbar-user__avatar {
594
+ width: 32px;
595
+ height: 32px;
596
+ border-radius: 50%;
597
+ background: #beea4e;
598
+ color: #0a0f1a;
599
+ display: flex;
600
+ align-items: center;
601
+ justify-content: center;
602
+ font-size: 12px;
603
+ font-weight: 600;
604
+ cursor: pointer;
605
+ overflow: hidden;
606
+ border: 2px solid transparent;
607
+ transition: border-color 0.15s ease;
608
+ }
609
+
610
+ .appbar-user__avatar:hover {
611
+ border-color: rgba(255, 255, 255, 0.3);
612
+ }
613
+
614
+ .appbar-user__avatar img {
615
+ width: 100%;
616
+ height: 100%;
617
+ object-fit: cover;
618
+ }
619
+
620
+ /* User Menu */
621
+ .appbar-user__menu {
622
+ position: absolute;
623
+ right: 0;
624
+ top: calc(100% + 8px);
625
+ min-width: 200px;
626
+ background: var(--kr-shell-menu-bg);
627
+ border: 1px solid var(--kr-shell-menu-border);
628
+ border-radius: 8px;
629
+ padding: 8px;
630
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
631
+ z-index: 1000;
632
+ opacity: 0;
633
+ visibility: hidden;
634
+ transform: translateY(-8px);
635
+ transition: all 0.15s ease;
636
+ }
637
+
638
+ .appbar-user__menu--open {
639
+ opacity: 1;
640
+ visibility: visible;
641
+ transform: translateY(0);
642
+ }
643
+
644
+ .appbar-user__header {
645
+ padding: 8px 12px 12px;
646
+ border-bottom: 1px solid var(--kr-shell-menu-border);
647
+ margin-bottom: 8px;
648
+ }
649
+
650
+ .appbar-user__name {
651
+ font-size: 14px;
652
+ font-weight: 600;
653
+ color: #ffffff;
654
+ margin: 0 0 2px;
655
+ }
656
+
657
+ .appbar-user__email {
658
+ font-size: 12px;
659
+ color: rgba(255, 255, 255, 0.6);
660
+ margin: 0;
661
+ }
662
+
663
+ .appbar-user__menu-item {
664
+ display: flex;
665
+ align-items: center;
666
+ gap: 10px;
667
+ width: 100%;
668
+ padding: 10px 12px;
669
+ background: none;
670
+ border: none;
671
+ color: rgba(255, 255, 255, 0.8);
672
+ font-size: 13px;
673
+ font-family: inherit;
674
+ text-align: left;
675
+ cursor: pointer;
676
+ border-radius: 6px;
677
+ transition: all 0.15s ease;
678
+ }
679
+
680
+ .appbar-user__menu-item:hover {
681
+ background: var(--kr-shell-menu-hover);
682
+ color: #ffffff;
683
+ }
684
+
685
+ .appbar-user__menu-item--danger {
686
+ color: #f87171;
687
+ }
688
+
689
+ .appbar-user__menu-item--danger:hover {
690
+ background: rgba(248, 113, 113, 0.1);
691
+ color: #f87171;
692
+ }
693
+
694
+ .appbar-user__menu-item__icon {
695
+ width: 16px;
696
+ height: 16px;
697
+ display: flex;
698
+ align-items: center;
699
+ justify-content: center;
700
+ flex-shrink: 0;
701
+ }
702
+
703
+ .appbar-user__menu-item__icon svg {
704
+ width: 100%;
705
+ height: 100%;
706
+ fill: currentColor;
707
+ }
708
+
709
+ .appbar-user__menu-divider {
710
+ height: 1px;
711
+ background: var(--kr-shell-menu-border);
712
+ margin: 8px 0;
713
+ }
714
+
715
+ /* Secondary App Bar */
716
+ .subbar {
717
+ height: 30px;
718
+ background: #364365;
719
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
720
+ display: flex;
721
+ align-items: center;
722
+ padding: 0 16px;
723
+ flex-shrink: 0;
724
+ }
725
+
726
+ .breadcrumbs {
727
+ display: flex;
728
+ align-items: center;
729
+ gap: 8px;
730
+ font-size: 12px;
731
+ color: #ffffff;
732
+ }
733
+
734
+ .breadcrumbs a {
735
+ color: #ffffff;
736
+ text-decoration: none;
737
+ }
738
+
739
+ .breadcrumbs a:hover {
740
+ text-decoration: underline;
741
+ }
742
+
743
+ .breadcrumbs__separator {
744
+ color: #ffffff;
745
+ }
746
+
747
+ /* Main Content */
748
+ .main {
749
+ flex: 1;
750
+ min-height: 0;
751
+ display: flex;
752
+ flex-direction: column;
753
+ overflow: hidden;
754
+ position: relative;
755
+ }
756
+
757
+ /* Click outside overlay */
758
+ .menu-backdrop {
759
+ position: fixed;
760
+ inset: 0;
761
+ z-index: 999;
762
+ }
763
+
764
+ /* Progress bar */
765
+ .progress {
766
+ position: fixed;
767
+ top: 0;
768
+ left: 0;
769
+ right: 0;
770
+ height: 4px;
771
+ overflow-x: hidden;
772
+ z-index: 1000;
773
+ display: none;
774
+ }
775
+
776
+ .progress--loading {
777
+ display: block;
778
+ }
779
+
780
+ .progress__track {
781
+ position: absolute;
782
+ top: 0;
783
+ bottom: 0;
784
+ width: 100%;
785
+ background: rgb(190 234 78 / 50%); // rgba(190, 234, 78, 0.3);
786
+ }
787
+
788
+ .progress__bar {
789
+ position: absolute;
790
+ top: 0;
791
+ bottom: 0;
792
+ width: 100%;
793
+ transform-origin: left center;
794
+ }
795
+
796
+ .progress__bar-inner {
797
+ display: inline-block;
798
+ position: absolute;
799
+ width: 100%;
800
+ height: 100%;
801
+ background: #beea4e;
802
+ }
803
+
804
+ .progress__bar--primary {
805
+ left: -145.166611%;
806
+ }
807
+
808
+ .progress--loading .progress__bar--primary {
809
+ animation: progress-primary-translate 2s infinite linear;
810
+ }
811
+
812
+ .progress--loading .progress__bar--primary .progress__bar-inner {
813
+ animation: progress-primary-scale 2s infinite linear;
814
+ }
815
+
816
+ .progress__bar--secondary {
817
+ left: -54.888891%;
818
+ }
819
+
820
+ .progress--loading .progress__bar--secondary {
821
+ animation: progress-secondary-translate 2s infinite linear;
822
+ }
823
+
824
+ .progress--loading .progress__bar--secondary .progress__bar-inner {
825
+ animation: progress-secondary-scale 2s infinite linear;
826
+ }
827
+
828
+ @keyframes progress-primary-translate {
829
+ 0% {
830
+ transform: translateX(0);
831
+ }
832
+ 20% {
833
+ animation-timing-function: cubic-bezier(0.5, 0, 0.701732, 0.495819);
834
+ transform: translateX(0);
835
+ }
836
+ 59.15% {
837
+ animation-timing-function: cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);
838
+ transform: translateX(83.67142%);
839
+ }
840
+ 100% {
841
+ transform: translateX(200.611057%);
842
+ }
843
+ }
844
+
845
+ @keyframes progress-primary-scale {
846
+ 0% {
847
+ transform: scaleX(0.08);
848
+ }
849
+ 36.65% {
850
+ animation-timing-function: cubic-bezier(0.334731, 0.12482, 0.785844, 1);
851
+ transform: scaleX(0.08);
852
+ }
853
+ 69.15% {
854
+ animation-timing-function: cubic-bezier(0.06, 0.11, 0.6, 1);
855
+ transform: scaleX(0.661479);
856
+ }
857
+ 100% {
858
+ transform: scaleX(0.08);
859
+ }
860
+ }
861
+
862
+ @keyframes progress-secondary-translate {
863
+ 0% {
864
+ animation-timing-function: cubic-bezier(0.15, 0, 0.515058, 0.409685);
865
+ transform: translateX(0);
866
+ }
867
+ 25% {
868
+ animation-timing-function: cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);
869
+ transform: translateX(37.651913%);
870
+ }
871
+ 48.35% {
872
+ animation-timing-function: cubic-bezier(0.4, 0.627035, 0.6, 0.902026);
873
+ transform: translateX(84.386165%);
874
+ }
875
+ 100% {
876
+ transform: translateX(160.277782%);
877
+ }
878
+ }
879
+
880
+ @keyframes progress-secondary-scale {
881
+ 0% {
882
+ animation-timing-function: cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);
883
+ transform: scaleX(0.08);
884
+ }
885
+ 19.15% {
886
+ animation-timing-function: cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);
887
+ transform: scaleX(0.457104);
888
+ }
889
+ 44.15% {
890
+ animation-timing-function: cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);
891
+ transform: scaleX(0.72796);
892
+ }
893
+ 100% {
894
+ transform: scaleX(0.08);
895
+ }
896
+ }
897
+ `;
898
+ __decorate$5([
899
+ n({ type: String })
900
+ ], exports.KRShell.prototype, "logo", void 0);
901
+ __decorate$5([
902
+ n({ type: Array })
903
+ ], exports.KRShell.prototype, "apps", void 0);
904
+ __decorate$5([
905
+ n({ type: String, attribute: 'active-app-id' })
906
+ ], exports.KRShell.prototype, "activeAppId", void 0);
907
+ __decorate$5([
908
+ n({ type: Object })
909
+ ], exports.KRShell.prototype, "user", void 0);
910
+ __decorate$5([
911
+ n({ type: Array, attribute: 'menu-items' })
912
+ ], exports.KRShell.prototype, "menuItems", void 0);
913
+ __decorate$5([
914
+ r()
915
+ ], exports.KRShell.prototype, "isUserMenuOpen", void 0);
916
+ __decorate$5([
917
+ r()
918
+ ], exports.KRShell.prototype, "isAppsMenuOpen", void 0);
919
+ __decorate$5([
920
+ r()
921
+ ], exports.KRShell.prototype, "pendingRequests", void 0);
922
+ exports.KRShell = __decorate$5([
923
+ t$1('kr-shell')
924
+ ], exports.KRShell);
925
+
926
+ class KRClient {
927
+ constructor() {
928
+ this._url = `https://content.kodaris.com`;
929
+ }
930
+ static getInstance() {
931
+ if (!KRClient._instance) {
932
+ KRClient._instance = new KRClient();
933
+ }
934
+ return KRClient._instance;
935
+ }
936
+ fetch(options) {
937
+ let url = options.url;
938
+ // Add on the default base url if user
939
+ // has not provided the full url
940
+ if (url.indexOf('http') !== 0) {
941
+ url = this._url + url;
942
+ }
943
+ if (options.params) {
944
+ url += '?';
945
+ Object.keys(options.params).forEach((key, keyIdx) => {
946
+ if (keyIdx > 0) {
947
+ url += '&';
948
+ }
949
+ url += `${key}=${options.params[key]}`;
950
+ });
951
+ }
952
+ // fixme
953
+ if (!options) {
954
+ options = {};
955
+ }
956
+ if (!options.headers) {
957
+ options.headers = {};
958
+ }
959
+ if (!options.headers['Content-Type']) {
960
+ options.headers['Content-Type'] = 'application/json';
961
+ }
962
+ options.credentials = 'include';
963
+ // User and Customer apis require CSRF tokens on non-GET reequests
964
+ let token;
965
+ if (url.indexOf('/api/user/') > -1 || url.indexOf('/api/customer/') > -1) {
966
+ token = fetch(`${this._url}/api/user/customer/authToken`, { credentials: 'include' });
967
+ }
968
+ else {
969
+ token = Promise.resolve(null);
970
+ }
971
+ let response;
972
+ return token
973
+ .then(res => res?.json())
974
+ .then(res => {
975
+ if (res?.data) {
976
+ options.headers['X-CSRF-TOKEN'] = res.data;
977
+ }
978
+ return fetch(url, options);
979
+ })
980
+ .then(res => {
981
+ response = res;
982
+ return res.json();
983
+ })
984
+ .then(json => {
985
+ if (!response?.ok) {
986
+ return Promise.reject(json);
987
+ }
988
+ return Promise.resolve(json);
989
+ });
990
+ }
991
+ }
992
+ KRClient._instance = null;
993
+
994
+ var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
995
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
996
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
997
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
998
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
999
+ };
1000
+ let KRNavItemEdit = class KRNavItemEdit extends i$1 {
1001
+ constructor() {
1002
+ super(...arguments);
1003
+ this.label = '';
1004
+ this.icon = '';
1005
+ this.url = '';
1006
+ this.active = true;
1007
+ }
1008
+ connectedCallback() {
1009
+ super.connectedCallback();
1010
+ if (this.data) {
1011
+ this.label = this.data.label || '';
1012
+ this.icon = this.data.icon || '';
1013
+ this.url = this.data.url || '';
1014
+ this.active = this.data.active !== false;
1015
+ }
1016
+ }
1017
+ handleLabelInput(e) {
1018
+ const textField = e.target;
1019
+ this.label = textField.value;
1020
+ }
1021
+ handleIconInput(e) {
1022
+ const textField = e.target;
1023
+ this.icon = textField.value;
1024
+ }
1025
+ handleUrlInput(e) {
1026
+ const textField = e.target;
1027
+ this.url = textField.value;
1028
+ }
1029
+ handleActiveChange(e) {
1030
+ this.active = e.target.checked;
1031
+ }
1032
+ handleCancel() {
1033
+ this.dialogRef.close(undefined);
1034
+ }
1035
+ handleSave() {
1036
+ this.dialogRef.close({
1037
+ label: this.label,
1038
+ icon: this.icon || undefined,
1039
+ url: this.url || undefined,
1040
+ active: this.active,
1041
+ });
1042
+ }
1043
+ handleKeyDown(e) {
1044
+ if (e.key === 'Enter') {
1045
+ this.handleSave();
1046
+ }
1047
+ }
1048
+ render() {
1049
+ return x `
1050
+ <h2>Edit Navigation Item</h2>
1051
+
1052
+ <div class="form-group">
1053
+ <kr-text-field
1054
+ label="Label"
1055
+ name="label"
1056
+ .value=${this.label}
1057
+ @input=${this.handleLabelInput}
1058
+ @keydown=${this.handleKeyDown}
1059
+ placeholder="Enter label"
1060
+ ></kr-text-field>
1061
+ </div>
1062
+
1063
+ <div class="form-group">
1064
+ <kr-text-field
1065
+ label="Icon (emoji or SVG)"
1066
+ name="icon"
1067
+ .value=${this.icon}
1068
+ @input=${this.handleIconInput}
1069
+ @keydown=${this.handleKeyDown}
1070
+ placeholder="e.g. 📊 or <svg>...</svg>"
1071
+ ></kr-text-field>
1072
+ </div>
1073
+
1074
+ <div class="form-group">
1075
+ <kr-text-field
1076
+ label="URL"
1077
+ name="url"
1078
+ .value=${this.url}
1079
+ @input=${this.handleUrlInput}
1080
+ @keydown=${this.handleKeyDown}
1081
+ placeholder="e.g. /ci/my-page or https://..."
1082
+ ></kr-text-field>
1083
+ </div>
1084
+
1085
+ <div class="form-group">
1086
+ <div class="checkbox-group">
1087
+ <input
1088
+ type="checkbox"
1089
+ id="active"
1090
+ .checked=${this.active}
1091
+ @change=${this.handleActiveChange}
1092
+ />
1093
+ <label class="checkbox-label" for="active">Visible in navigation</label>
1094
+ </div>
1095
+ </div>
1096
+
1097
+ <div class="actions">
1098
+ <button class="btn-cancel" @click=${this.handleCancel}>Cancel</button>
1099
+ <button class="btn-save" @click=${this.handleSave}>Save</button>
1100
+ </div>
1101
+ `;
1102
+ }
1103
+ };
1104
+ KRNavItemEdit.styles = i$4 `
1105
+ :host {
1106
+ display: block;
1107
+ width: 360px;
1108
+ padding: 24px;
1109
+ color: rgba(255, 255, 255, 0.9);
1110
+
1111
+ /* Dark theme for kr-text-field */
1112
+ --kr-text-field-label-color: rgba(255, 255, 255, 0.7);
1113
+ --kr-text-field-border-color: rgba(255, 255, 255, 0.1);
1114
+ --kr-text-field-bg: rgba(255, 255, 255, 0.05);
1115
+ --kr-text-field-color: #ffffff;
1116
+ --kr-text-field-focus-border-color: #beea4e;
1117
+ --kr-text-field-focus-ring-color: rgba(190, 234, 78, 0.1);
1118
+ --kr-text-field-placeholder-color: rgba(255, 255, 255, 0.3);
1119
+ --kr-text-field-helper-color: rgba(255, 255, 255, 0.5);
1120
+ }
1121
+
1122
+ h2 {
1123
+ margin: 0 0 24px 0;
1124
+ font-size: 18px;
1125
+ font-weight: 600;
1126
+ color: #ffffff;
1127
+ }
1128
+
1129
+ .form-group {
1130
+ margin-bottom: 20px;
1131
+ }
1132
+
1133
+ .checkbox-group {
1134
+ display: flex;
1135
+ align-items: center;
1136
+ gap: 10px;
1137
+ }
1138
+
1139
+ input[type="checkbox"] {
1140
+ width: 18px;
1141
+ height: 18px;
1142
+ accent-color: #beea4e;
1143
+ cursor: pointer;
1144
+ }
1145
+
1146
+ .checkbox-label {
1147
+ font-size: 14px;
1148
+ color: rgba(255, 255, 255, 0.9);
1149
+ cursor: pointer;
1150
+ }
1151
+
1152
+ .actions {
1153
+ display: flex;
1154
+ gap: 12px;
1155
+ justify-content: flex-end;
1156
+ margin-top: 28px;
1157
+ }
1158
+
1159
+ button {
1160
+ padding: 10px 20px;
1161
+ border-radius: 6px;
1162
+ font-size: 14px;
1163
+ font-weight: 500;
1164
+ font-family: inherit;
1165
+ cursor: pointer;
1166
+ transition: all 0.15s ease;
1167
+ }
1168
+
1169
+ .btn-cancel {
1170
+ background: rgba(255, 255, 255, 0.05);
1171
+ border: 1px solid rgba(255, 255, 255, 0.1);
1172
+ color: rgba(255, 255, 255, 0.8);
1173
+ }
1174
+
1175
+ .btn-cancel:hover {
1176
+ background: rgba(255, 255, 255, 0.1);
1177
+ color: #ffffff;
1178
+ }
1179
+
1180
+ .btn-save {
1181
+ background: #beea4e;
1182
+ border: none;
1183
+ color: #10172a;
1184
+ }
1185
+
1186
+ .btn-save:hover {
1187
+ background: #d4f472;
1188
+ }
1189
+ `;
1190
+ __decorate$4([
1191
+ r()
1192
+ ], KRNavItemEdit.prototype, "label", void 0);
1193
+ __decorate$4([
1194
+ r()
1195
+ ], KRNavItemEdit.prototype, "icon", void 0);
1196
+ __decorate$4([
1197
+ r()
1198
+ ], KRNavItemEdit.prototype, "url", void 0);
1199
+ __decorate$4([
1200
+ r()
1201
+ ], KRNavItemEdit.prototype, "active", void 0);
1202
+ KRNavItemEdit = __decorate$4([
1203
+ t$1('kr-nav-item-edit')
1204
+ ], KRNavItemEdit);
1205
+
1206
+ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
1207
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1208
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1209
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1210
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1211
+ };
1212
+ /**
1213
+ * Application shell component with nav drawer and main content area.
1214
+ *
1215
+ * ## Features
1216
+ * - Collapsible navigation drawer with hierarchical items (groups and items)
1217
+ * - User profile display in footer with customization menu
1218
+ * - Edit mode for customizing navigation (rename, reorder, hide items, add custom items)
1219
+ * - Drag and drop reordering in edit mode
1220
+ * - Persistence of customizations via preference API (global/organization level)
1221
+ *
1222
+ * ## Nav Customization
1223
+ * Users can customize the navigation by clicking their profile and selecting
1224
+ * "Customize Navigation". This enters edit mode where users can:
1225
+ * - Right-click items to edit label, icon, or visibility
1226
+ * - Right-click to add new items above/below existing items
1227
+ * - Drag and drop to reorder items or move them between groups
1228
+ *
1229
+ * Customizations are stored globally and apply to all users.
1230
+ *
1231
+ * ## Preference Storage
1232
+ * Preferences are stored as JSON with the following structure:
1233
+ * ```json
1234
+ * {
1235
+ * "nav": {
1236
+ * "itemId": { "label": "Custom Label", "icon": "...", "active": true, "order": 0 },
1237
+ * "custom-123": { "type": "item", "label": "New Item", "url": "/path", ... }
1238
+ * }
1239
+ * }
1240
+ * ```
1241
+ *
1242
+ * The `nav` object is a delta - it only contains overrides for existing items
1243
+ * or definitions for custom items (prefixed with "custom-").
1244
+ *
1245
+ * ## API Endpoints Used
1246
+ * - GET `/api/system/preference/json/scaffold?global=true` - load preferences
1247
+ * - POST `/api/system/preference/json/scaffold?global=true` - create new preference
1248
+ * - PUT `/api/system/preference/json/scaffold/{uuid}?global=true` - update existing preference
1249
+ *
1250
+ * @slot - The main content
1251
+ *
1252
+ * @property {string} logo - URL for the logo image
1253
+ * @property {string} title - Title text to display instead of logo
1254
+ * @property {'light'|'dark'} scheme - Color scheme: 'light' (default) or 'dark'
1255
+ * @property {KRNavItem[]} nav - Navigation items as JSON array
1256
+ * @property {KRUser} user - User profile data
1257
+ *
1258
+ *
1259
+ * TODO
1260
+ * - Don't hardcode breadcrumbs
1261
+ * - Look at renderNormalFooter and renderEditFooter and see if that is what we want to do
1262
+ */
1263
+ exports.KRScaffold = class KRScaffold extends i$1 {
1264
+ constructor() {
1265
+ super();
1266
+ /**
1267
+ * HTTP client for API calls
1268
+ */
1269
+ this.http = KRClient.getInstance();
1270
+ /**
1271
+ * Default icon for nav items without an icon (shown at top level)
1272
+ */
1273
+ this.defaultNavItemIcon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="12" r="10"/></svg>';
1274
+ this.navItemsExpanded = new Set();
1275
+ this.navQuery = '';
1276
+ this.activeNavItemId = null;
1277
+ this.isNavScrolled = false;
1278
+ this.isNavOpened = true;
1279
+ this.isEditing = false;
1280
+ this.isUserMenuOpen = false;
1281
+ this.pref = { nav: {} };
1282
+ this.draggedNavItemId = null;
1283
+ this.navItemDropTargetId = null;
1284
+ this.navItemDropPosition = 'above';
1285
+ this.pendingRequests = 0;
1286
+ this.originalFetch = null;
1287
+ this.originalXhrOpen = null;
1288
+ this.navItemDragPreview = null;
1289
+ this.navItemDragStartY = 0;
1290
+ this.isNavItemDragging = false;
1291
+ this.navItemDragExpandTimeout = null;
1292
+ this.navInitialized = false;
1293
+ this.logo = '';
1294
+ this.title = '';
1295
+ this.scheme = 'light';
1296
+ this.nav = [];
1297
+ this.navIconsDisplayed = false;
1298
+ this.navExpanded = false;
1299
+ this.user = null;
1300
+ /**
1301
+ * Whether to show the subbar with menu toggle
1302
+ */
1303
+ this.subbar = false;
1304
+ /**
1305
+ * Breadcrumbs to display in the subbar
1306
+ */
1307
+ this.breadcrumbs = [];
1308
+ this.boundHandleMouseMove = this.handleMouseMove.bind(this);
1309
+ this.boundHandleMouseUp = this.handleMouseUp.bind(this);
1310
+ }
1311
+ connectedCallback() {
1312
+ super.connectedCallback();
1313
+ this.loadPref();
1314
+ this.installFetchInterceptor();
1315
+ }
1316
+ updated(changedProperties) {
1317
+ super.updated(changedProperties);
1318
+ if (changedProperties.has('nav') && this.nav.length > 0) {
1319
+ this.updateActiveNavItem();
1320
+ if (this.navExpanded && !this.navInitialized) {
1321
+ this.navInitialized = true;
1322
+ this.getComputedNav()
1323
+ .filter(item => item.type === 'group')
1324
+ .forEach(group => this.navItemsExpanded.add(group.id));
1325
+ }
1326
+ }
1327
+ }
1328
+ disconnectedCallback() {
1329
+ super.disconnectedCallback();
1330
+ this.uninstallFetchInterceptor();
1331
+ }
1332
+ /**
1333
+ * Installs global interceptors for fetch and XMLHttpRequest to track pending HTTP requests.
1334
+ * Updates `pendingRequests` state when requests start/complete.
1335
+ */
1336
+ installFetchInterceptor() {
1337
+ if (this.originalFetch)
1338
+ return;
1339
+ const scaffold = this;
1340
+ // Intercept fetch
1341
+ this.originalFetch = window.fetch.bind(window);
1342
+ const originalFetch = this.originalFetch; // Capture in local scope to avoid null reference after uninstall
1343
+ window.fetch = function (...args) {
1344
+ scaffold.pendingRequests++;
1345
+ return originalFetch(...args).finally(() => {
1346
+ scaffold.pendingRequests--;
1347
+ });
1348
+ };
1349
+ // Intercept XMLHttpRequest
1350
+ this.originalXhrOpen = XMLHttpRequest.prototype.open;
1351
+ const originalXhrOpen = this.originalXhrOpen; // Capture in local scope to avoid null reference after uninstall
1352
+ XMLHttpRequest.prototype.open = function (method, url, async = true, username, password) {
1353
+ scaffold.pendingRequests++;
1354
+ this.addEventListener('loadend', () => {
1355
+ scaffold.pendingRequests--;
1356
+ }, { once: true });
1357
+ return originalXhrOpen.call(this, method, url, async, username, password);
1358
+ };
1359
+ }
1360
+ /**
1361
+ * Restores the original fetch and XMLHttpRequest functions.
1362
+ */
1363
+ uninstallFetchInterceptor() {
1364
+ if (this.originalFetch) {
1365
+ window.fetch = this.originalFetch;
1366
+ this.originalFetch = null;
1367
+ }
1368
+ if (this.originalXhrOpen) {
1369
+ XMLHttpRequest.prototype.open = this.originalXhrOpen;
1370
+ this.originalXhrOpen = null;
1371
+ }
1372
+ }
1373
+ // =========================================================================
1374
+ // Navigation Data
1375
+ // =========================================================================
1376
+ /**
1377
+ * Returns the computed navigation as a flat array with preferences applied.
1378
+ *
1379
+ * Transforms the hierarchical `nav` property into a flat list where each item
1380
+ * has a `parentId` reference instead of nested `children`. Merges user
1381
+ * preference overrides (label, icon, url, active, order, parentId) and
1382
+ * includes any custom items added via the edit dialog.
1383
+ *
1384
+ * @returns Flat array of nav items with preferences applied
1385
+ */
1386
+ getComputedNav() {
1387
+ const result = [];
1388
+ this.nav.forEach((item, index) => {
1389
+ const override = this.pref.nav[item.id];
1390
+ result.push({
1391
+ ...item,
1392
+ ...override,
1393
+ order: override?.order ?? item.order ?? index,
1394
+ parentId: override?.parentId ?? null,
1395
+ });
1396
+ // Add children if group
1397
+ if (item.type === 'group' && item.children) {
1398
+ item.children.forEach((child, childIndex) => {
1399
+ const childOverride = this.pref.nav[child.id];
1400
+ result.push({
1401
+ ...child,
1402
+ ...childOverride,
1403
+ order: childOverride?.order ?? child.order ?? childIndex,
1404
+ parentId: childOverride?.parentId !== undefined ? childOverride.parentId : item.id,
1405
+ });
1406
+ });
1407
+ }
1408
+ });
1409
+ // Add custom items from pref
1410
+ Object.entries(this.pref.nav).forEach(([id, item]) => {
1411
+ if (id.startsWith('custom') && item.type && item.label) {
1412
+ result.push({
1413
+ id,
1414
+ type: item.type,
1415
+ label: item.label,
1416
+ icon: item.icon,
1417
+ url: item.url,
1418
+ active: item.active,
1419
+ order: item.order ?? result.length,
1420
+ parentId: item.parentId ?? null,
1421
+ });
1422
+ }
1423
+ });
1424
+ return result;
1425
+ }
1426
+ /**
1427
+ * Returns nav items for a given parent, filtered and sorted for rendering.
1428
+ *
1429
+ * Filters the computed nav to items matching the parentId, sorts by order,
1430
+ * hides inactive items in normal mode, and applies the search query filter.
1431
+ * Groups are shown if their label matches or if they have matching children.
1432
+ *
1433
+ * @param parentId - The parent ID to filter by (null for top-level items)
1434
+ * @returns Filtered and sorted nav items ready for rendering
1435
+ */
1436
+ getNavItemChildren(parentId) {
1437
+ let items = this.getComputedNav()
1438
+ .filter(item => item.parentId === parentId)
1439
+ .sort((a, b) => a.order - b.order);
1440
+ // In normal mode, filter out hidden items
1441
+ if (!this.isEditing) {
1442
+ items = items.filter(item => item.active !== false);
1443
+ }
1444
+ // Apply search filter
1445
+ if (this.navQuery) {
1446
+ const query = this.navQuery.toLowerCase();
1447
+ const allItems = this.getComputedNav();
1448
+ items = items.filter(item => {
1449
+ if (item.type === 'group') {
1450
+ // Show group if its label matches OR if it has matching children
1451
+ return item.label.toLowerCase().includes(query) || allItems.some(child => child.parentId === item.id &&
1452
+ child.active !== false &&
1453
+ child.label.toLowerCase().includes(query));
1454
+ }
1455
+ // Show item if its label matches
1456
+ return item.label.toLowerCase().includes(query);
1457
+ });
1458
+ }
1459
+ return items;
1460
+ }
1461
+ // =========================================================================
1462
+ // Navigation Search
1463
+ // =========================================================================
1464
+ /**
1465
+ * Handles search input changes for filtering nav items.
1466
+ *
1467
+ * When a search query is entered, automatically expands any groups that
1468
+ * contain matching children so users can see the results. When the search
1469
+ * is cleared, collapses all groups back to their default state.
1470
+ *
1471
+ * @param e - The input event from the search field
1472
+ */
1473
+ handleNavQueryChange(e) {
1474
+ this.navQuery = e.target.value;
1475
+ // Expand all groups when searching so matching children are visible
1476
+ // (groups without matching children won't be rendered anyway)
1477
+ if (this.navQuery) {
1478
+ this.getComputedNav().forEach(item => {
1479
+ if (item.type === 'group') {
1480
+ this.navItemsExpanded.add(item.id);
1481
+ }
1482
+ });
1483
+ }
1484
+ else {
1485
+ // Collapse all when search is cleared
1486
+ this.navItemsExpanded.clear();
1487
+ }
1488
+ }
1489
+ /**
1490
+ * Clears the search query.
1491
+ */
1492
+ handleNavQueryClear() {
1493
+ this.navQuery = '';
1494
+ this.navItemsExpanded.clear();
1495
+ }
1496
+ // =========================================================================
1497
+ // Navigation Interaction
1498
+ // =========================================================================
1499
+ handleMenuClick() {
1500
+ this.isNavOpened = !this.isNavOpened;
1501
+ }
1502
+ /**
1503
+ * Handles scroll on nav content to show/hide header shadow.
1504
+ */
1505
+ handleNavScroll(e) {
1506
+ this.isNavScrolled = e.target.scrollTop > 0;
1507
+ }
1508
+ /**
1509
+ * Toggles the expanded/collapsed state of a nav group with animation.
1510
+ * Uses the Web Animations API to animate height transitions.
1511
+ * When collapsing, the `nav-group--expanded` class is removed after animation completes.
1512
+ * When expanding, the class is added immediately before animation starts.
1513
+ *
1514
+ * @param itemId - The unique identifier of the nav group to toggle
1515
+ */
1516
+ toggleNavItem(itemId) {
1517
+ const navItem = this.shadowRoot?.querySelector(`.nav-item[data-id="${itemId}"]`);
1518
+ const groupEl = navItem?.nextElementSibling;
1519
+ if (!groupEl)
1520
+ return;
1521
+ if (this.navItemsExpanded.has(itemId)) {
1522
+ this.navItemsExpanded.delete(itemId);
1523
+ groupEl.animate([
1524
+ { height: `${groupEl.scrollHeight}px` },
1525
+ { height: '0px' }
1526
+ ], { duration: 300, easing: 'ease-in-out' }).onfinish = () => {
1527
+ groupEl.classList.remove('nav-group--expanded');
1528
+ };
1529
+ }
1530
+ else {
1531
+ this.navItemsExpanded.add(itemId);
1532
+ groupEl.classList.add('nav-group--expanded');
1533
+ groupEl.animate([
1534
+ { height: '0px' },
1535
+ { height: `${groupEl.scrollHeight}px` }
1536
+ ], { duration: 300, easing: 'ease-in-out' });
1537
+ }
1538
+ this.requestUpdate();
1539
+ }
1540
+ /**
1541
+ * Handles click events on navigation items.
1542
+ *
1543
+ * For groups, toggles the expanded/collapsed state.
1544
+ * For items, dispatches a cancelable `nav-item-click` custom event.
1545
+ *
1546
+ * If a listener calls `preventDefault()` on the custom event, native browser
1547
+ * navigation is prevented. Otherwise, the default `<a href>` navigation
1548
+ * proceeds normally.
1549
+ *
1550
+ * The `@krubble/angular` package provides `KRScaffoldDirective` which
1551
+ * automatically listens for this event and handles navigation using
1552
+ * Angular's router. Import `KrubbleModule` in your Angular app to enable
1553
+ * SPA navigation without page reloads.
1554
+ *
1555
+ * @param e - The original click event
1556
+ * @param item - The nav item that was clicked
1557
+ */
1558
+ handleNavItemClick(e, item) {
1559
+ if (item.type === 'group') {
1560
+ this.toggleNavItem(item.id);
1561
+ }
1562
+ else {
1563
+ const navEvent = new CustomEvent('nav-item-click', {
1564
+ detail: { item },
1565
+ bubbles: true,
1566
+ composed: true,
1567
+ cancelable: true,
1568
+ });
1569
+ this.dispatchEvent(navEvent);
1570
+ // If a listener called preventDefault(), prevent the native navigation
1571
+ if (navEvent.defaultPrevented) {
1572
+ e.preventDefault();
1573
+ }
1574
+ }
1575
+ }
1576
+ /**
1577
+ * Updates the active nav item highlight based on the current URL.
1578
+ *
1579
+ * Compares the first path segment of `window.location.pathname` with each
1580
+ * nav item's URL to find a match. When found, highlights that item and
1581
+ * expands its parent group if nested.
1582
+ *
1583
+ * Called automatically by `KRScaffoldDirective` on Angular route changes.
1584
+ */
1585
+ updateActiveNavItem() {
1586
+ const currentPath = window.location.pathname;
1587
+ const allItems = this.getComputedNav().filter(item => item.type === 'item' && item.url);
1588
+ // Find the best match - prefer longer/more specific URL matches
1589
+ let activeItem = null;
1590
+ let longestMatch = 0;
1591
+ for (const item of allItems) {
1592
+ const url = item.url; // We filtered for items with url above
1593
+ if (currentPath.startsWith(url) && url.length > longestMatch) {
1594
+ activeItem = item;
1595
+ longestMatch = url.length;
1596
+ }
1597
+ }
1598
+ if (activeItem) {
1599
+ this.activeNavItemId = activeItem.id;
1600
+ if (activeItem.parentId) {
1601
+ this.navItemsExpanded.add(activeItem.parentId);
1602
+ }
1603
+ }
1604
+ else {
1605
+ this.activeNavItemId = null;
1606
+ }
1607
+ }
1608
+ // =========================================================================
1609
+ // Navigation Customization
1610
+ // =========================================================================
1611
+ startEditing() {
1612
+ this.isEditing = true;
1613
+ }
1614
+ cancelEditing() {
1615
+ this.isEditing = false;
1616
+ // Reload to revert changes
1617
+ this.loadPref();
1618
+ }
1619
+ resetPref() {
1620
+ this.pref.nav = {};
1621
+ }
1622
+ savePref() {
1623
+ const url = this.pref.uuid
1624
+ ? `/api/system/preference/json/scaffold/${this.pref.uuid}?global=true`
1625
+ : `/api/system/preference/json/scaffold?global=true`;
1626
+ this.http.fetch({
1627
+ url,
1628
+ method: this.pref.uuid ? 'PUT' : 'POST',
1629
+ body: JSON.stringify({ nav: this.pref.nav }),
1630
+ })
1631
+ .then((response) => {
1632
+ this.pref = response.data;
1633
+ this.isEditing = false;
1634
+ })
1635
+ .catch((error) => {
1636
+ console.error('Failed to save nav customizations:', error);
1637
+ });
1638
+ }
1639
+ loadPref() {
1640
+ this.http.fetch({
1641
+ url: '/api/system/preference/json/scaffold?global=true',
1642
+ method: 'GET',
1643
+ })
1644
+ .then((response) => {
1645
+ const pref = response?.data?.[0];
1646
+ if (pref) {
1647
+ this.pref = pref;
1648
+ }
1649
+ })
1650
+ .catch(() => {
1651
+ // No preferences saved yet
1652
+ });
1653
+ }
1654
+ handleNavItemContextMenu(e, item) {
1655
+ if (!this.isEditing)
1656
+ return;
1657
+ e.preventDefault();
1658
+ krubbleComponents.KRContextMenu.open({
1659
+ x: e.clientX,
1660
+ y: e.clientY,
1661
+ items: [
1662
+ { id: 'edit', label: 'Edit Item' },
1663
+ { id: 'divider-1', label: '', divider: true },
1664
+ { id: 'add-above', label: 'Add Item Above' },
1665
+ { id: 'add-below', label: 'Add Item Below' },
1666
+ ],
1667
+ }).then((result) => {
1668
+ if (!result)
1669
+ return;
1670
+ switch (result.id) {
1671
+ case 'edit':
1672
+ this.openNavItemEdit(item);
1673
+ break;
1674
+ case 'add-above':
1675
+ this.addNavItem(item, 'above');
1676
+ break;
1677
+ case 'add-below':
1678
+ this.addNavItem(item, 'below');
1679
+ break;
1680
+ }
1681
+ });
1682
+ }
1683
+ /**
1684
+ * Opens the nav item edit dialog for customizing an item's properties.
1685
+ *
1686
+ * Opens `KRNavItemEdit` dialog pre-populated with the item's current values.
1687
+ * When the user saves, merges the result into the nav delta to persist
1688
+ * customizations like label, icon, URL, and visibility.
1689
+ *
1690
+ * @param item - The nav item to edit
1691
+ */
1692
+ openNavItemEdit(item) {
1693
+ krubbleComponents.KRDialog.open(KRNavItemEdit, { data: item }).afterClosed().then((res) => {
1694
+ const result = res;
1695
+ if (!result)
1696
+ return;
1697
+ if (!this.pref.nav[item.id]) {
1698
+ this.pref.nav[item.id] = {};
1699
+ }
1700
+ this.pref.nav[item.id] = {
1701
+ ...this.pref.nav[item.id],
1702
+ ...result
1703
+ };
1704
+ this.requestUpdate();
1705
+ });
1706
+ }
1707
+ /**
1708
+ * Adds a new custom nav item relative to an existing item.
1709
+ *
1710
+ * Creates a placeholder item in the nav delta, shifts existing siblings
1711
+ * to make room, then opens the edit dialog so the user can configure
1712
+ * the new item's label, icon, and URL.
1713
+ *
1714
+ * @param targetItem - The existing item to position relative to
1715
+ * @param position - Whether to insert 'above' or 'below' the target item
1716
+ */
1717
+ addNavItem(targetItem, position) {
1718
+ const customId = `custom-${Date.now()}`;
1719
+ const siblings = this.getComputedNav()
1720
+ .filter(i => i.parentId === targetItem.parentId)
1721
+ .sort((a, b) => a.order - b.order);
1722
+ const targetIndex = siblings.findIndex(i => i.id === targetItem.id);
1723
+ const newOrder = position === 'above' ? targetIndex : targetIndex + 1;
1724
+ // Shift existing items to make room for the new item
1725
+ siblings.forEach((sibling, index) => {
1726
+ if (index >= newOrder) {
1727
+ if (!this.pref.nav[sibling.id]) {
1728
+ this.pref.nav[sibling.id] = {};
1729
+ }
1730
+ this.pref.nav[sibling.id].order = index + 1;
1731
+ }
1732
+ });
1733
+ // Add the new item and open edit dialog
1734
+ const newItem = {
1735
+ id: customId,
1736
+ type: 'item',
1737
+ label: 'New Item',
1738
+ order: newOrder,
1739
+ parentId: targetItem.parentId,
1740
+ active: true,
1741
+ };
1742
+ this.pref.nav[customId] = newItem;
1743
+ this.requestUpdate();
1744
+ this.openNavItemEdit(newItem);
1745
+ }
1746
+ // =========================================================================
1747
+ // Navigation Drag & Drop
1748
+ // =========================================================================
1749
+ /**
1750
+ * Initiates a potential drag operation when mouse is pressed on a nav item.
1751
+ *
1752
+ * Only active in edit mode. Records the starting position and sets up
1753
+ * document-level listeners for mouse move and mouse up events. The actual
1754
+ * drag doesn't start until the mouse moves more than 5 pixels.
1755
+ *
1756
+ * @param e - The mouse event
1757
+ * @param item - The nav item being pressed
1758
+ */
1759
+ handleNavItemMouseDown(e, item) {
1760
+ if (!this.isEditing)
1761
+ return;
1762
+ e.preventDefault();
1763
+ this.draggedNavItemId = item.id;
1764
+ this.navItemDragStartY = e.clientY;
1765
+ this.isNavItemDragging = false;
1766
+ document.addEventListener('mousemove', this.boundHandleMouseMove);
1767
+ document.addEventListener('mouseup', this.boundHandleMouseUp);
1768
+ }
1769
+ /**
1770
+ * Handles mouse movement during a nav item drag operation.
1771
+ *
1772
+ * Initiates dragging after the mouse moves more than 5 pixels (to distinguish
1773
+ * from clicks), creates a floating preview element that follows the cursor,
1774
+ * and updates the drop target indicator based on mouse position.
1775
+ *
1776
+ * @param e - The mouse event
1777
+ */
1778
+ handleMouseMove(e) {
1779
+ if (!this.draggedNavItemId)
1780
+ return;
1781
+ // Start dragging after moving a few pixels (to distinguish from clicks)
1782
+ if (!this.isNavItemDragging && Math.abs(e.clientY - this.navItemDragStartY) > 5) {
1783
+ this.isNavItemDragging = true;
1784
+ this.classList.add('kr-scaffold--dragging');
1785
+ // Create drag preview
1786
+ const draggedItem = this.getComputedNav().find(i => i.id === this.draggedNavItemId);
1787
+ if (draggedItem) {
1788
+ this.navItemDragPreview = document.createElement('div');
1789
+ this.navItemDragPreview.className = 'nav-item-drag-preview';
1790
+ this.navItemDragPreview.textContent = draggedItem.label;
1791
+ this.navItemDragPreview.style.left = `${e.clientX + 10}px`;
1792
+ this.navItemDragPreview.style.top = `${e.clientY - 20}px`;
1793
+ this.shadowRoot?.appendChild(this.navItemDragPreview);
1794
+ }
1795
+ }
1796
+ if (!this.isNavItemDragging)
1797
+ return;
1798
+ // Update preview position
1799
+ if (this.navItemDragPreview) {
1800
+ this.navItemDragPreview.style.left = `${e.clientX + 10}px`;
1801
+ this.navItemDragPreview.style.top = `${e.clientY - 20}px`;
1802
+ }
1803
+ // Find drop target based on mouse position
1804
+ this.updateNavItemDropTarget(e);
1805
+ }
1806
+ /**
1807
+ * Handles the end of a nav item drag operation.
1808
+ *
1809
+ * Removes document-level mouse listeners, executes the drop if there's a valid
1810
+ * target, and cleans up all drag-related state.
1811
+ */
1812
+ handleMouseUp() {
1813
+ document.removeEventListener('mousemove', this.boundHandleMouseMove);
1814
+ document.removeEventListener('mouseup', this.boundHandleMouseUp);
1815
+ if (this.isNavItemDragging && this.navItemDropTargetId) {
1816
+ this.executeNavItemDrop();
1817
+ }
1818
+ // Reset all drag state
1819
+ this.draggedNavItemId = null;
1820
+ this.navItemDropTargetId = null;
1821
+ this.isNavItemDragging = false;
1822
+ this.classList.remove('kr-scaffold--dragging');
1823
+ if (this.navItemDragPreview) {
1824
+ this.navItemDragPreview.remove();
1825
+ this.navItemDragPreview = null;
1826
+ }
1827
+ this.clearNavItemDragExpandTimeout();
1828
+ this.requestUpdate();
1829
+ }
1830
+ /**
1831
+ * Determines where a dragged nav item would be dropped based on mouse position.
1832
+ *
1833
+ * Loops through all nav items and checks if the mouse is hovering over one.
1834
+ * For groups, the item is divided into thirds (above/center/below) where
1835
+ * "center" means drop into the group. For regular items, it's halves (above/below).
1836
+ *
1837
+ * Also handles auto-expanding collapsed groups when hovering over their center,
1838
+ * and validates drops (e.g., prevents dropping a group into another group).
1839
+ *
1840
+ * Updates `navItemDropTargetId` and `navItemDropPosition` state which are used to render
1841
+ * visual drop indicators in the UI.
1842
+ *
1843
+ * @param e - The mouse event from dragging
1844
+ */
1845
+ updateNavItemDropTarget(e) {
1846
+ // Get all nav items in shadow DOM
1847
+ const navItems = this.shadowRoot?.querySelectorAll('.nav-item[data-id]');
1848
+ if (!navItems)
1849
+ return;
1850
+ let foundTarget = false;
1851
+ navItems.forEach((el) => {
1852
+ const rect = el.getBoundingClientRect();
1853
+ const itemId = el.getAttribute('data-id');
1854
+ if (!itemId || itemId === this.draggedNavItemId)
1855
+ return;
1856
+ // Skip if mouse is outside this element
1857
+ if (e.clientX < rect.left || e.clientX > rect.right ||
1858
+ e.clientY < rect.top || e.clientY > rect.bottom) {
1859
+ return;
1860
+ }
1861
+ const item = this.getComputedNav().find(i => i.id === itemId);
1862
+ if (!item) {
1863
+ return;
1864
+ }
1865
+ const y = e.clientY - rect.top;
1866
+ let position;
1867
+ // Determine drop position based on mouse Y position within the item.
1868
+ // Groups are divided into thirds: top=above, middle=center (drop into), bottom=below.
1869
+ // Regular items are divided in half: top=above, bottom=below.
1870
+ if (item.type === 'group') {
1871
+ if (y < rect.height / 3) {
1872
+ // Top third - drop above the group
1873
+ position = 'above';
1874
+ this.clearNavItemDragExpandTimeout();
1875
+ }
1876
+ else if (y > (rect.height * 2) / 3) {
1877
+ // Bottom third - drop below the group
1878
+ position = 'below';
1879
+ this.clearNavItemDragExpandTimeout();
1880
+ }
1881
+ else {
1882
+ // Middle third - drop into the group (as a child)
1883
+ position = 'center';
1884
+ // Auto-expand collapsed groups after a delay
1885
+ if (!this.navItemsExpanded.has(item.id) && !this.navItemDragExpandTimeout) {
1886
+ this.expandNavGroupOnDrag(item.id);
1887
+ }
1888
+ }
1889
+ }
1890
+ else {
1891
+ // Regular items only support above/below, not center
1892
+ position = y < rect.height / 2 ? 'above' : 'below';
1893
+ this.clearNavItemDragExpandTimeout();
1894
+ }
1895
+ // Determine what the new parent would be
1896
+ const newParentId = position === 'center' ? item.id : item.parentId;
1897
+ const draggedItem = this.getComputedNav().find(i => i.id === this.draggedNavItemId);
1898
+ // Don't show drop indicator if invalid drop:
1899
+ // 1. Can't drop an item into itself (newParentId === draggedNavItemId)
1900
+ // 2. Groups can only exist at the top level, so prevent dropping a group into another group (newParentId !== null means it would be nested)
1901
+ if (newParentId === this.draggedNavItemId || (draggedItem?.type === 'group' && newParentId !== null)) {
1902
+ this.navItemDropTargetId = null;
1903
+ this.clearNavItemDragExpandTimeout();
1904
+ return;
1905
+ }
1906
+ // Valid drop target found - store the target item and position (above/below/center)
1907
+ // so the UI can render the drop indicator in the correct location
1908
+ this.navItemDropTargetId = item.id;
1909
+ this.navItemDropPosition = position;
1910
+ foundTarget = true;
1911
+ });
1912
+ // Mouse is not over any valid nav item - clear the drop indicator
1913
+ // (e.g., user dragged outside the nav area or over empty space)
1914
+ if (!foundTarget) {
1915
+ this.navItemDropTargetId = null;
1916
+ this.clearNavItemDragExpandTimeout();
1917
+ }
1918
+ this.requestUpdate();
1919
+ }
1920
+ /**
1921
+ * Cancels the pending auto-expand timeout for nav groups during drag.
1922
+ * Called when the user moves away from a group's center or stops dragging.
1923
+ */
1924
+ clearNavItemDragExpandTimeout() {
1925
+ if (this.navItemDragExpandTimeout) {
1926
+ clearTimeout(this.navItemDragExpandTimeout);
1927
+ this.navItemDragExpandTimeout = null;
1928
+ }
1929
+ }
1930
+ /**
1931
+ * Auto-expands a collapsed nav group after a delay while dragging over it.
1932
+ *
1933
+ * Uses a 500ms timeout to prevent groups from expanding too eagerly when the
1934
+ * user is just passing over them. Only expands if the user is still hovering
1935
+ * over the group's center when the timeout fires.
1936
+ *
1937
+ * @param itemId - The ID of the group to expand
1938
+ */
1939
+ expandNavGroupOnDrag(itemId) {
1940
+ this.navItemDragExpandTimeout = window.setTimeout(() => {
1941
+ if (this.navItemDropTargetId === itemId && this.navItemDropPosition === 'center') {
1942
+ this.navItemsExpanded.add(itemId);
1943
+ this.requestUpdate();
1944
+ }
1945
+ this.navItemDragExpandTimeout = null;
1946
+ }, 500);
1947
+ }
1948
+ /**
1949
+ * Executes the drop operation after a nav item drag completes.
1950
+ *
1951
+ * Calculates the new position and parent for the dragged item based on
1952
+ * the drop target and position (above/below/center). Updates the navDelta
1953
+ * with new order values for the dragged item and shifts siblings as needed.
1954
+ */
1955
+ executeNavItemDrop() {
1956
+ if (!this.draggedNavItemId || !this.navItemDropTargetId)
1957
+ return;
1958
+ const allItems = this.getComputedNav();
1959
+ const draggedItem = allItems.find(i => i.id === this.draggedNavItemId);
1960
+ const targetItem = allItems.find(i => i.id === this.navItemDropTargetId);
1961
+ if (!draggedItem || !targetItem)
1962
+ return;
1963
+ // Determine the new parentId for the dragged item
1964
+ let newParentId;
1965
+ if (this.navItemDropPosition === 'center' && targetItem.type === 'group') {
1966
+ if (targetItem.id === this.draggedNavItemId) {
1967
+ return;
1968
+ }
1969
+ newParentId = targetItem.id;
1970
+ }
1971
+ else {
1972
+ newParentId = targetItem.parentId;
1973
+ }
1974
+ if (newParentId === this.draggedNavItemId)
1975
+ return;
1976
+ // Get siblings in the destination parent
1977
+ const siblings = allItems
1978
+ .filter(i => i.parentId === newParentId && i.id !== this.draggedNavItemId)
1979
+ .sort((a, b) => a.order - b.order);
1980
+ const navDelta = this.pref.nav;
1981
+ // Calculate the new order
1982
+ let newOrder;
1983
+ if (this.navItemDropPosition === 'center') {
1984
+ // Dropping into a group - place at the end of its children
1985
+ if (siblings.length > 0) {
1986
+ newOrder = Math.max(...siblings.map(s => s.order)) + 1;
1987
+ }
1988
+ else {
1989
+ newOrder = 0;
1990
+ }
1991
+ }
1992
+ else {
1993
+ // Find where the target item is in the sorted siblings list
1994
+ const targetIndex = siblings.findIndex(i => i.id === targetItem.id);
1995
+ // Determine insert position based on drop position (above/below target)
1996
+ if (targetIndex === -1) {
1997
+ newOrder = 0;
1998
+ }
1999
+ else if (this.navItemDropPosition === 'above') {
2000
+ newOrder = targetIndex;
2001
+ }
2002
+ else {
2003
+ newOrder = targetIndex + 1;
2004
+ }
2005
+ // Shift existing siblings to make room for the dropped item.
2006
+ // Items at or after the insert position get their order bumped up by 1.
2007
+ siblings.forEach((sibling, index) => {
2008
+ if (!navDelta[sibling.id]) {
2009
+ navDelta[sibling.id] = {};
2010
+ }
2011
+ if (index >= newOrder) {
2012
+ navDelta[sibling.id].order = index + 1;
2013
+ }
2014
+ else {
2015
+ navDelta[sibling.id].order = index;
2016
+ }
2017
+ });
2018
+ }
2019
+ // Update the dragged item's position and parent in the delta
2020
+ if (!navDelta[this.draggedNavItemId]) {
2021
+ navDelta[this.draggedNavItemId] = {};
2022
+ }
2023
+ navDelta[this.draggedNavItemId].order = newOrder;
2024
+ navDelta[this.draggedNavItemId].parentId = newParentId;
2025
+ // Persist changes and trigger re-render
2026
+ this.pref.nav = navDelta;
2027
+ this.requestUpdate();
2028
+ }
2029
+ // =========================================================================
2030
+ // User Menu
2031
+ // =========================================================================
2032
+ toggleUserMenu() {
2033
+ this.isUserMenuOpen = !this.isUserMenuOpen;
2034
+ }
2035
+ closeUserMenu() {
2036
+ this.isUserMenuOpen = false;
2037
+ }
2038
+ handleCustomize() {
2039
+ this.closeUserMenu();
2040
+ this.startEditing();
2041
+ }
2042
+ // =========================================================================
2043
+ // Rendering
2044
+ // =========================================================================
2045
+ renderNormalFooter() {
2046
+ if (!this.user)
2047
+ return E;
2048
+ const initials = this.user.name
2049
+ .split(' ')
2050
+ .map((part) => part[0])
2051
+ .join('')
2052
+ .toUpperCase()
2053
+ .slice(0, 2);
2054
+ // todo - use a reusable menu component
2055
+ return x `
2056
+ <div class="user-menu-container">
2057
+ ${this.isUserMenuOpen ? x `
2058
+ <div class="user-menu">
2059
+ <button class="user-menu__item" @click=${this.handleCustomize}>
2060
+ Customize Navigation
2061
+ </button>
2062
+ </div>
2063
+ ` : E}
2064
+ <div class="user" @click=${this.toggleUserMenu}>
2065
+ <div class="user__avatar">
2066
+ ${this.user.avatar
2067
+ ? x `<img src=${this.user.avatar} alt=${this.user.name} />`
2068
+ : initials}
2069
+ </div>
2070
+ <div class="user__info">
2071
+ <div class="user__name">${this.user.name}</div>
2072
+ ${this.user.email ? x `<div class="user__email">${this.user.email}</div>` : E}
2073
+ </div>
2074
+ </div>
2075
+ </div>
2076
+ `;
2077
+ }
2078
+ // todo - review
2079
+ renderEditFooter() {
2080
+ return x `
2081
+ <div class="edit-actions">
2082
+ <button class="edit-actions__btn edit-actions__btn--primary" @click=${this.savePref}>
2083
+ Save
2084
+ </button>
2085
+ <div class="edit-actions__secondary">
2086
+ <button class="edit-actions__btn" @click=${this.resetPref}>
2087
+ Reset
2088
+ </button>
2089
+ <button class="edit-actions__btn" @click=${this.cancelEditing}>
2090
+ Cancel
2091
+ </button>
2092
+ </div>
2093
+ </div>
2094
+ `;
2095
+ }
2096
+ /**
2097
+ * Renders a navigation item as either a group or a link.
2098
+ *
2099
+ * Groups render as expandable `<button>` elements with a chevron indicator and
2100
+ * nested children. Items render as `<a>` anchor links with href navigation.
2101
+ *
2102
+ * Both types support drag-and-drop reordering in edit mode, context menus for
2103
+ * customization, and visual indicators for active/hidden/drop-target states.
2104
+ *
2105
+ * Icons use SVG strings and fall back to `defaultNavItemIcon` when not provided.
2106
+ * Icons are only rendered for top-level items, not for children nested within groups.
2107
+ *
2108
+ * @param item - The flat nav item data to render
2109
+ * @param isChild - Whether this item is nested within a group (affects icon rendering)
2110
+ * @returns Lit HTML template for the nav item
2111
+ */
2112
+ renderNavItem(item, isChild = false) {
2113
+ if (item.type === 'section') {
2114
+ return x `
2115
+ <div class="nav-section">${item.label}</div>
2116
+ `;
2117
+ }
2118
+ if (item.type === 'group') {
2119
+ const children = this.getNavItemChildren(item.id);
2120
+ return x `
2121
+ <button
2122
+ class=${e$1({
2123
+ 'nav-item': true,
2124
+ 'nav-item--expanded': this.navItemsExpanded.has(item.id),
2125
+ 'nav-item--hidden': this.isEditing && item.active === false,
2126
+ 'nav-item--drop-above': this.navItemDropTargetId === item.id && this.navItemDropPosition === 'above',
2127
+ 'nav-item--drop-below': this.navItemDropTargetId === item.id && this.navItemDropPosition === 'below',
2128
+ 'nav-item--drop-center': this.navItemDropTargetId === item.id && this.navItemDropPosition === 'center',
2129
+ })}
2130
+ data-id="${item.id}"
2131
+ @mousedown=${(e) => this.handleNavItemMouseDown(e, item)}
2132
+ @click=${(e) => this.handleNavItemClick(e, item)}
2133
+ @contextmenu=${(e) => this.handleNavItemContextMenu(e, item)}
2134
+ >
2135
+ ${this.navIconsDisplayed ? x `<span class="nav-item__icon">${o(item.icon || this.defaultNavItemIcon)}</span>` : E}
2136
+ <span class="nav-item__label">${item.label}</span>
2137
+ <svg
2138
+ class="nav-item__chevron"
2139
+ viewBox="0 0 24 24"
2140
+ fill="none"
2141
+ stroke="currentColor"
2142
+ stroke-width="2"
2143
+ >
2144
+ <path d="M6 9l6 6 6-6" stroke-linecap="round" stroke-linejoin="round" />
2145
+ </svg>
2146
+ </button>
2147
+ <div class=${e$1({
2148
+ 'nav-group': true,
2149
+ 'nav-group--expanded': this.navItemsExpanded.has(item.id),
2150
+ })}>
2151
+ ${children.map((child) => this.renderNavItem(child, true))}
2152
+ </div>
2153
+ `;
2154
+ }
2155
+ return x `
2156
+ <a
2157
+ class=${e$1({
2158
+ 'nav-item': true,
2159
+ 'nav-item--active': this.activeNavItemId === item.id,
2160
+ 'nav-item--hidden': this.isEditing && item.active === false,
2161
+ 'nav-item--drop-above': this.navItemDropTargetId === item.id && this.navItemDropPosition === 'above',
2162
+ 'nav-item--drop-below': this.navItemDropTargetId === item.id && this.navItemDropPosition === 'below',
2163
+ })}
2164
+ data-id="${item.id}"
2165
+ href=${item.url || '#'}
2166
+ @mousedown=${(e) => this.handleNavItemMouseDown(e, item)}
2167
+ @click=${(e) => this.handleNavItemClick(e, item)}
2168
+ @contextmenu=${(e) => this.handleNavItemContextMenu(e, item)}
2169
+ >
2170
+ ${this.navIconsDisplayed && !isChild ? x `<span class="nav-item__icon">${o(item.icon || this.defaultNavItemIcon)}</span>` : E}
2171
+ <span class="nav-item__label">${item.label}</span>
2172
+ </a>
2173
+ `;
2174
+ }
2175
+ // todo - don't hardcode breadcrumbs
2176
+ render() {
2177
+ const topLevelItems = this.getNavItemChildren(null);
2178
+ // Use unfiltered count to determine if search should show (so it doesn't disappear while typing)
2179
+ const totalTopLevelItems = this.getComputedNav().filter(item => item.parentId === null).length;
2180
+ return x `
2181
+ <div class=${e$1({
2182
+ 'progress': true,
2183
+ 'progress--loading': this.pendingRequests > 0,
2184
+ })}>
2185
+ <div class="progress__track"></div>
2186
+ <div class="progress__bar progress__bar--primary">
2187
+ <span class="progress__bar-inner"></span>
2188
+ </div>
2189
+ <div class="progress__bar progress__bar--secondary">
2190
+ <span class="progress__bar-inner"></span>
2191
+ </div>
2192
+ </div>
2193
+
2194
+ ${this.subbar ? x `
2195
+ <kr-subbar menu .breadcrumbs=${this.breadcrumbs} @menu-click=${this.handleMenuClick}>
2196
+ <slot name="subbar"></slot>
2197
+ </kr-subbar>
2198
+ ` : E}
2199
+
2200
+ <div class="wrapper">
2201
+ <nav class=${e$1({
2202
+ 'nav': true,
2203
+ 'nav--scrolled': this.isNavScrolled,
2204
+ 'nav--opened': !this.subbar || this.isNavOpened,
2205
+ })}>
2206
+ <div class="nav-header">
2207
+ ${this.title
2208
+ ? x `<span class="nav-title">${this.title}</span>`
2209
+ : this.logo
2210
+ ? x `<img class="nav-logo" src=${this.logo} alt="Logo" />`
2211
+ : E}
2212
+ </div>
2213
+ <div class="nav-content" @scroll=${this.handleNavScroll}>
2214
+ ${totalTopLevelItems > 20 ? x `
2215
+ <div class="nav-search">
2216
+ <div class="nav-search__wrapper">
2217
+ <span class="nav-search__icon">
2218
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
2219
+ <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/>
2220
+ </svg>
2221
+ </span>
2222
+ <input
2223
+ class="nav-search__input"
2224
+ type="text"
2225
+ placeholder="Search..."
2226
+ .value=${this.navQuery}
2227
+ @input=${this.handleNavQueryChange}
2228
+ />
2229
+ ${this.navQuery ? x `
2230
+ <button class="nav-search__clear" @click=${this.handleNavQueryClear}>
2231
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
2232
+ <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>
2233
+ </svg>
2234
+ </button>
2235
+ ` : E}
2236
+ </div>
2237
+ </div>
2238
+ ` : E}
2239
+ <div class="nav-items">
2240
+ ${topLevelItems.map((item) => this.renderNavItem(item))}
2241
+ </div>
2242
+ </div>
2243
+ <!-- <div class="nav-footer">
2244
+ ${this.isEditing ? this.renderEditFooter() : this.renderNormalFooter()}
2245
+ </div> -->
2246
+ </nav>
2247
+
2248
+ <main class="main">
2249
+ <slot></slot>
2250
+ </main>
2251
+ </div>
2252
+
2253
+ `;
2254
+ }
2255
+ };
2256
+ exports.KRScaffold.styles = i$4 `
2257
+ :host {
2258
+ display: flex;
2259
+ flex-direction: column;
2260
+ width: 100%;
2261
+ height: 100%;
2262
+ font-size: 14px;
2263
+ --kr-scaffold-nav-width: 210px;
2264
+
2265
+ /* Default to light scheme */
2266
+ --kr-scaffold-nav-bg: #ffffff;
2267
+ --kr-scaffold-nav-text: #000000;
2268
+ --kr-scaffold-nav-text-active: #000000;
2269
+ --kr-scaffold-nav-hover: #f3f4f6;
2270
+ --kr-scaffold-nav-active-bg: #e5e7eb;
2271
+ --kr-scaffold-nav-border: rgb(229, 229, 228);
2272
+ --kr-scaffold-nav-divider: #e5e7eb;
2273
+ --kr-scaffold-nav-search-bg: #f3f4f6;
2274
+ --kr-scaffold-nav-search-focus-bg: #ffffff;
2275
+ --kr-scaffold-nav-search-focus-border: #d1d5db;
2276
+ }
2277
+
2278
+ /* Dark scheme */
2279
+ :host([scheme="dark"]) {
2280
+ --kr-scaffold-nav-bg: #10172a;
2281
+ --kr-scaffold-nav-text: rgb(255 255 255 / 80%);
2282
+ --kr-scaffold-nav-text-active: #ffffff;
2283
+ --kr-scaffold-nav-hover: rgba(255, 255, 255, 0.05);
2284
+ --kr-scaffold-nav-active-bg: rgb(255 255 255 / 12%);
2285
+ --kr-scaffold-nav-border: transparent;
2286
+ --kr-scaffold-nav-divider: rgba(255, 255, 255, 0.06);
2287
+ --kr-scaffold-nav-search-bg: rgba(255, 255, 255, 0.15);
2288
+ --kr-scaffold-nav-search-focus-bg: rgba(255, 255, 255, 0.2);
2289
+ --kr-scaffold-nav-search-focus-border: rgba(255, 255, 255, 0.3);
2290
+ }
2291
+
2292
+ *,
2293
+ *::before,
2294
+ *::after {
2295
+ box-sizing: border-box;
2296
+ }
2297
+
2298
+ /* Nav */
2299
+ .nav {
2300
+ width: var(--kr-scaffold-nav-width);
2301
+ background: var(--kr-scaffold-nav-bg);
2302
+ color: var(--kr-scaffold-nav-text);
2303
+ display: flex;
2304
+ flex-direction: column;
2305
+ flex-shrink: 0;
2306
+ overflow: hidden;
2307
+ border-right: 1px solid var(--kr-scaffold-nav-border);
2308
+ transition: margin-left 0.3s ease;
2309
+ margin-left: calc(-1 * var(--kr-scaffold-nav-width));
2310
+ }
2311
+
2312
+ .nav--opened {
2313
+ margin-left: 0;
2314
+ }
2315
+
2316
+ .wrapper {
2317
+ display: flex;
2318
+ flex: 1;
2319
+ min-height: 0;
2320
+ }
2321
+
2322
+ .nav-header {
2323
+ height: 64px;
2324
+ padding: 0 20px;
2325
+ display: flex;
2326
+ align-items: center;
2327
+ position: relative;
2328
+ z-index: 1;
2329
+ transition: box-shadow 0.2s ease;
2330
+ }
2331
+
2332
+ .nav--scrolled .nav-header {
2333
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
2334
+ }
2335
+
2336
+ .nav-logo {
2337
+ max-width: 100%;
2338
+ height: 32px;
2339
+ }
2340
+
2341
+ .nav-title {
2342
+ font-size: 18px;
2343
+ font-weight: 600;
2344
+ color: var(--kr-scaffold-nav-text-active);
2345
+ letter-spacing: .2px;
2346
+ white-space: nowrap;
2347
+ overflow: hidden;
2348
+ text-overflow: ellipsis;
2349
+ }
2350
+
2351
+ .nav-search {
2352
+ padding: 4px 0 8px;
2353
+ }
2354
+
2355
+ .nav-search__wrapper {
2356
+ display: flex;
2357
+ align-items: center;
2358
+ background: var(--kr-scaffold-nav-search-bg);
2359
+ border-radius: 8px;
2360
+ padding: 0 12px;
2361
+ height: 40px;
2362
+ gap: 8px;
2363
+ border: 1px solid transparent;
2364
+ transition: all 0.15s ease;
2365
+ }
2366
+
2367
+ .nav-search__wrapper:focus-within {
2368
+ background: var(--kr-scaffold-nav-search-focus-bg);
2369
+ border-color: var(--kr-scaffold-nav-search-focus-border);
2370
+ }
2371
+
2372
+ .nav-search__icon {
2373
+ width: 18px;
2374
+ height: 18px;
2375
+ flex-shrink: 0;
2376
+ opacity: 0.6;
2377
+ }
2378
+
2379
+ .nav-search__icon svg {
2380
+ width: 100%;
2381
+ height: 100%;
2382
+ fill: currentColor;
2383
+ }
2384
+
2385
+ .nav-search__input {
2386
+ flex: 1;
2387
+ background: none;
2388
+ border: none;
2389
+ outline: none;
2390
+ color: var(--kr-scaffold-nav-text-active);
2391
+ font-size: 13px;
2392
+ font-family: inherit;
2393
+ min-width: 0;
2394
+ }
2395
+
2396
+ .nav-search__input::placeholder {
2397
+ color: var(--kr-scaffold-nav-text);
2398
+ opacity: 0.7;
2399
+ }
2400
+
2401
+ .nav-search__clear {
2402
+ width: 18px;
2403
+ height: 18px;
2404
+ padding: 0;
2405
+ background: none;
2406
+ border: none;
2407
+ color: var(--kr-scaffold-nav-text);
2408
+ cursor: pointer;
2409
+ display: flex;
2410
+ align-items: center;
2411
+ justify-content: center;
2412
+ opacity: 0.6;
2413
+ transition: opacity 0.15s ease;
2414
+ }
2415
+
2416
+ .nav-search__clear:hover {
2417
+ opacity: 1;
2418
+ }
2419
+
2420
+ .nav-search__clear svg {
2421
+ width: 100%;
2422
+ height: 100%;
2423
+ fill: currentColor;
2424
+ }
2425
+
2426
+ .nav-content {
2427
+ flex: 1;
2428
+ overflow-y: auto;
2429
+ padding: 0 9px 0.75rem 8px;
2430
+ }
2431
+
2432
+ .nav-footer {
2433
+ padding: 12px;
2434
+ border-top: 1px solid var(--kr-scaffold-nav-divider);
2435
+ }
2436
+
2437
+ .user {
2438
+ display: flex;
2439
+ align-items: center;
2440
+ gap: 12px;
2441
+ padding: 8px;
2442
+ border-radius: 8px;
2443
+ cursor: pointer;
2444
+ transition: background 0.15s ease;
2445
+ }
2446
+
2447
+ .user:hover {
2448
+ background: var(--kr-scaffold-nav-hover);
2449
+ }
2450
+
2451
+ .user__avatar {
2452
+ width: 36px;
2453
+ height: 36px;
2454
+ border-radius: 50%;
2455
+ background: var(--kr-scaffold-avatar-bg, #beea4e);
2456
+ color: var(--kr-scaffold-avatar-text, #10172a);
2457
+ display: flex;
2458
+ align-items: center;
2459
+ justify-content: center;
2460
+ font-size: 14px;
2461
+ font-weight: 600;
2462
+ flex-shrink: 0;
2463
+ overflow: hidden;
2464
+ }
2465
+
2466
+ .user__avatar img {
2467
+ width: 100%;
2468
+ height: 100%;
2469
+ object-fit: cover;
2470
+ }
2471
+
2472
+ .user__info {
2473
+ flex: 1;
2474
+ min-width: 0;
2475
+ }
2476
+
2477
+ .user__name {
2478
+ font-size: 13px;
2479
+ font-weight: 500;
2480
+ color: var(--kr-scaffold-nav-text-active);
2481
+ white-space: nowrap;
2482
+ overflow: hidden;
2483
+ text-overflow: ellipsis;
2484
+ }
2485
+
2486
+ .user__email {
2487
+ font-size: 12px;
2488
+ color: var(--kr-scaffold-nav-text);
2489
+ white-space: nowrap;
2490
+ overflow: hidden;
2491
+ text-overflow: ellipsis;
2492
+ }
2493
+
2494
+ .user-menu-container {
2495
+ position: relative;
2496
+ }
2497
+
2498
+ .user-menu {
2499
+ position: absolute;
2500
+ bottom: 100%;
2501
+ left: 0;
2502
+ right: 0;
2503
+ margin-bottom: 8px;
2504
+ background: var(--kr-scaffold-nav-bg);
2505
+ border: 1px solid var(--kr-scaffold-nav-divider);
2506
+ border-radius: 8px;
2507
+ padding: 4px;
2508
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
2509
+ }
2510
+
2511
+ .user-menu__item {
2512
+ display: block;
2513
+ width: 100%;
2514
+ padding: 10px 12px;
2515
+ background: none;
2516
+ border: none;
2517
+ color: var(--kr-scaffold-nav-text);
2518
+ font-size: 13px;
2519
+ font-family: inherit;
2520
+ text-align: left;
2521
+ cursor: pointer;
2522
+ border-radius: 6px;
2523
+ transition: background 0.15s ease;
2524
+ }
2525
+
2526
+ .user-menu__item:hover {
2527
+ background: var(--kr-scaffold-nav-hover);
2528
+ color: var(--kr-scaffold-nav-text-active);
2529
+ }
2530
+
2531
+ .user-menu__divider {
2532
+ height: 1px;
2533
+ background: var(--kr-scaffold-nav-divider);
2534
+ margin: 4px 0;
2535
+ }
2536
+
2537
+ /* Main */
2538
+ .main {
2539
+ flex: 1;
2540
+ min-width: 0;
2541
+ overflow-y: auto;
2542
+ background: #ffffff;
2543
+ display: flex;
2544
+ flex-direction: column;
2545
+ }
2546
+
2547
+ .breadcrumbs {
2548
+ height: 32px;
2549
+ padding: 0 1rem;
2550
+ display: flex;
2551
+ align-items: center;
2552
+ gap: 6px;
2553
+ font-size: 12px;
2554
+ color: #6b7280;
2555
+ background: #f9fafb;
2556
+ border-bottom: 1px solid #e5e7eb;
2557
+ flex-shrink: 0;
2558
+ }
2559
+
2560
+ .breadcrumbs a {
2561
+ color: #6b7280;
2562
+ text-decoration: none;
2563
+ }
2564
+
2565
+ .breadcrumbs a:hover {
2566
+ color: #111827;
2567
+ text-decoration: underline;
2568
+ }
2569
+
2570
+ .breadcrumbs__separator {
2571
+ color: #d1d5db;
2572
+ }
2573
+
2574
+ .breadcrumbs__current {
2575
+ color: #111827;
2576
+ font-weight: 500;
2577
+ }
2578
+
2579
+ .main__content {
2580
+ flex: 1;
2581
+ overflow-y: auto;
2582
+ }
2583
+
2584
+ /* Nav Items */
2585
+ .nav-items {
2586
+ display: flex;
2587
+ flex-direction: column;
2588
+ gap: 2px;
2589
+ }
2590
+
2591
+ .nav-item {
2592
+ display: flex;
2593
+ align-items: center;
2594
+ gap: 16px;
2595
+ padding: 0 12px;
2596
+ height: 32px;
2597
+ border-radius: 8px;
2598
+ color: var(--kr-scaffold-nav-text);
2599
+ text-decoration: none;
2600
+ cursor: pointer;
2601
+ border: none;
2602
+ background: none;
2603
+ width: 100%;
2604
+ text-align: left;
2605
+ font-size: 13px;
2606
+ font-weight: 400;
2607
+ font-family: inherit;
2608
+ transition: all 0.15s ease;
2609
+ }
2610
+
2611
+ .nav-item:hover {
2612
+ background: #F3F7FC;
2613
+ color: var(--kr-scaffold-nav-text-active);
2614
+ }
2615
+
2616
+ .nav-item--active,
2617
+ .nav-item--active:hover {
2618
+ background: #e1e9f6;
2619
+ color: #1a2332;
2620
+ font-weight: 500;
2621
+ }
2622
+
2623
+ .nav-item__icon {
2624
+ width: 16px;
2625
+ height: 16px;
2626
+ display: flex;
2627
+ align-items: center;
2628
+ justify-content: center;
2629
+ flex-shrink: 0;
2630
+ }
2631
+
2632
+ .nav-item__icon svg {
2633
+ width: 16px;
2634
+ height: 16px;
2635
+ fill: currentColor;
2636
+ }
2637
+
2638
+ .nav-item__label {
2639
+ flex: 1;
2640
+ white-space: nowrap;
2641
+ overflow: hidden;
2642
+ text-overflow: ellipsis;
2643
+ letter-spacing: 0.01em;
2644
+ }
2645
+
2646
+ .nav-item__chevron {
2647
+ width: 16px;
2648
+ height: 16px;
2649
+ transition: transform 0.2s ease;
2650
+ transform: rotate(-90deg);
2651
+ stroke: currentColor;
2652
+ }
2653
+
2654
+ .nav-item--expanded .nav-item__chevron {
2655
+ transform: rotate(0deg);
2656
+ }
2657
+
2658
+ .nav-group {
2659
+ display: flex;
2660
+ flex-direction: column;
2661
+ overflow: hidden;
2662
+ height: 0;
2663
+ }
2664
+
2665
+ .nav-group--expanded {
2666
+ height: auto;
2667
+ }
2668
+
2669
+ .nav-group .nav-item {
2670
+ padding: 0 12px 0 44px;
2671
+ height: 32px;
2672
+ font-size: 13px;
2673
+ font-weight: 400;
2674
+ margin-top: 2px;
2675
+ flex-shrink: 0;
2676
+ }
2677
+
2678
+ .nav-group .nav-item:first-child {
2679
+ margin-top: 0;
2680
+ }
2681
+
2682
+ /* Nav items in groups when icons are hidden */
2683
+ :host(:not([nav-icons-displayed])) .nav-group .nav-item {
2684
+ padding-left: 24px;
2685
+ }
2686
+
2687
+ /* Sections */
2688
+ .nav-section {
2689
+ padding: 16px 12px 8px;
2690
+ font-size: 11px;
2691
+ font-weight: 600;
2692
+ text-transform: uppercase;
2693
+ letter-spacing: 0.05em;
2694
+ color: var(--kr-scaffold-nav-text);
2695
+ opacity: 0.6;
2696
+ }
2697
+
2698
+ .nav-section:first-child {
2699
+ padding-top: 0;
2700
+ }
2701
+
2702
+ /* Edit mode actions */
2703
+ .edit-actions {
2704
+ display: flex;
2705
+ flex-direction: column;
2706
+ gap: 8px;
2707
+ }
2708
+
2709
+ .edit-actions__btn {
2710
+ display: block;
2711
+ width: 100%;
2712
+ padding: 10px 12px;
2713
+ background: var(--kr-scaffold-nav-hover);
2714
+ border: none;
2715
+ color: var(--kr-scaffold-nav-text);
2716
+ font-size: 13px;
2717
+ font-weight: 500;
2718
+ font-family: inherit;
2719
+ cursor: pointer;
2720
+ border-radius: 6px;
2721
+ transition: background 0.15s ease;
2722
+ }
2723
+
2724
+ .edit-actions__btn:hover {
2725
+ background: var(--kr-scaffold-nav-active-bg);
2726
+ color: var(--kr-scaffold-nav-text-active);
2727
+ }
2728
+
2729
+ .edit-actions__btn--primary {
2730
+ background: #beea4e;
2731
+ color: #10172a;
2732
+ }
2733
+
2734
+ .edit-actions__btn--primary:hover {
2735
+ background: #d4f472;
2736
+ color: #10172a;
2737
+ }
2738
+
2739
+ .edit-actions__secondary {
2740
+ display: flex;
2741
+ gap: 8px;
2742
+ }
2743
+
2744
+ .edit-actions__secondary .edit-actions__btn {
2745
+ flex: 1;
2746
+ }
2747
+
2748
+ /* Hidden/inactive items in edit mode */
2749
+ .nav-item--hidden {
2750
+ opacity: 0.4;
2751
+ font-style: italic;
2752
+ }
2753
+
2754
+ .nav-item--hidden:hover {
2755
+ opacity: 0.6;
2756
+ }
2757
+
2758
+ /* Dragging state */
2759
+ :host(.kr-scaffold--dragging),
2760
+ :host(.kr-scaffold--dragging) * {
2761
+ cursor: grabbing;
2762
+ user-select: none;
2763
+ }
2764
+
2765
+ .nav-item-drag-preview {
2766
+ position: fixed;
2767
+ pointer-events: none;
2768
+ z-index: 1000;
2769
+ opacity: 0.9;
2770
+ background: var(--kr-scaffold-nav-bg);
2771
+ border: 1px solid var(--kr-scaffold-nav-divider);
2772
+ border-radius: 8px;
2773
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
2774
+ padding: 0 12px;
2775
+ height: 40px;
2776
+ min-width: 200px;
2777
+ display: flex;
2778
+ align-items: center;
2779
+ gap: 16px;
2780
+ color: var(--kr-scaffold-nav-text-active);
2781
+ font-size: 13px;
2782
+ font-weight: 500;
2783
+ }
2784
+
2785
+ /* Drop indicator */
2786
+ .nav-item--drop-above,
2787
+ .nav-item--drop-below,
2788
+ .nav-item--drop-center {
2789
+ position: relative;
2790
+ }
2791
+
2792
+ .nav-item--drop-above::before,
2793
+ .nav-item--drop-below::after {
2794
+ content: '';
2795
+ position: absolute;
2796
+ left: 0;
2797
+ right: 0;
2798
+ height: 2px;
2799
+ background: #beea4e;
2800
+ }
2801
+
2802
+ .nav-item--drop-above::before {
2803
+ top: 0;
2804
+ }
2805
+
2806
+ .nav-item--drop-below::after {
2807
+ bottom: 0;
2808
+ }
2809
+
2810
+ .nav-item--drop-center {
2811
+ background: var(--kr-scaffold-nav-active-bg);
2812
+ }
2813
+
2814
+ .breadcrumbs {
2815
+ height: 32px;
2816
+ padding: 0 1rem;
2817
+ display: flex;
2818
+ align-items: center;
2819
+ gap: 6px;
2820
+ font-size: 12px;
2821
+ color: #6b7280;
2822
+ //background: #f9fafb;
2823
+ background: #beea4e;
2824
+ border-top: 1px solid #e5e7eb;
2825
+ flex-shrink: 0;
2826
+ }
2827
+
2828
+ .breadcrumbs a {
2829
+ //color: #6b7280;
2830
+ color: #10172a;
2831
+ font-size: 13px;
2832
+ font-weight: 600;
2833
+ text-decoration: none;
2834
+ }
2835
+
2836
+ .breadcrumbs a:hover {
2837
+ color: #111827;
2838
+ text-decoration: underline;
2839
+ }
2840
+
2841
+ .breadcrumbs__separator {
2842
+ color: #d1d5db;
2843
+ }
2844
+
2845
+ .breadcrumbs__current {
2846
+ color: #111827;
2847
+ font-weight: 500;
2848
+ }
2849
+
2850
+ /* Progress bar */
2851
+ .progress {
2852
+ position: fixed;
2853
+ top: 0;
2854
+ left: 0;
2855
+ right: 0;
2856
+ height: 4px;
2857
+ overflow-x: hidden;
2858
+ z-index: 1000;
2859
+ display: none;
2860
+ }
2861
+
2862
+ .progress--loading {
2863
+ display: block;
2864
+ }
2865
+
2866
+ .progress__track {
2867
+ position: absolute;
2868
+ top: 0;
2869
+ bottom: 0;
2870
+ width: 100%;
2871
+ background: rgba(190, 234, 78, 0.3);
2872
+ }
2873
+
2874
+ .progress__bar {
2875
+ position: absolute;
2876
+ top: 0;
2877
+ bottom: 0;
2878
+ width: 100%;
2879
+ transform-origin: left center;
2880
+ }
2881
+
2882
+ .progress__bar-inner {
2883
+ display: inline-block;
2884
+ position: absolute;
2885
+ width: 100%;
2886
+ height: 100%;
2887
+ background: #beea4e;
2888
+ }
2889
+
2890
+ .progress__bar--primary {
2891
+ left: -145.166611%;
2892
+ }
2893
+
2894
+ .progress--loading .progress__bar--primary {
2895
+ animation: progress-primary-translate 2s infinite linear;
2896
+ }
2897
+
2898
+ .progress--loading .progress__bar--primary .progress__bar-inner {
2899
+ animation: progress-primary-scale 2s infinite linear;
2900
+ }
2901
+
2902
+ .progress__bar--secondary {
2903
+ left: -54.888891%;
2904
+ }
2905
+
2906
+ .progress--loading .progress__bar--secondary {
2907
+ animation: progress-secondary-translate 2s infinite linear;
2908
+ }
2909
+
2910
+ .progress--loading .progress__bar--secondary .progress__bar-inner {
2911
+ animation: progress-secondary-scale 2s infinite linear;
2912
+ }
2913
+
2914
+ @keyframes progress-primary-translate {
2915
+ 0% {
2916
+ transform: translateX(0);
2917
+ }
2918
+ 20% {
2919
+ animation-timing-function: cubic-bezier(0.5, 0, 0.701732, 0.495819);
2920
+ transform: translateX(0);
2921
+ }
2922
+ 59.15% {
2923
+ animation-timing-function: cubic-bezier(0.302435, 0.381352, 0.55, 0.956352);
2924
+ transform: translateX(83.67142%);
2925
+ }
2926
+ 100% {
2927
+ transform: translateX(200.611057%);
2928
+ }
2929
+ }
2930
+
2931
+ @keyframes progress-primary-scale {
2932
+ 0% {
2933
+ transform: scaleX(0.08);
2934
+ }
2935
+ 36.65% {
2936
+ animation-timing-function: cubic-bezier(0.334731, 0.12482, 0.785844, 1);
2937
+ transform: scaleX(0.08);
2938
+ }
2939
+ 69.15% {
2940
+ animation-timing-function: cubic-bezier(0.06, 0.11, 0.6, 1);
2941
+ transform: scaleX(0.661479);
2942
+ }
2943
+ 100% {
2944
+ transform: scaleX(0.08);
2945
+ }
2946
+ }
2947
+
2948
+ @keyframes progress-secondary-translate {
2949
+ 0% {
2950
+ animation-timing-function: cubic-bezier(0.15, 0, 0.515058, 0.409685);
2951
+ transform: translateX(0);
2952
+ }
2953
+ 25% {
2954
+ animation-timing-function: cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);
2955
+ transform: translateX(37.651913%);
2956
+ }
2957
+ 48.35% {
2958
+ animation-timing-function: cubic-bezier(0.4, 0.627035, 0.6, 0.902026);
2959
+ transform: translateX(84.386165%);
2960
+ }
2961
+ 100% {
2962
+ transform: translateX(160.277782%);
2963
+ }
2964
+ }
2965
+
2966
+ @keyframes progress-secondary-scale {
2967
+ 0% {
2968
+ animation-timing-function: cubic-bezier(0.205028, 0.057051, 0.57661, 0.453971);
2969
+ transform: scaleX(0.08);
2970
+ }
2971
+ 19.15% {
2972
+ animation-timing-function: cubic-bezier(0.152313, 0.196432, 0.648374, 1.004315);
2973
+ transform: scaleX(0.457104);
2974
+ }
2975
+ 44.15% {
2976
+ animation-timing-function: cubic-bezier(0.257759, -0.003163, 0.211762, 1.38179);
2977
+ transform: scaleX(0.72796);
2978
+ }
2979
+ 100% {
2980
+ transform: scaleX(0.08);
2981
+ }
2982
+ }
2983
+ `;
2984
+ __decorate$3([
2985
+ r()
2986
+ ], exports.KRScaffold.prototype, "navItemsExpanded", void 0);
2987
+ __decorate$3([
2988
+ r()
2989
+ ], exports.KRScaffold.prototype, "navQuery", void 0);
2990
+ __decorate$3([
2991
+ r()
2992
+ ], exports.KRScaffold.prototype, "activeNavItemId", void 0);
2993
+ __decorate$3([
2994
+ r()
2995
+ ], exports.KRScaffold.prototype, "isNavScrolled", void 0);
2996
+ __decorate$3([
2997
+ r()
2998
+ ], exports.KRScaffold.prototype, "isNavOpened", void 0);
2999
+ __decorate$3([
3000
+ r()
3001
+ ], exports.KRScaffold.prototype, "isEditing", void 0);
3002
+ __decorate$3([
3003
+ r()
3004
+ ], exports.KRScaffold.prototype, "isUserMenuOpen", void 0);
3005
+ __decorate$3([
3006
+ r()
3007
+ ], exports.KRScaffold.prototype, "pref", void 0);
3008
+ __decorate$3([
3009
+ r()
3010
+ ], exports.KRScaffold.prototype, "draggedNavItemId", void 0);
3011
+ __decorate$3([
3012
+ r()
3013
+ ], exports.KRScaffold.prototype, "navItemDropTargetId", void 0);
3014
+ __decorate$3([
3015
+ r()
3016
+ ], exports.KRScaffold.prototype, "navItemDropPosition", void 0);
3017
+ __decorate$3([
3018
+ r()
3019
+ ], exports.KRScaffold.prototype, "pendingRequests", void 0);
3020
+ __decorate$3([
3021
+ n({ type: String })
3022
+ ], exports.KRScaffold.prototype, "logo", void 0);
3023
+ __decorate$3([
3024
+ n({ type: String })
3025
+ ], exports.KRScaffold.prototype, "title", void 0);
3026
+ __decorate$3([
3027
+ n({ type: String, reflect: true })
3028
+ ], exports.KRScaffold.prototype, "scheme", void 0);
3029
+ __decorate$3([
3030
+ n({ type: Array })
3031
+ ], exports.KRScaffold.prototype, "nav", void 0);
3032
+ __decorate$3([
3033
+ n({ type: Boolean, attribute: 'nav-icons-displayed', reflect: true })
3034
+ ], exports.KRScaffold.prototype, "navIconsDisplayed", void 0);
3035
+ __decorate$3([
3036
+ n({ type: Boolean, attribute: 'nav-expanded' })
3037
+ ], exports.KRScaffold.prototype, "navExpanded", void 0);
3038
+ __decorate$3([
3039
+ n({ type: Object })
3040
+ ], exports.KRScaffold.prototype, "user", void 0);
3041
+ __decorate$3([
3042
+ n({ type: Boolean })
3043
+ ], exports.KRScaffold.prototype, "subbar", void 0);
3044
+ __decorate$3([
3045
+ n({ type: Array })
3046
+ ], exports.KRScaffold.prototype, "breadcrumbs", void 0);
3047
+ exports.KRScaffold = __decorate$3([
3048
+ t$1('kr-scaffold')
3049
+ ], exports.KRScaffold);
3050
+
3051
+ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
3052
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3053
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3054
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3055
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3056
+ };
3057
+ /**
3058
+ * Secondary navigation component for screens within the scaffold.
3059
+ * Provides a simple nav drawer for sub-navigation within a page/screen.
3060
+ * Typically used when viewing details of a specific entity (e.g., Company, Contact).
3061
+ *
3062
+ * ## Usage
3063
+ * ```html
3064
+ * <kr-screen-nav
3065
+ * title="Acme Corporation"
3066
+ * subtitle="Company"
3067
+ * backUrl="/crm/companies"
3068
+ * .navItems=${[
3069
+ * { id: 'overview', label: 'Overview', url: '/companies/123/overview' },
3070
+ * { id: 'contacts', label: 'Contacts', url: '/companies/123/contacts' },
3071
+ * { id: 'activity', label: 'Activity', url: '/companies/123/activity' },
3072
+ * ]}
3073
+ * activeId="overview"
3074
+ * >
3075
+ * <div>Screen content here</div>
3076
+ * </kr-screen-nav>
3077
+ * ```
3078
+ *
3079
+ * @slot - The main screen content
3080
+ *
3081
+ * @property {string} title - Main title (e.g., entity name like "Acme Corporation")
3082
+ * @property {string} subtitle - Subtitle/label (e.g., entity type like "Company")
3083
+ * @property {string} backUrl - URL to navigate back to (e.g., the table/list view)
3084
+ * @property {KRScreenNavItem[]} navItems - Navigation items as JSON array
3085
+ * @property {string} activeId - Currently active item ID
3086
+ */
3087
+ exports.KRScreenNav = class KRScreenNav extends i$1 {
3088
+ constructor() {
3089
+ super(...arguments);
3090
+ /**
3091
+ * Main title (e.g., entity name like "Acme Corporation")
3092
+ */
3093
+ this.title = '';
3094
+ /**
3095
+ * Subtitle/label (e.g., entity type like "Company")
3096
+ */
3097
+ this.subtitle = '';
3098
+ /**
3099
+ * URL to navigate back to (e.g., the table/list view)
3100
+ */
3101
+ this.backUrl = '';
3102
+ /**
3103
+ * Navigation items
3104
+ */
3105
+ this.navItems = [];
3106
+ /**
3107
+ * Currently active item ID
3108
+ */
3109
+ this.activeId = '';
3110
+ }
3111
+ /**
3112
+ * Handles click events on navigation items.
3113
+ *
3114
+ * Dispatches a cancelable `nav-item-click` custom event.
3115
+ * If a listener calls `preventDefault()` on the custom event, native browser
3116
+ * navigation is prevented. Otherwise, the default `<a href>` navigation
3117
+ * proceeds normally.
3118
+ *
3119
+ * The `@krubble/angular` package provides `KRScreenNavDirective` which
3120
+ * automatically listens for this event and handles navigation using
3121
+ * Angular's router.
3122
+ *
3123
+ * @param e - The original click event
3124
+ * @param item - The nav item that was clicked
3125
+ */
3126
+ handleNavItemClick(e, item) {
3127
+ const navEvent = new CustomEvent('nav-item-click', {
3128
+ detail: { item },
3129
+ bubbles: true,
3130
+ composed: true,
3131
+ cancelable: true,
3132
+ });
3133
+ this.dispatchEvent(navEvent);
3134
+ // If a listener called preventDefault(), prevent the native navigation
3135
+ if (navEvent.defaultPrevented) {
3136
+ e.preventDefault();
3137
+ }
3138
+ }
3139
+ /**
3140
+ * Updates the active nav item based on the current URL.
3141
+ * Called automatically by `KRScreenNavDirective` on Angular route changes.
3142
+ */
3143
+ updateActiveNavItem() {
3144
+ const currentPath = window.location.pathname;
3145
+ const activeItem = this.navItems.find(item => {
3146
+ if (!item.url)
3147
+ return false;
3148
+ // Handle both absolute and relative URLs
3149
+ if (item.url.startsWith('./')) {
3150
+ const segment = item.url.replace(/^\.\//, '');
3151
+ return currentPath.endsWith('/' + segment);
3152
+ }
3153
+ return currentPath === item.url || currentPath.startsWith(item.url + '/');
3154
+ });
3155
+ if (activeItem) {
3156
+ this.activeId = activeItem.id;
3157
+ }
3158
+ }
3159
+ render() {
3160
+ return x `
3161
+ <nav class="nav">
3162
+ ${this.title ? x `
3163
+ <div class="nav-header">
3164
+ <div class="nav-header__text">
3165
+ ${this.subtitle ? x `<div class="nav-header__subtitle">${this.subtitle}</div>` : E}
3166
+ <div class="nav-header__title">${this.title}</div>
3167
+ </div>
3168
+ </div>
3169
+ ` : E}
3170
+ <div class="nav-content">
3171
+ <div class="nav-items">
3172
+ ${this.navItems.map((item) => x `
3173
+ <a
3174
+ class="nav-item ${item.id === this.activeId ? 'nav-item--active' : ''}"
3175
+ href=${item.url || '#'}
3176
+ @click=${(e) => this.handleNavItemClick(e, item)}
3177
+ >
3178
+ ${item.label}
3179
+ </a>
3180
+ `)}
3181
+ </div>
3182
+ </div>
3183
+ </nav>
3184
+ <main class="content">
3185
+ <div class="content__main">
3186
+ <slot></slot>
3187
+ </div>
3188
+ <!--<div class="breadcrumbs">
3189
+ <a href="/crm">CRM</a>
3190
+ <span class="breadcrumbs__separator">/</span>
3191
+ <a href="/crm/companies">Companies</a>
3192
+ <span class="breadcrumbs__separator">/</span>
3193
+ <span class="breadcrumbs__current">Acme Corporation</span>
3194
+ </div>-->
3195
+ </main>
3196
+ `;
3197
+ }
3198
+ };
3199
+ exports.KRScreenNav.styles = i$4 `
3200
+ :host {
3201
+ display: flex;
3202
+ height: 100%;
3203
+ }
3204
+
3205
+ .nav {
3206
+ width: 200px;
3207
+ background: #F3F7FC;
3208
+ //border-right: 1px solid #000000;
3209
+ display: flex;
3210
+ flex-direction: column;
3211
+ flex-shrink: 0;
3212
+ }
3213
+
3214
+ .nav-header {
3215
+ padding: 20px 16px 16px;
3216
+ }
3217
+
3218
+ .nav-header__text {
3219
+ display: flex;
3220
+ flex-direction: column;
3221
+ gap: 4px;
3222
+ }
3223
+
3224
+ .nav-header__title {
3225
+ font-size: 16px;
3226
+ font-weight: 600;
3227
+ color: #111827;
3228
+ white-space: nowrap;
3229
+ overflow: hidden;
3230
+ text-overflow: ellipsis;
3231
+ line-height: 1.3;
3232
+ }
3233
+
3234
+ .nav-header__subtitle {
3235
+ font-size: 12px;
3236
+ font-weight: 400;
3237
+ color: rgb(0 0 0 / 70%);
3238
+ line-height: 1;
3239
+ }
3240
+
3241
+ .nav-content {
3242
+ flex: 1;
3243
+ overflow-y: auto;
3244
+ padding: 0 0 0.75rem;
3245
+ }
3246
+
3247
+ .nav-items {
3248
+ display: flex;
3249
+ flex-direction: column;
3250
+ padding: 0 8px;
3251
+ }
3252
+
3253
+ .nav-item {
3254
+ display: block;
3255
+ padding: 0 12px;
3256
+ height: 40px;
3257
+ line-height: 40px;
3258
+ letter-spacing: 0.13px;
3259
+ color: rgb(32, 33, 36);
3260
+ text-decoration: none;
3261
+ font-size: 13px;
3262
+ font-weight: 500;
3263
+ border-radius: 8px;
3264
+ transition: all 0.15s ease;
3265
+ }
3266
+
3267
+ .nav-item:hover {
3268
+ background: rgba(0, 0, 0, 0.04);
3269
+ color: #163052;
3270
+ }
3271
+
3272
+ .nav-item--active {
3273
+ background: rgba(22, 48, 82, 0.08);
3274
+ color: #163052;
3275
+ font-weight: 600;
3276
+ }
3277
+
3278
+ .content {
3279
+ flex: 1;
3280
+ min-width: 0;
3281
+ display: flex;
3282
+ flex-direction: column;
3283
+ }
3284
+
3285
+ .breadcrumbs {
3286
+ height: 32px;
3287
+ padding: 0 1rem;
3288
+ display: flex;
3289
+ align-items: center;
3290
+ gap: 6px;
3291
+ font-size: 12px;
3292
+ color: #6b7280;
3293
+ //background: #f9fafb;
3294
+ background: #beea4e;
3295
+ border-top: 1px solid #e5e7eb;
3296
+ flex-shrink: 0;
3297
+ }
3298
+
3299
+ .breadcrumbs a {
3300
+ //color: #6b7280;
3301
+ color: #10172a;
3302
+ font-size: 13px;
3303
+ font-weight: 600;
3304
+ text-decoration: none;
3305
+ }
3306
+
3307
+ .breadcrumbs a:hover {
3308
+ color: #111827;
3309
+ text-decoration: underline;
3310
+ }
3311
+
3312
+ .breadcrumbs__separator {
3313
+ color: #d1d5db;
3314
+ }
3315
+
3316
+ .breadcrumbs__current {
3317
+ color: #111827;
3318
+ font-weight: 500;
3319
+ }
3320
+
3321
+ .content__main {
3322
+ flex: 1;
3323
+ overflow-y: auto;
3324
+ }
3325
+ `;
3326
+ __decorate$2([
3327
+ n({ type: String })
3328
+ ], exports.KRScreenNav.prototype, "title", void 0);
3329
+ __decorate$2([
3330
+ n({ type: String })
3331
+ ], exports.KRScreenNav.prototype, "subtitle", void 0);
3332
+ __decorate$2([
3333
+ n({ type: String })
3334
+ ], exports.KRScreenNav.prototype, "backUrl", void 0);
3335
+ __decorate$2([
3336
+ n({ type: Array })
3337
+ ], exports.KRScreenNav.prototype, "navItems", void 0);
3338
+ __decorate$2([
3339
+ n({ type: String })
3340
+ ], exports.KRScreenNav.prototype, "activeId", void 0);
3341
+ exports.KRScreenNav = __decorate$2([
3342
+ t$1('kr-screen-nav')
3343
+ ], exports.KRScreenNav);
3344
+
3345
+ var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
3346
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3347
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3348
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3349
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3350
+ };
3351
+ /**
3352
+ * Detail screen component for viewing/editing entity details.
3353
+ * Displays a form-like layout with labeled fields centered in a single column.
3354
+ *
3355
+ * ## Usage
3356
+ * ```html
3357
+ * <kr-screen-detail title="Company Details">
3358
+ * <kr-button slot="actions">Save</kr-button>
3359
+ * <kr-text-field label="Company Name" value="Acme Corporation"></kr-text-field>
3360
+ * <kr-text-field label="Industry" value="Technology"></kr-text-field>
3361
+ * <kr-text-field label="Website" value="https://acme.com"></kr-text-field>
3362
+ * </kr-screen-detail>
3363
+ * ```
3364
+ *
3365
+ * @slot - Form fields and content (centered, max-width 480px)
3366
+ * @slot actions - Action buttons displayed in the header on the right
3367
+ *
3368
+ * @property {string} title - Section title (e.g., "Company Details")
3369
+ */
3370
+ exports.KRScreenDetail = class KRScreenDetail extends i$1 {
3371
+ constructor() {
3372
+ super(...arguments);
3373
+ /**
3374
+ * Section title
3375
+ */
3376
+ this.title = '';
3377
+ }
3378
+ render() {
3379
+ return x `
3380
+ <div class="header">
3381
+ <h2 class="header__title">${this.title}</h2>
3382
+ <div class="header__actions">
3383
+ <slot name="actions"></slot>
3384
+ </div>
3385
+ </div>
3386
+ <div class="content">
3387
+ <div class="content__inner">
3388
+ <slot></slot>
3389
+ </div>
3390
+ </div>
3391
+ `;
3392
+ }
3393
+ };
3394
+ exports.KRScreenDetail.styles = i$4 `
3395
+ :host {
3396
+ display: flex;
3397
+ flex-direction: column;
3398
+ height: 100%;
3399
+ overflow: hidden;
3400
+ }
3401
+
3402
+ .header {
3403
+ height: 64px;
3404
+ display: flex;
3405
+ align-items: center;
3406
+ justify-content: space-between;
3407
+ padding: 0 1.5rem;
3408
+ background: #ffffff;
3409
+ border-bottom: 1px solid #e5e7eb;
3410
+ flex-shrink: 0;
3411
+ }
3412
+
3413
+ .header__title {
3414
+ font-size: 18px;
3415
+ font-weight: 600;
3416
+ color: #111827;
3417
+ margin: 0;
3418
+ }
3419
+
3420
+ .header__actions {
3421
+ display: flex;
3422
+ align-items: center;
3423
+ gap: 8px;
3424
+ }
3425
+
3426
+ .content {
3427
+ flex: 1;
3428
+ overflow-y: auto;
3429
+ padding: 1.5rem;
3430
+ display: flex;
3431
+ justify-content: center;
3432
+ }
3433
+
3434
+ .content__inner {
3435
+ width: 100%;
3436
+ max-width: 700px;
3437
+ }
3438
+ `;
3439
+ __decorate$1([
3440
+ n({ type: String })
3441
+ ], exports.KRScreenDetail.prototype, "title", void 0);
3442
+ exports.KRScreenDetail = __decorate$1([
3443
+ t$1('kr-screen-detail')
3444
+ ], exports.KRScreenDetail);
3445
+
3446
+ var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
3447
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3448
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3449
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3450
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3451
+ };
3452
+ /**
3453
+ * Secondary bar component that sits below the main app bar.
3454
+ *
3455
+ * @slot - Content to display in the subbar (right side)
3456
+ */
3457
+ exports.KRSubbar = class KRSubbar extends i$1 {
3458
+ constructor() {
3459
+ super(...arguments);
3460
+ /**
3461
+ * Array of breadcrumb items to display
3462
+ */
3463
+ this.breadcrumbs = [];
3464
+ /**
3465
+ * Whether to show the menu icon
3466
+ */
3467
+ this.menu = false;
3468
+ }
3469
+ _handleMenuClick() {
3470
+ this.dispatchEvent(new CustomEvent('menu-click', { bubbles: true, composed: true }));
3471
+ }
3472
+ render() {
3473
+ return x `
3474
+ ${this.menu ? x `
3475
+ <div class="menu" @click=${this._handleMenuClick}>
3476
+ <svg class="menu__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
3477
+ <line x1="3" y1="6" x2="21" y2="6"></line>
3478
+ <line x1="3" y1="12" x2="21" y2="12"></line>
3479
+ <line x1="3" y1="18" x2="21" y2="18"></line>
3480
+ </svg>
3481
+ </div>
3482
+ ` : E}
3483
+ <div class="breadcrumbs">
3484
+ ${this.breadcrumbs.map((crumb, index) => x `
3485
+ ${index > 0 ? x `<span class="breadcrumb-separator">/</span>` : ''}
3486
+ <a
3487
+ class=${e$1({ 'breadcrumb': true, 'breadcrumb--current': index === this.breadcrumbs.length - 1 })}
3488
+ href=${crumb.url || ''}
3489
+ >${crumb.label}</a>
3490
+ `)}
3491
+ </div>
3492
+ <div class="content">
3493
+ <slot></slot>
3494
+ </div>
3495
+
3496
+ `;
3497
+ }
3498
+ };
3499
+ exports.KRSubbar.styles = i$4 `
3500
+ :host {
3501
+ display: flex;
3502
+ flex-direction: row;
3503
+ flex-wrap: nowrap;
3504
+ height: 40px;
3505
+ background: #ffffff;
3506
+ border-bottom: 1px solid rgb(229, 229, 228);
3507
+ align-items: center;
3508
+ padding: 0 16px;
3509
+ width: 100%;
3510
+ }
3511
+
3512
+ .breadcrumbs {
3513
+ display: flex;
3514
+ align-items: center;
3515
+ gap: 4px;
3516
+ font-size: 13px;
3517
+ flex: 1;
3518
+ }
3519
+
3520
+ .breadcrumb {
3521
+ color: #000000;
3522
+ text-decoration: none;
3523
+ cursor: pointer;
3524
+ font-size: 13px;
3525
+ }
3526
+
3527
+ .breadcrumb:hover {
3528
+ text-decoration: underline;
3529
+ }
3530
+
3531
+ .breadcrumb--current {
3532
+ cursor: default;
3533
+ }
3534
+
3535
+ .breadcrumb--current:hover {
3536
+ text-decoration: none;
3537
+ }
3538
+
3539
+ .breadcrumb-separator {
3540
+ color: #9ca3af;
3541
+ font-size: 12px;
3542
+ }
3543
+
3544
+ .content {
3545
+ display: flex;
3546
+ align-items: center;
3547
+ margin-left: auto;
3548
+ }
3549
+
3550
+ .menu {
3551
+ display: flex;
3552
+ align-items: center;
3553
+ justify-content: center;
3554
+ width: 24px;
3555
+ height: 24px;
3556
+ margin-right: 8px;
3557
+ cursor: pointer;
3558
+ }
3559
+
3560
+ .menu__icon {
3561
+ width: 18px;
3562
+ height: 18px;
3563
+ }
3564
+ `;
3565
+ __decorate([
3566
+ n({ type: Array })
3567
+ ], exports.KRSubbar.prototype, "breadcrumbs", void 0);
3568
+ __decorate([
3569
+ n({ type: Boolean })
3570
+ ], exports.KRSubbar.prototype, "menu", void 0);
3571
+ exports.KRSubbar = __decorate([
3572
+ t$1('kr-subbar')
3573
+ ], exports.KRSubbar);
3574
+
3575
+ }));
3576
+ (function(e){Object.keys(e).forEach(function(k){if(k.startsWith('KR')&&typeof e[k]==='function'){e[k.slice(2)]=e[k];delete e[k];}});})(krApp);
3577
+ //# sourceMappingURL=krubble-app.umd.js.map