@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 Zt,bindTo as X,customElement as ri,event as ii,onEvent as ce,onUpdated as Qt,prop as q,query as ai,state as oi}from"@ecopages/radiant";function fe(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 ue(t,e,n){return!(e&&t<e||n&&t>n)}function pe(t,e){return t.localeCompare(e)}function ye(t,e){return pe(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function U(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:ye(e,n)}function ve(t){if(!t)return"";let e=ye(t.start,t.end);return`${e.start}/${e.end}`}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(pe):[]}function Oe(t){return[...new Set(t)].sort(pe).join(",")}function Ve(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(pe)}function it(t,e){let n=ye(e.start,e.end);return pe(t,n.start)>=0&&pe(t,n.end)<=0}function Le(t,e,n){if(e==="single"){let g=n.singleIso===t;return{isSelected:g,isRangeStart:g,isRangeEnd:g,isRangeMiddle:!1}}if(e==="multiple"){let g=n.multipleIsos?.includes(t)??!1;return{isSelected:g,isRangeStart:g,isRangeEnd:g,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let i=ye(r.start,r.end),a=it(t,i),s=t===i.start,o=t===i.end;return{isSelected:a,isRangeStart:s,isRangeEnd:o,isRangeMiddle:a&&!s&&!o}}function je(t,e,n){return e.anchor?{committed:ye(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function Se(t){let e=Mr(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 Mr(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function Pr(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function kr(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Er(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:be(n)};if(e==="range"){let r=U(n);if(t.rangeDraft?.anchor){let i=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:Fr(t.rangeDraft.anchor,i)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function Fr(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function Ye(t,e,n){let r=Se(n.locale),i=Pr(n.today??new Date),a=Er(n),o=(new Date(t,e,1).getDay()-r+7)%7,f=new Date(t,e,1-o),g=[],v=new Date(f);for(let R=0;R<6;R+=1){let D=[];for(let j=0;j<7;j+=1){let Y=K(v),A=Le(Y,a.mode,{singleIso:a.singleIso,multipleIsos:a.multipleIsos,range:a.range});D.push({date:new Date(v),iso:Y,inMonth:v.getMonth()===e,isToday:kr(v,i),isSelected:A.isSelected,isDisabled:!ue(Y,n.min,n.max),isRangeStart:A.isRangeStart,isRangeEnd:A.isRangeEnd,isRangeMiddle:A.isRangeMiddle}),v.setDate(v.getDate()+1)}if(g.push(D),R>=4&&v.getMonth()!==e&&v.getDate()>7)break}return g}function Ie(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function Be(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(i,a)=>{let s=Ie(t,e,a);return{year:s.year,month:s.month,offset:a}})}var at=new Map;function Ar(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function ge(t,e){let n=Ar(t,e),r=at.get(n);if(r)return r;let i=new Intl.DateTimeFormat(t,e);return at.set(n,i),i}function $e(t,e){return ge(e,{month:"long",year:"numeric"}).format(t)}function ze(t,e){let n=ge(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 Ge(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var Tr=new Date(2e3,0,1);function Cr(t,e){return t==="year"?e==="year":t==="month"?e==="year"||e==="month":!0}function Or(t,e){let r=ge(e,{[t]:t==="year"?"numeric":"2-digit"}).formatToParts(Tr).find(i=>i.type===t);return r?r.value.replace(/\d/g,t==="year"?"y":t==="month"?"m":"d"):t==="year"?"yyyy":"mm"}function Vr(t,e,n){let r=t==="year"?{year:"numeric"}:{[t]:"2-digit"};return ge(n,r).formatToParts(e).find(i=>i.type===t)?.value??""}function Re(t,e,n={}){let r=n.granularity??"day",i=t??n.placeholderDate??new Date;return ge(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(!Cr(r,o))return null;let f=t!=null;return{type:o,value:f?Vr(o,t,e):"",placeholder:Or(o,e),isPlaceholder:!f,editable:!0}}).filter(s=>s!=null)}function Lr(t){if(t.isPlaceholder||t.value==="")return null;let e=Number(t.value);return Number.isFinite(e)?e:null}function jr(t){return t>=100?t:t>=69?1900+t:2e3+t}function ot(t){let e={};for(let r of t){if(!r.editable)continue;let i=Lr(r);if(i==null)return null;e[r.type]=r.type==="year"?jr(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 st(t){return t.every(e=>!e.editable||e.isPlaceholder||e.value==="")}function We(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(st(t))return{kind:"empty"};let r=ot(t);if(!r)return{kind:"incomplete"};let i=K(r);return ue(i,e.min,e.max)?{kind:"date",iso:i}:{kind:"out-of-range"}}function He(t){return t==="year"?4:2}function Yr(t,e){return t.findIndex(n=>n.editable&&n.type===e)}function Br(t){return t.map(e=>({...e}))}function Ue(t,e,n){let r=Br(t),i=Yr(r,e);return i<0||(r[i]={...r[i],...n}),r}function Ne(t){if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Me(t,e){return{min:1,max:ut(t,e)}}function ut(t,e){if(t==="month")return 12;if(t==="day"){let n=lt(e,"year"),r=lt(e,"month");return n!=null&&r!=null?new Date(n,r,0).getDate():31}return 9999}function lt(t,e){let n=t.find(r=>r.editable&&r.type===e);return!n||n.isPlaceholder||n.value===""?null:Number(n.value)}function ct(t,e){return t==="year"?String(e).padStart(4,"0"):String(e).padStart(2,"0")}function qe(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 De(t){return t.isPlaceholder||t.value===""?t.placeholder:t.value}function Pe(t){return t.isPlaceholder||t.value===""?null:Ne(t.value.replace(/\D/g,""))}function dt(t,e){return Ue(t,e,{value:"",isPlaceholder:!0})}function ht(t,e,n){return Ue(t,e,{value:ct(e,n),isPlaceholder:!1})}function Ke(t,e,n){let r=t.find(f=>f.editable&&f.type===e);if(!r)return t;let{min:i,max:a}=Me(e,t),o=(Pe(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),ht(t,e,o)}function Xe(t,e,n,r){let i=n.replace(/\D/g,"");if(!i)return{segments:t,enteredKeys:r,focusNext:!1};let a=r+i,s=Ne(a);if(s==null)return{segments:t,enteredKeys:r,focusNext:!1};let o=ut(e,t),f=s;f>o&&(f=Ne(i)??f);let g=He(e),v=+`${f}0`>o||a.length>=g||String(f).length>=g,R=v?ct(e,f):String(f);return{segments:Ue(t,e,{value:R,isPlaceholder:!1}),enteredKeys:v?"":a,focusNext:v}}function ft(t){return t.filter(e=>e.editable).map(e=>e.type)}function xe(t,e,n){let r=ft(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 Je(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 Ze(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:dt(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 $r={top:"bottom",bottom:"top",left:"right",right:"left"},zr=8,Qe=new WeakMap;function Gr(t){Qe.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",Qe.delete(t))}function Wr(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 mt(t){return t==="top"||t==="bottom"?"y":"x"}function pt(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 mt(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 Hr(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 gt(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 Nr(t,e){return e==="center"?t:`${t}-${e}`}function Ur(t,e,n,r){let{padding:i,width:a,height:s}=r;if(mt(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 qr(t,e,n,r,i={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:zr}){let{side:a,align:s}=Wr(n),o=pt(t,e,a,s,r),f=Hr(o,e,a,i),g=a,v=o;if(f>0){let R=$r[a],D=pt(t,e,R,s,r),j=gt(t,e,a,i);gt(t,e,R,i)>j&&(g=R,v=D)}return{coords:Ur(v,e,g,i),placement:Nr(g,s)}}function Kr(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",Qe.set(e,!0)):Gr(e);let{coords:f,placement:g}=qr(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",g),g}function yt({anchor:t,floating:e,getPlacement:n,gap:r,matchAnchorWidth:i}){let a=()=>{e.hidden||Kr(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 vt(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 bt(t,e,n){return n?!!(t?.contains(n)||e?.contains(n)):!1}function xt(t,e,n){return n instanceof Node?!bt(t,e,n):!0}var ke=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=vt(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=yt({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return bt(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 Ee=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(){Xr(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;xt(this.config.getHost(),i,a)&&n()})}ensureController(){return this.popoverController||(this.popoverController=new ke({getAnchor:this.config.getAnchor,getFloating:this.config.getFloating,getOpen:this.config.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}};function Xr(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 Zr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(`(max-width: ${639}px)`).matches}function _t(t){return t<=1||!Zr()?t:1}function wt(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 Dt,St,It,Rt,Mt,Pt,kt,Et,Ft,At,Tt,Ct,Ot,Vt,Lt,jt,Yt,Bt,$t,zt,Gt,Wt,Ht,Nt,Ut,qt,Kt,Xt;function Qr(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,A=Object.create,J=[A(null),A(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:Jt(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||Jt(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.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 S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=A(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:ei(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return ni(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(t,[e],r,t.name,5,l)),T(l,1)]}}}function ei(t){var e=ti(t,"string");return typeof e=="symbol"?e:e+""}function ti(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 Jt(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 ni(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 tn,en=class extends Zt{static{({e:[It,Rt,Mt,Pt,kt,Et,Ft,At,Tt,Ct,Ot,Vt,Lt,jt,Yt,Bt,$t,zt,Gt,Wt,Ht,Nt,Ut,qt,Kt,Xt,Dt],c:[tn,St]}=Qr(this,[ri("rui-date-range-picker")],[[[q({type:String,reflect:!0,defaultValue:""}),X({selector:"[data-range-calendar]",attr:"value"})],0,"value"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"min"},{selector:"[data-range-end]",attr:"min"},{selector:"[data-range-calendar]",attr:"min"}])],0,"min"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"max"},{selector:"[data-range-end]",attr:"max"},{selector:"[data-range-calendar]",attr:"max"}])],0,"max"],[[q({type:Boolean,reflect:!0,defaultValue:!1}),X([{selector:"[data-range-start]",bool:"disabled"},{selector:"[data-range-end]",bool:"disabled"},{selector:"[data-range-calendar]",bool:"disabled"}])],0,"disabled"],[[q({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),X([{selector:"[data-range-start]",bool:"read-only"},{selector:"[data-range-end]",bool:"read-only"}])],0,"readOnly"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"locale"},{selector:"[data-range-end]",attr:"locale"},{selector:"[data-range-calendar]",attr:"locale"}])],0,"locale"],[[q({type:String,attribute:"start-name",defaultValue:""}),X({selector:"[data-range-start]",attr:"name"})],0,"startName"],[[q({type:String,attribute:"end-name",defaultValue:""}),X({selector:"[data-range-end]",attr:"name"})],0,"endName"],[q({type:String,defaultValue:""}),0,"name"],[q({type:Number,attribute:"visible-months",defaultValue:2}),0,"visibleMonths"],[ii({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[[oi,X({selector:"[data-range-trigger]",attr:"aria-expanded"})],0,"open"],[ai({ref:"popover"}),0,"popoverTarget"],[Qt(["value","min","max","disabled","readOnly","locale","visibleMonths"]),2,"onPropsUpdated"],[Qt(["open"]),2,"onOpenUpdated"],[ce({selector:"[data-range-start], [data-range-end]",type:"rui-change"}),2,"onDateInputChange"],[ce({selector:"[data-range-start], [data-range-end]",type:"rui-form-reset"}),2,"onDateInputReset"],[ce({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[ce({ref:"trigger",type:"click"}),2,"onTriggerClick"],[ce({selector:"[data-range-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[ce({selector:"[data-range-calendar]",type:"rui-change"}),2,"onCalendarChange"],[ce({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-calendar]",type:"keydown"}),2,"onRootKeydown"],[ce({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-popover]",type:"focusout"}),2,"onRootFocusOut"]],0,void 0,Zt))}value=(Dt(this),It(this));min=(Rt(this),Mt(this));max=(Pt(this),kt(this));disabled=(Et(this),Ft(this));readOnly=(At(this),Tt(this));locale=(Ct(this),Ot(this));startName=(Vt(this),Lt(this));endName=(jt(this),Yt(this));name=(Bt(this),$t(this));visibleMonths=(zt(this),Gt(this));changeEvent=(Wt(this),Ht(this));open=(Nt(this),Ut(this,!1));calendarPopover=(qt(this),new Ee({getHost:()=>this,getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getCalendar:()=>this.getCalendar(),getFocusIso:()=>U(this.isoValue)?.start}));disposeMobileLayoutListener=null;popoverTarget=Kt(this);onMediaChange=(Xt(this),()=>{this.syncCalendar(),this.open&&this.calendarPopover.syncPopover()});get isoValue(){return this.value??""}getStartInput(){return this.querySelector("[data-range-start]")}getEndInput(){return this.querySelector("[data-range-end]")}getToggle(){return this.querySelector("[data-range-trigger]")}getCalendar(){return this.querySelector("[data-range-calendar]")}readInputIso(e){let n=e==="start"?this.getStartInput():this.getEndInput();if(!n)return"";let r=Reflect.get(n,"value");return typeof r=="string"?r:n.getAttribute("value")??""}projectCompleteRangeOntoInputs(){let e=U(this.isoValue);e&&(this.getStartInput()?.setAttribute("value",e.start),this.getEndInput()?.setAttribute("value",e.end))}commitRange(e,n){let r=this.min||void 0,i=this.max||void 0;if(e&&!ue(e,r,i)||n&&!ue(n,r,i))return;let a=e&&n?ve({start:e,end:n}):"";a!==this.isoValue&&(this.value=a,this.changeEvent.emit({value:a,start:e,end:n}))}commitFromInputs(){let e=this.readInputIso("start"),n=this.readInputIso("end");if(e&&n){this.commitRange(e,n);return}this.commitRange("","")}setOpen(e){this.open=e,queueMicrotask(()=>{this.calendarPopover.syncPopover(),e&&this.calendarPopover.focusCalendarDay()})}syncToggle(){let e=this.getToggle();e&&(e.disabled=this.disabled||this.readOnly)}syncCalendar(){let e=this.getCalendar();e&&(e.setAttribute("selection-mode","range"),e.setAttribute("visible-months",String(_t(this.visibleMonths))))}initialize(){this.projectCompleteRangeOntoInputs(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}onConnected(){this.disposeMobileLayoutListener=wt(this.onMediaChange),this.initialize()}disconnectedCallback(){this.disposeMobileLayoutListener?.(),this.disposeMobileLayoutListener=null,this.calendarPopover.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.projectCompleteRangeOntoInputs(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.calendarPopover.syncPopover()}onDateInputChange(e){let n=e.target;n instanceof HTMLElement&&n.matches("[data-range-start], [data-range-end]")&&this.commitFromInputs()}onDateInputReset(){queueMicrotask(()=>{let e=this.readInputIso("start"),n=this.readInputIso("end");this.value=e&&n?ve({start:e,end:n}):""})}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-range-calendar]"))return;let r=e.detail;!r?.start||!r.end||(this.commitRange(r.start,r.end),this.setOpen(!1))}onRootKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),this.setOpen(!1))}onRootFocusOut(e){this.calendarPopover.handleFocusOut(e,()=>this.setOpen(!1))}static{St()}};import{Fragment as Pi,jsx as F,jsxs as rt}from"@ecopages/jsx/jsx-runtime";function nn(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function $(...t){return t.filter(Boolean).join(" ")}import{jsx as Fe,jsxs as si}from"@ecopages/jsx/jsx-runtime";function et({class:t,size:e="sm",...n}){return si("svg",{...n,class:$("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:[Fe("path",{d:"M8 2v4"}),Fe("path",{d:"M16 2v4"}),Fe("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Fe("path",{d:"M3 10h18"})]})}import{jsx as B,jsxs as tt}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as $n,customElement as hi,event as fi,onEvent as me,onUpdated as pi,prop as de,registerSsrPreparationCallback as gi,state as he}from"@ecopages/radiant";function Ae(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}var rn,an,on,sn,ln,un,cn,dn,hn,fn,pn,gn,mn,yn,vn,bn,xn,_n,wn,Dn,Sn,In,Rn,Mn,Pn,kn,En,Fn,An,Tn,Cn,On,Vn,Ln,jn,Yn;function li(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,A=Object.create,J=[A(null),A(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:Bn(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||Bn(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.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 S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=A(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:ui(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return di(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(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 Gn,zn=class extends $n{static{({e:[on,sn,ln,un,cn,dn,hn,fn,pn,gn,mn,yn,vn,bn,xn,_n,wn,Dn,Sn,In,Rn,Mn,Pn,kn,En,Fn,An,Tn,Cn,On,Vn,Ln,jn,Yn,rn],c:[Gn,an]}=li(this,[hi("rui-calendar")],[[de({type:String,reflect:!0,defaultValue:""}),0,"value"],[de({type:String,defaultValue:""}),0,"min"],[de({type:String,defaultValue:""}),0,"max"],[de({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[de({type:String,defaultValue:""}),0,"locale"],[de({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[de({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[de({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[fi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[he,0,"viewYear"],[he,0,"viewMonth"],[he,0,"focusedIso"],[he,0,"weekdayLabels"],[he,0,"monthPanels"],[he,0,"todayLabel"],[he,0,"rangeAnchor"],[he,0,"rangeHover"],[pi(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[me({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[me({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[me({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[me({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[me({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[me({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[me({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=(gn(this),mn(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=(In(this),Rn(this,new Date().getMonth()));focusedIso=(Mn(this),Pn(this,""));weekdayLabels=(kn(this),En(this,[]));monthPanels=(Fn(this),An(this,[]));todayLabel=(Tn(this),Cn(this,""));rangeAnchor=(On(this),Vn(this,null));rangeHover=(Ln(this),jn(this,null));get resolvedLocale(){return Ae(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"?U(this.value)?.start??"":this.selectionMode==="multiple"?be(this.value)[0]??"":this.value,n=fe(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,Se(this.resolvedLocale)),this.monthPanels=Be(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:$e(n,this.resolvedLocale),weeks:Ye(e.year,e.month,this.monthOptions)}}),this.todayLabel=Ge(this.resolvedLocale)}moveMonth(e){let n=Ie(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=fe(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(Ve(be(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=je(U(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),gi(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:[B("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?B("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):B("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),B("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),i===e-1?B("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):B("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),i===0?B("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(a=>B("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:a}))}):null,B("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(a=>B("div",{class:"rui-calendar__week",role:"row",children:a.map(s=>B("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()}))}))})]}))}),B("div",{class:"rui-calendar__footer",children:B("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{an()}};import{jsx as mi}from"@ecopages/jsx/jsx-runtime";function nt({children:t,...e}){return mi("rui-calendar",{...e,children:t})}import{jsx as Te}from"@ecopages/jsx/jsx-runtime";import{customElement as Di,event as Si,onEvent as _e,onUpdated as pr,prop as we,registerSsrPreparationCallback as Ii,state as gr}from"@ecopages/radiant";import{FormAssociatedElement as mr}from"@ecopages/radiant/form-associated-element";var yi=/^[A-Za-z][A-Za-z0-9_-]*$/;function Wn(t){return yi.test(t)}function vi(t){let e=t.trim();if(Wn(e))return e;let n=`rui-${e}`;return e&&Wn(n)?n:"rui"}function Hn(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`${vi(t)}-${e}`}function Nn(t,e){let n=t.type,r=Pe(t),i=!e.useTextboxRole,a=i?"spinbutton":"textbox",s=!e.disabled&&!e.readOnly,o=Me(n,e.segments);return{ariaLabel:qe(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?De(t):void 0,className:$("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 Un,qn,Kn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,dr,hr;function bi(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,A=Object.create,J=[A(null),A(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:fr(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||fr(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.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 S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=A(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:xi(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return wi(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(t,[e],r,t.name,5,l)),T(l,1)]}}}function xi(t){var e=_i(t,"string");return typeof e=="symbol"?e:e+""}function _i(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 fr(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 wi(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 Ri(){return typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)}var vr,yr=class extends mr{static{({e:[Kn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,dr,hr,Un],c:[vr,qn]}=bi(this,[Di("rui-date-input")],[[we({type:String,reflect:!0,defaultValue:""}),0,"value"],[we({type:String,defaultValue:""}),0,"min"],[we({type:String,defaultValue:""}),0,"max"],[we({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[we({type:String,defaultValue:""}),0,"label"],[we({type:String,defaultValue:""}),0,"locale"],[Si({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[gr,0,"segments"],[gr,0,"focusedPart"],[pr(["value","locale"]),2,"syncSegmentsFromValue"],[pr("label"),2,"syncGroupLabel"],[_e({selector:'[data-ref="root"]',type:"focusin"}),2,"onGroupFocusIn"],[_e({selector:"[data-date-segment]",type:"focusin"}),2,"onSegmentFocusIn"],[_e({selector:"[data-date-segment]",type:"focusout"}),2,"onSegmentFocusOut"],[_e({selector:"[data-date-segment]",type:"keydown"}),2,"onSegmentKeyDown"],[_e({selector:"[data-date-segment]",type:"beforeinput"}),2,"onSegmentBeforeInput"],[_e({selector:"[data-date-segment]",type:"pointerdown"}),2,"onSegmentPointerDown"]],0,void 0,mr))}value=(Un(this),Kn(this));min=(Xn(this),Jn(this));max=(Zn(this),Qn(this));readOnly=(er(this),tr(this));label=(nr(this),rr(this));locale=(ir(this),ar(this));changeEvent=(or(this),sr(this));segments=(lr(this),ur(this,[]));focusedPart=(cr(this),dr(this,null));uid=(hr(this),Hn("rui-date-input"));buffer="";useTextboxRole=Ri();pendingFocus=null;get resolvedLocale(){return Ae(this.locale)}get isoValue(){return this.value??""}syncSegmentsFromValue(){this.segments=Re(fe(this.isoValue),this.resolvedLocale),this.buffer=""}get displaySegments(){return this.segments.length>0?this.segments:Re(fe(this.isoValue),this.resolvedLocale)}constructor(){super(),Ii(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=We(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=Xe(this.segments,e,n,this.buffer);if(this.segments=r.segments,this.buffer=r.enteredKeys,r.focusNext){this.focusPart(xe(this.segments,e,1));return}this.commit("edit")}handleBackspace(e){this.setFocusedPart(e);let n=Ze(this.segments,e);if(n.kind==="focus-previous"){this.focusPart(xe(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=Ke(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(Je(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(xe(this.segments,n,-1));return}if(e.key==="ArrowRight"){e.preventDefault(),this.focusPart(xe(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 Te("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=Nn(e,{disabled:this.effectiveDisabled,locale:this.resolvedLocale,readOnly:this.readOnly,segments:this.displaySegments,useTextboxRole:this.useTextboxRole});return Te("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:De(e)},r)}render(){return Te("div",{class:"rui-date-input","data-ref":"root",role:"group",children:Te("div",{class:"rui-date-input__segments",children:this.displaySegments.map((e,n)=>this.renderSegment(e,n))})})}static{qn()}};import{jsx as Mi}from"@ecopages/jsx/jsx-runtime";function Ce({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 br({children:t,class:e,...n}){return F("div",{...n,class:$("rui-date-range-picker",e),children:F("div",{class:"rui-date-range-picker__group","data-ref":"control",children:t})})}function xr({children:t,class:e,...n}){return F("div",{...n,class:$("rui-date-range-picker__values",e),"data-ref":"values",children:t})}function _r({class:t,...e}){return F(Ce,{...e,"data-range-start":!0,class:$("rui-date-range-picker__input",t)})}function wr({class:t,...e}){return F(Ce,{...e,"data-range-end":!0,class:$("rui-date-range-picker__input",t)})}function Dr({children:t="\u2013",class:e,...n}){return F("span",{...n,class:$("rui-date-range-picker__separator",e),"aria-hidden":"true",children:t})}function Sr({children:t,class:e,aria:n,...r}){return F("button",{...r,aria:nn(n,"Open calendar"),type:"button","data-ref":"trigger","data-range-trigger":!0,class:$("rui-control-toggle",e),"aria-haspopup":"dialog",children:t??F(et,{})})}function Ir({children:t,class:e,...n}){return F("div",{...n,"data-ref":"popover","data-range-popover":!0,class:$("rui-date-range-picker__popover rui-popover rui-floating",e),hidden:!0,role:"dialog",children:t})}function Rr(t){return F(nt,{...t,"data-range-calendar":!0})}function ki(t){let{children:e,startLabel:n="Start date",endLabel:r="End date",value:i,min:a,max:s,disabled:o,readOnly:f,locale:g,startName:v,endName:R}=t,D=U(i??"");return F("rui-date-range-picker",{"data-rui-aria-targets":'[data-range-start] [data-ref="root"],[data-range-end] [data-ref="root"]',...t,children:e??rt(Pi,{children:[rt(br,{children:[rt(xr,{children:[F(_r,{"aria-label":n,value:D?.start,min:a,max:s,disabled:o,readOnly:f,locale:g,name:v}),F(Dr,{}),F(wr,{"aria-label":r,value:D?.end,min:a,max:s,disabled:o,readOnly:f,locale:g,name:R})]}),F(Sr,{})]}),F(Ir,{children:F(Rr,{})})]})})}export{ki as RuiDateRangePicker,Rr as RuiDateRangePickerCalendar,br as RuiDateRangePickerControl,tn as RuiDateRangePickerElement,wr as RuiDateRangePickerEndInput,xr as RuiDateRangePickerInputs,Ir as RuiDateRangePickerPopover,Dr as RuiDateRangePickerSeparator,_r as RuiDateRangePickerStartInput,Sr as RuiDateRangePickerToggle};
1
+ import{RadiantElement as Zt,bindTo as X,customElement as ri,event as ii,onEvent as ce,onUpdated as Qt,prop as q,query as ai,state as oi}from"@ecopages/radiant";function fe(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 ue(t,e,n){return!(e&&t<e||n&&t>n)}function pe(t,e){return t.localeCompare(e)}function ye(t,e){return pe(t,e)<=0?{start:t,end:e}:{start:e,end:t}}function U(t){if(!t)return null;let[e,n]=t.split("/");return!e||!n?null:ye(e,n)}function ve(t){if(!t)return"";let e=ye(t.start,t.end);return`${e.start}/${e.end}`}function be(t){return t?t.split(",").map(e=>e.trim()).filter(Boolean).sort(pe):[]}function Oe(t){return[...new Set(t)].sort(pe).join(",")}function Ve(t,e){let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),[...n].sort(pe)}function it(t,e){let n=ye(e.start,e.end);return pe(t,n.start)>=0&&pe(t,n.end)<=0}function Le(t,e,n){if(e==="single"){let g=n.singleIso===t;return{isSelected:g,isRangeStart:g,isRangeEnd:g,isRangeMiddle:!1}}if(e==="multiple"){let g=n.multipleIsos?.includes(t)??!1;return{isSelected:g,isRangeStart:g,isRangeEnd:g,isRangeMiddle:!1}}let r=n.range;if(!r)return{isSelected:!1,isRangeStart:!1,isRangeEnd:!1,isRangeMiddle:!1};let i=ye(r.start,r.end),a=it(t,i),s=t===i.start,o=t===i.end;return{isSelected:a,isRangeStart:s,isRangeEnd:o,isRangeMiddle:a&&!s&&!o}}function je(t,e,n){return e.anchor?{committed:ye(e.anchor,n),draft:{anchor:null,hover:null}}:{committed:t,draft:{anchor:n,hover:n}}}function Se(t){let e=Mr(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 Mr(t){return Array.isArray(t)?t[0]??navigator.language:t??navigator.language}function Pr(t){return new Date(t.getFullYear(),t.getMonth(),t.getDate())}function kr(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Er(t){let e=t.selectionMode??"single",n=t.value??"";if(e==="multiple")return{mode:e,multipleIsos:be(n)};if(e==="range"){let r=U(n);if(t.rangeDraft?.anchor){let i=t.rangeDraft.hover??t.rangeDraft.anchor;return{mode:e,range:Fr(t.rangeDraft.anchor,i)}}return{mode:e,range:r}}return{mode:e,singleIso:n||void 0}}function Fr(t,e){return t.localeCompare(e)<=0?{start:t,end:e}:{start:e,end:t}}function Ye(t,e,n){let r=Se(n.locale),i=Pr(n.today??new Date),a=Er(n),o=(new Date(t,e,1).getDay()-r+7)%7,f=new Date(t,e,1-o),g=[],v=new Date(f);for(let R=0;R<6;R+=1){let D=[];for(let j=0;j<7;j+=1){let Y=K(v),A=Le(Y,a.mode,{singleIso:a.singleIso,multipleIsos:a.multipleIsos,range:a.range});D.push({date:new Date(v),iso:Y,inMonth:v.getMonth()===e,isToday:kr(v,i),isSelected:A.isSelected,isDisabled:!ue(Y,n.min,n.max),isRangeStart:A.isRangeStart,isRangeEnd:A.isRangeEnd,isRangeMiddle:A.isRangeMiddle}),v.setDate(v.getDate()+1)}if(g.push(D),R>=4&&v.getMonth()!==e&&v.getDate()>7)break}return g}function Ie(t,e,n){let r=new Date(t,e+n,1);return{year:r.getFullYear(),month:r.getMonth()}}function Be(t,e,n){let r=Math.max(1,Math.min(n,12));return Array.from({length:r},(i,a)=>{let s=Ie(t,e,a);return{year:s.year,month:s.month,offset:a}})}var at=new Map;function Ar(t,e){return`${JSON.stringify(t??null)}|${JSON.stringify(e)}`}function ge(t,e){let n=Ar(t,e),r=at.get(n);if(r)return r;let i=new Intl.DateTimeFormat(t,e);return at.set(n,i),i}function $e(t,e){return ge(e,{month:"long",year:"numeric"}).format(t)}function ze(t,e){let n=ge(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 Ge(t){return new Intl.RelativeTimeFormat(t,{numeric:"auto"}).format(0,"day")}var Tr=new Date(2e3,0,1);function Cr(t,e){return t==="year"?e==="year":t==="month"?e==="year"||e==="month":!0}function Or(t,e){let r=ge(e,{[t]:t==="year"?"numeric":"2-digit"}).formatToParts(Tr).find(i=>i.type===t);return r?r.value.replace(/\d/g,t==="year"?"y":t==="month"?"m":"d"):t==="year"?"yyyy":"mm"}function Vr(t,e,n){let r=t==="year"?{year:"numeric"}:{[t]:"2-digit"};return ge(n,r).formatToParts(e).find(i=>i.type===t)?.value??""}function Re(t,e,n={}){let r=n.granularity??"day",i=t??n.placeholderDate??new Date;return ge(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(!Cr(r,o))return null;let f=t!=null;return{type:o,value:f?Vr(o,t,e):"",placeholder:Or(o,e),isPlaceholder:!f,editable:!0}}).filter(s=>s!=null)}function Lr(t){if(t.isPlaceholder||t.value==="")return null;let e=Number(t.value);return Number.isFinite(e)?e:null}function jr(t){return t>=100?t:t>=69?1900+t:2e3+t}function ot(t){let e={};for(let r of t){if(!r.editable)continue;let i=Lr(r);if(i==null)return null;e[r.type]=r.type==="year"?jr(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 st(t){return t.every(e=>!e.editable||e.isPlaceholder||e.value==="")}function We(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(st(t))return{kind:"empty"};let r=ot(t);if(!r)return{kind:"incomplete"};let i=K(r);return ue(i,e.min,e.max)?{kind:"date",iso:i}:{kind:"out-of-range"}}function He(t){return t==="year"?4:2}function Yr(t,e){return t.findIndex(n=>n.editable&&n.type===e)}function Br(t){return t.map(e=>({...e}))}function Ue(t,e,n){let r=Br(t),i=Yr(r,e);return i<0||(r[i]={...r[i],...n}),r}function Ne(t){if(t==="")return null;let e=Number(t);return Number.isFinite(e)?e:null}function Me(t,e){return{min:1,max:ut(t,e)}}function ut(t,e){if(t==="month")return 12;if(t==="day"){let n=lt(e,"year"),r=lt(e,"month");return n!=null&&r!=null?new Date(n,r,0).getDate():31}return 9999}function lt(t,e){let n=t.find(r=>r.editable&&r.type===e);return!n||n.isPlaceholder||n.value===""?null:Number(n.value)}function ct(t,e){return t==="year"?String(e).padStart(4,"0"):String(e).padStart(2,"0")}function qe(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 De(t){return t.isPlaceholder||t.value===""?t.placeholder:t.value}function Pe(t){return t.isPlaceholder||t.value===""?null:Ne(t.value.replace(/\D/g,""))}function dt(t,e){return Ue(t,e,{value:"",isPlaceholder:!0})}function ht(t,e,n){return Ue(t,e,{value:ct(e,n),isPlaceholder:!1})}function Ke(t,e,n){let r=t.find(f=>f.editable&&f.type===e);if(!r)return t;let{min:i,max:a}=Me(e,t),o=(Pe(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),ht(t,e,o)}function Xe(t,e,n,r){let i=n.replace(/\D/g,"");if(!i)return{segments:t,enteredKeys:r,focusNext:!1};let a=r+i,s=Ne(a);if(s==null)return{segments:t,enteredKeys:r,focusNext:!1};let o=ut(e,t),f=s;f>o&&(f=Ne(i)??f);let g=He(e),v=+`${f}0`>o||a.length>=g||String(f).length>=g,R=v?ct(e,f):String(f);return{segments:Ue(t,e,{value:R,isPlaceholder:!1}),enteredKeys:v?"":a,focusNext:v}}function ft(t){return t.filter(e=>e.editable).map(e=>e.type)}function xe(t,e,n){let r=ft(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 Je(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 Ze(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:dt(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 $r={top:"bottom",bottom:"top",left:"right",right:"left"},zr=8,Qe=new WeakMap;function Gr(t){Qe.has(t)&&(t.style.width="",t.style.minWidth="",t.style.maxWidth="",t.style.boxSizing="",Qe.delete(t))}function Wr(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 mt(t){return t==="top"||t==="bottom"?"y":"x"}function pt(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 mt(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 Hr(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 gt(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 Nr(t,e){return e==="center"?t:`${t}-${e}`}function Ur(t,e,n,r){let{padding:i,width:a,height:s}=r;if(mt(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 qr(t,e,n,r,i={width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight,padding:zr}){let{side:a,align:s}=Wr(n),o=pt(t,e,a,s,r),f=Hr(o,e,a,i),g=a,v=o;if(f>0){let R=$r[a],D=pt(t,e,R,s,r),j=gt(t,e,a,i);gt(t,e,R,i)>j&&(g=R,v=D)}return{coords:Ur(v,e,g,i),placement:Nr(g,s)}}function Kr(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",Qe.set(e,!0)):Gr(e);let{coords:f,placement:g}=qr(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",g),g}function yt({anchor:t,floating:e,getPlacement:n,gap:r,matchAnchorWidth:i}){let a=()=>{e.hidden||Kr(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 vt(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 bt(t,e,n){return n?!!(t?.contains(n)||e?.contains(n)):!1}function xt(t,e,n){return n instanceof Node?!bt(t,e,n):!0}var ke=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=vt(e,this.config.portalContainer??document.body)):this.portalHandle&&(this.portalHandle.unmount(),this.portalHandle=null),this.teardownFloating(),this.cleanupFloating=yt({anchor:r,floating:e,getPlacement:this.config.getPlacement,gap:this.config.gap??8,matchAnchorWidth:this.config.matchAnchorWidth})}contains(e){return bt(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 Ee=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(){Xr(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;xt(this.config.getHost(),i,a)&&n()})}ensureController(){return this.popoverController||(this.popoverController=new ke({getAnchor:this.config.getAnchor,getFloating:this.config.getFloating,getOpen:this.config.getOpen,getPlacement:()=>"bottom-start",gap:4,portal:!1})),this.popoverController}};function Xr(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 Zr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(`(max-width: ${639}px)`).matches}function _t(t){return t<=1||!Zr()?t:1}function wt(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 Dt,St,It,Rt,Mt,Pt,kt,Et,Ft,At,Tt,Ct,Ot,Vt,Lt,jt,Yt,Bt,$t,zt,Gt,Wt,Ht,Nt,Ut,qt,Kt,Xt;function Qr(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,A=Object.create,J=[A(null),A(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:Jt(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||Jt(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.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 S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=A(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:ei(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return ni(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(t,[e],r,t.name,5,l)),T(l,1)]}}}function ei(t){var e=ti(t,"string");return typeof e=="symbol"?e:e+""}function ti(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 Jt(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 ni(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 tn,en=class extends Zt{static{({e:[It,Rt,Mt,Pt,kt,Et,Ft,At,Tt,Ct,Ot,Vt,Lt,jt,Yt,Bt,$t,zt,Gt,Wt,Ht,Nt,Ut,qt,Kt,Xt,Dt],c:[tn,St]}=Qr(this,[ri("rui-date-range-picker")],[[[q({type:String,reflect:!0,defaultValue:""}),X({selector:"[data-range-calendar]",attr:"value"})],0,"value"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"min"},{selector:"[data-range-end]",attr:"min"},{selector:"[data-range-calendar]",attr:"min"}])],0,"min"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"max"},{selector:"[data-range-end]",attr:"max"},{selector:"[data-range-calendar]",attr:"max"}])],0,"max"],[[q({type:Boolean,reflect:!0,defaultValue:!1}),X([{selector:"[data-range-start]",bool:"disabled"},{selector:"[data-range-end]",bool:"disabled"},{selector:"[data-range-calendar]",bool:"disabled"}])],0,"disabled"],[[q({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),X([{selector:"[data-range-start]",bool:"read-only"},{selector:"[data-range-end]",bool:"read-only"}])],0,"readOnly"],[[q({type:String,defaultValue:""}),X([{selector:"[data-range-start]",attr:"locale"},{selector:"[data-range-end]",attr:"locale"},{selector:"[data-range-calendar]",attr:"locale"}])],0,"locale"],[[q({type:String,attribute:"start-name",defaultValue:""}),X({selector:"[data-range-start]",attr:"name"})],0,"startName"],[[q({type:String,attribute:"end-name",defaultValue:""}),X({selector:"[data-range-end]",attr:"name"})],0,"endName"],[q({type:String,defaultValue:""}),0,"name"],[q({type:Number,attribute:"visible-months",defaultValue:2}),0,"visibleMonths"],[ii({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[[oi,X({selector:"[data-range-trigger]",attr:"aria-expanded"})],0,"open"],[ai({ref:"popover"}),0,"popoverTarget"],[Qt(["value","min","max","disabled","readOnly","locale","visibleMonths"]),2,"onPropsUpdated"],[Qt(["open"]),2,"onOpenUpdated"],[ce({selector:"[data-range-start], [data-range-end]",type:"rui-change"}),2,"onDateInputChange"],[ce({selector:"[data-range-start], [data-range-end]",type:"rui-form-reset"}),2,"onDateInputReset"],[ce({ref:"trigger",type:"pointerdown"}),2,"onTriggerPointerDown"],[ce({ref:"trigger",type:"click"}),2,"onTriggerClick"],[ce({selector:"[data-range-popover]",type:"mousedown"}),2,"onPopoverMouseDown"],[ce({selector:"[data-range-calendar]",type:"rui-change"}),2,"onCalendarChange"],[ce({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-calendar]",type:"keydown"}),2,"onRootKeydown"],[ce({selector:"[data-range-start], [data-range-end], [data-range-trigger], [data-range-popover]",type:"focusout"}),2,"onRootFocusOut"]],0,void 0,Zt))}value=(Dt(this),It(this));min=(Rt(this),Mt(this));max=(Pt(this),kt(this));disabled=(Et(this),Ft(this));readOnly=(At(this),Tt(this));locale=(Ct(this),Ot(this));startName=(Vt(this),Lt(this));endName=(jt(this),Yt(this));name=(Bt(this),$t(this));visibleMonths=(zt(this),Gt(this));changeEvent=(Wt(this),Ht(this));open=(Nt(this),Ut(this,!1));calendarPopover=(qt(this),new Ee({getHost:()=>this,getAnchor:()=>this.getToggle()?.parentElement??this,getFloating:()=>this.popoverTarget,getOpen:()=>this.open,getCalendar:()=>this.getCalendar(),getFocusIso:()=>U(this.isoValue)?.start}));disposeMobileLayoutListener=null;popoverTarget=Kt(this);onMediaChange=(Xt(this),()=>{this.syncCalendar(),this.open&&this.calendarPopover.syncPopover()});get isoValue(){return this.value??""}getStartInput(){return this.querySelector("[data-range-start]")}getEndInput(){return this.querySelector("[data-range-end]")}getToggle(){return this.querySelector("[data-range-trigger]")}getCalendar(){return this.querySelector("[data-range-calendar]")}readInputIso(e){let n=e==="start"?this.getStartInput():this.getEndInput();if(!n)return"";let r=Reflect.get(n,"value");return typeof r=="string"?r:n.getAttribute("value")??""}projectCompleteRangeOntoInputs(){let e=U(this.isoValue);e&&(this.getStartInput()?.setAttribute("value",e.start),this.getEndInput()?.setAttribute("value",e.end))}commitRange(e,n){let r=this.min||void 0,i=this.max||void 0;if(e&&!ue(e,r,i)||n&&!ue(n,r,i))return;let a=e&&n?ve({start:e,end:n}):"";a!==this.isoValue&&(this.value=a,this.changeEvent.emit({value:a,start:e,end:n}))}commitFromInputs(){let e=this.readInputIso("start"),n=this.readInputIso("end");if(e&&n){this.commitRange(e,n);return}this.commitRange("","")}setOpen(e){this.open=e,queueMicrotask(()=>{this.calendarPopover.syncPopover(),e&&this.calendarPopover.focusCalendarDay()})}syncToggle(){let e=this.getToggle();e&&(e.disabled=this.disabled||this.readOnly)}syncCalendar(){let e=this.getCalendar();e&&(e.setAttribute("selection-mode","range"),e.setAttribute("visible-months",String(_t(this.visibleMonths))))}initialize(){this.projectCompleteRangeOntoInputs(),this.syncToggle(),this.syncCalendar(),this.setOpen(!1)}onConnected(){this.disposeMobileLayoutListener=wt(this.onMediaChange),this.initialize()}disconnectedCallback(){this.disposeMobileLayoutListener?.(),this.disposeMobileLayoutListener=null,this.calendarPopover.destroy(),super.disconnectedCallback()}onPropsUpdated(){this.projectCompleteRangeOntoInputs(),this.syncToggle(),this.syncCalendar()}onOpenUpdated(){this.syncToggle(),this.calendarPopover.syncPopover()}onDateInputChange(e){let n=e.target;n instanceof HTMLElement&&n.matches("[data-range-start], [data-range-end]")&&this.commitFromInputs()}onDateInputReset(){queueMicrotask(()=>{let e=this.readInputIso("start"),n=this.readInputIso("end");this.value=e&&n?ve({start:e,end:n}):""})}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-range-calendar]"))return;let r=e.detail;!r?.start||!r.end||(this.commitRange(r.start,r.end),this.setOpen(!1))}onRootKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),this.setOpen(!1))}onRootFocusOut(e){this.calendarPopover.handleFocusOut(e,()=>this.setOpen(!1))}static{St()}};import{Fragment as Pi,jsx as F,jsxs as rt}from"@ecopages/jsx/jsx-runtime";function nn(t,e){return e===void 0||t?.label!==void 0?t:{...t,label:e}}function $(...t){return t.filter(Boolean).join(" ")}import{jsx as Fe,jsxs as si}from"@ecopages/jsx/jsx-runtime";function et({class:t,size:e="sm",...n}){return si("svg",{...n,class:$("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:[Fe("path",{d:"M8 2v4"}),Fe("path",{d:"M16 2v4"}),Fe("rect",{width:"18",height:"18",x:"3",y:"4",rx:"2"}),Fe("path",{d:"M3 10h18"})]})}import{jsx as B,jsxs as tt}from"@ecopages/jsx/jsx-runtime";import{RadiantElement as $n,customElement as hi,event as fi,onEvent as me,onUpdated as pi,prop as de,registerSsrPreparationCallback as gi,state as he}from"@ecopages/radiant";function Ae(t){if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length>1?e:e[0]}var rn,an,on,sn,ln,un,cn,dn,hn,fn,pn,gn,mn,yn,vn,bn,xn,_n,wn,Dn,Sn,In,Rn,Mn,Pn,kn,En,Fn,An,Tn,Cn,On,Vn,Ln,jn,Yn;function li(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,A=Object.create,J=[A(null),A(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:Bn(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||Bn(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.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 S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=A(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:ui(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return di(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(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 Gn,zn=class extends $n{static{({e:[on,sn,ln,un,cn,dn,hn,fn,pn,gn,mn,yn,vn,bn,xn,_n,wn,Dn,Sn,In,Rn,Mn,Pn,kn,En,Fn,An,Tn,Cn,On,Vn,Ln,jn,Yn,rn],c:[Gn,an]}=li(this,[hi("rui-calendar")],[[de({type:String,reflect:!0,defaultValue:""}),0,"value"],[de({type:String,defaultValue:""}),0,"min"],[de({type:String,defaultValue:""}),0,"max"],[de({type:Boolean,reflect:!0,defaultValue:!1}),0,"disabled"],[de({type:String,defaultValue:""}),0,"locale"],[de({type:String,attribute:"selection-mode",defaultValue:"single"}),0,"selectionMode"],[de({type:Number,attribute:"visible-months",defaultValue:1}),0,"visibleMonths"],[de({type:String,attribute:"page-behavior",defaultValue:"visible"}),0,"pageBehavior"],[fi({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[he,0,"viewYear"],[he,0,"viewMonth"],[he,0,"focusedIso"],[he,0,"weekdayLabels"],[he,0,"monthPanels"],[he,0,"todayLabel"],[he,0,"rangeAnchor"],[he,0,"rangeHover"],[pi(["value","min","max","disabled","locale","selectionMode","visibleMonths","pageBehavior"]),2,"onPropsUpdated"],[me({selector:"[data-calendar-prev-month]",type:"click"}),2,"onPrevMonth"],[me({selector:"[data-calendar-next-month]",type:"click"}),2,"onNextMonth"],[me({selector:"[data-calendar-today]",type:"click"}),2,"onTodayClick"],[me({selector:"[data-calendar-day]",type:"click"}),2,"onDayClick"],[me({selector:"[data-calendar-day]",type:"pointerenter"}),2,"onDayPointerEnter"],[me({selector:"[data-calendar-grid]",type:"pointerleave"}),2,"onGridPointerLeave"],[me({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=(gn(this),mn(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=(In(this),Rn(this,new Date().getMonth()));focusedIso=(Mn(this),Pn(this,""));weekdayLabels=(kn(this),En(this,[]));monthPanels=(Fn(this),An(this,[]));todayLabel=(Tn(this),Cn(this,""));rangeAnchor=(On(this),Vn(this,null));rangeHover=(Ln(this),jn(this,null));get resolvedLocale(){return Ae(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"?U(this.value)?.start??"":this.selectionMode==="multiple"?be(this.value)[0]??"":this.value,n=fe(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,Se(this.resolvedLocale)),this.monthPanels=Be(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:$e(n,this.resolvedLocale),weeks:Ye(e.year,e.month,this.monthOptions)}}),this.todayLabel=Ge(this.resolvedLocale)}moveMonth(e){let n=Ie(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=fe(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(Ve(be(this.value),e));n!==this.value&&(this.value=n,this.emitChange(n),this.refreshGrid())}selectRange(e){if(!this.isIsoAllowed(e))return;let n=je(U(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),gi(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:[B("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?B("button",{type:"button",class:"rui-calendar__nav","data-calendar-prev-month":!0,"aria-label":"Previous month",disabled:this.disabled,children:"\u2039"}):B("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"}),B("div",{class:"rui-calendar__month","aria-live":"polite",children:r.label}),i===e-1?B("button",{type:"button",class:"rui-calendar__nav","data-calendar-next-month":!0,"aria-label":"Next month",disabled:this.disabled,children:"\u203A"}):B("span",{class:"rui-calendar__nav-spacer","aria-hidden":"true"})]}),i===0?B("div",{class:"rui-calendar__weekdays",role:"row",children:this.weekdayLabels.map(a=>B("div",{class:"rui-calendar__weekday",role:"columnheader","aria-hidden":"true",children:a}))}):null,B("div",{class:"rui-calendar__grid",role:"grid","data-calendar-grid":!0,children:r.weeks.map(a=>B("div",{class:"rui-calendar__week",role:"row",children:a.map(s=>B("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()}))}))})]}))}),B("div",{class:"rui-calendar__footer",children:B("button",{type:"button",class:"rui-calendar__today","data-calendar-today":!0,disabled:this.disabled,children:this.todayLabel})})]})}static{an()}};import{jsx as mi}from"@ecopages/jsx/jsx-runtime";function nt(t){return mi("rui-calendar",{...t})}import{jsx as Te}from"@ecopages/jsx/jsx-runtime";import{customElement as Di,event as Si,onEvent as _e,onUpdated as pr,prop as we,registerSsrPreparationCallback as Ii,state as gr}from"@ecopages/radiant";import{FormAssociatedElement as mr}from"@ecopages/radiant/form-associated-element";var yi=/^[A-Za-z][A-Za-z0-9_-]*$/;function Wn(t){return yi.test(t)}function vi(t){let e=t.trim();if(Wn(e))return e;let n=`rui-${e}`;return e&&Wn(n)?n:"rui"}function Hn(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`${vi(t)}-${e}`}function Nn(t,e){let n=t.type,r=Pe(t),i=!e.useTextboxRole,a=i?"spinbutton":"textbox",s=!e.disabled&&!e.readOnly,o=Me(n,e.segments);return{ariaLabel:qe(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?De(t):void 0,className:$("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 Un,qn,Kn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,dr,hr;function bi(t,e,n,r,i,a){var s,o,f,g,v,R,D,j=Symbol.metadata||Symbol.for("Symbol.metadata"),Y=Object.defineProperty,A=Object.create,J=[A(null),A(null)],Z=e.length;function T(l,b,m){return function(u,c){b&&(c=u,u=t);for(var x=0;x<l.length;x++)c=l[x].apply(u,m?[c]:[]);return m?c:u}}function S(l,b,m,u){if(typeof l!="function"&&(u||l!==void 0))throw new TypeError(b+" must "+(m||"be")+" a function"+(u?"":" or undefined"));return l}function Q(l,b,m,u,c,x,M,y,_,w,te){function z(h){if(!te(h))throw new TypeError("Attempted to access private element on non-instance")}var G=[].concat(b[0]),ne=b[3],W=!M,k=c===1,re=c===3,ie=c===4,C=c===2;function O(h,P,se){return function(L,le){return P&&(le=L,L=l),se&&se(L),d[h].call(L,le)}}if(!W){var d={},H=[],I=re?"get":ie||k?"set":"value";if(_?(w||k?d={get:fr(function(){return ne(this)},u,"get"),set:function(h){b[4](this,h)}}:d[I]=ne,w||fr(d[I],u,C?"":I)):w||(d=Object.getOwnPropertyDescriptor(l,u)),!w&&!_){if((o=J[+y][u])&&(o^c)!==7)throw Error("Decorating two elements with the same name ("+d[I].name+") is not supported yet");J[+y][u]=c<3?1:c}}for(var p=l,V=G.length-1;V>=0;V-=m?2:1){var ae=S(G[V],"A decorator","be",!0),oe=m?G[V-1]:void 0,N={},E={kind:["field","accessor","method","getter","setter","class"][c],name:u,metadata:s,addInitializer:function(h,P){if(h.v)throw new TypeError("attempted to call addInitializer after decoration was finished");S(P,"An initializer","be",!0),x.push(P)}.bind(null,N)};if(W)o=ae.call(oe,p,E),N.v=1,S(o,"class decorators","return")&&(p=o);else if(E.static=y,E.private=_,o=E.access={has:_?te.bind():function(h){return u in h}},ie||(o.get=_?C?function(h){return z(h),d.value}:O("get",0,z):function(h){return h[u]}),C||re||(o.set=_?O("set",0,z):function(h,P){h[u]=P}),p=ae.call(oe,k?{get:d.get,set:d.set}:d[I],E),N.v=1,k){if(typeof p=="object"&&p)(o=S(p.get,"accessor.get"))&&(d.get=o),(o=S(p.set,"accessor.set"))&&(d.set=o),(o=S(p.init,"accessor.init"))&&H.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 S(p,(w?"field":"method")+" decorators","return")&&(w?H.unshift(p):d[I]=p)}return c<2&&M.push(T(H,y,1),T(x,y,0)),w||W||(_?k?M.splice(-1,0,O("get",y),O("set",y)):M.push(C?d[I]:S.call.bind(d[I])):Y(l,u,d)),p}function ee(l){return Y(l,j,{configurable:!0,enumerable:!0,value:s})}return a!==void 0&&(s=a[j]),s=A(s??null),v=[],R=function(l){l&&v.push(T(l))},D=function(l,b){for(var m=0;m<n.length;m++){var u=n[m],c=u[1],x=7&c;if((8&c)==l&&!x==b){var M=u[2],y=!!u[3],_=16&c;Q(l?t:t.prototype,u,_,y?"#"+M:xi(M),x,x<2?[]:l?g=g||[]:f=f||[],v,!!l,y,b,l&&y?function(w){return wi(w)===t}:i)}}},D(8,0),D(0,0),D(8,1),D(0,1),R(f),R(g),o=v,Z||ee(t),{e:o,get c(){var l=[];return Z&&[ee(t=Q(t,[e],r,t.name,5,l)),T(l,1)]}}}function xi(t){var e=_i(t,"string");return typeof e=="symbol"?e:e+""}function _i(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 fr(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 wi(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 Ri(){return typeof navigator>"u"?!1:/iPad|iPhone|iPod/.test(navigator.userAgent)}var vr,yr=class extends mr{static{({e:[Kn,Xn,Jn,Zn,Qn,er,tr,nr,rr,ir,ar,or,sr,lr,ur,cr,dr,hr,Un],c:[vr,qn]}=bi(this,[Di("rui-date-input")],[[we({type:String,reflect:!0,defaultValue:""}),0,"value"],[we({type:String,defaultValue:""}),0,"min"],[we({type:String,defaultValue:""}),0,"max"],[we({type:Boolean,attribute:"read-only",reflect:!0,defaultValue:!1}),0,"readOnly"],[we({type:String,defaultValue:""}),0,"label"],[we({type:String,defaultValue:""}),0,"locale"],[Si({name:"rui-change",bubbles:!0,composed:!0}),0,"changeEvent"],[gr,0,"segments"],[gr,0,"focusedPart"],[pr(["value","locale"]),2,"syncSegmentsFromValue"],[pr("label"),2,"syncGroupLabel"],[_e({selector:'[data-ref="root"]',type:"focusin"}),2,"onGroupFocusIn"],[_e({selector:"[data-date-segment]",type:"focusin"}),2,"onSegmentFocusIn"],[_e({selector:"[data-date-segment]",type:"focusout"}),2,"onSegmentFocusOut"],[_e({selector:"[data-date-segment]",type:"keydown"}),2,"onSegmentKeyDown"],[_e({selector:"[data-date-segment]",type:"beforeinput"}),2,"onSegmentBeforeInput"],[_e({selector:"[data-date-segment]",type:"pointerdown"}),2,"onSegmentPointerDown"]],0,void 0,mr))}value=(Un(this),Kn(this));min=(Xn(this),Jn(this));max=(Zn(this),Qn(this));readOnly=(er(this),tr(this));label=(nr(this),rr(this));locale=(ir(this),ar(this));changeEvent=(or(this),sr(this));segments=(lr(this),ur(this,[]));focusedPart=(cr(this),dr(this,null));uid=(hr(this),Hn("rui-date-input"));buffer="";useTextboxRole=Ri();pendingFocus=null;get resolvedLocale(){return Ae(this.locale)}get isoValue(){return this.value??""}syncSegmentsFromValue(){this.segments=Re(fe(this.isoValue),this.resolvedLocale),this.buffer=""}get displaySegments(){return this.segments.length>0?this.segments:Re(fe(this.isoValue),this.resolvedLocale)}constructor(){super(),Ii(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=We(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=Xe(this.segments,e,n,this.buffer);if(this.segments=r.segments,this.buffer=r.enteredKeys,r.focusNext){this.focusPart(xe(this.segments,e,1));return}this.commit("edit")}handleBackspace(e){this.setFocusedPart(e);let n=Ze(this.segments,e);if(n.kind==="focus-previous"){this.focusPart(xe(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=Ke(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(Je(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(xe(this.segments,n,-1));return}if(e.key==="ArrowRight"){e.preventDefault(),this.focusPart(xe(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 Te("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=Nn(e,{disabled:this.effectiveDisabled,locale:this.resolvedLocale,readOnly:this.readOnly,segments:this.displaySegments,useTextboxRole:this.useTextboxRole});return Te("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:De(e)},r)}render(){return Te("div",{class:"rui-date-input","data-ref":"root",role:"group",children:Te("div",{class:"rui-date-input__segments",children:this.displaySegments.map((e,n)=>this.renderSegment(e,n))})})}static{qn()}};import{jsx as Mi}from"@ecopages/jsx/jsx-runtime";function Ce(t){return Mi("rui-date-input",{"data-rui-control":!0,"data-rui-control-type":"date","data-rui-aria-target":'[data-ref="root"]',...t})}function br({children:t,class:e,...n}){return F("div",{...n,class:$("rui-date-range-picker",e),children:F("div",{class:"rui-date-range-picker__group","data-ref":"control",children:t})})}function xr({children:t,class:e,...n}){return F("div",{...n,class:$("rui-date-range-picker__values",e),"data-ref":"values",children:t})}function _r({class:t,...e}){return F(Ce,{...e,"data-range-start":!0,class:$("rui-date-range-picker__input",t)})}function wr({class:t,...e}){return F(Ce,{...e,"data-range-end":!0,class:$("rui-date-range-picker__input",t)})}function Dr({children:t="\u2013",class:e,...n}){return F("span",{...n,class:$("rui-date-range-picker__separator",e),"aria-hidden":"true",children:t})}function Sr({children:t,class:e,aria:n,...r}){return F("button",{...r,aria:nn(n,"Open calendar"),type:"button","data-ref":"trigger","data-range-trigger":!0,class:$("rui-control-toggle",e),"aria-haspopup":"dialog",children:t??F(et,{})})}function Ir({children:t,class:e,...n}){return F("div",{...n,"data-ref":"popover","data-range-popover":!0,class:$("rui-date-range-picker__popover rui-popover rui-floating",e),hidden:!0,role:"dialog",children:t})}function Rr(t){return F(nt,{...t,"data-range-calendar":!0})}function ki(t){let{children:e,startLabel:n="Start date",endLabel:r="End date",value:i,min:a,max:s,disabled:o,readOnly:f,locale:g,startName:v,endName:R}=t,D=U(i??"");return F("rui-date-range-picker",{"data-rui-aria-targets":'[data-range-start] [data-ref="root"],[data-range-end] [data-ref="root"]',...t,children:e??rt(Pi,{children:[rt(br,{children:[rt(xr,{children:[F(_r,{"aria-label":n,value:D?.start,min:a,max:s,disabled:o,readOnly:f,locale:g,name:v}),F(Dr,{}),F(wr,{"aria-label":r,value:D?.end,min:a,max:s,disabled:o,readOnly:f,locale:g,name:R})]}),F(Sr,{})]}),F(Ir,{children:F(Rr,{})})]})})}export{ki as RuiDateRangePicker,Rr as RuiDateRangePickerCalendar,br as RuiDateRangePickerControl,tn as RuiDateRangePickerElement,wr as RuiDateRangePickerEndInput,xr as RuiDateRangePickerInputs,Ir as RuiDateRangePickerPopover,Dr as RuiDateRangePickerSeparator,_r as RuiDateRangePickerStartInput,Sr as RuiDateRangePickerToggle};
2
2
  //# sourceMappingURL=index.js.map