@ecopages/radiant-ui 0.2.4 → 0.2.5

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.
@@ -1,2 +1,2 @@
1
- import{RadiantElement as Gt,bindTo as se,customElement as Wr,event as zr,onEvent as le,onUpdated as Wt,prop as U,query as Hr,state as Ur}from"@ecopages/radiant";function Sr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(`(max-width: ${639}px)`).matches}function it(t){return t<=1||!Sr()?t:1}function at(t){if(typeof window>"u"||typeof window.matchMedia!="function")return null;let e=window.matchMedia(`(max-width: ${639}px)`);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}var Mr=/^[A-Za-z][A-Za-z0-9_-]*$/;function ot(t){return Mr.test(t)}function Ir(t){let e=t.trim();if(ot(e))return e;let n=`rui-${e}`;return e&&ot(n)?n:"rui"}function De(t){let e=typeof crypto.randomUUID=="function"?crypto.randomUUID().replace(/-/g,""):Array.from(crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("");return`${Ir(t)}-${e}`}var Rr={top:"bottom",bottom:"top",left:"right",right:"left"},Fr=8,Le=new WeakMap;function Pr(t){Le.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",Le.delete(t))}function Er(t){let e=t.indexOf("-");if(e===-1)return{side:t,align:"center"};let n=t.slice(0,e),r=t.slice(e+1);return{side:n,align:r==="start"||r==="end"?r:"center"}}function ut(t){return t==="top"||t==="bottom"?"y":"x"}function st(t,e,n,r,i){let{width:a,height:s}=e,o=0,f=0;switch(n){case"top":f=t.top-s-i;break;case"bottom":f=t.bottom+i;break;case"left":o=t.left-a-i;break;case"right":o=t.right+i;break}return ut(n)==="y"?r==="start"?o=t.left:r==="end"?o=t.right-a:o=t.left+(t.width-a)/2:r==="start"?f=t.top:r==="end"?f=t.bottom-s:f=t.top+(t.height-s)/2,{x:o,y:f}}function Ar(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?Math.max(0,i-t.y):n==="bottom"?Math.max(0,t.y+e.height-(s-i)):n==="left"?Math.max(0,i-t.x):Math.max(0,t.x+e.width-(a-i))}function lt(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?t.top-i-e.height:n==="bottom"?s-i-e.height-t.bottom:n==="left"?t.left-i-e.width:a-i-e.width-t.right}function Tr(t,e){return e==="center"?t:`${t}-${e}`}function kr(t,e,n,r){let{padding:i,width:a,height:s}=r;if(ut(n)==="y"){let f=Math.max(i,a-i-e.width);return{x:Math.min(Math.max(t.x,i),f),y:Math.max(i,t.y)}}let o=Math.max(i,s-i-e.height);return{x:Math.max(i,t.x),y:Math.min(Math.max(t.y,i),o)}}function Lr(t,e,n,r,i={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Fr}){let{side:a,align:s}=Er(n),o=st(t,e,a,s,r),f=Ar(o,e,a,i),y=a,x=o;if(f>0){let R=Rr[a],M=st(t,e,R,s,r),O=lt(t,e,a,i);lt(t,e,R,i)>O&&(y=R,x=M)}return{coords:kr(x,e,y,i),placement:Tr(y,s)}}function Cr(t,e,n,r,i={}){let a=i.matchAnchorWidth===!0,s=t.offsetWidth,o=a?{width:s,height:e.offsetHeight}:{width:e.offsetWidth,height:e.offsetHeight};a?(e.style.width=`${s}px`,e.style.minWidth=`${s}px`,e.style.maxWidth=`${s}px`,e.style.boxSizing="border-box",Le.set(e,!0)):Pr(e);let{coords:f,placement:y}=Lr(t.getBoundingClientRect(),o,n,r);return Object.assign(e.style,{position:"fixed",left:`${f.x}px`,top:`${f.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),e.setAttribute("data-placement",y),y}function ct({anchor:t,floating:e,getPlacement:n,gap:r,matchAnchorWidth:i}){let a=()=>{e.hidden||Cr(t,e,n(),r,{matchAnchorWidth:i})};a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0);let s=new ResizeObserver(a);return s.observe(t),s.observe(e),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),s.disconnect()}}function dt(t,e=document.body){let n=t.parentNode;if(!n)return{unmount:()=>{}};let r=document.createComment("rui-portal");return n.insertBefore(r,t),e.appendChild(t),{unmount:()=>{let i=r.parentNode;i&&(i.insertBefore(t,r),r.remove())}}}function ht(t,e,n){return n?!!(t?.contains(n)||e?.contains(n)):!1}function ft(t,e,n){return n instanceof Node?!ht(t,e,n):!0}var Se=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(e){this.config=e}updateConfig(e){this.config={...this.config,...e}}sync(){let e=this.resolveFloating();if(!e)return;if(!this.config.getOpen()){this.teardown(),e.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;e.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=dt(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=ct({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return ht(this.config.getAnchor(),this.resolveFloating(),e)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let e=this.config.getFloating();return e&&(this.floatingElement=e),e??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};var Me=class{config;popoverController=null;suppressPopoverDismiss=!1;constructor(e){this.config=e}destroy(){this.popoverController?.destroy(),this.popoverController=null}suppressDismiss(){this.suppressPopoverDismiss=!0}syncPopover(){let e=this.config.getFloating();if(!e)return;e.hidden=!this.config.getOpen();let n=this.ensureController();n.updateConfig({getOpen:()=>this.config.getOpen()}),n.sync()}focusCalendarDay(){Vr(this.config.getCalendar(),this.config.getFocusIso())}handleFocusOut(e,n){let r=e.relatedTarget;queueMicrotask(()=>{if(this.suppressPopoverDismiss){this.suppressPopoverDismiss=!1;return}if(!this.config.getOpen())return;let i=this.config.getFloating();if(!i)return;let a=r instanceof Node?r:document.activeElement;ft(this.config.getHost(),i,a)&&n()})}ensureController(){return this.popoverController||(this.popoverController=new Se({getAnchor:this.config.getAnchor,getFloating:this.config.getFloating,getOpen:this.config.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}};function Vr(t,e){requestAnimationFrame(()=>{if(!t)return;((e?t.querySelector(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`):null)??t.querySelector('[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day]:not(:disabled)'))?.focus()})}function Or(t){let e=t.previousElementSibling;return e?.tagName.toLowerCase()==="label"?e:t.parentElement?.querySelector("[data-rui-field-label]")??null}function jr(t,e,n){t.id||(t.id=n.labelId),t.htmlFor||(t.htmlFor=n.controlId),e.setAttribute("aria-labelledby",t.id),e.removeAttribute("aria-label")}function pt(t,e,n){if(!e||e.hasAttribute("data-rui-field-managed"))return;let r=Or(t);if(r){jr(r,e,n);return}if(n.label){e.setAttribute("aria-label",n.label),e.removeAttribute("aria-labelledby");return}e.removeAttribute("aria-label"),e.removeAttribute("aria-labelledby")}var mt,gt,yt,vt,bt,xt,_t,wt,Dt,St,Mt,It,Rt,Ft,Pt,Et,At,Tt,kt,Lt,Ct,Vt,Ot,jt,Yt,Bt;function Yr(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:$t(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||$t(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:Br(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return Gr(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function Br(t){var e=$r(t,"string");return typeof e=="symbol"?e:e+""}function $r(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $t(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function Gr(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var Ht,zt=class extends Gt{static{({e:[yt,vt,bt,xt,_t,wt,Dt,St,Mt,It,Rt,Ft,Pt,Et,At,Tt,kt,Lt,Ct,Vt,Ot,jt,Yt,Bt,mt],c:[Ht,gt]}=Yr(this,[Wr("rui-date-field")],[[[U({type:String,reflect:!0,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"value"},{selector:"[data-date-field-calendar]",attr:"value"}])],0,"value"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"min"},{selector:"[data-date-field-calendar]",attr:"min"}])],0,"min"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"max"},{selector:"[data-date-field-calendar]",attr:"max"}])],0,"max"],[[U({type:Boolean,reflect:!0,defaultValue:!1}),se([{selector:"[data-date-field-input]",bool:"disabled"},{selector:"[data-date-field-calendar]",bool:"disabled"}])],0,"disabled"],[[U({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),se({selector:"[data-date-field-input]",bool:"read-only"})],0,"readOnly"],[U({type:String,defaultValue:""}),0,"label"],[[U({type:String,defaultValue:""}),se({selector:"[data-date-field-input]",attr:"name"})],0,"name"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"locale"},{selector:"[data-date-field-calendar]",attr:"locale"}])],0,"locale"],[U({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[zr({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[[Ur,se({selector:"[data-date-field-trigger]",attr:"aria-expanded"})],0,"open"],[Hr({ref:"popover"}),0,"popoverTarget"],[Wt(["value","min","max","label","disabled","readOnly","locale","visibleMonths"]),2,"onPropsUpdated"],[Wt(["open"]),2,"onOpenUpdated"],[le({selector:"[data-date-field-input]",type:"rui-change"}),2,"onDateInputChange"],[le({selector:"[data-date-field-input]",type:"rui-form-reset"}),2,"onDateInputReset"],[le({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-popover]",type:"focusout"}),2,"onRootFocusOut"],[le({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[le({ref:"trigger",type:"click"}),2,"onTriggerClick"],[le({selector:"[data-date-field-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[le({selector:"[data-date-field-calendar]",type:"rui-change"}),2,"onCalendarChange"],[le({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-calendar]",type:"keydown"}),2,"onRootKeydown"]],0,void 0,Gt))}value=(mt(this),yt(this));min=(vt(this),bt(this));max=(xt(this),_t(this));disabled=(wt(this),Dt(this));readOnly=(St(this),Mt(this));label=(It(this),Rt(this));name=(Ft(this),Pt(this));locale=(Et(this),At(this));visibleMonths=(Tt(this),kt(this));changeEvent=(Lt(this),Ct(this));open=(Vt(this),Ot(this,!1));uid=(jt(this),De("rui-date-field"));calendarPopover=new Me({getHost:()=>this,getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getCalendar:()=>this.getCalendar(),getFocusIso:()=>this.isoValue||void 0});disposeMobileLayoutListener=null;popoverTarget=Yt(this);onMediaChange=(Bt(this),()=>{this.syncCalendar(),this.open&&this.calendarPopover.syncPopover()});get isoValue(){return this.value??""}get inputId(){return`${this.uid}-input`}getDateInput(){return this.querySelector("[data-date-field-input]")}getToggle(){return this.querySelector("[data-date-field-trigger]")}getCalendar(){return this.querySelector("[data-date-field-calendar]")}syncLabel(){let e=this.getDateInput();pt(this,e,{controlId:this.inputId,label:this.label,labelId:`${this.uid}-label`})}syncInput(){let e=this.getDateInput();e?.id||e?.setAttribute("id",this.inputId)}syncToggle(){let e=this.getToggle();e&&(e.disabled=this.disabled||this.readOnly)}commitValue(e){e!==this.isoValue&&(this.value=e,this.changeEvent.emit({value:e}))}syncCalendar(){let e=this.getCalendar();e&&(e.setAttribute("selection-mode","single"),e.setAttribute("visible-months",String(it(this.visibleMonths))))}initialize(){this.syncLabel(),this.syncInput(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}setOpen(e){this.open=e,queueMicrotask(()=>{this.calendarPopover.syncPopover(),e&&this.calendarPopover.focusCalendarDay()})}onConnected(){this.disposeMobileLayoutListener=at(this.onMediaChange),this.initialize()}disconnectedCallback(){this.disposeMobileLayoutListener?.(),this.disposeMobileLayoutListener=null,this.calendarPopover.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncInput(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.calendarPopover.syncPopover()}onDateInputChange(e){let n=e.target;if(!(n instanceof HTMLElement)||!n.matches("[data-date-field-input]"))return;let r=e.detail;this.commitValue(r?.value??"")}onDateInputReset(){let e=this.getDateInput(),n=e&&Reflect.get(e,"value");this.value=typeof n=="string"?n:""}onRootFocusOut(e){this.calendarPopover.handleFocusOut(e,()=>this.setOpen(!1))}onTriggerPointerDown(){this.calendarPopover.suppressDismiss()}onTriggerClick(){this.disabled||this.readOnly||this.setOpen(!this.open)}onPopoverMouseDown(e){e.preventDefault()}onCalendarChange(e){let n=e.target;if(!(n instanceof HTMLElement)||!n.matches("[data-date-field-calendar]"))return;let r=e.detail;r?.value&&(this.commitValue(r.value),this.setOpen(!1))}onRootKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),this.setOpen(!1))}static{gt()}};import{Fragment as Ii,jsx as B,jsxs as yr}from"@ecopages/jsx/jsx-runtime";function Ut(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function q(...t){return t.filter(Boolean).join(" ")}import{jsx as Ie,jsxs as qr}from"@ecopages/jsx/jsx-runtime";function Ce({class:t,size:e="sm",...n}){return qr("svg",{...n,class:q("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[Ie("path",{d:"M8 2v4"}),Ie("path",{d:"M16 2v4"}),Ie("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Ie("path",{d:"M3 10h18"})]})}import{jsx as Y,jsxs as tt}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as $n,customElement as hi,event as fi,onEvent as pe,onUpdated as pi,prop as ue,registerSsrPreparationCallback as mi,state as ce}from"@ecopages/radiant";function Re(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}function de(t){if(t==null)return null;let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;let n=Number(e[1]),r=Number(e[2])-1,i=Number(e[3]),a=new Date(n,r,i);return a.getFullYear()!==n||a.getMonth()!==r||a.getDate()!==i?null:a}function K(t){let e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`}function _e(t,e,n){return!(e&&t<e||n&&t>n)}function he(t,e){return t.localeCompare(e)}function me(t,e){return he(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function ge(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:me(e,n)}function Ve(t){if(!t)return"";let e=me(t.start,t.end);return`${e.start}/${e.end}`}function ye(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(he):[]}function Oe(t){return[...new Set(t)].sort(he).join(",")}function je(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(he)}function qt(t,e){let n=me(e.start,e.end);return he(t,n.start)>=0&&he(t,n.end)<=0}function Ye(t,e,n){if(e==="single"){let y=n.singleIso===t;return{isSelected:y,isRangeStart:y,isRangeEnd:y,isRangeMiddle:!1}}if(e==="multiple"){let y=n.multipleIsos?.includes(t)??!1;return{isSelected:y,isRangeStart:y,isRangeEnd:y,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let i=me(r.start,r.end),a=qt(t,i),s=t===i.start,o=t===i.end;return{isSelected:a,isRangeStart:s,isRangeEnd:o,isRangeMiddle:a&&!s&&!o}}function Be(t,e,n){return e.anchor?{committed:me(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function Fe(t){let e=Kr(t);try{let r=new Intl.Locale(e).weekInfo;if(r?.firstDay!=null)return r.firstDay===7?0:r.firstDay}catch{}return e.startsWith("en-US")?0:1}function Kr(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function Nr(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Xr(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Jr(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:ye(n)};if(e==="range"){let r=ge(n);if(t.rangeDraft?.anchor){let i=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:Zr(t.rangeDraft.anchor,i)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function Zr(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function $e(t,e,n){let r=Fe(n.locale),i=Nr(n.today??new Date),a=Jr(n),o=(new Date(t,e,1).getDay()-r+7)%7,f=new Date(t,e,1-o),y=[],x=new Date(f);for(let R=0;R<6;R+=1){let M=[];for(let O=0;O<7;O+=1){let j=K(x),A=Ye(j,a.mode,{singleIso:a.singleIso,multipleIsos:a.multipleIsos,range:a.range});M.push({date:new Date(x),iso:j,inMonth:x.getMonth()===e,isToday:Xr(x,i),isSelected:A.isSelected,isDisabled:!_e(j,n.min,n.max),isRangeStart:A.isRangeStart,isRangeEnd:A.isRangeEnd,isRangeMiddle:A.isRangeMiddle}),x.setDate(x.getDate()+1)}if(y.push(M),R>=4&&x.getMonth()!==e&&x.getDate()>7)break}return y}function Pe(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function Ge(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(i,a)=>{let s=Pe(t,e,a);return{year:s.year,month:s.month,offset:a}})}var Kt=new Map;function Qr(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function fe(t,e){let n=Qr(t,e),r=Kt.get(n);if(r)return r;let i=new Intl.DateTimeFormat(t,e);return Kt.set(n,i),i}function We(t,e){return fe(e,{month:"long",year:"numeric"}).format(t)}function ze(t,e){let n=fe(t,{weekday:"narrow"}),r=[];for(let i=0;i<7;i+=1){let a=(e+i)%7,s=new Date(2024,0,a===0?7:a);r.push(n.format(s))}return r}function He(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var ei=new Date(2e3,0,1);function ti(t,e){return t==="year"?e==="year":t==="month"?e==="year"||e==="month":!0}function ni(t,e){let r=fe(e,{[t]:t==="year"?"numeric":"2-digit"}).formatToParts(ei).find(i=>i.type===t);return r?r.value.replace(/\d/g,t==="year"?"y":t==="month"?"m":"d"):t==="year"?"yyyy":"mm"}function ri(t,e,n){let r=t==="year"?{year:"numeric"}:{[t]:"2-digit"};return fe(n,r).formatToParts(e).find(i=>i.type===t)?.value??""}function Ee(t,e,n={}){let r=n.granularity??"day",i=t??n.placeholderDate??new Date;return fe(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).filter(s=>s.type!=="era").map(s=>{if(s.type==="literal")return{type:"literal",value:s.value,placeholder:s.value,isPlaceholder:!1,editable:!1};let o=s.type;if(!ti(r,o))return null;let f=t!=null;return{type:o,value:f?ri(o,t,e):"",placeholder:ni(o,e),isPlaceholder:!f,editable:!0}}).filter(s=>s!=null)}function ii(t){if(t.isPlaceholder||t.value==="")return null;let e=Number(t.value);return Number.isFinite(e)?e:null}function ai(t){return t>=100?t:t>=69?1900+t:2e3+t}function Nt(t){let e={};for(let r of t){if(!r.editable)continue;let i=ii(r);if(i==null)return null;e[r.type]=r.type==="year"?ai(i):i}if(e.year==null||e.month==null||e.day==null)return null;let n=new Date(e.year,e.month-1,e.day);return n.getFullYear()!==e.year||n.getMonth()!==e.month-1||n.getDate()!==e.day?null:n}function Xt(t){return t.every(e=>!e.editable||e.isPlaceholder||e.value==="")}function Ue(t,e={}){let n=t.find(a=>a.editable&&a.type==="year");if(n&&!n.isPlaceholder&&n.value!==""&&n.value.replace(/\D/g,"").length<4)return{kind:"partial-year"};if(Xt(t))return{kind:"empty"};let r=Nt(t);if(!r)return{kind:"incomplete"};let i=K(r);return _e(i,e.min,e.max)?{kind:"date",iso:i}:{kind:"out-of-range"}}function qe(t){return t==="year"?4:2}function oi(t,e){return t.findIndex(n=>n.editable&&n.type===e)}function si(t){return t.map(e=>({...e}))}function Ne(t,e,n){let r=si(t),i=oi(r,e);return i<0||(r[i]={...r[i],...n}),r}function Ke(t){if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Ae(t,e){return{min:1,max:Zt(t,e)}}function Zt(t,e){if(t==="month")return 12;if(t==="day"){let n=Jt(e,"year"),r=Jt(e,"month");return n!=null&&r!=null?new Date(n,r,0).getDate():31}return 9999}function Jt(t,e){let n=t.find(r=>r.editable&&r.type===e);return!n||n.isPlaceholder||n.value===""?null:Number(n.value)}function Qt(t,e){return t==="year"?String(e).padStart(4,"0"):String(e).padStart(2,"0")}function Xe(t,e){try{let r=new Intl.DisplayNames(e,{type:"dateTimeField"}).of(t);if(r)return r}catch{}return t==="month"?"Month":t==="day"?"Day":"Year"}function we(t){return t.isPlaceholder||t.value===""?t.placeholder:t.value}function Te(t){return t.isPlaceholder||t.value===""?null:Ke(t.value.replace(/\D/g,""))}function en(t,e){return Ne(t,e,{value:"",isPlaceholder:!0})}function tn(t,e,n){return Ne(t,e,{value:Qt(e,n),isPlaceholder:!1})}function Je(t,e,n){let r=t.find(f=>f.editable&&f.type===e);if(!r)return t;let{min:i,max:a}=Ae(e,t),o=(Te(r)??(n>0?i-1:a+1))+n;return e==="month"||e==="day"?o<i?o=a:o>a&&(o=i):o=Math.max(i,o),tn(t,e,o)}function Ze(t,e,n,r){let i=n.replace(/\D/g,"");if(!i)return{segments:t,enteredKeys:r,focusNext:!1};let a=r+i,s=Ke(a);if(s==null)return{segments:t,enteredKeys:r,focusNext:!1};let o=Zt(e,t),f=s;f>o&&(f=Ke(i)??f);let y=qe(e),x=+`${f}0`>o||a.length>=y||String(f).length>=y,R=x?Qt(e,f):String(f);return{segments:Ne(t,e,{value:R,isPlaceholder:!1}),enteredKeys:x?"":a,focusNext:x}}function nn(t){return t.filter(e=>e.editable).map(e=>e.type)}function ve(t,e,n){let r=nn(t),i=r.indexOf(e);if(i<0)return r[0]??null;let a=i+n;return a<0||a>=r.length?null:r[a]??null}function Qe(t){let e=null;for(let n of t){if(!n.editable)continue;let r=n.type;if(e||(e=r),n.isPlaceholder||n.value==="")return r}return e}function et(t,e){let n=t.find(a=>a.editable&&a.type===e);if(!n)return{kind:"focus-previous"};if(n.isPlaceholder||n.value==="")return{kind:"focus-previous"};let r=n.value.replace(/\D/g,"");if(r.length<=1)return{kind:"updated",segments:en(t,e),enteredKeys:""};let i=r.slice(0,-1);return{kind:"updated",segments:t.map(a=>a.editable&&a.type===e?{...a,value:i,isPlaceholder:!1}:a),enteredKeys:i}}var rn,an,on,sn,ln,un,cn,dn,hn,fn,pn,mn,gn,yn,vn,bn,xn,_n,wn,Dn,Sn,Mn,In,Rn,Fn,Pn,En,An,Tn,kn,Ln,Cn,Vn,On,jn,Yn;function li(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:Bn(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||Bn(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:ui(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return di(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function ui(t){var e=ci(t,"string");return typeof e=="symbol"?e:e+""}function ci(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bn(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function di(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var Wn,Gn=class extends $n{static{({e:[on,sn,ln,un,cn,dn,hn,fn,pn,mn,gn,yn,vn,bn,xn,_n,wn,Dn,Sn,Mn,In,Rn,Fn,Pn,En,An,Tn,kn,Ln,Cn,Vn,On,jn,Yn,rn],c:[Wn,an]}=li(this,[hi("rui-calendar")],[[ue({type:String,reflect:!0,defaultValue:""}),0,"value"],[ue({type:String,defaultValue:""}),0,"min"],[ue({type:String,defaultValue:""}),0,"max"],[ue({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[ue({type:String,defaultValue:""}),0,"locale"],[ue({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[ue({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[ue({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[fi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[ce,0,"viewYear"],[ce,0,"viewMonth"],[ce,0,"focusedIso"],[ce,0,"weekdayLabels"],[ce,0,"monthPanels"],[ce,0,"todayLabel"],[ce,0,"rangeAnchor"],[ce,0,"rangeHover"],[pi(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[pe({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[pe({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[pe({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[pe({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[pe({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[pe({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[pe({selector:"[data-calendar-day]",type:"keydown"}),2,"onDayKeydown"]],0,void 0,$n))}value=(rn(this),on(this));min=(sn(this),ln(this));max=(un(this),cn(this));disabled=(dn(this),hn(this));locale=(fn(this),pn(this));selectionMode=(mn(this),gn(this));visibleMonths=(yn(this),vn(this));pageBehavior=(bn(this),xn(this));changeEvent=(_n(this),wn(this));viewYear=(Dn(this),Sn(this,new Date().getFullYear()));viewMonth=(Mn(this),In(this,new Date().getMonth()));focusedIso=(Rn(this),Fn(this,""));weekdayLabels=(Pn(this),En(this,[]));monthPanels=(An(this),Tn(this,[]));todayLabel=(kn(this),Ln(this,""));rangeAnchor=(Cn(this),Vn(this,null));rangeHover=(On(this),jn(this,null));get resolvedLocale(){return Re(this.locale)}get pageDelta(){return this.pageBehavior==="single"?1:Math.max(1,Math.min(this.visibleMonths,12))}get monthOptions(){return{locale:this.resolvedLocale,selectionMode:this.selectionMode,value:this.value??"",rangeDraft:{anchor:this.rangeAnchor,hover:this.rangeHover},min:this.min||void 0,max:this.max||void 0}}syncViewFromValue(){let e=this.selectionMode==="range"?ge(this.value)?.start??"":this.selectionMode==="multiple"?ye(this.value)[0]??"":this.value,n=de(e);if(n){this.viewYear=n.getFullYear(),this.viewMonth=n.getMonth(),this.focusedIso=e;return}let r=new Date;this.viewYear=r.getFullYear(),this.viewMonth=r.getMonth(),this.focusedIso=K(r)}refreshGrid(){this.weekdayLabels=ze(this.resolvedLocale,Fe(this.resolvedLocale)),this.monthPanels=Ge(this.viewYear,this.viewMonth,this.visibleMonths).map(e=>{let n=new Date(e.year,e.month,1);return{year:e.year,month:e.month,label:We(n,this.resolvedLocale),weeks:$e(e.year,e.month,this.monthOptions)}}),this.todayLabel=He(this.resolvedLocale)}moveMonth(e){let n=Pe(this.viewYear,this.viewMonth,e);this.viewYear=n.year,this.viewMonth=n.month,this.refreshGrid()}getFlatDays(){return this.monthPanels.flatMap(e=>e.weeks.flat())}moveFocusedDay(e){let n=this.getFlatDays().filter(s=>!s.isDisabled);if(!n.length)return;let r=n.findIndex(s=>s.iso===this.focusedIso),i=r<0?Math.max(0,n.findIndex(s=>s.inMonth)):(r+e+n.length)%n.length,a=n[i];if(a){if(!this.isMonthVisible(a.date)){this.viewYear=a.date.getFullYear(),this.viewMonth=a.date.getMonth(),this.focusedIso=a.iso,this.refreshGrid(),this.focusFocusedDay();return}this.focusedIso=a.iso,this.focusDayInCurrentGrid(a.iso)}}isMonthVisible(e){let n=this.viewYear*12+this.viewMonth,r=n+this.visibleMonths-1,i=e.getFullYear()*12+e.getMonth();return i>=n&&i<=r}focusDayInCurrentGrid(e){let n=this.querySelector('[data-calendar-day][tabindex="0"]'),r=Array.from(this.querySelectorAll(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`)),i=r.find(a=>!a.hasAttribute("data-outside"))??r[0];i&&(n&&n!==i&&(n.tabIndex=-1),i.tabIndex=0,i.focus())}focusFocusedDay(){requestAnimationFrame(()=>{this.focusDayInCurrentGrid(this.focusedIso)})}moveFocusedMonth(e){let n=de(this.focusedIso)??new Date(this.viewYear,this.viewMonth,1),r=new Date(n.getFullYear(),n.getMonth()+e,1),i=new Date(r.getFullYear(),r.getMonth()+1,0).getDate(),a=new Date(r.getFullYear(),r.getMonth(),Math.min(n.getDate(),i));this.viewYear=a.getFullYear(),this.viewMonth=a.getMonth(),this.focusedIso=K(a),this.refreshGrid(),this.focusFocusedDay()}isIsoAllowed(e){return!(this.min&&e<this.min||this.max&&e>this.max)}emitChange(e,n={}){this.changeEvent.emit({value:e,...n})}selectSingle(e){!this.isIsoAllowed(e)||e===this.value||(this.value=e,this.emitChange(e),this.refreshGrid())}selectMultiple(e){if(!this.isIsoAllowed(e))return;let n=Oe(je(ye(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=Be(ge(this.value),{anchor:this.rangeAnchor,hover:this.rangeHover},e);if(this.rangeAnchor=n.draft.anchor,this.rangeHover=n.draft.hover,n.committed){let r=Ve(n.committed);r!==this.value&&(this.value=r,this.emitChange(r,{start:n.committed.start,end:n.committed.end}))}this.refreshGrid()}selectIso(e){if(this.selectionMode==="multiple"){this.selectMultiple(e);return}if(this.selectionMode==="range"){this.selectRange(e);return}this.selectSingle(e)}previewRange(e){this.selectionMode!=="range"||!this.rangeAnchor||this.disabled||this.rangeHover!==e&&(this.rangeHover=e,this.refreshGrid())}clearRangePreview(){this.rangeHover&&(this.rangeHover=this.rangeAnchor,this.refreshGrid())}initialize(){this.syncViewFromValue(),this.refreshGrid()}constructor(){super(),Yn(this),mi(this,()=>this.initialize())}onConnected(){this.initialize()}onPropsUpdated(){this.selectionMode!=="range"&&(this.rangeAnchor=null,this.rangeHover=null),this.syncViewFromValue(),this.refreshGrid()}onPrevMonth(e){e.preventDefault(),this.moveMonth(-this.pageDelta)}onNextMonth(e){e.preventDefault(),this.moveMonth(this.pageDelta)}onTodayClick(e){e.preventDefault(),this.selectIso(K(new Date))}onDayClick(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.disabled||this.selectIso(r)}onDayPointerEnter(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.previewRange(r)}onGridPointerLeave(){this.clearRangePreview()}onDayKeydown(e){if(this.disabled)return;let n=e.target.getAttribute("data-iso");if(n&&(this.focusedIso=n),e.key==="ArrowLeft"){e.preventDefault(),this.moveFocusedDay(-1);return}if(e.key==="ArrowRight"){e.preventDefault(),this.moveFocusedDay(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this.moveFocusedDay(-7);return}if(e.key==="ArrowDown"){e.preventDefault(),this.moveFocusedDay(7);return}if(e.key==="PageUp"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?-12:-this.pageDelta);return}if(e.key==="PageDown"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?12:this.pageDelta);return}if(e.key==="Enter"||e.key===" "){e.preventDefault();let r=e.target,i=r.getAttribute("data-iso");i&&!r.disabled&&this.selectIso(i)}}dayDataAttributes(e){return{"data-range-start":e.isRangeStart?"true":void 0,"data-range-end":e.isRangeEnd?"true":void 0,"data-range-middle":e.isRangeMiddle?"true":void 0}}render(){let e=this.monthPanels.length,n=e>1;return tt("div",{class:`rui-calendar${n?" rui-calendar--multi":""}`,"data-ref":"root",role:"application","aria-label":"Calendar","aria-multiselectable":this.selectionMode==="multiple"?"true":void 0,children:[Y("div",{class:"rui-calendar__months",children:this.monthPanels.map((r,i)=>tt("div",{class:"rui-calendar__month-panel","data-calendar-month-panel":!0,children:[tt("div",{class:"rui-calendar__header",children:[i===0?Y("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):Y("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),Y("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),i===e-1?Y("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):Y("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),i===0?Y("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(a=>Y("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:a}))}):null,Y("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(a=>Y("div",{class:"rui-calendar__week",role:"row",children:a.map(s=>Y("button",{type:"button",class:"rui-calendar__day","data-calendar-day":!0,"data-iso":s.iso,role:"gridcell",disabled:this.disabled||s.isDisabled,tabIndex:s.iso===this.focusedIso?0:-1,"aria-selected":s.isSelected?"true":"false","aria-current":s.isToday?"date":void 0,"data-outside":s.inMonth?void 0:"true",...this.dayDataAttributes(s),children:s.date.getDate()}))}))})]}))}),Y("div",{class:"rui-calendar__footer",children:Y("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{an()}};import{jsx as gi}from"@ecopages/jsx/jsx-runtime";function nt({children:t,...e}){return gi("rui-calendar",{...e,children:t})}import{jsx as ke}from"@ecopages/jsx/jsx-runtime";import{customElement as _i,event as wi,onEvent as be,onUpdated as hr,prop as xe,registerSsrPreparationCallback as Di,state as fr}from"@ecopages/radiant";import{FormAssociatedElement as pr}from"@ecopages/radiant/form-associated-element";function zn(t,e){let n=t.type,r=Te(t),i=!e.useTextboxRole,a=i?"spinbutton":"textbox",s=!e.disabled&&!e.readOnly,o=Ae(n,e.segments);return{ariaLabel:Xe(n,e.locale),ariaReadonly:e.readOnly||void 0,ariaRole:a,ariaValuemax:i?o.max:void 0,ariaValuemin:i?o.min:void 0,ariaValuenow:i&&r!=null?r:void 0,ariaValuetext:i?we(t):void 0,className:q("rui-date-input__segment",t.isPlaceholder&&"rui-date-input__segment--placeholder"),dataRuiFocusManaged:!0,contenteditable:s?"true":void 0,inputmode:s?"numeric":void 0,suppresscontenteditablewarning:s?"true":void 0,tabindex:e.disabled?void 0:0}}var Hn,Un,qn,Kn,Nn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr;function yi(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:dr(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||dr(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:vi(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return xi(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function vi(t){var e=bi(t,"string");return typeof e=="symbol"?e:e+""}function bi(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dr(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function xi(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}function Si(){return typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)}var gr,mr=class extends pr{static{({e:[qn,Kn,Nn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,Hn],c:[gr,Un]}=yi(this,[_i("rui-date-input")],[[xe({type:String,reflect:!0,defaultValue:""}),0,"value"],[xe({type:String,defaultValue:""}),0,"min"],[xe({type:String,defaultValue:""}),0,"max"],[xe({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[xe({type:String,defaultValue:""}),0,"label"],[xe({type:String,defaultValue:""}),0,"locale"],[wi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[fr,0,"segments"],[fr,0,"focusedPart"],[hr(["value","locale"]),2,"syncSegmentsFromValue"],[hr("label"),2,"syncGroupLabel"],[be({selector:'[data-ref="root"]',type:"focusin"}),2,"onGroupFocusIn"],[be({selector:"[data-date-segment]",type:"focusin"}),2,"onSegmentFocusIn"],[be({selector:"[data-date-segment]",type:"focusout"}),2,"onSegmentFocusOut"],[be({selector:"[data-date-segment]",type:"keydown"}),2,"onSegmentKeyDown"],[be({selector:"[data-date-segment]",type:"beforeinput"}),2,"onSegmentBeforeInput"],[be({selector:"[data-date-segment]",type:"pointerdown"}),2,"onSegmentPointerDown"]],0,void 0,pr))}value=(Hn(this),qn(this));min=(Kn(this),Nn(this));max=(Xn(this),Jn(this));readOnly=(Zn(this),Qn(this));label=(er(this),tr(this));locale=(nr(this),rr(this));changeEvent=(ir(this),ar(this));segments=(or(this),sr(this,[]));focusedPart=(lr(this),ur(this,null));uid=(cr(this),De("rui-date-input"));buffer="";useTextboxRole=Si();pendingFocus=null;get resolvedLocale(){return Re(this.locale)}get isoValue(){return this.value??""}syncSegmentsFromValue(){this.segments=Ee(de(this.isoValue),this.resolvedLocale),this.buffer=""}get displaySegments(){return this.segments.length>0?this.segments:Ee(de(this.isoValue),this.resolvedLocale)}constructor(){super(),Di(this,()=>this.syncSegmentsFromValue())}getSegmentElement(e){return this.querySelector(`[data-date-segment][data-type="${e}"]`)}setFocusedPart(e,n="leave"){let r=this.focusedPart;e===r&&n==="leave"||(this.buffer="",(r!=null||n==="blur")&&this.commit(n),this.focusedPart=e)}focusPart(e){this.setFocusedPart(e),this.pendingFocus=e}updated(e){super.updated(e),this.pendingFocus=null;let n=this.focusedPart;if(!n||!(e.has("focusedPart")||e.has("segments"))||!this.matches(":focus-within"))return;let r=this.getSegmentElement(n);r&&(document.activeElement!==r&&r.focus(),document.activeElement===r&&window.getSelection()?.collapse(r,0))}commit(e){if(e==="edit"&&this.buffer)return;let n=Ue(this.segments,{min:this.min,max:this.max});switch(n.kind){case"partial-year":e!=="edit"&&this.syncSegmentsFromValue();return;case"incomplete":e==="blur"&&this.syncSegmentsFromValue();return;case"out-of-range":this.syncSegmentsFromValue();return;case"empty":this.publish("");return;case"date":this.publish(n.iso)}}publish(e){if(e===this.isoValue){this.syncSegmentsFromValue();return}this.value=e,this.changeEvent.emit({value:e})}partFromTarget(e){if(!(e instanceof HTMLElement))return null;let r=e.closest("[data-date-segment]")?.getAttribute("data-type");return r==="month"||r==="day"||r==="year"?r:null}handleDigit(e,n){this.setFocusedPart(e);let r=Ze(this.segments,e,n,this.buffer);if(this.segments=r.segments,this.buffer=r.enteredKeys,r.focusNext){this.focusPart(ve(this.segments,e,1));return}this.commit("edit")}handleBackspace(e){this.setFocusedPart(e);let n=et(this.segments,e);if(n.kind==="focus-previous"){this.focusPart(ve(this.segments,e,-1));return}this.segments=n.segments,this.buffer=n.enteredKeys,this.commit("edit")}handleIncrement(e,n){this.setFocusedPart(e),this.buffer="",this.segments=Je(this.segments,e,n),this.commit("edit")}onConnected(){this.syncSegmentsFromValue(),this.syncGroupLabel()}formValue(){return this.name?this.isoValue:null}formState(){return this.value}restoreFormState(e){this.value=typeof e=="string"?e:"",this.syncSegmentsFromValue()}formResetCallback(){super.formResetCallback(),this.dispatchEvent(new Event("rui-form-reset",{bubbles:!0}))}syncGroupLabel(){let e=this.querySelector('[data-ref="root"]');if(!e)return;e.id||(e.id=`${this.uid}-group`);let n=this.label||this.getAttribute("aria-label")||"";n?e.setAttribute("aria-label",n):e.removeAttribute("aria-label")}onGroupFocusIn(e){this.partFromTarget(e.target)||this.focusPart(Qe(this.segments))}onSegmentFocusIn(e){let n=this.partFromTarget(e.target);n&&(this.pendingFocus&&this.pendingFocus!==n||this.setFocusedPart(n))}onSegmentFocusOut(){queueMicrotask(()=>{this.matches(":focus-within")||this.setFocusedPart(null,"blur")})}onSegmentKeyDown(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly)){if(e.key==="ArrowLeft"){e.preventDefault(),this.focusPart(ve(this.segments,n,-1));return}if(e.key==="ArrowRight"){e.preventDefault(),this.focusPart(ve(this.segments,n,1));return}if(e.key==="ArrowUp"){e.preventDefault(),this.handleIncrement(n,1);return}if(e.key==="ArrowDown"){e.preventDefault(),this.handleIncrement(n,-1);return}(e.key==="Backspace"||e.key==="Delete")&&(e.preventDefault(),e.stopPropagation(),this.handleBackspace(n))}}onSegmentBeforeInput(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly))switch(e.preventDefault(),e.inputType){case"deleteContentBackward":case"deleteContentForward":this.handleBackspace(n);break;default:e.data!=null&&this.handleDigit(n,e.data);break}}onSegmentPointerDown(e){e.stopPropagation()}renderSegment(e,n){if(!e.editable)return ke("span",{class:"rui-date-input__literal","data-type":"literal","aria-hidden":"true",children:e.value},`literal-${n}`);let r=e.type,i=this.focusedPart===r,a=zn(e,{disabled:this.effectiveDisabled,locale:this.resolvedLocale,readOnly:this.readOnly,segments:this.displaySegments,useTextboxRole:this.useTextboxRole});return ke("span",{class:a.className,"data-date-segment":!0,"data-type":r,"data-placeholder":e.isPlaceholder?"true":void 0,"data-focused":i?"true":void 0,role:a.ariaRole,"aria-label":a.ariaLabel,"aria-valuemin":a.ariaValuemin,"aria-valuemax":a.ariaValuemax,"aria-valuenow":a.ariaValuenow,"aria-valuetext":a.ariaValuetext,"aria-readonly":a.ariaReadonly,"data-rui-focus-managed":a.dataRuiFocusManaged,contenteditable:a.contenteditable,suppresscontenteditablewarning:a.suppresscontenteditablewarning,spellcheck:"false",inputmode:a.inputmode,tabindex:a.tabindex,children:we(e)},r)}render(){return ke("div",{class:"rui-date-input","data-ref":"root",role:"group",children:ke("div",{class:"rui-date-input__segments",children:this.displaySegments.map((e,n)=>this.renderSegment(e,n))})})}static{Un()}};import{jsx as Mi}from"@ecopages/jsx/jsx-runtime";function rt({children:t,...e}){return Mi("rui-date-input",{"data-rui-control":!0,"data-rui-control-type":"date","data-rui-aria-target":'[data-ref="root"]',...e,children:t})}function vr({children:t,class:e,...n}){return B("div",{...n,class:q("rui-date-field",e),children:B("div",{class:"rui-date-field__group","data-ref":"control",children:t})})}function br({class:t,...e}){return B(rt,{...e,"data-date-field-input":!0,class:q("rui-date-field__input",t)})}function xr({children:t,class:e,aria:n,...r}){return B("button",{...r,aria:Ut(n,"Open calendar"),type:"button","data-ref":"trigger","data-date-field-trigger":!0,class:q("rui-control-toggle",e),"aria-haspopup":"dialog",children:t??B(Ce,{})})}function _r({children:t,class:e,...n}){return B("div",{...n,"data-ref":"popover","data-date-field-popover":!0,class:q("rui-date-field__popover rui-popover rui-floating",e),hidden:!0,role:"dialog",children:t})}function wr(t){return B(nt,{...t,"data-date-field-calendar":!0})}function Ri(t){let{children:e,value:n,min:r,max:i,disabled:a,readOnly:s,label:o,name:f,locale:y}=t;return B("rui-date-field",{"data-rui-aria-target":'[data-date-field-input] [data-ref="root"]',...t,children:e??yr(Ii,{children:[yr(vr,{children:[B(br,{value:n,min:r,max:i,disabled:a,readOnly:s,label:o,name:f,locale:y}),B(xr,{})]}),B(_r,{children:B(wr,{})})]})})}export{Ri as RuiDateField,wr as RuiDateFieldCalendar,vr as RuiDateFieldControl,Ht as RuiDateFieldElement,br as RuiDateFieldInput,_r as RuiDateFieldPopover,xr as RuiDateFieldToggle};
1
+ import{RadiantElement as Gt,bindTo as se,customElement as Wr,event as zr,onEvent as le,onUpdated as Wt,prop as U,query as Hr,state as Ur}from"@ecopages/radiant";function Sr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(`(max-width: ${639}px)`).matches}function it(t){return t<=1||!Sr()?t:1}function at(t){if(typeof window>"u"||typeof window.matchMedia!="function")return null;let e=window.matchMedia(`(max-width: ${639}px)`);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}var Mr=/^[A-Za-z][A-Za-z0-9_-]*$/;function ot(t){return Mr.test(t)}function Ir(t){let e=t.trim();if(ot(e))return e;let n=`rui-${e}`;return e&&ot(n)?n:"rui"}function De(t){let e=typeof crypto.randomUUID=="function"?crypto.randomUUID().replace(/-/g,""):Array.from(crypto.getRandomValues(new Uint8Array(16)),n=>n.toString(16).padStart(2,"0")).join("");return`${Ir(t)}-${e}`}var Rr={top:"bottom",bottom:"top",left:"right",right:"left"},Fr=8,Le=new WeakMap;function Pr(t){Le.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",Le.delete(t))}function Er(t){let e=t.indexOf("-");if(e===-1)return{side:t,align:"center"};let n=t.slice(0,e),r=t.slice(e+1);return{side:n,align:r==="start"||r==="end"?r:"center"}}function ut(t){return t==="top"||t==="bottom"?"y":"x"}function st(t,e,n,r,i){let{width:a,height:s}=e,o=0,f=0;switch(n){case"top":f=t.top-s-i;break;case"bottom":f=t.bottom+i;break;case"left":o=t.left-a-i;break;case"right":o=t.right+i;break}return ut(n)==="y"?r==="start"?o=t.left:r==="end"?o=t.right-a:o=t.left+(t.width-a)/2:r==="start"?f=t.top:r==="end"?f=t.bottom-s:f=t.top+(t.height-s)/2,{x:o,y:f}}function Ar(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?Math.max(0,i-t.y):n==="bottom"?Math.max(0,t.y+e.height-(s-i)):n==="left"?Math.max(0,i-t.x):Math.max(0,t.x+e.width-(a-i))}function lt(t,e,n,r){let{padding:i,width:a,height:s}=r;return n==="top"?t.top-i-e.height:n==="bottom"?s-i-e.height-t.bottom:n==="left"?t.left-i-e.width:a-i-e.width-t.right}function Tr(t,e){return e==="center"?t:`${t}-${e}`}function kr(t,e,n,r){let{padding:i,width:a,height:s}=r;if(ut(n)==="y"){let f=Math.max(i,a-i-e.width);return{x:Math.min(Math.max(t.x,i),f),y:Math.max(i,t.y)}}let o=Math.max(i,s-i-e.height);return{x:Math.max(i,t.x),y:Math.min(Math.max(t.y,i),o)}}function Lr(t,e,n,r,i={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:Fr}){let{side:a,align:s}=Er(n),o=st(t,e,a,s,r),f=Ar(o,e,a,i),y=a,x=o;if(f>0){let R=Rr[a],M=st(t,e,R,s,r),O=lt(t,e,a,i);lt(t,e,R,i)>O&&(y=R,x=M)}return{coords:kr(x,e,y,i),placement:Tr(y,s)}}function Cr(t,e,n,r,i={}){let a=i.matchAnchorWidth===!0,s=t.offsetWidth,o=a?{width:s,height:e.offsetHeight}:{width:e.offsetWidth,height:e.offsetHeight};a?(e.style.width=`${s}px`,e.style.minWidth=`${s}px`,e.style.maxWidth=`${s}px`,e.style.boxSizing="border-box",Le.set(e,!0)):Pr(e);let{coords:f,placement:y}=Lr(t.getBoundingClientRect(),o,n,r);return Object.assign(e.style,{position:"fixed",left:`${f.x}px`,top:`${f.y}px`,right:"auto",bottom:"auto",visibility:"visible"}),e.setAttribute("data-placement",y),y}function ct({anchor:t,floating:e,getPlacement:n,gap:r,matchAnchorWidth:i}){let a=()=>{e.hidden||Cr(t,e,n(),r,{matchAnchorWidth:i})};a(),window.addEventListener("resize",a),window.addEventListener("scroll",a,!0);let s=new ResizeObserver(a);return s.observe(t),s.observe(e),()=>{window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0),s.disconnect()}}function dt(t,e=document.body){let n=t.parentNode;if(!n)return{unmount:()=>{}};let r=document.createComment("rui-portal");return n.insertBefore(r,t),e.appendChild(t),{unmount:()=>{let i=r.parentNode;i&&(i.insertBefore(t,r),r.remove())}}}function ht(t,e,n){return n?!!(t?.contains(n)||e?.contains(n)):!1}function ft(t,e,n){return n instanceof Node?!ht(t,e,n):!0}var Se=class{config;cleanupFloating=null;portalHandle=null;floatingElement=null;constructor(e){this.config=e}updateConfig(e){this.config={...this.config,...e}}sync(){let e=this.resolveFloating();if(!e)return;if(!this.config.getOpen()){this.teardown(),e.toggleAttribute("hidden",!0);return}let r=this.config.getAnchor();if(!r)return;e.toggleAttribute("hidden",!1),this.config.portal!==!1?this.portalHandle||(this.portalHandle=dt(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=ct({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return ht(this.config.getAnchor(),this.resolveFloating(),e)}getFloatingElement(){return this.resolveFloating()}teardown(){this.teardownFloating(),this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null)}destroy(){this.teardown(),this.floatingElement=null}resolveFloating(){let e=this.config.getFloating();return e&&(this.floatingElement=e),e??this.floatingElement}teardownFloating(){this.cleanupFloating?.(),this.cleanupFloating=null}};var Me=class{config;popoverController=null;suppressPopoverDismiss=!1;constructor(e){this.config=e}destroy(){this.popoverController?.destroy(),this.popoverController=null}suppressDismiss(){this.suppressPopoverDismiss=!0}syncPopover(){let e=this.config.getFloating();if(!e)return;e.hidden=!this.config.getOpen();let n=this.ensureController();n.updateConfig({getOpen:()=>this.config.getOpen()}),n.sync()}focusCalendarDay(){Vr(this.config.getCalendar(),this.config.getFocusIso())}handleFocusOut(e,n){let r=e.relatedTarget;queueMicrotask(()=>{if(this.suppressPopoverDismiss){this.suppressPopoverDismiss=!1;return}if(!this.config.getOpen())return;let i=this.config.getFloating();if(!i)return;let a=r instanceof Node?r:document.activeElement;ft(this.config.getHost(),i,a)&&n()})}ensureController(){return this.popoverController||(this.popoverController=new Se({getAnchor:this.config.getAnchor,getFloating:this.config.getFloating,getOpen:this.config.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}};function Vr(t,e){requestAnimationFrame(()=>{if(!t)return;((e?t.querySelector(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`):null)??t.querySelector('[data-calendar-day][tabindex="0"]:not(:disabled), [data-calendar-day]:not(:disabled)'))?.focus()})}function Or(t){let e=t.previousElementSibling;return e?.tagName.toLowerCase()==="label"?e:t.parentElement?.querySelector("[data-rui-field-label]")??null}function jr(t,e,n){t.id||(t.id=n.labelId),t.htmlFor||(t.htmlFor=n.controlId),e.setAttribute("aria-labelledby",t.id),e.removeAttribute("aria-label")}function pt(t,e,n){if(!e||e.hasAttribute("data-rui-field-managed"))return;let r=Or(t);if(r){jr(r,e,n);return}if(n.label){e.setAttribute("aria-label",n.label),e.removeAttribute("aria-labelledby");return}e.removeAttribute("aria-label"),e.removeAttribute("aria-labelledby")}var mt,gt,yt,vt,bt,xt,_t,wt,Dt,St,Mt,It,Rt,Ft,Pt,Et,At,Tt,kt,Lt,Ct,Vt,Ot,jt,Yt,Bt;function Yr(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:$t(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||$t(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:Br(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return Gr(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function Br(t){var e=$r(t,"string");return typeof e=="symbol"?e:e+""}function $r(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $t(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function Gr(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var Ht,zt=class extends Gt{static{({e:[yt,vt,bt,xt,_t,wt,Dt,St,Mt,It,Rt,Ft,Pt,Et,At,Tt,kt,Lt,Ct,Vt,Ot,jt,Yt,Bt,mt],c:[Ht,gt]}=Yr(this,[Wr("rui-date-field")],[[[U({type:String,reflect:!0,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"value"},{selector:"[data-date-field-calendar]",attr:"value"}])],0,"value"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"min"},{selector:"[data-date-field-calendar]",attr:"min"}])],0,"min"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"max"},{selector:"[data-date-field-calendar]",attr:"max"}])],0,"max"],[[U({type:Boolean,reflect:!0,defaultValue:!1}),se([{selector:"[data-date-field-input]",bool:"disabled"},{selector:"[data-date-field-calendar]",bool:"disabled"}])],0,"disabled"],[[U({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),se({selector:"[data-date-field-input]",bool:"read-only"})],0,"readOnly"],[U({type:String,defaultValue:""}),0,"label"],[[U({type:String,defaultValue:""}),se({selector:"[data-date-field-input]",attr:"name"})],0,"name"],[[U({type:String,defaultValue:""}),se([{selector:"[data-date-field-input]",attr:"locale"},{selector:"[data-date-field-calendar]",attr:"locale"}])],0,"locale"],[U({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[zr({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[[Ur,se({selector:"[data-date-field-trigger]",attr:"aria-expanded"})],0,"open"],[Hr({ref:"popover"}),0,"popoverTarget"],[Wt(["value","min","max","label","disabled","readOnly","locale","visibleMonths"]),2,"onPropsUpdated"],[Wt(["open"]),2,"onOpenUpdated"],[le({selector:"[data-date-field-input]",type:"rui-change"}),2,"onDateInputChange"],[le({selector:"[data-date-field-input]",type:"rui-form-reset"}),2,"onDateInputReset"],[le({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-popover]",type:"focusout"}),2,"onRootFocusOut"],[le({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[le({ref:"trigger",type:"click"}),2,"onTriggerClick"],[le({selector:"[data-date-field-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[le({selector:"[data-date-field-calendar]",type:"rui-change"}),2,"onCalendarChange"],[le({selector:"[data-date-field-input], [data-date-field-trigger], [data-date-field-calendar]",type:"keydown"}),2,"onRootKeydown"]],0,void 0,Gt))}value=(mt(this),yt(this));min=(vt(this),bt(this));max=(xt(this),_t(this));disabled=(wt(this),Dt(this));readOnly=(St(this),Mt(this));label=(It(this),Rt(this));name=(Ft(this),Pt(this));locale=(Et(this),At(this));visibleMonths=(Tt(this),kt(this));changeEvent=(Lt(this),Ct(this));open=(Vt(this),Ot(this,!1));uid=(jt(this),De("rui-date-field"));calendarPopover=new Me({getHost:()=>this,getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getCalendar:()=>this.getCalendar(),getFocusIso:()=>this.isoValue||void 0});disposeMobileLayoutListener=null;popoverTarget=Yt(this);onMediaChange=(Bt(this),()=>{this.syncCalendar(),this.open&&this.calendarPopover.syncPopover()});get isoValue(){return this.value??""}get inputId(){return`${this.uid}-input`}getDateInput(){return this.querySelector("[data-date-field-input]")}getToggle(){return this.querySelector("[data-date-field-trigger]")}getCalendar(){return this.querySelector("[data-date-field-calendar]")}syncLabel(){let e=this.getDateInput();pt(this,e,{controlId:this.inputId,label:this.label,labelId:`${this.uid}-label`})}syncInput(){let e=this.getDateInput();e?.id||e?.setAttribute("id",this.inputId)}syncToggle(){let e=this.getToggle();e&&(e.disabled=this.disabled||this.readOnly)}commitValue(e){e!==this.isoValue&&(this.value=e,this.changeEvent.emit({value:e}))}syncCalendar(){let e=this.getCalendar();e&&(e.setAttribute("selection-mode","single"),e.setAttribute("visible-months",String(it(this.visibleMonths))))}initialize(){this.syncLabel(),this.syncInput(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}setOpen(e){this.open=e,queueMicrotask(()=>{this.calendarPopover.syncPopover(),e&&this.calendarPopover.focusCalendarDay()})}onConnected(){this.disposeMobileLayoutListener=at(this.onMediaChange),this.initialize()}disconnectedCallback(){this.disposeMobileLayoutListener?.(),this.disposeMobileLayoutListener=null,this.calendarPopover.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.syncLabel(),this.syncInput(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.calendarPopover.syncPopover()}onDateInputChange(e){let n=e.target;if(!(n instanceof HTMLElement)||!n.matches("[data-date-field-input]"))return;let r=e.detail;this.commitValue(r?.value??"")}onDateInputReset(){let e=this.getDateInput(),n=e&&Reflect.get(e,"value");this.value=typeof n=="string"?n:""}onRootFocusOut(e){this.calendarPopover.handleFocusOut(e,()=>this.setOpen(!1))}onTriggerPointerDown(){this.calendarPopover.suppressDismiss()}onTriggerClick(){this.disabled||this.readOnly||this.setOpen(!this.open)}onPopoverMouseDown(e){e.preventDefault()}onCalendarChange(e){let n=e.target;if(!(n instanceof HTMLElement)||!n.matches("[data-date-field-calendar]"))return;let r=e.detail;r?.value&&(this.commitValue(r.value),this.setOpen(!1))}onRootKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),this.setOpen(!1))}static{gt()}};import{Fragment as Ii,jsx as B,jsxs as yr}from"@ecopages/jsx/jsx-runtime";function Ut(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function q(...t){return t.filter(Boolean).join(" ")}import{jsx as Ie,jsxs as qr}from"@ecopages/jsx/jsx-runtime";function Ce({class:t,size:e="sm",...n}){return qr("svg",{...n,class:q("rui-icon",e==="md"&&"rui-icon--md",t),viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round","aria-hidden":"true",children:[Ie("path",{d:"M8 2v4"}),Ie("path",{d:"M16 2v4"}),Ie("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Ie("path",{d:"M3 10h18"})]})}import{jsx as Y,jsxs as tt}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as $n,customElement as hi,event as fi,onEvent as pe,onUpdated as pi,prop as ue,registerSsrPreparationCallback as mi,state as ce}from"@ecopages/radiant";function Re(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}function de(t){if(t==null)return null;let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t.trim());if(!e)return null;let n=Number(e[1]),r=Number(e[2])-1,i=Number(e[3]),a=new Date(n,r,i);return a.getFullYear()!==n||a.getMonth()!==r||a.getDate()!==i?null:a}function K(t){let e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${e}-${n}-${r}`}function _e(t,e,n){return!(e&&t<e||n&&t>n)}function he(t,e){return t.localeCompare(e)}function me(t,e){return he(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function ge(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:me(e,n)}function Ve(t){if(!t)return"";let e=me(t.start,t.end);return`${e.start}/${e.end}`}function ye(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(he):[]}function Oe(t){return[...new Set(t)].sort(he).join(",")}function je(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(he)}function qt(t,e){let n=me(e.start,e.end);return he(t,n.start)>=0&&he(t,n.end)<=0}function Ye(t,e,n){if(e==="single"){let y=n.singleIso===t;return{isSelected:y,isRangeStart:y,isRangeEnd:y,isRangeMiddle:!1}}if(e==="multiple"){let y=n.multipleIsos?.includes(t)??!1;return{isSelected:y,isRangeStart:y,isRangeEnd:y,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let i=me(r.start,r.end),a=qt(t,i),s=t===i.start,o=t===i.end;return{isSelected:a,isRangeStart:s,isRangeEnd:o,isRangeMiddle:a&&!s&&!o}}function Be(t,e,n){return e.anchor?{committed:me(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function Fe(t){let e=Kr(t);try{let r=new Intl.Locale(e).weekInfo;if(r?.firstDay!=null)return r.firstDay===7?0:r.firstDay}catch{}return e.startsWith("en-US")?0:1}function Kr(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function Nr(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function Xr(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Jr(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:ye(n)};if(e==="range"){let r=ge(n);if(t.rangeDraft?.anchor){let i=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:Zr(t.rangeDraft.anchor,i)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function Zr(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function $e(t,e,n){let r=Fe(n.locale),i=Nr(n.today??new Date),a=Jr(n),o=(new Date(t,e,1).getDay()-r+7)%7,f=new Date(t,e,1-o),y=[],x=new Date(f);for(let R=0;R<6;R+=1){let M=[];for(let O=0;O<7;O+=1){let j=K(x),A=Ye(j,a.mode,{singleIso:a.singleIso,multipleIsos:a.multipleIsos,range:a.range});M.push({date:new Date(x),iso:j,inMonth:x.getMonth()===e,isToday:Xr(x,i),isSelected:A.isSelected,isDisabled:!_e(j,n.min,n.max),isRangeStart:A.isRangeStart,isRangeEnd:A.isRangeEnd,isRangeMiddle:A.isRangeMiddle}),x.setDate(x.getDate()+1)}if(y.push(M),R>=4&&x.getMonth()!==e&&x.getDate()>7)break}return y}function Pe(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function Ge(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(i,a)=>{let s=Pe(t,e,a);return{year:s.year,month:s.month,offset:a}})}var Kt=new Map;function Qr(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function fe(t,e){let n=Qr(t,e),r=Kt.get(n);if(r)return r;let i=new Intl.DateTimeFormat(t,e);return Kt.set(n,i),i}function We(t,e){return fe(e,{month:"long",year:"numeric"}).format(t)}function ze(t,e){let n=fe(t,{weekday:"narrow"}),r=[];for(let i=0;i<7;i+=1){let a=(e+i)%7,s=new Date(2024,0,a===0?7:a);r.push(n.format(s))}return r}function He(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var ei=new Date(2e3,0,1);function ti(t,e){return t==="year"?e==="year":t==="month"?e==="year"||e==="month":!0}function ni(t,e){let r=fe(e,{[t]:t==="year"?"numeric":"2-digit"}).formatToParts(ei).find(i=>i.type===t);return r?r.value.replace(/\d/g,t==="year"?"y":t==="month"?"m":"d"):t==="year"?"yyyy":"mm"}function ri(t,e,n){let r=t==="year"?{year:"numeric"}:{[t]:"2-digit"};return fe(n,r).formatToParts(e).find(i=>i.type===t)?.value??""}function Ee(t,e,n={}){let r=n.granularity??"day",i=t??n.placeholderDate??new Date;return fe(e,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i).filter(s=>s.type!=="era").map(s=>{if(s.type==="literal")return{type:"literal",value:s.value,placeholder:s.value,isPlaceholder:!1,editable:!1};let o=s.type;if(!ti(r,o))return null;let f=t!=null;return{type:o,value:f?ri(o,t,e):"",placeholder:ni(o,e),isPlaceholder:!f,editable:!0}}).filter(s=>s!=null)}function ii(t){if(t.isPlaceholder||t.value==="")return null;let e=Number(t.value);return Number.isFinite(e)?e:null}function ai(t){return t>=100?t:t>=69?1900+t:2e3+t}function Nt(t){let e={};for(let r of t){if(!r.editable)continue;let i=ii(r);if(i==null)return null;e[r.type]=r.type==="year"?ai(i):i}if(e.year==null||e.month==null||e.day==null)return null;let n=new Date(e.year,e.month-1,e.day);return n.getFullYear()!==e.year||n.getMonth()!==e.month-1||n.getDate()!==e.day?null:n}function Xt(t){return t.every(e=>!e.editable||e.isPlaceholder||e.value==="")}function Ue(t,e={}){let n=t.find(a=>a.editable&&a.type==="year");if(n&&!n.isPlaceholder&&n.value!==""&&n.value.replace(/\D/g,"").length<4)return{kind:"partial-year"};if(Xt(t))return{kind:"empty"};let r=Nt(t);if(!r)return{kind:"incomplete"};let i=K(r);return _e(i,e.min,e.max)?{kind:"date",iso:i}:{kind:"out-of-range"}}function qe(t){return t==="year"?4:2}function oi(t,e){return t.findIndex(n=>n.editable&&n.type===e)}function si(t){return t.map(e=>({...e}))}function Ne(t,e,n){let r=si(t),i=oi(r,e);return i<0||(r[i]={...r[i],...n}),r}function Ke(t){if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Ae(t,e){return{min:1,max:Zt(t,e)}}function Zt(t,e){if(t==="month")return 12;if(t==="day"){let n=Jt(e,"year"),r=Jt(e,"month");return n!=null&&r!=null?new Date(n,r,0).getDate():31}return 9999}function Jt(t,e){let n=t.find(r=>r.editable&&r.type===e);return!n||n.isPlaceholder||n.value===""?null:Number(n.value)}function Qt(t,e){return t==="year"?String(e).padStart(4,"0"):String(e).padStart(2,"0")}function Xe(t,e){try{let r=new Intl.DisplayNames(e,{type:"dateTimeField"}).of(t);if(r)return r}catch{}return t==="month"?"Month":t==="day"?"Day":"Year"}function we(t){return t.isPlaceholder||t.value===""?t.placeholder:t.value}function Te(t){return t.isPlaceholder||t.value===""?null:Ke(t.value.replace(/\D/g,""))}function en(t,e){return Ne(t,e,{value:"",isPlaceholder:!0})}function tn(t,e,n){return Ne(t,e,{value:Qt(e,n),isPlaceholder:!1})}function Je(t,e,n){let r=t.find(f=>f.editable&&f.type===e);if(!r)return t;let{min:i,max:a}=Ae(e,t),o=(Te(r)??(n>0?i-1:a+1))+n;return e==="month"||e==="day"?o<i?o=a:o>a&&(o=i):o=Math.max(i,o),tn(t,e,o)}function Ze(t,e,n,r){let i=n.replace(/\D/g,"");if(!i)return{segments:t,enteredKeys:r,focusNext:!1};let a=r+i,s=Ke(a);if(s==null)return{segments:t,enteredKeys:r,focusNext:!1};let o=Zt(e,t),f=s;f>o&&(f=Ke(i)??f);let y=qe(e),x=+`${f}0`>o||a.length>=y||String(f).length>=y,R=x?Qt(e,f):String(f);return{segments:Ne(t,e,{value:R,isPlaceholder:!1}),enteredKeys:x?"":a,focusNext:x}}function nn(t){return t.filter(e=>e.editable).map(e=>e.type)}function ve(t,e,n){let r=nn(t),i=r.indexOf(e);if(i<0)return r[0]??null;let a=i+n;return a<0||a>=r.length?null:r[a]??null}function Qe(t){let e=null;for(let n of t){if(!n.editable)continue;let r=n.type;if(e||(e=r),n.isPlaceholder||n.value==="")return r}return e}function et(t,e){let n=t.find(a=>a.editable&&a.type===e);if(!n)return{kind:"focus-previous"};if(n.isPlaceholder||n.value==="")return{kind:"focus-previous"};let r=n.value.replace(/\D/g,"");if(r.length<=1)return{kind:"updated",segments:en(t,e),enteredKeys:""};let i=r.slice(0,-1);return{kind:"updated",segments:t.map(a=>a.editable&&a.type===e?{...a,value:i,isPlaceholder:!1}:a),enteredKeys:i}}var rn,an,on,sn,ln,un,cn,dn,hn,fn,pn,mn,gn,yn,vn,bn,xn,_n,wn,Dn,Sn,Mn,In,Rn,Fn,Pn,En,An,Tn,kn,Ln,Cn,Vn,On,jn,Yn;function li(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:Bn(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||Bn(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:ui(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return di(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function ui(t){var e=ci(t,"string");return typeof e=="symbol"?e:e+""}function ci(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Bn(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function di(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}var Wn,Gn=class extends $n{static{({e:[on,sn,ln,un,cn,dn,hn,fn,pn,mn,gn,yn,vn,bn,xn,_n,wn,Dn,Sn,Mn,In,Rn,Fn,Pn,En,An,Tn,kn,Ln,Cn,Vn,On,jn,Yn,rn],c:[Wn,an]}=li(this,[hi("rui-calendar")],[[ue({type:String,reflect:!0,defaultValue:""}),0,"value"],[ue({type:String,defaultValue:""}),0,"min"],[ue({type:String,defaultValue:""}),0,"max"],[ue({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[ue({type:String,defaultValue:""}),0,"locale"],[ue({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[ue({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[ue({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[fi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[ce,0,"viewYear"],[ce,0,"viewMonth"],[ce,0,"focusedIso"],[ce,0,"weekdayLabels"],[ce,0,"monthPanels"],[ce,0,"todayLabel"],[ce,0,"rangeAnchor"],[ce,0,"rangeHover"],[pi(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[pe({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[pe({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[pe({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[pe({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[pe({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[pe({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[pe({selector:"[data-calendar-day]",type:"keydown"}),2,"onDayKeydown"]],0,void 0,$n))}value=(rn(this),on(this));min=(sn(this),ln(this));max=(un(this),cn(this));disabled=(dn(this),hn(this));locale=(fn(this),pn(this));selectionMode=(mn(this),gn(this));visibleMonths=(yn(this),vn(this));pageBehavior=(bn(this),xn(this));changeEvent=(_n(this),wn(this));viewYear=(Dn(this),Sn(this,new Date().getFullYear()));viewMonth=(Mn(this),In(this,new Date().getMonth()));focusedIso=(Rn(this),Fn(this,""));weekdayLabels=(Pn(this),En(this,[]));monthPanels=(An(this),Tn(this,[]));todayLabel=(kn(this),Ln(this,""));rangeAnchor=(Cn(this),Vn(this,null));rangeHover=(On(this),jn(this,null));get resolvedLocale(){return Re(this.locale)}get pageDelta(){return this.pageBehavior==="single"?1:Math.max(1,Math.min(this.visibleMonths,12))}get monthOptions(){return{locale:this.resolvedLocale,selectionMode:this.selectionMode,value:this.value??"",rangeDraft:{anchor:this.rangeAnchor,hover:this.rangeHover},min:this.min||void 0,max:this.max||void 0}}syncViewFromValue(){let e=this.selectionMode==="range"?ge(this.value)?.start??"":this.selectionMode==="multiple"?ye(this.value)[0]??"":this.value,n=de(e);if(n){this.viewYear=n.getFullYear(),this.viewMonth=n.getMonth(),this.focusedIso=e;return}let r=new Date;this.viewYear=r.getFullYear(),this.viewMonth=r.getMonth(),this.focusedIso=K(r)}refreshGrid(){this.weekdayLabels=ze(this.resolvedLocale,Fe(this.resolvedLocale)),this.monthPanels=Ge(this.viewYear,this.viewMonth,this.visibleMonths).map(e=>{let n=new Date(e.year,e.month,1);return{year:e.year,month:e.month,label:We(n,this.resolvedLocale),weeks:$e(e.year,e.month,this.monthOptions)}}),this.todayLabel=He(this.resolvedLocale)}moveMonth(e){let n=Pe(this.viewYear,this.viewMonth,e);this.viewYear=n.year,this.viewMonth=n.month,this.refreshGrid()}getFlatDays(){return this.monthPanels.flatMap(e=>e.weeks.flat())}moveFocusedDay(e){let n=this.getFlatDays().filter(s=>!s.isDisabled);if(!n.length)return;let r=n.findIndex(s=>s.iso===this.focusedIso),i=r<0?Math.max(0,n.findIndex(s=>s.inMonth)):(r+e+n.length)%n.length,a=n[i];if(a){if(!this.isMonthVisible(a.date)){this.viewYear=a.date.getFullYear(),this.viewMonth=a.date.getMonth(),this.focusedIso=a.iso,this.refreshGrid(),this.focusFocusedDay();return}this.focusedIso=a.iso,this.focusDayInCurrentGrid(a.iso)}}isMonthVisible(e){let n=this.viewYear*12+this.viewMonth,r=n+this.visibleMonths-1,i=e.getFullYear()*12+e.getMonth();return i>=n&&i<=r}focusDayInCurrentGrid(e){let n=this.querySelector('[data-calendar-day][tabindex="0"]'),r=Array.from(this.querySelectorAll(`[data-calendar-day][data-iso="${e}"]:not(:disabled)`)),i=r.find(a=>!a.hasAttribute("data-outside"))??r[0];i&&(n&&n!==i&&(n.tabIndex=-1),i.tabIndex=0,i.focus())}focusFocusedDay(){requestAnimationFrame(()=>{this.focusDayInCurrentGrid(this.focusedIso)})}moveFocusedMonth(e){let n=de(this.focusedIso)??new Date(this.viewYear,this.viewMonth,1),r=new Date(n.getFullYear(),n.getMonth()+e,1),i=new Date(r.getFullYear(),r.getMonth()+1,0).getDate(),a=new Date(r.getFullYear(),r.getMonth(),Math.min(n.getDate(),i));this.viewYear=a.getFullYear(),this.viewMonth=a.getMonth(),this.focusedIso=K(a),this.refreshGrid(),this.focusFocusedDay()}isIsoAllowed(e){return!(this.min&&e<this.min||this.max&&e>this.max)}emitChange(e,n={}){this.changeEvent.emit({value:e,...n})}selectSingle(e){!this.isIsoAllowed(e)||e===this.value||(this.value=e,this.emitChange(e),this.refreshGrid())}selectMultiple(e){if(!this.isIsoAllowed(e))return;let n=Oe(je(ye(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=Be(ge(this.value),{anchor:this.rangeAnchor,hover:this.rangeHover},e);if(this.rangeAnchor=n.draft.anchor,this.rangeHover=n.draft.hover,n.committed){let r=Ve(n.committed);r!==this.value&&(this.value=r,this.emitChange(r,{start:n.committed.start,end:n.committed.end}))}this.refreshGrid()}selectIso(e){if(this.selectionMode==="multiple"){this.selectMultiple(e);return}if(this.selectionMode==="range"){this.selectRange(e);return}this.selectSingle(e)}previewRange(e){this.selectionMode!=="range"||!this.rangeAnchor||this.disabled||this.rangeHover!==e&&(this.rangeHover=e,this.refreshGrid())}clearRangePreview(){this.rangeHover&&(this.rangeHover=this.rangeAnchor,this.refreshGrid())}initialize(){this.syncViewFromValue(),this.refreshGrid()}constructor(){super(),Yn(this),mi(this,()=>this.initialize())}onConnected(){this.initialize()}onPropsUpdated(){this.selectionMode!=="range"&&(this.rangeAnchor=null,this.rangeHover=null),this.syncViewFromValue(),this.refreshGrid()}onPrevMonth(e){e.preventDefault(),this.moveMonth(-this.pageDelta)}onNextMonth(e){e.preventDefault(),this.moveMonth(this.pageDelta)}onTodayClick(e){e.preventDefault(),this.selectIso(K(new Date))}onDayClick(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.disabled||this.selectIso(r)}onDayPointerEnter(e){let n=e.target.closest("[data-calendar-day]"),r=n?.getAttribute("data-iso");!r||n?.disabled||this.previewRange(r)}onGridPointerLeave(){this.clearRangePreview()}onDayKeydown(e){if(this.disabled)return;let n=e.target.getAttribute("data-iso");if(n&&(this.focusedIso=n),e.key==="ArrowLeft"){e.preventDefault(),this.moveFocusedDay(-1);return}if(e.key==="ArrowRight"){e.preventDefault(),this.moveFocusedDay(1);return}if(e.key==="ArrowUp"){e.preventDefault(),this.moveFocusedDay(-7);return}if(e.key==="ArrowDown"){e.preventDefault(),this.moveFocusedDay(7);return}if(e.key==="PageUp"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?-12:-this.pageDelta);return}if(e.key==="PageDown"){e.preventDefault(),this.moveFocusedMonth(e.shiftKey?12:this.pageDelta);return}if(e.key==="Enter"||e.key===" "){e.preventDefault();let r=e.target,i=r.getAttribute("data-iso");i&&!r.disabled&&this.selectIso(i)}}dayDataAttributes(e){return{"data-range-start":e.isRangeStart?"true":void 0,"data-range-end":e.isRangeEnd?"true":void 0,"data-range-middle":e.isRangeMiddle?"true":void 0}}render(){let e=this.monthPanels.length,n=e>1;return tt("div",{class:`rui-calendar${n?" rui-calendar--multi":""}`,"data-ref":"root",role:"application","aria-label":"Calendar","aria-multiselectable":this.selectionMode==="multiple"?"true":void 0,children:[Y("div",{class:"rui-calendar__months",children:this.monthPanels.map((r,i)=>tt("div",{class:"rui-calendar__month-panel","data-calendar-month-panel":!0,children:[tt("div",{class:"rui-calendar__header",children:[i===0?Y("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):Y("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),Y("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),i===e-1?Y("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):Y("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),i===0?Y("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(a=>Y("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:a}))}):null,Y("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(a=>Y("div",{class:"rui-calendar__week",role:"row",children:a.map(s=>Y("button",{type:"button",class:"rui-calendar__day","data-calendar-day":!0,"data-iso":s.iso,role:"gridcell",disabled:this.disabled||s.isDisabled,tabIndex:s.iso===this.focusedIso?0:-1,"aria-selected":s.isSelected?"true":"false","aria-current":s.isToday?"date":void 0,"data-outside":s.inMonth?void 0:"true",...this.dayDataAttributes(s),children:s.date.getDate()}))}))})]}))}),Y("div",{class:"rui-calendar__footer",children:Y("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{an()}};import{jsx as gi}from"@ecopages/jsx/jsx-runtime";function nt(t){return gi("rui-calendar",{...t})}import{jsx as ke}from"@ecopages/jsx/jsx-runtime";import{customElement as _i,event as wi,onEvent as be,onUpdated as hr,prop as xe,registerSsrPreparationCallback as Di,state as fr}from"@ecopages/radiant";import{FormAssociatedElement as pr}from"@ecopages/radiant/form-associated-element";function zn(t,e){let n=t.type,r=Te(t),i=!e.useTextboxRole,a=i?"spinbutton":"textbox",s=!e.disabled&&!e.readOnly,o=Ae(n,e.segments);return{ariaLabel:Xe(n,e.locale),ariaReadonly:e.readOnly||void 0,ariaRole:a,ariaValuemax:i?o.max:void 0,ariaValuemin:i?o.min:void 0,ariaValuenow:i&&r!=null?r:void 0,ariaValuetext:i?we(t):void 0,className:q("rui-date-input__segment",t.isPlaceholder&&"rui-date-input__segment--placeholder"),dataRuiFocusManaged:!0,contenteditable:s?"true":void 0,inputmode:s?"numeric":void 0,suppresscontenteditablewarning:s?"true":void 0,tabindex:e.disabled?void 0:0}}var Hn,Un,qn,Kn,Nn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr;function yi(t,e,n,r,i,a){var s,o,f,y,x,R,M,O=Symbol.metadata||Symbol.for("Symbol.metadata"),j=Object.defineProperty,A=Object.create,N=[A(null),A(null)],X=e.length;function T(l,v,m){return function(u,c){v&&(c=u,u=t);for(var b=0;b<l.length;b++)c=l[b].apply(u,m?[c]:[]);return m?c:u}}function D(l,v,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(v+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function J(l,v,m,u,c,b,I,g,_,w,Q){function $(h){if(!Q(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(v[0]),ee=v[3],W=!I,P=c===1,te=c===3,ne=c===4,k=c===2;function L(h,F,ae){return function(V,oe){return F&&(oe=V,V=l),ae&&ae(V),d[h].call(V,oe)}}if(!W){var d={},z=[],S=te?"get":ne||P?"set":"value";if(_?(w||P?d={get:dr(function(){return ee(this)},u,"get"),set:function(h){v[4](this,h)}}:d[S]=ee,w||dr(d[S],u,k?"":S)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=N[+g][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[S].name+") is not supported yet");N[+g][u]=c<3?1:c}}for(var p=l,C=G.length-1;C>=0;C-=m?2:1){var re=D(G[C],"A decorator","be",!0),ie=m?G[C-1]:void 0,H={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,F){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");D(F,"An initializer","be",!0),b.push(F)}.bind(null,H)};if(W)o=re.call(ie,p,E),H.v=1,D(o,"class decorators","return")&&(p=o);else if(E.static=g,E.private=_,o=E.access={has:_?Q.bind():function(h){return u in h}},ne||(o.get=_?k?function(h){return $(h),d.value}:L("get",0,$):function(h){return h[u]}),k||te||(o.set=_?L("set",0,$):function(h,F){h[u]=F}),p=re.call(ie,P?{get:d.get,set:d.set}:d[S],E),H.v=1,P){if(typeof p=="object"&&p)(o=D(p.get,"accessor.get"))&&(d.get=o),(o=D(p.set,"accessor.set"))&&(d.set=o),(o=D(p.init,"accessor.init"))&&z.unshift(o);else if(p!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or undefined")}else D(p,(w?"field":"method")+" decorators","return")&&(w?z.unshift(p):d[S]=p)}return c<2&&I.push(T(z,g,1),T(b,g,0)),w||W||(_?P?I.splice(-1,0,L("get",g),L("set",g)):I.push(k?d[S]:D.call.bind(d[S])):j(l,u,d)),p}function Z(l){return j(l,O,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[O]),s=A(s??null),x=[],R=function(l){l&&x.push(T(l))},M=function(l,v){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],b=7&c;if((8&c)==l&&!b==v){var I=u[2],g=!!u[3],_=16&c;J(l?t:t.prototype,u,_,g?"#"+I:vi(I),b,b<2?[]:l?y=y||[]:f=f||[],x,!!l,g,v,l&&g?function(w){return xi(w)===t}:i)}}},M(8,0),M(0,0),M(8,1),M(0,1),R(f),R(y),o=x,X||Z(t),{e:o,get c(){var l=[];return X&&[Z(t=J(t,[e],r,t.name,5,l)),T(l,1)]}}}function vi(t){var e=bi(t,"string");return typeof e=="symbol"?e:e+""}function bi(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function dr(t,e,n){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(t,"name",{configurable:!0,value:n?n+" "+e:e})}catch{}return t}function xi(t){if(Object(t)!==t)throw TypeError("right-hand side of 'in' should be an object, got "+(t!==null?typeof t:"null"));return t}function Si(){return typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)}var gr,mr=class extends pr{static{({e:[qn,Kn,Nn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,Hn],c:[gr,Un]}=yi(this,[_i("rui-date-input")],[[xe({type:String,reflect:!0,defaultValue:""}),0,"value"],[xe({type:String,defaultValue:""}),0,"min"],[xe({type:String,defaultValue:""}),0,"max"],[xe({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[xe({type:String,defaultValue:""}),0,"label"],[xe({type:String,defaultValue:""}),0,"locale"],[wi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[fr,0,"segments"],[fr,0,"focusedPart"],[hr(["value","locale"]),2,"syncSegmentsFromValue"],[hr("label"),2,"syncGroupLabel"],[be({selector:'[data-ref="root"]',type:"focusin"}),2,"onGroupFocusIn"],[be({selector:"[data-date-segment]",type:"focusin"}),2,"onSegmentFocusIn"],[be({selector:"[data-date-segment]",type:"focusout"}),2,"onSegmentFocusOut"],[be({selector:"[data-date-segment]",type:"keydown"}),2,"onSegmentKeyDown"],[be({selector:"[data-date-segment]",type:"beforeinput"}),2,"onSegmentBeforeInput"],[be({selector:"[data-date-segment]",type:"pointerdown"}),2,"onSegmentPointerDown"]],0,void 0,pr))}value=(Hn(this),qn(this));min=(Kn(this),Nn(this));max=(Xn(this),Jn(this));readOnly=(Zn(this),Qn(this));label=(er(this),tr(this));locale=(nr(this),rr(this));changeEvent=(ir(this),ar(this));segments=(or(this),sr(this,[]));focusedPart=(lr(this),ur(this,null));uid=(cr(this),De("rui-date-input"));buffer="";useTextboxRole=Si();pendingFocus=null;get resolvedLocale(){return Re(this.locale)}get isoValue(){return this.value??""}syncSegmentsFromValue(){this.segments=Ee(de(this.isoValue),this.resolvedLocale),this.buffer=""}get displaySegments(){return this.segments.length>0?this.segments:Ee(de(this.isoValue),this.resolvedLocale)}constructor(){super(),Di(this,()=>this.syncSegmentsFromValue())}getSegmentElement(e){return this.querySelector(`[data-date-segment][data-type="${e}"]`)}setFocusedPart(e,n="leave"){let r=this.focusedPart;e===r&&n==="leave"||(this.buffer="",(r!=null||n==="blur")&&this.commit(n),this.focusedPart=e)}focusPart(e){this.setFocusedPart(e),this.pendingFocus=e}updated(e){super.updated(e),this.pendingFocus=null;let n=this.focusedPart;if(!n||!(e.has("focusedPart")||e.has("segments"))||!this.matches(":focus-within"))return;let r=this.getSegmentElement(n);r&&(document.activeElement!==r&&r.focus(),document.activeElement===r&&window.getSelection()?.collapse(r,0))}commit(e){if(e==="edit"&&this.buffer)return;let n=Ue(this.segments,{min:this.min,max:this.max});switch(n.kind){case"partial-year":e!=="edit"&&this.syncSegmentsFromValue();return;case"incomplete":e==="blur"&&this.syncSegmentsFromValue();return;case"out-of-range":this.syncSegmentsFromValue();return;case"empty":this.publish("");return;case"date":this.publish(n.iso)}}publish(e){if(e===this.isoValue){this.syncSegmentsFromValue();return}this.value=e,this.changeEvent.emit({value:e})}partFromTarget(e){if(!(e instanceof HTMLElement))return null;let r=e.closest("[data-date-segment]")?.getAttribute("data-type");return r==="month"||r==="day"||r==="year"?r:null}handleDigit(e,n){this.setFocusedPart(e);let r=Ze(this.segments,e,n,this.buffer);if(this.segments=r.segments,this.buffer=r.enteredKeys,r.focusNext){this.focusPart(ve(this.segments,e,1));return}this.commit("edit")}handleBackspace(e){this.setFocusedPart(e);let n=et(this.segments,e);if(n.kind==="focus-previous"){this.focusPart(ve(this.segments,e,-1));return}this.segments=n.segments,this.buffer=n.enteredKeys,this.commit("edit")}handleIncrement(e,n){this.setFocusedPart(e),this.buffer="",this.segments=Je(this.segments,e,n),this.commit("edit")}onConnected(){this.syncSegmentsFromValue(),this.syncGroupLabel()}formValue(){return this.name?this.isoValue:null}formState(){return this.value}restoreFormState(e){this.value=typeof e=="string"?e:"",this.syncSegmentsFromValue()}formResetCallback(){super.formResetCallback(),this.dispatchEvent(new Event("rui-form-reset",{bubbles:!0}))}syncGroupLabel(){let e=this.querySelector('[data-ref="root"]');if(!e)return;e.id||(e.id=`${this.uid}-group`);let n=this.label||this.getAttribute("aria-label")||"";n?e.setAttribute("aria-label",n):e.removeAttribute("aria-label")}onGroupFocusIn(e){this.partFromTarget(e.target)||this.focusPart(Qe(this.segments))}onSegmentFocusIn(e){let n=this.partFromTarget(e.target);n&&(this.pendingFocus&&this.pendingFocus!==n||this.setFocusedPart(n))}onSegmentFocusOut(){queueMicrotask(()=>{this.matches(":focus-within")||this.setFocusedPart(null,"blur")})}onSegmentKeyDown(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly)){if(e.key==="ArrowLeft"){e.preventDefault(),this.focusPart(ve(this.segments,n,-1));return}if(e.key==="ArrowRight"){e.preventDefault(),this.focusPart(ve(this.segments,n,1));return}if(e.key==="ArrowUp"){e.preventDefault(),this.handleIncrement(n,1);return}if(e.key==="ArrowDown"){e.preventDefault(),this.handleIncrement(n,-1);return}(e.key==="Backspace"||e.key==="Delete")&&(e.preventDefault(),e.stopPropagation(),this.handleBackspace(n))}}onSegmentBeforeInput(e){let n=this.partFromTarget(e.target);if(!(!n||this.effectiveDisabled||this.readOnly))switch(e.preventDefault(),e.inputType){case"deleteContentBackward":case"deleteContentForward":this.handleBackspace(n);break;default:e.data!=null&&this.handleDigit(n,e.data);break}}onSegmentPointerDown(e){e.stopPropagation()}renderSegment(e,n){if(!e.editable)return ke("span",{class:"rui-date-input__literal","data-type":"literal","aria-hidden":"true",children:e.value},`literal-${n}`);let r=e.type,i=this.focusedPart===r,a=zn(e,{disabled:this.effectiveDisabled,locale:this.resolvedLocale,readOnly:this.readOnly,segments:this.displaySegments,useTextboxRole:this.useTextboxRole});return ke("span",{class:a.className,"data-date-segment":!0,"data-type":r,"data-placeholder":e.isPlaceholder?"true":void 0,"data-focused":i?"true":void 0,role:a.ariaRole,"aria-label":a.ariaLabel,"aria-valuemin":a.ariaValuemin,"aria-valuemax":a.ariaValuemax,"aria-valuenow":a.ariaValuenow,"aria-valuetext":a.ariaValuetext,"aria-readonly":a.ariaReadonly,"data-rui-focus-managed":a.dataRuiFocusManaged,contenteditable:a.contenteditable,suppresscontenteditablewarning:a.suppresscontenteditablewarning,spellcheck:"false",inputmode:a.inputmode,tabindex:a.tabindex,children:we(e)},r)}render(){return ke("div",{class:"rui-date-input","data-ref":"root",role:"group",children:ke("div",{class:"rui-date-input__segments",children:this.displaySegments.map((e,n)=>this.renderSegment(e,n))})})}static{Un()}};import{jsx as Mi}from"@ecopages/jsx/jsx-runtime";function rt(t){return Mi("rui-date-input",{"data-rui-control":!0,"data-rui-control-type":"date","data-rui-aria-target":'[data-ref="root"]',...t})}function vr({children:t,class:e,...n}){return B("div",{...n,class:q("rui-date-field",e),children:B("div",{class:"rui-date-field__group","data-ref":"control",children:t})})}function br({class:t,...e}){return B(rt,{...e,"data-date-field-input":!0,class:q("rui-date-field__input",t)})}function xr({children:t,class:e,aria:n,...r}){return B("button",{...r,aria:Ut(n,"Open calendar"),type:"button","data-ref":"trigger","data-date-field-trigger":!0,class:q("rui-control-toggle",e),"aria-haspopup":"dialog",children:t??B(Ce,{})})}function _r({children:t,class:e,...n}){return B("div",{...n,"data-ref":"popover","data-date-field-popover":!0,class:q("rui-date-field__popover rui-popover rui-floating",e),hidden:!0,role:"dialog",children:t})}function wr(t){return B(nt,{...t,"data-date-field-calendar":!0})}function Ri(t){let{children:e,value:n,min:r,max:i,disabled:a,readOnly:s,label:o,name:f,locale:y}=t;return B("rui-date-field",{"data-rui-aria-target":'[data-date-field-input] [data-ref="root"]',...t,children:e??yr(Ii,{children:[yr(vr,{children:[B(br,{value:n,min:r,max:i,disabled:a,readOnly:s,label:o,name:f,locale:y}),B(xr,{})]}),B(_r,{children:B(wr,{})})]})})}export{Ri as RuiDateField,wr as RuiDateFieldCalendar,vr as RuiDateFieldControl,Ht as RuiDateFieldElement,br as RuiDateFieldInput,_r as RuiDateFieldPopover,xr as RuiDateFieldToggle};
2
2
  //# sourceMappingURL=index.js.map