@kodaris/krubble-app-components 1.0.9 → 1.0.11

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