compelem 0.3.1-b1 → 0.3.2-b1

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.
@@ -2,4 +2,4 @@ export declare const enum ModelTriggerType {
2
2
  CHANGE = "change",
3
3
  INPUT = "input"
4
4
  }
5
- export declare const model: (modelValue: any, modelPath?: string | undefined) => import("../directive/index").DirectiveWrapper;
5
+ export declare const model: (modelValue: any, updateProp?: string | undefined) => import("../directive/index").DirectiveWrapper;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * compelem v0.3.1-b1.1739106920
2
+ * compelem v0.3.2-b1.1739287210
3
3
  * A modern, reactive, fast, lightweight and flexible lib for building web components
4
4
  * @holyhigh2
5
5
  * https://github.com/holyhigh2/compelem
6
6
  */
7
- import{toPath as t,get as e,isObject as s,isDefined as r,isUndefined as n,isEmpty as i,has as o,concat as a,defaults as l,merge as c,cloneDeep as d,each as h,kebabCase as u,toArray as p,last as f,startsWith as g,isFunction as m,isArray as _,initial as E,isBlank as b,join as v,split as C,set as y,camelCase as S,isEqual as N,replace as T,isPlainObject as P,flatMap as x,isString as w,test as A,size as M,assign as O,first as k,debounce as R,closest as L,once as D,bind as V,isNil as H,trim as I,some as $,isNull as W,fval as j,omit as U,groupBy as B,reject as z,filter as F,slice as K,compact as Q,remove as X,includes as G,find as q,throttle as Y,map as Z,replaceAll as J,snakeCase as tt,toString as et,reduce as st,isMatch as rt,clone as nt,findIndex as it,call as ot}from"myfx";const at=new WeakMap,lt=/\s+\.?key\s*=/;var ct,dt,ht;function ut(t){console.error("[CompElem]",t)}function pt(t,e){console.error(`[CompElem <${t}>]`,e)}function ft(e){return t(e).join("-")}function gt(t){return Object.getPrototypeOf(t)}!function(t){t[t.CSS=1]="CSS",t[t.COMPUTED=2]="COMPUTED"}(ct||(ct={})),function(t){t.PROPS="__deco_props",t.STATES="__deco_states",t.COMPUTED="__deco_computed",t.WATCH="__deco_watch",t.EVENTS="__deco_events"}(dt||(dt={})),function(t){t.CLASS="class",t.FIELD="field",t.METHOD="method"}(ht||(ht={}));class mt{static get priority(){return 0}}const _t="getKey",Et="__decorators",bt=new WeakMap;class vt{args;metadata;decoratorClass;instanceMap;key;priority=0;constructor(t,s,r){this.args=t,this.metadata=s,this.decoratorClass=r,this.priority=e(r,"priority",0),this.instanceMap=new WeakMap}create(t){let o,a=new this.decoratorClass(...this.args),l=a.targets,c=this.metadata[2];s(c)&&r(e(c,"configurable"))?o=ht.METHOD:n(this.metadata[2])&&(o=ht.FIELD),!i(l)&&o&&l.includes(o)?(a.created(t,...this.metadata),this.instanceMap.set(t,a)):ut(`Decorator '${this.decoratorClass.name}' is out of targets, expect '${l.join(",")}' bug got '${o}'`)}beforeMount(t,e){this.instanceMap.get(t).beforeMount(t,e,...this.metadata)}mounted(t,e){this.instanceMap.get(t).mounted(t,e,...this.metadata)}updated(t,e){this.instanceMap.get(t).updated(t,e)}}const Ct=new WeakMap;function yt(t){let s=(...s)=>(...r)=>{let n=r[0].constructor,i=e(n,Et);if(!o(n,Et)){let t=e(Object.getPrototypeOf(n),Et);i=t?a(t):[],Reflect.defineProperty(n,Et,{configurable:!1,enumerable:!1,value:i})}let l,c={},d=e(t,_t);if(d){let e=Ct.get(t);if(e||(e=new WeakMap,Ct.set(t,e)),c=e.get(n),c||(c={},e.set(n,c)),l=d(...s),c[l])return c[l]}let h=new vt(s,r,t);return c[l]=h,i?.push(h),h};return bt.set(s,!0),s}const St=new WeakMap;function Nt(t){if(1===arguments.length)return(e,s,r)=>{t.required=t.required||!1,t.attribute=!1!==t.attribute,Tt(e,s,t,r)};let e=arguments[0],s=arguments[1],r=arguments[2];t={type:void 0,required:!1,attribute:!0},r&&"function"==typeof r.type&&(t=l(r,t),r=void 0),Tt(e,s,t,r)}function Tt(t,e,s,r){let n;if(/[a-z]/.test(e[0])||ut(`Prop '${e}' must be in CamelCase`),!o(t.constructor,dt.PROPS)){const e={};let s=t.constructor;for(;(s=gt(s))!==jt;)c(e,s[dt.PROPS]?d(s[dt.PROPS]):{});Reflect.defineProperty(t.constructor,dt.PROPS,{configurable:!1,enumerable:!1,value:e}),n=new Set,h(e,((t,e)=>{if(t.attribute){let t=u(e);n?.add(t)}})),St.set(t.constructor,n)}if(r&&(r.get&&(s.getter=r.get),r.set&&(s.setter=r.set)),s.attribute){n||(n=St.get(t.constructor));let s=u(e);n?.add(s)}o(t.constructor,"observedAttributes")||(t.constructor.observedAttributes=[]),t.constructor.observedAttributes=p(n),t.constructor[dt.PROPS][e]=s}const Pt=new Set;function xt(t){return St.get(t)??Pt}const wt={collectWatch(t,e,s){let r=Rt.get(t);r||(r={},Rt.set(t,r));let n=r[s];n||(n=r[s]=[]),n.push(e)},startCollect(t,e){this.__collectType=e,this.__collecting=t},setUpdater(t){this.__updater=t},endCollect(){this.__collecting=null},__directiveQ:[],setDirectiveQ(t){let e=f(this.__directiveQ);const s=t?t.join(","):"",r=e?e.join(","):"";e&&s===r||(e&&e.length<t.length&&g(s,r)?this.__directiveQ[this.__directiveQ.length-1]=t:this.__directiveQ.push(t))},popDirectiveQ(){let t=a(this.__directiveQ);return this.__directiveQ=[],t},startRender(t){this.__renderCollecting=!0,this.__renderContext=t},endRender(t){this.__renderCollection.forEach((e=>{t._regDeps(e,this.__renderContext)})),this.__renderCollection.clear(),this.__renderCollecting=!1,this.__renderContext=null},collect(t){this.__renderCollection.add(t)},clear(){this.__directiveQ=[]},__updater:null,__collecting:null,__collectType:-1,__renderCollection:new Set,__renderContext:null,__renderCollecting:!1,__skipCheck:!1},At=new WeakMap,Mt=new WeakMap,Ot=new WeakMap,kt=new WeakMap,Rt=new WeakMap;function Lt(t,r){if(!s(t))return t;const n=t.__proxy?t:new Proxy(t,{get(t,e,s){if(!e)return;const r=Reflect.get(t,e,s);if("string"!=typeof e&&"number"!=typeof e)return r;let n=e in t;if((wt.__renderCollecting||wt.__collecting)&&(n&&t.hasOwnProperty(e)||!n)){let t=Mt.get(s)??[],r=a(t,[e]),n=r.join("-");if(wt.__renderCollecting)wt.collect(ft(r)),wt.setDirectiveQ(r);else if(wt.__collecting){let t;switch(wt.__collectType){case ct.COMPUTED:t=Ot.get(wt.__collecting),t||(t={},Ot.set(wt.__collecting,t));break;case ct.CSS:t=kt.get(wt.__collecting),t||(t={},kt.set(wt.__collecting,t))}let e=t[n];e||(e=t[n]=[]),e.push(wt.__updater)}}return r},set(t,r,n,o){if(!r)return!1;let l=t[r];if(!s(l)&&l===n)return!0;if(Number.isNaN(n)&&Number.isNaN(l))return!0;let c=Mt.get(o)??[],d=a(c,[r]),h=At.get(o).from,u=e(h.constructor,dt.PROPS),p=e(h.constructor,dt.STATES),f=e(u,[d[0],"hasChanged"])||e(p,[d[0],"hasChanged"]);if(f){if(!f.call(h,n,l))return!0}else if(l===n&&!at.has(l))return!0;u&&u[r]&&t.__isData&&u[r].sync&&h.emit("update:"+r,{value:n});let g=At.get(o)?.contextSet,E=n;!s(n)||m(n)||n instanceof Node||Object.isFrozen(n)||g.forEach((t=>{let e=At.get(o)?.pathMap,s=e?.get(t);s&&(d=a(s,[r]),Mt.set(E,d),E=Lt(E,t),Mt.set(E,d))}));let b=Reflect.set(t,r,E),v=At.get(o).pathMap;return g.forEach((t=>{let s=v.get(t);if(!s)return;t===h&&c.length>1&&s.length>1&&c[0]===s[0]&&(s=c),d=a(s,"length"==r&&_(o)?[]:[r]);let n=Ot.get(t),u=kt.get(t),p=Rt.get(t);if(n||u||p){let t=d.length;for(;t;){let s=d.slice(0,t).join("-");if(p){const r=p[s];t===d.length?r?.forEach((t=>{let e=t();e.ov=l,Dt.pushWatch(e)})):r?.forEach((t=>{let s=t();e(s,"deep")&&(s.ov=l,Dt.pushWatch(s))}))}if(n){let t=n[s];if(!i(t))for(let e=0;e<t.length;e++){const s=t[e];Dt.pushComputed(s)}}if(u){let t=u[s];if(!i(t))for(let e=0;e<t.length;e++){const s=t[e];Dt.pushCss(s)}}t--}}let f=t._notify(l,d);Dt.pushNext(f)})),b}});t.__proxy||Reflect.defineProperty(t,"__proxy",{enumerable:!1,writable:!1,configurable:!1,value:!0});let o=Mt.get(t)??[];if(Object.isExtensible(t)&&!At.get(n)){let t=new Set;t.add(r);let e=new WeakMap;e.set(r,o),At.set(n,{from:r,contextSet:t,pathMap:e})}else{At.get(n).contextSet.add(r);let t=At.get(n).pathMap,s=t.get(r),i=a(o);if(s&&s.join("")!==i.join("")){let t=e(r,E(s));_(t)||function(...t){console.warn("[CompElem]",...t)}(`The object is referenced by more than one @state '${i.join(".")},${s.join(".")}'`),s=i}else t.set(r,i)}for(let e in t){const n=t[e];!s(n)||n.__proxy||m(n)||n instanceof Node||Object.isFrozen(n)||(Mt.set(n,a(o,[e])),t[e]=Lt(n,r),Mt.set(t[e],a(o,[e])))}return n}class Dt{static watchSet=new Set;static computedSet=new Set;static cssSet=new Set;static nextSet=new Set;static nextPending=!1;static next;static{const t=Promise.resolve(),e=Dt.flush;Dt.next=()=>{t.then(e)}}static flush(){Dt.nextPending=!1;let t=Array.from(Dt.watchSet);Dt.watchSet.clear();let s=Array.from(Dt.computedSet);Dt.computedSet.clear();let r=Array.from(Dt.cssSet);Dt.cssSet.clear();let n=Array.from(Dt.nextSet);Dt.nextSet.clear(),t.forEach((t=>t(e(t,"ov")))),s.forEach((t=>t())),r.forEach((t=>t())),n.forEach((t=>t()))}static pushWatch(t){Dt.watchSet.add(t)}static pushComputed(t){Dt.computedSet.add(t)}static pushCss(t){Dt.cssSet.add(t)}static pushNext(t){Dt.nextSet.add(t),Dt.nextPending||(Dt.nextPending=!0,Dt.next())}}function Vt(t){return class extends t{__updatePoints;renderComponent;buildView(t){let e=this instanceof jt?this:this.renderComponent,[s,r]=we(e,t),n=[],i=Ve(n,s,r,e,this);return this.__updatePoints=n,i}updateView(t){if(b(v(t.strings)))return;if(!this.__updatePoints)return;let{vars:r}=t,n=this instanceof jt?this:this.renderComponent;for(let t=0;t<this.__updatePoints.length;t++){const i=this.__updatePoints[t];let o=i.varIndex,a=i.value,l=r,c=i.node,d=C(o,"-");for(let s=0;s<d.length;s++){const r=d[s];l=e(l,r),l&&l.vars&&t<d.length-1&&(l=l.vars)}if(!s(a)&&a===l)continue;let h=c;if(i.isDirective){if(!a.di)continue;l.di=a.di,l.di.renderParams=l.varChain,l.di._renderArgs=l.args,l.point=a.point,l.varPath=a.varPath,a.update(a.point,l.args,a.args)}else if(i.isToggleProp){if(!!l===a)continue;h.toggleAttribute(i.attrName,!!l),y(h,i.attrName,!!l)}else if(i.isProp){if(!s(l)&&l===a)continue;let t=S(i.attrName),r=e(i.node.constructor,dt.PROPS);if(r){let e=r[t];if(e&&e.hasChanged&&!e.hasChanged.call(this,l,a))continue}c instanceof jt?c._updateProps({[i.attrName]:l}):c instanceof HTMLSlotElement&&n._updateSlot(c.getAttribute("name")||"default",i.attrName,l)}else if(i.attrName&&!i.isEvent){if(!N(a,l))switch(i.attrName){case"value":if(c instanceof HTMLInputElement){c.value=l;break}default:c.setAttribute(i.attrName,T(i.attrTmpl,De,l+""))}}else if(i.isTmpl)(l.strings.join()!==a.tmpl.strings.join()||l.vars.some((t=>s(t)&&!P(t)))||a.tmpl.vars.some((t=>s(t)&&!P(t)))||!N(l.vars,a.tmpl.vars))&&i.value.updateView(l),a.tmpl=l,l=a;else if(i.isText){let t=i.textNode.nextSibling;t&&t===i.node.previousSibling?t.textContent=l:(He.remove(i.textNode,i.node),He.insertBefore(i.node,[l]))}i.value=l}}}}class Ht extends(Vt(Object)){tmpl;constructor(t){super(),this._renderVars=e(t,"_renderVars"),this.tmpl=t}}const It={boolean:Boolean,string:String,number:Number,object:Object,array:Array,function:Function,bigint:BigInt,symbol:Symbol,undefined:Object},$t=new WeakMap;let Wt=[];class jt extends(Vt(HTMLElement)){static __l_globalRule=document.createElement("style");static{document.head.appendChild(jt.__l_globalRule)}static defaults(t){Wt=x(t.css,(t=>{if(w(t)){let e=new CSSStyleSheet;return e.replaceSync(t),e}return t instanceof CSSStyleSheet?t:[]})),t.global,h(t,((t,e)=>{A(e[0],/[A-Z]/)}))}#t={};#e={"#slots":{}};#s={};#r={};#n;#i;#o={};__events={};get[Symbol.toStringTag](){return this.constructor.name}get reactiveData(){return this.#s}get attrs(){return this.#a}get props(){return this.#l}get renderRoot(){return this.#c}get renderRoots(){return this.#d}get parentComponent(){return this.#h}get slotHooks(){return this.#u}get css(){return $t.get(this.constructor)}get isMounted(){return this.#p}get slots(){return this.#e["#slots"]}#a;#l;#c;#d;#h;#f={};#u={};#g={};#p=!1;static get autoSlot(){return!0}static get styles(){return[]}static get globalStyles(){return[]}get styles(){return[]}#m=!1;constructor(...t){super(),1===M(t)&&(this.#l={},O(this.#l,k(t)));let s=this.render.bind(this);this.render=function(){let t;return wt.startRender(this),t=s(),wt.endRender(this),t};let r=e(this.constructor,"globalStyles"),n=e(this.constructor,"_global_style_attached");if(!i(r)&&"1"!==n){let t="";r.forEach((e=>{w(e)&&(t+=e+"\n")})),jt.__l_globalRule.textContent+=t,y(this.constructor,"_global_style_attached","1")}let o=$t.get(this.constructor),a=o??[];o||(h(e(this.constructor,"styles"),(t=>{if(w(t)){let e=new CSSStyleSheet;e.replaceSync(t),a.push(e)}else a.push(t)})),$t.set(this.constructor,a)),this.#n=this.attachShadow({mode:"open",slotAssignment:e(this.constructor,"autoSlot",!0)?"named":"manual"}),this.#n.adoptedStyleSheets=[...Wt,...a];let l=this.attributes.getNamedItem("css-link")?.value;if(l){const t=document.createElement("style");t.textContent=`@import "${l}"`,this.#n.appendChild(t)}let c=R(this.#_,20);this.#i=new MutationObserver((t=>{for(let e=0;e<t.length;e++){"childList"===t[e].type&&c.call(this)}})),this._slotsPropMap={default:[]};let d=e(this.constructor,Et);d&&d.sort(((t,e)=>e.priority-t.priority)).forEach((t=>t.create(this))),this.#E=this.#b.bind(this)}#E;connectedCallback(){let t=L(this.parentNode,(t=>t instanceof jt||t.host instanceof jt),"parentNode");this.#h=t?t instanceof jt?t:t.host:null,this.__init()}disconnectedCallback(){this.#i.disconnect()}__init(){if(this.#m)return;this.#v();const t=this.#C();this.propsReady(t);for(const e in t){const s=t[e];this.#e[e]=s}this.#y(),h(this.#e,((t,e)=>{let s=Reflect.getOwnPropertyDescriptor(this.#e,e);Reflect.defineProperty(this,e,{get(){let t=Reflect.get(this.#s,e);return s?.get?s?.get():t},set(t){s?.set?s?.set(t):Reflect.set(this.#s,e,t)}})})),Reflect.defineProperty(this.#e,"__isData",{enumerable:!1,value:!0}),this.#s=Lt(this.#e,this);let s=this.render(),r=this.buildView(s);if(r){let t=p(r);t.forEach((t=>{this.#n.appendChild(t)})),this.#d=t,this.#c=t[0]}this.#_(),this.beforeMount(),this.#i.observe(this,{childList:!0});const n=this;let i=e(this.constructor,Et);i&&i.sort(((t,e)=>e.priority-t.priority)).forEach((t=>{t.beforeMount(this,((t,e)=>(n.#s[t]=e,n.#s[t])))}));let o=e(this.constructor,dt.WATCH);h(o,((t,s)=>{t.forEach((t=>{let{source:r,options:n,handler:i}=t,o=i.bind(this);e(n,"once",!1)&&(o=D(o));const a=function(t){let s=e(this,r.replaceAll("-","."));o(s,t,r)}.bind(this);let l=e(n,"deep",!1);if(a.deep=l,wt.collectWatch(this,(()=>a),s),!e(n,"immediate",!1))return;let c=e(this,r.replaceAll("-","."));o(c,c,r)}))}));let a=e(this.constructor,dt.COMPUTED);h(a,((t,e)=>{wt.startCollect(this,ct.COMPUTED),wt.setUpdater((()=>{this.#s[e]=t.call(this)})),this.#e[e]=t.call(this),wt.endCollect(),Reflect.defineProperty(this,e,{get(){return Reflect.get(this.#s,e)},set(t){pt(this.tagName,"Cannot set a computed property '"+e+"'")}})}));let l=e(this.constructor,dt.EVENTS);l&&l.forEach((t=>{let e=t.name,s=O({target:document,once:!1,passive:!1,capture:!1},t.options),r=V(t.fn,this),n=s.target;m(n)&&(n=n.call(this,this)),n?n.addEventListener(e,r,s):pt(this.tagName,"The target of @event('"+e+"',...) is invalid")})),h(this.#u,((t,e)=>{this.#S(e)})),wt.startCollect(this,ct.CSS);let c=[];this.styles.forEach((t=>{if(!m(t))return;let e=new CSSStyleSheet;c.push(e),wt.setUpdater((()=>{let s=t()??"";e.replaceSync(s)}));let s=t();b(s)||e.replaceSync(s)})),wt.endCollect(),this.#n.adoptedStyleSheets=[...this.#n.adoptedStyleSheets,...c],setTimeout((()=>{this.#p=!0,this.mounted(),i&&i.forEach((t=>{t.mounted(this,((t,e)=>(n.#s[t]=e,n.#s[t])))}))}),0),this.#m=!0}propsReady(t){}render(){throw Error(`[CompElem <${this.tagName}>] Missing render()`)}beforeMount(){}mounted(){}#N(t,s){this.#v();let r=e(this.#t[s],"props");r&&h(this.slots,((t,s)=>{t.filter((t=>t.nodeType===Node.ELEMENT_NODE)).forEach((t=>{t instanceof jt?t._updateProps(r):h(r,((s,r)=>{if(t instanceof HTMLSlotElement){let n=e(t,"__l_comp");if(n){let e=t.name||"default",i=n.#t[e];i||(i=n.#t[e]={props:{}}),i.props||(i.props={}),i.props[r]=s,n.#N(t,e)}}else t.setAttribute(r,s)}))}))})),this.slotChange(t,s)}slotChange(t,e){}attributeChangedCallback(t,e,s){this.#T(t,e,s)}shouldUpdate(t){return!0}updated(t){}emit(t,s={},r){r&&r.event&&(s.event=r.event),s.target=this,this.dispatchEvent(new CustomEvent(t,{bubbles:e(r,"bubbles",!1),composed:e(r,"composed",!1),cancelable:!0,detail:s}))}#P={};on(t,e){this.#P[t]||(this.#P[t]=[]);let s=e.bind(this);this.#P[t].push(s),this.addEventListener(t,s)}nextTick(t){Dt.pushNext(t)}forceUpdate(){h(this.#s,((t,e)=>{this.#r[e]={value:void 0,chain:void 0}})),this.#b()}_notify(t,r){let n=[];for(let i=0;i<r.length;i++){const o=r[i];n.push(o);let a=e(this,n),l=ft(n);this.#r[l]={value:a,chain:"slots"===l?["slots"]:n,oldValue:t,end:n.length===r.length},s(a)&&"#"!=l[0]&&at.set(a,l)}return this.#E}#b(){if(M(this.#r)<1)return;const t=this.#r;this.#r={};let r=e(this.constructor,Et);if(r&&r.sort(((t,e)=>e.priority-t.priority)).forEach((e=>{e.updated(this,t)})),!this.shouldUpdate(t))return;let n=new Set;h(t,(({value:t,chain:e,oldValue:s},r)=>{this.#o[r]&&this.#o[r].forEach((t=>{n.add(t)}))})),n.forEach((t=>{if(t===this)this.updateView(this.render());else{let e=t.render(...t._renderArgs?t._renderArgs:[]);e&&t.updateView(e)}})),this.#x.forEach((t=>{this.#S(t)})),this.updated(t),h(t,(({value:t,chain:e,oldValue:r},n)=>{s(t)&&at.has(t)&&at.delete(t)}))}#C(){let t=e(this.constructor,dt.PROPS),i=this.attributes,a=this.tagName,l=this.#l,c={};h(i,(({name:e,value:s})=>{if(e[0]===be||e[0]===ve||e[0]===Ce||e===Ne||"slot"===e)return;let r=S(e);t&&!t[r]&&(c[e]=s)})),this.#a=this.#a?O(this.#a,c):c;let d={};return h(t,((c,h)=>{let p,f=t[h],g=o(l,h),m=e(this,h);if(!("_defaultValue"in f)&&(f._defaultValue=m,!f.type)){n(m)&&pt(a,"Prop '"+h+"' has neither propType nor defaultValue be used for type inference");let t=typeof m;_(m)&&(t="array");let e=It[t];f.type=e}if(g)p=H(l[h])?m:l[h];else{p=m;let t=i.getNamedItem(u(h))||i.getNamedItem(ve+u(h));t&&(g=!0,p=t.value)}if(f.required&&!g)return pt(a,"Prop '"+h+"' is required"),!1;p=this.#w(t,h,p);let E=e(t,[h,"getter"]);E&&(E=V(E,this));let b=e(t,[h,"setter"]);b&&(b=V(b,this)),(E||b)&&Reflect.defineProperty(this.#e,h,{set:b||function(t){},get:E}),f.attribute&&r(p)&&!s(p)&&this.setAttribute(u(h),I(p)),this.#e[h]=p,d[h]=p})),Object.seal(d)}#w(t,e,s){let i=t[e];if(!i)return s;let o=i.isValid,a=i.type,l=_(a)?a:[a],c=i.converter,d=s;if(!$(l,(t=>t===String))&&w(d)&&!W(d))try{d=c?c(d):j(d,{html:Ie})}catch(t){pt(this.tagName,`Convert attribute '${e}' error with `+d)}for(let t=0;t<l.length;t++){"Boolean"===l[t].name&&(w(d)&&/(?:^true$)|(?:^false$)/.test(d)?d=j(d):(n(d)||b(d))&&(d=!0))}let h=typeof d,u=!r(d);for(let t=0;t<l.length;t++){const e=l[t];if(A(h,e.name,"i")||d instanceof e||Object.prototype.toString.call(d)===Object.prototype.toString.call(e.prototype)){u=!0;break}}return u||pt(this.tagName,`Invalid prop '${e}'. expected '${l.map((t=>t.name||t))}' but got '${h}'`),o&&(o.call(this,d,this.#e)||pt(this.tagName,`Invalid prop '${e}'. IsValid() check failed`)),d}#y(){let t=e(this.constructor,dt.STATES);h(t,((s,r)=>{let n=t[r],i=e(this,r);if(n){let t=n.prop;i=t?d(this.#e[t]):e(this,r)}this.#e[r]=i}))}#A=R(this.propsReady,100);_setParentProps(t,s){if(this.#m){let r=e(this.constructor,dt.PROPS);h(t,((t,e)=>{let s=S(e),n=r[s];if(!n)return;let i=this.#e[s];t=this.#w(r,s,t),n.hasChanged&&!n.hasChanged.call(this,t,i)||(this.#e[s]=t,this._notify(i,[s]))})),O(this.#l,t),O(this.#a,s),this.#A(this.#l)}}_updateProps(t){let s=e(this.constructor,dt.PROPS);h(t,((t,e)=>{let r=S(e),n=s[r];if(!n)return;let i=this.#e[r];t=this.#w(s,r,t),n.hasChanged&&!n.hasChanged.call(this,t,i)||(wt.__skipCheck=!0,y(this,r,t),wt.__skipCheck=!1)})),O(this.#l,t),this.#A(this.#l)}_initProps(t,e){this.#l=c(this.#l||{},t),this.#a=c({},e)}_bindSlot(t,e,s){if(this.#f[e]||(this.#f[e]=t,Reflect.defineProperty(t,"__l_comp",{value:this})),t.addEventListener("slotchange",(s=>{this.#m&&this.#N(t,"default"===e?"":e)})),!i(s)){let t=this.#t[e];t||(t=this.#t[e]={}),s.nodeFilter&&(t.filter=s.nodeFilter),t.props=U(s,"nodeFilter")}}_bindSlotHook(t,e){this.#u[t]=e}#x=new Set;_updateSlot(t,e,s){let r=this.#f[t],n=this.#u[t];if(!n&&!r)return;let i=this.#t[t];if(e&&(i.props||(i.props={}),i.props[e]=s),n)this.#x.add(t);else{let t=r.assignedElements({flatten:!0});for(let r=0;r<t.length;r++){t[r].setAttribute(e,s+"")}}}#v(){const t=x(this.childNodes,(t=>t.nodeType===Node.COMMENT_NODE?[]:t instanceof HTMLSlotElement?t.assignedNodes({flatten:!0}):t));let e=B(t,(t=>t.nodeType===Node.TEXT_NODE?"default":t instanceof Element?t.getAttribute("slot")||"default":void 0));if(i(e))return void(i(this.#e["#slots"])||(this.#m?this.#s["#slots"]={}:this.#e["#slots"]={}));h(e,((t,e)=>{if(e){for(;t.length>0;){let e=t[0];if(!(e.nodeType===Node.TEXT_NODE&&b(e.textContent)||e instanceof HTMLSlotElement&&i(e.assignedNodes({flatten:!0}))))break;t.shift()}for(;t.length>0;){let e=f(t);if(!(e.nodeType===Node.TEXT_NODE&&b(e.textContent)||e instanceof HTMLSlotElement&&i(e.assignedNodes({flatten:!0}))))break;t.pop()}}}));let s={};h(e,((t,e)=>{i(t)||(s[e]=t)})),this.#m?this.#s["#slots"]=s:this.#e["#slots"]=s}#S(t){let s=this.#u[t];if(!s)return;let r=this.#t[t];if(!this.#e["#slots"][t])return;this.renderAsync(s,e(r,"props"));const n=this._asyncDirectives.get(s);let o=n?.buildView(s(e(r,"props"))),a=z(p(o),(t=>t.nodeType===Node.COMMENT_NODE));if(a){let e=this.#g[t];if(!i(e))for(let t=0;t<e.length;t++){const s=e[t];s.parentNode?.removeChild(s)}this.#g[t]=a,this.append(...a),this.#x.clear()}}_asyncDirectives=new WeakMap;renderAsync(t,...e){}#_(){i(this.#t)||h(this.slots,((t,e)=>{if(i(t))return;let r=this.#t[e],n=t;if(r){let e=r.filter;if(m(e))n=e(t);else if(s(e)){let s=e.type,r=e.maxCount;if(s){let e=_(s)?s:[s];n=F(t,(t=>$(e,(e=>t instanceof e))))}r>0&&(n=K(t,0,r))}}if("named"===this.#n.slotAssignment){let e=[];for(let s=0;s<t.length;s++){const r=t[s];n.includes(r)||e.push(r)}for(;e.length>0;){let t=e.pop();t.parentNode?.removeChild(t)}}else this.#f[e].assign(...n);this.#m&&this.#N(this.#f[e],"default"===e?"":e)}))}#T(t,s,r){if(!this.isMounted)return;if(xt(this.constructor).has(t)){let s=S(t);if(W(r)){r=e(this.constructor,dt.PROPS)[s]._defaultValue}this._updateProps({[s]:r})}}_regDeps(t,e){let s=this.#o[t];s||(s=this.#o[t]=new Set),s.add(e);let r=t.split("-");if(r.pop(),r.length<1)return;let n=r.join("-");s=this.#o[n],s||(s=this.#o[n]=new Set),s.add(e)}}var Ut,Bt,zt;!function(t){t.NONE="NONE",t.REMOVE="REMOVE",t.REPLACE="REPLACE",t.UPDATE="UPDATE",t.APPEND="APPEND"}(Ut||(Ut={}));class Ft{key;varIndex;value;isText=!1;isTmpl=!1;isDirective=!1;node;textNode;isComponent=!1;attrName;attrTmpl;isProp=!1;isToggleProp=!1;isEvent;constructor(t,e,s,r){this.varIndex=t,this.node=e,s&&(this.attrName=s),r&&(this.attrTmpl=r)}}!function(t){t.ATTR="attr",t.PROP="prop",t.TEXT="text",t.CLASS="class",t.STYLE="style",t.SLOT="slot",t.TAG="tag"}(Bt||(Bt={}));class Kt{startNode;endNode;type;attrName;varIndex;expressionChain;nodes;constructor(t,e,s){this.startNode=t,this.attrName=e,this.type=s}setVarIndex(t){this.varIndex=t}getNodes(){let t=this.startNode.nextSibling;if(!this.endNode)return[t];let e=[];for(;t&&t!==this.endNode;)e.push(t),t=t?.nextSibling;return e}}!function(t){t.AFTER_BEGIN="afterbegin"}(zt||(zt={}));class Qt extends Function{diClass;args;di;varPath;point;slotComponent;varChain;constructor(t,...e){super(),this.diClass=t,this.args=e,this.varChain=wt.popDirectiveQ(),this.di=new this.diClass,this.di.renderParams=this.varChain}checkScope(t){let s=e(this.diClass,"scopes");i(s)||A(s.join(","),t)||ut(`Directive '${this.diClass.name}' is out of scopes, expect '${s.join(",")}' bug got '${t}'`)}render(t){let e=this.di;return this.args,e.renderComponent||(e.renderComponent=t),this.di=e,e._renderArgs=this.args,this.di.render(...this.args)}update(t,e,s){let r=this.di.update(t,e,s);if(r===Ut.NONE)return;let n=t.getNodes();if(r===Ut.REMOVE)for(let t=0;t<n.length;t++){const e=n[t];e.parentNode?.removeChild(e)}else if(r===Ut.REPLACE){let s=[];for(let t=0;t<n.length;t++){const e=n[t];e.parentNode?.removeChild(e)}let r=this.di.render(...e),i=this.di.buildView(r);s=p(i);let o=document.createDocumentFragment();o.append(...s),t.endNode.parentNode.insertBefore(o,t.endNode)}else if(r===Ut.UPDATE){let s,r={},o=[],a=[],l=this.di.render(...e);if(l||(l=new je([],[])),i(n)){let e=this.di.buildView(l);return void t.startNode.after(...e)}let c={};l instanceof je&&l.vars.forEach((t=>{if(t instanceof je){const e=t.getKey();c[e]=t,r[e]=!0,a.push(e)}})),n=F(Q(n),(t=>t.nodeType===Node.ELEMENT_NODE)),s=F(Q(p(s)),(t=>t.nodeType===Node.ELEMENT_NODE));let d={},u="",g={};for(let t=0;t<n.length;t++){let e=n[t],s=e.getAttribute("key");if(s){if(d[s]){u=s;break}d[s]=e,o.push(s),g[s]=!0}}if(u)return void ut(`${S(this.diClass.name)} - duplicate key '${u}'`);let m=r;const _=t.startNode.parentNode;let b=[],v=[];if(h(g,((t,e)=>{m[e]||(v.push(e),delete g[e],X(o,e))})),!i(a)){let e="",s=-1,r=[],n=new Map;for(let i=0;i<a.length;i++){const l=a[i];let c=o.findIndex((t=>t===l));if(c>-1&&c!==i){if(s<0||s-c==1){let t=f(r);r.push({nodeId:l,targetId:0===i?zt.AFTER_BEGIN:t?t.nodeId:a[i-1]})}else n.set(r.length,{group:r,targetId:""}),r=[],r.push({nodeId:l,targetId:o[c]});s=c}else if(c<0){let s=e?d[e]||t.endNode:t.startNode;b.push({prevNode:s,newkey:l})}e=l}i(n)&&r.length>0&&n.set(r.length,{group:r,targetId:""});let l=n.keys().toArray(),c=l.sort(((t,e)=>t-e));if(l.length>0&&l.length<2){let{group:e}=n.get(c[0]);E(e).forEach((({targetId:e,nodeId:s})=>{let r,n=d[s];e===zt.AFTER_BEGIN?(r=t.startNode,r.after(n)):(r=d[e],r.after(n))}))}}b.length>0&&this.#M(b,c,a),b.forEach((e=>{let s=e.newkey,r=this.newNodeMap[s],n=e.prevNode;n===t.endNode?n.before(r):(t.startNode,n.after(r))})),v.forEach((t=>{let e=o.findIndex((e=>e==t));this.#O(e);let s=d[t];s&&s.parentNode&&_.removeChild(s)})),this.di.__updatePoints.forEach((t=>{t.key||(t.key=t.value.tmpl.getKey());const e=a.findIndex((e=>e==t.key));t.varIndex=e})),this.di.updateView(l)}}getDirective(){return this.di}newNodeMap={};#M(t,e,s){const r=[],n=[];t.forEach((t=>{let s=t.newkey;r.push(""),n.push(e[s])})),r.push("");let i=new je(r,n),o=this.di.__updatePoints,a=this.di.buildView(i);this.di.__updatePoints.forEach(((t,e)=>{const s=t.value.tmpl.getKey();t.key=s})),this.di.__updatePoints.push(...o),a.forEach((t=>{t instanceof HTMLElement&&(this.newNodeMap[t.getAttribute("key")]=t)}))}#O(t){X(this.di.__updatePoints,((e,s)=>{if(e.varIndex==t)return He.remove(e.node,e.textNode),!0}))}}function Xt(t){return(...e)=>{let s=null;return e.forEach(((t,r)=>{if(m(t)){let n=t;e[r]=function(...t){let e=s.di;wt.startRender(e);let r=n.call(e.renderComponent,...t);return wt.endRender(e.renderComponent),r}}})),s=new Qt(t,...e),s}}const Gt=["resize","outside","mutate"],qt=new WeakMap,Yt=[],Zt=new ResizeObserver((t=>{for(const e of t){const t=Array.isArray(e.contentBoxSize)?e.contentBoxSize[0]:e.contentBoxSize,s=Array.isArray(e.borderBoxSize)?e.borderBoxSize[0]:e.borderBoxSize;let r=qt.get(e.target);if(r){r(new CustomEvent("resize",{bubbles:!1,cancelable:!1,detail:{borderBox:{w:s.inlineSize,h:s.blockSize},contentBox:{w:t.inlineSize,h:t.blockSize}}}),e.target)}}}));var Jt;!function(t){t.Child="child",t.Tree="tree",t.Attr="attr",t.Char="char"}(Jt||(Jt={}));const te=new WeakMap,ee=new MutationObserver((t=>{for(let e=0;e<t.length;e++){const s=t[e];let r=te.get(s.target);if(!r)return;let n={target:s.target},i=null;switch(s.type){case"subtree":n.type=Jt.Tree,i=r[Jt.Tree];break;case"childList":n.type=Jt.Child,n.addedNodes=s.addedNodes,n.removedNodes=s.removedNodes,i=r[Jt.Child];break;case"attributes":n.type=Jt.Attr,n.attributeName=s.attributeName,n.oldValue=s.oldValue,i=r[Jt.Attr];break;case"characterData":n.type=Jt.Char,n.oldValue=s.oldValue,i=r[Jt.Char]}if(i){i(new CustomEvent("mutate",{bubbles:!1,cancelable:!1,detail:n}),s.target)}}}));function se(t,e,s,r){if("resize"===t)!function(t,e){qt.has(t)||(qt.set(t,e),Zt.observe(t))}(e,s);else if("outside"===t){if("mousedown"===r[0])!function(t,e){Yt.push([t,e])}(e,s)}else"mutate"===t&&function(t,e,s){let r=G(s,"child"),n=G(s,"attr"),i=G(s,"char"),o=G(s,"tree"),a=te.get(t);a||(a={},te.set(t,a),r&&(a[Jt.Child]=e),n&&(a[Jt.Attr]=e),i&&(a[Jt.Char]=e),o&&(a[Jt.Tree]=e),ee.observe(t,{childList:r,attributes:n,characterData:i,subtree:o}))}(e,s,r)}document.addEventListener("mousedown",(t=>{let e=t.target;Yt.forEach((([s,r])=>{if(!s.contains(e)){r(new CustomEvent("outside",{bubbles:!1,cancelable:!1,detail:{currentTarget:s,event:t}}),s)}}))}),!1);const re=/,|^(debounce:.+)|(debounce$)/,ne=/,|^(throttle:.+)|(throttle$)/,ie="self",oe="stop",ae="prevent",le="once",ce="left",de="right",he="middle",ue="ctrl",pe="alt",fe="shift",ge="meta",me={esc:"escape"},_e=":";function Ee(t,e,s,r){let n,i=t.split("."),o=i.shift(),a=i.includes(le),l=e;if(n=q(i,(t=>re.test(t)))){let t=n.split(_e);l=R(l,parseInt(t[1])||100)}if(n=q(i,(t=>ne.test(t)))){let t=n.split(_e);l=Y(l,parseInt(t[1])||100)}if(a&&(l=D(l)),function(t){return Gt.includes(t)}(o))return se(o,s,l,i),l;let c=t=>{if(i.includes(ae)&&t.preventDefault(),i.includes(oe)&&t.stopPropagation(),!i.includes(ie)||t.target===t.currentTarget){if(t instanceof MouseEvent){if(i.includes(ce)&&0!=t.button)return;if(i.includes(de)&&2!=t.button)return;if(i.includes(he)&&1!=t.button)return}else if(t instanceof KeyboardEvent){if(X(i,(t=>t==ue))[0]&&!t.ctrlKey)return;if(X(i,(t=>t==pe))[0]&&!t.altKey)return;if(X(i,(t=>t==fe))[0]&&!t.shiftKey)return;if(X(i,(t=>t==ge))[0]&&!t.metaKey)return;if(!Z(i,(t=>me[t]||t)).includes(t.key.toLowerCase()))return}l(t,s)}};s.addEventListener(o,c);let d=r.__events[o];return d||(d=r.__events[o]=[]),d.push([s,c]),c}const be="@",ve=".",Ce="?",ye="*",Se=":",Ne="ref",Te=/[.?-a-z]+\s*=\s*(['"])\s*([^='"]*<\!--c_ui-pl_df-->){2,}.*?\1/ims,Pe=/<\s*[a-z0-9-]+([^>]*<\!--c_ui-pl_df-->)*[^>]*?(?<!-)>/gims,xe="slot-props";function we(t,s){let r="",n=a(s.vars),i=s.strings.length-1,o=s.vars.length-1;for(let n=0;n<=i;n++){const i=s.strings[n];let a=e(s.vars,n,"");if(a&&a.di){let e=a.render(t);if(e instanceof je){let[s,r]=we(t,e);Reflect.defineProperty(a,"_renderVars",{value:r}),a=Ae+s+Me}else a=e??Re}else if(a instanceof je){let[e,s]=we(t,a);Reflect.defineProperty(a,"_renderVars",{value:s}),a=Oe+e+ke}else a=n>o?"":Re;r+=i+a}let l=r.match(Te);if(l){return ut(`Parse error: attribute value can be set only one interpolation —— \n ${J(l[0],Re,"${...}")}`),["",n]}let c=0;return r=r.replace(Pe,((t,e)=>J(t,Re,(()=>Re.replace("--\x3e","")+c++)))),r=r.replace($e,"$1><").trim(),[r,n]}const Ae="\x3c!--c_ui-pl_di-start--\x3e",Me="\x3c!--c_ui-pl_di-end--\x3e",Oe="\x3c!--c_ui-pl_tmpl-start--\x3e",ke="\x3c!--c_ui-pl_tmpl-end--\x3e",Re="\x3c!--c_ui-pl_df--\x3e",Le="\x3c!--c_ui-pl_df",De=/<!--c_ui-pl_df\d*(-->)?/;function Ve(t,s,r,i,a){const l=document.createElement("div");l.innerHTML=s;const c=document.createNodeIterator(l,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT);let d,h,_=0,E=null,b=[],v=[],C=[],y=[t],N=[],P=[];for(;d=c.nextNode();)if(d instanceof HTMLElement||d instanceof SVGElement){d instanceof jt?E=d:E?.contains(d)||(E=null);let e={},s=p(d.attributes);for(let n=0;n<s.length;n++){const a=s[n];let{name:l,value:c}=a;if(l===xe){let t=d.getAttribute("name")||"default";if(E){let e=E._slotsPropMap[t];e||(e=E._slotsPropMap[t]=[]),e.push(d)}}if(g(l,Le)){let e=r[_];if(e instanceof Qt){e.checkScope(Bt.TAG);let s=new Kt(d,l.substring(1),Bt.TAG);e.point=s,e.di.slotComponent=E,e.di.renderComponent=i;let r=new Ft(_,d);r.isDirective=!0,r.value=e,r.isComponent=!!E,t.push(r),_++,e.di.created(s,...e.args)}d.removeAttribute(l)}else if(l[0]!==be)if(l!==Ne)if(l[0]!==ve||De.test(c)){if(De.test(c)){let s=r[_],n=new Ft(_,d,l.replace(/\.|\?|@/,""),c);if(t.push(n),n.isComponent=!!E,l[0]===ve||l[0]===Ce||l[0]===ye){if(s instanceof Qt){s.checkScope(Bt.PROP);let t=new Kt(d,l.substring(1),Bt.PROP);s.point=t,s.slotComponent=E,n.value=s,n.isDirective=!0,s&&s.di.created(s.point,...s.args)}else if(l[0]===Ce)n.isToggleProp=!0,n.value=!!s,n.value&&d.setAttribute(l.substring(1),"");else if(l[0]===ye){n.value=s;let t=l.substring(1);const[e,r]=t.split(Se);let i=e;switch(r){case"camel":i=S(i);break;case"kebab":i=u(i);break;case"snake":i=tt(i)}n.attrName=i,d.setAttribute(i,s)}else if(d instanceof jt||"SLOT"===d.tagName){let t=S(l.substring(1));t in d||"SLOT"===d.tagName||pt(d.tagName,`Prop '${l}' is not defined in ${d.tagName}`),n.value=s,n.isProp=!0,e[t]=s}else pt(d.tagName,`Prop '${l}' can only be set on a CompElem or a slot`);d.removeAttribute(l),s=""}else{let t;if(n.value=s,s instanceof Qt){let e=Bt.ATTR;"class"===l?e=Bt.CLASS:"style"===l&&(e=Bt.STYLE),s.checkScope(e),n.isDirective=!0;let r=new Kt(d,l,e);s.point=r,s.di.slotComponent=E,s.di.renderComponent=i,t=s,s=""}c=T(c,De,s),a.value=c,t&&t.di.created(t.point,...t.args)}_++}}else pt(d.tagName,`Prop '${l}' must be an interpolation`);else{if(De.test(c)){let t=r[_];if(!o(t,"current")){pt(d.tagName,"Ref must be a RefObject");continue}_++,t.current=d}d.removeAttribute(l)}else{let e=t=>{};if(De.test(c)){let s=r[_];if(!m(s)){pt(d.tagName,`Event '${l}' must be a function`);continue}e=s.bind(i);let n=new Ft(_,d,l.replace(/\.|\?|@/,""),c);n.isComponent=!!E,n.isEvent=!0,t.push(n),_++}Ee(l.substring(1),e,d,i),d.removeAttribute(l)}}d instanceof jt?d._initProps(e):d instanceof HTMLSlotElement&&i._bindSlot(d,d.name||"default",e)}else{let s=d,o=`\x3c!--${s.nodeValue}--\x3e`;if(o===Ae){h&&b.push(h),h=s;let e=r[_],n=new Ft(_,d);n.isComponent=!!E,n.isDirective=!0,n.value=e;let o=E?Bt.SLOT:Bt.TEXT,a=new Kt(h,"",o);e.point=a,e.di.slotComponent=E,e.di.renderComponent=i,v.push(e),t.push(n),C.push(n),t=[],y.push(t),_++,P.push(_),N.push(r),r=e._renderVars,_=0;continue}if(o===Me){C.pop().textNode=s;let e=v.pop();e.point.endNode=s,e.di.created(e.point,...e.args),h=b.pop(),e.di.__updatePoints=t,y.pop(),t=f(y),r=N.pop(),_=P.pop()}else{if(o===Oe){h&&b.push(h),h=s;let n=r[_],o=new Ft(_,d);o.isComponent=!!E,o.isTmpl=!0;let l=f(v);(l&&"ForEach"===e(l,"diClass.name")||"ForEach"==a.constructor.name)&&(o.key=n.getKey()),n=o.value=new Ht(n);let c=E?Bt.SLOT:Bt.TEXT,u=new Kt(h,"",c);n.point=u,n.slotComponent=E,n.renderComponent=i,v.push(n),t.push(o),C.push(o),t=[],y.push(t),_++,P.push(_),N.push(r),r=n._renderVars,_=0;continue}if(o===ke){C.pop().textNode=s;let e=v.pop();e.point.endNode=s,h=b.pop(),e.__updatePoints=t,y.pop(),t=f(y),r=N.pop(),_=P.pop()}}if(o!==Re)continue;let l=new Ft(_,d);t.push(l),l.isComponent=!!E,l.isText=!0;let c,u=r[_];if(c=document.createComment(`compelem-ui-${_}-child-start`),s.parentNode.insertBefore(c,s),s.nodeValue=`compelem-ui-${_}-child-end`,l.textNode=c,u instanceof Qt){l.isDirective=!0,l.value=u;let t=E?Bt.SLOT:Bt.TEXT,e=new Kt(c,"",t);e.endNode=s,u.point=e,u.di.slotComponent=E,u.di.renderComponent=i,u.di.created(e,...u.args),u=""}else if(u instanceof je){l.isTmpl=!0,l.value=u;let[e,s]=we(i,u);u=Ve(t,e,s,i,a)}else l.value=u;if(_++,n(u))continue;if(u instanceof NodeList){let t=document.createDocumentFragment();t.append(...u),s.parentNode.insertBefore(t,s)}else if(u instanceof Element)s.parentNode.insertBefore(u,s);else if(I(u)){let t=document.createTextNode(u);s.parentNode.insertBefore(t,s)}}return l.childNodes}const He={insertBefore:function(t,e){if(!t.parentNode)return;let s=document.createDocumentFragment();s.append(...e),t.parentNode.insertBefore(s,t)},remove:function(t,e){if(t===e)return void t?.parentNode?.removeChild(t);let s=t.nextSibling;for(;s&&s!==e;)s?.parentNode?.removeChild(s),s=t.nextSibling}};function Ie(t,...e){return new je(w(t)?[t]:t,e)}const $e=/([a-z0-9"'])\s*>\s*</gim;function We(t){return{current:t}}class je{strings;vars;constructor(t,e){this.strings=a(t),this.vars=e}getKey(){let t=this.vars,e="";return h(this.strings,((s,r)=>{if(lt.test(s))return e=et(t[r]),!1})),e}getKeys(){let t=this.vars,e=[];for(let s=0;s<this.strings.length;s++){const r=this.strings[s];if(lt.test(r)){let r=et(t[s]);e.push(r)}}return i(e)&&t.forEach((t=>{if(t instanceof je){let s=t.getKey();e.push(s)}})),e}append(t){let e=f(this.strings);return t.strings.forEach(((t,s)=>{0!=s?this.strings.push(t):this.strings[this.strings.length-1]=e+t})),this.vars=a(this.vars,t.vars),this}insert(t,e){let s=e.strings.shift();return this.strings[t]+=s,this.strings.splice(t+1,0,...e.strings),this.vars.splice(t,0,...e.vars),this}getHTML(t){let[e,s]=we(t,this),r=Ve([],e,s,t,t);return st(r,((t,e)=>t+e.outerHTML),"")}}function Ue(t,e,s){s.get||ut(`Computed '${e}' must be a getter`),o(t.constructor,dt.COMPUTED)||(t.constructor[dt.COMPUTED]=i(t.constructor[dt.COMPUTED])?{}:d(t.constructor[dt.COMPUTED])),t.constructor[dt.COMPUTED][e]=s.get}function Be(t,e){return(s,r,n)=>{o(s.constructor,dt.EVENTS)||(s.constructor[dt.EVENTS]=i(s.constructor[dt.EVENTS])?[]:d(s.constructor[dt.EVENTS])),s.constructor[dt.EVENTS].push({name:t,options:e,fn:s[r]})}}var ze;!function(t){t.ONCE="once",t.UPDATABLE="updatable"}(ze||(ze={}));class Fe extends mt{static get priority(){return Number.MAX_VALUE}created(t,e,s,...r){}mounted(t,e,...s){}get targets(){return[ht.FIELD]}selector;cache;result;constructor(t,e){super(),this.selector=t,this.cache=e}static getKey(t){return t}getter(t){this.result=t.shadowRoot?.querySelector(this.selector)}beforeMount(t,e,s,r,...n){const i=this;Reflect.defineProperty(t,r,{get:()=>(i.result&&i.cache||i.getter(t),i.result)})}updated(t,e){this.cache===ze.UPDATABLE&&this.getter(t)}}const Ke=yt(Fe),Qe=yt(class extends Fe{getter(t){this.result=t.shadowRoot?.querySelectorAll(this.selector)}});function Xe(t){if(1===arguments.length)return(e,s)=>{Ge(e,s,t)};Ge(arguments[0],arguments[1],{prop:""})}function Ge(t,e,s){if(!o(t.constructor,dt.STATES)){const e={};let s=t.constructor;for(;(s=gt(s))!==jt;)c(e,s[dt.STATES]?d(s[dt.STATES]):{});Reflect.defineProperty(t.constructor,dt.STATES,{configurable:!1,enumerable:!1,value:e})}t.constructor[dt.STATES][e]=s}function qe(t,e,s){Ge(t.prototype,e,s||{prop:""})}function Ye(t){return e=>{if(e){if(e.prototype.hasOwnProperty("attributeChangedCallback")){let t=e.prototype.attributeChangedCallback;e.prototype.attributeChangedCallback=function(e,s,r){jt.prototype.attributeChangedCallback.call(this,e,s,r),t.call(this,e,s,r)}}if(e.prototype.hasOwnProperty("connectedCallback")){let t=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){jt.prototype.connectedCallback.call(this),t.call(this)}}if(e.prototype.hasOwnProperty("disconnectedCallback")){let t=e.prototype.connectedCallback;e.prototype.disconnectedCallback=function(){jt.prototype.disconnectedCallback.call(this),t.call(this)}}customElements.define(t,e)}}}function Ze(t,e){return(s,r)=>{o(s.constructor,dt.WATCH)||(s.constructor[dt.WATCH]=i(s.constructor[dt.WATCH])?{}:d(s.constructor[dt.WATCH]));(_(t)?t:[t]).forEach((t=>{let n=t.replaceAll(".","-"),i=s.constructor[dt.WATCH][n];_(i)||(i=s.constructor[dt.WATCH][n]=[]),i.push({source:t,options:e,handler:s[r]})}))}}class Je extends(Vt(Object)){_renderArgs;static get scopes(){return[]}renderParams}const ts=["key"];const es=Xt(class extends Je{created(t,e){let s=t.startNode;if(s instanceof jt){let t={},r={};h(e,((e,n)=>{ts.includes(n)||(n in s?t[n]=e:r[n]=e+"")})),s._initProps(t,r)}else h(e,((t,e)=>{s.setAttribute(e,t)}))}update(t,e,s){return Ut.NONE}static get scopes(){return[Bt.TAG]}render(t){}});const ss=Xt(class extends Je{created(t,e){let r=[];_(e)?r=Q(e):s(e)?r=x(e,((t,e)=>t?e:[])):w(e)&&(r=e.split(" "));let n=t.startNode;h(this.lastCls,(t=>{n.classList.remove(t)})),h(r,(t=>{n.classList.add(t)})),this.lastCls=a(r)}update(t,e,s){return this.created(t,e[0]),Ut.NONE}static get scopes(){return[Bt.CLASS]}lastCls;render(t){}});const rs=Xt(class extends Je{created(t,...e){}update(t,e,s){if(i(t.getNodes())&&(!e||i(e[0])))return Ut.NONE;if(rt(this.lastAry,e[0])&&this.lastAry.length===e[0].length)return Ut.NONE;if(!i(this.renderParams)){let t=f(this.renderParams);_(t)||(t=[t]),this.renderParams=t}return this.lastAry=nt(e[0]),Ut.UPDATE}constructor(t){super(),i(this.renderParams)||(this.renderParams=p(f(this.renderParams)))}static get scopes(){return[Bt.TEXT,Bt.SLOT]}lastAry;lastRenderTmpl;render(t,e){let s=Z(t,((t,s)=>e(t,s)));if(s.length<1)return this.lastRenderTmpl=new je([],[]),this.lastRenderTmpl;let r=[],n=[];const i=[],o=[];for(let t=0;t<s.length;t++){const e=s[t];let a=f(n),l=e.vars,c=!0,d=e.strings;for(let t=0;t<d.length;t++){const e=d[t];if(lt.test(e)){let e=l[t]+"";if(r.includes(e))return void ut(`forEach - duplicate key '${e}'`);r.push(e),c=!1}0==t&&a?n[n.length-1]=a+e:n.push(e)}if(c)return void ut("forEach - missing 'key' prop");let h=f(i);h&&d.length>0&&(i[i.length-1]=I(h)+d.shift()),i.push(""),o.push(e)}return this.lastAry=nt(t),i.push(""),this.lastRenderTmpl=new je(i,o),this.lastRenderTmpl}});const ns=Xt(class extends Je{created(t,...e){}ifNodes;elseNodes;static get scopes(){return[Bt.TEXT,Bt.SLOT]}update(t,e,s){return!!e[0]==!!s[0]?Ut.NONE:(e[0],Ut.REPLACE)}render(t,e,s){return t?e(t):s(t)}});const is=Xt(class extends Je{created(t,...e){}static get scopes(){return[Bt.TEXT,Bt.SLOT]}update(t,e,s){return e[0]===s[0]?Ut.NONE:e[0]?Ut.REPLACE:Ut.REMOVE}render(t,e){return t?e():Ie``}});var os;!function(t){t.CHANGE="change",t.INPUT="input"}(os||(os={}));const as=Xt(class extends Je{created(r,n,i){this.modelPath||(this.modelPath=f(this.renderParams)),i&&(this.modelPath=t(i));const o=r.startNode;if("binded"!==e(o,"_model"))if(s(n)||I(n)||(n=""),o instanceof jt)o._initProps({value:n}),o.addEventListener("update:value",(t=>{y(this.renderComponent,this.modelPath,t.detail.value)})),y(o,"_model","binded");else if(o instanceof HTMLTextAreaElement)o.setAttribute("value",n+""),o.addEventListener("input",(t=>{let e=t.target;y(this.renderComponent,this.modelPath,e.value)})),y(o,"_model","binded");else if(o instanceof HTMLInputElement){let t="",e="";switch(o.type){case"checkbox":case"radio":t="checked",e="change";break;default:t="value",e="input"}o.setAttribute(t,n+""),o.addEventListener(e,(t=>{let e=t.target;y(this.renderComponent,this.modelPath,e.value)})),y(o,"_model","binded")}else o instanceof HTMLSelectElement&&(o.setAttribute("value",n+""),o.addEventListener("change",(t=>{let e=t.target;y(this.renderComponent,this.modelPath,e.value)})),y(o,"_model","binded"))}update(t,e,s){if(this.modelPath||(this.modelPath=f(this.renderParams)),!N(e,s)){const s=t.startNode;if(s instanceof jt)s._updateProps({value:e[0]});else if(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)s.setAttribute("value",e[0]+"");else if(s instanceof HTMLInputElement)switch(s.type){case"checkbox":case"radio":e[0]?s.setAttribute("checked",""):s.removeAttribute("checked");break;default:s.setAttribute("value",e[0]+"")}}return Ut.NONE}static get scopes(){return[Bt.TAG]}modelPath;render(t,e){}});const ls=Xt(class extends Je{created(t,e){let s=t.startNode;n(this.display)&&(this.display=s.style.display),this.renderComponent.nextTick((()=>{s.style.display=e?this.display:"none"}))}update(t,e,s){return this.created(t,e[0]),Ut.NONE}display=void 0;static get scopes(){return[Bt.TAG]}constructor(t){super(),this.point=t}render(t){}});const cs=Xt(class extends Je{created(t,e,s){e=e.bind(this.renderComponent),this.slotComponent._bindSlotHook(s||"default",e)}update(t,e,s){return Ut.NONE}static get scopes(){return[Bt.SLOT]}render(t,e){}});class ds{static getCssText(t){return w(t)?t:v(Z(t,((t,e)=>u(e)+":"+t)),";")}static setStyle(t,e){if(w(t)&&!I(t))return{};let s=ds.getCssText(t),r={};return h(s.split(";"),(t=>{let s=t.split(":"),n=I(s[0]),i=I(s[1]);r[n]=e.style.getPropertyValue(n),e.style.setProperty(n,i)})),r}}const hs=Xt(class extends Je{created(t,e){ds.setStyle(e,t.startNode)}update(t,e,s){return this.created(t,e[0]),Ut.NONE}constructor(t){super(),this.point=t}static get scopes(){return[Bt.STYLE]}render(t){}});const us=Xt(class extends Je{created(t,e){this.modelPath||(this.modelPath=f(this.renderParams));const s=t.startNode;let r=t.attrName;s._initProps({[r]:e}),s.addEventListener("update:"+r,(t=>{y(this.renderComponent,this.modelPath,t.detail.value)}))}update(t,e,s){if(!N(e,s)){const s=t.startNode;let r=t.attrName;s._updateProps({[r]:e[0]})}return Ut.NONE}static get scopes(){return[Bt.PROP]}modelPath;constructor(t){super()}render(t){}});const ps=Xt(class extends Je{created(t,...e){}static get scopes(){return[Bt.TEXT,Bt.SLOT]}update(t,e,s){return N(e,s)?Ut.NONE:Ut.REPLACE}render(t,e){let s=()=>Ie``,r=[],n=[];h(e,((t,e)=>{if(m(t))r.push(e),n.push(t);else{let e=t[0],s=t[1];r.push(e),n.push(s)}"default"===e&&(s=t)}));let i=it(r,(e=>m(e)?e(t):e==t));return ot(n[i]??s)}});export{jt as CompElem,ds as CssHelper,mt as Decorator,ht as DecoratorType,vt as DecoratorWrapper,Je as Directive,Ut as DirectiveUpdateTag,Qt as DirectiveWrapper,Kt as EnterPoint,Bt as EnterPointType,_t as GetKeyFnName,os as ModelTriggerType,ze as QueryCache,je as Template,Ft as UpdatePoint,bt as _DecoratorMap,Et as _DecoratorsKey,xt as _getObservedAttrs,es as bind,we as buildHTML,ss as classes,Ue as computed,We as createRef,yt as decorator,Xt as directive,Be as event,rs as forEach,Ie as html,ns as ifElse,is as ifTrue,qe as makeState,as as model,Nt as prop,Ke as query,Qe as queryAll,ls as show,cs as slot,Xe as state,hs as styles,us as sync,Ye as tag,Ze as watch,ps as when};
7
+ import{toPath as t,get as e,isObject as s,isDefined as r,isUndefined as n,isEmpty as i,has as o,concat as a,defaults as l,merge as c,cloneDeep as d,each as h,kebabCase as u,toArray as p,last as f,startsWith as g,isFunction as m,isArray as _,initial as E,isBlank as b,join as v,split as C,set as y,camelCase as S,isEqual as N,replace as T,isPlainObject as P,flatMap as x,isString as w,test as A,size as M,assign as O,first as k,debounce as R,closest as L,once as D,bind as V,isNil as H,trim as I,some as $,isNull as W,fval as j,omit as U,groupBy as B,reject as z,filter as F,slice as K,compact as Q,remove as X,includes as G,find as q,throttle as Y,map as Z,replaceAll as J,snakeCase as tt,toString as et,reduce as st,isMatch as rt,clone as nt,findIndex as it,call as ot}from"myfx";const at=new WeakMap,lt=/\s+\.?key\s*=/;var ct,dt,ht;function ut(t){console.error("[CompElem]",t)}function pt(t,e){console.error(`[CompElem <${t}>]`,e)}function ft(e){return t(e).join("-")}function gt(t){return Object.getPrototypeOf(t)}!function(t){t[t.CSS=1]="CSS",t[t.COMPUTED=2]="COMPUTED"}(ct||(ct={})),function(t){t.PROPS="__deco_props",t.STATES="__deco_states",t.COMPUTED="__deco_computed",t.WATCH="__deco_watch",t.EVENTS="__deco_events"}(dt||(dt={})),function(t){t.CLASS="class",t.FIELD="field",t.METHOD="method"}(ht||(ht={}));class mt{static get priority(){return 0}}const _t="getKey",Et="__decorators",bt=new WeakMap;class vt{args;metadata;decoratorClass;instanceMap;key;priority=0;constructor(t,s,r){this.args=t,this.metadata=s,this.decoratorClass=r,this.priority=e(r,"priority",0),this.instanceMap=new WeakMap}create(t){let o,a=new this.decoratorClass(...this.args),l=a.targets,c=this.metadata[2];s(c)&&r(e(c,"configurable"))?o=ht.METHOD:n(this.metadata[2])&&(o=ht.FIELD),!i(l)&&o&&l.includes(o)?(a.created(t,...this.metadata),this.instanceMap.set(t,a)):ut(`Decorator '${this.decoratorClass.name}' is out of targets, expect '${l.join(",")}' bug got '${o}'`)}beforeMount(t,e){this.instanceMap.get(t).beforeMount(t,e,...this.metadata)}mounted(t,e){this.instanceMap.get(t).mounted(t,e,...this.metadata)}updated(t,e){this.instanceMap.get(t).updated(t,e)}}const Ct=new WeakMap;function yt(t){let s=(...s)=>(...r)=>{let n=r[0].constructor,i=e(n,Et);if(!o(n,Et)){let t=e(Object.getPrototypeOf(n),Et);i=t?a(t):[],Reflect.defineProperty(n,Et,{configurable:!1,enumerable:!1,value:i})}let l,c={},d=e(t,_t);if(d){let e=Ct.get(t);if(e||(e=new WeakMap,Ct.set(t,e)),c=e.get(n),c||(c={},e.set(n,c)),l=d(...s),c[l])return c[l]}let h=new vt(s,r,t);return c[l]=h,i?.push(h),h};return bt.set(s,!0),s}const St=new WeakMap;function Nt(t){if(1===arguments.length)return(e,s,r)=>{t.required=t.required||!1,t.attribute=!1!==t.attribute,Tt(e,s,t,r)};let e=arguments[0],s=arguments[1],r=arguments[2];t={type:void 0,required:!1,attribute:!0},r&&"function"==typeof r.type&&(t=l(r,t),r=void 0),Tt(e,s,t,r)}function Tt(t,e,s,r){let n;if(/[a-z]/.test(e[0])||ut(`Prop '${e}' must be in CamelCase`),!o(t.constructor,dt.PROPS)){const e={};let s=t.constructor;for(;(s=gt(s))!==jt;)c(e,s[dt.PROPS]?d(s[dt.PROPS]):{});Reflect.defineProperty(t.constructor,dt.PROPS,{configurable:!1,enumerable:!1,value:e}),n=new Set,h(e,((t,e)=>{if(t.attribute){let t=u(e);n?.add(t)}})),St.set(t.constructor,n)}if(r&&(r.get&&(s.getter=r.get),r.set&&(s.setter=r.set)),s.attribute){n||(n=St.get(t.constructor));let s=u(e);n?.add(s)}o(t.constructor,"observedAttributes")||(t.constructor.observedAttributes=[]),t.constructor.observedAttributes=p(n),t.constructor[dt.PROPS][e]=s}const Pt=new Set;function xt(t){return St.get(t)??Pt}const wt={collectWatch(t,e,s){let r=Rt.get(t);r||(r={},Rt.set(t,r));let n=r[s];n||(n=r[s]=[]),n.push(e)},startCollect(t,e){this.__collectType=e,this.__collecting=t},setUpdater(t){this.__updater=t},endCollect(){this.__collecting=null},__directiveQ:[],setDirectiveQ(t){let e=f(this.__directiveQ);const s=t?t.join(","):"",r=e?e.join(","):"";e&&s===r||(e&&e.length<t.length&&g(s,r)?this.__directiveQ[this.__directiveQ.length-1]=t:this.__directiveQ.push(t))},popDirectiveQ(){let t=a(this.__directiveQ);return this.__directiveQ=[],t},startRender(t){this.__renderCollecting=!0,this.__renderContext=t},endRender(t){this.__renderCollection.forEach((e=>{t._regDeps(e,this.__renderContext)})),this.__renderCollection.clear(),this.__renderCollecting=!1,this.__renderContext=null},collect(t){this.__renderCollection.add(t)},clear(){this.__directiveQ=[]},__updater:null,__collecting:null,__collectType:-1,__renderCollection:new Set,__renderContext:null,__renderCollecting:!1,__skipCheck:!1},At=new WeakMap,Mt=new WeakMap,Ot=new WeakMap,kt=new WeakMap,Rt=new WeakMap;function Lt(t,r){if(!s(t))return t;const n=t.__proxy?t:new Proxy(t,{get(t,e,s){if(!e)return;const r=Reflect.get(t,e,s);if("string"!=typeof e&&"number"!=typeof e)return r;let n=e in t;if((wt.__renderCollecting||wt.__collecting)&&(n&&t.hasOwnProperty(e)||!n)){let t=Mt.get(s)??[],r=a(t,[e]),n=r.join("-");if(wt.__renderCollecting)wt.collect(ft(r)),wt.setDirectiveQ(r);else if(wt.__collecting){let t;switch(wt.__collectType){case ct.COMPUTED:t=Ot.get(wt.__collecting),t||(t={},Ot.set(wt.__collecting,t));break;case ct.CSS:t=kt.get(wt.__collecting),t||(t={},kt.set(wt.__collecting,t))}let e=t[n];e||(e=t[n]=[]),e.push(wt.__updater)}}return r},set(t,r,n,o){if(!r)return!1;let l=t[r];if(!s(l)&&l===n)return!0;if(Number.isNaN(n)&&Number.isNaN(l))return!0;let c=Mt.get(o)??[],d=a(c,[r]),h=At.get(o).from,u=e(h.constructor,dt.PROPS),p=e(h.constructor,dt.STATES),f=e(u,[d[0],"hasChanged"])||e(p,[d[0],"hasChanged"]);if(f){if(!f.call(h,n,l))return!0}else if(l===n&&!at.has(l))return!0;u&&u[r]&&t.__isData&&u[r].sync&&h.emit("update:"+r,{value:n});let g=At.get(o)?.contextSet,E=n;!s(n)||m(n)||n instanceof Node||Object.isFrozen(n)||g.forEach((t=>{let e=At.get(o)?.pathMap,s=e?.get(t);s&&(d=a(s,[r]),Mt.set(E,d),E=Lt(E,t),Mt.set(E,d))}));let b=Reflect.set(t,r,E),v=At.get(o).pathMap;return g.forEach((t=>{let s=v.get(t);if(!s)return;t===h&&c.length>1&&s.length>1&&c[0]===s[0]&&(s=c),d=a(s,"length"==r&&_(o)?[]:[r]);let n=Ot.get(t),u=kt.get(t),p=Rt.get(t);if(n||u||p){let t=d.length;for(;t;){let s=d.slice(0,t).join("-");if(p){const r=p[s];t===d.length?r?.forEach((t=>{let e=t();e.ov=l,Dt.pushWatch(e)})):r?.forEach((t=>{let s=t();e(s,"deep")&&(s.ov=l,Dt.pushWatch(s))}))}if(n){let t=n[s];if(!i(t))for(let e=0;e<t.length;e++){const s=t[e];Dt.pushComputed(s)}}if(u){let t=u[s];if(!i(t))for(let e=0;e<t.length;e++){const s=t[e];Dt.pushCss(s)}}t--}}let f=t._notify(l,d);Dt.pushNext(f)})),b}});t.__proxy||Reflect.defineProperty(t,"__proxy",{enumerable:!1,writable:!1,configurable:!1,value:!0});let o=Mt.get(t)??[];if(Object.isExtensible(t)&&!At.get(n)){let t=new Set;t.add(r);let e=new WeakMap;e.set(r,o),At.set(n,{from:r,contextSet:t,pathMap:e})}else{At.get(n).contextSet.add(r);let t=At.get(n).pathMap,s=t.get(r),i=a(o);if(s&&s.join("")!==i.join("")){let t=e(r,E(s));_(t)||function(...t){console.warn("[CompElem]",...t)}(`The object is referenced by more than one @state '${i.join(".")},${s.join(".")}'`),s=i}else t.set(r,i)}for(let e in t){const n=t[e];!s(n)||n.__proxy||m(n)||n instanceof Node||Object.isFrozen(n)||(Mt.set(n,a(o,[e])),t[e]=Lt(n,r),Mt.set(t[e],a(o,[e])))}return n}class Dt{static watchSet=new Set;static computedSet=new Set;static cssSet=new Set;static nextSet=new Set;static nextPending=!1;static next;static{const t=Promise.resolve(),e=Dt.flush;Dt.next=()=>{t.then(e)}}static flush(){Dt.nextPending=!1;let t=Array.from(Dt.watchSet);Dt.watchSet.clear();let s=Array.from(Dt.computedSet);Dt.computedSet.clear();let r=Array.from(Dt.cssSet);Dt.cssSet.clear();let n=Array.from(Dt.nextSet);Dt.nextSet.clear(),t.forEach((t=>t(e(t,"ov")))),s.forEach((t=>t())),r.forEach((t=>t())),n.forEach((t=>t()))}static pushWatch(t){Dt.watchSet.add(t)}static pushComputed(t){Dt.computedSet.add(t)}static pushCss(t){Dt.cssSet.add(t)}static pushNext(t){Dt.nextSet.add(t),Dt.nextPending||(Dt.nextPending=!0,Dt.next())}}function Vt(t){return class extends t{__updatePoints;renderComponent;buildView(t){let e=this instanceof jt?this:this.renderComponent,[s,r]=we(e,t),n=[],i=Ve(n,s,r,e,this);return this.__updatePoints=n,i}updateView(t){if(b(v(t.strings)))return;if(!this.__updatePoints)return;let{vars:r}=t,n=this instanceof jt?this:this.renderComponent;for(let t=0;t<this.__updatePoints.length;t++){const i=this.__updatePoints[t];let o=i.varIndex,a=i.value,l=r,c=i.node,d=C(o,"-");for(let s=0;s<d.length;s++){const r=d[s];l=e(l,r),l&&l.vars&&t<d.length-1&&(l=l.vars)}if(!s(a)&&a===l)continue;let h=c;if(i.isDirective){if(!a.di)continue;l.di=a.di,l.di.renderParams=l.varChain,l.di._renderArgs=l.args,l.point=a.point,l.varPath=a.varPath,a.update(a.point,l.args,a.args)}else if(i.isToggleProp){if(!!l===a)continue;h.toggleAttribute(i.attrName,!!l),y(h,i.attrName,!!l)}else if(i.isProp){if(!s(l)&&l===a)continue;let t=S(i.attrName),r=e(i.node.constructor,dt.PROPS);if(r){let e=r[t];if(e&&e.hasChanged&&!e.hasChanged.call(this,l,a))continue}c instanceof jt?c._updateProps({[i.attrName]:l}):c instanceof HTMLSlotElement&&n._updateSlot(c.getAttribute("name")||"default",i.attrName,l)}else if(i.attrName&&!i.isEvent){if(!N(a,l))switch(i.attrName){case"value":if(c instanceof HTMLInputElement){c.value=l;break}default:c.setAttribute(i.attrName,T(i.attrTmpl,De,l+""))}}else if(i.isTmpl)(l.strings.join()!==a.tmpl.strings.join()||l.vars.some((t=>s(t)&&!P(t)))||a.tmpl.vars.some((t=>s(t)&&!P(t)))||!N(l.vars,a.tmpl.vars))&&i.value.updateView(l),a.tmpl=l,l=a;else if(i.isText){let t=i.textNode.nextSibling;t&&t===i.node.previousSibling?t.textContent=l:(He.remove(i.textNode,i.node),He.insertBefore(i.node,[l]))}i.value=l}}}}class Ht extends(Vt(Object)){tmpl;constructor(t){super(),this._renderVars=e(t,"_renderVars"),this.tmpl=t}}const It={boolean:Boolean,string:String,number:Number,object:Object,array:Array,function:Function,bigint:BigInt,symbol:Symbol,undefined:Object},$t=new WeakMap;let Wt=[];class jt extends(Vt(HTMLElement)){static __l_globalRule=document.createElement("style");static{document.head.appendChild(jt.__l_globalRule)}static defaults(t){Wt=x(t.css,(t=>{if(w(t)){let e=new CSSStyleSheet;return e.replaceSync(t),e}return t instanceof CSSStyleSheet?t:[]})),t.global,h(t,((t,e)=>{A(e[0],/[A-Z]/)}))}#t={};#e={"#slots":{}};#s={};#r={};#n;#i;#o={};__events={};get[Symbol.toStringTag](){return this.constructor.name}get reactiveData(){return this.#s}get attrs(){return this.#a}get props(){return this.#l}get renderRoot(){return this.#c}get renderRoots(){return this.#d}get parentComponent(){return this.#h}get slotHooks(){return this.#u}get css(){return $t.get(this.constructor)}get isMounted(){return this.#p}get slots(){return this.#e["#slots"]}#a;#l;#c;#d;#h;#f={};#u={};#g={};#p=!1;static get autoSlot(){return!0}static get styles(){return[]}static get globalStyles(){return[]}get styles(){return[]}#m=!1;constructor(...t){super(),1===M(t)&&(this.#l={},O(this.#l,k(t)));let s=this.render.bind(this);this.render=function(){let t;return wt.startRender(this),t=s(),wt.endRender(this),t};let r=e(this.constructor,"globalStyles"),n=e(this.constructor,"_global_style_attached");if(!i(r)&&"1"!==n){let t="";r.forEach((e=>{w(e)&&(t+=e+"\n")})),jt.__l_globalRule.textContent+=t,y(this.constructor,"_global_style_attached","1")}let o=$t.get(this.constructor),a=o??[];o||(h(e(this.constructor,"styles"),(t=>{if(w(t)){let e=new CSSStyleSheet;e.replaceSync(t),a.push(e)}else a.push(t)})),$t.set(this.constructor,a)),this.#n=this.attachShadow({mode:"open",slotAssignment:e(this.constructor,"autoSlot",!0)?"named":"manual"}),this.#n.adoptedStyleSheets=[...Wt,...a];let l=this.attributes.getNamedItem("css-link")?.value;if(l){const t=document.createElement("style");t.textContent=`@import "${l}"`,this.#n.appendChild(t)}let c=R(this.#_,20);this.#i=new MutationObserver((t=>{for(let e=0;e<t.length;e++){"childList"===t[e].type&&c.call(this)}})),this._slotsPropMap={default:[]};let d=e(this.constructor,Et);d&&d.sort(((t,e)=>e.priority-t.priority)).forEach((t=>t.create(this))),this.#E=this.#b.bind(this)}#E;connectedCallback(){let t=L(this.parentNode,(t=>t instanceof jt||t.host instanceof jt),"parentNode");this.#h=t?t instanceof jt?t:t.host:null,this.__init()}disconnectedCallback(){this.#i.disconnect()}__init(){if(this.#m)return;this.#v();const t=this.#C();this.propsReady(t);for(const e in t){const s=t[e];this.#e[e]=s}this.#y(),h(this.#e,((t,e)=>{let s=Reflect.getOwnPropertyDescriptor(this.#e,e);Reflect.defineProperty(this,e,{get(){let t=Reflect.get(this.#s,e);return s?.get?s?.get():t},set(t){s?.set?s?.set(t):Reflect.set(this.#s,e,t)}})})),Reflect.defineProperty(this.#e,"__isData",{enumerable:!1,value:!0}),this.#s=Lt(this.#e,this);let s=this.render(),r=this.buildView(s);if(r){let t=p(r);t.forEach((t=>{this.#n.appendChild(t)})),this.#d=t,this.#c=t[0]}this.#_(),this.beforeMount(),this.#i.observe(this,{childList:!0});const n=this;let i=e(this.constructor,Et);i&&i.sort(((t,e)=>e.priority-t.priority)).forEach((t=>{t.beforeMount(this,((t,e)=>(n.#s[t]=e,n.#s[t])))}));let o=e(this.constructor,dt.WATCH);h(o,((t,s)=>{t.forEach((t=>{let{source:r,options:n,handler:i}=t,o=i.bind(this);e(n,"once",!1)&&(o=D(o));const a=function(t){let s=e(this,r.replaceAll("-","."));o(s,t,r)}.bind(this);let l=e(n,"deep",!1);if(a.deep=l,wt.collectWatch(this,(()=>a),s),!e(n,"immediate",!1))return;let c=e(this,r.replaceAll("-","."));o(c,c,r)}))}));let a=e(this.constructor,dt.COMPUTED);h(a,((t,e)=>{wt.startCollect(this,ct.COMPUTED),wt.setUpdater((()=>{this.#s[e]=t.call(this)})),this.#e[e]=t.call(this),wt.endCollect(),Reflect.defineProperty(this,e,{get(){return Reflect.get(this.#s,e)},set(t){pt(this.tagName,"Cannot set a computed property '"+e+"'")}})}));let l=e(this.constructor,dt.EVENTS);l&&l.forEach((t=>{let e=t.name,s=O({target:document,once:!1,passive:!1,capture:!1},t.options),r=V(t.fn,this),n=s.target;m(n)&&(n=n.call(this,this)),n?n.addEventListener(e,r,s):pt(this.tagName,"The target of @event('"+e+"',...) is invalid")})),h(this.#u,((t,e)=>{this.#S(e)})),wt.startCollect(this,ct.CSS);let c=[];this.styles.forEach((t=>{if(!m(t))return;let e=new CSSStyleSheet;c.push(e),wt.setUpdater((()=>{let s=t()??"";e.replaceSync(s)}));let s=t();b(s)||e.replaceSync(s)})),wt.endCollect(),this.#n.adoptedStyleSheets=[...this.#n.adoptedStyleSheets,...c],setTimeout((()=>{this.#p=!0,this.mounted(),i&&i.forEach((t=>{t.mounted(this,((t,e)=>(n.#s[t]=e,n.#s[t])))}))}),0),this.#m=!0}propsReady(t){}render(){throw Error(`[CompElem <${this.tagName}>] Missing render()`)}beforeMount(){}mounted(){}#N(t,s){this.#v();let r=e(this.#t[s],"props");r&&h(this.slots,((t,s)=>{t.filter((t=>t.nodeType===Node.ELEMENT_NODE)).forEach((t=>{t instanceof jt?t._updateProps(r):h(r,((s,r)=>{if(t instanceof HTMLSlotElement){let n=e(t,"__l_comp");if(n){let e=t.name||"default",i=n.#t[e];i||(i=n.#t[e]={props:{}}),i.props||(i.props={}),i.props[r]=s,n.#N(t,e)}}else t.setAttribute(r,s)}))}))})),this.slotChange(t,s)}slotChange(t,e){}attributeChangedCallback(t,e,s){this.#T(t,e,s)}shouldUpdate(t){return!0}updated(t){}emit(t,s={},r){r&&r.event&&(s.event=r.event),s.target=this,this.dispatchEvent(new CustomEvent(t,{bubbles:e(r,"bubbles",!1),composed:e(r,"composed",!1),cancelable:!0,detail:s}))}#P={};on(t,e){this.#P[t]||(this.#P[t]=[]);let s=e.bind(this);this.#P[t].push(s),this.addEventListener(t,s)}nextTick(t){Dt.pushNext(t)}forceUpdate(){h(this.#s,((t,e)=>{this.#r[e]={value:void 0,chain:void 0}})),this.#b()}_notify(t,r){let n=[];for(let i=0;i<r.length;i++){const o=r[i];n.push(o);let a=e(this,n),l=ft(n);this.#r[l]={value:a,chain:"slots"===l?["slots"]:n,oldValue:t,end:n.length===r.length},s(a)&&"#"!=l[0]&&at.set(a,l)}return this.#E}#b(){if(M(this.#r)<1)return;const t=this.#r;this.#r={};let r=e(this.constructor,Et);if(r&&r.sort(((t,e)=>e.priority-t.priority)).forEach((e=>{e.updated(this,t)})),!this.shouldUpdate(t))return;let n=new Set;h(t,(({value:t,chain:e,oldValue:s},r)=>{this.#o[r]&&this.#o[r].forEach((t=>{n.add(t)}))})),n.forEach((t=>{if(t===this)this.updateView(this.render());else{let e=t.render(...t._renderArgs?t._renderArgs:[]);e&&t.updateView(e)}})),this.#x.forEach((t=>{this.#S(t)})),this.updated(t),h(t,(({value:t,chain:e,oldValue:r},n)=>{s(t)&&at.has(t)&&at.delete(t)}))}#C(){let t=e(this.constructor,dt.PROPS),i=this.attributes,a=this.tagName,l=this.#l,c={};h(i,(({name:e,value:s})=>{if(e[0]===be||e[0]===ve||e[0]===Ce||e===Ne||"slot"===e)return;let r=S(e);t&&!t[r]&&(c[e]=s)})),this.#a=this.#a?O(this.#a,c):c;let d={};return h(t,((c,h)=>{let p,f=t[h],g=o(l,h),m=e(this,h);if(!("_defaultValue"in f)&&(f._defaultValue=m,!f.type)){n(m)&&pt(a,"Prop '"+h+"' has neither propType nor defaultValue be used for type inference");let t=typeof m;_(m)&&(t="array");let e=It[t];f.type=e}if(g)p=H(l[h])?m:l[h];else{p=m;let t=i.getNamedItem(u(h))||i.getNamedItem(ve+u(h));t&&(g=!0,p=t.value)}if(f.required&&!g)return pt(a,"Prop '"+h+"' is required"),!1;p=this.#w(t,h,p);let E=e(t,[h,"getter"]);E&&(E=V(E,this));let b=e(t,[h,"setter"]);b&&(b=V(b,this)),(E||b)&&Reflect.defineProperty(this.#e,h,{set:b||function(t){},get:E}),f.attribute&&r(p)&&!s(p)&&this.setAttribute(u(h),I(p)),this.#e[h]=p,d[h]=p})),Object.seal(d)}#w(t,e,s){let i=t[e];if(!i)return s;let o=i.isValid,a=i.type,l=_(a)?a:[a],c=i.converter,d=s;if(!$(l,(t=>t===String))&&w(d)&&!W(d))try{d=c?c(d):j(d,{html:Ie})}catch(t){pt(this.tagName,`Convert attribute '${e}' error with `+d)}for(let t=0;t<l.length;t++){"Boolean"===l[t].name&&(w(d)&&/(?:^true$)|(?:^false$)/.test(d)?d=j(d):(n(d)||b(d))&&(d=!0))}let h=typeof d,u=!r(d);for(let t=0;t<l.length;t++){const e=l[t];if(A(h,e.name,"i")||d instanceof e||Object.prototype.toString.call(d)===Object.prototype.toString.call(e.prototype)){u=!0;break}}return u||pt(this.tagName,`Invalid prop '${e}'. expected '${l.map((t=>t.name||t))}' but got '${h}'`),o&&(o.call(this,d,this.#e)||pt(this.tagName,`Invalid prop '${e}'. IsValid() check failed`)),d}#y(){let t=e(this.constructor,dt.STATES);h(t,((s,r)=>{let n=t[r],i=e(this,r);if(n){let t=n.prop;i=t?d(this.#e[t]):e(this,r)}this.#e[r]=i}))}#A=R(this.propsReady,100);_setParentProps(t,s){if(this.#m){let r=e(this.constructor,dt.PROPS);h(t,((t,e)=>{let s=S(e),n=r[s];if(!n)return;let i=this.#e[s];t=this.#w(r,s,t),n.hasChanged&&!n.hasChanged.call(this,t,i)||(this.#e[s]=t,this._notify(i,[s]))})),O(this.#l,t),O(this.#a,s),this.#A(this.#l)}}_updateProps(t){let s=e(this.constructor,dt.PROPS);h(t,((t,e)=>{let r=S(e),n=s[r];if(!n)return;let i=this.#e[r];t=this.#w(s,r,t),n.hasChanged&&!n.hasChanged.call(this,t,i)||(wt.__skipCheck=!0,y(this,r,t),wt.__skipCheck=!1)})),O(this.#l,t),this.#A(this.#l)}_initProps(t,e){this.#l=c(this.#l||{},t),this.#a=c({},e)}_bindSlot(t,e,s){if(this.#f[e]||(this.#f[e]=t,Reflect.defineProperty(t,"__l_comp",{value:this})),t.addEventListener("slotchange",(s=>{this.#m&&this.#N(t,"default"===e?"":e)})),!i(s)){let t=this.#t[e];t||(t=this.#t[e]={}),s.nodeFilter&&(t.filter=s.nodeFilter),t.props=U(s,"nodeFilter")}}_bindSlotHook(t,e){this.#u[t]=e}#x=new Set;_updateSlot(t,e,s){let r=this.#f[t],n=this.#u[t];if(!n&&!r)return;let i=this.#t[t];if(e&&(i.props||(i.props={}),i.props[e]=s),n)this.#x.add(t);else{let t=r.assignedElements({flatten:!0});for(let r=0;r<t.length;r++){t[r].setAttribute(e,s+"")}}}#v(){const t=x(this.childNodes,(t=>t.nodeType===Node.COMMENT_NODE?[]:t instanceof HTMLSlotElement?t.assignedNodes({flatten:!0}):t));let e=B(t,(t=>t.nodeType===Node.TEXT_NODE?"default":t instanceof Element?t.getAttribute("slot")||"default":void 0));if(i(e))return void(i(this.#e["#slots"])||(this.#m?this.#s["#slots"]={}:this.#e["#slots"]={}));h(e,((t,e)=>{if(e){for(;t.length>0;){let e=t[0];if(!(e.nodeType===Node.TEXT_NODE&&b(e.textContent)||e instanceof HTMLSlotElement&&i(e.assignedNodes({flatten:!0}))))break;t.shift()}for(;t.length>0;){let e=f(t);if(!(e.nodeType===Node.TEXT_NODE&&b(e.textContent)||e instanceof HTMLSlotElement&&i(e.assignedNodes({flatten:!0}))))break;t.pop()}}}));let s={};h(e,((t,e)=>{i(t)||(s[e]=t)})),this.#m?this.#s["#slots"]=s:this.#e["#slots"]=s}#S(t){let s=this.#u[t];if(!s)return;let r=this.#t[t];if(!this.#e["#slots"][t])return;this.renderAsync(s,e(r,"props"));const n=this._asyncDirectives.get(s);let o=n?.buildView(s(e(r,"props"))),a=z(p(o),(t=>t.nodeType===Node.COMMENT_NODE));if(a){let e=this.#g[t];if(!i(e))for(let t=0;t<e.length;t++){const s=e[t];s.parentNode?.removeChild(s)}this.#g[t]=a,this.append(...a),this.#x.clear()}}_asyncDirectives=new WeakMap;renderAsync(t,...e){}#_(){i(this.#t)||h(this.slots,((t,e)=>{if(i(t))return;let r=this.#t[e],n=t;if(r){let e=r.filter;if(m(e))n=e(t);else if(s(e)){let s=e.type,r=e.maxCount;if(s){let e=_(s)?s:[s];n=F(t,(t=>$(e,(e=>t instanceof e))))}r>0&&(n=K(t,0,r))}}if("named"===this.#n.slotAssignment){let e=[];for(let s=0;s<t.length;s++){const r=t[s];n.includes(r)||e.push(r)}for(;e.length>0;){let t=e.pop();t.parentNode?.removeChild(t)}}else this.#f[e].assign(...n);this.#m&&this.#N(this.#f[e],"default"===e?"":e)}))}#T(t,s,r){if(!this.isMounted)return;if(xt(this.constructor).has(t)){let s=S(t);if(W(r)){r=e(this.constructor,dt.PROPS)[s]._defaultValue}this._updateProps({[s]:r})}}_regDeps(t,e){let s=this.#o[t];s||(s=this.#o[t]=new Set),s.add(e);let r=t.split("-");if(r.pop(),r.length<1)return;let n=r.join("-");s=this.#o[n],s||(s=this.#o[n]=new Set),s.add(e)}}var Ut,Bt,zt;!function(t){t.NONE="NONE",t.REMOVE="REMOVE",t.REPLACE="REPLACE",t.UPDATE="UPDATE",t.APPEND="APPEND"}(Ut||(Ut={}));class Ft{key;varIndex;value;isText=!1;isTmpl=!1;isDirective=!1;node;textNode;isComponent=!1;attrName;attrTmpl;isProp=!1;isToggleProp=!1;isEvent;constructor(t,e,s,r){this.varIndex=t,this.node=e,s&&(this.attrName=s),r&&(this.attrTmpl=r)}}!function(t){t.ATTR="attr",t.PROP="prop",t.TEXT="text",t.CLASS="class",t.STYLE="style",t.SLOT="slot",t.TAG="tag"}(Bt||(Bt={}));class Kt{startNode;endNode;type;attrName;varIndex;expressionChain;nodes;constructor(t,e,s){this.startNode=t,this.attrName=e,this.type=s}setVarIndex(t){this.varIndex=t}getNodes(){let t=this.startNode.nextSibling;if(!this.endNode)return[t];let e=[];for(;t&&t!==this.endNode;)e.push(t),t=t?.nextSibling;return e}}!function(t){t.AFTER_BEGIN="afterbegin"}(zt||(zt={}));class Qt extends Function{diClass;args;di;varPath;point;slotComponent;varChain;constructor(t,...e){super(),this.diClass=t,this.args=e,this.varChain=wt.popDirectiveQ(),this.di=new this.diClass,this.di.renderParams=this.varChain}checkScope(t){let s=e(this.diClass,"scopes");i(s)||A(s.join(","),t)||ut(`Directive '${this.diClass.name}' is out of scopes, expect '${s.join(",")}' bug got '${t}'`)}render(t){let e=this.di;return this.args,e.renderComponent||(e.renderComponent=t),this.di=e,e._renderArgs=this.args,this.di.render(...this.args)}update(t,e,s){let r=this.di.update(t,e,s);if(r===Ut.NONE)return;let n=t.getNodes();if(r===Ut.REMOVE)for(let t=0;t<n.length;t++){const e=n[t];e.parentNode?.removeChild(e)}else if(r===Ut.REPLACE){let s=[];for(let t=0;t<n.length;t++){const e=n[t];e.parentNode?.removeChild(e)}let r=this.di.render(...e),i=this.di.buildView(r);s=p(i);let o=document.createDocumentFragment();o.append(...s),t.endNode.parentNode.insertBefore(o,t.endNode)}else if(r===Ut.UPDATE){let s,r={},o=[],a=[],l=this.di.render(...e);if(l||(l=new je([],[])),i(n)){let e=this.di.buildView(l);return void t.startNode.after(...e)}let c={};l instanceof je&&l.vars.forEach((t=>{if(t instanceof je){const e=t.getKey();c[e]=t,r[e]=!0,a.push(e)}})),n=F(Q(n),(t=>t.nodeType===Node.ELEMENT_NODE)),s=F(Q(p(s)),(t=>t.nodeType===Node.ELEMENT_NODE));let d={},u="",g={};for(let t=0;t<n.length;t++){let e=n[t],s=e.getAttribute("key");if(s){if(d[s]){u=s;break}d[s]=e,o.push(s),g[s]=!0}}if(u)return void ut(`${S(this.diClass.name)} - duplicate key '${u}'`);let m=r;const _=t.startNode.parentNode;let b=[],v=[];if(h(g,((t,e)=>{m[e]||(v.push(e),delete g[e],X(o,e))})),!i(a)){let e="",s=-1,r=[],n=new Map;for(let i=0;i<a.length;i++){const l=a[i];let c=o.findIndex((t=>t===l));if(c>-1&&c!==i){if(s<0||s-c==1){let t=f(r);r.push({nodeId:l,targetId:0===i?zt.AFTER_BEGIN:t?t.nodeId:a[i-1]})}else n.set(r.length,{group:r,targetId:""}),r=[],r.push({nodeId:l,targetId:o[c]});s=c}else if(c<0){let s=e?d[e]||t.endNode:t.startNode;b.push({prevNode:s,newkey:l})}e=l}i(n)&&r.length>0&&n.set(r.length,{group:r,targetId:""});let l=n.keys().toArray(),c=l.sort(((t,e)=>t-e));if(l.length>0&&l.length<2){let{group:e}=n.get(c[0]);E(e).forEach((({targetId:e,nodeId:s})=>{let r,n=d[s];e===zt.AFTER_BEGIN?(r=t.startNode,r.after(n)):(r=d[e],r.after(n))}))}}b.length>0&&this.#M(b,c,a),b.forEach((e=>{let s=e.newkey,r=this.newNodeMap[s],n=e.prevNode;n===t.endNode?n.before(r):(t.startNode,n.after(r))})),v.forEach((t=>{let e=o.findIndex((e=>e==t));this.#O(e);let s=d[t];s&&s.parentNode&&_.removeChild(s)})),this.di.__updatePoints.forEach((t=>{t.key||(t.key=t.value.tmpl.getKey());const e=a.findIndex((e=>e==t.key));t.varIndex=e})),this.di.updateView(l)}}getDirective(){return this.di}newNodeMap={};#M(t,e,s){const r=[],n=[];t.forEach((t=>{let s=t.newkey;r.push(""),n.push(e[s])})),r.push("");let i=new je(r,n),o=this.di.__updatePoints,a=this.di.buildView(i);this.di.__updatePoints.forEach(((t,e)=>{const s=t.value.tmpl.getKey();t.key=s})),this.di.__updatePoints.push(...o),a.forEach((t=>{t instanceof HTMLElement&&(this.newNodeMap[t.getAttribute("key")]=t)}))}#O(t){X(this.di.__updatePoints,((e,s)=>{if(e.varIndex==t)return He.remove(e.node,e.textNode),!0}))}}function Xt(t){return(...e)=>{let s=null;return e.forEach(((t,r)=>{if(m(t)){let n=t;e[r]=function(...t){let e=s.di;wt.startRender(e);let r=n.call(e.renderComponent,...t);return wt.endRender(e.renderComponent),r}}})),s=new Qt(t,...e),s}}const Gt=["resize","outside","mutate"],qt=new WeakMap,Yt=[],Zt=new ResizeObserver((t=>{for(const e of t){const t=Array.isArray(e.contentBoxSize)?e.contentBoxSize[0]:e.contentBoxSize,s=Array.isArray(e.borderBoxSize)?e.borderBoxSize[0]:e.borderBoxSize;let r=qt.get(e.target);if(r){r(new CustomEvent("resize",{bubbles:!1,cancelable:!1,detail:{borderBox:{w:s.inlineSize,h:s.blockSize},contentBox:{w:t.inlineSize,h:t.blockSize}}}),e.target)}}}));var Jt;!function(t){t.Child="child",t.Tree="tree",t.Attr="attr",t.Char="char"}(Jt||(Jt={}));const te=new WeakMap,ee=new MutationObserver((t=>{for(let e=0;e<t.length;e++){const s=t[e];let r=te.get(s.target);if(!r)return;let n={target:s.target},i=null;switch(s.type){case"subtree":n.type=Jt.Tree,i=r[Jt.Tree];break;case"childList":n.type=Jt.Child,n.addedNodes=s.addedNodes,n.removedNodes=s.removedNodes,i=r[Jt.Child];break;case"attributes":n.type=Jt.Attr,n.attributeName=s.attributeName,n.oldValue=s.oldValue,i=r[Jt.Attr];break;case"characterData":n.type=Jt.Char,n.oldValue=s.oldValue,i=r[Jt.Char]}if(i){i(new CustomEvent("mutate",{bubbles:!1,cancelable:!1,detail:n}),s.target)}}}));function se(t,e,s,r){if("resize"===t)!function(t,e){qt.has(t)||(qt.set(t,e),Zt.observe(t))}(e,s);else if("outside"===t){if("mousedown"===r[0])!function(t,e){Yt.push([t,e])}(e,s)}else"mutate"===t&&function(t,e,s){let r=G(s,"child"),n=G(s,"attr"),i=G(s,"char"),o=G(s,"tree"),a=te.get(t);a||(a={},te.set(t,a),r&&(a[Jt.Child]=e),n&&(a[Jt.Attr]=e),i&&(a[Jt.Char]=e),o&&(a[Jt.Tree]=e),ee.observe(t,{childList:r,attributes:n,characterData:i,subtree:o}))}(e,s,r)}document.addEventListener("mousedown",(t=>{let e=t.target;Yt.forEach((([s,r])=>{if(!s.contains(e)){r(new CustomEvent("outside",{bubbles:!1,cancelable:!1,detail:{currentTarget:s,event:t}}),s)}}))}),!1);const re=/,|^(debounce:.+)|(debounce$)/,ne=/,|^(throttle:.+)|(throttle$)/,ie="self",oe="stop",ae="prevent",le="once",ce="left",de="right",he="middle",ue="ctrl",pe="alt",fe="shift",ge="meta",me={esc:"escape"},_e=":";function Ee(t,e,s,r){let n,i=t.split("."),o=i.shift(),a=i.includes(le),l=e;if(n=q(i,(t=>re.test(t)))){let t=n.split(_e);l=R(l,parseInt(t[1])||100)}if(n=q(i,(t=>ne.test(t)))){let t=n.split(_e);l=Y(l,parseInt(t[1])||100)}if(a&&(l=D(l)),function(t){return Gt.includes(t)}(o))return se(o,s,l,i),l;let c=t=>{if(i.includes(ae)&&t.preventDefault(),i.includes(oe)&&t.stopPropagation(),!i.includes(ie)||t.target===t.currentTarget){if(t instanceof MouseEvent){if(i.includes(ce)&&0!=t.button)return;if(i.includes(de)&&2!=t.button)return;if(i.includes(he)&&1!=t.button)return}else if(t instanceof KeyboardEvent){if(X(i,(t=>t==ue))[0]&&!t.ctrlKey)return;if(X(i,(t=>t==pe))[0]&&!t.altKey)return;if(X(i,(t=>t==fe))[0]&&!t.shiftKey)return;if(X(i,(t=>t==ge))[0]&&!t.metaKey)return;if(!Z(i,(t=>me[t]||t)).includes(t.key.toLowerCase()))return}l(t,s)}};s.addEventListener(o,c);let d=r.__events[o];return d||(d=r.__events[o]=[]),d.push([s,c]),c}const be="@",ve=".",Ce="?",ye="*",Se=":",Ne="ref",Te=/[.?-a-z]+\s*=\s*(['"])\s*([^='"]*<\!--c_ui-pl_df-->){2,}.*?\1/ims,Pe=/<\s*[a-z0-9-]+([^>]*<\!--c_ui-pl_df-->)*[^>]*?(?<!-)>/gims,xe="slot-props";function we(t,s){let r="",n=a(s.vars),i=s.strings.length-1,o=s.vars.length-1;for(let n=0;n<=i;n++){const i=s.strings[n];let a=e(s.vars,n,"");if(a&&a.di){let e=a.render(t);if(e instanceof je){let[s,r]=we(t,e);Reflect.defineProperty(a,"_renderVars",{value:r}),a=Ae+s+Me}else a=e??Re}else if(a instanceof je){let[e,s]=we(t,a);Reflect.defineProperty(a,"_renderVars",{value:s}),a=Oe+e+ke}else a=n>o?"":Re;r+=i+a}let l=r.match(Te);if(l){return ut(`Parse error: attribute value can be set only one interpolation —— \n ${J(l[0],Re,"${...}")}`),["",n]}let c=0;return r=r.replace(Pe,((t,e)=>J(t,Re,(()=>Re.replace("--\x3e","")+c++)))),r=r.replace($e,"$1><").trim(),[r,n]}const Ae="\x3c!--c_ui-pl_di-start--\x3e",Me="\x3c!--c_ui-pl_di-end--\x3e",Oe="\x3c!--c_ui-pl_tmpl-start--\x3e",ke="\x3c!--c_ui-pl_tmpl-end--\x3e",Re="\x3c!--c_ui-pl_df--\x3e",Le="\x3c!--c_ui-pl_df",De=/<!--c_ui-pl_df\d*(-->)?/;function Ve(t,s,r,i,a){const l=document.createElement("div");l.innerHTML=s;const c=document.createNodeIterator(l,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT);let d,h,_=0,E=null,b=[],v=[],C=[],y=[t],N=[],P=[];for(;d=c.nextNode();)if(d instanceof HTMLElement||d instanceof SVGElement){d instanceof jt?E=d:E?.contains(d)||(E=null);let e={},s=p(d.attributes);for(let n=0;n<s.length;n++){const a=s[n];let{name:l,value:c}=a;if(l===xe){let t=d.getAttribute("name")||"default";if(E){let e=E._slotsPropMap[t];e||(e=E._slotsPropMap[t]=[]),e.push(d)}}if(g(l,Le)){let e=r[_];if(e instanceof Qt){e.checkScope(Bt.TAG);let s=new Kt(d,l.substring(1),Bt.TAG);e.point=s,e.di.slotComponent=E,e.di.renderComponent=i;let r=new Ft(_,d);r.isDirective=!0,r.value=e,r.isComponent=!!E,t.push(r),_++,e.di.created(s,...e.args)}d.removeAttribute(l)}else if(l[0]!==be)if(l!==Ne)if(l[0]!==ve||De.test(c)){if(De.test(c)){let s=r[_],n=new Ft(_,d,l.replace(/\.|\?|@/,""),c);if(t.push(n),n.isComponent=!!E,l[0]===ve||l[0]===Ce||l[0]===ye){if(s instanceof Qt){s.checkScope(Bt.PROP);let t=new Kt(d,l.substring(1),Bt.PROP);s.point=t,s.slotComponent=E,n.value=s,n.isDirective=!0,s&&s.di.created(s.point,...s.args)}else if(l[0]===Ce)n.isToggleProp=!0,n.value=!!s,n.value&&d.setAttribute(l.substring(1),"");else if(l[0]===ye){n.value=s;let t=l.substring(1);const[e,r]=t.split(Se);let i=e;switch(r){case"camel":i=S(i);break;case"kebab":i=u(i);break;case"snake":i=tt(i)}n.attrName=i,d.setAttribute(i,s)}else if(d instanceof jt||"SLOT"===d.tagName){let t=S(l.substring(1));t in d||"SLOT"===d.tagName||pt(d.tagName,`Prop '${l}' is not defined in ${d.tagName}`),n.value=s,n.isProp=!0,e[t]=s}else pt(d.tagName,`Prop '${l}' can only be set on a CompElem or a slot`);d.removeAttribute(l),s=""}else{let t;if(n.value=s,s instanceof Qt){let e=Bt.ATTR;"class"===l?e=Bt.CLASS:"style"===l&&(e=Bt.STYLE),s.checkScope(e),n.isDirective=!0;let r=new Kt(d,l,e);s.point=r,s.di.slotComponent=E,s.di.renderComponent=i,t=s,s=""}c=T(c,De,s),a.value=c,t&&t.di.created(t.point,...t.args)}_++}}else pt(d.tagName,`Prop '${l}' must be an interpolation`);else{if(De.test(c)){let t=r[_];if(!o(t,"current")){pt(d.tagName,"Ref must be a RefObject");continue}_++,t.current=d}d.removeAttribute(l)}else{let e=t=>{};if(De.test(c)){let s=r[_];if(!m(s)){pt(d.tagName,`Event '${l}' must be a function`);continue}e=s.bind(i);let n=new Ft(_,d,l.replace(/\.|\?|@/,""),c);n.isComponent=!!E,n.isEvent=!0,t.push(n),_++}Ee(l.substring(1),e,d,i),d.removeAttribute(l)}}d instanceof jt?d._initProps(e):d instanceof HTMLSlotElement&&i._bindSlot(d,d.name||"default",e)}else{let s=d,o=`\x3c!--${s.nodeValue}--\x3e`;if(o===Ae){h&&b.push(h),h=s;let e=r[_],n=new Ft(_,d);n.isComponent=!!E,n.isDirective=!0,n.value=e;let o=E?Bt.SLOT:Bt.TEXT,a=new Kt(h,"",o);e.point=a,e.di.slotComponent=E,e.di.renderComponent=i,v.push(e),t.push(n),C.push(n),t=[],y.push(t),_++,P.push(_),N.push(r),r=e._renderVars,_=0;continue}if(o===Me){C.pop().textNode=s;let e=v.pop();e.point.endNode=s,e.di.created(e.point,...e.args),h=b.pop(),e.di.__updatePoints=t,y.pop(),t=f(y),r=N.pop(),_=P.pop()}else{if(o===Oe){h&&b.push(h),h=s;let n=r[_],o=new Ft(_,d);o.isComponent=!!E,o.isTmpl=!0;let l=f(v);(l&&"ForEach"===e(l,"diClass.name")||"ForEach"==a.constructor.name)&&(o.key=n.getKey()),n=o.value=new Ht(n);let c=E?Bt.SLOT:Bt.TEXT,u=new Kt(h,"",c);n.point=u,n.slotComponent=E,n.renderComponent=i,v.push(n),t.push(o),C.push(o),t=[],y.push(t),_++,P.push(_),N.push(r),r=n._renderVars,_=0;continue}if(o===ke){C.pop().textNode=s;let e=v.pop();e.point.endNode=s,h=b.pop(),e.__updatePoints=t,y.pop(),t=f(y),r=N.pop(),_=P.pop()}}if(o!==Re)continue;let l=new Ft(_,d);t.push(l),l.isComponent=!!E,l.isText=!0;let c,u=r[_];if(c=document.createComment(`compelem-ui-${_}-child-start`),s.parentNode.insertBefore(c,s),s.nodeValue=`compelem-ui-${_}-child-end`,l.textNode=c,u instanceof Qt){l.isDirective=!0,l.value=u;let t=E?Bt.SLOT:Bt.TEXT,e=new Kt(c,"",t);e.endNode=s,u.point=e,u.di.slotComponent=E,u.di.renderComponent=i,u.di.created(e,...u.args),u=""}else if(u instanceof je){l.isTmpl=!0,l.value=u;let[e,s]=we(i,u);u=Ve(t,e,s,i,a)}else l.value=u;if(_++,n(u))continue;if(u instanceof NodeList){let t=document.createDocumentFragment();t.append(...u),s.parentNode.insertBefore(t,s)}else if(u instanceof Element)s.parentNode.insertBefore(u,s);else if(I(u)){let t=document.createTextNode(u);s.parentNode.insertBefore(t,s)}}return l.childNodes}const He={insertBefore:function(t,e){if(!t.parentNode)return;let s=document.createDocumentFragment();s.append(...e),t.parentNode.insertBefore(s,t)},remove:function(t,e){if(t===e)return void t?.parentNode?.removeChild(t);let s=t.nextSibling;for(;s&&s!==e;)s?.parentNode?.removeChild(s),s=t.nextSibling}};function Ie(t,...e){return new je(w(t)?[t]:t,e)}const $e=/([a-z0-9"'])\s*>\s*</gim;function We(t){return{current:t}}class je{strings;vars;constructor(t,e){this.strings=a(t),this.vars=e}getKey(){let t=this.vars,e="";return h(this.strings,((s,r)=>{if(lt.test(s))return e=et(t[r]),!1})),e}getKeys(){let t=this.vars,e=[];for(let s=0;s<this.strings.length;s++){const r=this.strings[s];if(lt.test(r)){let r=et(t[s]);e.push(r)}}return i(e)&&t.forEach((t=>{if(t instanceof je){let s=t.getKey();e.push(s)}})),e}append(t){let e=f(this.strings);return t.strings.forEach(((t,s)=>{0!=s?this.strings.push(t):this.strings[this.strings.length-1]=e+t})),this.vars=a(this.vars,t.vars),this}insert(t,e){let s=e.strings.shift();return this.strings[t]+=s,this.strings.splice(t+1,0,...e.strings),this.vars.splice(t,0,...e.vars),this}getHTML(t){let[e,s]=we(t,this),r=Ve([],e,s,t,t);return st(r,((t,e)=>t+e.outerHTML),"")}}function Ue(t,e,s){s.get||ut(`Computed '${e}' must be a getter`),o(t.constructor,dt.COMPUTED)||(t.constructor[dt.COMPUTED]=i(t.constructor[dt.COMPUTED])?{}:d(t.constructor[dt.COMPUTED])),t.constructor[dt.COMPUTED][e]=s.get}function Be(t,e){return(s,r,n)=>{o(s.constructor,dt.EVENTS)||(s.constructor[dt.EVENTS]=i(s.constructor[dt.EVENTS])?[]:d(s.constructor[dt.EVENTS])),s.constructor[dt.EVENTS].push({name:t,options:e,fn:s[r]})}}var ze;!function(t){t.ONCE="once",t.UPDATABLE="updatable"}(ze||(ze={}));class Fe extends mt{static get priority(){return Number.MAX_VALUE}created(t,e,s,...r){}mounted(t,e,...s){}get targets(){return[ht.FIELD]}selector;cache;result;constructor(t,e){super(),this.selector=t,this.cache=e}static getKey(t){return t}getter(t){this.result=t.shadowRoot?.querySelector(this.selector)}beforeMount(t,e,s,r,...n){const i=this;Reflect.defineProperty(t,r,{get:()=>(i.result&&i.cache||i.getter(t),i.result)})}updated(t,e){this.cache===ze.UPDATABLE&&this.getter(t)}}const Ke=yt(Fe),Qe=yt(class extends Fe{getter(t){this.result=t.shadowRoot?.querySelectorAll(this.selector)}});function Xe(t){if(1===arguments.length)return(e,s)=>{Ge(e,s,t)};Ge(arguments[0],arguments[1],{prop:""})}function Ge(t,e,s){if(!o(t.constructor,dt.STATES)){const e={};let s=t.constructor;for(;(s=gt(s))!==jt;)c(e,s[dt.STATES]?d(s[dt.STATES]):{});Reflect.defineProperty(t.constructor,dt.STATES,{configurable:!1,enumerable:!1,value:e})}t.constructor[dt.STATES][e]=s}function qe(t,e,s){Ge(t.prototype,e,s||{prop:""})}function Ye(t){return e=>{if(e){if(e.prototype.hasOwnProperty("attributeChangedCallback")){let t=e.prototype.attributeChangedCallback;e.prototype.attributeChangedCallback=function(e,s,r){jt.prototype.attributeChangedCallback.call(this,e,s,r),t.call(this,e,s,r)}}if(e.prototype.hasOwnProperty("connectedCallback")){let t=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){jt.prototype.connectedCallback.call(this),t.call(this)}}if(e.prototype.hasOwnProperty("disconnectedCallback")){let t=e.prototype.connectedCallback;e.prototype.disconnectedCallback=function(){jt.prototype.disconnectedCallback.call(this),t.call(this)}}customElements.define(t,e)}}}function Ze(t,e){return(s,r)=>{o(s.constructor,dt.WATCH)||(s.constructor[dt.WATCH]=i(s.constructor[dt.WATCH])?{}:d(s.constructor[dt.WATCH]));(_(t)?t:[t]).forEach((t=>{let n=t.replaceAll(".","-"),i=s.constructor[dt.WATCH][n];_(i)||(i=s.constructor[dt.WATCH][n]=[]),i.push({source:t,options:e,handler:s[r]})}))}}class Je extends(Vt(Object)){_renderArgs;static get scopes(){return[]}renderParams}const ts=["key"];const es=Xt(class extends Je{created(t,e){let s=t.startNode;if(s instanceof jt){let t={},r={};h(e,((e,n)=>{ts.includes(n)||(n in s?t[n]=e:r[n]=e+"")})),s._initProps(t,r)}else h(e,((t,e)=>{s.setAttribute(e,t)}))}update(t,e,s){return Ut.NONE}static get scopes(){return[Bt.TAG]}render(t){}});const ss=Xt(class extends Je{created(t,e){let r=[];_(e)?r=Q(e):s(e)?r=x(e,((t,e)=>t?e:[])):w(e)&&(r=e.split(" "));let n=t.startNode;h(this.lastCls,(t=>{n.classList.remove(t)})),h(r,(t=>{n.classList.add(t)})),this.lastCls=a(r)}update(t,e,s){return this.created(t,e[0]),Ut.NONE}static get scopes(){return[Bt.CLASS]}lastCls;render(t){}});const rs=Xt(class extends Je{created(t,...e){}update(t,e,s){if(i(t.getNodes())&&(!e||i(e[0])))return Ut.NONE;if(rt(this.lastAry,e[0])&&this.lastAry.length===e[0].length)return Ut.NONE;if(!i(this.renderParams)){let t=f(this.renderParams);_(t)||(t=[t]),this.renderParams=t}return this.lastAry=nt(e[0]),Ut.UPDATE}constructor(t){super(),i(this.renderParams)||(this.renderParams=p(f(this.renderParams)))}static get scopes(){return[Bt.TEXT,Bt.SLOT]}lastAry;lastRenderTmpl;render(t,e){let s=Z(t,((t,s)=>e(t,s)));if(s.length<1)return this.lastRenderTmpl=new je([],[]),this.lastRenderTmpl;let r=[],n=[];const i=[],o=[];for(let t=0;t<s.length;t++){const e=s[t];let a=f(n),l=e.vars,c=!0,d=e.strings;for(let t=0;t<d.length;t++){const e=d[t];if(lt.test(e)){let e=l[t]+"";if(r.includes(e))return void ut(`forEach - duplicate key '${e}'`);r.push(e),c=!1}0==t&&a?n[n.length-1]=a+e:n.push(e)}if(c)return void ut("forEach - missing 'key' prop");let h=f(i);h&&d.length>0&&(i[i.length-1]=I(h)+d.shift()),i.push(""),o.push(e)}return this.lastAry=nt(t),i.push(""),this.lastRenderTmpl=new je(i,o),this.lastRenderTmpl}});const ns=Xt(class extends Je{created(t,...e){}ifNodes;elseNodes;static get scopes(){return[Bt.TEXT,Bt.SLOT]}update(t,e,s){return!!e[0]==!!s[0]?Ut.NONE:(e[0],Ut.REPLACE)}render(t,e,s){return t?e(t):s(t)}});const is=Xt(class extends Je{created(t,...e){}static get scopes(){return[Bt.TEXT,Bt.SLOT]}update(t,e,s){return e[0]===s[0]?Ut.NONE:e[0]?Ut.REPLACE:Ut.REMOVE}render(t,e){return t?e():Ie``}});var os;!function(t){t.CHANGE="change",t.INPUT="input"}(os||(os={}));const as=Xt(class extends Je{created(t,r,n="value"){const i=t.startNode;if("binded"===e(i,"_model"))return;let o=f(this.renderParams);if(this.updateProp=n,this.modelPath=o,s(r)||I(r)||(r=""),i instanceof jt)i._initProps({[this.updateProp]:r}),i.addEventListener("update:"+n,(t=>{y(this.renderComponent,this.modelPath,t.detail.value)})),y(i,"_model","binded");else if(i instanceof HTMLTextAreaElement)i.setAttribute(this.updateProp,r+""),i.addEventListener("input",(t=>{let e=t.target;y(this.renderComponent,this.modelPath,e.value)})),y(i,"_model","binded");else if(i instanceof HTMLInputElement){let t="",e="";switch(i.type){case"checkbox":case"radio":t="checked",e="change";break;default:t="value",e="input"}i.setAttribute(n??t,r+""),i.addEventListener(e,(t=>{let e=t.target;y(this.renderComponent,this.modelPath,e.value)})),y(i,"_model","binded")}else i instanceof HTMLSelectElement&&(i.setAttribute(this.updateProp,r+""),i.addEventListener("change",(t=>{let e=t.target;y(this.renderComponent,this.modelPath,e.value)})),y(i,"_model","binded"))}update(t,e,s){if(this.modelPath||(this.modelPath=f(this.renderParams)),!N(e,s)){const s=t.startNode;if(s instanceof jt)s._updateProps({[this.updateProp]:e[0]});else if(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)s.setAttribute(this.updateProp,e[0]+"");else if(s instanceof HTMLInputElement)switch(s.type){case"checkbox":case"radio":e[0]?s.setAttribute("checked",""):s.removeAttribute("checked");break;default:s.setAttribute(this.updateProp,e[0]+"")}}return Ut.NONE}static get scopes(){return[Bt.TAG]}modelPath;render(t,e="value"){}});const ls=Xt(class extends Je{created(t,e){let s=t.startNode;n(this.display)&&(this.display=s.style.display),this.renderComponent.nextTick((()=>{s.style.display=e?this.display:"none"}))}update(t,e,s){return this.created(t,e[0]),Ut.NONE}display=void 0;static get scopes(){return[Bt.TAG]}constructor(t){super(),this.point=t}render(t){}});const cs=Xt(class extends Je{created(t,e,s){e=e.bind(this.renderComponent),this.slotComponent._bindSlotHook(s||"default",e)}update(t,e,s){return Ut.NONE}static get scopes(){return[Bt.SLOT]}render(t,e){}});class ds{static getCssText(t){return w(t)?t:v(Z(t,((t,e)=>u(e)+":"+t)),";")}static setStyle(t,e){if(w(t)&&!I(t))return{};let s=ds.getCssText(t),r={};return h(s.split(";"),(t=>{let s=t.split(":"),n=I(s[0]),i=I(s[1]);r[n]=e.style.getPropertyValue(n),e.style.setProperty(n,i)})),r}}const hs=Xt(class extends Je{created(t,e){ds.setStyle(e,t.startNode)}update(t,e,s){return this.created(t,e[0]),Ut.NONE}constructor(t){super(),this.point=t}static get scopes(){return[Bt.STYLE]}render(t){}});const us=Xt(class extends Je{created(t,e){this.modelPath||(this.modelPath=f(this.renderParams));const s=t.startNode;let r=t.attrName;s._initProps({[r]:e}),s.addEventListener("update:"+r,(t=>{y(this.renderComponent,this.modelPath,t.detail.value)}))}update(t,e,s){if(!N(e,s)){const s=t.startNode;let r=t.attrName;s._updateProps({[r]:e[0]})}return Ut.NONE}static get scopes(){return[Bt.PROP]}modelPath;constructor(t){super()}render(t){}});const ps=Xt(class extends Je{created(t,...e){}static get scopes(){return[Bt.TEXT,Bt.SLOT]}update(t,e,s){return N(e,s)?Ut.NONE:Ut.REPLACE}render(t,e){let s=()=>Ie``,r=[],n=[];h(e,((t,e)=>{if(m(t))r.push(e),n.push(t);else{let e=t[0],s=t[1];r.push(e),n.push(s)}"default"===e&&(s=t)}));let i=it(r,(e=>m(e)?e(t):e==t));return ot(n[i]??s)}});export{jt as CompElem,ds as CssHelper,mt as Decorator,ht as DecoratorType,vt as DecoratorWrapper,Je as Directive,Ut as DirectiveUpdateTag,Qt as DirectiveWrapper,Kt as EnterPoint,Bt as EnterPointType,_t as GetKeyFnName,os as ModelTriggerType,ze as QueryCache,je as Template,Ft as UpdatePoint,bt as _DecoratorMap,Et as _DecoratorsKey,xt as _getObservedAttrs,es as bind,we as buildHTML,ss as classes,Ue as computed,We as createRef,yt as decorator,Xt as directive,Be as event,rs as forEach,Ie as html,ns as ifElse,is as ifTrue,qe as makeState,as as model,Nt as prop,Ke as query,Qe as queryAll,ls as show,cs as slot,Xe as state,hs as styles,us as sync,Ye as tag,Ze as watch,ps as when};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "compelem",
3
- "version": "0.3.1-b1",
3
+ "version": "0.3.2-b1",
4
4
  "description": "A modern, reactive, fast, lightweight and flexible lib for building web components",
5
5
  "main": "index.js",
6
6
  "module": "index.js",