@featherk/composables 0.12.2 → 0.12.3

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
- (function(j,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/integrations/useFocusTrap")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/integrations/useFocusTrap"],t):(j=typeof globalThis<"u"?globalThis:j||self,t(j.FeatherKComposables={},j.Vue,j.useFocusTrap))})(this,(function(j,t,Fe){"use strict";const Ve=(e,n)=>{const a=t.ref(null);let h=!1,c=null,p=null;const k=[],x=".k-table-row[data-grid-row-index] [tabindex]",F=()=>{const u=e?.value?.$el;return u?u.closest(".k-grid"):null},O=u=>{const A=F();if(!A)return!1;const v=u.closest(".k-grid-aria-root");if(v)return A.contains(v);const w=u.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return w?A.contains(w):!1},E=u=>u.key==="Enter"||u.code==="Enter"||u.code==="NumpadEnter",V=()=>e?.value?.columns,I=u=>{const A=u.key||u.code;([" ","Spacebar","Space"].includes(A)||E(u))&&(u.preventDefault(),u.stopPropagation(),a.value=u.target,u.target.click())},D=u=>{if(!a.value)return;if(u.code==="Escape"){u.stopPropagation(),a.value&&a.value.focus();return}const A=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),v=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(v){if(u.code==="Tab"){const w=[".k-dropdownlist[tabindex='0']","input.k-input-inner:not([tabindex='-1']):not([disabled])","button:not([tabindex='-1']):not([disabled])",".k-checkbox"],C=n?.focusableMenuSelectors??w,i=Array.from(v.querySelectorAll(C.join(",")));if(i.length===0)return;const m=i.findIndex(U=>U===document.activeElement);let L;m===-1?L=0:u.shiftKey?L=(m-1+i.length)%i.length:L=(m+1)%i.length,u.preventDefault(),u.stopPropagation(),i[L]?.focus()}}else if(u.code==="ArrowUp"||u.code==="ArrowDown"){u.preventDefault(),u.stopPropagation();const w=A.findIndex(i=>i===document.activeElement);let C=w;u.code==="ArrowUp"?C=w>0?w-1:A.length-1:u.code==="ArrowDown"&&(C=w<A.length-1?w+1:0),A[C]?.focus();return}if(u.code==="Tab"){u.preventDefault(),u.stopPropagation();const w=a.value?.parentElement;(u.shiftKey?w?.previousElementSibling:w?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},M=()=>{c=new MutationObserver(u=>{u.forEach(A=>{A.addedNodes.forEach(v=>{if(v.nodeType===Node.ELEMENT_NODE){const w=v;if(w.classList.contains("k-animation-container")){const i=a.value;i&&(i.dataset.featherKSortable==="true"||t.nextTick(()=>{w.querySelectorAll(".k-columnmenu-item-wrapper").forEach(U=>{U.textContent?.toLowerCase().includes("sort")&&U.remove()})})),w.addEventListener("keydown",D),t.nextTick(()=>{const m=()=>{const L=Array.from(w.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(L.length===1)L[0].focus(),L[0].click(),m.attempts=0;else if(L.length>1){m.attempts=0;return}else m.attempts===void 0&&(m.attempts=0),m.attempts++<3&&setTimeout(m,200)};m()})}w.querySelectorAll(".k-animation-container").forEach(i=>{i.addEventListener("keydown",D)})}}),A.removedNodes.forEach(v=>{if(v.nodeType===Node.ELEMENT_NODE){const w=v;w.classList.contains("k-animation-container")&&w.removeEventListener("keydown",D),w.querySelectorAll(".k-animation-container").forEach(i=>{i.removeEventListener("keydown",D)})}})})}),c.observe(document.body,{childList:!0,subtree:!0})},d=u=>{const A=u.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(A)||u.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},s=u=>{if(!u.type||!u)return;const A=u.target;if(!A)return;const v=A.closest(".k-table-row[data-grid-row-index]");if(!O(A))return;const w=["ArrowLeft","ArrowRight"].includes(u.code);if(!(d(A)&&!(v&&w))){if(u.code==="Escape"){const C=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(C){u.preventDefault(),u.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(m=>m.setAttribute("tabindex","-1"))}catch{}C.setAttribute("tabindex","0"),C.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(u.code)){if(A.classList.contains("k-grid-header-menu")&&A.classList.contains("k-grid-column-menu")){a.value=A;return}if(v){if(["ArrowDown","ArrowUp"].includes(u.code)){u.preventDefault(),u.stopPropagation();const C=(m,L)=>{let U=L==="next"?m.nextElementSibling:m.previousElementSibling;for(;U;){const te=U;try{if(te.classList.contains("k-table-row"))return te}catch{}U=L==="next"?U.nextElementSibling:U.previousElementSibling}return null},i=u.code==="ArrowDown"?C(v,"next"):C(v,"previous");i&&(v.setAttribute("tabindex","-1"),i.setAttribute("tabindex","0"),i.focus());return}if(["ArrowLeft","ArrowRight"].includes(u.code)){u.preventDefault(),u.stopPropagation();const C=v.querySelectorAll(x);if(C.length===0)return;let i=Array.from(C).findIndex(m=>m===document.activeElement);if(i===-1&&document.activeElement===v){C[0].focus();return}u.code==="ArrowRight"?i=i===C.length-1?0:i+1:u.code==="ArrowLeft"&&(i=i===0?C.length-1:i-1),C[i].focus();return}}}}},g=()=>{t.nextTick(()=>{const u=e.value?.$el;if(!u||typeof u.closest!="function")return;const A=u.closest(".k-grid");A&&A.classList.add("fk-grid")})},S=()=>{if(!p)try{const u=()=>{try{const w=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!w||w.length===0||w.filter(m=>m.getAttribute("tabindex")==="0").length===1)return;const i=w.find(m=>m===document.activeElement||m.contains(document.activeElement));if(w.forEach(m=>m.setAttribute("tabindex","-1")),i){i.setAttribute("tabindex","0");return}w[0].setAttribute("tabindex","0")}catch(w){console.error("ensureSingleTabindex error:",w)}},A=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));A.length>0&&A.forEach((w,C)=>{w.setAttribute("tabindex",C===0?"0":"-1")});const v=e.value.$el.querySelector(".k-table-tbody");v&&(p=new MutationObserver(()=>{u()}),p.observe(v,{childList:!0,subtree:!0}))}catch(u){console.error("Error setting up row navigation:",u)}},R=()=>{t.nextTick(()=>{const A=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");A&&A.forEach(v=>{v.setAttribute("role","button"),v.addEventListener("keydown",I)}),M(),q()})},K=()=>{const A=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");A&&A.forEach(v=>{v.removeEventListener("keydown",I)}),c&&(c.disconnect(),c=null),p&&(p.disconnect(),p=null),k.forEach(v=>v()),k.length=0},q=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((v,w)=>{if(v.dataset.featherKHeaderBound==="true")return;const C=v.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!C)return;const i=V();if(i&&i[w]){const o=i[w].field??"";v.setAttribute("data-feather-k-field",o),v.setAttribute("data-feather-k-filterable",i[w].filterable===!1?"false":"true"),v.setAttribute("data-feather-k-sortable",i[w].sortable===!1?"false":"true")}const m=v.dataset.featherKFilterable!=="false",L=v.dataset.featherKSortable!=="false";C.setAttribute("tabindex","-1"),m||L?v.style.cursor="pointer":v.style.cursor="default",m?(v.setAttribute("tabindex","0"),v.setAttribute("role","button"),v.setAttribute("aria-haspopup","menu")):(v.setAttribute("tabindex","0"),v.setAttribute("role","columnheader"),v.removeAttribute("aria-haspopup"));const U=o=>{o.target?.closest(".k-column-resizer")||(a.value=v,C.click())},te=o=>{if(m)a.value=v,o.preventDefault(),o.stopPropagation(),U(o);else if(L){a.value=v;const b=v.querySelector(".k-link");b&&b.click()}};v.addEventListener("click",te),k.push(()=>{v.removeEventListener("click",te)});const ee=o=>{if((E(o)||o.code==="Space")&&(m||L)){if(o.preventDefault(),o.stopPropagation(),a.value=v,a.value.focus(),m)U(o);else if(L){const b=v.querySelector(".k-link");b&&b.click()}}};v.addEventListener("keydown",ee,!0),k.push(()=>{v.removeEventListener("keydown",ee,!0)}),v.dataset.featherKHeaderBound="true"});const A=document.querySelector(".k-grid-header .k-table-thead");if(A&&A.dataset.featherKHeaderBound!=="true"){const v=w=>{const C=w.target.closest("th");C&&(E(w)||w.code==="Space")&&C.dataset.featherKFilterable==="false"&&C.dataset.featherKSortable==="false"&&(w.preventDefault(),w.stopImmediatePropagation())};A.addEventListener("keydown",v,!0),k.push(()=>{A.removeEventListener("keydown",v,!0)}),A.dataset.featherKHeaderBound="true"}},z=function(u,A){const v=u?.event?.event.target,w=V();if(!v||!w)return;const C=v.classList.contains("k-grid-header-menu"),i=v.classList.contains("k-columnmenu-item"),m=w.find(L=>L.field===u?.event?.field)?.sortable&&!0;if(!C){if(i&&!m){u?.event?.sort?.filter(U=>U.field!==u?.event?.field);return}typeof A=="function"&&t.nextTick(()=>{a.value&&a.value.focus(),A(u),t.nextTick(()=>{q()})})}},J=()=>{if(!h)try{g(),S(),R(),h=!0}catch(u){console.error("initA11y failed:",u),K()}};return t.onBeforeUnmount(()=>{K()}),{activeFilterButton:a,handleGridKeyDown:s,handleSortChange:z,initA11y:J}},$e=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Pe=e=>!!e&&typeof e=="object"&&"field"in e,De=(e,n)=>!e||typeof e!="object"?!1:$e(e)?e.filters.some(a=>De(a,n)):Pe(e)?e.field===n:!1,Le=e=>n=>e.value?.filters&&e.value.filters.some(a=>De(a,n))?"active":"",Oe=["button","a","input","select","textarea",'[role="button"]','[role="checkbox"]','[role="link"]','[role="menuitem"]','[role="option"]',".k-checkbox",".k-button",".k-dropdown",".k-picker",".k-hierarchy-cell",".k-grid-header-menu",".k-column-menu"],Ne=e=>{const{onRowAction:n,gridRef:a,dataItems:h,ignoreSelectors:c=[],shouldIgnoreTarget:p,enableKeyboardAction:k=!0}=e,x=[...Oe,...c],F=(d,s)=>{if(!d)return!1;const g=x.join(",");return d.closest&&d.closest(g)?!0:p&&s?p(d,s):!1},O=d=>{const g=d?.closest?.(".k-table-row[data-grid-row-index]")?.getAttribute("data-grid-row-index");if(g==null)return;const S=parseInt(g,10);return Number.isNaN(S)?void 0:S},E=d=>{if(!d||typeof d.clientX!="number")return;const s=typeof window<"u"&&window.scrollX||0,g=typeof window<"u"&&window.scrollY||0,S=typeof window<"u"&&window.screenX||0,R=typeof window<"u"&&window.screenY||0;return{clientX:d.clientX,clientY:d.clientY,pageX:typeof d.pageX=="number"?d.pageX:d.clientX+s,pageY:typeof d.pageY=="number"?d.pageY:d.clientY+g,screenX:typeof d.screenX=="number"?d.screenX:d.clientX+S,screenY:typeof d.screenY=="number"?d.screenY:d.clientY+R}},V=d=>{if(!d||typeof d.getBoundingClientRect!="function")return;const s=d.getBoundingClientRect();if(!s)return;const g=s.left,S=s.bottom,R=typeof window<"u"&&window.scrollX||0,K=typeof window<"u"&&window.scrollY||0;return{clientX:g,clientY:S,pageX:g+R,pageY:S+K,screenX:g,screenY:S}},I=d=>{if(typeof window>"u")return!1;const s=window.getSelection();if(!s||s.isCollapsed||!s.toString().trim())return!1;if(d&&s.anchorNode&&s.focusNode){const g=d.closest(".k-table-row")||d.closest(".k-grid")||d,S=s.anchorNode.nodeType===Node.ELEMENT_NODE?s.anchorNode:s.anchorNode.parentElement,R=s.focusNode.nodeType===Node.ELEMENT_NODE?s.focusNode:s.focusNode.parentElement,K=!!(S&&g.contains(S)),q=!!(R&&g.contains(R));return K||q}return!0};return{handleRowClick:d=>{const s=d?.htmlEvent||d?.event||d?.nativeEvent||(d instanceof Event?d:void 0);if(s&&s.button!==void 0&&s.button!==0)return;const g=s?.target||d?.target;if(g&&F(g,s||d)||I(g))return;const S={dataItem:d.dataItem,rowIndex:d.rowIndex??O(g),field:d.field,event:s||d,triggerType:"click",ctrlKey:!!s?.ctrlKey,shiftKey:!!s?.shiftKey,metaKey:!!s?.metaKey,altKey:!!s?.altKey,coordinates:E(s)??V(g)};n(d.dataItem,S)},handleRowKeyDown:(d,s)=>{if(!k)return;const g=d.key||d.code;if(!(g==="Enter"||g==="NumpadEnter"||g===" "||g==="Space"||d.code==="Enter"||d.code==="NumpadEnter"||d.code==="Space"))return;const R=d.target;if(!R)return;const K=R.closest(".k-table-row[data-grid-row-index], .k-table-row");if(!K||F(R,d))return;d.preventDefault(),d.stopPropagation();const q=K.getAttribute("data-grid-row-index"),z=q!==null?parseInt(q,10):void 0;let J=s;if(J===void 0){const A=(Array.isArray(h)?h:h?.value)||a?.value?.props?.dataItems||a?.value?.dataItems;A&&z!==void 0&&z>=0&&z<A.length&&(J=A[z])}if(J===void 0)return;const u={dataItem:J,rowIndex:z,event:d,triggerType:"keyboard",ctrlKey:!!d.ctrlKey,shiftKey:!!d.shiftKey,metaKey:!!d.metaKey,altKey:!!d.altKey,coordinates:V(K)};n(J,u)},isIgnoredTarget:F}},Ke="Enter a valid ZIP code with exactly 5 or 9 digits.",Ee=e=>{const n=e.replace(/\D/g,"").slice(0,9);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n},qe=(e,n)=>e.slice(0,Math.max(0,n)).replace(/\D/g,"").length,Ue=e=>e<=5?e:Math.min(e+1,10),xe=e=>{const n=t.ref(Ee(e.initialValue??"")),a=t.ref(!1),h=t.ref(e.errorMessage?.trim()||Ke),c=t.computed(()=>n.value.replace(/\D/g,"")),p=t.computed(()=>{const D=c.value.length;return D===5||D===9}),k=t.computed(()=>a.value&&!p.value),x=t.computed(()=>!a.value||p.value),F=t.computed(()=>a.value),O=(D,M)=>{const d=Ue(M);t.nextTick(()=>{D.isConnected&&D.setSelectionRange(d,d)})};return{zipDisplay:n,submitted:a,errorMessage:h,wrapperClass:"fk-zip-textbox",zipRaw:c,isZipValid:p,showZipError:k,textBoxValid:x,textBoxValidate:F,handleZipInput:(...D)=>{const M=D[0],s=M?.event?.target,g=M?.value,S=Array.isArray(g)?g.join(""):String(g??""),R=s?.selectionStart!==void 0&&s.selectionStart!==null?qe(s.value,s.selectionStart):S.replace(/\D/g,"").length;n.value=Ee(S),s&&O(s,R)},submitAndValidate:D=>{a.value=!0;const M=p.value;return!M&&D?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),M},buildPayload:()=>({zip:c.value})}};function Ie(e,n){const a=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function h(p){const k=e.value??p.currentTarget,x=p.relatedTarget;(!k||!k.contains(x))&&(a.value=!0)}function c(){a.value=!1}return{touched:a,onFocusout:h,reset:c}}function Te(e,n){const a=t.ref(!1),h=t.ref(!1),c=t.computed(()=>t.toValue(n.submitted)||a.value),p=t.computed(()=>!c.value||n.isValid()),k=Ie(e,{isValid:()=>p.value});function x(I){return t.computed(()=>!c.value||t.toValue(I))}function F(I){return Object.fromEntries(Object.entries(I).map(([D,M])=>[D,x(M)]))}function O(I){const D=t.toValue(I);if(!D)return;D.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function E(I){if(h.value){h.value=!1;return}k.onFocusout(I),k.touched.value&&(a.value=!0)}function V(){a.value=!1,h.value=!0,k.reset()}return{touched:a,fieldsetValidate:c,onFocusout:E,reset:V,createFieldValidity:x,createFieldValidationsMap:F,focusFirstInvalidField:O}}const Be=[{label:"Alabama",value:"AL"},{label:"Alaska",value:"AK"},{label:"Arizona",value:"AZ"},{label:"Arkansas",value:"AR"},{label:"California",value:"CA"},{label:"Colorado",value:"CO"},{label:"Connecticut",value:"CT"},{label:"Delaware",value:"DE"},{label:"Florida",value:"FL"},{label:"Georgia",value:"GA"},{label:"Hawaii",value:"HI"},{label:"Idaho",value:"ID"},{label:"Illinois",value:"IL"},{label:"Indiana",value:"IN"},{label:"Iowa",value:"IA"},{label:"Kansas",value:"KS"},{label:"Kentucky",value:"KY"},{label:"Louisiana",value:"LA"},{label:"Maine",value:"ME"},{label:"Maryland",value:"MD"},{label:"Massachusetts",value:"MA"},{label:"Michigan",value:"MI"},{label:"Minnesota",value:"MN"},{label:"Mississippi",value:"MS"},{label:"Missouri",value:"MO"},{label:"Montana",value:"MT"},{label:"Nebraska",value:"NE"},{label:"Nevada",value:"NV"},{label:"New Hampshire",value:"NH"},{label:"New Jersey",value:"NJ"},{label:"New Mexico",value:"NM"},{label:"New York",value:"NY"},{label:"North Carolina",value:"NC"},{label:"North Dakota",value:"ND"},{label:"Ohio",value:"OH"},{label:"Oklahoma",value:"OK"},{label:"Oregon",value:"OR"},{label:"Pennsylvania",value:"PA"},{label:"Rhode Island",value:"RI"},{label:"South Carolina",value:"SC"},{label:"South Dakota",value:"SD"},{label:"Tennessee",value:"TN"},{label:"Texas",value:"TX"},{label:"Utah",value:"UT"},{label:"Vermont",value:"VT"},{label:"Virginia",value:"VA"},{label:"Washington",value:"WA"},{label:"West Virginia",value:"WV"},{label:"Wisconsin",value:"WI"},{label:"Wyoming",value:"WY"}];function ve(e){if(e&&typeof e=="object"&&"value"in e){const n=e.value;return typeof n=="string"?n:String(n??"")}return""}function Ye(){const e=t.reactive({address1:"",address2:"",city:"",state:null,zip:""});return{formData:e,onAddress1Input:(...k)=>{e.address1=ve(k[0])},onAddress2Input:(...k)=>{e.address2=ve(k[0])},onCityInput:(...k)=>{e.city=ve(k[0])},onStateChange:k=>{e.state=k.value},resetFormData:()=>{e.address1="",e.address2="",e.city="",e.state=null,e.zip=""}}}function ze(e,n="zip"){const a=xe({id:n}),{zipDisplay:h,zipRaw:c,isZipValid:p,wrapperClass:k,handleZipInput:x}=a;return t.watch(c,O=>{e.zip=O}),{zipDisplay:h,isZipValid:p,zipWrapperClass:k,onZipInput:x,resetZip:()=>{h.value="",e.zip=""}}}function He(e){const n=t.computed(()=>e.formData.address1.trim()!==""),a=t.computed(()=>e.formData.city.trim()!==""),h=t.computed(()=>!!e.formData.state),c=t.computed(()=>t.toValue(e.isZipValid)),p=t.computed(()=>n.value&&a.value&&h.value&&c.value);return{strictAddress1Valid:n,strictCityValid:a,strictStateValid:h,strictZipValid:c,strictAddressValid:p}}function Xe(e){if(!e)return;e.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function Ze(e,n){const a=e??n.currentTarget,h=n.relatedTarget;return!a||!a.contains(h)}function We(e){const n=t.ref(t.toValue(e.fieldsetRef));t.watchEffect(()=>{n.value=t.toValue(e.fieldsetRef)});const a=t.ref(!1),h=t.ref(!1),c=t.computed(()=>t.toValue(e.required)??!0),{formData:p,onAddress1Input:k,onAddress2Input:x,onCityInput:F,onStateChange:O,resetFormData:E}=Ye(),V=`${e.addressId}-zip`,{zipDisplay:I,isZipValid:D,zipWrapperClass:M,onZipInput:d,resetZip:s}=ze(p,V),{strictAddress1Valid:g,strictCityValid:S,strictStateValid:R,strictZipValid:K,strictAddressValid:q}=He({formData:p,isZipValid:D}),z=Te(n,{submitted:a,isValid:()=>q.value}),{touched:J,fieldsetValidate:u,onFocusout:A,reset:v}=z,w=z.createFieldValidationsMap({address1:g,city:S,state:R,zip:K,address:q}),{address1:C,city:i,state:m,zip:L,address:U}=w,te=t.computed(()=>c.value?u.value:!1),ee=t.computed(()=>c.value?C.value:!0),o=t.computed(()=>c.value?i.value:!0),b=t.computed(()=>c.value?m.value:!0),P=t.computed(()=>c.value?L.value:!0),H=t.computed(()=>c.value?U.value:!0),X={value:null,label:"State"},W=Be.map(({label:y,value:T})=>({label:y,value:T})),r=t.computed(()=>({address1:p.address1.trim(),address2:p.address2.trim(),city:p.city.trim(),state:(p.state??"").trim().toUpperCase(),zip:p.zip.replace(/\D/g,"")})),f=t.computed(()=>p.address1.trim()===""&&p.address2.trim()===""&&p.city.trim()===""&&(p.state??"").trim()===""&&p.zip.replace(/\D/g,"")===""),$=t.computed(()=>!f.value),B=t.computed(()=>!c.value&&$.value&&(!g.value||!S.value||!R.value)),G=t.computed(()=>{const y=p.zip.replace(/\D/g,"");return!c.value&&$.value&&y.length!==5&&y.length!==9}),Q=t.computed(()=>!c.value&&$.value&&!q.value),Y=t.computed(()=>!c.value&&Q.value&&(h.value||a.value));return t.watch(r,()=>{c.value||(h.value=!1)}),t.watch(c,y=>{y||(a.value=!1,h.value=!1,v())}),{formData:p,submitted:a,touched:J,addressValidate:te,address1Valid:ee,cityValid:o,stateValid:b,zipValid:P,addressValid:H,optionalFeedbackActive:Y,optionalPartialInvalid:Q,optionalMissingRequiredFields:B,optionalZipInvalid:G,stateDefaultItem:X,stateOptions:W,zipDisplay:I,zipWrapperClass:M,onAddress1Input:k,onAddress2Input:x,onCityInput:F,onStateChange:O,onZipInput:d,onFieldsetFocusout:y=>{const T=Ze(n.value,y);A(y),!c.value&&T&&(h.value=!0)},normalizedPayload:r,validateForSubmit:async()=>c.value?(a.value=!0,q.value?{isValid:!0,payload:r.value}:(await t.nextTick(),Xe(n.value),{isValid:!1,payload:null})):f.value||q.value?(a.value=!1,{isValid:!0,payload:r.value}):(a.value=!0,{isValid:!1,payload:null}),reset:()=>{a.value=!1,h.value=!1,v(),E(),s()}}}const Ge=(e="fkid")=>{const n=`${e}-${t.useId()}`;return{instanceId:n,compose:(...h)=>[n,...h].filter(c=>c!=null).map(String).join("-")}},je=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const _e=Object.prototype.toString,Je=e=>_e.call(e)==="[object Object]",ge=()=>{};function be(e){return Array.isArray(e)?e:[e]}function Qe(e,n,a){return t.watch(e,n,{...a,immediate:!0})}const Me=je?window:void 0;function pe(e){var n;const a=t.toValue(e);return(n=a?.$el)!==null&&n!==void 0?n:a}function we(...e){const n=(h,c,p,k)=>(h.addEventListener(c,p,k),()=>h.removeEventListener(c,p,k)),a=t.computed(()=>{const h=be(t.toValue(e[0])).filter(c=>c!=null);return h.every(c=>typeof c!="string")?h:void 0});return Qe(()=>{var h,c;return[(h=(c=a.value)===null||c===void 0?void 0:c.map(p=>pe(p)))!==null&&h!==void 0?h:[Me].filter(p=>p!=null),be(t.toValue(a.value?e[1]:e[0])),be(t.unref(a.value?e[2]:e[1])),t.toValue(a.value?e[3]:e[2])]},([h,c,p,k],x,F)=>{if(!h?.length||!c?.length||!p?.length)return;const O=Je(k)?{...k}:k,E=h.flatMap(V=>c.flatMap(I=>p.map(D=>n(V,I,D,O))));F(()=>{E.forEach(V=>V())})},{flush:"post"})}function Ce(e,n,a={}){const{window:h=Me,ignore:c=[],capture:p=!0,detectIframe:k=!1,controls:x=!1}=a;if(!h)return x?{stop:ge,cancel:ge,trigger:ge}:ge;let F=!0;const O=s=>t.toValue(c).some(g=>{if(typeof g=="string")return Array.from(h.document.querySelectorAll(g)).some(S=>S===s.target||s.composedPath().includes(S));{const S=pe(g);return S&&(s.target===S||s.composedPath().includes(S))}});function E(s){const g=t.toValue(s);return g&&g.$.subTree.shapeFlag===16}function V(s,g){const S=t.toValue(s),R=S.$.subTree&&S.$.subTree.children;return R==null||!Array.isArray(R)?!1:R.some(K=>K.el===g.target||g.composedPath().includes(K.el))}const I=s=>{const g=pe(e);if(s.target!=null&&!(!(g instanceof Element)&&E(e)&&V(e,s))&&!(!g||g===s.target||s.composedPath().includes(g))){if("detail"in s&&s.detail===0&&(F=!O(s)),!F){F=!0;return}n(s)}};let D=!1;const M=[we(h,"click",s=>{D||(D=!0,setTimeout(()=>{D=!1},0),I(s))},{passive:!0,capture:p}),we(h,"pointerdown",s=>{const g=pe(e);F=!O(s)&&!!(g&&!s.composedPath().includes(g))},{passive:!0}),k&&we(h,"blur",s=>{setTimeout(()=>{const g=pe(e);let S=h.document.activeElement;for(;S?.shadowRoot;)S=S.shadowRoot.activeElement;S?.tagName==="IFRAME"&&!g?.contains(h.document.activeElement)&&n(s)},0)},{passive:!0})].filter(Boolean),d=()=>M.forEach(s=>s());return x?{stop:d,cancel:()=>{F=!1},trigger:s=>{F=!0,I(s),F=!1}}:d}const Re=e=>{let n=null;const a=()=>{n?.disconnect(),n=null};return typeof window<"u"&&typeof window.IntersectionObserver=="function"&&t.watch([e.target,()=>e.root()],([c,p])=>{a(),c&&(n=new IntersectionObserver(([k])=>{k&&e.onChange(k)},{root:p,threshold:e.threshold??1}),n.observe(c))},{immediate:!0}),t.onUnmounted(a),{disconnect:a}},et=".k-table-row",ye=e=>{if(e instanceof HTMLElement)return e;const n=e?.$el;return n instanceof HTMLElement?n:null},tt=(e,n)=>n==="row"?e.matches("tr.k-table-row"):!e.matches("tr.k-table-row"),nt=(e,n)=>{console.warn(`usePopupMenu: triggerMode "${n}" does not match resolved element <${e.tagName.toLowerCase()}${e.className?`.${e.className.split(" ").join(".")}`:""}>; ARIA management skipped.`)},rt=e=>{let n=e.parentElement;for(;n;){const{overflow:a,overflowX:h,overflowY:c}=window.getComputedStyle(n);if([a,h,c].some(p=>/auto|scroll|overlay/.test(p)))return n;n=n.parentElement}return null},at=e=>{const n=t.ref(null),a=e.menuItemSelector??".k-menu-item:not(.k-disabled)",h=e.triggerMode,c=e.anchor===!0?{}:e.anchor,p=t.shallowRef(null),k=()=>ye(e.triggerRef.value),x=t.computed(()=>k()),F=t.computed(()=>c&&c.hideWhenAnchorClipped!==!1?x.value:null),O=t.computed(()=>{const i=p.value;return!e.isOpen.value||!i?{left:0,top:0}:{left:i.left+window.scrollX,top:i.bottom+window.scrollY}}),E=()=>e.resolveFocusTarget?.()??ye(e.focusTargetRef?.value),V=()=>{if(h!=="button")return null;if(e.escapeFocusTarget)return e.escapeFocusTarget();const i=e.escapeFocusContainerSelector??et;return(k()??document.activeElement)?.closest(i)??null},I=()=>{const i=E()??V();if(i)return i.focus(),!0;const m=k();return m?.focus(),!!m},D=()=>{ye(e.menuRef.value)?.querySelector(a)?.focus({preventScroll:!0})},M=t.shallowRef(null),d=t.shallowRef(null);let s=!1;const g=()=>{const i=n.value;if(i==="keyboard"||i==="escape"){const m=M.value??d.value;m?.focus(),i==="keyboard"&&m&&m===d.value&&(s=!0)}else n.value==="mouse-selection"&&d.value?.focus();n.value=null,M.value=null,d.value=null},S=i=>{e.isOpen.value&&(n.value=i,M.value=E()??(i==="escape"?V():null),d.value=k(),z(!1),e.requestHide(),t.nextTick(g))};t.watch(x,(i,m,L)=>{if(!c||!i){p.value=null;return}let U=null;const te=()=>{U=null,p.value=c.getRect?.()??i.getBoundingClientRect()},ee=()=>{U===null&&(U=window.requestAnimationFrame(te))},o=typeof window.ResizeObserver=="function"?new window.ResizeObserver(ee):null;o?.observe(i),window.addEventListener("scroll",ee,{capture:!0,passive:!0}),window.addEventListener("resize",ee,{passive:!0}),ee(),L(()=>{U!==null&&window.cancelAnimationFrame(U),o?.disconnect(),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee)})},{immediate:!0,flush:"post"}),Re({target:F,root:()=>c?.clipRoot?t.toValue(c.clipRoot):x.value?rt(x.value):null,threshold:1,onChange:i=>{i.isIntersecting||S("anchor-hidden")}}),Ce(e.menuRef,()=>S("outside-click"),{ignore:[x]});let R=null,K=null;const q=()=>{R?.isConnected&&R.setAttribute("aria-expanded","false"),R=null},z=i=>{if(e.manageMenuTriggerAria===!1)return;const m=x.value;if(!m){R?.isConnected&&R.setAttribute("aria-expanded",i?"true":"false");return}if(!tt(m,h)){nt(m,h),q();return}R&&R!==m&&q(),m.setAttribute("aria-expanded",i?"true":"false"),R=m},J=()=>{const i=ye(e.menuRef.value),m=i?.matches('[role="menubar"]')?i:i?.querySelector('[role="menubar"]'),L=t.toValue(e.menuLabel)?.trim();K&&K!==m&&K.removeAttribute("aria-label"),m&&(L?m.setAttribute("aria-label",L):m.removeAttribute("aria-label")),K=m??null};t.watch([e.isOpen,e.triggerRef],([i])=>z(i),{immediate:!0,flush:"post"}),t.watch([e.isOpen,e.menuRef,()=>t.toValue(e.menuLabel)],J,{immediate:!0,flush:"post"}),t.onUnmounted(()=>{q(),K?.removeAttribute("aria-label")}),t.watch(e.isOpen,i=>{i&&D()},{flush:"post"});const u=(...i)=>{const m=i[0];if(s){s=!1;return}if(e.isOpen.value){S("trigger-click");return}e.requestShow(m)};return{handleMenuSelect:(i,m)=>{m?.(i),S(i.event?.type?.startsWith("key")?"keyboard":"mouse-selection")},handleActionButtonClick:u,handleActionButtonKeydown:(...i)=>{const m=i[0],L=i[1];if(m.key==="Enter"||m.code==="Space"){m.preventDefault(),u(L);return}if(m.key==="Escape"){if(m.preventDefault(),m.stopPropagation(),e.isOpen.value){S("escape");return}I()}},handleActionMenuEscape:i=>{i.preventDefault(),i.stopPropagation(),S("escape")},handlePopupClose:()=>{t.nextTick(g)},offset:O}},ot=()=>{const e=new Set;return{register:c=>{e.add(c),t.onUnmounted(()=>e.delete(c))},deactivateOthers:c=>{e.forEach(p=>{p!==c&&p.deactivate()})},deactivateAll:()=>{e.forEach(c=>c.deactivate())}}},lt=e=>{if(e instanceof HTMLElement)return e;const n=e&&"$el"in e?e.$el:null;return n instanceof HTMLElement?n:null},it=()=>{const e=t.shallowReactive(new Map),n=t.ref(null),a=(x,F)=>{const O=lt(F);O?e.set(x,O):e.delete(x)},h=x=>e.get(x)??null,c=x=>{n.value=x},p=()=>{n.value=null},k=x=>n.value===x;return{activeId:t.readonly(n),isActive:t.computed(()=>n.value!==null),activeElement:t.computed(()=>n.value!==null?h(n.value):null),register:a,resolve:h,activate:c,deactivate:p,isIdActive:k}};function st(e){const n=t.ref(""),a=t.ref(void 0),h=t.ref(!!e.debug),c=t.ref(e.dateFormat??"mm/dd/yyyy"),p=t.computed(()=>!!e.required),k=1e3,x=t.ref(!1),F=["ArrowUp","ArrowDown"],O=["ArrowLeft","ArrowRight"],E=t.computed(()=>(n.value??"").replace(/\D/g,"")),V=o=>o<=2?"mm":o<=5?"dd":E.value.length<=10?"yyyy":"mm",I=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),D=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),M=t.computed(()=>{const o=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(4,"0")}),d=o=>{if(E.value.length===0){e.onChange({value:null,event:o});return}if(E.value.length<8){e.onChange({value:null,event:o});return}if((n.value??"").length===10&&E.value.length===8){const[b,P,H]=n.value.split("/"),X=parseInt(b),W=parseInt(P),r=parseInt(H);if(q(r,X,W)){const f=R(r,X,W);s(f)?e.onChange({value:f,event:o}):e.onChange({value:null,event:o})}else e.onChange({value:null,event:o})}},s=o=>{const b=e.min??void 0,P=e.max??void 0;return!(b&&o<b||P&&o>P)},g=t.computed(()=>{if((n.value??"").length===10&&E.value.length===8){const[o,b,P]=(n.value??"").split("/"),H=parseInt(o),X=parseInt(b),W=parseInt(P);if(q(W,H,X))return R(W,H,X)}return null}),S=t.computed(()=>(n.value??"").length===10&&E.value.length===8),R=(o,b,P)=>{const H=new Date(0);return H.setFullYear(o,b-1,P),H.setHours(0,0,0,0),H},K=(o,b)=>R(o,b+1,0).getDate(),q=(o,b,P)=>b>=1&&b<=12&&o>=k&&P>=1&&P<=K(o,b),z=o=>{n.value=o.value;const b=o.event?.target;a.value=b?.selectionStart??0,d(o)},J=o=>{a.value=o.target.selectionStart??0},u=(o,b,P)=>{const H=b?.selectionStart??a.value??0;a.value=H;let X=parseInt(I.value),W=parseInt(D.value),r=parseInt(M.value);if(!(E.value.length>=8)||!q(r,X,W)){const Z=e.defaultValue??new Date;X=Z.getMonth()+1,W=Z.getDate(),r=Z.getFullYear(),n.value=`${String(X).padStart(2,"0")}/${String(W).padStart(2,"0")}/${String(r)}`;const le=R(r,X,W);e.onChange({value:s(le)?le:null,event:P}),i({useRAF:!0});return}const $=V(H);if($==="mm")X=o==="ArrowUp"?X<12?X+1:1:X>1?X-1:12;else if($==="dd"){const Z=new Date(r,X,0).getDate();W=o==="ArrowUp"?W<Z?W+1:1:W>1?W-1:Z}else $==="yyyy"&&(r=o==="ArrowUp"?r+1:Math.max(1,r-1));n.value=`${String(X).padStart(2,"0")}/${String(W).padStart(2,"0")}/${String(r)}`;const[B,G,Q]=n.value.split("/"),Y=R(parseInt(Q),parseInt(B),parseInt(G));Y.toString()!=="Invalid Date"&&parseInt(Q)>=1e3?e.onChange({value:s(Y)?Y:null,event:P}):e.onChange({value:null,event:P}),i({useRAF:!0})},A=o=>{if(o.code==="Space"||o.key===" "){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(o.key==="ArrowDown"&&o.altKey){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(F.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const b=o.target;u(o.key,b,o);return}},v=o=>{o.preventDefault();const b=o.deltaY<0?"ArrowUp":"ArrowDown";u(b,o.target,o)},w=o=>{const b=o.target;if(O.includes(o.key)){a.value=b?.selectionStart??0;return}if(F.includes(o.key)){if(o.altKey)return;a.value=b?.selectionStart??0}},C=o=>{x.value=!0,p.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&E.value.length===0&&(e.externalValue.value="");const b=o.target;b&&(a.value=b.selectionStart??0)},i=o=>{const b=()=>{const P=document.getElementById(e.id);if(!P)return;const H=o?.pos??a.value??P.value.length;try{P.focus(),P.setSelectionRange(H,H)}catch{}};t.nextTick(()=>{if(o?.delay&&o.delay>0){setTimeout(b,o.delay);return}if(o?.useRAF){requestAnimationFrame(b);return}b()})};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const b=new Date(o);if(b.toString()!=="Invalid Date"){const P=(b.getMonth()+1).toString().padStart(2,"0"),H=b.getDate().toString().padStart(2,"0"),X=b.getFullYear().toString();n.value=`${P}/${H}/${X}`,i({delay:50});return}}},{immediate:!0});const m=t.computed(()=>[["Date",`${I.value} / ${D.value} / ${M.value}`],["Digits only",E.value],["min",e.min?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null],["max",e.max?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null]]),L=t.computed(()=>{if(!p.value){if(!S.value)return!0;const b=g.value;return b?s(b):!1}if(!x.value)return!0;const o=g.value;return!S.value||!o?!1:s(o)}),U=t.computed(()=>{if(!p.value){if(!S.value)return;const b=g.value;return b?s(b)?"valid":"out-of-bounds":"invalid-date"}if(!x.value)return;if(E.value.length===0||!S.value)return"incomplete";const o=g.value;return o?s(o)?"valid":"out-of-bounds":"invalid-date"}),te=t.computed(()=>{const o=U.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-date")return`Must be in ${c.value} format.`;const b=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,P=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(o==="out-of-bounds"){if(b&&P)return`Must be between ${b} and ${P}.`;if(b)return`Must be on or after ${b}.`;if(P)return`Must be on or before ${P}.`}return""}),ee=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`ID (#${e.id}) not found for styling.`);return}const b=o.closest(".k-datepicker");if(!b){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const P=b.parentElement;if(P){if(P.classList.contains("fk-datepicker"))return;P.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{ee()}),{raw:n,cursorPos:a,debugEnabled:h,debugLines:m,placeholder:c,isValid:L,reason:t.readonly(U),validationMessage:te,digitsOnly:E,month:t.readonly(I),day:t.readonly(D),year:t.readonly(M),datePart:V,handleChange:z,handleKeyDown:A,handleWheel:v,handleKeyUp:w,handleClick:J,handleBlur:C,initStyling:ee}}function ut(e){const n=t.ref(""),a=t.ref(void 0),h=t.ref(!!e.debug),c=t.ref(!1),p=1440*60*1e3,k=365*p,x=new Date,F=new Date(x.getTime()-k),O=new Date(x.getTime()+k);e.min=e.min??F,e.max=e.max??O;const E=t.computed(()=>(n.value??"").replace(/\D/g,"")),V=(l,y)=>new Date(l,y,0).getDate(),I=(l,y,T)=>y>=1&&y<=12&&l>=1e3&&T>=1&&T<=V(l,y),D=l=>Date.UTC(l.getFullYear(),l.getMonth(),l.getDate()),M=l=>{if(!l)return null;const y=e.min??new Date(Date.now()-90*p),T=e.max??new Date,N=D(l);return N<D(y)||N>D(T)?null:l},d=(l,y)=>e.allowReverse??!1?!0:l<=y,s=t.computed(()=>(n.value?.length??0)>=23&&E.value.length>=16),g=l=>{if((l??"").length<23||E.value.length<16)return{start:null,end:null};const y=l.substring(0,10),T=l.substring(13,23),[N,ne,re]=y.split("/").map(ue=>parseInt(ue||"0",10)),[se,ce,de]=T.split("/").map(ue=>parseInt(ue||"0",10)),fe=new Date(re,N-1,ne),me=new Date(de,se-1,ce),Se=I(re,N,ne)&&fe.toString()!=="Invalid Date",ke=I(de,se,ce)&&me.toString()!=="Invalid Date";return{start:Se?fe:null,end:ke?me:null}},S=e.externalValid??t.ref(!0),R=t.computed(()=>g(n.value)),K=t.computed(()=>{const l=M(R.value.start),y=M(R.value.end);return{start:l,end:y}}),q=t.computed(()=>{if(!s.value)return;const l=K.value.start,y=K.value.end;if(!l||!y)return;const T=Math.abs(D(y)-D(l));return Math.round(T/864e5+1)}),z=t.ref(!1),J=t.computed(()=>{if(!z.value)return;const{start:l,end:y}=R.value;if(!s.value)return"incomplete";if(!l||!y)return"invalid-date";if(!K.value.start||!K.value.end)return"out-of-bounds";const T=K.value.start,N=K.value.end;return d(T,N)?typeof e.maxSpanDays=="number"&&q.value!==void 0&&q.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),u=t.computed(()=>{const l=J.value;return l===void 0||l==="valid"}),A=t.computed(()=>{const{min:l,max:y}=e,T=J.value;if(!T)return"";switch(T){case"incomplete":return"Required";case"invalid-date":return"One or both dates invalid.";case"reversed-range":return"End Date must be on or after Start Date.";case"out-of-bounds":return l&&y?`Dates must be between ${i(l)} and ${i(y)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),v=["ArrowUp","ArrowDown"],w=["ArrowLeft","ArrowRight"],C=(l,y)=>String(l).padStart(y,"0"),i=l=>`${C(l.getMonth()+1,2)}/${C(l.getDate(),2)}/${C(l.getFullYear(),4)}`,m=l=>l<=2?{side:"start",part:"mm"}:l<=5?{side:"start",part:(l<=3,"dd")}:l<=11?{side:"start",part:"yyyy"}:l<=15?{side:"end",part:"mm"}:l<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},L=(l,y,T)=>{const N=y?.selectionStart??a.value??0;a.value=N;const{start:ne,end:re}=g(n.value);if(!ne&&!re){const _=new Date,ie=i(_);n.value=`${ie} - ${ie}`,e.onChange({value:{start:_,end:_},event:T}),t.nextTick(()=>{requestAnimationFrame(()=>{const ae=document.getElementById(e.id),oe=a.value??0;ae&&(ae.focus(),ae.setSelectionRange(oe,oe))})});return}const se=new Date,ce=m(N);let de=ne?new Date(ne):new Date(se),fe=re?new Date(re):new Date(se);const me=(_,ie)=>{if(ie==="mm"){const ae=_.getMonth()+1,oe=l==="ArrowUp"?ae<12?ae+1:1:ae>1?ae-1:12;_.setMonth(oe-1);const he=V(_.getFullYear(),oe);_.getDate()>he&&_.setDate(he)}else if(ie==="dd"){const ae=V(_.getFullYear(),_.getMonth()+1),oe=_.getDate(),he=l==="ArrowUp"?oe<ae?oe+1:1:oe>1?oe-1:ae;_.setDate(he)}else if(ie==="yyyy"){const ae=_.getFullYear();_.setFullYear(l==="ArrowUp"?ae+1:Math.max(1,ae-1));const oe=V(_.getFullYear(),_.getMonth()+1);_.getDate()>oe&&_.setDate(oe)}};ce.side==="start"?me(de,ce.part):me(fe,ce.part);const Se=i(de),ke=i(fe);n.value=`${Se} - ${ke}`;const ue=M(de),Ae=M(fe);ue&&Ae&&d(ue,Ae)?e.onChange({value:{start:ue,end:Ae},event:T}):e.onChange({value:null,event:T}),t.nextTick(()=>{requestAnimationFrame(()=>{const _=document.getElementById(e.id),ie=a.value??0;_&&(_.focus(),_.setSelectionRange(ie,ie))})})},U=l=>{const{start:y,end:T}=g(n.value);if(!y||!T){e.onChange({value:null,event:l});return}const N=M(y),ne=M(T);if(!N||!ne){e.onChange({value:null,event:l});return}if(!d(N,ne)){e.onChange({value:null,event:l});return}e.onChange({value:{start:N,end:ne},event:l})},te=l=>{const y=l.value??"",T=l.event;if(!y&&T&&T.type==="click"){W(T);return}n.value=y;const N=T?.target;a.value=N?.selectionStart??0,U(l)},ee=l=>{a.value=l.target.selectionStart??0},o=l=>{if(l.code==="Space"||l.key===" "){l.preventDefault(),l.stopPropagation(),e.onShowCalendar(l);return}if(l.key==="ArrowDown"&&l.altKey){l.preventDefault(),l.stopPropagation(),e.onShowCalendar(l);return}if(v.includes(l.key)){l.preventDefault(),l.stopPropagation();const y=l.target;L(l.key,y,l);return}},b=l=>{l.preventDefault();const y=l.deltaY<0?"ArrowUp":"ArrowDown";L(y,l.target,l)},P=l=>{if(w.includes(l.key)||v.includes(l.key)){const y=l.target;a.value=y?.selectionStart??0}},H=()=>{z.value=!0,(e.manageValid??!0)&&(S.value=u.value)},X=l=>{H()},W=l=>{n.value="",a.value=0,e.onChange({value:null,event:l}),H(),t.nextTick(()=>{const y=document.getElementById(e.id);y&&(y.focus(),y.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,l=>{const y=l?.start??null,T=l?.end??null;if(y&&T){if(n.value=`${i(y)} - ${i(T)}`,e.isOpen?.value&&c.value&&e.onRequestClose){const N=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),c.value=!1,H()},N)}return}},{immediate:!0});const r=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),f=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),$=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),B=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),G=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),Q=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),Y=t.computed(()=>{const{start:l,end:y}=g(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(r.value).padStart(2,"0")} / ${String(f.value).padStart(2,"0")} / ${String($.value).padStart(4,"0")}`},{label:"End",value:`${String(B.value).padStart(2,"0")} / ${String(G.value).padStart(2,"0")} / ${String(Q.value).padStart(4,"0")}`},{label:"Digits only",value:E.value},{label:"Mask complete",value:`${s.value}`},{label:"Parsed",value:`${l?l.toDateString():"-"} | ${y?y.toDateString():"-"}`},{label:"Valid (managed)",value:`${S.value??"-"}`},{label:"Span (days)",value:`${q.value??"-"}`},{label:"Reason",value:`${J.value??"-"}`},{label:"Cursor in",value:`${a.value??"-"} (${(()=>{const T=a.value??0,N=m(T);return`${N.side}.${N.part}`})()})`}]}),Z=()=>{t.nextTick(()=>{const l=document.getElementById(e.id);if(!l){console.warn(`#${e.id} not found for styling.`);return}const y=l.closest("div");if(!y){console.warn(`Parent div of #${e.id} not found for styling.`);return}y.classList.contains("fk-daterangepicker")||y.classList.add("fk-daterangepicker")})};t.onMounted(()=>{Z()});const le=()=>{t.nextTick(()=>{try{const l=Array.from(document.querySelectorAll(".k-animation-container"));if(!l.length)return;const T=[...l].reverse().find(re=>re.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!T)return;const N=T.querySelectorAll(".k-calendar-table");let ne=!1;N.forEach(re=>{re.tabIndex===0&&(ne?re.tabIndex=-1:ne=!0)})}catch(l){console.warn(l)}})};return e.isOpen&&t.watch(e.isOpen,l=>{l&&setTimeout(()=>le(),0)},{immediate:!1}),{raw:n,cursorPos:a,debugEnabled:h,debugLines:Y,digitsOnly:E,valid:S,validComputed:t.readonly(u),reason:t.readonly(J),validationMessage:t.readonly(A),spanDays:t.readonly(q),month1:t.readonly(r),day1:t.readonly(f),year1:t.readonly($),month2:t.readonly(B),day2:t.readonly(G),year2:t.readonly(Q),handleChange:te,handleKeyDown:o,handleWheel:b,handleKeyUp:P,handleClick:ee,handleBlur:X,handleClear:W,onCalendarChange:()=>{c.value=!0},initStyling:Z}}function ct(e){const n=t.ref(""),a=t.ref(void 0),h=t.ref(!!e.debug),c=t.ref(e.timeFormat??"hh:mm AM"),p=t.computed(()=>!!e.required),k=t.ref(!1),x=["ArrowUp","ArrowDown"],F=["ArrowLeft","ArrowRight"],O=t.computed(()=>(n.value??"").replace(/\D/g,"")),E={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},V=r=>r<=2?"hh":r<=5?"mm":"ampm",I=t.computed(()=>{const r=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",f=parseInt(r);return Math.min(Math.max(f,0),23)}),D=t.computed(()=>{const r=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",f=parseInt(r);return Math.min(Math.max(f,0),59)}),M=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),d=t.computed(()=>{const r=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),f=M.value;return r===12?f==="AM"?0:12:f==="PM"?r+12:r}),s=t.computed(()=>g.value?`${String(d.value).padStart(2,"0")}:${String(D.value).padStart(2,"0")}:00`:null),g=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),S=(r,f,$)=>{let B=r%12;return B===0&&(B=12),`${String(B).padStart(2,"0")}:${String(f).padStart(2,"0")} ${$}`},R=r=>{const f=r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!f)return null;const $=parseInt(f[1]),B=parseInt(f[2]),G=f[3].toUpperCase();if($<1||$>12||B<0||B>59)return null;let Q=$%12;G==="PM"&&(Q+=12);const Y=new Date;return Y.setSeconds(0,0),Y.setHours(Q),Y.setMinutes(B),Y},K=r=>{if(O.value.length===0){e.onChange({value:null,event:r});return}if(!g.value){e.onChange({value:null,event:r});return}const f=R(n.value);f&&z(f)?e.onChange({value:f,event:r}):e.onChange({value:null,event:r})},q=r=>r.getHours()*60+r.getMinutes(),z=r=>{const f=e.min??void 0,$=e.max??void 0,B=q(r);if(f){const G=q(f);if(B<G)return!1}if($){const G=q($);if(B>G)return!1}return!0},J=r=>{const f=r.getHours(),$=f>=12?"PM":"AM";n.value=S(f,r.getMinutes(),$)},u=(r,f)=>{e.onChange({value:r,event:f})},A=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const r=document.getElementById(e.id);if(r){r.focus();const f=(r.value??"").length;r.setSelectionRange(f,f)}})})})},v=r=>{const f=r?.event?.target;return f?f.closest(".k-time-now")?"now":f.closest(".k-time-accept")?"set":null:null},w=(r,f)=>{r&&z(r)?u(r,f):u(null,f)},C=(...r)=>{const f=r[0];if(!f)return;const $=v(f);if($==="now"){const G=new Date;J(G),w(G,f),A();return}if(f?.value instanceof Date){const G=new Date(f.value);J(G),w(G,f),$==="set"&&A();return}if(f?.value===null){n.value="",u(null,f);return}n.value=f.value;const B=f.event?.target;a.value=B?.selectionStart??0;try{const G=a.value??0;if(V(G)==="ampm"&&(n.value??"").length>=8){const Q=n.value.charAt(6);/[Aa]/.test(Q)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id);Y&&(Y.focus(),Y.setSelectionRange(8,8))})})):/[Pp]/.test(Q)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id);Y&&(Y.focus(),Y.setSelectionRange(8,8))})}))}}catch{}K(f)},i=r=>{a.value=r.target.selectionStart??0},m=(r,f,$)=>{const B=f?.selectionStart??a.value??0;a.value=B;const G=V(B),Q=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!Q){if((n.value??"").length===0||O.value.length===0){const y=new Date,T=y.getHours(),N=T>=12?"PM":"AM";n.value=S(T,y.getMinutes(),N);const ne=R(n.value);w(ne,$),t.nextTick(()=>{requestAnimationFrame(()=>{const re=document.getElementById(e.id),se=a.value??0;re&&(re.focus(),re.setSelectionRange(se,se))})})}return}let Y=parseInt(Q[1]),Z=parseInt(Q[2]),le=Q[3].toUpperCase();if(G==="hh")r==="ArrowUp"?Y=Y<12?Y+1:1:Y=Y>1?Y-1:12;else if(G==="mm"){const y=e.minuteStepRef?.value??e.minuteStep??1;if(y===1)r==="ArrowUp"?Z=Z<59?Z+1:0:Z=Z>0?Z-1:59;else if(r==="ArrowUp"){const T=Z%y;let N=T===0?Z+y:Z+(y-T);N>=60&&(N=0),Z=N}else{const T=Z%y;let N=T===0?Z-y:Z-T;N<0&&(N=60-y),Z=N}}else G==="ampm"&&(le=le==="AM"?"PM":"AM");n.value=`${String(Y).padStart(2,"0")}:${String(Z).padStart(2,"0")} ${le}`;const l=R(n.value);w(l,$),t.nextTick(()=>{requestAnimationFrame(()=>{const y=document.getElementById(e.id),T=a.value??0;y&&(y.focus(),y.setSelectionRange(T,T))})})},L=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(x.includes(r.key)){if(r.altKey)return;r.preventDefault(),r.stopPropagation();const f=r.target;m(r.key,f,r);return}},U=r=>{r.preventDefault();const f=r.deltaY<0?"ArrowUp":"ArrowDown";m(f,r.target,r)},te=r=>{const f=r.target;if(F.includes(r.key)){a.value=f?.selectionStart??0;return}if(x.includes(r.key)){if(r.altKey)return;a.value=f?.selectionStart??0}},ee=r=>{k.value=!0,p.value&&e.externalValue&&e.externalValue.value===void 0&&O.value.length===0&&(e.externalValue.value="");const f=r.target;f&&(a.value=f.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,r=>{if(r){const f=new Date(r);if(f.toString()!=="Invalid Date"){const $=f.getHours(),B=$>=12?"PM":"AM";n.value=S($,f.getMinutes(),B);return}}},{immediate:!0});const o=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",I.value],["Hour (24h)",d.value],["Minute",D.value],["Period",M.value],["Time (24h)",s.value??"--:--:--"],["Digits only",O.value],["Parsed Date",b.value?.toLocaleDateString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["min",e.min?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["max",e.max?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["valid",P.value],["reason",H.value],["validationMessage",X.value]]),b=t.computed(()=>R(n.value)??null),P=t.computed(()=>{if(!p.value){if(!g.value)return!0;const f=b.value;return f?z(f):!1}if(!k.value)return!0;const r=b.value;return!g.value||!r?!1:z(r)}),H=t.computed(()=>{if(!p.value){if(!g.value)return;const f=b.value;return f?z(f)?"valid":"out-of-bounds":"invalid-time"}if(!k.value)return;if(O.value.length===0||!g.value)return"incomplete";const r=b.value;return r?z(r)?"valid":"out-of-bounds":"invalid-time"}),X=t.computed(()=>{const r=H.value;if(!r||r==="valid")return"";if(r==="incomplete")return"Required";if(r==="invalid-time")return`Must be in ${c.value} format.`;const f={hour:"2-digit",minute:"2-digit"},$=e.min?e.min.toLocaleTimeString("en-US",f):null,B=e.max?e.max.toLocaleTimeString("en-US",f):null;if(r==="out-of-bounds"){if($&&B)return`Must be between ${$} and ${B}.`;if($)return`Must be ${$} or later.`;if(B)return`Must be ${B} or earlier.`}return""}),W=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const f=r.closest(".k-timepicker");if(!f){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const $=f.parentElement;if(!$){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}$.classList.contains("fk-timepicker")||$.classList.add("fk-timepicker")})};return t.onMounted(()=>{W()}),{raw:n,rules:E,debugEnabled:h,debugLines:o,placeholder:c,isValid:P,reason:t.readonly(H),validationMessage:X,isComplete:g,inRangeTime:z,cursorPos:a,hour:t.readonly(I),hour24:t.readonly(d),minute:t.readonly(D),period:t.readonly(M),time24:t.readonly(s),parsedRawTime:t.readonly(b),handleChange:C,handleKeyDown:L,handleKeyUp:te,handleClick:i,handleWheel:U,handleBlur:ee,initStyling:W}}function dt(e){const n=t.shallowRef(null),a=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],h=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??a].flat(),c=E=>E?typeof e.initialFocus=="string"?E.querySelector(e.initialFocus)??E:typeof e.initialFocus=="function"?e.initialFocus(E)??E:E.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??E:null,{activate:p,deactivate:k}=Fe.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>c(n.value),...e.focusTrapOptions??{}});let x=null,F=t.ref(null);const O=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const E=(I,D)=>{const M=Array.from(I.querySelectorAll(D));if(!M.length)return null;const d=M.filter(s=>s.offsetParent!==null||s.getClientRects().length>0);return d[d.length-1]??M[M.length-1]??null},V=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const I of h){const D=E(V,I);if(D)return D}for(const I of h){const D=E(document,I);if(D)return D}return null};return Ce(n,E=>{F.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",E)}),t.watch(()=>e.isOpen.value,E=>{E?(F.value=null,t.nextTick(()=>{const V=O();V&&(n.value=V,setTimeout(()=>p(),0),x||(x=I=>{I.key==="Escape"&&(F.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",I))},document.addEventListener("keydown",x,!0)))})):(k(),x&&(document.removeEventListener("keydown",x,!0),x=null),n.value=null,F.value==="outside"&&t.nextTick(()=>{const V=()=>{const I=e.triggerEl?.value,D=I?.querySelector("input"),M=document.activeElement;M&&(M===D||I&&I.contains(M))&&(D??I)?.blur?.()};requestAnimationFrame(()=>setTimeout(V,0))}),e.returnFocusToTrigger!==!1&&F.value==="escape"&&e.triggerEl?.value&&t.nextTick(()=>{const V=()=>{const I=e.triggerEl?.value;if(!I)return;(I.querySelector("input")??I)?.focus?.()};requestAnimationFrame(()=>setTimeout(V,0))}))}),{popupRef:n,activate:p,deactivate:k,lastCloseReason:t.readonly(F),setPopupEl:E=>n.value=E}}j.useActiveIdRegistry=it,j.useCompositeId=Ge,j.useExclusiveGroup=ot,j.useFieldsetTouchTracker=Ie,j.useFieldsetValidationKit=Te,j.useGridA11y=Ve,j.useGridActiveFilter=Le,j.useGridRowAction=Ne,j.useIntersectionObserver=Re,j.useMaskedDateInput=st,j.useMaskedDateRangeInput=ut,j.useMaskedTimeInput=ct,j.usePopupMenu=at,j.usePopupTrap=dt,j.useUSAddress=We,j.useZipTextBox=xe,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(j,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("@vueuse/integrations/useFocusTrap")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/integrations/useFocusTrap"],t):(j=typeof globalThis<"u"?globalThis:j||self,t(j.FeatherKComposables={},j.Vue,j.useFocusTrap))})(this,(function(j,t,Fe){"use strict";const Ve=(e,n)=>{const a=t.ref(null);let h=!1,u=null,p=null;const k=[],x=".k-table-row[data-grid-row-index] [tabindex]",F=()=>{const c=e?.value?.$el;return c?c.closest(".k-grid"):null},O=c=>{const A=F();if(!A)return!1;const v=c.closest(".k-grid-aria-root");if(v)return A.contains(v);const w=c.closest(".k-grid-header, .k-grid-content, .k-grid-content-locked");return w?A.contains(w):!1},E=c=>c.key==="Enter"||c.code==="Enter"||c.code==="NumpadEnter",V=()=>e?.value?.columns,I=c=>{const A=c.key||c.code;([" ","Spacebar","Space"].includes(A)||E(c))&&(c.preventDefault(),c.stopPropagation(),a.value=c.target,c.target.click())},D=c=>{if(!a.value)return;if(c.code==="Escape"){c.stopPropagation(),a.value&&a.value.focus();return}const A=Array.from(document.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item")),v=document.querySelector(".k-animation-container .k-popup .k-column-menu .k-filter-menu-container");if(v){if(c.code==="Tab"){const w=[".k-dropdownlist[tabindex='0']","input.k-input-inner:not([tabindex='-1']):not([disabled])","button:not([tabindex='-1']):not([disabled])",".k-checkbox"],C=n?.focusableMenuSelectors??w,i=Array.from(v.querySelectorAll(C.join(",")));if(i.length===0)return;const m=i.findIndex(U=>U===document.activeElement);let L;m===-1?L=0:c.shiftKey?L=(m-1+i.length)%i.length:L=(m+1)%i.length,c.preventDefault(),c.stopPropagation(),i[L]?.focus()}}else if(c.code==="ArrowUp"||c.code==="ArrowDown"){c.preventDefault(),c.stopPropagation();const w=A.findIndex(i=>i===document.activeElement);let C=w;c.code==="ArrowUp"?C=w>0?w-1:A.length-1:c.code==="ArrowDown"&&(C=w<A.length-1?w+1:0),A[C]?.focus();return}if(c.code==="Tab"){c.preventDefault(),c.stopPropagation();const w=a.value?.parentElement;(c.shiftKey?w?.previousElementSibling:w?.nextElementSibling)?.querySelector("button, [role='button'], .k-link")?.focus()}},M=()=>{u=new MutationObserver(c=>{c.forEach(A=>{A.addedNodes.forEach(v=>{if(v.nodeType===Node.ELEMENT_NODE){const w=v;if(w.classList.contains("k-animation-container")){const i=a.value;i&&(i.dataset.featherKSortable==="true"||t.nextTick(()=>{w.querySelectorAll(".k-columnmenu-item-wrapper").forEach(U=>{U.textContent?.toLowerCase().includes("sort")&&U.remove()})})),w.addEventListener("keydown",D),t.nextTick(()=>{const m=()=>{const L=Array.from(w.querySelectorAll(".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"));if(L.length===1)L[0].focus(),L[0].click(),m.attempts=0;else if(L.length>1){m.attempts=0;return}else m.attempts===void 0&&(m.attempts=0),m.attempts++<3&&setTimeout(m,200)};m()})}w.querySelectorAll(".k-animation-container").forEach(i=>{i.addEventListener("keydown",D)})}}),A.removedNodes.forEach(v=>{if(v.nodeType===Node.ELEMENT_NODE){const w=v;w.classList.contains("k-animation-container")&&w.removeEventListener("keydown",D),w.querySelectorAll(".k-animation-container").forEach(i=>{i.removeEventListener("keydown",D)})}})})}),u.observe(document.body,{childList:!0,subtree:!0})},d=c=>{const A=c.tagName.toLowerCase();return!!(["input","textarea","select","button"].includes(A)||c.closest('.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'))},s=c=>{if(!c.type||!c)return;const A=c.target;if(!A)return;const v=A.closest(".k-table-row[data-grid-row-index]");if(!O(A))return;const w=["ArrowLeft","ArrowRight"].includes(c.code);if(!(d(A)&&!(v&&w))){if(c.code==="Escape"){const C=document.activeElement?.closest(".k-table-row[data-grid-row-index]");if(C){c.preventDefault(),c.stopPropagation();try{Array.from(e?.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]")).forEach(m=>m.setAttribute("tabindex","-1"))}catch{}C.setAttribute("tabindex","0"),C.focus();return}}if(["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter","NumpadEnter","Space"].includes(c.code)){if(A.classList.contains("k-grid-header-menu")&&A.classList.contains("k-grid-column-menu")){a.value=A;return}if(v){if(["ArrowDown","ArrowUp"].includes(c.code)){c.preventDefault(),c.stopPropagation();const C=(m,L)=>{let U=L==="next"?m.nextElementSibling:m.previousElementSibling;for(;U;){const te=U;try{if(te.classList.contains("k-table-row"))return te}catch{}U=L==="next"?U.nextElementSibling:U.previousElementSibling}return null},i=c.code==="ArrowDown"?C(v,"next"):C(v,"previous");i&&(v.setAttribute("tabindex","-1"),i.setAttribute("tabindex","0"),i.focus());return}if(["ArrowLeft","ArrowRight"].includes(c.code)){c.preventDefault(),c.stopPropagation();const C=v.querySelectorAll(x);if(C.length===0)return;let i=Array.from(C).findIndex(m=>m===document.activeElement);if(i===-1&&document.activeElement===v){C[0].focus();return}c.code==="ArrowRight"?i=i===C.length-1?0:i+1:c.code==="ArrowLeft"&&(i=i===0?C.length-1:i-1),C[i].focus();return}}}}},g=()=>{t.nextTick(()=>{const c=e.value?.$el;if(!c||typeof c.closest!="function")return;const A=c.closest(".k-grid");A&&A.classList.add("fk-grid")})},S=()=>{if(!p)try{const c=()=>{try{const w=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));if(!w||w.length===0||w.filter(m=>m.getAttribute("tabindex")==="0").length===1)return;const i=w.find(m=>m===document.activeElement||m.contains(document.activeElement));if(w.forEach(m=>m.setAttribute("tabindex","-1")),i){i.setAttribute("tabindex","0");return}w[0].setAttribute("tabindex","0")}catch(w){console.error("ensureSingleTabindex error:",w)}},A=Array.from(e.value.$el.querySelectorAll(".k-table-row[data-grid-row-index]"));A.length>0&&A.forEach((w,C)=>{w.setAttribute("tabindex",C===0?"0":"-1")});const v=e.value.$el.querySelector(".k-table-tbody");v&&(p=new MutationObserver(()=>{c()}),p.observe(v,{childList:!0,subtree:!0}))}catch(c){console.error("Error setting up row navigation:",c)}},R=()=>{t.nextTick(()=>{const A=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");A&&A.forEach(v=>{v.setAttribute("role","button"),v.addEventListener("keydown",I)}),M(),q()})},K=()=>{const A=document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");A&&A.forEach(v=>{v.removeEventListener("keydown",I)}),u&&(u.disconnect(),u=null),p&&(p.disconnect(),p=null),k.forEach(v=>v()),k.length=0},q=()=>{document.querySelectorAll(".k-grid-header .k-table-thead th").forEach((v,w)=>{if(v.dataset.featherKHeaderBound==="true")return;const C=v.querySelector(".k-grid-header-menu.k-grid-column-menu");if(!C)return;const i=V();if(i&&i[w]){const o=i[w].field??"";v.setAttribute("data-feather-k-field",o),v.setAttribute("data-feather-k-filterable",i[w].filterable===!1?"false":"true"),v.setAttribute("data-feather-k-sortable",i[w].sortable===!1?"false":"true")}const m=v.dataset.featherKFilterable!=="false",L=v.dataset.featherKSortable!=="false";C.setAttribute("tabindex","-1"),m||L?v.style.cursor="pointer":v.style.cursor="default",m?(v.setAttribute("tabindex","0"),v.setAttribute("role","button"),v.setAttribute("aria-haspopup","menu")):(v.setAttribute("tabindex","0"),v.setAttribute("role","columnheader"),v.removeAttribute("aria-haspopup"));const U=o=>{o.target?.closest(".k-column-resizer")||(a.value=v,C.click())},te=o=>{if(m)a.value=v,o.preventDefault(),o.stopPropagation(),U(o);else if(L){a.value=v;const b=v.querySelector(".k-link");b&&b.click()}};v.addEventListener("click",te),k.push(()=>{v.removeEventListener("click",te)});const ee=o=>{if((E(o)||o.code==="Space")&&(m||L)){if(o.preventDefault(),o.stopPropagation(),a.value=v,a.value.focus(),m)U(o);else if(L){const b=v.querySelector(".k-link");b&&b.click()}}};v.addEventListener("keydown",ee,!0),k.push(()=>{v.removeEventListener("keydown",ee,!0)}),v.dataset.featherKHeaderBound="true"});const A=document.querySelector(".k-grid-header .k-table-thead");if(A&&A.dataset.featherKHeaderBound!=="true"){const v=w=>{const C=w.target.closest("th");C&&(E(w)||w.code==="Space")&&C.dataset.featherKFilterable==="false"&&C.dataset.featherKSortable==="false"&&(w.preventDefault(),w.stopImmediatePropagation())};A.addEventListener("keydown",v,!0),k.push(()=>{A.removeEventListener("keydown",v,!0)}),A.dataset.featherKHeaderBound="true"}},z=function(c,A){const v=c?.event?.event.target,w=V();if(!v||!w)return;const C=v.classList.contains("k-grid-header-menu"),i=v.classList.contains("k-columnmenu-item"),m=w.find(L=>L.field===c?.event?.field)?.sortable&&!0;if(!C){if(i&&!m){c?.event?.sort?.filter(U=>U.field!==c?.event?.field);return}typeof A=="function"&&t.nextTick(()=>{a.value&&a.value.focus(),A(c),t.nextTick(()=>{q()})})}},J=()=>{if(!h)try{g(),S(),R(),h=!0}catch(c){console.error("initA11y failed:",c),K()}};return t.onBeforeUnmount(()=>{K()}),{activeFilterButton:a,handleGridKeyDown:s,handleSortChange:z,initA11y:J}},$e=e=>!!e&&typeof e=="object"&&"filters"in e&&Array.isArray(e.filters),Pe=e=>!!e&&typeof e=="object"&&"field"in e,De=(e,n)=>!e||typeof e!="object"?!1:$e(e)?e.filters.some(a=>De(a,n)):Pe(e)?e.field===n:!1,Le=e=>n=>e.value?.filters&&e.value.filters.some(a=>De(a,n))?"active":"",Oe=["button","a","input","select","textarea",'[role="button"]','[role="checkbox"]','[role="link"]','[role="menuitem"]','[role="option"]',".k-checkbox",".k-button",".k-dropdown",".k-picker",".k-hierarchy-cell",".k-grid-header-menu",".k-column-menu"],Ne=e=>{const{onRowAction:n,gridRef:a,dataItems:h,ignoreSelectors:u=[],shouldIgnoreTarget:p,enableKeyboardAction:k=!0}=e,x=[...Oe,...u],F=(d,s)=>{if(!d)return!1;const g=x.join(",");return d.closest&&d.closest(g)?!0:p&&s?p(d,s):!1},O=d=>{const g=d?.closest?.(".k-table-row[data-grid-row-index]")?.getAttribute("data-grid-row-index");if(g==null)return;const S=parseInt(g,10);return Number.isNaN(S)?void 0:S},E=d=>{if(!d||typeof d.clientX!="number")return;const s=typeof window<"u"&&window.scrollX||0,g=typeof window<"u"&&window.scrollY||0,S=typeof window<"u"&&window.screenX||0,R=typeof window<"u"&&window.screenY||0;return{clientX:d.clientX,clientY:d.clientY,pageX:typeof d.pageX=="number"?d.pageX:d.clientX+s,pageY:typeof d.pageY=="number"?d.pageY:d.clientY+g,screenX:typeof d.screenX=="number"?d.screenX:d.clientX+S,screenY:typeof d.screenY=="number"?d.screenY:d.clientY+R}},V=d=>{if(!d||typeof d.getBoundingClientRect!="function")return;const s=d.getBoundingClientRect();if(!s)return;const g=s.left,S=s.bottom,R=typeof window<"u"&&window.scrollX||0,K=typeof window<"u"&&window.scrollY||0;return{clientX:g,clientY:S,pageX:g+R,pageY:S+K,screenX:g,screenY:S}},I=d=>{if(typeof window>"u")return!1;const s=window.getSelection();if(!s||s.isCollapsed||!s.toString().trim())return!1;if(d&&s.anchorNode&&s.focusNode){const g=d.closest(".k-table-row")||d.closest(".k-grid")||d,S=s.anchorNode.nodeType===Node.ELEMENT_NODE?s.anchorNode:s.anchorNode.parentElement,R=s.focusNode.nodeType===Node.ELEMENT_NODE?s.focusNode:s.focusNode.parentElement,K=!!(S&&g.contains(S)),q=!!(R&&g.contains(R));return K||q}return!0};return{handleRowClick:d=>{const s=d?.htmlEvent||d?.event||d?.nativeEvent||(d instanceof Event?d:void 0);if(s&&s.button!==void 0&&s.button!==0)return;const g=s?.target||d?.target;if(g&&F(g,s||d)||I(g))return;const S={dataItem:d.dataItem,rowIndex:d.rowIndex??O(g),field:d.field,event:s||d,triggerType:"click",ctrlKey:!!s?.ctrlKey,shiftKey:!!s?.shiftKey,metaKey:!!s?.metaKey,altKey:!!s?.altKey,coordinates:E(s)??V(g)};n(d.dataItem,S)},handleRowKeyDown:(d,s)=>{if(!k)return;const g=d.key||d.code;if(!(g==="Enter"||g==="NumpadEnter"||g===" "||g==="Space"||d.code==="Enter"||d.code==="NumpadEnter"||d.code==="Space"))return;const R=d.target;if(!R)return;const K=R.closest(".k-table-row[data-grid-row-index], .k-table-row");if(!K||F(R,d))return;d.preventDefault(),d.stopPropagation();const q=K.getAttribute("data-grid-row-index"),z=q!==null?parseInt(q,10):void 0;let J=s;if(J===void 0){const A=(Array.isArray(h)?h:h?.value)||a?.value?.props?.dataItems||a?.value?.dataItems;A&&z!==void 0&&z>=0&&z<A.length&&(J=A[z])}if(J===void 0)return;const c={dataItem:J,rowIndex:z,event:d,triggerType:"keyboard",ctrlKey:!!d.ctrlKey,shiftKey:!!d.shiftKey,metaKey:!!d.metaKey,altKey:!!d.altKey,coordinates:V(K)};n(J,c)},isIgnoredTarget:F}},Ke="Enter a valid ZIP code with exactly 5 or 9 digits.",Ee=e=>{const n=e.replace(/\D/g,"").slice(0,9);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n},qe=(e,n)=>e.slice(0,Math.max(0,n)).replace(/\D/g,"").length,Ue=e=>e<=5?e:Math.min(e+1,10),xe=e=>{const n=t.ref(Ee(e.initialValue??"")),a=t.ref(!1),h=t.ref(e.errorMessage?.trim()||Ke),u=t.computed(()=>n.value.replace(/\D/g,"")),p=t.computed(()=>{const D=u.value.length;return D===5||D===9}),k=t.computed(()=>a.value&&!p.value),x=t.computed(()=>!a.value||p.value),F=t.computed(()=>a.value),O=(D,M)=>{const d=Ue(M);t.nextTick(()=>{D.isConnected&&D.setSelectionRange(d,d)})};return{zipDisplay:n,submitted:a,errorMessage:h,wrapperClass:"fk-zip-textbox",zipRaw:u,isZipValid:p,showZipError:k,textBoxValid:x,textBoxValidate:F,handleZipInput:(...D)=>{const M=D[0],s=M?.event?.target,g=M?.value,S=Array.isArray(g)?g.join(""):String(g??""),R=s?.selectionStart!==void 0&&s.selectionStart!==null?qe(s.value,s.selectionStart):S.replace(/\D/g,"").length;n.value=Ee(S),s&&O(s,R)},submitAndValidate:D=>{a.value=!0;const M=p.value;return!M&&D?.focus&&t.nextTick(()=>{document.getElementById(e.id)?.focus()}),M},buildPayload:()=>({zip:u.value})}};function Ie(e,n){const a=t.ref(!1);t.watchEffect(()=>{e.value?.setAttribute("aria-invalid",String(!n.isValid()))});function h(p){const k=e.value??p.currentTarget,x=p.relatedTarget;(!k||!k.contains(x))&&(a.value=!0)}function u(){a.value=!1}return{touched:a,onFocusout:h,reset:u}}function Te(e,n){const a=t.ref(!1),h=t.ref(!1),u=t.computed(()=>t.toValue(n.submitted)||a.value),p=t.computed(()=>!u.value||n.isValid()),k=Ie(e,{isValid:()=>p.value});function x(I){return t.computed(()=>!u.value||t.toValue(I))}function F(I){return Object.fromEntries(Object.entries(I).map(([D,M])=>[D,x(M)]))}function O(I){const D=t.toValue(I);if(!D)return;D.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function E(I){if(h.value){h.value=!1;return}k.onFocusout(I),k.touched.value&&(a.value=!0)}function V(){a.value=!1,h.value=!0,k.reset()}return{touched:a,fieldsetValidate:u,onFocusout:E,reset:V,createFieldValidity:x,createFieldValidationsMap:F,focusFirstInvalidField:O}}const Be=[{label:"Alabama",value:"AL"},{label:"Alaska",value:"AK"},{label:"Arizona",value:"AZ"},{label:"Arkansas",value:"AR"},{label:"California",value:"CA"},{label:"Colorado",value:"CO"},{label:"Connecticut",value:"CT"},{label:"Delaware",value:"DE"},{label:"Florida",value:"FL"},{label:"Georgia",value:"GA"},{label:"Hawaii",value:"HI"},{label:"Idaho",value:"ID"},{label:"Illinois",value:"IL"},{label:"Indiana",value:"IN"},{label:"Iowa",value:"IA"},{label:"Kansas",value:"KS"},{label:"Kentucky",value:"KY"},{label:"Louisiana",value:"LA"},{label:"Maine",value:"ME"},{label:"Maryland",value:"MD"},{label:"Massachusetts",value:"MA"},{label:"Michigan",value:"MI"},{label:"Minnesota",value:"MN"},{label:"Mississippi",value:"MS"},{label:"Missouri",value:"MO"},{label:"Montana",value:"MT"},{label:"Nebraska",value:"NE"},{label:"Nevada",value:"NV"},{label:"New Hampshire",value:"NH"},{label:"New Jersey",value:"NJ"},{label:"New Mexico",value:"NM"},{label:"New York",value:"NY"},{label:"North Carolina",value:"NC"},{label:"North Dakota",value:"ND"},{label:"Ohio",value:"OH"},{label:"Oklahoma",value:"OK"},{label:"Oregon",value:"OR"},{label:"Pennsylvania",value:"PA"},{label:"Rhode Island",value:"RI"},{label:"South Carolina",value:"SC"},{label:"South Dakota",value:"SD"},{label:"Tennessee",value:"TN"},{label:"Texas",value:"TX"},{label:"Utah",value:"UT"},{label:"Vermont",value:"VT"},{label:"Virginia",value:"VA"},{label:"Washington",value:"WA"},{label:"West Virginia",value:"WV"},{label:"Wisconsin",value:"WI"},{label:"Wyoming",value:"WY"}];function ve(e){if(e&&typeof e=="object"&&"value"in e){const n=e.value;return typeof n=="string"?n:String(n??"")}return""}function Ye(){const e=t.reactive({address1:"",address2:"",city:"",state:null,zip:""});return{formData:e,onAddress1Input:(...k)=>{e.address1=ve(k[0])},onAddress2Input:(...k)=>{e.address2=ve(k[0])},onCityInput:(...k)=>{e.city=ve(k[0])},onStateChange:k=>{e.state=k.value},resetFormData:()=>{e.address1="",e.address2="",e.city="",e.state=null,e.zip=""}}}function ze(e,n="zip"){const a=xe({id:n}),{zipDisplay:h,zipRaw:u,isZipValid:p,wrapperClass:k,handleZipInput:x}=a;return t.watch(u,O=>{e.zip=O}),{zipDisplay:h,isZipValid:p,zipWrapperClass:k,onZipInput:x,resetZip:()=>{h.value="",e.zip=""}}}function He(e){const n=t.computed(()=>e.formData.address1.trim()!==""),a=t.computed(()=>e.formData.city.trim()!==""),h=t.computed(()=>!!e.formData.state),u=t.computed(()=>t.toValue(e.isZipValid)),p=t.computed(()=>n.value&&a.value&&h.value&&u.value);return{strictAddress1Valid:n,strictCityValid:a,strictStateValid:h,strictZipValid:u,strictAddressValid:p}}function Xe(e){if(!e)return;e.querySelector('.k-invalid input, .k-invalid[tabindex="0"]')?.focus()}function Ze(e,n){const a=e??n.currentTarget,h=n.relatedTarget;return!a||!a.contains(h)}function We(e){const n=t.ref(t.toValue(e.fieldsetRef));t.watchEffect(()=>{n.value=t.toValue(e.fieldsetRef)});const a=t.ref(!1),h=t.ref(!1),u=t.computed(()=>t.toValue(e.required)??!0),{formData:p,onAddress1Input:k,onAddress2Input:x,onCityInput:F,onStateChange:O,resetFormData:E}=Ye(),V=`${e.addressId}-zip`,{zipDisplay:I,isZipValid:D,zipWrapperClass:M,onZipInput:d,resetZip:s}=ze(p,V),{strictAddress1Valid:g,strictCityValid:S,strictStateValid:R,strictZipValid:K,strictAddressValid:q}=He({formData:p,isZipValid:D}),z=Te(n,{submitted:a,isValid:()=>q.value}),{touched:J,fieldsetValidate:c,onFocusout:A,reset:v}=z,w=z.createFieldValidationsMap({address1:g,city:S,state:R,zip:K,address:q}),{address1:C,city:i,state:m,zip:L,address:U}=w,te=t.computed(()=>u.value?c.value:!1),ee=t.computed(()=>u.value?C.value:!0),o=t.computed(()=>u.value?i.value:!0),b=t.computed(()=>u.value?m.value:!0),P=t.computed(()=>u.value?L.value:!0),H=t.computed(()=>u.value?U.value:!0),X={value:null,label:"State"},W=Be.map(({label:y,value:T})=>({label:y,value:T})),r=t.computed(()=>({address1:p.address1.trim(),address2:p.address2.trim(),city:p.city.trim(),state:(p.state??"").trim().toUpperCase(),zip:p.zip.replace(/\D/g,"")})),f=t.computed(()=>p.address1.trim()===""&&p.address2.trim()===""&&p.city.trim()===""&&(p.state??"").trim()===""&&p.zip.replace(/\D/g,"")===""),$=t.computed(()=>!f.value),B=t.computed(()=>!u.value&&$.value&&(!g.value||!S.value||!R.value)),G=t.computed(()=>{const y=p.zip.replace(/\D/g,"");return!u.value&&$.value&&y.length!==5&&y.length!==9}),Q=t.computed(()=>!u.value&&$.value&&!q.value),Y=t.computed(()=>!u.value&&Q.value&&(h.value||a.value));return t.watch(r,()=>{u.value||(h.value=!1)}),t.watch(u,y=>{y||(a.value=!1,h.value=!1,v())}),{formData:p,submitted:a,touched:J,addressValidate:te,address1Valid:ee,cityValid:o,stateValid:b,zipValid:P,addressValid:H,optionalFeedbackActive:Y,optionalPartialInvalid:Q,optionalMissingRequiredFields:B,optionalZipInvalid:G,stateDefaultItem:X,stateOptions:W,zipDisplay:I,zipWrapperClass:M,onAddress1Input:k,onAddress2Input:x,onCityInput:F,onStateChange:O,onZipInput:d,onFieldsetFocusout:y=>{const T=Ze(n.value,y);A(y),!u.value&&T&&(h.value=!0)},normalizedPayload:r,validateForSubmit:async()=>u.value?(a.value=!0,q.value?{isValid:!0,payload:r.value}:(await t.nextTick(),Xe(n.value),{isValid:!1,payload:null})):f.value||q.value?(a.value=!1,{isValid:!0,payload:r.value}):(a.value=!0,{isValid:!1,payload:null}),reset:()=>{a.value=!1,h.value=!1,v(),E(),s()}}}const Ge=(e="fkid")=>{const n=`${e}-${t.useId()}`;return{instanceId:n,compose:(...h)=>[n,...h].filter(u=>u!=null).map(String).join("-")}},je=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const _e=Object.prototype.toString,Je=e=>_e.call(e)==="[object Object]",ge=()=>{};function be(e){return Array.isArray(e)?e:[e]}function Qe(e,n,a){return t.watch(e,n,{...a,immediate:!0})}const Me=je?window:void 0;function pe(e){var n;const a=t.toValue(e);return(n=a?.$el)!==null&&n!==void 0?n:a}function we(...e){const n=(h,u,p,k)=>(h.addEventListener(u,p,k),()=>h.removeEventListener(u,p,k)),a=t.computed(()=>{const h=be(t.toValue(e[0])).filter(u=>u!=null);return h.every(u=>typeof u!="string")?h:void 0});return Qe(()=>{var h,u;return[(h=(u=a.value)===null||u===void 0?void 0:u.map(p=>pe(p)))!==null&&h!==void 0?h:[Me].filter(p=>p!=null),be(t.toValue(a.value?e[1]:e[0])),be(t.unref(a.value?e[2]:e[1])),t.toValue(a.value?e[3]:e[2])]},([h,u,p,k],x,F)=>{if(!h?.length||!u?.length||!p?.length)return;const O=Je(k)?{...k}:k,E=h.flatMap(V=>u.flatMap(I=>p.map(D=>n(V,I,D,O))));F(()=>{E.forEach(V=>V())})},{flush:"post"})}function Ce(e,n,a={}){const{window:h=Me,ignore:u=[],capture:p=!0,detectIframe:k=!1,controls:x=!1}=a;if(!h)return x?{stop:ge,cancel:ge,trigger:ge}:ge;let F=!0;const O=s=>t.toValue(u).some(g=>{if(typeof g=="string")return Array.from(h.document.querySelectorAll(g)).some(S=>S===s.target||s.composedPath().includes(S));{const S=pe(g);return S&&(s.target===S||s.composedPath().includes(S))}});function E(s){const g=t.toValue(s);return g&&g.$.subTree.shapeFlag===16}function V(s,g){const S=t.toValue(s),R=S.$.subTree&&S.$.subTree.children;return R==null||!Array.isArray(R)?!1:R.some(K=>K.el===g.target||g.composedPath().includes(K.el))}const I=s=>{const g=pe(e);if(s.target!=null&&!(!(g instanceof Element)&&E(e)&&V(e,s))&&!(!g||g===s.target||s.composedPath().includes(g))){if("detail"in s&&s.detail===0&&(F=!O(s)),!F){F=!0;return}n(s)}};let D=!1;const M=[we(h,"click",s=>{D||(D=!0,setTimeout(()=>{D=!1},0),I(s))},{passive:!0,capture:p}),we(h,"pointerdown",s=>{const g=pe(e);F=!O(s)&&!!(g&&!s.composedPath().includes(g))},{passive:!0}),k&&we(h,"blur",s=>{setTimeout(()=>{const g=pe(e);let S=h.document.activeElement;for(;S?.shadowRoot;)S=S.shadowRoot.activeElement;S?.tagName==="IFRAME"&&!g?.contains(h.document.activeElement)&&n(s)},0)},{passive:!0})].filter(Boolean),d=()=>M.forEach(s=>s());return x?{stop:d,cancel:()=>{F=!1},trigger:s=>{F=!0,I(s),F=!1}}:d}const Re=e=>{let n=null;const a=()=>{n?.disconnect(),n=null};return typeof window<"u"&&typeof window.IntersectionObserver=="function"&&t.watch([e.target,()=>e.root()],([u,p])=>{a(),u&&(n=new IntersectionObserver(([k])=>{k&&e.onChange(k)},{root:p,threshold:e.threshold??1}),n.observe(u))},{immediate:!0}),t.onUnmounted(a),{disconnect:a}},et=".k-table-row",ye=e=>{if(e instanceof HTMLElement)return e;const n=e?.$el;return n instanceof HTMLElement?n:null},tt=(e,n)=>n==="row"?e.matches("tr.k-table-row"):!e.matches("tr.k-table-row"),nt=(e,n)=>{console.warn(`usePopupMenu: triggerMode "${n}" does not match resolved element <${e.tagName.toLowerCase()}${e.className?`.${e.className.split(" ").join(".")}`:""}>; ARIA management skipped.`)},rt=e=>{let n=e.parentElement;for(;n;){const{overflow:a,overflowX:h,overflowY:u}=window.getComputedStyle(n);if([a,h,u].some(p=>/auto|scroll|overlay/.test(p)))return n;n=n.parentElement}return null},at=e=>{const n=t.ref(null),a=e.menuItemSelector??".k-menu-item:not(.k-disabled)",h=e.triggerMode,u=e.anchor===!0?{}:e.anchor,p=t.shallowRef(null),k=()=>ye(e.triggerRef.value),x=t.computed(()=>k()),F=t.computed(()=>u&&u.hideWhenAnchorClipped!==!1?x.value:null),O=t.computed(()=>{const i=p.value;return!e.isOpen.value||!i?{left:0,top:0}:{left:i.left+window.scrollX,top:i.bottom+window.scrollY}}),E=()=>e.resolveFocusTarget?.()??ye(e.focusTargetRef?.value),V=()=>{if(h!=="button")return null;if(e.escapeFocusTarget)return e.escapeFocusTarget();const i=e.escapeFocusContainerSelector??et;return(k()??document.activeElement)?.closest(i)??null},I=()=>{const i=E()??V();if(i)return i.focus(),!0;const m=k();return m?.focus(),!!m},D=()=>{ye(e.menuRef.value)?.querySelector(a)?.focus({preventScroll:!0})},M=t.shallowRef(null),d=t.shallowRef(null);let s=!1;const g=()=>{const i=n.value;if(i==="keyboard"||i==="escape"){const m=M.value??d.value;m?.focus(),i==="keyboard"&&m&&m===d.value&&(s=!0)}else n.value==="mouse-selection"&&d.value?.focus();n.value=null,M.value=null,d.value=null},S=i=>{e.isOpen.value&&(n.value=i,M.value=E()??(i==="escape"?V():null),d.value=k(),z(!1),e.requestHide(),t.nextTick(g))};t.watch(x,(i,m,L)=>{if(!u||!i){p.value=null;return}let U=null;const te=()=>{U=null,p.value=u.getRect?.()??i.getBoundingClientRect()},ee=()=>{U===null&&(U=window.requestAnimationFrame(te))},o=typeof window.ResizeObserver=="function"?new window.ResizeObserver(ee):null;o?.observe(i),window.addEventListener("scroll",ee,{capture:!0,passive:!0}),window.addEventListener("resize",ee,{passive:!0}),ee(),L(()=>{U!==null&&window.cancelAnimationFrame(U),o?.disconnect(),window.removeEventListener("scroll",ee,!0),window.removeEventListener("resize",ee)})},{immediate:!0,flush:"post"}),Re({target:F,root:()=>u?.clipRoot?t.toValue(u.clipRoot):x.value?rt(x.value):null,threshold:u?.intersectionThreshold??.5,onChange:i=>{i.isIntersecting||S("anchor-hidden")}}),Ce(e.menuRef,()=>S("outside-click"),{ignore:[x]});let R=null,K=null;const q=()=>{R?.isConnected&&R.setAttribute("aria-expanded","false"),R=null},z=i=>{if(e.manageMenuTriggerAria===!1)return;const m=x.value;if(!m){R?.isConnected&&R.setAttribute("aria-expanded",i?"true":"false");return}if(!tt(m,h)){nt(m,h),q();return}R&&R!==m&&q(),m.setAttribute("aria-expanded",i?"true":"false"),R=m},J=()=>{const i=ye(e.menuRef.value),m=i?.matches('[role="menubar"]')?i:i?.querySelector('[role="menubar"]'),L=t.toValue(e.menuLabel)?.trim();K&&K!==m&&K.removeAttribute("aria-label"),m&&(L?m.setAttribute("aria-label",L):m.removeAttribute("aria-label")),K=m??null};t.watch([e.isOpen,e.triggerRef],([i])=>z(i),{immediate:!0,flush:"post"}),t.watch([e.isOpen,e.menuRef,()=>t.toValue(e.menuLabel)],J,{immediate:!0,flush:"post"}),t.onUnmounted(()=>{q(),K?.removeAttribute("aria-label")}),t.watch(e.isOpen,i=>{i&&D()},{flush:"post"});const c=(...i)=>{const m=i[0];if(s){s=!1;return}if(e.isOpen.value){S("trigger-click");return}e.requestShow(m)};return{handleMenuSelect:(i,m)=>{m?.(i),S(i.event?.type?.startsWith("key")?"keyboard":"mouse-selection")},handleActionButtonClick:c,handleActionButtonKeydown:(...i)=>{const m=i[0],L=i[1];if(m.key==="Enter"||m.code==="Space"){m.preventDefault(),c(L);return}if(m.key==="Escape"){if(m.preventDefault(),m.stopPropagation(),e.isOpen.value){S("escape");return}I()}},handleActionMenuEscape:i=>{i.preventDefault(),i.stopPropagation(),S("escape")},handlePopupClose:()=>{t.nextTick(g)},offset:O}},ot=()=>{const e=new Set;return{register:u=>{e.add(u),t.onUnmounted(()=>e.delete(u))},deactivateOthers:u=>{e.forEach(p=>{p!==u&&p.deactivate()})},deactivateAll:()=>{e.forEach(u=>u.deactivate())}}},lt=e=>{if(e instanceof HTMLElement)return e;const n=e&&"$el"in e?e.$el:null;return n instanceof HTMLElement?n:null},it=()=>{const e=t.shallowReactive(new Map),n=t.ref(null),a=(x,F)=>{const O=lt(F);O?e.set(x,O):e.delete(x)},h=x=>e.get(x)??null,u=x=>{n.value=x},p=()=>{n.value=null},k=x=>n.value===x;return{activeId:t.readonly(n),isActive:t.computed(()=>n.value!==null),activeElement:t.computed(()=>n.value!==null?h(n.value):null),register:a,resolve:h,activate:u,deactivate:p,isIdActive:k}};function st(e){const n=t.ref(""),a=t.ref(void 0),h=t.ref(!!e.debug),u=t.ref(e.dateFormat??"mm/dd/yyyy"),p=t.computed(()=>!!e.required),k=1e3,x=t.ref(!1),F=["ArrowUp","ArrowDown"],O=["ArrowLeft","ArrowRight"],E=t.computed(()=>(n.value??"").replace(/\D/g,"")),V=o=>o<=2?"mm":o<=5?"dd":E.value.length<=10?"yyyy":"mm",I=t.computed(()=>{const o=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),D=t.computed(()=>{const o=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(2,"0")}),M=t.computed(()=>{const o=n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0";return parseInt(o).toString().padStart(4,"0")}),d=o=>{if(E.value.length===0){e.onChange({value:null,event:o});return}if(E.value.length<8){e.onChange({value:null,event:o});return}if((n.value??"").length===10&&E.value.length===8){const[b,P,H]=n.value.split("/"),X=parseInt(b),W=parseInt(P),r=parseInt(H);if(q(r,X,W)){const f=R(r,X,W);s(f)?e.onChange({value:f,event:o}):e.onChange({value:null,event:o})}else e.onChange({value:null,event:o})}},s=o=>{const b=e.min??void 0,P=e.max??void 0;return!(b&&o<b||P&&o>P)},g=t.computed(()=>{if((n.value??"").length===10&&E.value.length===8){const[o,b,P]=(n.value??"").split("/"),H=parseInt(o),X=parseInt(b),W=parseInt(P);if(q(W,H,X))return R(W,H,X)}return null}),S=t.computed(()=>(n.value??"").length===10&&E.value.length===8),R=(o,b,P)=>{const H=new Date(0);return H.setFullYear(o,b-1,P),H.setHours(0,0,0,0),H},K=(o,b)=>R(o,b+1,0).getDate(),q=(o,b,P)=>b>=1&&b<=12&&o>=k&&P>=1&&P<=K(o,b),z=o=>{n.value=o.value;const b=o.event?.target;a.value=b?.selectionStart??0,d(o)},J=o=>{a.value=o.target.selectionStart??0},c=(o,b,P)=>{const H=b?.selectionStart??a.value??0;a.value=H;let X=parseInt(I.value),W=parseInt(D.value),r=parseInt(M.value);if(!(E.value.length>=8)||!q(r,X,W)){const Z=e.defaultValue??new Date;X=Z.getMonth()+1,W=Z.getDate(),r=Z.getFullYear(),n.value=`${String(X).padStart(2,"0")}/${String(W).padStart(2,"0")}/${String(r)}`;const le=R(r,X,W);e.onChange({value:s(le)?le:null,event:P}),i({useRAF:!0});return}const $=V(H);if($==="mm")X=o==="ArrowUp"?X<12?X+1:1:X>1?X-1:12;else if($==="dd"){const Z=new Date(r,X,0).getDate();W=o==="ArrowUp"?W<Z?W+1:1:W>1?W-1:Z}else $==="yyyy"&&(r=o==="ArrowUp"?r+1:Math.max(1,r-1));n.value=`${String(X).padStart(2,"0")}/${String(W).padStart(2,"0")}/${String(r)}`;const[B,G,Q]=n.value.split("/"),Y=R(parseInt(Q),parseInt(B),parseInt(G));Y.toString()!=="Invalid Date"&&parseInt(Q)>=1e3?e.onChange({value:s(Y)?Y:null,event:P}):e.onChange({value:null,event:P}),i({useRAF:!0})},A=o=>{if(o.code==="Space"||o.key===" "){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(o.key==="ArrowDown"&&o.altKey){o.preventDefault(),o.stopPropagation(),e.onShowCalendar(o);return}if(F.includes(o.key)){if(o.altKey)return;o.preventDefault(),o.stopPropagation();const b=o.target;c(o.key,b,o);return}},v=o=>{o.preventDefault();const b=o.deltaY<0?"ArrowUp":"ArrowDown";c(b,o.target,o)},w=o=>{const b=o.target;if(O.includes(o.key)){a.value=b?.selectionStart??0;return}if(F.includes(o.key)){if(o.altKey)return;a.value=b?.selectionStart??0}},C=o=>{x.value=!0,p.value&&!e.defaultValue&&e.externalValue&&e.externalValue.value===void 0&&E.value.length===0&&(e.externalValue.value="");const b=o.target;b&&(a.value=b.selectionStart??0)},i=o=>{const b=()=>{const P=document.getElementById(e.id);if(!P)return;const H=o?.pos??a.value??P.value.length;try{P.focus(),P.setSelectionRange(H,H)}catch{}};t.nextTick(()=>{if(o?.delay&&o.delay>0){setTimeout(b,o.delay);return}if(o?.useRAF){requestAnimationFrame(b);return}b()})};e.externalValue&&t.watch(e.externalValue,o=>{if(o){const b=new Date(o);if(b.toString()!=="Invalid Date"){const P=(b.getMonth()+1).toString().padStart(2,"0"),H=b.getDate().toString().padStart(2,"0"),X=b.getFullYear().toString();n.value=`${P}/${H}/${X}`,i({delay:50});return}}},{immediate:!0});const m=t.computed(()=>[["Date",`${I.value} / ${D.value} / ${M.value}`],["Digits only",E.value],["min",e.min?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null],["max",e.max?.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"})??null]]),L=t.computed(()=>{if(!p.value){if(!S.value)return!0;const b=g.value;return b?s(b):!1}if(!x.value)return!0;const o=g.value;return!S.value||!o?!1:s(o)}),U=t.computed(()=>{if(!p.value){if(!S.value)return;const b=g.value;return b?s(b)?"valid":"out-of-bounds":"invalid-date"}if(!x.value)return;if(E.value.length===0||!S.value)return"incomplete";const o=g.value;return o?s(o)?"valid":"out-of-bounds":"invalid-date"}),te=t.computed(()=>{const o=U.value;if(!o||o==="valid")return"";if(o==="incomplete")return"Required";if(o==="invalid-date")return`Must be in ${u.value} format.`;const b=e.min?e.min.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null,P=e.max?e.max.toLocaleDateString("en-US",{year:"numeric",month:"2-digit",day:"2-digit"}):null;if(o==="out-of-bounds"){if(b&&P)return`Must be between ${b} and ${P}.`;if(b)return`Must be on or after ${b}.`;if(P)return`Must be on or before ${P}.`}return""}),ee=()=>{t.nextTick(()=>{const o=document.getElementById(e.id);if(!o){console.warn(`ID (#${e.id}) not found for styling.`);return}const b=o.closest(".k-datepicker");if(!b){console.warn(`.k-datepicker parent not found for #${e.id} styling.`);return}const P=b.parentElement;if(P){if(P.classList.contains("fk-datepicker"))return;P.classList.add("fk-datepicker")}else console.warn(`Parent of .k-datepicker not found for #${e.id} styling.`)})};return t.onMounted(()=>{ee()}),{raw:n,cursorPos:a,debugEnabled:h,debugLines:m,placeholder:u,isValid:L,reason:t.readonly(U),validationMessage:te,digitsOnly:E,month:t.readonly(I),day:t.readonly(D),year:t.readonly(M),datePart:V,handleChange:z,handleKeyDown:A,handleWheel:v,handleKeyUp:w,handleClick:J,handleBlur:C,initStyling:ee}}function ut(e){const n=t.ref(""),a=t.ref(void 0),h=t.ref(!!e.debug),u=t.ref(!1),p=1440*60*1e3,k=365*p,x=new Date,F=new Date(x.getTime()-k),O=new Date(x.getTime()+k);e.min=e.min??F,e.max=e.max??O;const E=t.computed(()=>(n.value??"").replace(/\D/g,"")),V=(l,y)=>new Date(l,y,0).getDate(),I=(l,y,T)=>y>=1&&y<=12&&l>=1e3&&T>=1&&T<=V(l,y),D=l=>Date.UTC(l.getFullYear(),l.getMonth(),l.getDate()),M=l=>{if(!l)return null;const y=e.min??new Date(Date.now()-90*p),T=e.max??new Date,N=D(l);return N<D(y)||N>D(T)?null:l},d=(l,y)=>e.allowReverse??!1?!0:l<=y,s=t.computed(()=>(n.value?.length??0)>=23&&E.value.length>=16),g=l=>{if((l??"").length<23||E.value.length<16)return{start:null,end:null};const y=l.substring(0,10),T=l.substring(13,23),[N,ne,re]=y.split("/").map(ue=>parseInt(ue||"0",10)),[se,ce,de]=T.split("/").map(ue=>parseInt(ue||"0",10)),fe=new Date(re,N-1,ne),me=new Date(de,se-1,ce),Se=I(re,N,ne)&&fe.toString()!=="Invalid Date",ke=I(de,se,ce)&&me.toString()!=="Invalid Date";return{start:Se?fe:null,end:ke?me:null}},S=e.externalValid??t.ref(!0),R=t.computed(()=>g(n.value)),K=t.computed(()=>{const l=M(R.value.start),y=M(R.value.end);return{start:l,end:y}}),q=t.computed(()=>{if(!s.value)return;const l=K.value.start,y=K.value.end;if(!l||!y)return;const T=Math.abs(D(y)-D(l));return Math.round(T/864e5+1)}),z=t.ref(!1),J=t.computed(()=>{if(!z.value)return;const{start:l,end:y}=R.value;if(!s.value)return"incomplete";if(!l||!y)return"invalid-date";if(!K.value.start||!K.value.end)return"out-of-bounds";const T=K.value.start,N=K.value.end;return d(T,N)?typeof e.maxSpanDays=="number"&&q.value!==void 0&&q.value>e.maxSpanDays?"span-exceeds-limit":"valid":"reversed-range"}),c=t.computed(()=>{const l=J.value;return l===void 0||l==="valid"}),A=t.computed(()=>{const{min:l,max:y}=e,T=J.value;if(!T)return"";switch(T){case"incomplete":return"Required";case"invalid-date":return"One or both dates invalid.";case"reversed-range":return"End Date must be on or after Start Date.";case"out-of-bounds":return l&&y?`Dates must be between ${i(l)} and ${i(y)}.`:"Dates must be within the allowed range.";case"span-exceeds-limit":return typeof e.maxSpanDays=="number"?`Date range exceeds ${e.maxSpanDays} days.`:"Date range exceeds maximum allowed span.";default:return""}}),v=["ArrowUp","ArrowDown"],w=["ArrowLeft","ArrowRight"],C=(l,y)=>String(l).padStart(y,"0"),i=l=>`${C(l.getMonth()+1,2)}/${C(l.getDate(),2)}/${C(l.getFullYear(),4)}`,m=l=>l<=2?{side:"start",part:"mm"}:l<=5?{side:"start",part:(l<=3,"dd")}:l<=11?{side:"start",part:"yyyy"}:l<=15?{side:"end",part:"mm"}:l<=18?{side:"end",part:"dd"}:{side:"end",part:"yyyy"},L=(l,y,T)=>{const N=y?.selectionStart??a.value??0;a.value=N;const{start:ne,end:re}=g(n.value);if(!ne&&!re){const _=new Date,ie=i(_);n.value=`${ie} - ${ie}`,e.onChange({value:{start:_,end:_},event:T}),t.nextTick(()=>{requestAnimationFrame(()=>{const ae=document.getElementById(e.id),oe=a.value??0;ae&&(ae.focus(),ae.setSelectionRange(oe,oe))})});return}const se=new Date,ce=m(N);let de=ne?new Date(ne):new Date(se),fe=re?new Date(re):new Date(se);const me=(_,ie)=>{if(ie==="mm"){const ae=_.getMonth()+1,oe=l==="ArrowUp"?ae<12?ae+1:1:ae>1?ae-1:12;_.setMonth(oe-1);const he=V(_.getFullYear(),oe);_.getDate()>he&&_.setDate(he)}else if(ie==="dd"){const ae=V(_.getFullYear(),_.getMonth()+1),oe=_.getDate(),he=l==="ArrowUp"?oe<ae?oe+1:1:oe>1?oe-1:ae;_.setDate(he)}else if(ie==="yyyy"){const ae=_.getFullYear();_.setFullYear(l==="ArrowUp"?ae+1:Math.max(1,ae-1));const oe=V(_.getFullYear(),_.getMonth()+1);_.getDate()>oe&&_.setDate(oe)}};ce.side==="start"?me(de,ce.part):me(fe,ce.part);const Se=i(de),ke=i(fe);n.value=`${Se} - ${ke}`;const ue=M(de),Ae=M(fe);ue&&Ae&&d(ue,Ae)?e.onChange({value:{start:ue,end:Ae},event:T}):e.onChange({value:null,event:T}),t.nextTick(()=>{requestAnimationFrame(()=>{const _=document.getElementById(e.id),ie=a.value??0;_&&(_.focus(),_.setSelectionRange(ie,ie))})})},U=l=>{const{start:y,end:T}=g(n.value);if(!y||!T){e.onChange({value:null,event:l});return}const N=M(y),ne=M(T);if(!N||!ne){e.onChange({value:null,event:l});return}if(!d(N,ne)){e.onChange({value:null,event:l});return}e.onChange({value:{start:N,end:ne},event:l})},te=l=>{const y=l.value??"",T=l.event;if(!y&&T&&T.type==="click"){W(T);return}n.value=y;const N=T?.target;a.value=N?.selectionStart??0,U(l)},ee=l=>{a.value=l.target.selectionStart??0},o=l=>{if(l.code==="Space"||l.key===" "){l.preventDefault(),l.stopPropagation(),e.onShowCalendar(l);return}if(l.key==="ArrowDown"&&l.altKey){l.preventDefault(),l.stopPropagation(),e.onShowCalendar(l);return}if(v.includes(l.key)){l.preventDefault(),l.stopPropagation();const y=l.target;L(l.key,y,l);return}},b=l=>{l.preventDefault();const y=l.deltaY<0?"ArrowUp":"ArrowDown";L(y,l.target,l)},P=l=>{if(w.includes(l.key)||v.includes(l.key)){const y=l.target;a.value=y?.selectionStart??0}},H=()=>{z.value=!0,(e.manageValid??!0)&&(S.value=c.value)},X=l=>{H()},W=l=>{n.value="",a.value=0,e.onChange({value:null,event:l}),H(),t.nextTick(()=>{const y=document.getElementById(e.id);y&&(y.focus(),y.setSelectionRange(0,0))})};e.externalValue&&t.watch(e.externalValue,l=>{const y=l?.start??null,T=l?.end??null;if(y&&T){if(n.value=`${i(y)} - ${i(T)}`,e.isOpen?.value&&u.value&&e.onRequestClose){const N=typeof e.closeDelay=="number"?e.closeDelay:e.closeDelay?.value??0;setTimeout(()=>{e.onRequestClose?.(),u.value=!1,H()},N)}return}},{immediate:!0});const r=t.computed(()=>n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0"),f=t.computed(()=>n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0"),$=t.computed(()=>n.value&&n.value.substring(6,10).replace(/\D/g,"0")||"0"),B=t.computed(()=>n.value&&n.value.substring(13,15).replace(/\D/g,"0")||"0"),G=t.computed(()=>n.value&&n.value.substring(16,18).replace(/\D/g,"0")||"0"),Q=t.computed(()=>n.value&&n.value.substring(19,23).replace(/\D/g,"0")||"0"),Y=t.computed(()=>{const{start:l,end:y}=g(n.value);return[{label:"Raw",value:n.value},{label:"Min Date",value:`${e.min?e.min.toDateString():"-"}`},{label:"Max Date",value:`${e.max?e.max.toDateString():"-"}`},{label:"Start",value:`${String(r.value).padStart(2,"0")} / ${String(f.value).padStart(2,"0")} / ${String($.value).padStart(4,"0")}`},{label:"End",value:`${String(B.value).padStart(2,"0")} / ${String(G.value).padStart(2,"0")} / ${String(Q.value).padStart(4,"0")}`},{label:"Digits only",value:E.value},{label:"Mask complete",value:`${s.value}`},{label:"Parsed",value:`${l?l.toDateString():"-"} | ${y?y.toDateString():"-"}`},{label:"Valid (managed)",value:`${S.value??"-"}`},{label:"Span (days)",value:`${q.value??"-"}`},{label:"Reason",value:`${J.value??"-"}`},{label:"Cursor in",value:`${a.value??"-"} (${(()=>{const T=a.value??0,N=m(T);return`${N.side}.${N.part}`})()})`}]}),Z=()=>{t.nextTick(()=>{const l=document.getElementById(e.id);if(!l){console.warn(`#${e.id} not found for styling.`);return}const y=l.closest("div");if(!y){console.warn(`Parent div of #${e.id} not found for styling.`);return}y.classList.contains("fk-daterangepicker")||y.classList.add("fk-daterangepicker")})};t.onMounted(()=>{Z()});const le=()=>{t.nextTick(()=>{try{const l=Array.from(document.querySelectorAll(".k-animation-container"));if(!l.length)return;const T=[...l].reverse().find(re=>re.querySelector(".k-calendar"))?.querySelector(".k-calendar");if(!T)return;const N=T.querySelectorAll(".k-calendar-table");let ne=!1;N.forEach(re=>{re.tabIndex===0&&(ne?re.tabIndex=-1:ne=!0)})}catch(l){console.warn(l)}})};return e.isOpen&&t.watch(e.isOpen,l=>{l&&setTimeout(()=>le(),0)},{immediate:!1}),{raw:n,cursorPos:a,debugEnabled:h,debugLines:Y,digitsOnly:E,valid:S,validComputed:t.readonly(c),reason:t.readonly(J),validationMessage:t.readonly(A),spanDays:t.readonly(q),month1:t.readonly(r),day1:t.readonly(f),year1:t.readonly($),month2:t.readonly(B),day2:t.readonly(G),year2:t.readonly(Q),handleChange:te,handleKeyDown:o,handleWheel:b,handleKeyUp:P,handleClick:ee,handleBlur:X,handleClear:W,onCalendarChange:()=>{u.value=!0},initStyling:Z}}function ct(e){const n=t.ref(""),a=t.ref(void 0),h=t.ref(!!e.debug),u=t.ref(e.timeFormat??"hh:mm AM"),p=t.computed(()=>!!e.required),k=t.ref(!1),x=["ArrowUp","ArrowDown"],F=["ArrowLeft","ArrowRight"],O=t.computed(()=>(n.value??"").replace(/\D/g,"")),E={H:/[0-9]/,h:/[0-9]/,M:/[0-9]/,m:/[0-9]/,A:/[AaPp]/,a:/[Mm]/},V=r=>r<=2?"hh":r<=5?"mm":"ampm",I=t.computed(()=>{const r=n.value&&n.value.substring(0,2).replace(/\D/g,"0")||"0",f=parseInt(r);return Math.min(Math.max(f,0),23)}),D=t.computed(()=>{const r=n.value&&n.value.substring(3,5).replace(/\D/g,"0")||"0",f=parseInt(r);return Math.min(Math.max(f,0),59)}),M=t.computed(()=>(n.value?.substring(6,8)||"AM").toUpperCase().startsWith("P")?"PM":"AM"),d=t.computed(()=>{const r=parseInt(n.value?.substring(0,2).replace(/\D/g,"0")||"0"),f=M.value;return r===12?f==="AM"?0:12:f==="PM"?r+12:r}),s=t.computed(()=>g.value?`${String(d.value).padStart(2,"0")}:${String(D.value).padStart(2,"0")}:00`:null),g=t.computed(()=>/^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value??"")),S=(r,f,$)=>{let B=r%12;return B===0&&(B=12),`${String(B).padStart(2,"0")}:${String(f).padStart(2,"0")} ${$}`},R=r=>{const f=r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!f)return null;const $=parseInt(f[1]),B=parseInt(f[2]),G=f[3].toUpperCase();if($<1||$>12||B<0||B>59)return null;let Q=$%12;G==="PM"&&(Q+=12);const Y=new Date;return Y.setSeconds(0,0),Y.setHours(Q),Y.setMinutes(B),Y},K=r=>{if(O.value.length===0){e.onChange({value:null,event:r});return}if(!g.value){e.onChange({value:null,event:r});return}const f=R(n.value);f&&z(f)?e.onChange({value:f,event:r}):e.onChange({value:null,event:r})},q=r=>r.getHours()*60+r.getMinutes(),z=r=>{const f=e.min??void 0,$=e.max??void 0,B=q(r);if(f){const G=q(f);if(B<G)return!1}if($){const G=q($);if(B>G)return!1}return!0},J=r=>{const f=r.getHours(),$=f>=12?"PM":"AM";n.value=S(f,r.getMinutes(),$)},c=(r,f)=>{e.onChange({value:r,event:f})},A=()=>{t.nextTick(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const r=document.getElementById(e.id);if(r){r.focus();const f=(r.value??"").length;r.setSelectionRange(f,f)}})})})},v=r=>{const f=r?.event?.target;return f?f.closest(".k-time-now")?"now":f.closest(".k-time-accept")?"set":null:null},w=(r,f)=>{r&&z(r)?c(r,f):c(null,f)},C=(...r)=>{const f=r[0];if(!f)return;const $=v(f);if($==="now"){const G=new Date;J(G),w(G,f),A();return}if(f?.value instanceof Date){const G=new Date(f.value);J(G),w(G,f),$==="set"&&A();return}if(f?.value===null){n.value="",c(null,f);return}n.value=f.value;const B=f.event?.target;a.value=B?.selectionStart??0;try{const G=a.value??0;if(V(G)==="ampm"&&(n.value??"").length>=8){const Q=n.value.charAt(6);/[Aa]/.test(Q)?(n.value=`${n.value.slice(0,6)}AM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id);Y&&(Y.focus(),Y.setSelectionRange(8,8))})})):/[Pp]/.test(Q)&&(n.value=`${n.value.slice(0,6)}PM${n.value.slice(8)}`,t.nextTick(()=>{requestAnimationFrame(()=>{const Y=document.getElementById(e.id);Y&&(Y.focus(),Y.setSelectionRange(8,8))})}))}}catch{}K(f)},i=r=>{a.value=r.target.selectionStart??0},m=(r,f,$)=>{const B=f?.selectionStart??a.value??0;a.value=B;const G=V(B),Q=(n.value??"").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);if(!Q){if((n.value??"").length===0||O.value.length===0){const y=new Date,T=y.getHours(),N=T>=12?"PM":"AM";n.value=S(T,y.getMinutes(),N);const ne=R(n.value);w(ne,$),t.nextTick(()=>{requestAnimationFrame(()=>{const re=document.getElementById(e.id),se=a.value??0;re&&(re.focus(),re.setSelectionRange(se,se))})})}return}let Y=parseInt(Q[1]),Z=parseInt(Q[2]),le=Q[3].toUpperCase();if(G==="hh")r==="ArrowUp"?Y=Y<12?Y+1:1:Y=Y>1?Y-1:12;else if(G==="mm"){const y=e.minuteStepRef?.value??e.minuteStep??1;if(y===1)r==="ArrowUp"?Z=Z<59?Z+1:0:Z=Z>0?Z-1:59;else if(r==="ArrowUp"){const T=Z%y;let N=T===0?Z+y:Z+(y-T);N>=60&&(N=0),Z=N}else{const T=Z%y;let N=T===0?Z-y:Z-T;N<0&&(N=60-y),Z=N}}else G==="ampm"&&(le=le==="AM"?"PM":"AM");n.value=`${String(Y).padStart(2,"0")}:${String(Z).padStart(2,"0")} ${le}`;const l=R(n.value);w(l,$),t.nextTick(()=>{requestAnimationFrame(()=>{const y=document.getElementById(e.id),T=a.value??0;y&&(y.focus(),y.setSelectionRange(T,T))})})},L=r=>{if(r.code==="Space"||r.key===" "){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(r.key==="ArrowDown"&&r.altKey){r.preventDefault(),r.stopPropagation(),e.onShowPicker(r);return}if(x.includes(r.key)){if(r.altKey)return;r.preventDefault(),r.stopPropagation();const f=r.target;m(r.key,f,r);return}},U=r=>{r.preventDefault();const f=r.deltaY<0?"ArrowUp":"ArrowDown";m(f,r.target,r)},te=r=>{const f=r.target;if(F.includes(r.key)){a.value=f?.selectionStart??0;return}if(x.includes(r.key)){if(r.altKey)return;a.value=f?.selectionStart??0}},ee=r=>{k.value=!0,p.value&&e.externalValue&&e.externalValue.value===void 0&&O.value.length===0&&(e.externalValue.value="");const f=r.target;f&&(a.value=f.selectionStart??0)};e.externalValue&&t.watch(e.externalValue,r=>{if(r){const f=new Date(r);if(f.toString()!=="Invalid Date"){const $=f.getHours(),B=$>=12?"PM":"AM";n.value=S($,f.getMinutes(),B);return}}},{immediate:!0});const o=t.computed(()=>[["Time",n.value||"--:-- --"],["Hour (12h)",I.value],["Hour (24h)",d.value],["Minute",D.value],["Period",M.value],["Time (24h)",s.value??"--:--:--"],["Digits only",O.value],["Parsed Date",b.value?.toLocaleDateString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["min",e.min?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["max",e.max?.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})??null],["valid",P.value],["reason",H.value],["validationMessage",X.value]]),b=t.computed(()=>R(n.value)??null),P=t.computed(()=>{if(!p.value){if(!g.value)return!0;const f=b.value;return f?z(f):!1}if(!k.value)return!0;const r=b.value;return!g.value||!r?!1:z(r)}),H=t.computed(()=>{if(!p.value){if(!g.value)return;const f=b.value;return f?z(f)?"valid":"out-of-bounds":"invalid-time"}if(!k.value)return;if(O.value.length===0||!g.value)return"incomplete";const r=b.value;return r?z(r)?"valid":"out-of-bounds":"invalid-time"}),X=t.computed(()=>{const r=H.value;if(!r||r==="valid")return"";if(r==="incomplete")return"Required";if(r==="invalid-time")return`Must be in ${u.value} format.`;const f={hour:"2-digit",minute:"2-digit"},$=e.min?e.min.toLocaleTimeString("en-US",f):null,B=e.max?e.max.toLocaleTimeString("en-US",f):null;if(r==="out-of-bounds"){if($&&B)return`Must be between ${$} and ${B}.`;if($)return`Must be ${$} or later.`;if(B)return`Must be ${B} or earlier.`}return""}),W=()=>{t.nextTick(()=>{const r=document.getElementById(e.id);if(!r){console.warn(`#${e.id} not found for styling.`);return}const f=r.closest(".k-timepicker");if(!f){console.warn(`.k-timepicker parent of #${e.id} not found for styling.`);return}const $=f.parentElement;if(!$){console.warn(`Parent of .k-timepicker not found for #${e.id} styling.`);return}$.classList.contains("fk-timepicker")||$.classList.add("fk-timepicker")})};return t.onMounted(()=>{W()}),{raw:n,rules:E,debugEnabled:h,debugLines:o,placeholder:u,isValid:P,reason:t.readonly(H),validationMessage:X,isComplete:g,inRangeTime:z,cursorPos:a,hour:t.readonly(I),hour24:t.readonly(d),minute:t.readonly(D),period:t.readonly(M),time24:t.readonly(s),parsedRawTime:t.readonly(b),handleChange:C,handleKeyDown:L,handleKeyUp:te,handleClick:i,handleWheel:U,handleBlur:ee,initStyling:W}}function dt(e){const n=t.shallowRef(null),a=[".k-animation-container .k-popup",".k-popup",".k-timepicker-popup",".k-menu-popup"],h=Array.isArray(e.popupSelector)?e.popupSelector:[e.popupSelector??a].flat(),u=E=>E?typeof e.initialFocus=="string"?E.querySelector(e.initialFocus)??E:typeof e.initialFocus=="function"?e.initialFocus(E)??E:E.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??E:null,{activate:p,deactivate:k}=Fe.useFocusTrap(n,{escapeDeactivates:!1,clickOutsideDeactivates:!1,fallbackFocus:()=>n.value,initialFocus:()=>u(n.value),...e.focusTrapOptions??{}});let x=null,F=t.ref(null);const O=()=>{if(e.resolvePopupEl)return e.resolvePopupEl();const E=(I,D)=>{const M=Array.from(I.querySelectorAll(D));if(!M.length)return null;const d=M.filter(s=>s.offsetParent!==null||s.getClientRects().length>0);return d[d.length-1]??M[M.length-1]??null},V=e.triggerEl?.value?.closest?.(".k-animation-container")??document.body;for(const I of h){const D=E(V,I);if(D)return D}for(const I of h){const D=E(document,I);if(D)return D}return null};return Ce(n,E=>{F.value="outside",e.isOpen.value&&e.onRequestClose?.("outside",E)}),t.watch(()=>e.isOpen.value,E=>{E?(F.value=null,t.nextTick(()=>{const V=O();V&&(n.value=V,setTimeout(()=>p(),0),x||(x=I=>{I.key==="Escape"&&(F.value="escape",e.isOpen.value&&e.onRequestClose?.("escape",I))},document.addEventListener("keydown",x,!0)))})):(k(),x&&(document.removeEventListener("keydown",x,!0),x=null),n.value=null,F.value==="outside"&&t.nextTick(()=>{const V=()=>{const I=e.triggerEl?.value,D=I?.querySelector("input"),M=document.activeElement;M&&(M===D||I&&I.contains(M))&&(D??I)?.blur?.()};requestAnimationFrame(()=>setTimeout(V,0))}),e.returnFocusToTrigger!==!1&&F.value==="escape"&&e.triggerEl?.value&&t.nextTick(()=>{const V=()=>{const I=e.triggerEl?.value;if(!I)return;(I.querySelector("input")??I)?.focus?.()};requestAnimationFrame(()=>setTimeout(V,0))}))}),{popupRef:n,activate:p,deactivate:k,lastCloseReason:t.readonly(F),setPopupEl:E=>n.value=E}}j.useActiveIdRegistry=it,j.useCompositeId=Ge,j.useExclusiveGroup=ot,j.useFieldsetTouchTracker=Ie,j.useFieldsetValidationKit=Te,j.useGridA11y=Ve,j.useGridActiveFilter=Le,j.useGridRowAction=Ne,j.useIntersectionObserver=Re,j.useMaskedDateInput=st,j.useMaskedDateRangeInput=ut,j.useMaskedTimeInput=ct,j.usePopupMenu=at,j.usePopupTrap=dt,j.useUSAddress=We,j.useZipTextBox=xe,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})}));
2
2
  //# sourceMappingURL=featherk-composables.umd.js.map