import{h as M}from"./OdysseyThemeProvider-Bh0Bu-2o.js";import{r as e}from"./index-NdkWRN8K.js";import{V as O}from"./index.esm-CBOWgn41.js";import{j as a}from"./jsx-runtime-CnH95YSl.js";import{M as D}from"./Field-DH3L8v09.js";import{g as A,u as N,C as T}from"./inputUtils-Dbi8XkA6.js";import{I as k}from"./InputBase-DeB4_faH.js";/*!
 * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.
 * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
 *
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and limitations under the License.
 */const H=M.div({width:"100%",height:"100%"}),_=({data:u,index:t,setItemSize:c,style:d})=>{const o=e.useRef(null);e.useEffect(()=>{if(o.current){const l=o.current.firstElementChild,f=l?l.clientHeight:o.current.clientHeight;c(f)}},[t,o,c]);const h=u[t],{props:s}=h,r=e.useMemo(()=>({...d,height:"auto"}),[d]);return a.jsx("div",{ref:o,children:a.jsx("li",{...s,style:r})})},y=e.createContext({}),w=e.forwardRef((u,t)=>{const c=e.useContext(y);return a.jsx("div",{ref:t,...u,...c})}),F=u=>{const t=e.useRef(null);return e.useEffect(()=>{t.current&&t.current.resetAfterIndex(0,!0)},[u]),t},v=e.forwardRef((u={},t)=>{const[c,d]=e.useState(0),{children:o,...h}=u,s=e.Children.toArray(o).flatMap(n=>typeof n=="number"||typeof n=="string"?[n]:[n].concat("children"in n?e.Children.toArray(o):[])),r=e.useRef([]),l=e.useCallback(()=>s.length>f?9999:16+r.current.slice(0,s.length).map((p,C)=>r.current[C]||0).reduce((p,C)=>p+C,0),[s,r]);e.useEffect(()=>{r.current.length&&s.length&&d(l())},[l,s,r]);const f=8,m=F(s.length),x=e.useCallback(n=>{var i;(i=m==null?void 0:m.current)==null||i.resetAfterIndex(0,!0),r.current=r.current.concat(n)},[m,r]),g=e.useCallback(n=>r.current[n]||45,[r]);return a.jsx(H,{ref:t,children:a.jsx(y.Provider,{value:h,children:a.jsx(O,{height:c,innerElementType:"ul",itemCount:s.length,itemData:s,itemSize:g,outerElementType:w,overscanCount:f,ref:m,width:"100%",children:({data:n,index:i,style:p})=>a.jsx(_,{data:n,index:i,setItemSize:x,style:p})})})})}),G=e.memo(v);G.displayName="PickerVirtualizationListBox";const Y=({ariaDescribedBy:u,defaultValue:t,errorMessage:c,errorMessageList:d,hasMultipleChoices:o,hint:h,HintLinkComponent:s,inputValue:r,isFullWidth:l,isOptional:f,isVirtualized:m,label:x,name:g,testId:n,value:i})=>{const p=e.useRef(A({controlledValue:i,uncontrolledValue:t})),C=e.useRef(!!m),L=e.useMemo(()=>o?i===void 0?t:[]:i===void 0?t:void 0,[t,o,i]),E=N({controlState:p.current,defaultValue:L,value:i}),I=e.useMemo(()=>{if(p.current===T.CONTROLLED)return{inputValue:r}},[r]),z=e.useCallback(({InputLabelProps:P,InputProps:S,...R})=>a.jsx(D,{ariaDescribedBy:u,errorMessage:c,errorMessageList:d,fieldType:"single",hasVisibleLabel:!0,hint:h,HintLinkComponent:s,id:P.htmlFor,isFullWidth:l,isOptional:f,label:x,renderFieldComponent:({ariaDescribedBy:j,id:b,errorMessageElementId:V,labelElementId:B})=>a.jsx(k,{...R,...S,"aria-describedby":j,id:b,inputProps:{...R.inputProps,"aria-errormessage":V,"aria-labelledby":B,"data-se":n},name:g??b,required:!f})}),[u,c,d,h,s,l,f,x,g,n]);return{inputValueProp:I,isVirtualizedRef:C,renderInput:z,valueProps:E}};export{G as M,Y as u};
