amateras 0.14.1 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -12
- package/build/core.js +1 -1
- package/build/css-keyframes.js +1 -1
- package/build/css-property.js +1 -1
- package/build/css-variable.js +1 -1
- package/build/css.js +1 -1
- package/build/for.js +1 -1
- package/build/i18n.js +1 -1
- package/build/idb.js +1 -1
- package/build/if.js +1 -1
- package/build/import-map.js +1 -1
- package/build/markdown.js +1 -1
- package/build/match.js +1 -1
- package/build/meta.js +1 -1
- package/build/prefetch.js +1 -1
- package/build/router.js +1 -1
- package/build/signal.js +1 -1
- package/build/store.js +1 -1
- package/build/ui.js +1 -1
- package/build/utils.js +1 -1
- package/build/widget.js +1 -1
- package/package.json +4 -4
- package/packages/core/src/index.ts +50 -72
- package/packages/core/src/lib/hmr.ts +119 -133
- package/packages/core/src/lib/virtual_scroll.ts +29 -0
- package/packages/core/src/structure/ElementProto.ts +44 -27
- package/packages/core/src/structure/GlobalState.ts +5 -5
- package/packages/core/src/structure/NodeProto.ts +8 -13
- package/packages/core/src/structure/Proto.ts +50 -42
- package/packages/core/src/structure/ProtoProcess.ts +45 -0
- package/packages/core/src/structure/ProxyProto.ts +2 -2
- package/packages/css/package.json +4 -2
- package/packages/css/src/ext/fluent.ts +18 -0
- package/packages/css/src/ext/fluents/border.ts +49 -0
- package/packages/css/src/ext/fluents/box.ts +135 -0
- package/packages/css/src/ext/fluents/container.ts +3 -0
- package/packages/css/src/ext/fluents/flex.ts +32 -0
- package/packages/css/src/ext/fluents/flexItem.ts +20 -0
- package/packages/css/src/ext/fluents/font.ts +18 -0
- package/packages/css/src/ext/fluents/grid.ts +15 -0
- package/packages/css/src/ext/fluents/hover.ts +6 -0
- package/packages/css/src/ext/fluents/media.ts +12 -0
- package/packages/css/src/ext/fluents.ts +9 -0
- package/packages/css/src/ext/keyframes.ts +5 -6
- package/packages/css/src/ext/property.ts +6 -7
- package/packages/css/src/ext/static-colors.ts +2 -0
- package/packages/css/src/ext/variable.ts +7 -8
- package/packages/css/src/ext/variables/colors.ts +32 -0
- package/packages/css/src/ext/variables/general.ts +4 -0
- package/packages/css/src/ext/variables/lineHeight.ts +14 -0
- package/packages/css/src/ext/variables/radius.ts +13 -0
- package/packages/css/src/ext/variables/text.ts +17 -0
- package/packages/css/src/ext/variables/weight.ts +12 -0
- package/packages/css/src/ext/variables.ts +14 -0
- package/packages/css/src/index.ts +50 -16
- package/packages/css/src/lib/cache.ts +2 -1
- package/packages/css/src/lib/colorAssign.ts +3 -3
- package/packages/css/src/lib/createRule.ts +4 -4
- package/packages/css/src/lib/spacingFn.ts +3 -0
- package/packages/css/src/lib/static-colors/amber.ts +11 -0
- package/packages/css/src/lib/static-colors/blackwhite.ts +2 -0
- package/packages/css/src/lib/static-colors/blue.ts +11 -0
- package/packages/css/src/lib/static-colors/cyan.ts +11 -0
- package/packages/css/src/lib/static-colors/emerald.ts +11 -0
- package/packages/css/src/lib/static-colors/fuchsia.ts +11 -0
- package/packages/css/src/lib/static-colors/gray.ts +11 -0
- package/packages/css/src/lib/static-colors/green.ts +11 -0
- package/packages/css/src/lib/static-colors/indigo.ts +11 -0
- package/packages/css/src/lib/static-colors/lime.ts +11 -0
- package/packages/css/src/lib/static-colors/neutral.ts +11 -0
- package/packages/css/src/lib/static-colors/orange.ts +11 -0
- package/packages/css/src/lib/static-colors/pink.ts +11 -0
- package/packages/css/src/lib/static-colors/purple.ts +11 -0
- package/packages/css/src/lib/static-colors/red.ts +11 -0
- package/packages/css/src/lib/static-colors/rose.ts +11 -0
- package/packages/css/src/lib/static-colors/sky.ts +11 -0
- package/packages/css/src/lib/static-colors/slate.ts +11 -0
- package/packages/css/src/lib/static-colors/stone.ts +11 -0
- package/packages/css/src/lib/static-colors/teal.ts +11 -0
- package/packages/css/src/lib/static-colors/violet.ts +11 -0
- package/packages/css/src/lib/static-colors/yellow.ts +11 -0
- package/packages/css/src/lib/static-colors/zinc.ts +11 -0
- package/packages/css/src/lib/static-colors.ts +23 -0
- package/packages/css/src/lib/valueFn.ts +1 -0
- package/packages/css/src/structure/$CSSFluent.ts +129 -0
- package/packages/css/src/structure/$CSSProperty.ts +2 -2
- package/packages/css/src/structure/$CSSRule.ts +6 -6
- package/packages/for/src/global.ts +12 -2
- package/packages/for/src/index.ts +1 -1
- package/packages/for/src/structure/For.ts +19 -19
- package/packages/hmr/src/index.ts +28 -3
- package/packages/i18n/package.json +2 -1
- package/packages/i18n/src/index.ts +11 -9
- package/packages/i18n/src/structure/I18n.ts +29 -26
- package/packages/i18n/src/structure/I18nDictionary.ts +13 -10
- package/packages/i18n/src/structure/I18nSession.ts +25 -7
- package/packages/i18n/src/structure/I18nTranslation.ts +7 -5
- package/packages/i18n/src/types.ts +43 -35
- package/packages/idb/src/index.ts +3 -3
- package/packages/idb/src/lib/$IDBRequest.ts +1 -3
- package/packages/idb/src/structure/$IDB.ts +6 -6
- package/packages/idb/src/structure/$IDBCursor.ts +2 -2
- package/packages/idb/src/structure/$IDBIndex.ts +2 -2
- package/packages/idb/src/structure/$IDBStore.ts +2 -2
- package/packages/idb/src/structure/$IDBStoreBase.ts +0 -1
- package/packages/idb/src/structure/$IDBTransaction.ts +3 -3
- package/packages/idb/src/structure/builder/$IDBBuilder.ts +25 -25
- package/packages/idb/src/structure/builder/$IDBStoreBuilder.ts +1 -1
- package/packages/if/src/index.ts +8 -8
- package/packages/if/src/structure/Condition.ts +8 -8
- package/packages/if/src/structure/ConditionStatement.ts +3 -3
- package/packages/markdown/src/lib/util.ts +2 -2
- package/packages/markdown/src/structure/MarkdownLexer.ts +3 -3
- package/packages/markdown/src/structure/MarkdownParser.ts +3 -3
- package/packages/markdown/src/syntax/alert.ts +2 -2
- package/packages/markdown/src/syntax/link.ts +2 -2
- package/packages/markdown/src/syntax/list.ts +3 -3
- package/packages/markdown/src/syntax/table.ts +2 -2
- package/packages/match/src/index.ts +6 -6
- package/packages/match/src/structure/Case.ts +2 -2
- package/packages/match/src/structure/Match.ts +8 -8
- package/packages/meta/src/index.ts +18 -9
- package/packages/meta/src/lib/resolveMeta.ts +5 -5
- package/packages/prefetch/src/index.ts +81 -16
- package/packages/router/src/index.ts +17 -15
- package/packages/router/src/structure/Link.ts +2 -2
- package/packages/router/src/structure/NavLink.ts +23 -6
- package/packages/router/src/structure/Page.ts +4 -4
- package/packages/router/src/structure/Route.ts +11 -6
- package/packages/router/src/structure/RouteNode.ts +5 -5
- package/packages/router/src/structure/RouteSlot.ts +5 -5
- package/packages/router/src/structure/Router.ts +61 -44
- package/packages/signal/src/index.ts +22 -20
- package/packages/signal/src/structure/Signal.ts +25 -25
- package/packages/store/src/index.ts +2 -2
- package/packages/store/src/structure/Store.ts +2 -2
- package/packages/ui/src/index.ts +8 -2
- package/packages/ui/src/lib/float.ts +29 -17
- package/packages/ui/src/lib/matrix.ts +27 -0
- package/packages/ui/src/lib/slideshowAnimations.ts +2 -1
- package/packages/ui/src/lib/toCSS.ts +8 -4
- package/packages/ui/src/structure/Accordion.ts +5 -5
- package/packages/ui/src/structure/Badge.ts +9 -12
- package/packages/ui/src/structure/Button.ts +8 -3
- package/packages/ui/src/structure/Card.ts +33 -11
- package/packages/ui/src/structure/Carousel.ts +462 -0
- package/packages/ui/src/structure/Combobox/Combobox.ts +54 -46
- package/packages/ui/src/structure/Combobox/ComboboxChips.ts +122 -67
- package/packages/ui/src/structure/Combobox/ComboboxList.ts +56 -42
- package/packages/ui/src/structure/Container.ts +25 -0
- package/packages/ui/src/structure/ContextMenu.ts +150 -36
- package/packages/ui/src/structure/DescriptionList.ts +6 -5
- package/packages/ui/src/structure/Field.ts +35 -9
- package/packages/ui/src/structure/Icon.ts +17 -4
- package/packages/ui/src/structure/Input.ts +2 -2
- package/packages/ui/src/structure/Progress.ts +72 -0
- package/packages/ui/src/structure/Radio.ts +5 -6
- package/packages/ui/src/structure/Searchbar.ts +209 -0
- package/packages/ui/src/structure/Select/Select.ts +22 -30
- package/packages/ui/src/structure/Select/SelectArrow.ts +2 -2
- package/packages/ui/src/structure/Select/SelectContent.ts +24 -5
- package/packages/ui/src/structure/Select/SelectItem.ts +33 -62
- package/packages/ui/src/structure/Select/SelectTrigger.ts +27 -7
- package/packages/ui/src/structure/Select/SelectValue.ts +7 -7
- package/packages/ui/src/structure/Slide.ts +7 -1
- package/packages/ui/src/structure/Slideshow.ts +11 -6
- package/packages/ui/src/structure/Switch.ts +4 -2
- package/packages/ui/src/structure/Tabs.ts +26 -26
- package/packages/ui/src/structure/TextArea.ts +22 -0
- package/packages/ui/src/structure/TextBlock.ts +18 -0
- package/packages/ui/src/structure/Toast.ts +101 -0
- package/packages/ui/src/structure/Toggle.ts +6 -6
- package/packages/ui/src/structure/Waterfall.ts +60 -24
- package/packages/ui/src/style/content_style.ts +4 -5
- package/packages/ui/src/style/input_style.ts +16 -2
- package/packages/utils/package.json +2 -1
- package/packages/utils/src/index.bun.ts +2 -2
- package/packages/utils/src/index.ts +3 -2
- package/packages/utils/src/lib/array.ts +1 -0
- package/packages/utils/src/lib/call.ts +1 -0
- package/packages/utils/src/lib/camelToDashedStyle.ts +1 -0
- package/packages/utils/src/lib/debounce.ts +18 -0
- package/packages/utils/src/lib/forEach.ts +25 -0
- package/packages/utils/src/lib/isEqual.ts +30 -0
- package/packages/utils/src/lib/json.ts +2 -0
- package/packages/utils/src/lib/map.ts +11 -0
- package/packages/utils/src/lib/match.ts +28 -0
- package/packages/utils/src/lib/merge.ts +12 -0
- package/packages/utils/src/lib/object.ts +3 -0
- package/packages/utils/src/lib/primitive.ts +2 -0
- package/packages/utils/src/lib/randstr.ts +13 -0
- package/packages/utils/src/lib/remove.ts +1 -0
- package/packages/utils/src/lib/sleep.ts +1 -0
- package/packages/utils/src/lib/toArray.ts +3 -0
- package/packages/utils/src/lib/trycatch.ts +17 -0
- package/packages/utils/src/lib/tuple.ts +1 -0
- package/packages/utils/src/lib/type.ts +16 -0
- package/packages/utils/src/lib/uppercase.ts +7 -0
- package/packages/utils/src/lib/url.ts +7 -0
- package/packages/utils/src/lib/utils.ts +21 -152
- package/packages/utils/src/structure/UID.ts +2 -2
- package/packages/widget/src/index.ts +4 -4
- package/packages/widget/src/structure/Widget.ts +6 -3
- package/tsconfig.json +1 -0
- package/packages/ui/src/structure/WaterfallItem.ts +0 -21
package/build/ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e,i,s,o,r,n,a,c,l,h=Object.defineProperty,d=t=>{throw TypeError(t)},u=(t,e,i)=>((t,e,i)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),p=(t,e,i)=>e.has(t)||d("Cannot "+i),g=(t,e,i)=>(p(t,e,"read from private field"),i?i.call(t):e.get(t)),b=(t,e,i)=>e.has(t)?d("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),m=(t,e,i,s)=>(p(t,e,"write to private field"),s?s.call(t,i):e.set(t,i),i);import{onclient as v,ElementProto as f,TextProto as x,Proto as k,ProxyProto as w}from"@amateras/core";import{_null as y,is as M,UID as I,forEach as z,_Object_entries as D,isObject as C,_instanceof as S,isUndefined as A,isEqual as O,_Object_assign as W,isNull as L,isString as E,_Array_from as H}from"@amateras/utils";const R=t=>(e,i,s)=>{if(e.slide=i,!v())return;let o=i.toDOM();e.node?.append(...o);let r={duration:t?.duration??500,easing:t?.easing??"ease"},n=$.match(t?.direction,t=>t.case("up",()=>[["0 100%","0 0"],["0 0","0 -100%"]]).case("down",()=>[["0 -100%","0 0"],["0 0","0 100%"]]).case("left",()=>[["100% 0","0 0"],["0 0","-100% 0"]]).case("right",()=>[["-100% 0","0 0"],["0 0","100% 0"]]).default(()=>[["100% 0","0 0"],["0 0","-100% 0"]]));i.node?.animate({translate:n[0]},r);const a=s?.node?.animate({translate:n[1]},r);a&&(a.onfinish=()=>s?.node?.remove())},T=class extends f{constructor(t,e){super("slide",t,e)}};$.style(T,"slide{display:block;height:100%;width:100%;position:absolute}");let B=T;const F=class extends f{constructor({index:i,interval:s,autoplay:o,autopause:r,animation:n,...a},c){super("slideshow",a,c),u(this,"slide",y),u(this,"index"),u(this,"timer",y),u(this,"interval"),u(this,"autoplay"),u(this,"autopause"),u(this,"animation"),b(this,t,0),b(this,e,y),u(this,"playing",!1),this.index=i??0,this.interval=s??5,this.autoplay=o??!1,this.autopause=r??!0,this.animation=n??y,this.listen("dispose",()=>this.pause()),this.listen("dom",()=>{this.autoplay&&this.play()})}build(){return super.build(),this.switch(this.index),this}toString(){return this.parseHTML({children:this.slide?.toString()})}toDOM(t=!0){return super.toDOM(!1),this.node&&!g(this,e)&&(m(this,e,new ResizeObserver(()=>{this.autopause&&(this.inDOM()?this.play():this.pause())})),g(this,e).observe(this.node)),t&&this.slide&&this.node?.append(...this.slide.toDOM()),[this.node]}play(){this.playing||(this.playing=!0,this.timer=setInterval(()=>{var e,i,s,o;(e=this,i=t,{set _(t){m(e,i,t,s)},get _(){return g(e,i,o)}})._++,g(this,t)>=100*this.interval&&(this.next(),m(this,t,0))},10))}pause(){this.playing=!1,this.timer&&clearTimeout(this.timer)}next(){let t=this.children.length,e=this.index+1;e>=t&&(e=0),this.switch(e)}prev(){let t=this.children.length,e=this.index-1;e<=0&&(e=t-1),this.switch(e)}switch(t){this.index=t;let e=this.children.at(t);this.slide!==e&&e&&(this.animation?this.animation(this,e,this.slide):(this.append(e),this.slide=e,this.node?.replaceChildren(...e.toDOM())),e.node?.dispatchEvent(new Event("showslide")))}};t=new WeakMap,e=new WeakMap,$.style(F,"slideshow{display:block;position:relative;overflow:clip}");let _=F;const j=class extends f{value;constructor({value:t,...e},i){super("radio-group",e,i),this.value=t,this.on("input",t=>{this.value=M(t.target,HTMLInputElement)?.value})}};$.style(j,"radio-group{display:block}");let N=j;const U=class extends f{inputId;name;value;constructor({inputId:t,name:e,value:i,...s},o){super("radio-item",s,o),this.inputId=t??`input-${I.persistInProto(this,"radio-item")}`,this.name=e??y,this.value=i}};$.style(U,"radio-item{display:block}");let P=U;class Y extends f{constructor(t,e){super("input",{type:"radio",...t},e)}build(t){let e=this.findAbove(t=>M(t,P));return e&&(this.attr("id",e.inputId),this.attr("name",e.name)),super.build(t)}}class q extends f{constructor(t,e){super("label",t,e)}build(t){let e=this.findAbove(t=>M(t,P));return e&&this.attr("for",e.inputId),super.build(t)}}const[G,X,Z,J,K]=["accordion","accordion-item","accordion-trigger","accordion-content","accordion-container"],Q=class extends f{$trigger=y;$container=y;constructor(t,e){super(G,t,e)}open(){this.attr("opened","")}close(){this.attr("opened",null)}switch(){""===this.attr("opened")?this.close():this.open()}};$.style(Q,[`${G},${X},${Z}{display:block}`,`${K}{display:grid;grid-template-rows:0fr}`,`${G}[opened] ${K}{grid-template-rows:1fr}`,`${J}{overflow:hidden}`]);let V=Q;class tt extends f{constructor(t,e){super(K,t,e)}build(t){let e=this.findAbove(t=>M(t,V));return e&&(e.$container=this),super.build(t)}}class et extends f{constructor(t,e){super(J,t,e)}}class it extends f{constructor(t,e){super(Z,t,e)}build(t){let e=this.findAbove(t=>M(t,V));return e&&(e.$trigger=this,this.on("click",()=>e.switch())),super.build(t)}}const st=class extends f{gap;columns;size;observer=null;constructor({gap:t,columns:e,autosize:i,size:s,...o},r){super("waterfall",o,r),this.gap=t??0,this.columns=e??1,this.size=s??0,v()&&(this.observer=new ResizeObserver(()=>{this.inDOM()&&requestAnimationFrame(()=>this.refresh())}))}toDOM(t=!0){return super.toDOM(t),this.node&&this.observer?.observe(this.node),[this.node]}refresh(){if(!this.node)return;const t=[],e=this.node.offsetWidth;let i=this.columns;this.size&&(i=Math.trunc(e/(this.size+this.gap))||1);const s=(e-this.gap*(i-1))/i;for(let o=0;o<i;o++)t.push({items:[],height:0,width:s,left:o*(s+this.gap)});z(this.children,e=>{if(!e.node)return;e.ratio||e.node.offsetHeight&&e.node.offsetWidth&&(e.ratio=e.node.offsetWidth/e.node.offsetHeight);const i=s/e.ratio,o=t.sort((t,e)=>t.height-e.height)[0];e.style({height:`${i}px`,width:`${s}px`,top:`${o.height}px`,left:`${o.left}px`}),o.height+=i+this.gap})}mutate(){this.refresh()}};$.style(st,"waterfall{display:block;position:relative;min-height:100dvh}");let ot=st;const rt=class extends f{ratio=0;constructor(t,e){super("waterfall-item",t,e)}toDOM(t=!0){super.toDOM(t);const e=this.findAbove(t=>M(t,ot));return this.node?.querySelectorAll("img").forEach(t=>e?.observer?.observe(t)),[this.node]}};$.style(rt,"waterfall-item{display:block;position:absolute}");let nt=rt;const at=class extends f{targetId;$container=y;triggers=/* @__PURE__ */new Map;constructor({targetId:t,...e},i){super("tabs",e,i),this.targetId=t??y}switch(t){this.targetId!==t&&(this.targetId=t,this.$container?.renderContent())}};$.style(at,"tabs{display:block;}");let ct=at;class lt extends f{tabId;tabs=y;constructor({tabId:t,...e},i){super("tab-trigger",e,i),this.tabId=t,this.on("click",()=>this.tabs?.switch(this.tabId))}build(t){return super.build(t),this.tabs=this.findAbove(t=>M(t,ct)),this.tabs?.triggers.set(this.tabId,this),this}}$.style(ct,"tab-trigger{cursor:pointer;}");class ht extends f{tabs=null;constructor({...t},e){super("tab-container",t,e)}build(t){return super.build(t),this.tabs=this.findAbove(t=>M(t,ct)),this.tabs&&(this.tabs.$container=this),this}toDOM(t=!0){return super.toDOM(!1),this.renderContent(t),[this.node]}toString(){return this.parseHTML({children:this.renderContent()?.toString()})}mutate(){this.renderContent()}getContent(t){return this.children.find(e=>e.tabId===t)}renderContent(t=!0){const e=this.tabs?.targetId,i=e?this.getContent(e):this.children.at(0);return t&&i&&(this.node?.replaceChildren(...i.toDOM()),this.tabs?.triggers.forEach(t=>{t.attr("active",t.tabId===i.tabId?"":y)})),i}}$.style(ct,"tab-container{display:block;}");class dt extends f{tabId;tabs=null;constructor({tabId:t,...e},i){super("tab-content",e,i),this.tabId=t}build(t){return super.build(t),this.tabs=this.findAbove(t=>M(t,ct)),this}}$.style(ct,"tab-content{display:block;}");const ut=(t,e)=>{let i=[];for(let[s,o]of D(e))C(o)?i.push(ut(s,o)):i.push(`${s.replaceAll(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}: ${o};`);return`${t} { ${i.join(" ")} }`},pt={position:"absolute",top:"0",left:"0",maxHeight:"50dvh",overflowY:"auto",display:"block",boxSizing:"border-box",border:"1px solid var(--input)",background:"oklch(from var(--bg) l c h)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",userSelect:"none",scrollbarWidth:"thin",scrollbarColor:"var(--input) transparent"},gt=class t extends f{$select=y;constructor(e,i){super(t.tagname,e,i)}build(t){return super.build(t),this.$select=this.findAbove(t=>S(t,wt)),this.$select&&(this.$select.$content=this),this}};u(gt,"tagname","select-content"),$.style(gt,ut(gt.tagname,pt));let bt=gt;const mt={display:"flex",gap:"calc(var(--spacing) * 1.25)",boxSizing:"border-box",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"500",lineHeight:"1","&:hover, :not(:has(select-item:hover)) &[focus]":{background:"oklch(from var(--input) l c h / .1)"},"&[focus]":{outline:"none"}},vt=class t extends f{constructor(e,s){super(t.tagname,{tabindex:0,...e},s),u(this,"$select",y),u(this,"$content",y),b(this,i,y),this.on("click",()=>{this.$select?.close(),this.select()}),this.on("keydown",e=>{let i=i=>{if(e.preventDefault(),!this.$content)return;let s=this.$content?.findBelowAll(e=>S(e,t)),o=s.indexOf(this),r="up"===i?o-1:o+1;(r<0||r>=s.length)&&(r="up"===i?-1:0);let n=s.at(r);n?.node?.focus()};switch(e.key){case"ArrowDown":i("down");break;case"ArrowUp":i("up");break;case" ":e.preventDefault()}}),this.on("keyup",t=>{switch(t.key){case"Escape":t.preventDefault(),this.$select?.close(),this.$select?.$trigger?.node?.focus();break;case" ":case"Enter":t.preventDefault(),this.select(),this.$select?.close(),this.$select?.$trigger?.node?.focus()}})}value(t){if(!arguments.length)return g(this,i);A(t)||$.resolve(t,t=>{m(this,i,t)})}select(){this.$select&&this.$select.value(this.value())}props({value:t,...e}){super.props(e),this.value(t)}build(t){return super.build(t),this.$select=this.findAbove(t=>S(t,wt)),this.$content=this.findAbove(t=>S(t,bt)),this.$select&&this.$select.value()===g(this,i)&&(this.$select.selected=this),this.$select?.itemMap.set(g(this,i),this),this}};i=new WeakMap,u(vt,"tagname","select-item"),$.style(vt,ut(vt.tagname,mt));let ft=vt;const $t=(t,e,i)=>{let s={top:0,left:0,height:0,width:0},o=new ResizeObserver(()=>xt(t,e,s)),r=()=>xt(t,e,s);return o.observe(t),window.addEventListener("resize",r),()=>{o.disconnect(),window.removeEventListener("resize",r)}},xt=(t,{style:e},i)=>{let s=t.getBoundingClientRect(),o={top:s.top+window.scrollY,left:s.left+window.scrollX,width:s.width,height:s.height},{top:r,left:n,width:a,height:c}=o;O(i,o,["top","left","height","width"])||(W(i,{top:r,left:n,width:a,height:c}),e.top=`${c+r}px`,e.left=`${n}px`,e.width=`${a}px`)},kt=class t extends f{constructor(e,i){super(t.tagname,e,i),u(this,"$trigger",y),u(this,"$content",y),u(this,"clickListener",y),b(this,s,y),u(this,"selected",y),u(this,"itemMap",/* @__PURE__ */new Map),u(this,"$value",y),u(this,"disconnect",y),this.listen("i18nupdate",()=>this.$value?.render())}props({value:t,disabled:e,...i}){super.props(i),this.disabled(e),this.value(t)}disabled(t){if(!arguments.length)return""===this.attr("disabled");A(t)||$.resolve(t,t=>{this.attr("disabled",t?"":y)})}value(t){if(!arguments.length)return g(this,s);A(t)||($.resolve(t,t=>{m(this,s,t);let e=this.itemMap.get(t);this.selected=e??y,this.$value?.render(),this.dispatch("selectvalue",[this,t],{bubbles:!0})}),this.node?.dispatchEvent(new Event("select-value")))}open(){this.attr("opened",""),v()&&this.$content&&(this.disconnect=$t(this.$trigger?.node,this.$content.node),document.body.append(...this.$content.toDOM()),this.clickListener=t=>{t.target!==this.$trigger?.node&&(t.target&&this.$content?.node?.contains(t.target)||this.close())},this.selected?.node?this.selected.node.focus():this.$content?.findBelow(t=>S(t,ft))?.node?.focus(),window.addEventListener("click",this.clickListener))}close(){this.attr("opened",y),v()&&(this.$content?.removeNode(),this.clickListener&&window.removeEventListener("click",this.clickListener),this.disconnect?.(),this.disconnect=y)}toDOM(t=!0){return super.toDOM(!1),t&&this.$trigger&&(this.node?.append(...this.$trigger.toDOM()),this.$content?.toDOM(),this.$value?.render()),[this.node]}toString(){let t=this.$trigger?.toString()??"";return this.parseHTML({children:t})}};s=new WeakMap,u(kt,"tagname","select-proto"),$.style(kt,ut(kt.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let wt=kt;const yt=class t extends f{$select=y;constructor(e,i){super(t.tagname,{tabindex:0,...e},i),this.on("click",t=>L(this.$select?.attr("opened"))?this.$select.open():this.$select?.close()),this.on("keydown",t=>{if(" "===t.key)t.preventDefault()}),this.on("keyup",t=>{switch(t.key){case" ":case"Enter":t.preventDefault(),this.$select?.open()}})}build(t){return super.build(t),this.$select=this.findAbove(t=>S(t,wt)),this.$select&&(this.$select.$trigger=this),this}};u(yt,"tagname","select-trigger"),$.style(yt,ut(yt.tagname,{display:"flex",gap:"0.5rem",placeContent:"space-between",placeItems:"center",boxSizing:"border-box",border:"1px solid var(--input)",background:"color-mix(in oklch, var(--input) 30%, transparent)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",lineHeight:"1","&:hover":{background:"color-mix(in oklch, var(--input) 50%, transparent)"},"&:focus":{outline:"0.1rem solid var(--border)"},"*":{pointerEvents:"none"}}));let Mt=yt;class It extends f{static tagname="select-value";$select=y;$placeholder=y;$text=new x("");constructor(t,e){super(It.tagname,t,e)}props({placeholder:t,...e}){super.props(e),this.placeholder(t??y)}build(t){return super.build(t),this.$select=this.findAbove(t=>S(t,wt)),this.$select&&(this.$select.$value=this),this}placeholder(t){$.resolve(t,t=>{E(t)?$.context(k,this,()=>this.$placeholder=new x(t)):this.$placeholder=t,this.render()})}render(){let t=y;this.$select?.selected?(t=this.$text,this.$text.content=this.$select.selected.text):this.$placeholder&&(t=this.$placeholder),t&&(t.builded||t.build(),this.replaceProtos(t),this.node?.replaceChildren(...t.toDOM()))}}class zt extends f{constructor(t,e){super("selector-group",t,e)}}const Dt=class t extends f{constructor(e,i){super(t.tagname,e,i)}props({svg:t,...e}){super.props(e),this.svg(t)}svg(t){$.resolve(t,t=>{this.innerHTML(t)})}};u(Dt,"tagname","icon"),$.style(Dt,ut(Dt.tagname,{display:"inline-block",verticalAlign:"middle",height:"1rem",width:"1rem",svg:{display:"block",height:"auto",width:"100%"}}));let Ct=Dt;const St=class extends Ct{constructor(t){super({svg:'<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-chevron-down-icon lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>',...t})}};$.style(St,ut(`select-proto[opened] ${St.tagname}`,{rotate:"180deg"}));let At=St;const Ot="@media (hover: hover) and (pointer: fine)",Wt=class extends f{constructor(t,e){super("button",{ui:"button",...t},e)}};u(Wt,"tagname","button"),$.style(Wt,ut('button[ui="button"]',{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",lineHeight:"1rem",transition:"0.2s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",userSelect:"none",gap:"calc(var(--spacing) * 2.5)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"&:not([disabled]):active":{translate:"0 0.125rem"},[Ot]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)",[Ot]:{"&:not([disabled]):hover":{background:"oklch(from var(--primary-bg) l c h / .8)"}}},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)",[Ot]:{"&:not([disabled]):hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)",[Ot]:{"&:not([disabled]):hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)",[Ot]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)"}}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)",[Ot]:{"&:not([disabled]):hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}}},'&[size="icon"]':{width:"calc(var(--spacing) * 8)",padding:"0"},'&[size="xs"]':{padding:"calc(var(--spacing) * 2)",fontSize:"var(--text-xs)",lineHeight:"var(--text-xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",padding:"0",svg:{width:"calc(var(--spacing) * 3)",height:"calc(var(--spacing) * 3)"}},'&[size="sm"]':{height:"calc(var(--spacing) * 7)"},'&[size="icon-sm"]':{width:"calc(var(--spacing) * 7)",height:"calc(var(--spacing) * 7)",padding:"0"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)",padding:"0"},"&[disabled]":{opacity:".5"}}));let Lt=Wt;const Et=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Et,"tagname","badge"),$.style(Et,ut(Et.tagname,{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2)",borderRadius:"calc(var(--radius) * 2.6)",height:"calc(var(--spacing) * 5)",lineHeight:"var(--text-xs)",transition:"0.2s all ease",fontSize:"var(--text-xs)",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",whiteSpace:"nowrap",gap:"var(--spacing)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"a:not([disabled]) &:hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h / 1)"},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)","a:not([disabled]) &:hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)","a:not([disabled]) &:hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","a:not([disabled]) &:hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","a:not([disabled]) &:hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}},'&[size="sm"]':{padding:"0 calc(var(--spacing) * 1)",fontSize:"var(--text-xs2)",lineHeight:"var(--text-xs2)",height:"calc(var(--spacing) * 4)"},"a[disabled] &":{opacity:".5"}}));let Ht=Et;const Rt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Rt,"tagname","card"),$.style(Rt,ut(Rt.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing))",paddingBlock:"calc(var(--spacing) * 4)",background:"var(--secondary-bg)",borderRadius:"calc(var(--radius) * 1.4)"}));let Tt=Rt;const Bt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Bt,"tagname","card-header"),$.style(Bt,ut(Bt.tagname,{display:"flex",width:"100%",flexDirection:"column",gap:"var(--spacing)",paddingInline:"calc(var(--spacing) * 4)"}));let Ft=Bt;const _t=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(_t,"tagname","card-content"),$.style(_t,ut(_t.tagname,{display:"block",paddingInline:"calc(var(--spacing) * 4)"}));let jt=_t;const Nt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Nt,"tagname","h3"),$.style(Nt,ut(`card ${Nt.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"1.375",fontSize:"var(--text-base)",color:"var(--fg)"}));let Ut=Nt;const Pt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Pt,"tagname","p"),$.style(Pt,ut(`card ${Pt.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"var(--line-height-sm)",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Yt=Pt;const qt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(qt,"tagname","dl"),$.style(qt,ut(qt.tagname,{display:"flex",flexDirection:"column"}));let Gt=qt;const Xt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Xt,"tagname","dc"),$.style(Xt,ut(Xt.tagname,{paddingBlock:"1rem",borderBottom:"1px solid color-mix(in oklch, var(--input) 50%, transparent)","&:last-child":{borderBottom:"none"}}));let Zt=Xt;const Jt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Jt,"tagname","dt"),$.style(Jt,ut(Jt.tagname,{fontSize:"var(--text-sm)",fontWeight:"var(--font-weight-medium)"}));let Kt=Jt;const Qt=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(Qt,"tagname","dd"),$.style(Qt,ut(Qt.tagname,{margin:"0",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Vt=Qt;const te=class t extends f{clickListener=y;constructor(e,i){super(t.tagname,e,i)}open(t){v()&&(this.build(),this.style({top:`${t.y}px`,left:`${t.x}px`}),this.clickListener=t=>{t.target!==this.node&&(t.target&&this.node?.contains(t.target)||this.close())},setTimeout(()=>window.addEventListener("click",this.clickListener),1),document.body.append(...this.toDOM()))}close(t=!0){this.removeNode(),this.clickListener&&window.removeEventListener("click",this.clickListener),this.clickListener=y,t&&this.dispose()}};u(te,"tagname","context-menu"),$.style(te,ut(te.tagname,{display:"block",position:"fixed",top:"0",left:"0",maxHeight:"50dvh",overflowY:"auto",boxSizing:"border-box",border:"1px solid var(--input)",background:"oklch(from var(--bg) l c h)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",userSelect:"none",scrollbarWidth:"thin",scrollbarColor:"var(--input) transparent"}));let ee=te;const ie=class t extends f{$menu=y;constructor(e,i){super(t.tagname,e,i),this.on("click",()=>this.$menu?.close())}build(t){return super.build(t),this.$menu=this.findAbove(t=>S(t,ee)),this}};u(ie,"tagname","context-menu-item"),$.style(ie,ut(ie.tagname,{display:"block",boxSizing:"border-box",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"500",lineHeight:"1","&:hover, :not(:has(select-item:hover)) &:focus":{background:"oklch(from var(--input) l c h / .1)"},"&:focus":{outline:"none"}}));let se=ie;const oe={borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",transition:"0.2s all ease",fontFamily:"inherit",fontSize:"var(--text-sm)",padding:"0 calc(var(--spacing) * 2.5)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)",outline:"0.2rem solid transparent","&:focus-visible":{outlineColor:"var(--border)"}},re=class t extends f{constructor(e,i){super(t.tagname,{ui:"input",...e},i)}};u(re,"tagname","input"),$.style(re,ut('input[ui="input"]',{...oe}));let ne=re;const ae=class t extends f{constructor(e,i){super(t.tagname,e,i)}props({for:t,...e}){super.props(e),this.for(t)}build(t){return super.build(t),this.setFor(),this}for(t){if(!arguments.length)return this.attr("for");A(t)||$.resolve(t,t=>{this.attr("for",t),this.setFor()})}setFor(){const t=this.for();this.findBelow(e=>{S(e,f)&&("input"===e.tagname&&e.attr("id",t),"label"===e.tagname&&e.attr("for",t))})}};u(ae,"tagname","field"),$.style(ae,ut(ae.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing) * 2)",width:"100%",'&[direction="horizontal"]':{flexDirection:"row",placeItems:"center",width:"unset"}}));let ce=ae;const le=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(le,"tagname","label"),$.style(le,ut(le.tagname,{"field &":{display:"block",userSelect:"none",color:"var(--fg)",fontWeight:"var(--font-weight-medium)",fontSize:"var(--text-sm)",lineHeight:"var(--text-sm)",flexShrink:"0"},"field[disabled] &":{pointerEvents:"none"}}));let he=le;const de=class t extends f{constructor(e,i){super(t.tagname,e,i)}};u(de,"tagname","field-description"),$.style(de,ut(de.tagname,{"field &":{display:"block",color:"var(--muted)",fontWeight:"var(--font-weight-medium)",fontSize:"var(--text-sm)"},"field[disabled] &":{pointerEvents:"none"}}));let ue=de;const pe=class extends f{constructor(t,e){super("input",{type:"checkbox",ui:"switch",...t},e)}};u(pe,"tagname","input"),$.style(pe,ut('input[ui="switch"]',{appearance:"none",display:"inline-flex",height:"calc(var(--spacing) * 5)",width:"calc(var(--spacing) * 9)",background:"color-mix(in oklab, var(--input) 80%, transparent)",border:"none",placeItems:"center",borderRadius:"calc(var(--spacing) * 5)",transition:"all .3s ease",padding:"0","&::after":{content:'""',display:"block",height:"calc(var(--spacing) * 5)",width:"calc(var(--spacing) * 5)",background:"var(--fg)",borderRadius:"var(--radius-round)",transition:"all .3s ease"},"&:checked":{background:"var(--primary-bg)","&::after":{height:"calc(var(--spacing) * 4.5)",width:"calc(var(--spacing) * 4.5)",translate:"calc(115% - var(--spacing)) 0",background:"var(--bg)"}}}));let ge=pe;const be=class extends f{constructor(t,e){super("button",{ui:"toggle",...t},e),this.on("click",t=>this.checked(!this.checked()))}props({checked:t,...e}){super.props(e),this.checked(t)}checked(t){if(!arguments.length)return!L(this.attr("checked"));A(t)||$.resolve(t,t=>{this.attr("checked",t?"":y),this.node?.dispatchEvent(new Event("input"))})}};u(be,"tagname","button"),$.style(be,ut('button[ui="toggle"]',{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",lineHeight:"1rem",transition:"0.1s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",userSelect:"none",gap:"calc(var(--spacing) * 2.5)",flexShrink:"0",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .8)",[Ot]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h)"}},"&[checked]":{color:"oklch(from var(--primary-fg) l c h)",background:"oklch(from var(--primary-bg) l c h / .8)",[Ot]:{"&:not([disabled]):hover":{background:"oklch(from var(--primary-bg) l c h)",color:"oklch(from var(--primary-fg) l c h)"}}},'&[variant="primary"]':{"&[checked]":{color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"}},'&[variant="secondary"]':{"&[checked]":{color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)"}},'&[variant="destructive"]':{"&[checked]":{color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&[checked]":{color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)"}},'&[size="icon"]':{width:"calc(var(--spacing) * 8)",padding:"0"},'&[size="xs"]':{padding:"calc(var(--spacing) * 2)",fontSize:"var(--text-xs)",lineHeight:"var(--text-xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",padding:"0",svg:{width:"calc(var(--spacing) * 3)",height:"calc(var(--spacing) * 3)"}},'&[size="sm"]':{height:"calc(var(--spacing) * 7)"},'&[size="icon-sm"]':{width:"calc(var(--spacing) * 7)",height:"calc(var(--spacing) * 7)",padding:"0"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)",padding:"0"},"&[disabled]":{opacity:".5"}}));let me=be;class ve extends f{$combobox=y;$focusedItem=y;$createItem=y;virtual=!0;constructor(t,e){super("combobox-list",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>S(t,ye)),this.$combobox&&(this.$combobox.$list=this),this}filter(t){if(!this.$combobox)return;const e=[];this.$createItem&&(this.$createItem.visible=!!t.trim()&&!this.$combobox.itemMap.has(t.trim())),z(this.$combobox.itemMap,([i,s])=>{s.visible=!1,s.text.toLowerCase().includes(t.toLowerCase())&&(s.visible=!0,e.push(s))}),this.$combobox?.$content?.$empty&&(this.$combobox.$content.$empty.visible=!this.$createItem?.visible&&!e.length),this.$combobox.$content?.toDOM()}switch(t){const e=this.$focusedItem,i=this.children,s=e?i.indexOf(e):"up"===t?0:-1;let o="up"===t?s-1:s+1;(o<0||o>=i.length)&&(o="up"===t?-1:0),this.focus(o)}focus(t){let e=this.children.at(t);this.$focusedItem?.blur(),e?.focus()}focusFirstItem(){this.$createItem?.visible&&this.children[1]?this.focus(1):this.focus(0)}}const fe=class extends f{constructor(t,e){super("combobox-item",t,()=>{e?e(this):$([g(this,r)]),$(Ct,{ui:"combobox-item-check",svg:'<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-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>'})}),u(this,"$combobox",y),u(this,"$list",y),b(this,o,y),b(this,r,""),b(this,n,!1),this.on("mousedown",t=>t.preventDefault()),this.on("click",()=>{this.$combobox?.select(g(this,o),!this.selected())})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>S(t,ye)),this.$list=this.findAbove(t=>S(t,ve)),this.$combobox?.itemMap.set(g(this,o),this),this}props({value:t,label:e,selected:i,...s}){super.props(s),this.value(t),this.label(e),this.selected(i)}value(t){if(!arguments.length)return g(this,o);A(t)||$.resolve(t,t=>{this.$combobox?.itemMap.delete(g(this,o)),this.$combobox?.itemMap.set(t,this),m(this,o,t)})}label(t){if(!arguments.length)return g(this,r);A(t)||$.resolve(t,t=>{m(this,r,t)})}selected(t){if(!arguments.length)return g(this,n);A(t)||$.resolve(t,t=>{m(this,n,t),this.attr("selected",t?"":null)})}focus(){this.attr("focus",""),this.$list&&(this.$list.$focusedItem=this)}blur(){this.attr("focus",y),this.$list&&(this.$list.$focusedItem=null)}};o=new WeakMap,r=new WeakMap,n=new WeakMap,u(fe,"tagname","combobox-item"),$.style(fe,ut(fe.tagname,{...mt,'icon[ui="combobox-item-check"]':{visibility:"hidden",marginInlineStart:"auto"},'&[selected] icon[ui="combobox-item-check"]':{visibility:"visible"}}));let $e=fe;const xe=class extends f{$combobox=y;$list=y;constructor(t,e){super("combobox-create-item",t,e),this.on("mousedown",t=>t.preventDefault())}build(t){return super.build(t),this.$combobox=this.findAbove(t=>S(t,ye)),this.$list=this.findAbove(t=>S(t,ve)),this.$list&&(this.$list.$createItem=this),this}focus(){this.attr("focus",""),this.$list&&(this.$list.$focusedItem=this)}blur(){this.attr("focus",y),this.$list&&(this.$list.$focusedItem=null)}};u(xe,"tagname","combobox-create-item"),$.style(xe,ut(xe.tagname,mt));let ke=xe;const we=class extends f{constructor(t,e){super("combobox",t,e),u(this,"$trigger",y),u(this,"$content",y),u(this,"$list",y),u(this,"$chips",y),u(this,"$input",y),u(this,"itemMap",/* @__PURE__ */new Map),b(this,a,/* @__PURE__ */new Set),u(this,"disconnect",y)}build(t){return super.build(t),z(g(this,a),t=>this.select(t)),this}toDOM(t=!0){return super.toDOM(!1),t&&this.$trigger&&(this.node?.append(...this.$trigger.toDOM()),this.$content?.toDOM()),[this.node]}props({values:t,...e}){super.props(e),this.values(t)}open(){this.attr("opened",""),v()&&this.$content&&(this.disconnect=$t(this.$trigger?.node,this.$content.node),document.body.append(...this.$content.toDOM()),this.$input&&this.$list?.filter(this.$input.node?.value??""))}close(){this.attr("opened",y),v()&&(this.$content?.removeNode(),this.disconnect?.(),this.disconnect=y)}select(t,e=!0){const i=this.itemMap.get(t);i&&(i.selected(e),e?(g(this,a).add(t),this.$chips?.appendChip(t),this.dispatch("combobox_select",[t])):(g(this,a).delete(t),this.$chips?.removeChip(t),this.dispatch("combobox_unselect",[t])),this.dispatch("combobox_input",[t]))}get selected(){return H(this.itemMap.values()).filter(t=>t.selected())}values(t){if(!arguments.length)return H(g(this,a));A(t)||$.resolve(t,t=>{m(this,a,new Set(t))})}};a=new WeakMap,u(we,"tagname","combobox"),$.style(we,ut(we.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let ye=we;const Me=class extends f{$combobox=y;constructor(t,e){super("combobox-trigger",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>S(t,ye)),this.$combobox&&(this.$combobox.$trigger=this),this}};u(Me,"tagname","combobox-trigger"),$.style(Me,ut(Me.tagname,{display:"flex",flexWrap:"wrap",columnGap:"calc(var(--spacing) * 1.25)",placeItems:"center",boxSizing:"border-box",border:"1px solid var(--input)",background:"color-mix(in oklch, var(--input) 30%, transparent)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",lineHeight:"1",padding:"0 calc(var(--spacing) * 1.25)","&:hover":{background:"color-mix(in oklch, var(--input) 50%, transparent)"},"&:focus-within":{outline:"0.1rem solid var(--border)"}}));let Ie=Me;const ze=class extends f{$combobox=y;constructor(t,e){super("input",{ui:"combobox-input",...t},e),this.on("focus",t=>L(this.$combobox?.attr("opened"))&&this.$combobox.open()),this.on("blur",t=>{this.$combobox?.close(),this.$combobox?.$chips?.$focusedChip?.blur()}),this.on("input",t=>{this.$combobox?.$list?.filter(t.currentTarget.value),this.$combobox?.$list?.focusFirstItem()}),this.on("keydown",t=>{switch(t.key){case"ArrowDown":return t.preventDefault(),void this.$combobox?.$list?.switch("down");case"ArrowUp":return t.preventDefault(),void this.$combobox?.$list?.switch("up");case"Backspace":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.visibleChildren.at(-1)?.delete());case"ArrowRight":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.switch("right"));case"ArrowLeft":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.switch("left"))}}),this.on("keyup",t=>{switch(t.key){case"Escape":return t.preventDefault(),this.$combobox?.close(),void this.$combobox?.$trigger?.node?.focus();case"Delete":{const t=this.$combobox?.$chips?.$focusedChip;return this.$combobox?.$chips?.switch("right"),void t?.delete()}case"Tab":case"Enter":{t.preventDefault();const e=this.$combobox?.$list?.$focusedItem;if(!e)return;return S(e,$e)?this.$combobox?.select(e.value()):this.dispatch("combobox_create",[t.currentTarget.value],{bubbles:!0}),t.currentTarget.value="",void this.$combobox?.$list?.filter("")}}t.currentTarget.value.length&&this.$combobox?.$chips?.$focusedChip?.blur()})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>S(t,ye)),this.$combobox&&(this.$combobox.$input=this),this}};$.style(ze,ut('input[ui="combobox-input"]',{border:"unset",background:"unset",color:"oklch(from var(--fg) l c h / .9)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",lineHeight:"1",height:"calc(var(--spacing) * 8)",flex:"1",minWidth:"2rem",padding:"0 calc(var(--spacing) * 1.25)","&:focus":{outline:"unset"}}));let De=ze;const Ce=class extends f{$combobox=y;$empty=y;constructor(t,e){super("combobox-content",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>S(t,ye)),this.$combobox&&(this.$combobox.$content=this),this}};u(Ce,"tagname","combobox-content"),$.style(Ce,ut(Ce.tagname,pt));let Se=Ce;const Ae=class extends f{$content=y;constructor(t,e){super("combobox-empty",t,e)}build(t){return super.build(t),this.$content=this.findAbove(t=>S(t,Se)),this.$content&&(this.$content.$empty=this),this}};u(Ae,"tagname","combobox-empty"),$.style(Ae,ut(Ae.tagname,{...mt}));let Oe=Ae;class We extends w{static tagname="combobox-chips";$combobox=y;chipMap=/* @__PURE__ */new Map;$focusedChip=y;constructor(t){super(t)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>S(t,ye)),this.$combobox&&(this.$combobox.$chips=this),this}appendChip(t){const e=this.$combobox?.itemMap.get(t);if(!e)throw"ComboboxChips.addChip: $item not found";const i=this.chipMap.get(t)??$(Ee,{value:t,label:e.label()});this.chipMap.set(t,i),this.protos.includes(i)||(this.append(i),i.builded||i.build(),this.node?.replaceWith(...this.toDOM()))}removeChip(t){const e=this.chipMap.get(t);if(!e)throw"ComboboxChips.removeChip: $chip not found";e.remove(),e.removeNode()}switch(t){const e=this.$focusedChip,i=this.children,s=e?i.indexOf(e):"left"===t?0:-1;let o="left"===t?s-1:s+1;(o<0||o>=i.length)&&(o="left"===t?-1:0),this.focus(o)}focus(t){let e=this.children.at(t);this.$focusedChip?.blur(),e?.focus()}}const Le=class extends f{constructor(t,e){super("combobox-chip",t,()=>{e?e(this):($([g(this,l)]),$(He))}),u(this,"$chips",y),b(this,c),b(this,l,"")}build(t){return super.build(t),this.$chips=this.findAbove(t=>S(t,We)),this}props({value:t,label:e,...i}){super.props(i),this.value(t),this.label(e)}value(t){if(!arguments.length)return g(this,c);A(t)||$.resolve(t,t=>{this.$chips?.chipMap.delete(t),this.$chips?.chipMap.set(t,this),m(this,c,t)})}label(t){if(!arguments.length)return g(this,l);A(t)||$.resolve(t,t=>{m(this,l,t)})}delete(){this.$chips?.$combobox?.select(g(this,c),!1)}focus(){this.attr("focus",""),this.$chips&&(this.$chips.$focusedChip=this)}blur(){this.attr("focus",y),this.$chips&&(this.$chips.$focusedChip=y)}};c=new WeakMap,l=new WeakMap,u(Le,"tagname","combobox-chip"),$.style(Le,ut(Le.tagname,{display:"inline-flex",placeItems:"center",fontSize:"var(--text-xs)",padding:"0 calc(var(--spacing) * 1.5)",background:"var(--secondary-bg)",borderRadius:"calc(var(--radius) * .6)",height:"calc(var(--spacing) * 5.25)",marginBlock:"calc(var(--spacing))","&[focus]":{outline:"2px solid var(--input)"},'button[ui="combobox-chip-remove"]':{background:"unset",border:"unset",color:"oklch(from var(--fg) l c h / .9)",paddingInlineStart:"calc(var(--spacing) * 1.5)",icon:{height:"calc(var(--spacing) * 3.25)",width:"calc(var(--spacing) * 3.25)"}}}));let Ee=Le;class He extends f{static tagname="button";$chip=y;constructor(t,e){super("button",{ui:"combobox-chip-remove",...t},()=>{e?e(this):$(Ct,{svg:'<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-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>'})}),this.on("click",()=>{this.$chip?.$chips?.$combobox?.select(this.$chip.value(),!1)})}build(t){return super.build(t),this.$chip=this.findAbove(t=>S(t,Ee)),this}}export{V as Accordion,tt as AccordionContainer,et as AccordionContent,it as AccordionTrigger,Ht as Badge,Lt as Button,Tt as Card,jt as CardContent,Yt as CardDescription,Ft as CardHeader,Ut as CardTitle,ye as Combobox,Ee as ComboboxChip,He as ComboboxChipRemoveButton,We as ComboboxChips,Se as ComboboxContent,ke as ComboboxCreateItem,Oe as ComboboxEmpty,De as ComboboxInput,$e as ComboboxItem,ve as ComboboxList,Ie as ComboboxTrigger,ee as ContextMenu,se as ContextMenuItem,Zt as DescriptionContent,Vt as DescriptionDetail,Gt as DescriptionList,Kt as DescriptionTerm,ce as Field,ue as FieldDescription,he as FieldLabel,Ct as Icon,ne as Input,q as Label,Y as Radio,N as RadioGroup,P as RadioItem,wt as Select,At as SelectArrow,bt as SelectContent,zt as SelectGroup,ft as SelectItem,Mt as SelectTrigger,It as SelectValue,B as Slide,_ as Slideshow,ge as Switch,dt as TabContent,lt as TabTrigger,ct as Tabs,ht as TabsContainer,me as Toggle,ot as Waterfall,nt as WaterfallItem,R as slideInOut};
|
|
1
|
+
var t,e,s,i,o,n,r,a,c,l,h,u,d,p=Object.defineProperty,g=t=>{throw TypeError(t)},b=(t,e,s)=>((t,e,s)=>e in t?p(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),m=(t,e,s)=>e.has(t)||g("Cannot "+s),v=(t,e,s)=>(m(t,e,"read from private field"),s?s.call(t):e.get(t)),f=(t,e,s)=>e.has(t)?g("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),x=(t,e,s,i)=>(m(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),y=(t,e,s,i)=>({set _(i){x(t,e,i,s)},get _(){return v(t,e,i)}});import{onclient as k,ElementProto as w,onserver as I,TextProto as N,ProxyProto as M}from"@amateras/core";import{Utils as z,UID as D}from"@amateras/utils";const C=t=>(e,s,i)=>{if(e.slide=s,!k())return;let o=s.toDOM();e.node?.append(...o);let n={duration:t?.duration??500,easing:t?.easing??"ease"},r=z.match(t?.direction,t=>t.case("up",()=>[["0 100%","0 0"],["0 0","0 -100%"]]).case("down",()=>[["0 -100%","0 0"],["0 0","0 100%"]]).case("left",()=>[["100% 0","0 0"],["0 0","-100% 0"]]).case("right",()=>[["-100% 0","0 0"],["0 0","100% 0"]]).default(()=>[["100% 0","0 0"],["0 0","-100% 0"]]));s.node?.animate({translate:r[0]},n);const a=i?.node?.animate({translate:r[1]},n);a&&(a.onfinish=()=>i?.node?.remove())},S=(t,e)=>`@layer ui { ${A(t,e)} }`,A=(t,e)=>{let s=[];for(let[i,o]of z.entries(e))z.isObject(o)?s.push(A(i,o)):s.push(`${z.camelToDashedStyle(i)}: ${o};`);return`${t} { ${s.join(" ")} }`},O=class extends w{constructor(t,e){super("slide",t,e)}};$.style(O,S("slide",{display:"block",height:"100%",width:"100%",position:"relative"}));let E=O;const W=class extends w{constructor({index:s,interval:i,autoplay:o,autopause:n,animation:r,...a},c){super("slideshow",a,c),b(this,"slide",z.Null),b(this,"index"),b(this,"timer",z.Null),b(this,"interval"),b(this,"autoplay"),b(this,"autopause"),b(this,"animation"),f(this,t,0),f(this,e,z.Null),b(this,"playing",!1),this.index=s??0,this.interval=i??5,this.autoplay=o??!1,this.autopause=n??!0,this.animation=r??z.Null,this.listen("dispose",()=>this.pause()),this.listen("dom",()=>{this.autoplay&&this.play()})}build(){return super.build(),this.switch(this.index),this}toString(){return this.parseHTML({children:this.slide?.toString()})}toDOM(t=!0){return super.toDOM(!1),this.node&&!v(this,e)&&(x(this,e,new ResizeObserver(()=>{this.autopause&&(this.inDOM()?this.play():this.pause())})),v(this,e).observe(this.node)),t&&this.slide&&this.node?.append(...this.slide.toDOM()),[this.node]}play(){this.playing||(this.playing=!0,this.timer=setInterval(()=>{y(this,t)._++,v(this,t)>=100*this.interval&&(this.next(),x(this,t,0))},10))}pause(){this.playing=!1,this.timer&&clearTimeout(this.timer)}next(){let t=this.children.length,e=this.index+1;e>=t&&(e=0),this.switch(e)}prev(){let t=this.children.length,e=this.index-1;e<=0&&(e=t-1),this.switch(e)}switch(t){this.index=t;let e=this.children.at(t);this.slide!==e&&e&&(this.animation?this.animation(this,e,this.slide):(this.append(e),this.slide=e,this.node?.replaceChildren(...e.toDOM())),e.node?.dispatchEvent(new Event("showslide")))}};t=new WeakMap,e=new WeakMap,$.style(W,S("slideshow",{display:"block",position:"relative",overflow:"clip"}));let R=W;const T=class extends w{value;constructor({value:t,...e},s){super("radio-group",e,s),this.value=t,this.on("input",t=>{this.value=z.is(t.target,HTMLInputElement)?.value})}};$.style(T,"radio-group{display:block}");let H=T;const L=class extends w{inputId;name;value;constructor({inputId:t,name:e,value:s,...i},o){super("radio-item",i,o),this.inputId=t??`input-${D.persistInProto(this,"radio-item")}`,this.name=e??z.Null,this.value=s}};$.style(L,"radio-item{display:block}");let B=L;class F extends w{constructor(t,e){super("input",{type:"radio",...t},e)}build(t){let e=this.findAbove(t=>z.is(t,B));return e&&(this.attr("id",e.inputId),this.attr("name",e.name)),super.build(t)}}class U extends w{constructor(t,e){super("label",t,e)}build(t){let e=this.findAbove(t=>z.is(t,B));return e&&this.attr("for",e.inputId),super.build(t)}}const[_,V,j,Y,q]=["accordion","accordion-item","accordion-trigger","accordion-content","accordion-container"],X=class extends w{$trigger=z.Null;$container=z.Null;constructor(t,e){super(_,t,e)}open(){this.attr("opened","")}close(){this.attr("opened",null)}switch(){""===this.attr("opened")?this.close():this.open()}};$.style(X,[`${_},${V},${j}{display:block}`,`${q}{display:grid;grid-template-rows:0fr}`,`${_}[opened] ${q}{grid-template-rows:1fr}`,`${Y}{overflow:hidden}`]);let P=X;class G extends w{constructor(t,e){super(q,t,e)}build(t){let e=this.findAbove(t=>z.is(t,P));return e&&(e.$container=this),super.build(t)}}class J extends w{constructor(t,e){super(Y,t,e)}}class K extends w{constructor(t,e){super(j,t,e)}build(t){let e=this.findAbove(t=>z.is(t,P));return e&&(e.$trigger=this,this.on("click",()=>e.switch())),super.build(t)}}const Q=class extends w{gap;columns;size;observer=null;constructor({gap:t,columns:e,autosize:s,size:i,...o},n){super("waterfall",o,n),this.gap=t??0,this.columns=e??1,this.size=i??0,k()&&(this.observer=new ResizeObserver(t=>{this.inDOM()&&requestAnimationFrame(()=>this.resize())})),this.listen("dom",t=>this.observer?.observe(t)),this.listen("waterfall_resize",()=>this.resize()),this.listen("mutate",()=>this.resize()),I()&&this.attr("style",`display: flex; flex-direction: column; gap: ${t}px`)}resize(){if(!this.node)return;const t=[],e=this.node.offsetWidth;let s=this.columns;this.size&&(s=Math.trunc(e/(this.size+this.gap))||1);const i=(e-this.gap*(s-1))/s;for(let o=0;o<s;o++)t.push({items:[],height:0,width:i,left:o*(i+this.gap)});z.forEach(this.children,e=>{if(!e.node)return;e.node.offsetHeight&&(e.height=e.node.offsetHeight);const s=t.sort((t,e)=>t.height-e.height)[0];e.style({width:`${i}px`,translate:`${s.left}px ${s.height}px`}),s.height+=e.height+this.gap}),this.style({height:`${t.sort((t,e)=>e.height-t.height)[0].height}px`})}};$.style(Q,S("waterfall",{display:"block",position:"relative"}));let Z=Q;const tt=class extends w{ratio=0;height=0;constructor(t,e){super("waterfall-item",t,e)}toDOM(t=!0){let e=super.toDOM(t);const s=this.findAbove(t=>z.is(t,Z));return this.node?.querySelectorAll("img").forEach(t=>s?.observer?.observe(t)),e}};$.style(tt,S("waterfall-item",{display:"block",position:k()?"absolute":"static"}));let et=tt;const st=class extends w{targetId;$container=z.Null;triggers=/* @__PURE__ */new Map;constructor({targetId:t,...e},s){super("tabs",e,s),this.targetId=t??z.Null}switch(t){this.targetId!==t&&(this.targetId=t,this.$container?.renderContent())}};$.style(st,S("tabs",{display:"block"}));let it=st;const ot=class extends w{tabId;tabs=z.Null;constructor({tabId:t,...e},s){super("tab-trigger",e,s),this.tabId=t,this.on("click",()=>this.tabs?.switch(this.tabId))}build(t){return super.build(t),this.tabs=this.findAbove(t=>z.is(t,it)),this.tabs?.triggers.set(this.tabId,this),this}};$.style(ot,S("tab-trigger",{cursor:"pointer"}));let nt=ot;const rt=class extends w{tabs=null;constructor({...t},e){super("tab-container",t,e)}build(t){return super.build(!1),this.tabs=this.findAbove(t=>z.is(t,it)),this.tabs&&(this.tabs.$container=this),this.renderContent(),this}toString(){return this.parseHTML({children:this.renderContent()?.toString()})}mutate(){this.renderContent()}getContent(t){return this.children.find(e=>e.tabId===t)}renderContent(){const t=this.tabs?.targetId,e=t?this.getContent(t):this.children.at(0);return e&&(e.builded||e.build(),this.node?.replaceChildren(...e.toDOM()),this.tabs?.triggers.forEach(t=>{t.attr("active",t.tabId===e.tabId?"":z.Null)})),e}};$.style(rt,S("tab-container",{display:"block"}));let at=rt;const ct=class extends w{tabId;tabs=null;virtual=!0;constructor({tabId:t,...e},s){super("tab-content",e,s),this.tabId=t}};$.style(ct,S("tab-content",{display:"block"}));let lt=ct;const ht={position:"absolute",maxHeight:"50dvh",overflowY:"auto",display:"flex",flexDirection:"column",boxSizing:"border-box",border:"1px solid var(--input)",background:"oklch(from var(--bg) l c h)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",userSelect:"none",scrollbarWidth:"thin",scrollbarColor:"var(--input) transparent"},ut=class t extends w{$select=z.Null;$focusedItem=z.Null;constructor(e,s){super(t.tagname,e,s)}build(t){return super.build(t),this.$select=this.findAbove(t=>z.isInstanceof(t,$t)),this.$select&&(this.$select.$content=this),this}switch(t){const e=this.$focusedItem,s=this.visibleChildren,i=e?s.indexOf(e):"up"===t?0:-1;let o="up"===t?i-1:i+1;(o<0||o>=s.length)&&(o="up"===t?-1:0),this.focus(o)}focus(t){let e=this.visibleChildren.at(t);this.$focusedItem?.blur(),e?.focus()}};b(ut,"tagname","select-content"),$.style(ut,S(ut.tagname,ht));let dt=ut;const pt={display:"flex",gap:"calc(var(--spacing) * 1.25)",boxSizing:"border-box",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"500",lineHeight:"1","&:hover, :not(:has(select-item:hover)) &[focus]":{background:"oklch(from var(--input) l c h / .1)"},"&[focus]":{outline:"none"}},gt=class t extends w{constructor(e,i){super(t.tagname,{tabindex:0,...e},i),b(this,"$select",z.Null),b(this,"$content",z.Null),f(this,s,z.Null),this.on("mousedown",t=>t.preventDefault()),this.on("click",()=>{this.$select?.close(),this.select()})}props({value:t,...e}){super.props(e),this.value(t)}build(t){return super.build(t),this.$select=this.findAbove(t=>z.isInstanceof(t,$t)),this.$content=this.findAbove(t=>z.isInstanceof(t,dt)),this.$select&&this.$select.value()===v(this,s)&&(this.$select.selected=this),this.$select?.itemMap.set(v(this,s),this),this}value(t){if(!arguments.length)return v(this,s);z.isUndefined(t)||$.resolve(t,t=>{x(this,s,t)})}select(){this.$select&&this.$select.value(this.value())}focus(t=!0){this.$content?.$focusedItem?.blur(),this.attr("focus","");const e=this.$content?.node;e&&e.scrollHeight>e.clientHeight&&this.node?.scrollIntoView({block:"nearest"}),this.$content&&(this.$content.$focusedItem=this)}blur(){this.attr("focus",z.Null),this.$content&&(this.$content.$focusedItem=null)}};s=new WeakMap,b(gt,"tagname","select-item"),$.style(gt,S(gt.tagname,pt));let bt=gt;const mt=(t,e,s)=>{let i={top:0,left:0,height:0,width:0,bottom:0},o=new ResizeObserver(()=>vt(t,e,i)),n=()=>vt(t,e,i);return o.observe(t),addEventListener("resize",n),vt(t,e,i),()=>{o.disconnect(),removeEventListener("resize",n)}},vt=(t,e,s)=>{let i=t.getBoundingClientRect(),o={top:i.top+i.height+scrollY,left:i.left,width:i.width,height:e.offsetHeight,bottom:innerHeight-i.top-scrollY},n=o.top+o.height>scrollY+innerHeight&&o.top-i.height-o.height>scrollY,{top:r,left:a,width:c,height:l,bottom:h}=o;z.isEqual(s,o,["top","left","height","width","bottom"])||(z.assign(s,{top:r,left:a,width:c,height:l,bottom:h}),n?(e.style.bottom=`${h}px`,e.style.top=""):(e.style.top=`${r}px`,e.style.bottom=""),e.style.left=`${a}px`,e.style.width=`${c}px`)},ft=class t extends w{constructor(e,s){super(t.tagname,e,s),b(this,"$trigger",z.Null),b(this,"$content",z.Null),f(this,i,z.Null),b(this,"selected",z.Null),b(this,"itemMap",/* @__PURE__ */new Map),b(this,"$value",z.Null),b(this,"disconnect",z.Null),f(this,o,!1),this.listen("i18nupdate",()=>this.$value?.render())}props({value:t,disabled:e,...s}){super.props(s),this.disabled(e),this.value(t)}disabled(t){if(!arguments.length)return""===this.attr("disabled");z.isUndefined(t)||$.resolve(t,t=>{this.attr("disabled",t?"":z.Null)})}value(t){if(!arguments.length)return v(this,i);z.isUndefined(t)||$.resolve(t,t=>{x(this,i,t);let e=this.itemMap.get(t);this.selected=e??z.Null,this.$value?.render(),this.dispatch("selectvalue",[this,t],{bubbles:!0})})}open(){this.attr("opened",""),k()&&this.$content&&(this.disconnect=mt(this.$trigger?.node,this.$content.node),document.body.append(...this.$content.toDOM()),this.selected?.focus())}close(){this.attr("opened",z.Null),k()&&(this.$content?.removeNode(),this.disconnect?.(),this.disconnect=z.Null)}toDOM(t=!0){const e=super.toDOM(!1);return!v(this,o)&&t&&this.$trigger&&(x(this,o,!0),this.node?.append(...this.$trigger.toDOM()),this.$content?.toDOM(),this.$value?.render()),e}toString(){let t=this.$trigger?.toString()??"";return this.parseHTML({children:t})}};i=new WeakMap,o=new WeakMap,b(ft,"tagname","select-proto"),$.style(ft,S(ft.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let $t=ft;const xt=class t extends w{$select=z.Null;constructor(e,s){super(t.tagname,{tabindex:0,...e},s),this.on("click",t=>z.isNull(this.$select?.attr("opened"))?this.$select.open():this.$select?.close()),this.on("blur",t=>this.$select?.close()),this.on("keydown",t=>{switch(t.key){case"ArrowDown":if(t.preventDefault(),!this.$select?.hasAttr("opened"))return this.$select?.open();this.$select?.$content?.switch("down");break;case"ArrowUp":if(t.preventDefault(),!this.$select?.hasAttr("opened"))return this.$select?.open();this.$select?.$content?.switch("up");break;case" ":t.preventDefault()}}),this.on("keyup",t=>{switch(t.key){case"Escape":t.preventDefault(),this.$select?.close();break;case" ":case"Enter":if(t.preventDefault(),!this.$select?.hasAttr("opened"))return this.$select?.open();this.$select?.$content?.$focusedItem?.select(),this.$select?.close()}})}build(t){return super.build(t),this.$select=this.findAbove(t=>z.isInstanceof(t,$t)),this.$select&&(this.$select.$trigger=this),this}};b(xt,"tagname","select-trigger"),$.style(xt,S(xt.tagname,{display:"flex",gap:"0.5rem",placeContent:"space-between",placeItems:"center",boxSizing:"border-box",border:"1px solid var(--input)",background:"color-mix(in oklch, var(--input) 30%, transparent)",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",lineHeight:"1","&:hover":{background:"color-mix(in oklch, var(--input) 50%, transparent)"},"&:focus":{outline:"0.1rem solid var(--border)"},"*":{pointerEvents:"none"}}));let yt=xt;class kt extends w{static tagname="select-value";$select=z.Null;$placeholder=z.Null;$text=new N("");constructor(t,e){super(kt.tagname,t,e)}props({placeholder:t,...e}){super.props(e),this.placeholder(t??z.Null)}build(t){return super.build(t),this.$select=this.findAbove(t=>z.isInstanceof(t,$t)),this.$select&&(this.$select.$value=this),this}placeholder(t){$.resolve(t,t=>{z.isString(t)?$.context(this,()=>this.$placeholder=new N(t)):this.$placeholder=t,this.render()})}render(){let t=z.Null;this.$select?.selected?(t=this.$text,this.$text.content=this.$select.selected.text):this.$placeholder&&(t=this.$placeholder),t&&(t.builded||t.build(),this.replaceProtos(t),this.node?.replaceChildren(...t.toDOM()))}}class wt extends w{constructor(t,e){super("selector-group",t,e)}}const It=class t extends w{constructor(e,s){super(t.tagname,e,s)}props({size:t,svg:e,...s}){super.props(s),this.svg(e),this.size(t)}svg(t){$.resolve(t,t=>{this.innerHTML(t)})}size(t){$.resolve(t,t=>{this.style({height:t,width:t})})}};b(It,"tagname","icon"),$.style(It,S(It.tagname,{display:"inline-block",verticalAlign:"middle",height:"1rem",width:"1rem",svg:{display:"block",height:"auto",width:"100%"}}));let Nt=It;const Mt=class extends Nt{constructor(t){super({svg:'<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-chevron-down-icon lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>',...t})}};$.style(Mt,S(`select-proto[opened] ${Mt.tagname}`,{rotate:"180deg"}));let zt=Mt;const Dt="@media (hover: hover) and (pointer: fine)",Ct=class extends w{constructor(t,e){super("button",{ui:"button",...t},e)}};b(Ct,"tagname","button"),$.style(Ct,S('button[ui="button"]',{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",lineHeight:"1rem",transition:"0.2s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",userSelect:"none",gap:"calc(var(--spacing) * 2.5)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"&:not([disabled]):active":{translate:"0 0.125rem"},[Dt]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)",[Dt]:{"&:not([disabled]):hover":{background:"oklch(from var(--primary-bg) l c h / .8)"}}},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)",[Dt]:{"&:not([disabled]):hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)",[Dt]:{"&:not([disabled]):hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)",[Dt]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)"}}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)",[Dt]:{"&:not([disabled]):hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}}},'&[size="icon"]':{width:"calc(var(--spacing) * 8)",padding:"0"},'&[size="xs"]':{padding:"calc(var(--spacing) * 2)",fontSize:"var(--text-xs)",lineHeight:"var(--text-xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",padding:"0",svg:{width:"calc(var(--spacing) * 3)",height:"calc(var(--spacing) * 3)"}},'&[size="sm"]':{height:"calc(var(--spacing) * 7)"},'&[size="icon-sm"]':{width:"calc(var(--spacing) * 7)",height:"calc(var(--spacing) * 7)",padding:"0"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)",padding:"0"},'&[size="custom"]':{padding:"calc(var(--spacing) * 2)",height:"unset"},"&[disabled]":{opacity:".5"}}));let St=Ct;const At=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(At,"tagname","badge"),$.style(At,S(At.tagname,{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2)",borderRadius:"calc(var(--radius) * 2.6)",height:"calc(var(--spacing) * 5)",lineHeight:"var(--text-xs)",transition:"0.2s all ease",fontSize:"var(--text-xs)",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",whiteSpace:"nowrap",gap:"var(--spacing)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)","&:focus-visible":{outline:"0.1rem solid var(--border)"},"&[hover]:hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h / 1)"},'&[variant="primary"]':{border:"none",color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"},'&[variant="secondary"]':{border:"none",color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)","&[hover]:hover":{background:"oklch(from var(--secondary-bg) l c h / .8)"}},'&[variant="destructive"]':{border:"none",color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)","&[hover]:hover":{background:"oklch(from var(--destructive-bg) l c h / .5)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&[hover]:hover":{background:"oklch(from var(--input) l c h / .1)"}},'&[variant="link"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&[hover]:hover":{textDecoration:"underline",textUnderlineOffset:"0.2rem"}},'&[size="sm"]':{padding:"0 calc(var(--spacing) * 1)",fontSize:"var(--text-xs2)",lineHeight:"var(--text-xs2)",height:"calc(var(--spacing) * 4)"}}));let Ot=At;const Et=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Et,"tagname","card"),$.style(Et,S(Et.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing) * 4)",paddingBlock:"calc(var(--spacing) * 4)",background:"var(--secondary-bg)",borderRadius:"calc(var(--radius) * 1.4)",overflow:"hidden","&:has(> card-footer)":{paddingBottom:"0"}}));let Wt=Et;const Rt=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Rt,"tagname","card-header"),$.style(Rt,S(Rt.tagname,{display:"flex",width:"100%",flexDirection:"column",gap:"var(--spacing)",paddingInline:"calc(var(--spacing) * 4)"}));let Tt=Rt;const Ht=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Ht,"tagname","card-content"),$.style(Ht,S(Ht.tagname,{display:"block",paddingInline:"calc(var(--spacing) * 4)"}));let Lt=Ht;const Bt=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Bt,"tagname","card-footer"),$.style(Bt,S(Bt.tagname,{display:"block",paddingInline:"calc(var(--spacing) * 4)",paddingBlock:"calc(var(--spacing) * 4)",background:"color-mix(in oklab, var(--muted) 5%, transparent)"}));let Ft=Bt;const Ut=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Ut,"tagname","h3"),$.style(Ut,S(`card ${Ut.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"1.375",fontSize:"var(--text-md)",color:"var(--fg)"}));let _t=Ut;const Vt=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Vt,"tagname","card-description"),$.style(Vt,S(`card ${Vt.tagname}`,{fontWeight:"var(--font-weight-medium)",lineHeight:"var(--line-height-sm)",fontSize:"var(--text-sm)",color:"var(--muted)"}));let jt=Vt;const Yt=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Yt,"tagname","dl"),$.style(Yt,S(Yt.tagname,{display:"flex",flexDirection:"column",margin:"0"}));let qt=Yt;const Xt=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Xt,"tagname","dc"),$.style(Xt,S(Xt.tagname,{paddingBlock:"1rem",borderBottom:"1px solid color-mix(in oklch, var(--input) 50%, transparent)","&:last-child":{borderBottom:"none"}}));let Pt=Xt;const Gt=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Gt,"tagname","dt"),$.style(Gt,S(Gt.tagname,{fontSize:"var(--text-sm)",fontWeight:"var(--font-weight-medium)"}));let Jt=Gt;const Kt=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(Kt,"tagname","dd"),$.style(Kt,S(Kt.tagname,{margin:"0",fontSize:"var(--text-sm)",color:"var(--muted)"}));let Qt=Kt;const Zt=class t extends w{$content=z.Null;constructor(e,s){super(t.tagname,e,s)}open({x:t,y:e,position:s,size:i}){if(k()){this.build(),this.on("pointerdown",t=>{t.target!==this.$content?.node&&(t.target&&this.$content?.node?.contains(t.target)||this.close())}),document.body.append(...this.toDOM());const o=this.$content?.node;if(!o)return;const n=t+o.offsetWidth>innerWidth,r=e+o.offsetHeight>innerHeight;innerWidth<800&&document.documentElement.hasAttribute("touch")?(this.attr("touch",""),this.$content?.style({bottom:"0",width:"100dvw"}),o.animate({translate:["0 100%","0 0"]},{duration:300,easing:"ease",fill:"both"})):s?this.$content?.style({top:"top"===s?"":`${e}px`,bottom:"top"===s?innerHeight-e+"px":"",left:n?"":`${t}px`,right:n?"calc(var(--spacing) * 4)":"",width:i?`${i}px`:""}):this.$content?.style({top:r?"":`${e}px`,bottom:r?"calc(var(--spacing) * 4)":"",left:n?"":`${t}px`,right:n?"calc(var(--spacing) * 4)":"",width:i?`${i}px`:""})}}close(t=!0){const e=()=>{this.removeNode(),t&&this.dispose()};if(this.hasAttr("touch")){if(!this.$content?.node)return;this.style({background:"transparent"});const t=this.$content.node.animate({translate:["0 0","0 100%"]},{duration:300,easing:"ease",fill:"both"});t.addEventListener("finish",e),t.addEventListener("cancel",e)}else e()}};b(Zt,"tagname","context-menu"),$.style(Zt,S(Zt.tagname,{position:"fixed",inset:"0",transition:"all .3s ease",zIndex:"999","&[touch]":{background:"oklch(from var(--bg) calc(l - 0.1) c h / .5)"}})),$.style(Zt,A("html:has(context-menu)",{scrollbarGutter:"stable",overflowY:"hidden",overflowX:"hidden",height:"100dvh"}));let te=Zt;const ee=class t extends w{$menu=z.Null;constructor(e,s){super(t.tagname,e,s),this.on("click",()=>this.$menu?.close())}build(t){return super.build(t),this.$menu=this.findAbove(t=>z.isInstanceof(t,te)),this.$menu&&(this.$menu.$content=this),this}};b(ee,"tagname","context-menu-content"),$.style(ee,S(ee.tagname,{...ht,background:"oklch(from var(--secondary-bg) l c h)","context-menu[touch] &":{borderRadius:"calc(var(--radius) * 2)",padding:"calc(var(--spacing) * 4)",gap:"0.1rem",border:"none",borderBottomLeftRadius:"0",borderBottomRightRadius:"0","& > context-menu-item:first-child, & > :first-child context-menu-item":{borderTopLeftRadius:"calc(var(--radius) * 2)",borderTopRightRadius:"calc(var(--radius) * 2)"},"& > context-menu-item:last-child, & > :last-child context-menu-item":{borderBottomLeftRadius:"calc(var(--radius) * 2)",borderBottomRightRadius:"calc(var(--radius) * 2)"}}}));let se=ee;const ie=class t extends w{$menu=z.Null;constructor(e,s){super(t.tagname,e,s),this.on("click",()=>requestAnimationFrame(()=>this.$menu?.close()))}build(t){return super.build(t),this.$menu=this.findAbove(t=>z.isInstanceof(t,te)),this}};b(ie,"tagname","context-menu-item"),$.style(ie,S(ie.tagname,{display:"block",boxSizing:"border-box",padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)",borderRadius:"var(--radius)",fontSize:"var(--text-md)",fontWeight:"500",lineHeight:"1",cursor:"pointer","context-menu[touch] &":{fontSize:"var(--text-md)",padding:"calc(var(--spacing) * 4)",background:"color-mix(in oklch, var(--secondary-bg), var(--input) 40%)",transition:"all .3s ease",borderRadius:"0","html:not([touch]) &:hover":{background:"color-mix(in oklch, var(--secondary-bg), var(--input) 20%)"},"&:active":{scale:".99 .99",background:"color-mix(in oklch, var(--secondary-bg), var(--input) 20%)"}},"&:hover, :not(:has(select-item:hover)) &:focus":{background:"oklch(from var(--input) l c h / .1)"},"&:focus":{outline:"none"},"&:has(> a)":{padding:"0",a:{padding:"calc(var(--spacing) * 2) calc(var(--spacing) * 1.25)"}}}));let oe=ie;const ne={borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",transition:"0.2s all ease",fontFamily:"inherit",fontSize:"var(--text-sm)",padding:"0 calc(var(--spacing) * 2.5)",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .9)",outline:"0.2rem solid transparent","&:focus-visible":{outlineColor:"var(--border)"},"&:disabled":{opacity:".5"},"&::-webkit-outer-spin-button, &::-webkit-inner-spin-button":{"-webkit-appearance":"none",margin:"0"},"&[type=number]":{"-moz-appearance":"textfield",appearance:"textfield"}},re=class t extends w{constructor(e,s){super(t.tagname,{ui:"input",...e},s)}};b(re,"tagname","input"),$.style(re,S('input[ui="input"]',{...ne}));let ae=re;const ce=class t extends w{constructor(e,s){super(t.tagname,e,s)}props({for:t,...e}){super.props(e),this.for(t)}build(t){return super.build(t),this.setFor(),this}for(t){if(!arguments.length)return this.attr("for");z.isUndefined(t)||$.resolve(t,t=>{this.attr("for",t),this.setFor()})}setFor(){const t=this.for();this.findBelow(e=>{z.isInstanceof(e,w)&&("input"===e.tagname&&e.attr("id",t),"label"===e.tagname&&e.attr("for",t))})}};b(ce,"tagname","field"),$.style(ce,S(ce.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing) * 2)",width:"100%",'&[direction="horizontal"]':{flexDirection:"row",placeItems:"center",width:"unset"},"&:has(field-error)":{'input[ui="input"], textarea[ui="textarea"]':{borderColor:"var(--destructive-fg)","&:focus-visible":{outlineColor:"color-mix(in oklch, var(--destructive-fg) 30%, transparent)"}}}}));let le=ce;const he=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(he,"tagname","label"),$.style(he,S(he.tagname,{"field &":{display:"flex",gap:"var(--spacing)",placeItems:"center",userSelect:"none",color:"var(--fg)",fontWeight:"var(--font-weight-medium)",fontSize:"var(--text-sm)",flexShrink:"0"},"field[disabled] &":{pointerEvents:"none"}}));let ue=he;const de=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(de,"tagname","field-description"),$.style(de,S(de.tagname,{"field &":{display:"block",color:"var(--muted)",fontWeight:"var(--font-weight-medium)",fontSize:"var(--text-sm)"},"field[disabled] &":{pointerEvents:"none"}}));let pe=de;const ge=class t extends w{constructor(e,s){super(t.tagname,e,s)}};b(ge,"tagname","field-error"),$.style(ge,S(ge.tagname,{fontSize:"var(--text-sm)",color:"var(--destructive-fg)",display:"block"}));let be=ge;const me=class extends w{constructor(t,e){super("input",{type:"checkbox",ui:"switch",...t},e)}};b(me,"tagname","input"),$.style(me,S('input[ui="switch"]',{appearance:"none",display:"inline-flex",height:"calc(var(--spacing) * 5)",width:"calc(var(--spacing) * 9)",background:"color-mix(in oklab, var(--input) 80%, transparent)",border:"none",placeItems:"center",borderRadius:"calc(var(--spacing) * 5)",transition:"all .3s ease",padding:"0",flexShrink:"0",margin:"0","&::after":{content:'""',display:"block",height:"calc(var(--spacing) * 5)",width:"calc(var(--spacing) * 5)",background:"var(--fg)",borderRadius:"var(--radius-round)",transition:"all .3s ease"},"&:checked":{background:"var(--primary-bg)","&::after":{height:"calc(var(--spacing) * 4.5)",width:"calc(var(--spacing) * 4.5)",translate:"calc(115% - var(--spacing)) 0",background:"var(--bg)"}}}));let ve=me;const fe=class extends w{constructor(t,e){super("button",{ui:"toggle",...t},e),this.on("click",t=>this.checked(!this.checked()))}props({checked:t,...e}){super.props(e),this.checked(t)}checked(t){if(!arguments.length)return!z.isNull(this.attr("checked"));z.isUndefined(t)||$.resolve(t,t=>{this.attr("checked",t?"":z.Null),this.node?.dispatchEvent(new Event("input"))})}};b(fe,"tagname","button"),$.style(fe,S('button[ui="toggle"]',{display:"inline-flex",placeContent:"center",placeItems:"center",padding:"0 calc(var(--spacing) * 2.5)",borderRadius:"var(--radius)",height:"calc(var(--spacing) * 8)",lineHeight:"1rem",transition:"0.1s all ease",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",outline:"0.1rem solid oklch(from var(--border) l c h / 0)",userSelect:"none",gap:"calc(var(--spacing) * 2.5)",flexShrink:"0",border:"1px solid oklch(from var(--input) l c h / .2)",background:"oklch(from var(--input) l c h / .025)",color:"oklch(from var(--fg) l c h / .8)",[Dt]:{"&:not([disabled]):hover":{background:"oklch(from var(--input) l c h / .1)",color:"oklch(from var(--fg) l c h)"}},"&[checked]":{color:"oklch(from var(--primary-fg) l c h)",background:"oklch(from var(--primary-bg) l c h / .8)",[Dt]:{"&:not([disabled]):hover":{background:"oklch(from var(--primary-bg) l c h)",color:"oklch(from var(--primary-fg) l c h)"}}},'&[variant="primary"]':{"&[checked]":{color:"oklch(from var(--primary-fg) l c h)",background:"var(--primary-bg)"}},'&[variant="secondary"]':{"&[checked]":{color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)"}},'&[variant="destructive"]':{"&[checked]":{color:"oklch(from var(--destructive-fg) l c h)",background:"oklch(from var(--destructive-bg) l c h / .3)"}},'&[variant="ghost"]':{border:"none",color:"oklch(from var(--fg) l c h)",background:"oklch(from var(--input) l c h / 0)","&[checked]":{color:"oklch(from var(--secondary-fg) l c h)",background:"var(--secondary-bg)"}},'&[size="icon"]':{width:"calc(var(--spacing) * 8)",padding:"0"},'&[size="xs"]':{padding:"calc(var(--spacing) * 2)",fontSize:"var(--text-xs)",lineHeight:"var(--text-xs)",height:"calc(var(--spacing) * 6)"},'&[size="icon-xs"]':{width:"calc(var(--spacing) * 6)",height:"calc(var(--spacing) * 6)",padding:"0",svg:{width:"calc(var(--spacing) * 3)",height:"calc(var(--spacing) * 3)"}},'&[size="sm"]':{height:"calc(var(--spacing) * 7)"},'&[size="icon-sm"]':{width:"calc(var(--spacing) * 7)",height:"calc(var(--spacing) * 7)",padding:"0"},'&[size="lg"]':{height:"calc(var(--spacing) * 9)"},'&[size="icon-lg"]':{width:"calc(var(--spacing) * 9)",height:"calc(var(--spacing) * 9)",padding:"0"},"&[disabled]":{opacity:".5"}}));let $e=fe;class xe extends w{$combobox=z.Null;$focusedItem=z.Null;$createItem=z.Null;virtual=!0;constructor(t,e){super("combobox-list",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>z.isInstanceof(t,Me)),this.$combobox&&(this.$combobox.$list=this),this.$combobox?.$chips?.toDOM(),this}filter(t){if(!this.$combobox)return;const e=[];this.$createItem&&(this.$createItem.visible=!!t.trim()&&!z.arrayFrom(this.$combobox.itemMap.values()).find(e=>e.text===t.trim())),z.forEach(this.$combobox.itemMap,([s,i])=>{i.visible=!1,i.text.toLowerCase().includes(t.toLowerCase())&&(i.visible=!0,e.push(i))}),this.$combobox?.$content?.$empty&&(this.$combobox.$content.$empty.visible=!this.$createItem?.visible&&!e.length),this.$combobox.$content?.toDOM()}switch(t){const e=this.$focusedItem,s=this.visibleChildren,i=e?s.indexOf(e):"up"===t?0:-1;let o="up"===t?i-1:i+1;(o<0||o>=s.length)&&(o="up"===t?-1:0),this.focus(o)}focus(t){let e=this.visibleChildren.at(t);this.$focusedItem?.blur(),e?.focus()}focusFirstItem(){this.$createItem?.visible&&this.visibleChildren[1]?this.focus(1):this.focus(0)}mutate(){if(super.mutate(),this.$combobox?.itemMap.clear(),z.forEach(this.children,t=>{z.isInstanceof(t,ke)&&this.$combobox?.itemMap.set(t.value(),t)}),!this.$combobox)return;const t=this.$combobox.values(),e=t.filter(t=>this.$combobox?.itemMap.has(t));z.isEqual(t,e)||(this.$combobox?.values(e),this.$combobox?.dispatch("combobox_input",[]))}}const ye=class extends w{constructor(t,e){super("combobox-item",t,()=>{e?.(this),$(Nt,{ui:"combobox-item-check",svg:'<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-check-icon lucide-check"><path d="M20 6 9 17l-5-5"/></svg>'})}),b(this,"$combobox",z.Null),b(this,"$list",z.Null),f(this,n,z.Null),f(this,r,!1),this.on("mousedown",t=>t.preventDefault()),this.on("click",()=>{this.$combobox?.select(v(this,n),!this.selected())})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>z.isInstanceof(t,Me)),this.$list=this.findAbove(t=>z.isInstanceof(t,xe)),this.$combobox?.itemMap.set(v(this,n),this),this.$combobox?.values().includes(v(this,n))&&this.selected(!0),this}props({value:t,label:e,selected:s,...i}){super.props(i),this.value(t),this.selected(s)}value(t){if(!arguments.length)return v(this,n);z.isUndefined(t)||$.resolve(t,t=>{this.$combobox?.itemMap.delete(v(this,n)),this.$combobox?.itemMap.set(t,this),x(this,n,t)})}selected(t){if(!arguments.length)return v(this,r);z.isUndefined(t)||$.resolve(t,t=>{x(this,r,t),this.attr("selected",t?"":null)})}focus(){this.attr("focus",""),this.node?.scrollIntoView({block:"nearest"}),this.$list&&(this.$list.$focusedItem=this)}blur(){this.attr("focus",z.Null),this.$list&&(this.$list.$focusedItem=null)}};n=new WeakMap,r=new WeakMap,b(ye,"tagname","combobox-item"),$.style(ye,S(ye.tagname,{...pt,'icon[ui="combobox-item-check"]':{visibility:"hidden",marginInlineStart:"auto"},'&[selected] icon[ui="combobox-item-check"]':{visibility:"visible"}}));let ke=ye;const we=class extends w{$combobox=z.Null;$list=z.Null;constructor(t,e){super("combobox-create-item",t,e),this.on("mousedown",t=>t.preventDefault()),this.on("click",t=>{this.dispatch("combobox_create",[this.$combobox?.$input?.node?.value],{bubbles:!0}),this.$combobox?.$input?.clearValue()})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>z.isInstanceof(t,Me)),this.$list=this.findAbove(t=>z.isInstanceof(t,xe)),this.$list&&(this.$list.$createItem=this),this}focus(){this.attr("focus",""),this.$list&&(this.$list.$focusedItem=this)}blur(){this.attr("focus",z.Null),this.$list&&(this.$list.$focusedItem=null)}};b(we,"tagname","combobox-create-item"),$.style(we,S(we.tagname,pt));let Ie=we;const Ne=class extends w{constructor(t,e){super("combobox",t,e),b(this,"$trigger",z.Null),b(this,"$content",z.Null),b(this,"$list",z.Null),b(this,"$chips",z.Null),b(this,"$input",z.Null),b(this,"itemMap",/* @__PURE__ */new Map),f(this,a,/* @__PURE__ */new Set),f(this,c,!1),b(this,"disconnect",z.Null)}toDOM(t=!0){const e=super.toDOM(!1);return!v(this,c)&&t&&this.$trigger&&(this.node?.append(...this.$trigger.toDOM()),this.$content?.toDOM(),x(this,c,!0)),e}props({values:t,...e}){super.props(e),this.values(t)}open(){this.attr("opened",""),k()&&this.$content&&(this.disconnect=mt(this.$trigger?.node,this.$content.node),document.body.append(...this.$content.toDOM()),this.$input&&this.$list?.filter(this.$input.node?.value??""))}close(){this.attr("opened",z.Null),k()&&(this.$content?.removeNode(),this.disconnect?.(),this.disconnect=z.Null)}select(t,e=!0){const s=this.itemMap.get(t);s&&(s.selected(e),e?(v(this,a).add(t),this.dispatch("combobox_select",[t])):(v(this,a).delete(t),this.dispatch("combobox_unselect",[t])),this.$chips?.toDOM(),this.dispatch("combobox_input",[]))}get selected(){return z.map(v(this,a),t=>this.itemMap.get(t))}values(t){if(!arguments.length)return z.arrayFrom(v(this,a));z.isUndefined(t)||$.resolve(t,t=>{x(this,a,new Set(t)),z.forEach(this.itemMap.values(),t=>{t.selected(v(this,a).has(t.value()))}),this.$chips?.toDOM()})}};a=new WeakMap,c=new WeakMap,b(Ne,"tagname","combobox"),$.style(Ne,S(Ne.tagname,{display:"inline-block",width:"10rem",userSelect:"none"}));let Me=Ne;const ze=class extends w{$combobox=z.Null;constructor(t,e){super("combobox-trigger",t,e),this.on("dragover",t=>this.$combobox?.$chips?.dragover(t)),this.on("dragend",t=>this.$combobox?.$chips?.dragend())}build(t){return super.build(t),this.$combobox=this.findAbove(t=>z.isInstanceof(t,Me)),this.$combobox&&(this.$combobox.$trigger=this),this}};b(ze,"tagname","combobox-trigger"),$.style(ze,S(ze.tagname,{display:"flex",flexWrap:"wrap",columnGap:"calc(var(--spacing) * 1.25)",placeItems:"center",boxSizing:"border-box",border:"1px solid var(--input)",background:"color-mix(in oklch, var(--input) 30%, transparent)",borderRadius:"var(--radius)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",lineHeight:"1",padding:"0 calc(var(--spacing) * 1.25)","&:hover":{background:"color-mix(in oklch, var(--input) 50%, transparent)"},"&:focus-within":{outline:"0.1rem solid var(--border)"}}));let De=ze;const Ce=class extends w{$combobox=z.Null;constructor(t,e){super("input",{ui:"combobox-input",autocomplete:"off",...t},e),this.on("focus",t=>z.isNull(this.$combobox?.attr("opened"))&&this.$combobox.open()),this.on("blur",t=>{this.$combobox?.close(),this.$combobox?.$chips?.$focusedChip?.blur()}),this.on("input",t=>{this.$combobox?.$list?.filter(t.currentTarget.value),this.$combobox?.$list?.focusFirstItem()}),this.on("keydown",t=>{switch(t.key){case"ArrowDown":return t.preventDefault(),void this.$combobox?.$list?.switch("down");case"ArrowUp":return t.preventDefault(),void this.$combobox?.$list?.switch("up");case"Backspace":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.visibleChildren.at(-1)?.delete());case"ArrowRight":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.switch("right"));case"ArrowLeft":return void(0===t.currentTarget.value.length&&this.$combobox?.$chips?.switch("left"))}}),this.on("keyup",t=>{switch(t.key){case"Escape":return t.preventDefault(),this.$combobox?.close(),void this.$combobox?.$trigger?.node?.focus();case"Delete":{const t=this.$combobox?.$chips?.$focusedChip;return this.$combobox?.$chips?.switch("right"),void t?.delete()}case"Tab":case"Enter":{t.preventDefault();const e=this.$combobox?.$list?.$focusedItem;if(!e)return;return z.isInstanceof(e,ke)?this.$combobox?.select(e.value()):this.dispatch("combobox_create",[t.currentTarget.value],{bubbles:!0}),void this.clearValue()}}t.currentTarget.value.length&&this.$combobox?.$chips?.$focusedChip?.blur()})}build(t){return super.build(t),this.$combobox=this.findAbove(t=>z.isInstanceof(t,Me)),this.$combobox&&(this.$combobox.$input=this),this}clearValue(){this.node&&(this.node.value=""),this.$combobox?.$list?.filter("")}};$.style(Ce,S('input[ui="combobox-input"]',{display:"inline",border:"unset",background:"unset",color:"oklch(from var(--fg) l c h / .9)",fontSize:"0.875rem",fontWeight:"var(--font-weight-medium)",fontFamily:"inherit",lineHeight:"1",height:"calc(var(--spacing) * 8)",flex:"1",minWidth:"2rem",padding:"0 calc(var(--spacing) * 1.25)",outline:"unset","&:focus":{outline:"unset"}}));let Se=Ce;const Ae=class extends w{$combobox=z.Null;$empty=z.Null;constructor(t,e){super("combobox-content",t,e)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>z.isInstanceof(t,Me)),this.$combobox&&(this.$combobox.$content=this),this}};b(Ae,"tagname","combobox-content"),$.style(Ae,S(Ae.tagname,ht));let Oe=Ae;const Ee=class extends w{$content=z.Null;constructor(t,e){super("combobox-empty",t,e)}build(t){return super.build(t),this.$content=this.findAbove(t=>z.isInstanceof(t,Oe)),this.$content&&(this.$content.$empty=this),this}};b(Ee,"tagname","combobox-empty"),$.style(Ee,S(Ee.tagname,{...pt}));let We=Ee;class Re extends M{$combobox=z.Null;chipMap=/* @__PURE__ */new Map;$focusedChip=z.Null;$draggedChip=z.Null;#t=[];#e=[];#s=[];constructor(t){super(t)}build(t){return super.build(t),this.$combobox=this.findAbove(t=>z.isInstanceof(t,Me)),this.$combobox&&(this.$combobox.$chips=this),this}toDOM(){const t=this.$combobox?.values()??[];return z.isEqual(t,this.#e)||(this.#e=[...t],z.forEach(this.children,t=>t.removeNode()),this.#s=z.map(this.$combobox?.values(),t=>{const e=this.chipMap.get(t);return e?(e.builded||e.build(),e.toDOM()):[]})?.flat()??[],this.node?.replaceWith(this.node,...this.#s)),[this.node,...this.#s]}switch(t){const e=this.$focusedChip,s=this.visibleChildren,i=e?s.indexOf(e):"left"===t?0:-1;let o="left"===t?i-1:i+1;(o<0||o>=s.length)&&(o="left"===t?-1:0),this.focus(o)}focus(t){let e=this.visibleChildren.at(t);this.$focusedChip?.blur(),e?.focus()}dragover(t){if(!this.$draggedChip?.node)return;if(!this.$combobox)return;const e=z.map(this.#e,t=>this.chipMap.get(t)).reduce((e,s)=>{const i=s.node.getBoundingClientRect(),o=t.x-i.left-i.width/2,n=t.y-i.top-i.height/2,r=Math.pow(o,2)+Math.pow(n,2);return r<e.offset?{offset:r,$chip:s}:e},{offset:Number.POSITIVE_INFINITY,$chip:void 0}).$chip;if(e&&e!==this.$draggedChip){const s=e.node.getBoundingClientRect(),i=this.$draggedChip.value(),o=e.value(),n=this.$combobox.values();n.splice(n.indexOf(i),1),t.x<s.left+s.width/2?(this.$combobox.$trigger?.node?.insertBefore(this.$draggedChip.node,e.node),n.splice(n.indexOf(o),0,i)):(this.$combobox.$trigger?.node?.insertBefore(this.$draggedChip.node,e.node?.nextSibling??null),n.splice(n.indexOf(o)+1,0,i)),this.#t=n}}dragend(){this.#t.length&&(this.$combobox?.values(this.#t),this.$combobox?.dispatch("combobox_input",[])),this.#t=[],this.$draggedChip?.removeClass("dragging"),this.$draggedChip=null}mutate(){super.mutate(),this.chipMap.clear(),z.forEach(this.children,t=>{z.isInstanceof(t,He)&&this.chipMap.set(t.value(),t)}),this.#e=[],this.toDOM()}}const Te=class extends w{constructor(t,e){super("combobox-chip",{draggable:!0,...t},e),b(this,"$chips",z.Null),f(this,l),this.on("dragstart",()=>{this.$chips&&(this.$chips.$draggedChip=this,this.addClass("dragging"))})}build(t){return super.build(t),this.$chips=this.findAbove(t=>z.isInstanceof(t,Re)),this.$chips?.chipMap.set(this.value(),this),this}props({value:t,...e}){super.props(e),this.value(t)}value(t){if(!arguments.length)return v(this,l);z.isUndefined(t)||$.resolve(t,t=>{this.$chips?.chipMap.delete(t),this.$chips?.chipMap.set(t,this),x(this,l,t)})}delete(){this.$chips?.$combobox?.select(v(this,l),!1)}focus(){this.attr("focus",""),this.$chips&&(this.$chips.$focusedChip=this)}blur(){this.attr("focus",z.Null),this.$chips&&(this.$chips.$focusedChip=z.Null)}};l=new WeakMap,b(Te,"tagname","combobox-chip"),$.style(Te,S(Te.tagname,{display:"inline-flex",placeItems:"center",fontSize:"var(--text-xs)",padding:"0 calc(var(--spacing) * 1.5)",background:"var(--secondary-bg)",borderRadius:"calc(var(--radius) * .6)",height:"calc(var(--spacing) * 5.25)",marginBlock:"calc(var(--spacing))",cursor:"grab",gap:"var(--spacing)","&:active":{cursor:"grabbing"},"&[focus]":{outline:"2px solid var(--input)"},"&.dragging":{background:"var(--input)"}}));let He=Te;const Le=class extends w{$chip=z.Null;constructor(t,e){super("button",{ui:"combobox-chip-remove",tabindex:"-1",...t},()=>{e?e(this):$(Nt,{svg:'<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-x-icon lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>'})}),this.on("click",()=>{this.$chip?.$chips?.$combobox?.select(this.$chip.value(),!1)})}build(t){return super.build(t),this.$chip=this.findAbove(t=>z.isInstanceof(t,He)),this}};b(Le,"tagname","button"),$.style(Le,S('button[ui="combobox-chip-remove"]',{background:"unset",border:"unset",color:"oklch(from var(--fg) l c h / .9)",padding:"0",icon:{height:"calc(var(--spacing) * 3.25)",width:"calc(var(--spacing) * 3.25)"}}));let Be=Le;class Fe extends w{static $container=z.Null;constructor(t,e){super("toast",t,e)}static popup({position:t,...e},s){if(!k())return;this.$container=this.$container??new _e({});const i=new Fe(e,s),o=this.$container.list(t??"top");this.$container.append(o),o.append(i),i.build();const n=this.$container.toDOM();document.body.contains(this.$container.node)||document.body.append(...n),setTimeout(()=>{i.remove(),i.removeNode(),i.dispose()},3e3)}}const Ue=class extends w{listMap={};constructor(t,e){super("toast-container",t,e)}list(t){return this.listMap[t]=this.listMap[t]??new je({position:t}).build()}};b(Ue,"tagname","toast-container"),$.style(Ue,S(Ue.tagname,{position:"fixed",inset:"0 0 0 0",pointerEvents:"none"}));let _e=Ue;const Ve=class extends w{constructor(t,e){super("toast-list",t,e)}};b(Ve,"tagname","toast-list"),$.style(Ve,S(Ve.tagname,{display:"flex",flexDirection:"column",gap:"calc(var(--spacing) * 2)",pointerEvents:"auto",position:"absolute",'&[position="top"]':{top:"0",placeSelf:"center"},'&[position="top-left"]':{top:"0",placeSelf:"start"},'&[position="top-right"]':{top:"0",placeSelf:"end"},'&[position="bottom"]':{bottom:"0",placeSelf:"center"},'&[position="bottom-left"]':{bottom:"0",placeSelf:"start"},'&[position="bottom-right"]':{bottom:"0",placeSelf:"end"}}));let je=Ve;const Ye=class extends w{disconnect=z.Null;$content=z.Null;$list=z.Null;$input=z.Null;constructor(t,e){super("searchbar",t,e)}open(){this.hasAttr("opened")||(this.attr("opened",""),k()&&this.$content&&(this.disconnect=mt(this.$input?.node,this.$content.node),document.body.append(...this.$content.toDOM())))}close(){this.attr("opened",z.Null),k()&&(this.$content?.removeNode(),this.disconnect?.(),this.disconnect=z.Null)}toDOM(t=!0){return super.toDOM(!1),t&&this.$input&&(this.node?.append(...this.$input.toDOM()),this.$content?.toDOM()),[this.node]}};b(Ye,"tagname","searchbar"),$.style(Ye,S(Ye.tagname,{}));let qe=Ye;const Xe=class extends ae{$searchbar=z.Null;constructor(t,e){super({ui:"searchbar-input",...t},e),this.on("focus",t=>this.$searchbar?.$list?.visibleChildren.length&&this.$searchbar.open()),this.on("blur",t=>this.$searchbar?.close()),this.on("keydown",t=>{switch(t.key){case"ArrowDown":return t.preventDefault(),void this.$searchbar?.$list?.switch("down");case"ArrowUp":return t.preventDefault(),void this.$searchbar?.$list?.switch("up")}}),this.on("keyup",t=>{switch(t.key){case"Escape":return t.preventDefault(),this.$searchbar?.close(),void this.$searchbar?.$input?.node?.blur();case"Enter":return t.preventDefault(),void this.$searchbar?.$list?.$focusedItem?.select()}})}build(t){return super.build(t),this.$searchbar=this.findAbove(t=>z.isInstanceof(t,qe)),this.$searchbar&&(this.$searchbar.$input=this),this}};$.style(Xe,S('input[ui="searchbar-input"]',{...ne,width:"100%"}));let Pe=Xe;const Ge=class extends w{$searchbar=z.Null;constructor(t,e){super("searchbar-content",t,e),this.listen("mutate",()=>{this.$searchbar?.$list?.visibleChildren.length?this.$searchbar.open():this.$searchbar?.close()})}build(t){return super.build(t),this.$searchbar=this.findAbove(t=>z.isInstanceof(t,qe)),this.$searchbar&&(this.$searchbar.$content=this),this}};b(Ge,"tagname","searchbar-content"),$.style(Ge,S(Ge.tagname,ht));let Je=Ge;class Ke extends w{$searchbar=z.Null;$focusedItem=z.Null;constructor(t,e){super("combobox-list",t,e)}build(t){return super.build(t),this.$searchbar=this.findAbove(t=>z.isInstanceof(t,qe)),this.$searchbar&&(this.$searchbar.$list=this),this}switch(t){const e=this.$focusedItem,s=this.visibleChildren,i=e?s.indexOf(e):"up"===t?0:-1;let o="up"===t?i-1:i+1;(o<0||o>=s.length)&&(o="up"===t?-1:0),this.focus(o)}focus(t){let e=this.visibleChildren.at(t);this.$focusedItem?.blur(),e?.focus()}}const Qe=class extends w{$list=z.Null;constructor(t,e){super("searchbar-item",t,e),this.on("click",()=>this.select()),this.on("mousedown",t=>t.preventDefault())}build(t){return super.build(t),this.$list=this.findAbove(t=>z.isInstanceof(t,Ke)),this}focus(){this.attr("focus",""),this.node?.scrollIntoView({block:"nearest"}),this.$list&&(this.$list.$focusedItem=this)}blur(){this.attr("focus",z.Null),this.$list&&(this.$list.$focusedItem=null)}select(){this.dispatch("searchbar_item_select",[]),this.$list?.$searchbar?.hasAttr("autoclose")&&this.$list.$searchbar.close()}};b(Qe,"tagname","searchbar-item"),$.style(Qe,S(Qe.tagname,pt));let Ze=Qe;const ts=class extends w{constructor(t,e){super("textarea",{ui:"textarea",...t},e)}};b(ts,"tagname","textarea"),$.style(ts,S('textarea[ui="textarea"]',{...ne,padding:"calc(var(--spacing) * 2.5)",minHeight:"calc(var(--spacing) * 5 + 2rem)",maxHeight:"calc(var(--spacing) * 5 + 10rem)",fieldSizing:"content",resize:"none",height:"unset"}));let es=ts;const ss=class extends w{constructor(t,e){super("textblock",t,e)}};b(ss,"tagname","textblock"),$.style(ss,S(ss.tagname,{display:"block",whiteSpace:"pre",fontSize:"var(--text-sm)",textWrap:"auto"}));let is=ss;const os=class extends w{constructor(t,e){super("container",{type:"inline-size",...t},e),this.style({containerName:t.name,containerType:t.type??"inline-size"})}};b(os,"tagname","container"),$.style(os,S(os.tagname,{containerName:"attr(name type(*))",containerType:"attr(type type(*))"}));let ns=os;const rs=class t extends w{constructor(e,s){super(t.tagname,e,s),b(this,"$content",z.Null),b(this,"$container",z.Null),b(this,"index",0),b(this,"itemList",/* @__PURE__ */new Set),b(this,"timer",z.Null),f(this,h,3),f(this,u,0),b(this,"playing",!1),b(this,"transformIndex",0),b(this,"animation",z.Null),f(this,d,z.Null),b(this,"$targetItem",z.Null),this.on("mouseenter",t=>this.hasAttr("hoverpause")&&this.pause()),this.on("mouseleave",t=>this.autoplay()&&this.play()),this.listen("dom",()=>{this.jumpTo(this.index),this.node&&!v(this,d)&&(x(this,d,new ResizeObserver(()=>{this.inDOM()&&this.autoplay()?this.play():this.pause()})),v(this,d).observe(this.node)),this.autoplay()&&this.play()}),this.touchHandler()}props({interval:t,hoverpause:e,autoplay:s,loop:i,...o}){super.props(o),this.autoplay(s),this.loop(i),this.interval(t),this.hoverpause(e)}autoplay(t){if(!arguments.length)return this.hasAttr("autoplay");z.isUndefined(t)||$.resolve(t,t=>{this.attr("autoplay",t?"":z.Null)})}loop(t){if(!arguments.length)return this.hasAttr("loop");z.isUndefined(t)||$.resolve(t,t=>{this.attr("loop",t?"":z.Null)})}hoverpause(t){if(!arguments.length)return this.hasAttr("hoverpause");z.isUndefined(t)||$.resolve(t,t=>{this.attr("hoverpause",t?"":z.Null)})}interval(t){if(!arguments.length)return v(this,h);z.isUndefined(t)||$.resolve(t,t=>{x(this,h,t)})}play(){this.playing||(this.playing=!0,this.timer=setInterval(()=>{this.inDOM()||this.pause(),y(this,u)._++,v(this,u)>=100*v(this,h)&&(this.switch("next"),x(this,u,0))},10))}pause(){this.playing=!1,this.timer&&clearTimeout(this.timer)}stop(){this.pause(),x(this,u,0)}targetItems(t){const e=z.arrayFrom(this.itemList),s=e.at(t),i=e.at(t-1),o=e.at(t+1>=e.length?0:t+1);return z.tuple(i,s,o)}setItemsStyle(t){const[e,s,i]=this.targetItems(t),o=this.attr("gap")??"0px",n=(t,e)=>t?.style({transform:`translate(calc((100% + ${o}) * ${this.transformIndex+e}))`});n(s,0),(0!==t||this.itemList.size>2&&this.loop())&&n(e,-1),(t!==this.itemList.size-1||this.itemList.size>2&&this.loop())&&n(i,1)}switch(t){const e=this.$content?.node,s=this.$container?.node;if(!e||!s)return;const i=z.arrayFrom(this.itemList);if(!(i.length<=1)){if("next"===t){if(this.index+1>=i.length){if(!this.loop())return;this.index=0}else this.index++;i.length<=2&&0===this.index?this.transformIndex=0:this.transformIndex++}else{if(this.index-1<0){if(!this.loop())return;this.index=i.length-1}else this.index--;this.transformIndex--}this.jump(!0)}}jumpTo(t){const e=this.$content?.node;if(!e)return;const s=z.arrayFrom(this.itemList);t>=s.length||(this.index=t<0?s.length+t:t,this.jump())}jump(t=!1){this.setItemsStyle(this.index);const e=this.targetItems(this.index);z.forEach(this.itemList,t=>t.visible=!1),z.forEach(e,t=>t&&(t.visible=!0)),this.toDOM(),t&&this.animateTo(this.transformIndex),this.$targetItem=e[1]??z.Null,this.dispatch("carousel_switch",[this],{bubbles:!0}),this.$targetItem?.dispatch("carousel_target",[],{bubbles:!0}),this.stop(),this.autoplay()&&this.play()}animateTo(t){const e=this.$content?.node;if(!e)return;this.inDOM()&&(this.animation?.commitStyles(),this.animation?.cancel());const s=e.computedStyleMap().get("transform")?.toString(),i=this.attr("gap")??"0px";this.animation=e.animate({transform:[s??"",`translateX( calc((-100% - ${i}) * ${t}) )`]},{duration:500,easing:"ease",fill:"both"})}touchHandler(){this.on("pointerdown",t=>{if("mouse"===t.pointerType)return;this.pause(),this.animation?.commitStyles(),this.animation?.cancel();let e={x:0,y:0},s={x:0};const i=t=>{e={x:e.x+t.movementX,y:e.y+t.movementY},s={x:t.movementX,y:t.movementY};const i=this.$content?.node;if(!i)return;const o=function(t){if(!t||"none"===t)return{x:0,y:0,scaleX:1,scaleY:1,angle:0};const e=t.split("(")[1].split(")")[0].split(",").map(Number),[s,i,o,n,r,a]=e;return{x:r,y:a,scaleX:Math.sqrt(s*s+i*i),scaleY:Math.sqrt(o*o+n*n),angle:Math.round(Math.atan2(i,s)*(180/Math.PI))}}(window.getComputedStyle(i).transform);i.style.transform=`translate(${o.x+t.movementX}px)`},o=t=>{n(),this.autoplay()&&this.play();const i=e.x<-100||s.x<-10,o=e.x>100||s.x>10;if(!this.loop()){if(0===this.index&&o)return this.animateTo(this.transformIndex);if(this.index===this.itemList.size-1&&i)return this.animateTo(this.transformIndex)}if(1===this.itemList.size)return this.animateTo(this.transformIndex);!i||2===this.itemList.size&&1===this.index?!o||2===this.itemList.size&&0===this.index?this.animateTo(this.transformIndex):this.switch("prev"):this.switch("next")},n=()=>{this.off("pointermove",i),this.off("pointerup",o),this.off("pointercancel",o)};this.on("pointermove",i),this.on("pointerup",o),this.on("pointercancel",o)})}};h=new WeakMap,u=new WeakMap,d=new WeakMap,b(rs,"tagname","carousel"),$.style(rs,S(rs.tagname,{display:"block",position:"relative",touchAction:"pan-y","html:not([touch]) &:not([nopage]):hover":{"button.carousel-prev, button.carousel-next":{visibility:"visible"}}}));let as=rs;const cs=class t extends w{$carousel=z.Null;constructor(e,s){super(t.tagname,e,s)}build(t){return super.build(t),this.$carousel=this.findAbove(t=>z.isInstanceof(t,as)),this.$carousel&&(this.$carousel.$container=this),this}};b(cs,"tagname","carousel-container"),$.style(cs,S(cs.tagname,{display:"block",height:"100%",overflow:"hidden",position:"relative",margin:"auto"}));let ls=cs;const hs=class t extends w{$carousel=z.Null;virtual=!0;constructor(e,s){super(t.tagname,e,s)}build(t){if(super.build(t),this.$carousel=this.findAbove(t=>z.isInstanceof(t,as)),this.$carousel){this.$carousel.$content=this;const t=z.arrayFrom(this.$carousel.itemList).at(this.$carousel.index);t&&(this.$carousel.$targetItem=t,t.visible=!0)}return this.nopage(),this}mutate(){super.mutate(),this.$carousel?.itemList.clear(),z.forEach(this.children,(t,e)=>{e===this.$carousel?.index&&(this.$carousel.$targetItem=t,t.visible=!0),this.$carousel?.itemList.add(t)}),this.nopage()}nopage(){this.$carousel&&this.$carousel.attr("nopage",this.$carousel.itemList.size<=1?"":z.Null)}};b(hs,"tagname","carousel-content"),$.style(hs,S(hs.tagname,{display:"grid",height:"100%",gridTemplateColumns:"1fr",gridTemplateRows:"1fr",willChange:"transfrom"}));let us=hs;const ds=class t extends w{$carousel=z.Null;visible=!1;constructor(e,s){super(t.tagname,e,s)}build(t){return super.build(t),this.$carousel=this.findAbove(t=>z.isInstanceof(t,as)),this.$carousel&&this.$carousel.itemList.add(this),this}};b(ds,"tagname","carousel-item"),$.style(ds,S(ds.tagname,{position:"relative",height:"100%",width:"100%",flexShrink:"0",gridArea:"1 / 1 / 2 / 2",willChange:"transfrom",overflow:"hidden"}));let ps=ds;const gs=class extends St{$carousel=z.Null;constructor(t,e){super(t,e),this.on("click",()=>this.$carousel?.switch("next")),this.addClass("carousel-next")}build(t){return super.build(t),this.$carousel=this.findAbove(t=>z.isInstanceof(t,as)),this.checkDisabled(),this.$carousel?.listen("carousel_switch",()=>this.checkDisabled()),this}checkDisabled(){!this.$carousel?.loop()&&this.$carousel.index>=this.$carousel.itemList.size-1?this.attr("disabled",""):this.attr("disabled",z.Null)}};$.style(gs,S("button.carousel-next",{position:"absolute",inset:"0",width:"calc(var(--spacing) * 8)",marginBlock:"auto",marginInline:"auto 1rem",visibility:"hidden"}));let bs=gs;const ms=class extends St{$carousel=z.Null;constructor(t,e){super(t,e),this.on("click",()=>this.$carousel?.switch("prev")),this.addClass("carousel-prev")}build(t){return super.build(t),this.$carousel=this.findAbove(t=>z.isInstanceof(t,as)),this.checkDisabled(),this.$carousel?.listen("carousel_switch",()=>this.checkDisabled()),this}checkDisabled(){this.$carousel?.loop()||0!==this.$carousel?.index?this.attr("disabled",z.Null):this.attr("disabled","")}};$.style(ms,S("button.carousel-prev",{position:"absolute",inset:"0",width:"calc(var(--spacing) * 8)",marginBlock:"auto",marginInline:"1rem auto",visibility:"hidden"}));let vs=ms;const fs=class t extends w{$value=z.Null;constructor(e,s){super(t.tagname,e,()=>{$(ys),s?.(this)})}props({value:t,...e}){super.props(e),this.value(t)}value(t){if(!arguments.length)return Number(this.attr("value"));z.isUndefined(t)||$.resolve(t,t=>{this.attr("value",`${t}`),this.$value?.style({translate:`-${Math.min(Math.max(100-t,0),100)}% 0`})})}};b(fs,"tagname","progress-bar"),$.style(fs,S(fs.tagname,{display:"block",height:"var(--spacing)",background:"color-mix(in srgb, var(--input), transparent 30%)",borderRadius:"var(--radius)",overflow:"hidden"}));let $s=fs;const xs=class t extends w{$progress=z.Null;constructor(e){super(t.tagname,e)}build(t){return super.build(t),this.$progress=this.findAbove(t=>z.is(t,$s)),this.$progress&&(this.$progress.$value=this,this.$progress.value(this.$progress.value())),this}};b(xs,"tagname","progress-value"),$.style(xs,S(xs.tagname,{display:"block",height:"var(--spacing)",background:"var(--primary-bg)",borderRadius:"var(--radius)",transition:"all .3s ease"}));let ys=xs;export{P as Accordion,G as AccordionContainer,J as AccordionContent,K as AccordionTrigger,Ot as Badge,St as Button,Wt as Card,Lt as CardContent,jt as CardDescription,Ft as CardFooter,Tt as CardHeader,_t as CardTitle,as as Carousel,ls as CarouselContainer,us as CarouselContent,ps as CarouselItem,bs as CarouselNext,vs as CarouselPrev,Me as Combobox,He as ComboboxChip,Be as ComboboxChipRemoveButton,Re as ComboboxChips,Oe as ComboboxContent,Ie as ComboboxCreateItem,We as ComboboxEmpty,Se as ComboboxInput,ke as ComboboxItem,xe as ComboboxList,De as ComboboxTrigger,ns as Container,te as ContextMenu,se as ContextMenuContent,oe as ContextMenuItem,Pt as DescriptionContent,Qt as DescriptionDetail,qt as DescriptionList,Jt as DescriptionTerm,le as Field,pe as FieldDescription,be as FieldError,ue as FieldLabel,Nt as Icon,ae as Input,U as Label,$s as Progress,F as Radio,H as RadioGroup,B as RadioItem,qe as Searchbar,Je as SearchbarContent,Pe as SearchbarInput,Ze as SearchbarItem,Ke as SearchbarList,$t as Select,zt as SelectArrow,dt as SelectContent,wt as SelectGroup,bt as SelectItem,yt as SelectTrigger,kt as SelectValue,E as Slide,R as Slideshow,ve as Switch,lt as TabContent,nt as TabTrigger,it as Tabs,at as TabsContainer,es as TextArea,is as TextBlock,Fe as Toast,$e as Toggle,Z as Waterfall,et as WaterfallItem,C as slideInOut};
|
package/build/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=
|
|
1
|
+
const e=Array.from,t="abcdefghijklmnopqrstuvwxyz",r=t.toUpperCase(),n=n=>{const s="any"===(n={length:5,lettercase:"any",...n}).lettercase?t+r:"lower"===n.lettercase?t:r;return e({length:n.length},(e,t)=>s[Math.round(Math.random()*s.length)]).join("")};class s{static map=/* @__PURE__ */new Map;static generate(e,t){const r=s.map.get(e)??/* @__PURE__ */new Set,o=n(t);return r.has(o)?s.generate(e):o}static persistInProto(e,t,r){const n=s.generate(t,r);return e.listen("dispose",()=>s.map.get(t)?.delete(n)),n}}const o=null,a=void 0,i=(e,t)=>typeof e===t,c=e=>i(e,"object"),l=e=>g(e,(async()=>0).constructor),u=e=>e===o,f=Array.isArray,g=(e,...t)=>!!t.find(t=>e instanceof t),m=async(e,t)=>{if(!e)return;let r=0;return l(t)?(async()=>{for(let n of e)await t(n,r,e),r++})():(()=>{for(let n of e)t(n,r,e),r++})()},y=Object.fromEntries,p=Object.entries,d=Object.assign,h=(e,t,r)=>{const n=r?new Set(r):o;if(e===t)return!0;const s=p(e),a=p(t);if(s.length!==a.length)return!1;for(let[o,i]of p(e)){if(n&&!n.has(o))continue;const e=t[o];if(e!==i){if(u(e)||u(i))return!1;if(Number.isNaN(e)&&Number.isNaN(i))continue;if(c(e)&&c(i)){if(f(i)&&f(e)&&i.length!==e.length)return!1;if(h(i,e))continue;return!1}return!1}}return!0},b=JSON.stringify,w=JSON.parse,N=(e,t,r)=>e.slice(t,r),j=URL,S=/* @__PURE__ */Object.freeze(/* @__PURE__ */Object.defineProperty({__proto__:null,Null:o,Undefined:a,arrayFrom:e,assign:d,call:e=>e(),camelToDashedStyle:e=>e.replaceAll(/[A-Z]/g,e=>`-${e.toLowerCase()}`),debounce:(e,t)=>{let r=o,n=!1;return()=>{if(!r)return r=setTimeout(()=>{r=o,n&&e(),n=!1},t),e();n=!0}},entries:p,forEach:m,fromEntries:y,is:(e,t)=>g(e,t)?e:o,isArray:f,isAsyncFunction:l,isBoolean:e=>i(e,"boolean"),isEqual:h,isFunction:e=>i(e,"function"),isIncluded:(e,t)=>t.includes(e),isInstanceof:g,isNull:u,isNumber:e=>i(e,"number"),isObject:c,isString:e=>i(e,"string"),isSymbol:e=>i(e,"symbol"),isTypeof:i,isUndefined:e=>void 0===e,json:w,map:(t,r)=>t?e(t).map(r):a,match:(e,t)=>{var r=/* @__PURE__ */new Map,n=/* @__PURE__ */Symbol("default"),s={case:(e,t)=>(r.set(e,t),s),default:e=>(r.set(n,e),s)};return t(s),r.get(e)?.()??r.get(n)?.()},merge:(...e)=>{let t={};return m(e,e=>d(t,e)),t},randstr:n,remove:(e,...t)=>e.filter(e=>!t.includes(e)),sleep:async e=>new Promise(t=>setTimeout(t,e)),stringify:b,toArray:e=>g(e,Array)?e:[e],toURL:(e,t=globalThis.origin??"http://localhost")=>g(e,j)?e:new URL(e,t),trycatch:e=>{try{const t=e();return g(t,Promise)?t.then(e=>[e,o]).catch(e=>[o,new Error(e?.message??"",{cause:e})]):[t,o]}catch(t){return[o,new Error(t?.message??"",{cause:t})]}},tuple:(...e)=>e,uppercase:(e,t,r)=>`${N(e,0,t)}${N(e,t,r).toUpperCase()}${r?N(e,r):""}`},Symbol.toStringTag,{value:"Module"}));export{s as UID,S as Utils};
|
package/build/widget.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ProxyProto as t,symbol_ProtoType as e}from"@amateras/core";import{Utils as r}from"@amateras/utils";const i=r=>{const i=class extends t{static[e]="Widget";static name="Widget";static builder=r;constructor(t,e){super(()=>i.builder(t,t=>e?.(t)))}};return i};r.assign($,{widget:t=>i(t)}),$.middleware.craft.add((t,...i)=>{if("Widget"===t[e]){let[e]=i;return i=r.isFunction(e)?[{},e]:i,new t(...i)}});export{i as WidgetConstructor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amateras",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Amateras is a JavaScript library for building user interface.",
|
|
5
5
|
"module": "index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
]
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/bun": "^1.3.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
48
|
+
"@types/bun": "^1.3.14",
|
|
49
|
+
"terser": "^5.46.0",
|
|
50
|
+
"vite": "^7.3.1"
|
|
51
51
|
},
|
|
52
52
|
"files": [
|
|
53
53
|
"packages",
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { onclient, onserver } from '#env';
|
|
2
|
-
import {
|
|
2
|
+
import { Utils } from '@amateras/utils';
|
|
3
3
|
import './global';
|
|
4
4
|
import { ElementProto, type ElementProtoConstructor } from './structure/ElementProto';
|
|
5
5
|
import { Proto, type ProtoConstructor } from './structure/Proto';
|
|
6
6
|
import { TextProto } from './structure/TextProto';
|
|
7
7
|
import type { ProxyProto } from '#structure/ProxyProto';
|
|
8
8
|
import type { NodeProto } from '#structure/NodeProto';
|
|
9
|
+
import { hmr } from '#lib/hmr';
|
|
10
|
+
import { ProtoProcess } from '#structure/ProtoProcess';
|
|
9
11
|
|
|
10
12
|
function createProto(insert: boolean, ...args: any) {
|
|
11
13
|
const prevProtoParent = Proto.proto;
|
|
@@ -14,9 +16,9 @@ function createProto(insert: boolean, ...args: any) {
|
|
|
14
16
|
if (insert) prevProtoParent?.append(proto);
|
|
15
17
|
protos.push(proto);
|
|
16
18
|
}
|
|
17
|
-
for (let process of $.
|
|
19
|
+
for (let process of $.middleware.craft) {
|
|
18
20
|
let result = process(...args);
|
|
19
|
-
if (!isUndefined(result)) {
|
|
21
|
+
if (!Utils.isUndefined(result)) {
|
|
20
22
|
addProtoToParent(result);
|
|
21
23
|
return result;
|
|
22
24
|
}
|
|
@@ -24,40 +26,40 @@ function createProto(insert: boolean, ...args: any) {
|
|
|
24
26
|
const [arg1, arg2, arg3] = args;
|
|
25
27
|
|
|
26
28
|
// Proto
|
|
27
|
-
if (
|
|
29
|
+
if (Utils.isInstanceof(arg1, Proto)) {
|
|
28
30
|
addProtoToParent(arg1);
|
|
29
31
|
return arg1;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
// Element Proto
|
|
33
|
-
if (isString(arg1)) {
|
|
34
|
-
let args: [any, any] = isFunction(arg2) ? [,arg2] : [arg2, arg3];
|
|
35
|
+
if (Utils.isString(arg1)) {
|
|
36
|
+
let args: [any, any] = Utils.isFunction(arg2) ? [,arg2] : [arg2, arg3];
|
|
35
37
|
let eleProto = new ElementProto(arg1, ...args);
|
|
36
38
|
addProtoToParent(eleProto);
|
|
37
39
|
return eleProto;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
// Function Handler
|
|
41
|
-
if (isFunction(arg1)) {
|
|
43
|
+
if (Utils.isFunction(arg1)) {
|
|
42
44
|
let args = arg2 ? [arg2, arg3] : [arg3];
|
|
43
|
-
if (
|
|
44
|
-
args = isFunction(arg2) ? [{}, arg2] : [arg2, arg3];
|
|
45
|
+
if (Utils.isInstanceof(arg1.prototype, ElementProto)) {
|
|
46
|
+
args = Utils.isFunction(arg2) ? [{}, arg2] : [arg2, arg3];
|
|
45
47
|
}
|
|
46
48
|
// Constructor Handler
|
|
47
49
|
let target = new arg1(...args);
|
|
48
|
-
if (
|
|
50
|
+
if (Utils.isInstanceof(target, Proto)) {
|
|
49
51
|
addProtoToParent(target);
|
|
50
52
|
return target;
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
if (isArray(arg1)) {
|
|
56
|
+
if (Utils.isArray(arg1)) {
|
|
55
57
|
let valueBuilder = (value: any) => {
|
|
56
|
-
for (let process of $.
|
|
58
|
+
for (let process of $.middleware.text) {
|
|
57
59
|
let proto = process(value);
|
|
58
|
-
if (!isUndefined(proto)) return addProtoToParent(proto);
|
|
60
|
+
if (!Utils.isUndefined(proto)) return addProtoToParent(proto);
|
|
59
61
|
}
|
|
60
|
-
let valueTextProto = isUndefined(value) ?
|
|
62
|
+
let valueTextProto = Utils.isUndefined(value) ? Utils.Null : new TextProto(`${value}`);
|
|
61
63
|
if (valueTextProto) addProtoToParent(valueTextProto);
|
|
62
64
|
}
|
|
63
65
|
|
|
@@ -65,13 +67,13 @@ function createProto(insert: boolean, ...args: any) {
|
|
|
65
67
|
|
|
66
68
|
// Variables Array Handler
|
|
67
69
|
if (!arg1.raw) {
|
|
68
|
-
forEach(arg1, arg => valueBuilder(arg))
|
|
70
|
+
Utils.forEach(arg1, arg => valueBuilder(arg))
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
// Template String Array Handler
|
|
72
74
|
else {
|
|
73
|
-
forEach(arg1 as string[], (str, index) => {
|
|
74
|
-
let strTextProto = str.length ? new TextProto(str) :
|
|
75
|
+
Utils.forEach(arg1 as string[], (str, index) => {
|
|
76
|
+
let strTextProto = str.length ? new TextProto(str) : Utils.Null;
|
|
75
77
|
let value = values[index];
|
|
76
78
|
if (strTextProto) addProtoToParent(strTextProto);
|
|
77
79
|
valueBuilder(value)
|
|
@@ -103,10 +105,6 @@ export namespace $ {
|
|
|
103
105
|
/** Props 是组件函数的参数,集合了该组件的自定义属性,以及组件 Layout 函数和元素属性的传递。 */
|
|
104
106
|
export type Props<T = {}, H = HTMLElement> = { [key: string]: any } & T & Partial<AttrMap<H>>;
|
|
105
107
|
|
|
106
|
-
export type CraftMiddleware = (...args: any[]) => any;
|
|
107
|
-
export type TextMiddleware = (value: any) => Proto | undefined;
|
|
108
|
-
export type AttrMiddleware = (name: string, value: any, proto: ElementProto) => any;
|
|
109
|
-
|
|
110
108
|
export interface Overload<I extends any[] = any> {
|
|
111
109
|
protoConstructor: [
|
|
112
110
|
input: [ProtoConstructor],
|
|
@@ -183,83 +181,62 @@ export namespace $ {
|
|
|
183
181
|
mutate: [];
|
|
184
182
|
}
|
|
185
183
|
|
|
186
|
-
export
|
|
184
|
+
export type CraftMiddleware = (...args: any[]) => any;
|
|
185
|
+
export type TextMiddleware = (value: any) => Proto | undefined;
|
|
186
|
+
export type AttrMiddleware = (name: string, value: any, proto: ElementProto) => any;
|
|
187
|
+
export type SSRMiddleware = ($html: ElementProto, $head: ElementProto) => void;
|
|
188
|
+
|
|
189
|
+
export const middleware = {
|
|
187
190
|
craft: new Set<CraftMiddleware>(),
|
|
188
191
|
text: new Set<TextMiddleware>(),
|
|
189
|
-
attr: new Set<AttrMiddleware>()
|
|
192
|
+
attr: new Set<AttrMiddleware>(),
|
|
193
|
+
ssr: new Set<SSRMiddleware>()
|
|
190
194
|
}
|
|
191
195
|
|
|
192
196
|
export const craft: Craft = (...args: any) => createProto(false, ...args);
|
|
193
197
|
|
|
194
|
-
export const render = (proto: Proto | Constructor<Proto>, query: string) => {
|
|
198
|
+
export const render = async (proto: Proto | Constructor<Proto>, query: string) => {
|
|
195
199
|
// Disable render on server side
|
|
196
200
|
if (onserver()) return;
|
|
197
201
|
|
|
198
|
-
let
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
export const context = (object: {proto: Proto | null}, parent: Proto | null, callback: () => void) => {
|
|
207
|
-
let cacheProtoParent = object.proto;
|
|
208
|
-
object.proto = parent;
|
|
209
|
-
callback();
|
|
210
|
-
object.proto = cacheProtoParent;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export const call = <T>(callback: () => T) => callback();
|
|
202
|
+
let $proto = $(proto as Proto)
|
|
203
|
+
let nodes = $proto.build().toDOM()
|
|
204
|
+
let element = document.querySelector(query);
|
|
205
|
+
if (!element) return;
|
|
206
|
+
await Promise.all($proto.global.promises);
|
|
207
|
+
if (hmr(element, $proto)) {
|
|
208
|
+
} else element?.replaceChildren(...nodes);
|
|
214
209
|
|
|
215
|
-
|
|
216
|
-
case<C extends Exclude<T, Rec>, V>(condition: C, callback: () => V): MatchCase<T, Rec | C, Res | V, Def>
|
|
217
|
-
default<V>(callback: () => V): MatchCase<T, Rec, Res, V>
|
|
210
|
+
if (onclient()) document.querySelector('style#__ssr__')?.remove();
|
|
218
211
|
}
|
|
219
212
|
|
|
220
|
-
export const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
: Res | Def
|
|
227
|
-
: never => {
|
|
228
|
-
var cases = new Map();
|
|
229
|
-
var symbol_default = Symbol('default');
|
|
230
|
-
var match = {
|
|
231
|
-
case: (condition: any, callback: () => any) => {
|
|
232
|
-
cases.set(condition, callback);
|
|
233
|
-
return match;
|
|
234
|
-
},
|
|
235
|
-
default: (callback: () => any) => {
|
|
236
|
-
cases.set(symbol_default, callback);
|
|
237
|
-
return match;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
callback(match as any);
|
|
241
|
-
return cases.get(condition)?.() ?? cases.get(symbol_default)?.();
|
|
213
|
+
export const context = <T>(parent: Proto | null, callback: () => T): T => {
|
|
214
|
+
let cacheProtoParent = Proto.proto;
|
|
215
|
+
Proto.proto = parent;
|
|
216
|
+
let result = callback();
|
|
217
|
+
Proto.proto = cacheProtoParent;
|
|
218
|
+
return result;
|
|
242
219
|
}
|
|
243
220
|
|
|
244
|
-
export const tuple = <T extends any[]>(...args: T) => args;
|
|
245
|
-
|
|
246
221
|
export const async = <T>(fn: (parent: Proto | null) => Promise<T>): Promise<T> => Proto.proto?.global.asyncTask(fn(Proto.proto)) ?? fn(Proto.proto);
|
|
247
222
|
|
|
248
|
-
export const
|
|
223
|
+
export const process = (handle: (proc: ProtoProcess) => ProtoProcess) => handle(new ProtoProcess()).run()
|
|
224
|
+
|
|
225
|
+
export const stylesheet = onclient() ? new CSSStyleSheet() : Utils.Null;
|
|
249
226
|
export const styleMap = new Map<Constructor<ElementProto>, Set<string>>();
|
|
250
227
|
export const style = (proto: Constructor<ElementProto<any>> | null, css: string | string[]) => {
|
|
251
|
-
let rules = toArray(css)
|
|
228
|
+
let rules = Utils.toArray(css)
|
|
252
229
|
if (proto) {
|
|
253
230
|
let set = styleMap.get(proto) ?? new Set();
|
|
254
|
-
forEach(rules, rule => set.add(rule));
|
|
231
|
+
Utils.forEach(rules, rule => set.add(rule));
|
|
255
232
|
styleMap.set(proto, set);
|
|
256
233
|
}
|
|
257
|
-
if (stylesheet) forEach(rules, rule => stylesheet!.insertRule(rule));
|
|
234
|
+
if (stylesheet) Utils.forEach(rules, rule => stylesheet!.insertRule(rule));
|
|
258
235
|
}
|
|
259
236
|
|
|
260
237
|
if (stylesheet) document.adoptedStyleSheets.push(stylesheet);
|
|
261
238
|
|
|
262
|
-
|
|
239
|
+
stylesheet?.insertRule(`@layer base, ui`)
|
|
263
240
|
}
|
|
264
241
|
|
|
265
242
|
export type $ = typeof $;
|
|
@@ -274,3 +251,4 @@ export * from "#structure/ProxyProto";
|
|
|
274
251
|
export * from "#structure/TextProto";
|
|
275
252
|
export * from "#env";
|
|
276
253
|
export * from "#lib/symbols";
|
|
254
|
+
export * from "#lib/virtual_scroll";
|