@alexgorbatchev/shadcn 0.0.0-stage → 0.0.12

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.
Files changed (158) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +349 -2
  3. package/THIRD_PARTY_NOTICES.md +105 -0
  4. package/dist/chunk-1j2hz3w9.js +16 -0
  5. package/dist/chunk-5wvvqege.js +259 -0
  6. package/dist/chunk-8a7dn9ps.js +93 -0
  7. package/dist/chunk-cp2m7y7v.js +26 -0
  8. package/dist/chunk-jpvw9xqy.js +4 -0
  9. package/dist/chunk-rajgnfbr.js +24 -0
  10. package/dist/chunk-rjjwytbx.js +12 -0
  11. package/dist/chunk-tnktkgvp.js +63 -0
  12. package/dist/chunk-z1fy613d.js +64 -0
  13. package/dist/components/Accordion.d.ts +12 -0
  14. package/dist/components/Alert.d.ts +15 -0
  15. package/dist/components/AlertDialog.d.ts +28 -0
  16. package/dist/components/AspectRatio.d.ts +5 -0
  17. package/dist/components/Attachment.d.ts +36 -0
  18. package/dist/components/Avatar.d.ts +19 -0
  19. package/dist/components/Badge.d.ts +15 -0
  20. package/dist/components/Breadcrumb.d.ts +18 -0
  21. package/dist/components/Bubble.d.ts +25 -0
  22. package/dist/components/Button.d.ts +13 -0
  23. package/dist/components/ButtonGroup.d.ts +14 -0
  24. package/dist/components/Card.d.ts +19 -0
  25. package/dist/components/Checkbox.d.ts +6 -0
  26. package/dist/components/Collapsible.d.ts +6 -0
  27. package/dist/components/Combobox.d.ts +39 -0
  28. package/dist/components/ConfirmationDialog.d.ts +11 -0
  29. package/dist/components/ContextMenu.d.ts +24 -0
  30. package/dist/components/DensityProvider.d.ts +7 -0
  31. package/dist/components/Dialog.d.ts +25 -0
  32. package/dist/components/DirectionProvider.d.ts +1 -0
  33. package/dist/components/DragDropPreview.d.ts +7 -0
  34. package/dist/components/DragDropProvider.d.ts +6 -0
  35. package/dist/components/DragSource.d.ts +10 -0
  36. package/dist/components/Drawer.d.ts +25 -0
  37. package/dist/components/DropTarget.d.ts +11 -0
  38. package/dist/components/DropdownMenu.d.ts +26 -0
  39. package/dist/components/Empty.d.ts +19 -0
  40. package/dist/components/EmptyState.d.ts +8 -0
  41. package/dist/components/Field.d.ts +36 -0
  42. package/dist/components/HoverCard.d.ts +8 -0
  43. package/dist/components/ImagePicker.d.ts +11 -0
  44. package/dist/components/InlineEdit.d.ts +14 -0
  45. package/dist/components/Input.d.ts +6 -0
  46. package/dist/components/InputGroup.d.ts +26 -0
  47. package/dist/components/Item.d.ts +32 -0
  48. package/dist/components/JsonViewer.d.ts +8 -0
  49. package/dist/components/Kbd.d.ts +7 -0
  50. package/dist/components/Label.d.ts +5 -0
  51. package/dist/components/Marker.d.ts +19 -0
  52. package/dist/components/Menubar.d.ts +29 -0
  53. package/dist/components/Message.d.ts +17 -0
  54. package/dist/components/NativeSelect.d.ts +11 -0
  55. package/dist/components/NavigationMenu.d.ts +21 -0
  56. package/dist/components/Pagination.d.ts +21 -0
  57. package/dist/components/Popover.d.ts +14 -0
  58. package/dist/components/Progress.d.ts +14 -0
  59. package/dist/components/RadioGroup.d.ts +9 -0
  60. package/dist/components/ScrollArea.d.ts +10 -0
  61. package/dist/components/Select.d.ts +25 -0
  62. package/dist/components/Separator.d.ts +8 -0
  63. package/dist/components/Sheet.d.ts +20 -0
  64. package/dist/components/Sidebar.d.ts +60 -0
  65. package/dist/components/Skeleton.d.ts +5 -0
  66. package/dist/components/Slider.d.ts +6 -0
  67. package/dist/components/Spinner.d.ts +5 -0
  68. package/dist/components/StarRating.d.ts +10 -0
  69. package/dist/components/Switch.d.ts +8 -0
  70. package/dist/components/Table.d.ts +28 -0
  71. package/dist/components/Tabs.d.ts +16 -0
  72. package/dist/components/Textarea.d.ts +5 -0
  73. package/dist/components/ThemeProvider.d.ts +9 -0
  74. package/dist/components/Toast.d.ts +18 -0
  75. package/dist/components/Toggle.d.ts +11 -0
  76. package/dist/components/ToggleGroup.d.ts +12 -0
  77. package/dist/components/Tooltip.d.ts +9 -0
  78. package/dist/components/calendar/Calendar.d.ts +6 -0
  79. package/dist/components/calendar/getCalendarClassNames.d.ts +3 -0
  80. package/dist/components/calendar/index.d.ts +1 -0
  81. package/dist/components/calendar/index.js +10 -0
  82. package/dist/components/calendar/types.d.ts +9 -0
  83. package/dist/components/carousel/Carousel.d.ts +9 -0
  84. package/dist/components/carousel/CarouselContext.d.ts +2 -0
  85. package/dist/components/carousel/hooks/useCarousel.d.ts +2 -0
  86. package/dist/components/carousel/index.d.ts +3 -0
  87. package/dist/components/carousel/index.js +207 -0
  88. package/dist/components/carousel/types.d.ts +23 -0
  89. package/dist/components/chart/Chart.d.ts +10 -0
  90. package/dist/components/chart/ChartContext.d.ts +2 -0
  91. package/dist/components/chart/ChartStyle.d.ts +3 -0
  92. package/dist/components/chart/getPayloadConfigFromPayload.d.ts +2 -0
  93. package/dist/components/chart/hooks/useChart.d.ts +2 -0
  94. package/dist/components/chart/index.d.ts +3 -0
  95. package/dist/components/chart/index.js +284 -0
  96. package/dist/components/chart/types.d.ts +50 -0
  97. package/dist/components/command/Command.d.ts +21 -0
  98. package/dist/components/command/index.d.ts +1 -0
  99. package/dist/components/command/index.js +142 -0
  100. package/dist/components/input-otp/InputOTP.d.ts +12 -0
  101. package/dist/components/input-otp/index.d.ts +1 -0
  102. package/dist/components/input-otp/index.js +303 -0
  103. package/dist/components/message-scroller/MessageScroller.d.ts +16 -0
  104. package/dist/components/message-scroller/hooks/useMessageScroller.d.ts +1 -0
  105. package/dist/components/message-scroller/hooks/useMessageScrollerScrollable.d.ts +1 -0
  106. package/dist/components/message-scroller/hooks/useMessageScrollerVisibility.d.ts +1 -0
  107. package/dist/components/message-scroller/index.d.ts +5 -0
  108. package/dist/components/message-scroller/index.js +600 -0
  109. package/dist/components/persian-calendar/PersianCalendar.d.ts +6 -0
  110. package/dist/components/persian-calendar/index.d.ts +1 -0
  111. package/dist/components/persian-calendar/index.js +36 -0
  112. package/dist/components/questionnaire/Questionnaire.d.ts +20 -0
  113. package/dist/components/questionnaire/index.d.ts +2 -0
  114. package/dist/components/questionnaire/index.js +747 -0
  115. package/dist/components/resizable/Resizable.d.ts +10 -0
  116. package/dist/components/resizable/SplitView.d.ts +12 -0
  117. package/dist/components/resizable/index.d.ts +2 -0
  118. package/dist/components/resizable/index.js +147 -0
  119. package/dist/components/sonner/Sonner.d.ts +7 -0
  120. package/dist/components/sonner/hooks/useSonner.d.ts +1 -0
  121. package/dist/components/sonner/index.d.ts +2 -0
  122. package/dist/components/sonner/index.js +1273 -0
  123. package/dist/density/DensityContext.d.ts +2 -0
  124. package/dist/density/types.d.ts +4 -0
  125. package/dist/drag-drop/DragDropContext.d.ts +2 -0
  126. package/dist/drag-drop/types.d.ts +45 -0
  127. package/dist/drawer/DrawerContext.d.ts +2 -0
  128. package/dist/drawer/types.d.ts +7 -0
  129. package/dist/fonts.css +1 -0
  130. package/dist/hooks/useComboboxAnchor.d.ts +2 -0
  131. package/dist/hooks/useDensity.d.ts +2 -0
  132. package/dist/hooks/useDragDrop.d.ts +2 -0
  133. package/dist/hooks/useDragSource.d.ts +2 -0
  134. package/dist/hooks/useDrawer.d.ts +2 -0
  135. package/dist/hooks/useDropTarget.d.ts +2 -0
  136. package/dist/hooks/useMediaQuery.d.ts +1 -0
  137. package/dist/hooks/useObjectURL.d.ts +1 -0
  138. package/dist/hooks/useSidebar.d.ts +2 -0
  139. package/dist/hooks/useTheme.d.ts +2 -0
  140. package/dist/hooks/useToastManager.d.ts +2 -0
  141. package/dist/index.d.ts +82 -0
  142. package/dist/index.js +4908 -0
  143. package/dist/menu/types.d.ts +14 -0
  144. package/dist/message/MessageContext.d.ts +2 -0
  145. package/dist/message/types.d.ts +7 -0
  146. package/dist/sidebar/SidebarContext.d.ts +2 -0
  147. package/dist/sidebar/types.d.ts +32 -0
  148. package/dist/theme/ThemeContext.d.ts +2 -0
  149. package/dist/theme/types.d.ts +8 -0
  150. package/dist/theme.css +454 -0
  151. package/dist/toggle-group/ToggleGroupContext.d.ts +2 -0
  152. package/dist/toggle-group/types.d.ts +5 -0
  153. package/dist/typeset.css +444 -0
  154. package/dist/utils/cn.d.ts +2 -0
  155. package/package.json +193 -4
  156. package/patches/@shadcn%2Freact@0.3.1.patch +35 -0
  157. package/patches/input-otp@1.5.0.patch +20 -0
  158. package/patches/sonner@2.0.8.patch +87 -0
@@ -0,0 +1,35 @@
1
+ diff --git a/node_modules/@shadcn/react/.bun-tag-4d6ed6b90ab5ee83 b/.bun-tag-4d6ed6b90ab5ee83
2
+ new file mode 100644
3
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
4
+ diff --git a/node_modules/@shadcn/react/.bun-tag-8345adf9169f1ef7 b/.bun-tag-8345adf9169f1ef7
5
+ new file mode 100644
6
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
7
+ diff --git a/node_modules/@shadcn/react/.bun-tag-87cb917473cec6a b/.bun-tag-87cb917473cec6a
8
+ new file mode 100644
9
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
10
+ diff --git a/node_modules/@shadcn/react/.bun-tag-a9a0e11f24a07e83 b/.bun-tag-a9a0e11f24a07e83
11
+ new file mode 100644
12
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
13
+ diff --git a/node_modules/@shadcn/react/.bun-tag-ea8a96194e675a1b b/.bun-tag-ea8a96194e675a1b
14
+ new file mode 100644
15
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
16
+ diff --git a/dist/message-scroller/index.js b/dist/message-scroller/index.js
17
+ index ba994f34a6286cc533f388f61de59b5948a290b9..25938fcec2e9f6b52985ed8b754d3517e45fbbd8 100644
18
+ --- a/dist/message-scroller/index.js
19
+ +++ b/dist/message-scroller/index.js
20
+ @@ -1,2 +1,2 @@
21
+ "use client";
22
+ -import {c,a,b}from'../chunk-HBS6WEDP.js';import*as f from'react';import {jsx,jsxs}from'react/jsx-runtime';var _e=8,Be=64,Fe=0,J=.5,je=180,Ge=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),ge={start:false,end:false},vt=[],Q={currentAnchorId:null,visibleMessageIds:vt};function Ne({content:e,scrollEdgeThreshold:t,spacer:r,viewport:n}){if(!n||!e)return ge;let l=Re({content:e,spacer:r,viewport:n});return {start:n.scrollTop>t,end:l-n.scrollTop-n.clientHeight>t}}function Ue({content:e,scrollMargin:t,scrollPreviousItemPeek:r,spacer:n,viewport:l,visibleMessageIds:c}){if(!e||!l)return Q;let S=l.getBoundingClientRect(),o=S.top+t+r,b=typeof IntersectionObserver>"u",v=[],m=null;for(let L of ee(e,n)){let R=L.dataset.messageId;if(!R)continue;let E=L.dataset.scrollAnchor==="true",h=E||b?L.getBoundingClientRect():null;(b&&h?h.bottom>o&&h.top<S.bottom:c.has(R))&&v.push(R),E&&h&&h.top<=o+J&&(m=R);}return v.length===0&&m===null?Q:{currentAnchorId:m,visibleMessageIds:v}}function ee(e,t){return Array.from(e.children).filter(r=>r instanceof HTMLElement&&r!==t)}function Ye(e,t){for(let r=t;r<e.length;r++){let n=e[r];if(n?.dataset.scrollAnchor==="true")return n}return null}function ze(e,t){for(let r of e)if(r.dataset.scrollAnchor==="true"&&!t.has(r))return r;return null}function qe(e,t){let r=0;for(let n=t;n<e.length;n++)if(e[n]?.dataset.scrollAnchor==="true"&&(r+=1,r>1))return true;return false}function Ke(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(r?.dataset.scrollAnchor==="true")return r}return null}function We({content:e,spacer:t,viewport:r}){let n=r.getBoundingClientRect();for(let l of ee(e,t)){if(!l.dataset.messageId)continue;let c=l.getBoundingClientRect();if(c.bottom>n.top&&c.top<n.bottom)return l}return null}function $e({align:e,element:t,scrollMargin:r,spacer:n,viewport:l}){let c=me(t,l),S=t.getBoundingClientRect().height,o=ht(n);if(e==="center"){let b=Math.max(0,l.clientHeight-o.start-o.end);return c-o.start-(b-S)/2-r}if(e==="end")return c-l.clientHeight+S+o.end+r;if(e==="nearest"){let b=c+S,v=l.scrollTop+o.start,m=l.scrollTop+l.clientHeight-o.end;return c>=v&&b<=m?l.scrollTop:c<v?c-o.start-r:b-l.clientHeight+o.end+r}return c-o.start-r}function me(e,t){let r=e.getBoundingClientRect(),n=t.getBoundingClientRect();return r.top-n.top+t.scrollTop}function te(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function Je({content:e,scrollTop:t,spacer:r,viewport:n}){let l=Re({content:e,spacer:r,viewport:n});return t+n.clientHeight-l}function Re({content:e,spacer:t,viewport:r}){let n=ee(e,t),l=Xe(e),c=r.getBoundingClientRect(),S=r.scrollTop,o=l.start+l.end;for(let b of n){let v=b.getBoundingClientRect();o=Math.max(o,v.bottom-c.top+S+l.end);}return o}function Qe(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Xe(e){let t=window.getComputedStyle(e);return {end:pe(t.paddingBlockEnd||t.paddingBottom),start:pe(t.paddingBlockStart||t.paddingTop)}}function ht(e){let t=e?.parentElement;return t?Xe(t):{end:0,start:0}}function Ze(e){if(!e)return 0;let t=window.getComputedStyle(e),r=t.rowGap==="normal"?t.gap:t.rowGap;return pe(r)}function pe(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function et(e,t){let r=e,n=new Set;return {getSnapshot:()=>r,hasListeners:()=>n.size>0,setSnapshot:l=>{t(r,l)||(r=l,n.forEach(c=>c()));},subscribe:(l,c,S)=>{let o=n.size===0;return n.add(l),o&&c?.(),()=>{n.delete(l),n.size===0&&S?.();}}}}function de(e,t){return et(e,t)}function tt(){return et(Q,Lt)}function rt(e,t){return e.start===t.start&&e.end===t.end}function Lt(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?false:e.visibleMessageIds.every((r,n)=>r===t.visibleMessageIds[n])}function nt({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:r,scrollMargin:n,scrollPreviousItemPeek:l}){let c=f.useRef(e),S=f.useRef(false),o=f.useRef(null),b=f.useRef(false),v=f.useRef(r),m=f.useRef(0),L=f.useRef(null),R=f.useRef(0),E=f.useRef(e?"following-bottom":"free-scrolling"),h=f.useRef(new Map),I=f.useRef(null),u=f.useRef(null),k=f.useRef(null),j=f.useRef(l),_=f.useRef(true),Y=f.useRef(null),x=f.useRef(n),V=f.useRef(null),P=f.useRef(0),G=f.useRef(0),A=f.useRef(null),le=f.useRef(null),z=f.useRef(null),B=f.useRef(null),i=f.useRef(null),d=f.useRef(null),T=f.useRef(null),w=f.useRef(null),C=f.useRef(null),y=f.useRef(new Set),F=f.useRef(new WeakSet);return z.current===null&&(z.current=de(t==="end"||t==="last-anchor",(q,X)=>q===X)),B.current===null&&(B.current=de(ge,rt)),C.current===null&&(C.current=tt()),c.current=e,v.current=r,x.current=n,j.current=l,{autoScrollRef:c,autoscrollingRef:S,autoscrollingTimeoutRef:i,streamingTurnRef:k,contentRef:o,defaultScrollPositionAppliedRef:b,firstItemRef:L,itemCountRef:m,lastScrollTopRef:R,messageElementsRef:h,modeRef:E,pendingScrollFrameRef:V,pendingScrollToMessageRef:I,prependRestoreRef:u,preserveScrollOnPrependRef:_,pendingDefaultScrollStore:z.current,rootRef:Y,scrollEdgeThresholdRef:v,scrollMarginRef:x,scrollPreviousItemPeekRef:j,spacerGapRef:P,spacerHeightRef:G,spacerRef:A,stateFrameRef:le,stateStore:B.current,viewportRef:d,visibilityFrameRef:T,visibilityObserverRef:w,visibilityStore:C.current,visibleMessageIdsRef:y,handledScrollAnchorsRef:F}}function Me(e){e.pendingDefaultScrollStore.setSnapshot(false);}function re(e){e.defaultScrollPositionAppliedRef.current=true,Me(e);}function lt({refs:e,commitScrollState:t,scheduleStateCommit:r,scheduleVisibilitySync:n}){let{streamingTurnRef:l,autoScrollRef:c,autoscrollingRef:S,autoscrollingTimeoutRef:o,contentRef:b,itemCountRef:v,messageElementsRef:m,modeRef:L,pendingScrollToMessageRef:R,prependRestoreRef:E,scrollMarginRef:h,scrollPreviousItemPeekRef:I,spacerGapRef:u,spacerHeightRef:k,spacerRef:j,viewportRef:_}=e,Y=f.useCallback(i=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null),S.current!==i&&(S.current=i,t()),i&&(o.current=window.setTimeout(()=>{o.current=null,S.current=false,t();},je));},[t]),x=f.useCallback(i=>{let d=j.current;if(!d)return;let T=Math.max(0,Math.ceil(i));k.current!==T&&(k.current=T,d.hidden=T===0,d.style.height=`${T}px`,d.style.marginTop=T>0?`${-u.current}px`:"");},[]),V=f.useCallback((i,{behavior:d="auto",autoscrolling:T=false}={})=>{let w=_.current;if(!w)return;let C=Math.max(0,i);if(Math.abs(w.scrollTop-C)<=J){w.scrollTop=C,t();return}T&&Y(true),w.scrollTo({top:C,behavior:d}),r();},[t,r,Y]),P=f.useCallback(({behavior:i="auto"}={})=>_.current?(x(0),l.current=null,L.current="free-scrolling",V(0,{behavior:i}),n(),true):false,[n,V,x]),G=f.useCallback(({behavior:i="auto"}={})=>{let d=_.current;return d?(x(0),l.current=null,L.current=c.current?"following-bottom":"free-scrolling",V(Qe(d),{autoscrolling:true,behavior:i}),n(),true):false},[n,V,x]),A=f.useCallback((i,{align:d="start",behavior:T="auto",scrollMargin:w=h.current}={},{keepPreviousPeek:C=false}={})=>{let y=b.current,F=_.current;if(!y||!F||!y.contains(i))return false;let q=$e({align:d,element:i,scrollMargin:C?w+I.current:w,spacer:j.current,viewport:F}),X=Je({content:y,scrollTop:q,spacer:j.current,viewport:F});return x(X),E.current={element:i,viewportTop:te(i,F)},L.current=C?"anchored-to-message":"settling-jump",l.current=C?i:null,V(q,{behavior:T}),n(),true},[n,V,x]),le=f.useCallback(()=>{let i=l.current;return !i||!i.isConnected||L.current!=="anchored-to-message"?false:A(i,{align:"start"},{keepPreviousPeek:true})},[A]),z=f.useCallback((i,d)=>{let T=m.current.get(i);return T?(re(e),A(T,d)?(R.current=null,true):(R.current={messageId:i,options:d},true)):v.current===0?(R.current={messageId:i,options:d},re(e),true):false},[A]);return {flushPendingScrollToMessage:f.useCallback(()=>{let i=R.current;if(!i)return false;let d=m.current.get(i.messageId);return !d||!A(d,i.options)?false:(R.current=null,re(e),true)},[A]),reanchorToAnchoredMessage:le,scrollToElement:A,scrollToEnd:G,scrollToMessage:z,scrollToStart:P}}function ot(e,t){return f.useCallback(r=>{e.current=r,r&&t();},[e,t])}function st({autoScroll:e=false,defaultScrollPosition:t="end",scrollEdgeThreshold:r=_e,scrollPreviousItemPeek:n=Be,scrollMargin:l=Fe}){let c=nt({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:r,scrollMargin:l,scrollPreviousItemPeek:n}),{streamingTurnRef:S,autoScrollRef:o,autoscrollingRef:b,autoscrollingTimeoutRef:v,contentRef:m,defaultScrollPositionAppliedRef:L,firstItemRef:R,itemCountRef:E,lastScrollTopRef:h,messageElementsRef:I,modeRef:u,pendingScrollFrameRef:k,pendingScrollToMessageRef:j,prependRestoreRef:_,preserveScrollOnPrependRef:Y,pendingDefaultScrollStore:x,rootRef:V,scrollEdgeThresholdRef:P,scrollMarginRef:G,scrollPreviousItemPeekRef:A,spacerGapRef:le,spacerHeightRef:z,spacerRef:B,stateFrameRef:i,stateStore:d,viewportRef:T,visibilityFrameRef:w,visibilityObserverRef:C,visibilityStore:y,visibleMessageIdsRef:F,handledScrollAnchorsRef:q}=c,X=f.useRef(t);X.current!==t&&(X.current=t,L.current=false);let ce=f.useCallback(s=>{let a=V.current,M=T.current,H=[s.start&&"start",s.end&&"end"].filter(Boolean).join(" "),fe=b.current;for(let W of [a,M])W&&(H?W.setAttribute("data-scrollable",H):W.removeAttribute("data-scrollable"),W.toggleAttribute("data-autoscrolling",fe));},[]),be=f.useCallback(s=>{let a=T.current?.scrollTop??0,M=a<h.current-J;h.current=a,o.current&&!s.end&&u.current!=="settling-jump"&&u.current!=="anchored-to-message"?u.current="following-bottom":u.current==="following-bottom"&&s.end&&M&&!b.current&&(u.current="free-scrolling");},[]),N=f.useCallback(()=>{let s=Ne({content:m.current,scrollEdgeThreshold:P.current,spacer:B.current,viewport:T.current});be(s);let a=u.current==="following-bottom"?{...s,end:false}:s;ce(a),d.setSnapshot(a);},[be,d,ce]),oe=f.useCallback(()=>{i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,N();}));},[N]),O=f.useCallback(()=>{y.hasListeners()&&w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null,y.hasListeners()&&y.setSnapshot(Ue({content:m.current,scrollMargin:G.current,scrollPreviousItemPeek:A.current,spacer:B.current,viewport:T.current,visibleMessageIds:F.current}));}));},[y]),{flushPendingScrollToMessage:ae,reanchorToAnchoredMessage:Te,scrollToElement:se,scrollToEnd:D,scrollToMessage:Ee,scrollToStart:ie}=lt({refs:c,commitScrollState:N,scheduleStateCommit:oe,scheduleVisibilitySync:O}),ve=f.useCallback(()=>{let s=_.current,a=T.current;if(!s||!a||!s.element.isConnected)return false;let H=te(s.element,a)-s.viewportTop;return Math.abs(H)<=J?false:(a.scrollTop+=H,s.viewportTop=te(s.element,a),oe(),O(),true)},[oe,O]),Z=f.useCallback(()=>{let s=m.current,a=T.current;if(!s||!a){_.current=null;return}let M=We({content:s,spacer:B.current,viewport:a});_.current=M?{element:M,viewportTop:te(M,a)}:null;},[]),he=f.useCallback(()=>{k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,ae()&&Z();}));},[Z,ae]),ue=f.useCallback(()=>{if(!t||L.current||E.current===0)return false;let s=false;if(t==="last-anchor"){let a=m.current,M=T.current,H=a&&M?Ke(ee(a,B.current)):null;if(!a||!M||!H)s=D({behavior:"auto"});else {let fe=me(H,M);s=Re({content:a,spacer:B.current,viewport:M})-fe<=M.clientHeight?D({behavior:"auto"}):se(H,{align:"start"},{keepPreviousPeek:true});}}else s=t==="end"?D({behavior:"auto"}):ie({behavior:"auto"});return s?(re(c),true):false},[t,se,D,ie]),Le=f.useCallback(()=>{let s=m.current;if(!s)return;let a=ee(s,B.current),M=E.current,H=R.current;E.current=a.length,R.current=a[0]??null,(()=>{if(ae())return;if(M===0){if(ue()||a.length>0&&o.current&&D({behavior:"auto"}))return;N(),O();return}let W=H?a.indexOf(H):-1;if(Y.current&&W>0){ve();return}if(a.length>M){let $=Ye(a,M);if($){if(o.current&&u.current==="following-bottom"&&qe(a,M)){D({behavior:"auto"});return}se($,{align:"start"},{keepPreviousPeek:true}),q.current.add($);return}}if(a.length===M){let $=ze(a,q.current);if($){se($,{align:"start"},{keepPreviousPeek:true}),q.current.add($);return}}u.current==="following-bottom"&&o.current?D({behavior:"auto"}):(N(),O());})(),Z();},[ue,Z,N,ae,ve,O,se,D]),Ce=f.useCallback(()=>{if(u.current==="following-bottom"&&o.current){D({behavior:"auto"});return}let s=z.current;if(Te()){o.current&&s>0&&z.current===0&&D({behavior:"auto"});return}oe(),O();},[Te,oe,O,D]),Pe=f.useCallback(()=>{let s=T.current;if(!(!s||!y.hasListeners())){if(typeof IntersectionObserver>"u"){O();return}C.current||(C.current=new IntersectionObserver(a=>{for(let M of a){let H=M.target.dataset.messageId;H&&(M.isIntersecting?F.current.add(H):F.current.delete(H));}O();},{root:s,rootMargin:`${-(G.current+A.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),I.current.forEach(a=>{C.current?.observe(a);}),O();}},[O,y]),we=f.useCallback(()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),C.current?.disconnect(),C.current=null,F.current.clear(),y.setSnapshot(Q);},[y]),bt=f.useCallback((s,a,M)=>{if(a){I.current.set(s,a),C.current?.observe(a),O(),j.current?.messageId===s&&he();return}M&&I.current.get(s)===M&&(I.current.delete(s),F.current.delete(s),C.current?.unobserve(M),O());},[he,O]),Oe=f.useCallback(()=>{(u.current==="following-bottom"||u.current==="anchored-to-message"||u.current==="settling-jump")&&(S.current=null,u.current="free-scrolling");},[]),ye=f.useCallback(()=>ce(d.getSnapshot()),[d,ce]),He=ot(V,ye),Ie=ot(T,ye),Ae=f.useCallback(s=>{m.current=s;},[]),De=f.useCallback(s=>{B.current=s,le.current=Ze(s?.parentElement??null);},[]),xe=f.useCallback(()=>{N(),O(),Z();},[Z,N,O]),Tt=f.useMemo(()=>({handleContentChange:Le,handleResize:Ce,observeVisibility:Pe,pendingDefaultScrollStore:x,preserveScrollOnPrependRef:Y,scrollToEnd:D,scrollToMessage:Ee,scrollToStart:ie,setContentElement:Ae,setRootElement:He,setSpacerElement:De,setViewportElement:Ie,stateStore:d,syncAfterScroll:xe,unobserveVisibility:we,userScrollIntent:Oe,viewportRef:T,visibilityStore:y}),[Le,Ce,Pe,x,D,Ee,ie,Ae,He,De,Ie,d,xe,we,Oe,y]);return f.useLayoutEffect(()=>{ue()||E.current===0&&Me(c);},[ue]),f.useEffect(()=>()=>{i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),v.current!==null&&(window.clearTimeout(v.current),v.current=null),k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),C.current?.disconnect(),C.current=null;},[]),f.useLayoutEffect(()=>{if(e&&u.current==="following-bottom"&&E.current>0){D({behavior:"auto"});return}N();},[e,N,D]),{context:Tt,registerMessage:bt}}function at(e){let t=f.useRef(e);return t.current=e,t}var it=f.createContext(null),ut=f.createContext(null);function K(){let e=f.useContext(it);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Ct(){let e=f.useContext(ut);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Pt(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:r}=K();return f.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:r}),[e,t,r])}function wt(){let{stateStore:e}=K();return f.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Ot(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:r}=K(),n=f.useCallback(l=>r.subscribe(l,e,t),[e,t,r]);return f.useSyncExternalStore(n,r.getSnapshot,r.getSnapshot)}function ft({autoScroll:e=false,children:t,defaultScrollPosition:r="end",scrollEdgeThreshold:n,scrollPreviousItemPeek:l,scrollMargin:c}){let{context:S,registerMessage:o}=st({autoScroll:e,defaultScrollPosition:r,scrollEdgeThreshold:n,scrollPreviousItemPeek:l,scrollMargin:c});return jsx(it.Provider,{value:S,children:jsx(ut.Provider,{value:o,children:t})})}function St(){let{pendingDefaultScrollStore:e}=K();return f.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function gt({children:e,...t}){let{setRootElement:r}=K(),n=St();return jsx("div",{ref:r,...t,...n?{"data-pending-scroll":""}:null,children:e})}function Rt({"aria-label":e,children:t,onKeyDown:r,onScroll:n,onTouchMove:l,onWheel:c$1,preserveScrollOnPrepend:S=true,ref:o,role:b,tabIndex:v,...m}){let{handleResize:L,preserveScrollOnPrependRef:R,setViewportElement:E,syncAfterScroll:h,userScrollIntent:I,viewportRef:u}=K(),k=St();R.current=S;let j=f.useCallback(P=>{E(P),c(o)?.(P);},[o,E]);function _(P){h(),n?.(P);}function Y(P){I(),c$1?.(P);}function x(P){I(),l?.(P);}function V(P){Ge.has(P.key)&&I(),r?.(P);}return f.useEffect(()=>{let P=u.current;if(!P||typeof ResizeObserver>"u")return;let G=0,A=new ResizeObserver(()=>{window.cancelAnimationFrame(G),G=window.requestAnimationFrame(L);});return A.observe(P),()=>{window.cancelAnimationFrame(G),A.disconnect();}},[L,u]),jsx("div",{ref:j,role:b??"region","aria-label":e??"Messages",tabIndex:v??0,onKeyDown:V,onScroll:_,onTouchMove:x,onWheel:Y,...m,...k?{"data-pending-scroll":""}:null,children:t})}function pt({"aria-relevant":e,children:t,ref:r,role:n,spacerClassName:l,...c$1}){let{handleContentChange:S,handleResize:o,setContentElement:b,setSpacerElement:v}=K(),m=f.useRef(null),L=f.useCallback(R=>{m.current=R,b(R),c(r)?.(R);},[r,b]);return f.useLayoutEffect(()=>{let R=m.current;if(!R||(S(),typeof MutationObserver>"u"))return;let E=new MutationObserver(()=>{S();});return E.observe(R,{childList:true}),()=>E.disconnect()},[S]),f.useEffect(()=>{let R=m.current;if(!R||typeof ResizeObserver>"u")return;let E=0,h=new ResizeObserver(()=>{window.cancelAnimationFrame(E),E=window.requestAnimationFrame(o);});return h.observe(R),()=>{window.cancelAnimationFrame(E),h.disconnect();}},[o]),jsxs("div",{ref:L,role:n??"log","aria-relevant":e??"additions",...c$1,children:[t,jsx("div",{ref:v,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:true,className:l})]})}function mt({messageId:e,ref:t,scrollAnchor:r=false,...n}){let l=Ct(),c$1=f.useRef(null),S=f.useCallback(o=>{let b=c$1.current;c$1.current=o,e&&l(e,o,b),c(t)?.(o);},[e,t,l]);return jsx("div",{ref:S,"data-message-id":e,"data-scroll-anchor":r?"true":"false",...n})}function dt({behavior:e="smooth",children:t,direction:r="end",onClick:n,render:l,tabIndex:c,type:S="button",...o}){let{scrollToEnd:b$1,scrollToStart:v,stateStore:m}=K(),L=at(n),R=f.useCallback(u=>m.subscribe(u),[m]),E=f.useCallback(()=>{let u=m.getSnapshot();return r==="start"?u.start:u.end},[r,m]),h=f.useSyncExternalStore(R,E,E),I=f.useCallback(u=>{h&&(L.current?.(u),u.defaultPrevented||(u.currentTarget.blur(),r==="start"?v({behavior:e}):b$1({behavior:e})));},[e,r,h,L,b$1,v]);return a({defaultTagName:"button",props:b({type:S,inert:!h,tabIndex:h?c:-1,children:t??jsxs("span",{children:["Scroll to ",r]}),onClick:I},o),render:l,state:{active:h,direction:r},stateAttributesMapping:{active:u=>({"data-active":u?"true":"false"})}})}var er={Provider:ft,Root:gt,Viewport:Rt,Content:pt,Item:mt,Button:dt};export{er as MessageScroller,Pt as useMessageScroller,wt as useMessageScrollerScrollable,Ot as useMessageScrollerVisibility};
23
+
24
+ +import {c,a,b}from'../chunk-HBS6WEDP.js';import*as f from'react';import {jsx,jsxs}from'react/jsx-runtime';var _e=8,Be=64,Fe=0,J=.5,je=180,Ge=new Set(["ArrowDown","ArrowUp","End","Home","PageDown","PageUp"," "]),ge={start:false,end:false},vt=[],Q={currentAnchorId:null,visibleMessageIds:vt};function Ne({content:e,scrollEdgeThreshold:t,spacer:r,viewport:n}){if(!n||!e)return ge;let l=Re({content:e,spacer:r,viewport:n});return {start:n.scrollTop>t,end:l-n.scrollTop-n.clientHeight>t}}function Ue({content:e,scrollMargin:t,scrollPreviousItemPeek:r,spacer:n,viewport:l,visibleMessageIds:c}){if(!e||!l)return Q;let S=l.getBoundingClientRect(),o=S.top+t+r,b=typeof IntersectionObserver>"u",v=[],m=null;for(let L of ee(e,n)){let R=L.dataset.messageId;if(!R)continue;let E=L.dataset.scrollAnchor==="true",h=E||b?L.getBoundingClientRect():null;(b&&h?h.bottom>o&&h.top<S.bottom:c.has(R))&&v.push(R),E&&h&&h.top<=o+J&&(m=R);}return v.length===0&&m===null?Q:{currentAnchorId:m,visibleMessageIds:v}}function ee(e,t){return Array.from(e.children).filter(r=>r instanceof HTMLElement&&r!==t)}function Ye(e,t){for(let r=t;r<e.length;r++){let n=e[r];if(n?.dataset.scrollAnchor==="true")return n}return null}function ze(e,t){for(let r of e)if(r.dataset.scrollAnchor==="true"&&!t.has(r))return r;return null}function qe(e,t){let r=0;for(let n=t;n<e.length;n++)if(e[n]?.dataset.scrollAnchor==="true"&&(r+=1,r>1))return true;return false}function Ke(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(r?.dataset.scrollAnchor==="true")return r}return null}function We({content:e,spacer:t,viewport:r}){let n=r.getBoundingClientRect();for(let l of ee(e,t)){if(!l.dataset.messageId)continue;let c=l.getBoundingClientRect();if(c.bottom>n.top&&c.top<n.bottom)return l}return null}function $e({align:e,element:t,scrollMargin:r,spacer:n,viewport:l}){let c=me(t,l),S=t.getBoundingClientRect().height,o=ht(n);if(e==="center"){let b=Math.max(0,l.clientHeight-o.start-o.end);return c-o.start-(b-S)/2-r}if(e==="end")return c-l.clientHeight+S+o.end+r;if(e==="nearest"){let b=c+S,v=l.scrollTop+o.start,m=l.scrollTop+l.clientHeight-o.end;return c>=v&&b<=m?l.scrollTop:c<v?c-o.start-r:b-l.clientHeight+o.end+r}return c-o.start-r}function layoutBlockTop(e){let t=e.offsetTop;for(let r=e.offsetParent;r;r=r.offsetParent)t+=r.offsetTop+r.clientTop;return t}function me(e,t){let r=layoutBlockTop(e)-layoutBlockTop(t);for(let n=e.parentElement;n&&n!==t;n=n.parentElement)r-=n.scrollTop;return r}function te(e,t){return me(e,t)-t.scrollTop}function Je({content:e,scrollTop:t,spacer:r,viewport:n}){let l=Re({content:e,spacer:r,viewport:n});return t+n.clientHeight-l}function Re({content:e,spacer:t,viewport:r}){let n=ee(e,t),l=Xe(e),c=r.getBoundingClientRect(),S=r.scrollTop,o=l.start+l.end;for(let b of n){let v=b.getBoundingClientRect();o=Math.max(o,v.bottom-c.top+S+l.end);}return o}function Qe(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function Xe(e){let t=window.getComputedStyle(e);return {end:pe(t.paddingBlockEnd||t.paddingBottom),start:pe(t.paddingBlockStart||t.paddingTop)}}function ht(e){let t=e?.parentElement;return t?Xe(t):{end:0,start:0}}function Ze(e){if(!e)return 0;let t=window.getComputedStyle(e),r=t.rowGap==="normal"?t.gap:t.rowGap;return pe(r)}function pe(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function et(e,t){let r=e,n=new Set;return {getSnapshot:()=>r,hasListeners:()=>n.size>0,setSnapshot:l=>{t(r,l)||(r=l,n.forEach(c=>c()));},subscribe:(l,c,S)=>{let o=n.size===0;return n.add(l),o&&c?.(),()=>{n.delete(l),n.size===0&&S?.();}}}}function de(e,t){return et(e,t)}function tt(){return et(Q,Lt)}function rt(e,t){return e.start===t.start&&e.end===t.end}function Lt(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?false:e.visibleMessageIds.every((r,n)=>r===t.visibleMessageIds[n])}function nt({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:r,scrollMargin:n,scrollPreviousItemPeek:l}){let c=f.useRef(e),S=f.useRef(false),o=f.useRef(null),b=f.useRef(false),v=f.useRef(r),m=f.useRef(0),L=f.useRef(null),R=f.useRef(0),E=f.useRef(e?"following-bottom":"free-scrolling"),h=f.useRef(new Map),I=f.useRef(null),u=f.useRef(null),k=f.useRef(null),j=f.useRef(l),_=f.useRef(true),Y=f.useRef(null),x=f.useRef(n),V=f.useRef(null),P=f.useRef(0),G=f.useRef(0),A=f.useRef(null),le=f.useRef(null),z=f.useRef(null),B=f.useRef(null),i=f.useRef(null),d=f.useRef(null),T=f.useRef(null),w=f.useRef(null),C=f.useRef(null),y=f.useRef(new Set),F=f.useRef(new WeakSet);return z.current===null&&(z.current=de(t==="end"||t==="last-anchor",(q,X)=>q===X)),B.current===null&&(B.current=de(ge,rt)),C.current===null&&(C.current=tt()),c.current=e,v.current=r,x.current=n,j.current=l,{autoScrollRef:c,autoscrollingRef:S,autoscrollingTimeoutRef:i,streamingTurnRef:k,contentRef:o,defaultScrollPositionAppliedRef:b,firstItemRef:L,itemCountRef:m,lastScrollTopRef:R,messageElementsRef:h,modeRef:E,pendingScrollFrameRef:V,pendingScrollToMessageRef:I,prependRestoreRef:u,preserveScrollOnPrependRef:_,pendingDefaultScrollStore:z.current,rootRef:Y,scrollEdgeThresholdRef:v,scrollMarginRef:x,scrollPreviousItemPeekRef:j,spacerGapRef:P,spacerHeightRef:G,spacerRef:A,stateFrameRef:le,stateStore:B.current,viewportRef:d,visibilityFrameRef:T,visibilityObserverRef:w,visibilityStore:C.current,visibleMessageIdsRef:y,handledScrollAnchorsRef:F}}function Me(e){e.pendingDefaultScrollStore.setSnapshot(false);}function re(e){e.defaultScrollPositionAppliedRef.current=true,Me(e);}function lt({refs:e,commitScrollState:t,scheduleStateCommit:r,scheduleVisibilitySync:n}){let{streamingTurnRef:l,autoScrollRef:c,autoscrollingRef:S,autoscrollingTimeoutRef:o,contentRef:b,itemCountRef:v,messageElementsRef:m,modeRef:L,pendingScrollToMessageRef:R,prependRestoreRef:E,scrollMarginRef:h,scrollPreviousItemPeekRef:I,spacerGapRef:u,spacerHeightRef:k,spacerRef:j,viewportRef:_}=e,Y=f.useCallback(i=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null),S.current!==i&&(S.current=i,t()),i&&(o.current=window.setTimeout(()=>{o.current=null,S.current=false,t();},je));},[t]),x=f.useCallback(i=>{let d=j.current;if(!d)return;let T=Math.max(0,Math.ceil(i));k.current!==T&&(k.current=T,d.hidden=T===0,d.style.height=`${T}px`,d.style.marginTop=T>0?`${-u.current}px`:"");},[]),V=f.useCallback((i,{behavior:d="auto",autoscrolling:T=false}={})=>{let w=_.current;if(!w)return;let C=Math.max(0,i);if(Math.abs(w.scrollTop-C)<=J){w.scrollTop=C,t();return}T&&Y(true),w.scrollTo({top:C,behavior:d}),r();},[t,r,Y]),P=f.useCallback(({behavior:i="auto"}={})=>_.current?(x(0),l.current=null,L.current="free-scrolling",V(0,{behavior:i}),n(),true):false,[n,V,x]),G=f.useCallback(({behavior:i="auto"}={})=>{let d=_.current;return d?(x(0),l.current=null,L.current=c.current?"following-bottom":"free-scrolling",V(Qe(d),{autoscrolling:true,behavior:i}),n(),true):false},[n,V,x]),A=f.useCallback((i,{align:d="start",behavior:T="auto",scrollMargin:w=h.current}={},{keepPreviousPeek:C=false}={})=>{let y=b.current,F=_.current;if(!y||!F||!y.contains(i))return false;let q=$e({align:d,element:i,scrollMargin:C?w+I.current:w,spacer:j.current,viewport:F}),X=Je({content:y,scrollTop:q,spacer:j.current,viewport:F});return x(X),E.current={element:i,viewportTop:te(i,F)},L.current=C?"anchored-to-message":"settling-jump",l.current=C?i:null,V(q,{behavior:T}),n(),true},[n,V,x]),le=f.useCallback(()=>{let i=l.current;return !i||!i.isConnected||L.current!=="anchored-to-message"?false:A(i,{align:"start"},{keepPreviousPeek:true})},[A]),z=f.useCallback((i,d)=>{let T=m.current.get(i);return T?(re(e),A(T,d)?(R.current=null,true):(R.current={messageId:i,options:d},true)):v.current===0?(R.current={messageId:i,options:d},re(e),true):false},[A]);return {flushPendingScrollToMessage:f.useCallback(()=>{let i=R.current;if(!i)return false;let d=m.current.get(i.messageId);return !d||!A(d,i.options)?false:(R.current=null,re(e),true)},[A]),reanchorToAnchoredMessage:le,scrollToElement:A,scrollToEnd:G,scrollToMessage:z,scrollToStart:P}}function ot(e,t){return f.useCallback(r=>{e.current=r,r&&t();},[e,t])}function st({autoScroll:e=false,defaultScrollPosition:t="end",scrollEdgeThreshold:r=_e,scrollPreviousItemPeek:n=Be,scrollMargin:l=Fe}){let c=nt({autoScroll:e,defaultScrollPosition:t,scrollEdgeThreshold:r,scrollMargin:l,scrollPreviousItemPeek:n}),{streamingTurnRef:S,autoScrollRef:o,autoscrollingRef:b,autoscrollingTimeoutRef:v,contentRef:m,defaultScrollPositionAppliedRef:L,firstItemRef:R,itemCountRef:E,lastScrollTopRef:h,messageElementsRef:I,modeRef:u,pendingScrollFrameRef:k,pendingScrollToMessageRef:j,prependRestoreRef:_,preserveScrollOnPrependRef:Y,pendingDefaultScrollStore:x,rootRef:V,scrollEdgeThresholdRef:P,scrollMarginRef:G,scrollPreviousItemPeekRef:A,spacerGapRef:le,spacerHeightRef:z,spacerRef:B,stateFrameRef:i,stateStore:d,viewportRef:T,visibilityFrameRef:w,visibilityObserverRef:C,visibilityStore:y,visibleMessageIdsRef:F,handledScrollAnchorsRef:q}=c,X=f.useRef(t);X.current!==t&&(X.current=t,L.current=false);let ce=f.useCallback(s=>{let a=V.current,M=T.current,H=[s.start&&"start",s.end&&"end"].filter(Boolean).join(" "),fe=b.current;for(let W of [a,M])W&&(H?W.setAttribute("data-scrollable",H):W.removeAttribute("data-scrollable"),W.toggleAttribute("data-autoscrolling",fe));},[]),be=f.useCallback(s=>{let a=T.current?.scrollTop??0,M=a<h.current-J;h.current=a,o.current&&!s.end&&u.current!=="settling-jump"&&u.current!=="anchored-to-message"?u.current="following-bottom":u.current==="following-bottom"&&s.end&&M&&!b.current&&(u.current="free-scrolling");},[]),N=f.useCallback(()=>{let s=Ne({content:m.current,scrollEdgeThreshold:P.current,spacer:B.current,viewport:T.current});be(s);let a=u.current==="following-bottom"?{...s,end:false}:s;ce(a),d.setSnapshot(a);},[be,d,ce]),oe=f.useCallback(()=>{i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,N();}));},[N]),O=f.useCallback(()=>{y.hasListeners()&&w.current===null&&(w.current=window.requestAnimationFrame(()=>{w.current=null,y.hasListeners()&&y.setSnapshot(Ue({content:m.current,scrollMargin:G.current,scrollPreviousItemPeek:A.current,spacer:B.current,viewport:T.current,visibleMessageIds:F.current}));}));},[y]),{flushPendingScrollToMessage:ae,reanchorToAnchoredMessage:Te,scrollToElement:se,scrollToEnd:D,scrollToMessage:Ee,scrollToStart:ie}=lt({refs:c,commitScrollState:N,scheduleStateCommit:oe,scheduleVisibilitySync:O}),ve=f.useCallback(()=>{let s=_.current,a=T.current;if(!s||!a||!s.element.isConnected)return false;let H=te(s.element,a)-s.viewportTop;return Math.abs(H)<=J?false:(a.scrollTop+=H,s.viewportTop=te(s.element,a),oe(),O(),true)},[oe,O]),Z=f.useCallback(()=>{let s=m.current,a=T.current;if(!s||!a){_.current=null;return}let M=We({content:s,spacer:B.current,viewport:a});_.current=M?{element:M,viewportTop:te(M,a)}:null;},[]),he=f.useCallback(()=>{k.current===null&&(k.current=window.requestAnimationFrame(()=>{k.current=null,ae()&&Z();}));},[Z,ae]),ue=f.useCallback(()=>{if(!t||L.current||E.current===0)return false;let s=false;if(t==="last-anchor"){let a=m.current,M=T.current,H=a&&M?Ke(ee(a,B.current)):null;if(!a||!M||!H)s=D({behavior:"auto"});else {let fe=me(H,M);s=Re({content:a,spacer:B.current,viewport:M})-fe<=M.clientHeight?D({behavior:"auto"}):se(H,{align:"start"},{keepPreviousPeek:true});}}else s=t==="end"?D({behavior:"auto"}):ie({behavior:"auto"});return s?(re(c),true):false},[t,se,D,ie]),Le=f.useCallback(()=>{let s=m.current;if(!s)return;let a=ee(s,B.current),M=E.current,H=R.current;E.current=a.length,R.current=a[0]??null,(()=>{if(ae())return;if(M===0){if(ue()||a.length>0&&o.current&&D({behavior:"auto"}))return;N(),O();return}let W=H?a.indexOf(H):-1;if(Y.current&&W>0){ve();return}if(a.length>M){let $=Ye(a,M);if($){if(o.current&&u.current==="following-bottom"&&qe(a,M)){D({behavior:"auto"});return}se($,{align:"start"},{keepPreviousPeek:true}),q.current.add($);return}}if(a.length===M){let $=ze(a,q.current);if($){se($,{align:"start"},{keepPreviousPeek:true}),q.current.add($);return}}u.current==="following-bottom"&&o.current?D({behavior:"auto"}):(N(),O());})(),Z();},[ue,Z,N,ae,ve,O,se,D]),Ce=f.useCallback(()=>{if(u.current==="following-bottom"&&o.current){D({behavior:"auto"});return}let s=z.current;if(Te()){o.current&&s>0&&z.current===0&&D({behavior:"auto"});return}oe(),O();},[Te,oe,O,D]),Pe=f.useCallback(()=>{let s=T.current;if(!(!s||!y.hasListeners())){if(typeof IntersectionObserver>"u"){O();return}C.current||(C.current=new IntersectionObserver(a=>{for(let M of a){let H=M.target.dataset.messageId;H&&(M.isIntersecting?F.current.add(H):F.current.delete(H));}O();},{root:s,rootMargin:`${-(G.current+A.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]})),I.current.forEach(a=>{C.current?.observe(a);}),O();}},[O,y]),we=f.useCallback(()=>{w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),C.current?.disconnect(),C.current=null,F.current.clear(),y.setSnapshot(Q);},[y]),bt=f.useCallback((s,a,M)=>{if(a){I.current.set(s,a),C.current?.observe(a),O(),j.current?.messageId===s&&he();return}M&&I.current.get(s)===M&&(I.current.delete(s),F.current.delete(s),C.current?.unobserve(M),O());},[he,O]),Oe=f.useCallback(()=>{(u.current==="following-bottom"||u.current==="anchored-to-message"||u.current==="settling-jump")&&(S.current=null,u.current="free-scrolling");},[]),ye=f.useCallback(()=>ce(d.getSnapshot()),[d,ce]),He=ot(V,ye),Ie=ot(T,ye),Ae=f.useCallback(s=>{m.current=s;},[]),De=f.useCallback(s=>{B.current=s,le.current=Ze(s?.parentElement??null);},[]),xe=f.useCallback(()=>{N(),O(),Z();},[Z,N,O]),Tt=f.useMemo(()=>({handleContentChange:Le,handleResize:Ce,observeVisibility:Pe,pendingDefaultScrollStore:x,preserveScrollOnPrependRef:Y,scrollToEnd:D,scrollToMessage:Ee,scrollToStart:ie,setContentElement:Ae,setRootElement:He,setSpacerElement:De,setViewportElement:Ie,stateStore:d,syncAfterScroll:xe,unobserveVisibility:we,userScrollIntent:Oe,viewportRef:T,visibilityStore:y}),[Le,Ce,Pe,x,D,Ee,ie,Ae,He,De,Ie,d,xe,we,Oe,y]);return f.useLayoutEffect(()=>{ue()||E.current===0&&Me(c);},[ue]),f.useEffect(()=>()=>{i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null),w.current!==null&&(window.cancelAnimationFrame(w.current),w.current=null),v.current!==null&&(window.clearTimeout(v.current),v.current=null),k.current!==null&&(window.cancelAnimationFrame(k.current),k.current=null),C.current?.disconnect(),C.current=null;},[]),f.useLayoutEffect(()=>{if(e&&u.current==="following-bottom"&&E.current>0){D({behavior:"auto"});return}N();},[e,N,D]),{context:Tt,registerMessage:bt}}function at(e){let t=f.useRef(e);return t.current=e,t}var it=f.createContext(null),ut=f.createContext(null);function K(){let e=f.useContext(it);if(!e)throw new Error("useMessageScroller must be used within a MessageScroller.");return e}function Ct(){let e=f.useContext(ut);if(!e)throw new Error("MessageScrollerItem must be used within a MessageScroller.");return e}function Pt(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:r}=K();return f.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:r}),[e,t,r])}function wt(){let{stateStore:e}=K();return f.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function Ot(){let{observeVisibility:e,unobserveVisibility:t,visibilityStore:r}=K(),n=f.useCallback(l=>r.subscribe(l,e,t),[e,t,r]);return f.useSyncExternalStore(n,r.getSnapshot,r.getSnapshot)}function ft({autoScroll:e=false,children:t,defaultScrollPosition:r="end",scrollEdgeThreshold:n,scrollPreviousItemPeek:l,scrollMargin:c}){let{context:S,registerMessage:o}=st({autoScroll:e,defaultScrollPosition:r,scrollEdgeThreshold:n,scrollPreviousItemPeek:l,scrollMargin:c});return jsx(it.Provider,{value:S,children:jsx(ut.Provider,{value:o,children:t})})}function St(){let{pendingDefaultScrollStore:e}=K();return f.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function gt({children:e,ref:o,...t}){let{setRootElement:r}=K(),n=St(),l=f.useMemo(()=>c(r,o),[r,o]);return jsx("div",{ref:l,...t,...n?{"data-pending-scroll":""}:null,children:e})}function Rt({"aria-label":e,children:t,onKeyDown:r,onPointerDown:d,onScroll:n,onTouchMove:l,onWheel:c$1,preserveScrollOnPrepend:S=true,ref:o,role:b,tabIndex:v,...m}){let{handleResize:L,preserveScrollOnPrependRef:R,setViewportElement:E,syncAfterScroll:h,userScrollIntent:I,viewportRef:u}=K(),k=St();R.current=S;let j=f.useCallback(P=>{E(P),c(o)?.(P);},[o,E]);function _(P){h(),n?.(P);}function Y(P){I(),c$1?.(P);}function x(P){I(),l?.(P);}function V(P){Ge.has(P.key)&&I(),r?.(P);}function W(P){I(),d?.(P);}return f.useEffect(()=>{let P=u.current;if(!P||typeof ResizeObserver>"u")return;let G=0,A=new ResizeObserver(()=>{window.cancelAnimationFrame(G),G=window.requestAnimationFrame(L);});return A.observe(P),()=>{window.cancelAnimationFrame(G),A.disconnect();}},[L,u]),jsx("div",{ref:j,role:b??"region","aria-label":e??"Messages",tabIndex:v??0,onKeyDown:V,onPointerDown:W,onScroll:_,onTouchMove:x,onWheel:Y,...m,...k?{"data-pending-scroll":""}:null,children:t})}function pt({"aria-relevant":e,children:t,ref:r,role:n,spacerClassName:l,...c$1}){let{handleContentChange:S,handleResize:o,setContentElement:b,setSpacerElement:v}=K(),m=f.useRef(null),L=f.useCallback(R=>{m.current=R,b(R),c(r)?.(R);},[r,b]);return f.useLayoutEffect(()=>{let R=m.current;if(!R||(S(),typeof MutationObserver>"u"))return;let E=new MutationObserver(()=>{S();});return E.observe(R,{childList:true}),()=>E.disconnect()},[S]),f.useEffect(()=>{let R=m.current;if(!R||typeof ResizeObserver>"u")return;let E=0,h=new ResizeObserver(()=>{window.cancelAnimationFrame(E),E=window.requestAnimationFrame(o);});return h.observe(R),()=>{window.cancelAnimationFrame(E),h.disconnect();}},[o]),jsxs("div",{ref:L,role:n??"log","aria-relevant":e??"additions",...c$1,children:[t,jsx("div",{ref:v,"aria-hidden":"true","data-message-scroller-spacer":"",hidden:true,className:l})]})}function mt({messageId:e,ref:t,scrollAnchor:r=false,...n}){let l=Ct(),c$1=f.useRef(null),S=f.useCallback(o=>{let b=c$1.current;c$1.current=o,e&&l(e,o,b),c(t)?.(o);},[e,t,l]);return jsx("div",{ref:S,"data-message-id":e,"data-scroll-anchor":r?"true":"false",...n})}function dt({behavior:e="smooth",children:t,direction:r="end",onClick:n,render:l,tabIndex:c,type:S="button",...o}){let{scrollToEnd:b$1,scrollToStart:v,stateStore:m}=K(),L=at(n),R=f.useCallback(u=>m.subscribe(u),[m]),E=f.useCallback(()=>{let u=m.getSnapshot();return r==="start"?u.start:u.end},[r,m]),h=f.useSyncExternalStore(R,E,E),I=f.useCallback(u=>{h&&(L.current?.(u),u.defaultPrevented||(u.currentTarget.blur(),r==="start"?v({behavior:e}):b$1({behavior:e})));},[e,r,h,L,b$1,v]);return a({defaultTagName:"button",props:b({type:S,inert:!h,tabIndex:h?c:-1,children:t??jsxs("span",{children:["Scroll to ",r]}),onClick:I},o),render:l,state:{active:h,direction:r},stateAttributesMapping:{active:u=>({"data-active":u?"true":"false"})}})}var er={Provider:ft,Root:gt,Viewport:Rt,Content:pt,Item:mt,Button:dt};export{er as MessageScroller,Pt as useMessageScroller,wt as useMessageScrollerScrollable,Ot as useMessageScrollerVisibility};
25
+
26
+ diff --git a/dist/questionnaire/index.js b/dist/questionnaire/index.js
27
+ index db71caaab7e5909b83eb50d79a30eb29a032f1b4..b1f945e976802c6148bcbfa86b8eea449fceb3ef 100644
28
+ --- a/dist/questionnaire/index.js
29
+ +++ b/dist/questionnaire/index.js
30
+ @@ -1,2 +1,2 @@
31
+ "use client";
32
+ -import {a,b,c}from'../chunk-HBS6WEDP.js';import*as p from'react';import {jsx}from'react/jsx-runtime';var Pe=p.createContext(null),ve=p.createContext(null),Ee=p.createContext(null);function ne(e){let t=p.useContext(ve);if(!t)throw new Error(`${e} must be used within a Questionnaire.Root component.`);return t}function be(e){let t=p.useContext(Pe);if(!t)throw new Error(`${e} must be used within a Questionnaire.Choice component.`);return t}function Z(e){let t=p.useContext(Ee);if(!t)throw new Error(`${e} must be used within a Questionnaire.Item component.`);return t}function ce(e){return Array.isArray(e)?e.some(t=>String(t).trim().length>0):e!=null&&String(e).trim().length>0}function me(e){return e==="letters"?Array.from({length:26},(t,i)=>String.fromCharCode(65+i)):e==="numbers"?Array.from({length:9},(t,i)=>String(i+1)):[]}function He(e,t){let i=t==="letters"?e.toUpperCase():e;return me(t).includes(i)?i:null}function Ie(e,t){return [e,t?"Enter":null].filter(Boolean).join(" ")||void 0}function pe(e){return e.type==="choice"?e.element.checked:e.element.hasAttribute("name")&&ce(e.element.value)}function $e(e){return e?.type==="input"&&["email","password","search","tel","text","url"].includes(e.element.type)&&!ce(e.element.value)}function he(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?true:e instanceof HTMLInputElement?!["button","checkbox","radio","reset","submit"].includes(e.type):e instanceof HTMLElement&&e.isContentEditable}function le(e){return e instanceof HTMLInputElement&&e.type==="radio"}function Ke(e,t){if(e.element===t.element)return 0;let i=e.element.compareDocumentPosition(t.element);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0}function Ue(e,t){if(e.element===t.element)return 0;let i=e.element.compareDocumentPosition(t.element);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0}function qe({checked:e,defaultChecked:t=false,disabled:i=false,onChange:a,value:s}){let{disabled:o,hasInputAnswer:u,invalid:f,multiple:g,name:d,registerAnswerControl:c,registerAnswerSelection:S,required:B,resetVersion:Q,selectedAnswerIds:x,setAnswerDefault:U,setAnswerSelectionFromInteraction:P,shortcutByAnswerId:A,shortcutByChoiceValue:G,status:v,syncControlledAnswerSelection:C}=Z("Questionnaire.Choice"),E=p.useId(),[O,V]=p.useState(null),L=p.useRef(t),N=e!==void 0,D=o||i,M=x.includes(E),y=N?v==="skipped"?false:e:M,R=g?"checkbox":"radio",w=G?.get(s)??A.get(E)??null;p.useLayoutEffect(()=>S(E,L.current),[E,S]),p.useLayoutEffect(()=>U(E,t),[E,t,U]),p.useLayoutEffect(()=>{if(O)return c({disabled:D,element:O,id:E,ownDisabled:i,type:"choice",value:s})},[E,i,D,O,c,s]),p.useLayoutEffect(()=>{N&&C(E,e);},[E,N,e,Q,C]),p.useLayoutEffect(()=>{O&&(O.defaultChecked=N?e:t,Q>0&&(O.checked=y));},[y,N,e,t,O,Q]);function X(T){if(a?.(T),!T.defaultPrevented){if(!N){P(E,T.target.checked);return}v==="skipped"&&e===T.target.checked&&P(E,e);}}let ie={checked:y,disabled:D,invalid:f,shortcut:w,type:R};return {inputProps:{ref:V,"aria-invalid":f||void 0,"aria-keyshortcuts":Ie(w,!D&&y),checked:y,disabled:D,id:E,name:v==="skipped"?void 0:d,onChange:X,required:B&&!g&&!u,type:R,value:s},state:ie}}function _e({defaultValue:e,disabled:t=false,onChange:i,ref:a,type:s="text",value:o}){let{disabled:u,invalid:f,name:g,registerAnswerControl:d,registerAnswerSelection:c$1,resetVersion:S,selectedAnswerIds:B,setAnswerDefault:Q,setAnswerSelectionFromInteraction:x,syncControlledAnswerSelection:U}=Z("Questionnaire.Input"),P=p.useId(),A=p.useRef(null),G=p.useRef(ce(e)),v=o!==void 0,C=ce(e),E=ce(o),[O,V]=p.useState(C),L=u||t,N=v?E:O,D=B.includes(P);p.useLayoutEffect(()=>c$1(P,G.current),[P,c$1]),p.useLayoutEffect(()=>Q(P,C),[C,P,Q]),p.useLayoutEffect(()=>{let w=A.current;if(w)return d({disabled:L,element:w,id:P,type:"input"})},[L,P,d]),p.useLayoutEffect(()=>{if(v){U(P,E);return}S>0&&V(C);},[v,E,o,C,P,S,U]),p.useLayoutEffect(()=>{let w=A.current;!w||!v||(w.defaultValue=String(o));},[v,o]);function M(w){if(i?.(w),w.defaultPrevented)return;let X=w.target.value.trim().length>0;v||(V(X),x(P,X));}let y={disabled:L,filled:N,invalid:f},R=p.useCallback(w=>{A.current=w,c(a)?.(w);},[a]);return {inputProps:{"aria-invalid":f||void 0,"aria-keyshortcuts":Ie(null,!L&&N&&D),defaultValue:v?void 0:e,disabled:L,form:D?void 0:"",id:P,name:D?g:void 0,onChange:M,ref:R,type:s,value:v?o:void 0},state:y}}function We(e){return e===void 0?null:{enabledItems:e.filter(t=>!t.disabled),itemByName:new Map(e.map(t=>[t.name,t])),items:e}}function we(e,t){if(!e)return t??null;let i=t?e.itemByName.get(t):void 0;return i&&!i.disabled?i.name:e.enabledItems[0]?.name??null}function Ge(e,t){let i=new Map;if(!e||!t)return i;let a=me(t),s=0;for(let o of e.choices??[]){if(o.disabled)continue;let u=a[s];if(!u)break;i.set(o.value,u),s+=1;}return i}function je(e,t){let i=[],a=new Set;for(let s of e.items){a.has(s.name)&&i.push(`Item name "${s.name}" is defined more than once.`),a.add(s.name);let o=new Set;for(let u of s.choices??[])o.has(u.value)&&i.push(`Choice value "${u.value}" is defined more than once in item "${s.name}".`),o.add(u.value);}if(t){let s=e.itemByName.get(t);(!s||s.disabled)&&i.push(`defaultItem "${t}" does not identify an enabled item. The first enabled item will be used instead.`);}return i}function ze(e,t,i){let a=[],s=new Map(t.map(o=>[o.name,o]));for(let o of e.items){let u=s.get(o.name);if(!u){o.disabled||a.push(`Item "${o.name}" is defined but has no rendered Questionnaire.Item.`);continue}u.disabled!==!!o.disabled&&a.push(`Item "${o.name}" has different disabled values in Root.items and Questionnaire.Item.`),u.required!==!!o.required&&a.push(`Item "${o.name}" has different required values in Root.items and Questionnaire.Item.`);let f=o.choices??[],g=new Map(f.map(c=>[c.value,c])),d=new Map(u.choices.map(c=>[c.value,c]));for(let c of f){let S=d.get(c.value);if(!S){a.push(`Choice "${c.value}" is defined for item "${o.name}" but has no rendered Questionnaire.Choice.`);continue}S.disabled!==!!c.disabled&&a.push(`Choice "${c.value}" in item "${o.name}" has different disabled values in Root.items and Questionnaire.Choice.`);}if(i){for(let Q of u.choices)g.has(Q.value)||a.push(`Rendered choice "${Q.value}" in item "${o.name}" is missing from Root.items and will not receive a shortcut.`);let c=f.filter(Q=>!Q.disabled).map(Q=>Q.value),S=u.choices.filter(Q=>!Q.disabled).map(Q=>Q.value);c.length>0&&c.length===S.length&&c.every(Q=>S.includes(Q))&&c.some((Q,x)=>Q!==S[x])&&a.push(`Choice order for item "${o.name}" differs between Root.items and the rendered Questionnaire.Choice elements.`);}}for(let o of t)!o.disabled&&!e.itemByName.has(o.name)&&a.push(`Rendered item "${o.name}" is missing from Root.items and is excluded from the questionnaire collection.`);return a}function Je({"aria-describedby":e,"aria-keyshortcuts":t,disabled:i=false,invalid:a=false,multiple:s=false,name:o,onStatusChange:u,ref:f,required:g=false}){let{activeItemName:d,domVersion:c$1,first:S,itemDefinitionByName:B,last:Q,nativeValidation:x,registerItem:U,shortcuts:P}=ne("Questionnaire.Item"),[A,G]=p.useState(null),[v,C]=p.useState([]),[E,O]=p.useState(false),[V,L]=p.useState([]),[N,D]=p.useState(false),[M,y]=p.useState(0),[R,w]=p.useState([]),[X,ie]=p.useState([]),T=p.useRef([]),q=p.useRef(s),de=p.useRef(s);q.current=s;let _=!i&&d===o,j=p.useMemo(()=>[...v].sort(Ue),[v,c$1]),h=p.useMemo(()=>j.filter(r=>!r.disabled),[j]),ge=h.some(r=>V.includes(r.id)),F=N?"skipped":ge?"answered":"unanswered",re=F==="skipped"&&!g,se=i||re||!a&&F==="answered",ee=!i&&!re&&(a||E&&!se),Re=h.some(r=>r.type==="input"),Qe=p.useRef(F),Ce=B?.get(o),J=p.useMemo(()=>B?Ge(Ce,P):null,[Ce,B,P]),ae=p.useMemo(()=>{if(J)return new Map;let r=me(P),m=h.filter(l=>l.type==="choice");return new Map(m.slice(0,r.length).map((l,$)=>[l.id,r[$]]))},[h,J,P]),ye=p.useCallback(r=>(C(m=>[...m.filter(l=>l.element!==r.element&&l.id!==r.id),r]),()=>{C(m=>m.filter(l=>l!==r));}),[]);p.useLayoutEffect(()=>{Qe.current!==F&&(Qe.current=F,u?.(F));},[u,F]);let n=p.useCallback((r,m)=>{L(l=>m?s?l.includes(r)?l:[...l,r]:[r]:l.filter($=>$!==r));},[s]),b=p.useCallback((r,m)=>{D(false),n(r,m);},[n]),k=p.useCallback((r,m)=>{m&&D(false),n(r,m);},[n]),Y=p.useCallback((r,m)=>(m&&(T.current=[...T.current.filter(l=>l!==r),r],L(l=>q.current?l.includes(r)?l:[...l,r]:l.length?l:[r])),()=>{T.current=T.current.filter(l=>l!==r),L(l=>l.filter($=>$!==r));}),[]),xe=p.useCallback((r,m)=>{if(m){T.current=T.current.includes(r)?T.current:[...T.current,r];return}T.current=T.current.filter(l=>l!==r);},[]),Me=p.useCallback(r=>(w(m=>m.includes(r)?m:[...m,r]),()=>{w(m=>m.filter(l=>l!==r));}),[]),Ae=p.useCallback(r=>(ie(m=>m.includes(r)?m:[...m,r]),()=>{ie(m=>m.filter(l=>l!==r));}),[]),Ne=p.useCallback(()=>{if(O(true),!se)return false;if(!x)return true;let r=h.find(m=>pe(m)&&m.element.willValidate&&!m.element.validity.valid);return r?(r.element.focus(),r.element.reportValidity(),false):true},[h,x,se]),Te=p.useCallback(()=>{A?.focus();},[A]),Le=p.useCallback(()=>{let r=A?.querySelector("input[data-filled][name]:not(:disabled)"),m=A?.querySelector("input:not([type=hidden]):not(:disabled), textarea:not(:disabled)");(r??m??A)?.focus();},[A]),De=p.useCallback(()=>{O(false),D(false),L(s?[...T.current]:T.current.slice(0,1)),y(r=>r+1);},[s]),Be=p.useCallback(()=>{g||(L([]),D(true));},[g]);p.useLayoutEffect(()=>{let r=de.current;de.current=s,!(!r||s)&&L(m=>{let l=h.find($=>m.includes($.id));return l?[l.id]:[]});},[h,s]);let Fe=p.useCallback(r=>h.find(m=>m.element===r)??null,[h]),Ve=p.useCallback(r=>{if(J){let l=Array.from(J.entries()).find(([,$])=>$===r)?.[0];return h.find($=>$.type==="choice"&&$.value===l)??null}let m=Array.from(ae.entries()).find(([,l])=>l===r)?.[0];return h.find(l=>l.id===m)??null},[h,ae,J]),Oe=p.useCallback((r,m)=>{let l=h.findIndex(Qt=>Qt.element===r),$=l<0?null:h[l]??null;if(!h.length||he(r)&&!$e($)||l<0&&r!==A)return false;let oe=l<0?h.find(pe)??(m==="next"?h[0]:h[h.length-1]):h[(l+(m==="next"?1:-1)+h.length)%h.length];return !oe||oe.element===r||l>=0&&le(r)&&le(oe.element)?false:(oe.element.focus(),oe.type==="choice"&&le(oe.element)&&oe.element.click(),true)},[h,A]);p.useLayoutEffect(()=>{if(A)return U({choices:j.flatMap(r=>r.type==="choice"?[{disabled:r.ownDisabled,value:r.value}]:[]),disabled:i,element:A,focus:Te,focusInvalid:Le,getAnswerByElement:Fe,getAnswerByShortcut:Ve,moveAnswerFocus:Oe,name:o,required:g,reset:De,skip:Be,status:F,validate:Ne})},[j,i,A,Te,Le,Fe,Ve,Oe,o,U,g,De,Be,F,Ne]);let pt=p.useMemo(()=>({active:_,disabled:i,hasInputAnswer:Re,invalid:ee,multiple:s,name:o,registerAnswerControl:ye,registerAnswerSelection:Y,registerDescription:Me,registerError:Ae,required:g,resetVersion:M,selectedAnswerIds:V,setAnswerDefault:xe,setAnswerSelectionFromInteraction:b,shortcutByAnswerId:ae,shortcutByChoiceValue:J,shortcuts:P,status:F,syncControlledAnswerSelection:k}),[_,i,Re,ee,s,o,ye,Y,Me,Ae,g,M,V,xe,b,ae,J,P,F,k]),ht=p.useCallback(r=>{G(r),c(f)?.(r);},[f]),gt=[...R,...ee?X:[],e].filter(Boolean).join(" ")||void 0,Rt=[t,_?"Meta+Enter Control+Enter":void 0,_&&h.length?"ArrowUp ArrowDown":void 0,_&&!S?"ArrowLeft":void 0,_&&!Q&&F!=="unanswered"?"ArrowRight":void 0].filter(Boolean).join(" ")||void 0;return {context:pt,itemProps:{"aria-describedby":gt,"aria-invalid":ee||void 0,"aria-keyshortcuts":Rt,disabled:i,hidden:!_,inert:!_,ref:ht,tabIndex:-1},state:{active:_,disabled:i,invalid:ee,multiple:s,required:g,status:F}}}function Xe({defaultItem:e,item:t,items:i,noValidate:a,onItemChange:s,onReset:o,onSubmit:u,ref:f,shortcuts:g}){let d=p.useMemo(()=>We(i),[i]),[c$1,S]=p.useState([]),[B,Q]=p.useState(()=>we(d,e)),[x,U]=p.useState(null),[P,A]=p.useState(0),G=p.useRef(null),v=t!==void 0,C=v?t:B,E=p.useRef(C),O=a===false,V=g??null,L=p.useRef(new Set);p.useLayoutEffect(()=>{if(process.env.NODE_ENV==="production")return;if(!d||!x){L.current.clear();return}let n=false;return queueMicrotask(()=>{if(n)return;let b=[...je(d,e),...ze(d,c$1,V)],k=new Set(b);k.forEach(Y=>{L.current.has(Y)||console.warn(`[Questionnaire] ${Y}`);}),L.current=k;}),()=>{n=true;}},[d,e,c$1,x,V]),p.useLayoutEffect(()=>{if(!x||typeof MutationObserver>"u")return;let n=new MutationObserver(()=>{A(b=>b+1);});return n.observe(x,{childList:true,subtree:true}),()=>n.disconnect()},[x]);let N=p.useMemo(()=>c$1.filter(n=>!n.disabled).sort(Ke),[P,c$1]),D=p.useMemo(()=>new Map(N.map(n=>[n.name,n])),[N]),M=d?.enabledItems??N,y=M.findIndex(n=>n.name===C),R=y<0||!C?null:D.get(C)??null,w=C?d?.itemByName.get(C):void 0,X=y<0?null:w?!!w.required:R?.required??false,ie=y<0?null:R?.status??(C?"unanswered":null),T=p.useMemo(()=>d?d.enabledItems.flatMap(n=>{let b=D.get(n.name);return b?[b]:[]}):N,[d,D,N]),q=M.length,de=y<0?0:y+1,_=q>0&&y===0,j=q>0&&y===q-1,h=p.useCallback((n,b="item")=>{n!==C&&(G.current={name:n,target:b},v||Q(n),s?.(n));},[C,v,s]);p.useLayoutEffect(()=>{if(q===0)return;if(y<0){if(!v&&C===null){Q(M[0].name);return}h(M[0].name);return}let n=G.current,b=E.current!==C;if(E.current=C,!n||n.name!==C){v&&b&&(G.current=null,R?.focus());return}n.target==="invalid"?R?.focusInvalid():R?.focus(),G.current=null;},[R,C,v,y,M,h,q]);let ge=p.useCallback(n=>(S(b=>[...b.filter(k=>k.element!==n.element&&k.name!==n.name),n]),()=>{S(b=>b.filter(k=>k!==n));}),[]),F=p.useCallback(()=>{y<=0||h(M[y-1].name);},[y,M,h]),re=p.useCallback(()=>{if(!(!R||y>=q-1)){if(!R.validate()){R.focusInvalid();return}h(M[y+1].name);}},[R,y,M,h,q]),se=p.useCallback(()=>{if(R){if(!R.validate()){R.focusInvalid();return}if(j){x?.requestSubmit();return}h(M[y+1].name);}},[R,y,j,M,x,h]),ee=p.useCallback(()=>{if(!(!R||R.required)){if(R.skip(),!j){h(M[y+1].name);return}queueMicrotask(()=>{x?.requestSubmit();});}},[R,y,j,M,x,h]);function Re(n){if(o?.(n),n.defaultPrevented)return;for(let k of c$1)k.reset();let b=d?we(d,e):N.find(k=>k.name===e)?.name??N[0]?.name;b&&h(b);}function Qe(n){let b=T.find(k=>!k.validate());if(b){n.preventDefault(),h(b.name,"invalid"),b.name===C&&(b.focusInvalid(),G.current=null);return}u?.(n);}function Ce(n){if(n.defaultPrevented||n.nativeEvent.isComposing||n.keyCode===229||!R||!(n.target instanceof Element))return;if(n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey){n.preventDefault(),n.repeat||se();return}if(n.metaKey||n.ctrlKey||n.altKey)return;if((n.key==="ArrowUp"||n.key==="ArrowDown")&&R.moveAnswerFocus(n.target,n.key==="ArrowDown"?"next":"previous")){n.preventDefault();return}if((n.key==="ArrowLeft"||n.key==="ArrowRight")&&!he(n.target)&&!le(n.target)){if(n.preventDefault(),n.repeat)return;n.key==="ArrowLeft"?F():R.status!=="unanswered"&&re();return}if(n.key==="Enter"){let Y=R.getAnswerByElement(n.target);if(!Y)return;n.preventDefault(),!n.repeat&&pe(Y)&&se();return}if(!V||he(n.target))return;let b=He(n.key,V),k=b?R.getAnswerByShortcut(b):null;k&&(n.preventDefault(),!n.repeat&&(k.element.focus(),k.type==="choice"&&k.element.click()));}let J={current:de,first:_,last:j,total:q},ae=p.useMemo(()=>({...J,activeItem:R,activeItemName:C,activeItemRequired:X,activeItemStatus:ie,domVersion:P,goNext:re,goPrevious:F,itemDefinitionByName:d?.itemByName??null,nativeValidation:O,registerItem:ge,shortcuts:V,skipCurrent:ee}),[R,C,X,ie,d,de,P,_,re,F,j,O,ge,V,ee,q]),ye=p.useCallback(n=>{U(n),c(f)?.(n);},[f]);return {context:ae,rootProps:{"data-shortcuts":V??void 0,onKeyDown:Ce,onReset:Re,onSubmit:Qe,ref:ye},state:J}}function Ye({defaultItem:e,item:t,items:i,noValidate:a$1=true,onItemChange:s,onReset:o,onSubmit:u,ref:f,shortcuts:g,...d}){let{context:c,rootProps:S,state:B}=Xe({defaultItem:e,item:t,items:i,noValidate:a$1,onItemChange:s,onReset:o,onSubmit:u,ref:f,shortcuts:g}),Q=a({defaultTagName:"form",props:b({...S,noValidate:a$1},d),state:B});return jsx(ve.Provider,{value:c,children:Q})}function Ze({children:e,render:t,...i}){let{current:a$1,first:s,last:o,total:u}=ne("Questionnaire.Progress"),f=u?`Question ${a$1} of ${u}`:void 0;return a({defaultTagName:"div",props:b({"aria-label":"Questionnaire progress","aria-live":"polite","aria-valuemax":u||void 0,"aria-valuemin":u?1:void 0,"aria-valuenow":u?a$1:void 0,"aria-valuetext":f,children:e??f,role:"progressbar"},i),render:t,state:{current:a$1,first:s,last:o,total:u}})}function et({"aria-describedby":e,"aria-keyshortcuts":t,children:i,disabled:a$1=false,invalid:s=false,multiple:o=false,name:u,onStatusChange:f,ref:g,required:d=false,...c}){let{context:S,itemProps:B,state:Q}=Je({"aria-describedby":e,"aria-keyshortcuts":t,disabled:a$1,invalid:s,multiple:o,name:u,onStatusChange:f,ref:g,required:d}),x=a({defaultTagName:"fieldset",props:b({...B,children:i},c),state:Q,stateAttributesMapping:{active:U=>({"data-active":U?"":void 0})}});return jsx(Ee.Provider,{value:S,children:x})}function tt({render:e,...t}){return Z("Questionnaire.Title"),a({defaultTagName:"legend",props:t,render:e})}function nt({id:e,render:t,...i}){let{registerDescription:a$1}=Z("Questionnaire.Description"),s=p.useId(),o=e??s;return p.useLayoutEffect(()=>a$1(o),[o,a$1]),a({defaultTagName:"p",props:b({id:o},i),render:t})}function it({render:e,...t}){let{shortcuts:i}=Z("Questionnaire.Choices");return a({defaultTagName:"div",props:t,render:e,state:{shortcuts:i}})}function ot({checked:e,children:t,defaultChecked:i=false,disabled:a$1=false,onChange:s,render:o,value:u,...f}){let{inputProps:g,state:d}=qe({checked:e,defaultChecked:i,disabled:a$1,onChange:s,value:u}),c=a({defaultTagName:"label",props:b({children:t},f),render:o,state:d,stateAttributesMapping:{checked:S=>({"data-checked":S?"":void 0,"data-unchecked":S?void 0:""})}});return jsx(Pe.Provider,{value:{inputProps:g,state:d},children:c})}function rt({render:e,...t}){let{inputProps:i,state:a$1}=be("Questionnaire.ChoiceInput");return a({defaultTagName:"input",props:b(i,t),render:e,state:a$1,stateAttributesMapping:{checked:s=>({"data-checked":s?"":void 0,"data-unchecked":s?void 0:""})}})}function st({render:e,...t}){return be("Questionnaire.ChoiceLabel"),a({defaultTagName:"span",props:t,render:e})}function at({children:e,render:t,...i}){let{state:a$1}=be("Questionnaire.ChoiceShortcut"),s={shortcut:a$1.shortcut};return a({defaultTagName:"span",props:b({"aria-hidden":true,children:e??a$1.shortcut,hidden:a$1.shortcut===null},i),render:t,state:s})}function ut({defaultValue:e,disabled:t=false,onChange:i,ref:a$1,render:s,type:o="text",value:u,...f}){let{inputProps:g,state:d}=_e({defaultValue:e,disabled:t,onChange:i,ref:a$1,type:o,value:u});return a({defaultTagName:"input",props:b(g,f),render:s,state:d,stateAttributesMapping:{filled:c=>({"data-empty":c?void 0:"","data-filled":c?"":void 0})}})}function ct({children:e,id:t,render:i,...a$1}){let{invalid:s,registerError:o,required:u}=Z("Questionnaire.Error"),f=p.useId(),g=t??f;return p.useLayoutEffect(()=>o(g),[g,o]),a({defaultTagName:"p",props:b({children:e??(u?"Choose an answer to continue.":"Choose an answer or skip this question."),hidden:!s,id:g,role:s?"alert":void 0},a$1),render:i,state:{invalid:s}})}function lt({children:e,disabled:t=false,onClick:i,render:a,tabIndex:s,type:o="button",...u}){let f=ne("Questionnaire.Previous"),g=f.total>1&&!f.first;function d(c){i?.(c),c.defaultPrevented||f.goPrevious();}return Se({children:e??"Previous",disabled:t,onClick:d,props:u,render:a,status:f.activeItemStatus,tabIndex:s,type:o,visible:g})}function ft({children:e,disabled:t=false,onClick:i,render:a,tabIndex:s,type:o="button",...u}){let f=ne("Questionnaire.Skip"),g=f.activeItemRequired===false;function d(c){i?.(c),c.defaultPrevented||f.skipCurrent();}return Se({children:e??"Skip",disabled:t,onClick:d,props:u,render:a,status:f.activeItemStatus,tabIndex:s,type:o,visible:g})}function dt({children:e,disabled:t=false,onClick:i,render:a,tabIndex:s,type:o="button",...u}){let f=ne("Questionnaire.Next"),g=f.total>1&&!f.last;function d(c){i?.(c),c.defaultPrevented||f.goNext();}return Se({children:e??"Next",disabled:t,onClick:d,props:u,render:a,shortcut:"Enter",status:f.activeItemStatus,tabIndex:s,type:o,visible:g})}function mt({children:e,disabled:t=false,render:i,tabIndex:a,type:s="submit",...o}){let u=ne("Questionnaire.Submit"),f=u.total>0&&u.last;return Se({children:e??"Submit",disabled:t,props:o,render:i,shortcut:"Enter",status:u.activeItemStatus,tabIndex:a,type:s,visible:f})}function Se({children:e,disabled:t,onClick:i,props:a$1,render:s,shortcut:o,status:u,tabIndex:f,type:g,visible:d}){let c=d&&!t?o??null:null,S={disabled:t,shortcut:c,status:u,visible:d};return a({defaultTagName:"button",props:b({"aria-hidden":!d||void 0,"aria-keyshortcuts":c??void 0,children:e,disabled:t,hidden:!d,inert:!d,onClick:i,tabIndex:d?f:-1,type:g},a$1),render:s,state:S,stateAttributesMapping:{visible:B=>({"data-hidden":B?void 0:"","data-visible":B?"":void 0})}})}var zt={Root:Ye,Progress:Ze,Item:et,Title:tt,Description:nt,Choices:it,Choice:ot,ChoiceInput:rt,ChoiceLabel:st,ChoiceShortcut:at,Input:ut,Error:ct,Previous:lt,Skip:ft,Next:dt,Submit:mt};export{zt as Questionnaire};
33
+
34
+ +import {a,b,c}from'../chunk-HBS6WEDP.js';import*as p from'react';import {jsx}from'react/jsx-runtime';var Pe=p.createContext(null),ve=p.createContext(null),Ee=p.createContext(null);function ne(e){let t=p.useContext(ve);if(!t)throw new Error(`${e} must be used within a Questionnaire.Root component.`);return t}function be(e){let t=p.useContext(Pe);if(!t)throw new Error(`${e} must be used within a Questionnaire.Choice component.`);return t}function Z(e){let t=p.useContext(Ee);if(!t)throw new Error(`${e} must be used within a Questionnaire.Item component.`);return t}function ce(e){return Array.isArray(e)?e.some(t=>String(t).trim().length>0):e!=null&&String(e).trim().length>0}function me(e){return e==="letters"?Array.from({length:26},(t,i)=>String.fromCharCode(65+i)):e==="numbers"?Array.from({length:9},(t,i)=>String(i+1)):[]}function He(e,t){let i=t==="letters"?e.toUpperCase():e;return me(t).includes(i)?i:null}function Ie(e,t){return [e,t?"Enter":null].filter(Boolean).join(" ")||void 0}function pe(e){return e.type==="choice"?e.element.checked:e.element.hasAttribute("name")&&ce(e.element.value)}function $e(e){return e?.type==="input"&&["email","password","search","tel","text","url"].includes(e.element.type)&&!ce(e.element.value)}function he(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?true:e instanceof HTMLInputElement?!["button","checkbox","radio","reset","submit"].includes(e.type):e instanceof HTMLElement&&e.isContentEditable}function le(e){return e instanceof HTMLInputElement&&e.type==="radio"}function Ke(e,t){if(e.element===t.element)return 0;let i=e.element.compareDocumentPosition(t.element);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0}function Ue(e,t){if(e.element===t.element)return 0;let i=e.element.compareDocumentPosition(t.element);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0}function qe({checked:e,defaultChecked:t=false,disabled:i=false,onChange:a,value:s}){let{disabled:o,hasInputAnswer:u,invalid:f,multiple:g,name:d,registerAnswerControl:c,registerAnswerSelection:S,required:B,resetVersion:Q,selectedAnswerIds:x,setAnswerDefault:U,setAnswerSelectionFromInteraction:P,shortcutByAnswerId:A,shortcutByChoiceValue:G,status:v,syncControlledAnswerSelection:C}=Z("Questionnaire.Choice"),E=p.useId(),[O,V]=p.useState(null),L=p.useRef(t),N=e!==void 0,D=o||i,M=x.includes(E),y=N?v==="skipped"?false:e:M,R=g?"checkbox":"radio",w=G?.get(s)??A.get(E)??null;p.useLayoutEffect(()=>S(E,L.current),[E,S]),p.useLayoutEffect(()=>U(E,t),[E,t,U]),p.useLayoutEffect(()=>{if(O)return c({disabled:D,element:O,id:E,ownDisabled:i,type:"choice",value:s})},[E,i,D,O,c,s]),p.useLayoutEffect(()=>{N&&C(E,e);},[E,N,e,Q,C]),p.useLayoutEffect(()=>{O&&(O.defaultChecked=N?e:t,Q>0&&(O.checked=y));},[y,N,e,t,O,Q]);function X(T){if(a?.(T),!T.defaultPrevented){if(!N){P(E,T.target.checked);return}v==="skipped"&&e===T.target.checked&&P(E,e);}}let ie={checked:y,disabled:D,invalid:f,shortcut:w,type:R};return {inputProps:{ref:V,"aria-invalid":f||void 0,"aria-keyshortcuts":Ie(w,!D&&y),checked:y,disabled:D,id:E,name:v==="skipped"?void 0:d,onChange:X,required:B&&!g&&!u,type:R,value:s},state:ie}}function _e({defaultValue:e,disabled:t=false,onChange:i,ref:a,type:s="text",value:o}){let{disabled:u,invalid:f,name:g,registerAnswerControl:d,registerAnswerSelection:c$1,resetVersion:S,selectedAnswerIds:B,setAnswerDefault:Q,setAnswerSelectionFromInteraction:x,syncControlledAnswerSelection:U}=Z("Questionnaire.Input"),P=p.useId(),A=p.useRef(null),G=p.useRef(ce(e)),v=o!==void 0,C=ce(e),E=ce(o),[O,V]=p.useState(C),L=u||t,N=v?E:O,D=B.includes(P);p.useLayoutEffect(()=>c$1(P,G.current),[P,c$1]),p.useLayoutEffect(()=>Q(P,C),[C,P,Q]),p.useLayoutEffect(()=>{let w=A.current;if(w)return d({disabled:L,element:w,id:P,type:"input"})},[L,P,d]),p.useLayoutEffect(()=>{if(v){U(P,E);return}S>0&&(V(C),A.current&&(A.current.value=A.current.defaultValue));},[v,E,o,C,P,S,U]),p.useLayoutEffect(()=>{let w=A.current;!w||!v||(w.defaultValue=String(o));},[v,o]);function M(w){if(i?.(w),w.defaultPrevented)return;let X=w.target.value.trim().length>0;v||(V(X),x(P,X));}let y={disabled:L,filled:N,invalid:f},R=p.useCallback(w=>{A.current=w,c(a)?.(w);},[a]);return {inputProps:{"aria-invalid":f||void 0,"aria-keyshortcuts":Ie(null,!L&&N&&D),defaultValue:v?void 0:e,disabled:L,form:D?void 0:"",id:P,name:D?g:void 0,onChange:M,ref:R,type:s,value:v?o:void 0},state:y}}function We(e){return e===void 0?null:{enabledItems:e.filter(t=>!t.disabled),itemByName:new Map(e.map(t=>[t.name,t])),items:e}}function we(e,t){if(!e)return t??null;let i=t?e.itemByName.get(t):void 0;return i&&!i.disabled?i.name:e.enabledItems[0]?.name??null}function Ge(e,t){let i=new Map;if(!e||!t)return i;let a=me(t),s=0;for(let o of e.choices??[]){if(o.disabled)continue;let u=a[s];if(!u)break;i.set(o.value,u),s+=1;}return i}function je(e,t){let i=[],a=new Set;for(let s of e.items){a.has(s.name)&&i.push(`Item name "${s.name}" is defined more than once.`),a.add(s.name);let o=new Set;for(let u of s.choices??[])o.has(u.value)&&i.push(`Choice value "${u.value}" is defined more than once in item "${s.name}".`),o.add(u.value);}if(t){let s=e.itemByName.get(t);(!s||s.disabled)&&i.push(`defaultItem "${t}" does not identify an enabled item. The first enabled item will be used instead.`);}return i}function ze(e,t,i){let a=[],s=new Map(t.map(o=>[o.name,o]));for(let o of e.items){let u=s.get(o.name);if(!u){o.disabled||a.push(`Item "${o.name}" is defined but has no rendered Questionnaire.Item.`);continue}u.disabled!==!!o.disabled&&a.push(`Item "${o.name}" has different disabled values in Root.items and Questionnaire.Item.`),u.required!==!!o.required&&a.push(`Item "${o.name}" has different required values in Root.items and Questionnaire.Item.`);let f=o.choices??[],g=new Map(f.map(c=>[c.value,c])),d=new Map(u.choices.map(c=>[c.value,c]));for(let c of f){let S=d.get(c.value);if(!S){a.push(`Choice "${c.value}" is defined for item "${o.name}" but has no rendered Questionnaire.Choice.`);continue}S.disabled!==!!c.disabled&&a.push(`Choice "${c.value}" in item "${o.name}" has different disabled values in Root.items and Questionnaire.Choice.`);}if(i){for(let Q of u.choices)g.has(Q.value)||a.push(`Rendered choice "${Q.value}" in item "${o.name}" is missing from Root.items and will not receive a shortcut.`);let c=f.filter(Q=>!Q.disabled).map(Q=>Q.value),S=u.choices.filter(Q=>!Q.disabled).map(Q=>Q.value);c.length>0&&c.length===S.length&&c.every(Q=>S.includes(Q))&&c.some((Q,x)=>Q!==S[x])&&a.push(`Choice order for item "${o.name}" differs between Root.items and the rendered Questionnaire.Choice elements.`);}}for(let o of t)!o.disabled&&!e.itemByName.has(o.name)&&a.push(`Rendered item "${o.name}" is missing from Root.items and is excluded from the questionnaire collection.`);return a}function Je({"aria-describedby":e,"aria-keyshortcuts":t,disabled:i=false,invalid:a=false,multiple:s=false,name:o,onStatusChange:u,ref:f,required:g=false}){let{activeItemName:d,domVersion:c$1,first:S,itemDefinitionByName:B,last:Q,nativeValidation:x,registerItem:U,shortcuts:P}=ne("Questionnaire.Item"),[A,G]=p.useState(null),[v,C]=p.useState([]),[E,O]=p.useState(false),[V,L]=p.useState([]),[N,D]=p.useState(false),[M,y]=p.useState(0),[R,w]=p.useState([]),[X,ie]=p.useState([]),T=p.useRef([]),q=p.useRef(s),de=p.useRef(s);q.current=s;let _=!i&&d===o,j=p.useMemo(()=>[...v].sort(Ue),[v,c$1]),h=p.useMemo(()=>j.filter(r=>!r.disabled),[j]),ge=h.some(r=>V.includes(r.id)),F=N?"skipped":ge?"answered":"unanswered",re=F==="skipped"&&!g,se=i||re||!a&&F==="answered",ee=!i&&!re&&(a||E&&!se),Re=h.some(r=>r.type==="input"),Qe=p.useRef(F),Ce=B?.get(o),J=p.useMemo(()=>B?Ge(Ce,P):null,[Ce,B,P]),ae=p.useMemo(()=>{if(J)return new Map;let r=me(P),m=h.filter(l=>l.type==="choice");return new Map(m.slice(0,r.length).map((l,$)=>[l.id,r[$]]))},[h,J,P]),ye=p.useCallback(r=>(C(m=>[...m.filter(l=>l.element!==r.element&&l.id!==r.id),r]),()=>{C(m=>m.filter(l=>l!==r));}),[]);p.useLayoutEffect(()=>{Qe.current!==F&&(Qe.current=F,u?.(F));},[u,F]);let n=p.useCallback((r,m)=>{L(l=>m?s?l.includes(r)?l:[...l,r]:[r]:l.filter($=>$!==r));},[s]),b=p.useCallback((r,m)=>{D(false),n(r,m);},[n]),k=p.useCallback((r,m)=>{m&&D(false),n(r,m);},[n]),Y=p.useCallback((r,m)=>(m&&(T.current=[...T.current.filter(l=>l!==r),r],L(l=>q.current?l.includes(r)?l:[...l,r]:l.length?l:[r])),()=>{T.current=T.current.filter(l=>l!==r),L(l=>l.filter($=>$!==r));}),[]),xe=p.useCallback((r,m)=>{if(m){T.current=T.current.includes(r)?T.current:[...T.current,r];return}T.current=T.current.filter(l=>l!==r);},[]),Me=p.useCallback(r=>(w(m=>m.includes(r)?m:[...m,r]),()=>{w(m=>m.filter(l=>l!==r));}),[]),Ae=p.useCallback(r=>(ie(m=>m.includes(r)?m:[...m,r]),()=>{ie(m=>m.filter(l=>l!==r));}),[]),Ne=p.useCallback(()=>{if(O(true),!se)return false;if(!x)return true;let r=h.find(m=>pe(m)&&m.element.willValidate&&!m.element.validity.valid);return r?(r.element.focus(),r.element.reportValidity(),false):true},[h,x,se]),Te=p.useCallback(()=>{A?.focus();},[A]),Le=p.useCallback(()=>{let r=A?.querySelector("input[data-filled][name]:not(:disabled)"),m=A?.querySelector("input:not([type=hidden]):not(:disabled), textarea:not(:disabled)");(r??m??A)?.focus();},[A]),De=p.useCallback(()=>{O(false),D(false),L(s?[...T.current]:T.current.slice(0,1)),y(r=>r+1);},[s]),Be=p.useCallback(()=>{g||(L([]),D(true));},[g]);p.useLayoutEffect(()=>{let r=de.current;de.current=s,!(!r||s)&&L(m=>{let l=h.find($=>m.includes($.id));return l?[l.id]:[]});},[h,s]);let Fe=p.useCallback(r=>h.find(m=>m.element===r)??null,[h]),Ve=p.useCallback(r=>{if(J){let l=Array.from(J.entries()).find(([,$])=>$===r)?.[0];return h.find($=>$.type==="choice"&&$.value===l)??null}let m=Array.from(ae.entries()).find(([,l])=>l===r)?.[0];return h.find(l=>l.id===m)??null},[h,ae,J]),Oe=p.useCallback((r,m)=>{let l=h.findIndex(Qt=>Qt.element===r),$=l<0?null:h[l]??null;if(!h.length||he(r)&&!$e($)||l<0&&r!==A)return false;let oe=l<0?h.find(pe)??(m==="next"?h[0]:h[h.length-1]):h[(l+(m==="next"?1:-1)+h.length)%h.length];return !oe||oe.element===r||l>=0&&le(r)&&le(oe.element)?false:(oe.element.focus(),oe.type==="choice"&&le(oe.element)&&oe.element.click(),true)},[h,A]);p.useLayoutEffect(()=>{if(A)return U({choices:j.flatMap(r=>r.type==="choice"?[{disabled:r.ownDisabled,value:r.value}]:[]),disabled:i,element:A,focus:Te,focusInvalid:Le,getAnswerByElement:Fe,getAnswerByShortcut:Ve,moveAnswerFocus:Oe,name:o,required:g,reset:De,skip:Be,status:F,validate:Ne})},[j,i,A,Te,Le,Fe,Ve,Oe,o,U,g,De,Be,F,Ne]);let pt=p.useMemo(()=>({active:_,disabled:i,hasInputAnswer:Re,invalid:ee,multiple:s,name:o,registerAnswerControl:ye,registerAnswerSelection:Y,registerDescription:Me,registerError:Ae,required:g,resetVersion:M,selectedAnswerIds:V,setAnswerDefault:xe,setAnswerSelectionFromInteraction:b,shortcutByAnswerId:ae,shortcutByChoiceValue:J,shortcuts:P,status:F,syncControlledAnswerSelection:k}),[_,i,Re,ee,s,o,ye,Y,Me,Ae,g,M,V,xe,b,ae,J,P,F,k]),ht=p.useCallback(r=>{G(r),c(f)?.(r);},[f]),gt=[...R,...ee?X:[],e].filter(Boolean).join(" ")||void 0,Rt=[t,_?"Meta+Enter Control+Enter":void 0,_&&h.length?"ArrowUp ArrowDown":void 0,_&&!S?"ArrowLeft":void 0,_&&!Q&&F!=="unanswered"?"ArrowRight":void 0].filter(Boolean).join(" ")||void 0;return {context:pt,itemProps:{"aria-describedby":gt,"aria-invalid":ee||void 0,"aria-keyshortcuts":Rt,disabled:i,hidden:!_,inert:!_,ref:ht,tabIndex:-1},state:{active:_,disabled:i,invalid:ee,multiple:s,required:g,status:F}}}function Xe({defaultItem:e,item:t,items:i,noValidate:a,onItemChange:s,onReset:o,onSubmit:u,ref:f,shortcuts:g}){let d=p.useMemo(()=>We(i),[i]),[c$1,S]=p.useState([]),[B,Q]=p.useState(()=>we(d,e)),[x,U]=p.useState(null),[P,A]=p.useState(0),G=p.useRef(null),v=t!==void 0,C=v?t:B,E=p.useRef(C),O=a===false,V=g??null,L=p.useRef(new Set);p.useLayoutEffect(()=>{if(process.env.NODE_ENV==="production")return;if(!d||!x){L.current.clear();return}let n=false;return queueMicrotask(()=>{if(n)return;let b=[...je(d,e),...ze(d,c$1,V)],k=new Set(b);k.forEach(Y=>{L.current.has(Y)||console.warn(`[Questionnaire] ${Y}`);}),L.current=k;}),()=>{n=true;}},[d,e,c$1,x,V]),p.useLayoutEffect(()=>{if(!x||typeof MutationObserver>"u")return;let n=new MutationObserver(()=>{A(b=>b+1);});return n.observe(x,{childList:true,subtree:true}),()=>n.disconnect()},[x]);let N=p.useMemo(()=>c$1.filter(n=>!n.disabled).sort(Ke),[P,c$1]),D=p.useMemo(()=>new Map(N.map(n=>[n.name,n])),[N]),M=d?.enabledItems??N,y=M.findIndex(n=>n.name===C),R=y<0||!C?null:D.get(C)??null,w=C?d?.itemByName.get(C):void 0,X=y<0?null:w?!!w.required:R?.required??false,ie=y<0?null:R?.status??(C?"unanswered":null),T=p.useMemo(()=>d?d.enabledItems.flatMap(n=>{let b=D.get(n.name);return b?[b]:[]}):N,[d,D,N]),q=M.length,de=y<0?0:y+1,_=q>0&&y===0,j=q>0&&y===q-1,h=p.useCallback((n,b="item")=>{n!==C&&(G.current={name:n,target:b},v||Q(n),s?.(n));},[C,v,s]);p.useLayoutEffect(()=>{if(q===0)return;if(y<0){if(!v&&C===null){Q(M[0].name);return}h(M[0].name);return}let n=G.current,b=E.current!==C;if(E.current=C,!n||n.name!==C){v&&b&&(G.current=null,R?.focus());return}n.target==="invalid"?R?.focusInvalid():R?.focus(),G.current=null;},[R,C,v,y,M,h,q]);let ge=p.useCallback(n=>(S(b=>[...b.filter(k=>k.element!==n.element&&k.name!==n.name),n]),()=>{S(b=>b.filter(k=>k!==n));}),[]),F=p.useCallback(()=>{y<=0||h(M[y-1].name);},[y,M,h]),re=p.useCallback(()=>{if(!(!R||y>=q-1)){if(!R.validate()){R.focusInvalid();return}h(M[y+1].name);}},[R,y,M,h,q]),se=p.useCallback(()=>{if(R){if(!R.validate()){R.focusInvalid();return}if(j){x?.requestSubmit();return}h(M[y+1].name);}},[R,y,j,M,x,h]),ee=p.useCallback(()=>{if(!(!R||R.required)){if(R.skip(),!j){h(M[y+1].name);return}queueMicrotask(()=>{x?.requestSubmit();});}},[R,y,j,M,x,h]);function Re(n){if(o?.(n),n.defaultPrevented)return;for(let k of c$1)k.reset();let b=d?we(d,e):N.find(k=>k.name===e)?.name??N[0]?.name;b&&h(b);}function Qe(n){let b=T.find(k=>!k.validate());if(b){n.preventDefault(),h(b.name,"invalid"),b.name===C&&(b.focusInvalid(),G.current=null);return}u?.(n);}function Ce(n){if(n.defaultPrevented||n.nativeEvent.isComposing||n.keyCode===229||!R||!(n.target instanceof Element))return;if(n.key==="Enter"&&(n.metaKey||n.ctrlKey)&&!n.altKey&&!n.shiftKey){n.preventDefault(),n.repeat||se();return}if(n.metaKey||n.ctrlKey||n.altKey)return;if((n.key==="ArrowUp"||n.key==="ArrowDown")&&R.moveAnswerFocus(n.target,n.key==="ArrowDown"?"next":"previous")){n.preventDefault();return}if((n.key==="ArrowLeft"||n.key==="ArrowRight")&&!he(n.target)&&!le(n.target)){if(n.preventDefault(),n.repeat)return;n.key==="ArrowLeft"?F():R.status!=="unanswered"&&re();return}if(n.key==="Enter"){let Y=R.getAnswerByElement(n.target);if(!Y)return;n.preventDefault(),!n.repeat&&pe(Y)&&se();return}if(!V||he(n.target))return;let b=He(n.key,V),k=b?R.getAnswerByShortcut(b):null;k&&(n.preventDefault(),!n.repeat&&(k.element.focus(),k.type==="choice"&&k.element.click()));}let J={current:de,first:_,last:j,total:q},ae=p.useMemo(()=>({...J,activeItem:R,activeItemName:C,activeItemRequired:X,activeItemStatus:ie,domVersion:P,goNext:re,goPrevious:F,itemDefinitionByName:d?.itemByName??null,nativeValidation:O,registerItem:ge,shortcuts:V,skipCurrent:ee}),[R,C,X,ie,d,de,P,_,re,F,j,O,ge,V,ee,q]),ye=p.useCallback(n=>{U(n),c(f)?.(n);},[f]);return {context:ae,rootProps:{"data-shortcuts":V??void 0,onKeyDown:Ce,onReset:Re,onSubmit:Qe,ref:ye},state:J}}function Ye({defaultItem:e,item:t,items:i,noValidate:a$1=true,onItemChange:s,onReset:o,onSubmit:u,ref:f,shortcuts:g,...d}){let{context:c,rootProps:S,state:B}=Xe({defaultItem:e,item:t,items:i,noValidate:a$1,onItemChange:s,onReset:o,onSubmit:u,ref:f,shortcuts:g}),Q=a({defaultTagName:"form",props:b({...S,noValidate:a$1},d),state:B});return jsx(ve.Provider,{value:c,children:Q})}function Ze({children:e,render:t,...i}){let{current:a$1,first:s,last:o,total:u}=ne("Questionnaire.Progress"),f=u?`Question ${a$1} of ${u}`:void 0;return a({defaultTagName:"div",props:b({"aria-label":"Questionnaire progress","aria-live":"polite","aria-valuemax":u||void 0,"aria-valuemin":u?1:void 0,"aria-valuenow":u?a$1:void 0,"aria-valuetext":f,children:e??f,role:"progressbar"},i),render:t,state:{current:a$1,first:s,last:o,total:u}})}function et({"aria-describedby":e,"aria-keyshortcuts":t,children:i,disabled:a$1=false,invalid:s=false,multiple:o=false,name:u,onStatusChange:f,ref:g,required:d=false,...c}){let{context:S,itemProps:B,state:Q}=Je({"aria-describedby":e,"aria-keyshortcuts":t,disabled:a$1,invalid:s,multiple:o,name:u,onStatusChange:f,ref:g,required:d}),x=a({defaultTagName:"fieldset",props:b({...B,children:i},c),state:Q,stateAttributesMapping:{active:U=>({"data-active":U?"":void 0})}});return jsx(Ee.Provider,{value:S,children:x})}function tt({render:e,...t}){return Z("Questionnaire.Title"),a({defaultTagName:"legend",props:t,render:e})}function nt({id:e,render:t,...i}){let{registerDescription:a$1}=Z("Questionnaire.Description"),s=p.useId(),o=e??s;return p.useLayoutEffect(()=>a$1(o),[o,a$1]),a({defaultTagName:"p",props:b({id:o},i),render:t})}function it({render:e,...t}){let{shortcuts:i}=Z("Questionnaire.Choices");return a({defaultTagName:"div",props:t,render:e,state:{shortcuts:i}})}function ot({checked:e,children:t,defaultChecked:i=false,disabled:a$1=false,onChange:s,render:o,value:u,...f}){let{inputProps:g,state:d}=qe({checked:e,defaultChecked:i,disabled:a$1,onChange:s,value:u}),c=a({defaultTagName:"label",props:b({children:t},f),render:o,state:d,stateAttributesMapping:{checked:S=>({"data-checked":S?"":void 0,"data-unchecked":S?void 0:""})}});return jsx(Pe.Provider,{value:{inputProps:g,state:d},children:c})}function rt({render:e,...t}){let{inputProps:i,state:a$1}=be("Questionnaire.ChoiceInput");return a({defaultTagName:"input",props:b(i,t),render:e,state:a$1,stateAttributesMapping:{checked:s=>({"data-checked":s?"":void 0,"data-unchecked":s?void 0:""})}})}function st({render:e,...t}){return be("Questionnaire.ChoiceLabel"),a({defaultTagName:"span",props:t,render:e})}function at({children:e,render:t,...i}){let{state:a$1}=be("Questionnaire.ChoiceShortcut"),s={shortcut:a$1.shortcut};return a({defaultTagName:"span",props:b({"aria-hidden":true,children:e??a$1.shortcut,hidden:a$1.shortcut===null},i),render:t,state:s})}function ut({defaultValue:e,disabled:t=false,onChange:i,ref:a$1,render:s,type:o="text",value:u,...f}){let{inputProps:g,state:d}=_e({defaultValue:e,disabled:t,onChange:i,ref:a$1,type:o,value:u});return a({defaultTagName:"input",props:b(g,f),render:s,state:d,stateAttributesMapping:{filled:c=>({"data-empty":c?void 0:"","data-filled":c?"":void 0})}})}function ct({children:e,id:t,render:i,...a$1}){let{invalid:s,registerError:o,required:u}=Z("Questionnaire.Error"),f=p.useId(),g=t??f;return p.useLayoutEffect(()=>o(g),[g,o]),a({defaultTagName:"p",props:b({children:e??(u?"Choose an answer to continue.":"Choose an answer or skip this question."),hidden:!s,id:g,role:s?"alert":void 0},a$1),render:i,state:{invalid:s}})}function lt({children:e,disabled:t=false,onClick:i,render:a,tabIndex:s,type:o="button",...u}){let f=ne("Questionnaire.Previous"),g=f.total>1&&!f.first;function d(c){i?.(c),c.defaultPrevented||f.goPrevious();}return Se({children:e??"Previous",disabled:t,onClick:d,props:u,render:a,status:f.activeItemStatus,tabIndex:s,type:o,visible:g})}function ft({children:e,disabled:t=false,onClick:i,render:a,tabIndex:s,type:o="button",...u}){let f=ne("Questionnaire.Skip"),g=f.activeItemRequired===false;function d(c){i?.(c),c.defaultPrevented||f.skipCurrent();}return Se({children:e??"Skip",disabled:t,onClick:d,props:u,render:a,status:f.activeItemStatus,tabIndex:s,type:o,visible:g})}function dt({children:e,disabled:t=false,onClick:i,render:a,tabIndex:s,type:o="button",...u}){let f=ne("Questionnaire.Next"),g=f.total>1&&!f.last;function d(c){i?.(c),c.defaultPrevented||f.goNext();}return Se({children:e??"Next",disabled:t,onClick:d,props:u,render:a,shortcut:"Enter",status:f.activeItemStatus,tabIndex:s,type:o,visible:g})}function mt({children:e,disabled:t=false,render:i,tabIndex:a,type:s="submit",...o}){let u=ne("Questionnaire.Submit"),f=u.total>0&&u.last;return Se({children:e??"Submit",disabled:t,props:o,render:i,shortcut:"Enter",status:u.activeItemStatus,tabIndex:a,type:s,visible:f})}function Se({children:e,disabled:t,onClick:i,props:a$1,render:s,shortcut:o,status:u,tabIndex:f,type:g,visible:d}){let c=d&&!t?o??null:null,S={disabled:t,shortcut:c,status:u,visible:d};return a({defaultTagName:"button",props:b({"aria-hidden":!d||void 0,"aria-keyshortcuts":c??void 0,children:e,disabled:t,hidden:!d,inert:!d,onClick:i,tabIndex:d?f:-1,type:g},a$1),render:s,state:S,stateAttributesMapping:{visible:B=>({"data-hidden":B?void 0:"","data-visible":B?"":void 0})}})}var zt={Root:Ye,Progress:Ze,Item:et,Title:tt,Description:nt,Choices:it,Choice:ot,ChoiceInput:rt,ChoiceLabel:st,ChoiceShortcut:at,Input:ut,Error:ct,Previous:lt,Skip:ft,Next:dt,Submit:mt};export{zt as Questionnaire};
35
+
@@ -0,0 +1,20 @@
1
+ diff --git a/dist/index.js b/dist/index.js
2
+ index f3e7d22145ffd15c28b0cd51d5a691810f54cbe1..e0a816f0a985b9460d9f4a26ac4588b2072f84a6 100644
3
+ --- a/dist/index.js
4
+ +++ b/dist/index.js
5
+ @@ -1,4 +1,4 @@
6
+ -var jt=Object.create;var F=Object.defineProperty,Nt=Object.defineProperties,$t=Object.getOwnPropertyDescriptor,Ft=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertyNames,Z=Object.getOwnPropertySymbols,Xt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var bt=(e,n,t)=>n in e?F(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,wt=(e,n)=>{for(var t in n||(n={}))ot.call(n,t)&&bt(e,t,n[t]);if(Z)for(var t of Z(n))Pt.call(n,t)&&bt(e,t,n[t]);return e},_t=(e,n)=>Nt(e,Ft(n));var Tt=(e,n)=>{var t={};for(var l in e)ot.call(e,l)&&n.indexOf(l)<0&&(t[l]=e[l]);if(e!=null&&Z)for(var l of Z(e))n.indexOf(l)<0&&Pt.call(e,l)&&(t[l]=e[l]);return t};var Yt=(e,n)=>{for(var t in n)F(e,t,{get:n[t],enumerable:!0})},Ct=(e,n,t,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let m of Vt(n))!ot.call(e,m)&&m!==t&&F(e,m,{get:()=>n[m],enumerable:!(l=$t(n,m))||l.enumerable});return e};var rt=(e,n,t)=>(t=e!=null?jt(Xt(e)):{},Ct(n||!e||!e.__esModule?F(t,"default",{value:e,enumerable:!0}):t,e)),zt=e=>Ct(F({},"__esModule",{value:!0}),e);var ee={};Yt(ee,{OTPInput:()=>Bt,OTPInputContext:()=>Ht,REGEXP_ONLY_CHARS:()=>Qt,REGEXP_ONLY_DIGITS:()=>Jt,REGEXP_ONLY_DIGITS_AND_CHARS:()=>te});module.exports=zt(ee);var o=rt(require("react"));function Mt(e){let n=setTimeout(e,0),t=setTimeout(e,10),l=setTimeout(e,50);return[n,t,l]}var q=rt(require("react"));function It(e){let n=q.useRef();return q.useEffect(()=>{n.current=e}),n.current}var S=rt(require("react")),Ut=18,at=40,Zt=`${at}px`;function yt(e){let n=e.getBoundingClientRect().right,t=e;for(;t;){if(getComputedStyle(t).overflowX!=="visible")return t.getBoundingClientRect().left+t.clientLeft+t.clientWidth-n;t=t.parentElement}return document.documentElement.clientWidth-n}var qt=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function Dt({containerRef:e,inputRef:n,pushPasswordManagerStrategy:t,isFocused:l}){let[m,T]=S.useState(!1),[x,M]=S.useState(!1),[X,I]=S.useState(!1),K=S.useMemo(()=>t==="none"?!1:(t==="increase-width"||t==="experimental-no-flickering")&&m&&x,[m,x,t]),y=S.useCallback(()=>{let p=e.current,b=n.current;if(!p||!b||X||t==="none")return;let v=p,i=v.getBoundingClientRect().left+v.offsetWidth,G=v.getBoundingClientRect().top+v.offsetHeight/2,ct=i-Ut,Y=G;document.querySelectorAll(qt).length===0&&document.elementFromPoint(ct,Y)===p||(M(yt(p)>=at),T(!0),I(!0))},[e,n,X,t]);return S.useEffect(()=>{let p=e.current;if(!p||t==="none")return;function b(){M(yt(p)>=at)}b();let v=setInterval(b,1e3);return()=>{clearInterval(v)}},[e,t]),S.useEffect(()=>{let p=l||document.activeElement===n.current;if(t==="none"||!p)return;let b=setTimeout(y,0),v=setTimeout(y,2e3),i=setTimeout(y,5e3),G=setTimeout(()=>{I(!0)},6e3);return()=>{clearTimeout(b),clearTimeout(v),clearTimeout(i),clearTimeout(G)}},[n,l,t,y]),{hasPWMBadge:m,willPushPWMBadge:K,PWM_BADGE_SPACE_WIDTH:Zt}}var Ht=o.createContext({}),Bt=o.forwardRef((ct,G)=>{var Y=ct,{value:e,onChange:n,maxLength:t,textAlign:l="left",pattern:m,placeholder:T,inputMode:x="numeric",onComplete:M,pushPasswordManagerStrategy:X="increase-width",pasteTransformer:I,containerClassName:K,noScriptCSSFallback:y=Kt,nonce:p,render:b,children:v}=Y,i=Tt(Y,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","nonce","render","children"]);var U,Rt,vt,gt,Et;let[it,st]=o.useState(typeof i.defaultValue=="string"?i.defaultValue:""),u=e!=null?e:it,D=It(u),O=o.useCallback(a=>{n==null||n(a),st(a)},[n]),R=o.useMemo(()=>m?typeof m=="string"?new RegExp(m):m:null,[m]),d=o.useRef(null),J=o.useRef(null),Q=o.useRef({value:u,onChange:O,isIOS:typeof window!="undefined"&&((Rt=(U=window==null?void 0:window.CSS)==null?void 0:U.supports)==null?void 0:Rt.call(U,"-webkit-touch-callout","none"))}),z=o.useRef({prev:[(vt=d.current)==null?void 0:vt.selectionStart,(gt=d.current)==null?void 0:gt.selectionEnd,(Et=d.current)==null?void 0:Et.selectionDirection]});o.useImperativeHandle(G,()=>d.current,[]),o.useEffect(()=>{let a=d.current,r=J.current;if(!a||!r)return;Q.current.value!==a.value&&Q.current.onChange(a.value),z.current.prev=[a.selectionStart,a.selectionEnd,a.selectionDirection];function c(){if(document.activeElement!==a){j(null),N(null);return}let s=a.selectionStart,w=a.selectionEnd,$=a.selectionDirection,g=a.maxLength,B=a.value,_=z.current.prev,E=-1,h=-1,C;if(B.length!==0&&s!==null&&w!==null){let Gt=s===w,Ot=s===B.length&&B.length<g;if(Gt&&!Ot){let W=s;if(W===0)E=0,h=1,C="forward";else if(W===g)E=W-1,h=W,C="backward";else if(g>1&&B.length>1){let nt=0;if(_[0]!==null&&_[1]!==null){C=W<_[1]?"backward":"forward";let Lt=_[0]===_[1]&&_[0]<g;C==="backward"&&!Lt&&(nt=-1)}E=nt+W,h=nt+W+1}}E!==-1&&h!==-1&&E!==h&&a.setSelectionRange(E,h,C)}let ht=E!==-1?E:s,St=h!==-1?h:w,xt=C!=null?C:$;j(ht),N(St),z.current.prev=[ht,St,xt]}if(document.addEventListener("selectionchange",c,{capture:!0}),c(),document.activeElement===a&&tt(!0),!document.getElementById("input-otp-style")){let s=document.createElement("style");if(s.id="input-otp-style",p&&s.setAttribute("nonce",p),document.head.appendChild(s),s.sheet){let w="background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";V(s.sheet,"[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"),V(s.sheet,`[data-input-otp]:autofill { ${w} }`),V(s.sheet,`[data-input-otp]:-webkit-autofill { ${w} }`),V(s.sheet,"@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"),V(s.sheet,"[data-input-otp] + * { pointer-events: all !important; }")}}let P=()=>{r&&r.style.setProperty("--root-height",`${a.clientHeight}px`)};P();let f=typeof ResizeObserver=="undefined"?null:new ResizeObserver(P);return f==null||f.observe(a),()=>{document.removeEventListener("selectionchange",c,{capture:!0}),f==null||f.disconnect()}},[]);let[lt,ut]=o.useState(!1),[L,tt]=o.useState(!1),[H,j]=o.useState(null),[A,N]=o.useState(null);o.useEffect(()=>{let a=Mt(()=>{var f,s,w,$;(f=d.current)==null||f.dispatchEvent(new Event("input"));let r=(s=d.current)==null?void 0:s.selectionStart,c=(w=d.current)==null?void 0:w.selectionEnd,P=($=d.current)==null?void 0:$.selectionDirection;r!==null&&c!==null&&(j(r),N(c),z.current.prev=[r,c,P])});return()=>{a.forEach(r=>clearTimeout(r))}},[u,L]),o.useEffect(()=>{D!==void 0&&u!==D&&D.length<t&&u.length===t&&(M==null||M(u))},[t,M,D,u]);let k=Dt({containerRef:J,inputRef:d,pushPasswordManagerStrategy:X,isFocused:L}),dt=o.useCallback(a=>{let r=a.currentTarget.value.slice(0,t);if(r.length>0&&R&&!R.test(r)){a.preventDefault();return}typeof D=="string"&&r.length<D.length&&document.dispatchEvent(new Event("selectionchange")),O(r)},[t,O,D,R]),ft=o.useCallback(()=>{var a;if(d.current){let r=Math.min(d.current.value.length,t-1),c=d.current.value.length;(a=d.current)==null||a.setSelectionRange(r,c),j(r),N(c)}tt(!0)},[t]),mt=o.useCallback(a=>{var E,h;let r=d.current;if(!I&&(!Q.current.isIOS||!a.clipboardData||!r))return;let c=a.clipboardData.getData("text/plain"),P=I?I(c):c;a.preventDefault();let f=(E=d.current)==null?void 0:E.selectionStart,s=(h=d.current)==null?void 0:h.selectionEnd,g=(f!==s?u.slice(0,f)+P+u.slice(s):u.slice(0,f)+P+u.slice(f)).slice(0,t);if(g.length>0&&R&&!R.test(g))return;r.value=g,O(g);let B=Math.min(g.length,t-1),_=g.length;r.setSelectionRange(B,_),j(B),N(_)},[t,O,I,R,u]),Wt=o.useMemo(()=>({position:"relative",cursor:i.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[i.disabled]),pt=o.useMemo(()=>({position:"absolute",inset:0,width:k.willPushPWMBadge?`calc(100% + ${k.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:k.willPushPWMBadge?`inset(0 ${k.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:l,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height, 16px)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[k.PWM_BADGE_SPACE_WIDTH,k.willPushPWMBadge,l]),At=o.useMemo(()=>{var a;return o.createElement("input",_t(wt({autoComplete:i.autoComplete||"one-time-code"},i),{"data-input-otp":!0,"data-input-otp-placeholder-shown":u.length===0||void 0,"data-input-otp-mss":H,"data-input-otp-mse":A,inputMode:x,pattern:R==null?void 0:R.source,"aria-placeholder":T,style:pt,maxLength:t,value:u,ref:d,spellCheck:(a=i.spellCheck)!=null?a:!1,onPaste:r=>{var c;mt(r),(c=i.onPaste)==null||c.call(i,r)},onChange:dt,onMouseOver:r=>{var c;ut(!0),(c=i.onMouseOver)==null||c.call(i,r)},onMouseLeave:r=>{var c;ut(!1),(c=i.onMouseLeave)==null||c.call(i,r)},onFocus:r=>{var c;ft(),(c=i.onFocus)==null||c.call(i,r)},onBlur:r=>{var c;tt(!1),(c=i.onBlur)==null||c.call(i,r)}}))},[dt,ft,mt,x,pt,t,A,H,T,i,R==null?void 0:R.source,u]),et=o.useMemo(()=>({slots:Array.from({length:t}).map((a,r)=>{var s;let c=L&&H!==null&&A!==null&&(H===A&&r===H||r>=H&&r<A),P=u[r]!==void 0?u[r]:null,f=u[0]!==void 0?null:(s=T==null?void 0:T[r])!=null?s:null;return{char:P,placeholderChar:f,isActive:c,hasFakeCaret:c&&P===null}}),isFocused:L,isHovering:!i.disabled&&lt}),[L,lt,t,A,H,T,i.disabled,u]),kt=o.useMemo(()=>b?b(et):o.createElement(Ht.Provider,{value:et},v),[v,et,b]);return o.createElement(o.Fragment,null,y!==null&&o.createElement("noscript",null,o.createElement("style",null,y)),o.createElement("div",{ref:J,"data-input-otp-container":!0,translate:"no",style:Wt,className:K},kt,o.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},At)))});Bt.displayName="Input";function V(e,n){try{e.insertRule(n)}catch(t){console.warn("input-otp could not insert CSS rule:",n)}}var Kt=`
7
+ +var jt=Object.create;var F=Object.defineProperty,Nt=Object.defineProperties,$t=Object.getOwnPropertyDescriptor,Ft=Object.getOwnPropertyDescriptors,Vt=Object.getOwnPropertyNames,Z=Object.getOwnPropertySymbols,Xt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable;var bt=(e,n,t)=>n in e?F(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,wt=(e,n)=>{for(var t in n||(n={}))ot.call(n,t)&&bt(e,t,n[t]);if(Z)for(var t of Z(n))Pt.call(n,t)&&bt(e,t,n[t]);return e},_t=(e,n)=>Nt(e,Ft(n));var Tt=(e,n)=>{var t={};for(var l in e)ot.call(e,l)&&n.indexOf(l)<0&&(t[l]=e[l]);if(e!=null&&Z)for(var l of Z(e))n.indexOf(l)<0&&Pt.call(e,l)&&(t[l]=e[l]);return t};var Yt=(e,n)=>{for(var t in n)F(e,t,{get:n[t],enumerable:!0})},Ct=(e,n,t,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let m of Vt(n))!ot.call(e,m)&&m!==t&&F(e,m,{get:()=>n[m],enumerable:!(l=$t(n,m))||l.enumerable});return e};var rt=(e,n,t)=>(t=e!=null?jt(Xt(e)):{},Ct(n||!e||!e.__esModule?F(t,"default",{defaultValue:initialDefaultValue,value:e,enumerable:!0}):t,e)),zt=e=>Ct(F({},"__esModule",{value:!0}),e);var ee={};Yt(ee,{OTPInput:()=>Bt,OTPInputContext:()=>Ht,REGEXP_ONLY_CHARS:()=>Qt,REGEXP_ONLY_DIGITS:()=>Jt,REGEXP_ONLY_DIGITS_AND_CHARS:()=>te});module.exports=zt(ee);var o=rt(require("react"));function Mt(e){let n=setTimeout(e,0),t=setTimeout(e,10),l=setTimeout(e,50);return[n,t,l]}var q=rt(require("react"));function It(e){let n=q.useRef();return q.useEffect(()=>{n.current=e}),n.current}var S=rt(require("react")),Ut=18,at=40,Zt=`${at}px`;function yt(e){let n=e.getBoundingClientRect().right,t=e;for(;t;){if(getComputedStyle(t).overflowX!=="visible")return t.getBoundingClientRect().left+t.clientLeft+t.clientWidth-n;t=t.parentElement}return document.documentElement.clientWidth-n}var qt=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function Dt({containerRef:e,inputRef:n,pushPasswordManagerStrategy:t,isFocused:l}){let[m,T]=S.useState(!1),[x,M]=S.useState(!1),[X,I]=S.useState(!1),K=S.useMemo(()=>t==="none"?!1:(t==="increase-width"||t==="experimental-no-flickering")&&m&&x,[m,x,t]),y=S.useCallback(()=>{let p=e.current,b=n.current;if(!p||!b||X||t==="none")return;let v=p,i=v.getBoundingClientRect().left+v.offsetWidth,G=v.getBoundingClientRect().top+v.offsetHeight/2,ct=i-Ut,Y=G;document.querySelectorAll(qt).length===0&&document.elementFromPoint(ct,Y)===p||(M(yt(p)>=at),T(!0),I(!0))},[e,n,X,t]);return S.useEffect(()=>{let p=e.current;if(!p||t==="none")return;function b(){M(yt(p)>=at)}b();let v=setInterval(b,1e3);return()=>{clearInterval(v)}},[e,t]),S.useEffect(()=>{let p=l||document.activeElement===n.current;if(t==="none"||!p)return;let b=setTimeout(y,0),v=setTimeout(y,2e3),i=setTimeout(y,5e3),G=setTimeout(()=>{I(!0)},6e3);return()=>{clearTimeout(b),clearTimeout(v),clearTimeout(i),clearTimeout(G)}},[n,l,t,y]),{hasPWMBadge:m,willPushPWMBadge:K,PWM_BADGE_SPACE_WIDTH:Zt}}var Ht=o.createContext({}),Bt=o.forwardRef((ct,G)=>{var Y=ct,{value:e,onChange:n,maxLength:t,textAlign:l="left",pattern:m,placeholder:T,inputMode:x="numeric",onComplete:M,pushPasswordManagerStrategy:X="increase-width",pasteTransformer:I,containerClassName:K,noScriptCSSFallback:y=Kt,nonce:p,render:b,children:v}=Y,i=Tt(Y,["defaultValue","value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","nonce","render","children"]);var U,Rt,vt,gt,Et;let[it,st]=o.useState(typeof initialDefaultValue=="string"?initialDefaultValue:""),u=e!=null?e:it,D=It(u),O=o.useCallback(a=>{n==null||n(a),st(a)},[n]),R=o.useMemo(()=>m?typeof m=="string"?new RegExp(m):m:null,[m]),d=o.useRef(null),J=o.useRef(null),Q=o.useRef({value:u,onChange:O,isIOS:typeof window!="undefined"&&((Rt=(U=window==null?void 0:window.CSS)==null?void 0:U.supports)==null?void 0:Rt.call(U,"-webkit-touch-callout","none"))}),z=o.useRef({prev:[(vt=d.current)==null?void 0:vt.selectionStart,(gt=d.current)==null?void 0:gt.selectionEnd,(Et=d.current)==null?void 0:Et.selectionDirection]});o.useImperativeHandle(G,()=>d.current,[]),o.useEffect(()=>{let a=d.current,r=J.current;if(!a||!r)return;Q.current.value!==a.value&&Q.current.onChange(a.value),z.current.prev=[a.selectionStart,a.selectionEnd,a.selectionDirection];function c(){if(document.activeElement!==a){j(null),N(null);return}let s=a.selectionStart,w=a.selectionEnd,$=a.selectionDirection,g=a.maxLength,B=a.value,_=z.current.prev,E=-1,h=-1,C;if(B.length!==0&&s!==null&&w!==null){let Gt=s===w,Ot=s===B.length&&B.length<g;if(Gt&&!Ot){let W=s;if(W===0)E=0,h=1,C="forward";else if(W===g)E=W-1,h=W,C="backward";else if(g>1&&B.length>1){let nt=0;if(_[0]!==null&&_[1]!==null){C=W<_[1]?"backward":"forward";let Lt=_[0]===_[1]&&_[0]<g;C==="backward"&&!Lt&&(nt=-1)}E=nt+W,h=nt+W+1}}E!==-1&&h!==-1&&E!==h&&a.setSelectionRange(E,h,C)}let ht=E!==-1?E:s,St=h!==-1?h:w,xt=C!=null?C:$;j(ht),N(St),z.current.prev=[ht,St,xt]}if(document.addEventListener("selectionchange",c,{capture:!0}),c(),document.activeElement===a&&tt(!0),!document.getElementById("input-otp-style")){let s=document.createElement("style");if(s.id="input-otp-style",p&&s.setAttribute("nonce",p),document.head.appendChild(s),s.sheet){let w="background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";V(s.sheet,"[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"),V(s.sheet,`[data-input-otp]:autofill { ${w} }`),V(s.sheet,`[data-input-otp]:-webkit-autofill { ${w} }`),V(s.sheet,"@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"),V(s.sheet,"[data-input-otp] + * { pointer-events: all !important; }")}}let P=()=>{r&&r.style.setProperty("--root-height",`${a.clientHeight}px`)};P();let f=typeof ResizeObserver=="undefined"?null:new ResizeObserver(P);return f==null||f.observe(a),()=>{document.removeEventListener("selectionchange",c,{capture:!0}),f==null||f.disconnect()}},[]);let[lt,ut]=o.useState(!1),[L,tt]=o.useState(!1),[H,j]=o.useState(null),[A,N]=o.useState(null);o.useEffect(()=>{let a=Mt(()=>{var f,s,w,$;(f=d.current)==null||f.dispatchEvent(new Event("input"));let r=(s=d.current)==null?void 0:s.selectionStart,c=(w=d.current)==null?void 0:w.selectionEnd,P=($=d.current)==null?void 0:$.selectionDirection;r!==null&&c!==null&&(j(r),N(c),z.current.prev=[r,c,P])});return()=>{a.forEach(r=>clearTimeout(r))}},[u,L]),o.useEffect(()=>{D!==void 0&&u!==D&&D.length<t&&u.length===t&&(M==null||M(u))},[t,M,D,u]);let k=Dt({containerRef:J,inputRef:d,pushPasswordManagerStrategy:X,isFocused:L}),dt=o.useCallback(a=>{let r=a.currentTarget.value.slice(0,t);if(r.length>0&&R&&!R.test(r)){a.preventDefault();return}typeof D=="string"&&r.length<D.length&&document.dispatchEvent(new Event("selectionchange")),O(r)},[t,O,D,R]),ft=o.useCallback(()=>{var a;if(d.current){let r=Math.min(d.current.value.length,t-1),c=d.current.value.length;(a=d.current)==null||a.setSelectionRange(r,c),j(r),N(c)}tt(!0)},[t]),mt=o.useCallback(a=>{var E,h;let r=d.current;if(!I&&(!Q.current.isIOS||!a.clipboardData||!r))return;let c=a.clipboardData.getData("text/plain"),P=I?I(c):c;a.preventDefault();let f=(E=d.current)==null?void 0:E.selectionStart,s=(h=d.current)==null?void 0:h.selectionEnd,g=(f!==s?u.slice(0,f)+P+u.slice(s):u.slice(0,f)+P+u.slice(f)).slice(0,t);if(g.length>0&&R&&!R.test(g))return;r.value=g,O(g);let B=Math.min(g.length,t-1),_=g.length;r.setSelectionRange(B,_),j(B),N(_)},[t,O,I,R,u]),Wt=o.useMemo(()=>({position:"relative",cursor:i.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[i.disabled]),pt=o.useMemo(()=>({position:"absolute",inset:0,width:k.willPushPWMBadge?`calc(100% + ${k.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:k.willPushPWMBadge?`inset(0 ${k.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:l,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height, 16px)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[k.PWM_BADGE_SPACE_WIDTH,k.willPushPWMBadge,l]),At=o.useMemo(()=>{var a;return o.createElement("input",_t(wt({autoComplete:i.autoComplete||"one-time-code"},i),{"data-input-otp":!0,"data-input-otp-placeholder-shown":u.length===0||void 0,"data-input-otp-mss":H,"data-input-otp-mse":A,inputMode:x,pattern:R==null?void 0:R.source,"aria-placeholder":T,style:pt,maxLength:t,value:u,ref:d,spellCheck:(a=i.spellCheck)!=null?a:!1,onPaste:r=>{var c;mt(r),(c=i.onPaste)==null||c.call(i,r)},onChange:dt,onMouseOver:r=>{var c;ut(!0),(c=i.onMouseOver)==null||c.call(i,r)},onMouseLeave:r=>{var c;ut(!1),(c=i.onMouseLeave)==null||c.call(i,r)},onFocus:r=>{var c;ft(),(c=i.onFocus)==null||c.call(i,r)},onBlur:r=>{var c;tt(!1),(c=i.onBlur)==null||c.call(i,r)}}))},[dt,ft,mt,x,pt,t,A,H,T,i,R==null?void 0:R.source,u]),et=o.useMemo(()=>({slots:Array.from({length:t}).map((a,r)=>{var s;let c=L&&H!==null&&A!==null&&(H===A&&r===H||r>=H&&r<A),P=u[r]!==void 0?u[r]:null,f=u[0]!==void 0?null:(s=T==null?void 0:T[r])!=null?s:null;return{char:P,placeholderChar:f,isActive:c,hasFakeCaret:c&&P===null}}),isFocused:L,isHovering:!i.disabled&&lt}),[L,lt,t,A,H,T,i.disabled,u]),kt=o.useMemo(()=>b?b(et):o.createElement(Ht.Provider,{value:et},v),[v,et,b]);return o.createElement(o.Fragment,null,y!==null&&o.createElement("noscript",null,o.createElement("style",null,y)),o.createElement("div",{ref:J,"data-input-otp-container":!0,translate:"no",style:Wt,className:K},kt,o.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},At)))});Bt.displayName="Input";function V(e,n){try{e.insertRule(n)}catch(t){console.warn("input-otp could not insert CSS rule:",n)}}var Kt=`
8
+ [data-input-otp] {
9
+ --nojs-bg: white !important;
10
+ --nojs-fg: black !important;
11
+ diff --git a/dist/index.mjs b/dist/index.mjs
12
+ index d076c596e35078ee96997098de153d724bba3ae1..d50cb955f2e8843acb780c7e615a020df4f6347c 100644
13
+ --- a/dist/index.mjs
14
+ +++ b/dist/index.mjs
15
+ @@ -1,4 +1,4 @@
16
+ -var kt=Object.defineProperty,xt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var ht=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Et=(o,r,t)=>r in o?kt(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,bt=(o,r)=>{for(var t in r||(r={}))ht.call(r,t)&&Et(o,t,r[t]);if(U)for(var t of U(r))St.call(r,t)&&Et(o,t,r[t]);return o},Pt=(o,r)=>xt(o,Gt(r));var wt=(o,r)=>{var t={};for(var u in o)ht.call(o,u)&&r.indexOf(u)<0&&(t[u]=o[u]);if(o!=null&&U)for(var u of U(o))r.indexOf(u)<0&&St.call(o,u)&&(t[u]=o[u]);return t};import*as e from"react";function _t(o){let r=setTimeout(o,0),t=setTimeout(o,10),u=setTimeout(o,50);return[r,t,u]}import*as Z from"react";function Tt(o){let r=Z.useRef();return Z.useEffect(()=>{r.current=o}),r.current}import*as h from"react";var Ot=18,nt=40,Lt=`${nt}px`;function Ct(o){let r=o.getBoundingClientRect().right,t=o;for(;t;){if(getComputedStyle(t).overflowX!=="visible")return t.getBoundingClientRect().left+t.clientLeft+t.clientWidth-r;t=t.parentElement}return document.documentElement.clientWidth-r}var jt=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function Mt({containerRef:o,inputRef:r,pushPasswordManagerStrategy:t,isFocused:u}){let[w,T]=h.useState(!1),[x,M]=h.useState(!1),[V,I]=h.useState(!1),q=h.useMemo(()=>t==="none"?!1:(t==="increase-width"||t==="experimental-no-flickering")&&w&&x,[w,x,t]),y=h.useCallback(()=>{let m=o.current,S=r.current;if(!m||!S||V||t==="none")return;let R=m,i=R.getBoundingClientRect().left+R.offsetWidth,G=R.getBoundingClientRect().top+R.offsetHeight/2,ot=i-Ot,X=G;document.querySelectorAll(jt).length===0&&document.elementFromPoint(ot,X)===m||(M(Ct(m)>=nt),T(!0),I(!0))},[o,r,V,t]);return h.useEffect(()=>{let m=o.current;if(!m||t==="none")return;function S(){M(Ct(m)>=nt)}S();let R=setInterval(S,1e3);return()=>{clearInterval(R)}},[o,t]),h.useEffect(()=>{let m=u||document.activeElement===r.current;if(t==="none"||!m)return;let S=setTimeout(y,0),R=setTimeout(y,2e3),i=setTimeout(y,5e3),G=setTimeout(()=>{I(!0)},6e3);return()=>{clearTimeout(S),clearTimeout(R),clearTimeout(i),clearTimeout(G)}},[r,u,t,y]),{hasPWMBadge:w,willPushPWMBadge:q,PWM_BADGE_SPACE_WIDTH:Lt}}var Nt=e.createContext({}),$t=e.forwardRef((ot,G)=>{var X=ot,{value:o,onChange:r,maxLength:t,textAlign:u="left",pattern:w,placeholder:T,inputMode:x="numeric",onComplete:M,pushPasswordManagerStrategy:V="increase-width",pasteTransformer:I,containerClassName:q,noScriptCSSFallback:y=Ft,nonce:m,render:S,children:R}=X,i=wt(X,["value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","nonce","render","children"]);var z,ft,mt,pt,Rt;let[rt,at]=e.useState(typeof i.defaultValue=="string"?i.defaultValue:""),l=o!=null?o:rt,D=Tt(l),O=e.useCallback(a=>{r==null||r(a),at(a)},[r]),p=e.useMemo(()=>w?typeof w=="string"?new RegExp(w):w:null,[w]),d=e.useRef(null),K=e.useRef(null),J=e.useRef({value:l,onChange:O,isIOS:typeof window!="undefined"&&((ft=(z=window==null?void 0:window.CSS)==null?void 0:z.supports)==null?void 0:ft.call(z,"-webkit-touch-callout","none"))}),Y=e.useRef({prev:[(mt=d.current)==null?void 0:mt.selectionStart,(pt=d.current)==null?void 0:pt.selectionEnd,(Rt=d.current)==null?void 0:Rt.selectionDirection]});e.useImperativeHandle(G,()=>d.current,[]),e.useEffect(()=>{let a=d.current,n=K.current;if(!a||!n)return;J.current.value!==a.value&&J.current.onChange(a.value),Y.current.prev=[a.selectionStart,a.selectionEnd,a.selectionDirection];function c(){if(document.activeElement!==a){j(null),N(null);return}let s=a.selectionStart,P=a.selectionEnd,$=a.selectionDirection,v=a.maxLength,B=a.value,_=Y.current.prev,g=-1,E=-1,C;if(B.length!==0&&s!==null&&P!==null){let Bt=s===P,Wt=s===B.length&&B.length<v;if(Bt&&!Wt){let W=s;if(W===0)g=0,E=1,C="forward";else if(W===v)g=W-1,E=W,C="backward";else if(v>1&&B.length>1){let et=0;if(_[0]!==null&&_[1]!==null){C=W<_[1]?"backward":"forward";let At=_[0]===_[1]&&_[0]<v;C==="backward"&&!At&&(et=-1)}g=et+W,E=et+W+1}}g!==-1&&E!==-1&&g!==E&&a.setSelectionRange(g,E,C)}let vt=g!==-1?g:s,gt=E!==-1?E:P,Ht=C!=null?C:$;j(vt),N(gt),Y.current.prev=[vt,gt,Ht]}if(document.addEventListener("selectionchange",c,{capture:!0}),c(),document.activeElement===a&&Q(!0),!document.getElementById("input-otp-style")){let s=document.createElement("style");if(s.id="input-otp-style",m&&s.setAttribute("nonce",m),document.head.appendChild(s),s.sheet){let P="background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";F(s.sheet,"[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"),F(s.sheet,`[data-input-otp]:autofill { ${P} }`),F(s.sheet,`[data-input-otp]:-webkit-autofill { ${P} }`),F(s.sheet,"@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"),F(s.sheet,"[data-input-otp] + * { pointer-events: all !important; }")}}let b=()=>{n&&n.style.setProperty("--root-height",`${a.clientHeight}px`)};b();let f=typeof ResizeObserver=="undefined"?null:new ResizeObserver(b);return f==null||f.observe(a),()=>{document.removeEventListener("selectionchange",c,{capture:!0}),f==null||f.disconnect()}},[]);let[ct,it]=e.useState(!1),[L,Q]=e.useState(!1),[H,j]=e.useState(null),[A,N]=e.useState(null);e.useEffect(()=>{let a=_t(()=>{var f,s,P,$;(f=d.current)==null||f.dispatchEvent(new Event("input"));let n=(s=d.current)==null?void 0:s.selectionStart,c=(P=d.current)==null?void 0:P.selectionEnd,b=($=d.current)==null?void 0:$.selectionDirection;n!==null&&c!==null&&(j(n),N(c),Y.current.prev=[n,c,b])});return()=>{a.forEach(n=>clearTimeout(n))}},[l,L]),e.useEffect(()=>{D!==void 0&&l!==D&&D.length<t&&l.length===t&&(M==null||M(l))},[t,M,D,l]);let k=Mt({containerRef:K,inputRef:d,pushPasswordManagerStrategy:V,isFocused:L}),st=e.useCallback(a=>{let n=a.currentTarget.value.slice(0,t);if(n.length>0&&p&&!p.test(n)){a.preventDefault();return}typeof D=="string"&&n.length<D.length&&document.dispatchEvent(new Event("selectionchange")),O(n)},[t,O,D,p]),lt=e.useCallback(()=>{var a;if(d.current){let n=Math.min(d.current.value.length,t-1),c=d.current.value.length;(a=d.current)==null||a.setSelectionRange(n,c),j(n),N(c)}Q(!0)},[t]),ut=e.useCallback(a=>{var g,E;let n=d.current;if(!I&&(!J.current.isIOS||!a.clipboardData||!n))return;let c=a.clipboardData.getData("text/plain"),b=I?I(c):c;a.preventDefault();let f=(g=d.current)==null?void 0:g.selectionStart,s=(E=d.current)==null?void 0:E.selectionEnd,v=(f!==s?l.slice(0,f)+b+l.slice(s):l.slice(0,f)+b+l.slice(f)).slice(0,t);if(v.length>0&&p&&!p.test(v))return;n.value=v,O(v);let B=Math.min(v.length,t-1),_=v.length;n.setSelectionRange(B,_),j(B),N(_)},[t,O,I,p,l]),It=e.useMemo(()=>({position:"relative",cursor:i.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[i.disabled]),dt=e.useMemo(()=>({position:"absolute",inset:0,width:k.willPushPWMBadge?`calc(100% + ${k.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:k.willPushPWMBadge?`inset(0 ${k.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:u,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height, 16px)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[k.PWM_BADGE_SPACE_WIDTH,k.willPushPWMBadge,u]),yt=e.useMemo(()=>{var a;return e.createElement("input",Pt(bt({autoComplete:i.autoComplete||"one-time-code"},i),{"data-input-otp":!0,"data-input-otp-placeholder-shown":l.length===0||void 0,"data-input-otp-mss":H,"data-input-otp-mse":A,inputMode:x,pattern:p==null?void 0:p.source,"aria-placeholder":T,style:dt,maxLength:t,value:l,ref:d,spellCheck:(a=i.spellCheck)!=null?a:!1,onPaste:n=>{var c;ut(n),(c=i.onPaste)==null||c.call(i,n)},onChange:st,onMouseOver:n=>{var c;it(!0),(c=i.onMouseOver)==null||c.call(i,n)},onMouseLeave:n=>{var c;it(!1),(c=i.onMouseLeave)==null||c.call(i,n)},onFocus:n=>{var c;lt(),(c=i.onFocus)==null||c.call(i,n)},onBlur:n=>{var c;Q(!1),(c=i.onBlur)==null||c.call(i,n)}}))},[st,lt,ut,x,dt,t,A,H,T,i,p==null?void 0:p.source,l]),tt=e.useMemo(()=>({slots:Array.from({length:t}).map((a,n)=>{var s;let c=L&&H!==null&&A!==null&&(H===A&&n===H||n>=H&&n<A),b=l[n]!==void 0?l[n]:null,f=l[0]!==void 0?null:(s=T==null?void 0:T[n])!=null?s:null;return{char:b,placeholderChar:f,isActive:c,hasFakeCaret:c&&b===null}}),isFocused:L,isHovering:!i.disabled&&ct}),[L,ct,t,A,H,T,i.disabled,l]),Dt=e.useMemo(()=>S?S(tt):e.createElement(Nt.Provider,{value:tt},R),[R,tt,S]);return e.createElement(e.Fragment,null,y!==null&&e.createElement("noscript",null,e.createElement("style",null,y)),e.createElement("div",{ref:K,"data-input-otp-container":!0,translate:"no",style:It,className:q},Dt,e.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},yt)))});$t.displayName="Input";function F(o,r){try{o.insertRule(r)}catch(t){console.warn("input-otp could not insert CSS rule:",r)}}var Ft=`
17
+ +var kt=Object.defineProperty,xt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var ht=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var Et=(o,r,t)=>r in o?kt(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,bt=(o,r)=>{for(var t in r||(r={}))ht.call(r,t)&&Et(o,t,r[t]);if(U)for(var t of U(r))St.call(r,t)&&Et(o,t,r[t]);return o},Pt=(o,r)=>xt(o,Gt(r));var wt=(o,r)=>{var t={};for(var u in o)ht.call(o,u)&&r.indexOf(u)<0&&(t[u]=o[u]);if(o!=null&&U)for(var u of U(o))r.indexOf(u)<0&&St.call(o,u)&&(t[u]=o[u]);return t};import*as e from"react";function _t(o){let r=setTimeout(o,0),t=setTimeout(o,10),u=setTimeout(o,50);return[r,t,u]}import*as Z from"react";function Tt(o){let r=Z.useRef();return Z.useEffect(()=>{r.current=o}),r.current}import*as h from"react";var Ot=18,nt=40,Lt=`${nt}px`;function Ct(o){let r=o.getBoundingClientRect().right,t=o;for(;t;){if(getComputedStyle(t).overflowX!=="visible")return t.getBoundingClientRect().left+t.clientLeft+t.clientWidth-r;t=t.parentElement}return document.documentElement.clientWidth-r}var jt=["[data-lastpass-icon-root]","com-1password-button","[data-dashlanecreated]",'[style$="2147483647 !important;"]'].join(",");function Mt({containerRef:o,inputRef:r,pushPasswordManagerStrategy:t,isFocused:u}){let[w,T]=h.useState(!1),[x,M]=h.useState(!1),[V,I]=h.useState(!1),q=h.useMemo(()=>t==="none"?!1:(t==="increase-width"||t==="experimental-no-flickering")&&w&&x,[w,x,t]),y=h.useCallback(()=>{let m=o.current,S=r.current;if(!m||!S||V||t==="none")return;let R=m,i=R.getBoundingClientRect().left+R.offsetWidth,G=R.getBoundingClientRect().top+R.offsetHeight/2,ot=i-Ot,X=G;document.querySelectorAll(jt).length===0&&document.elementFromPoint(ot,X)===m||(M(Ct(m)>=nt),T(!0),I(!0))},[o,r,V,t]);return h.useEffect(()=>{let m=o.current;if(!m||t==="none")return;function S(){M(Ct(m)>=nt)}S();let R=setInterval(S,1e3);return()=>{clearInterval(R)}},[o,t]),h.useEffect(()=>{let m=u||document.activeElement===r.current;if(t==="none"||!m)return;let S=setTimeout(y,0),R=setTimeout(y,2e3),i=setTimeout(y,5e3),G=setTimeout(()=>{I(!0)},6e3);return()=>{clearTimeout(S),clearTimeout(R),clearTimeout(i),clearTimeout(G)}},[r,u,t,y]),{hasPWMBadge:w,willPushPWMBadge:q,PWM_BADGE_SPACE_WIDTH:Lt}}var Nt=e.createContext({}),$t=e.forwardRef((ot,G)=>{var X=ot,{defaultValue:initialDefaultValue,value:o,onChange:r,maxLength:t,textAlign:u="left",pattern:w,placeholder:T,inputMode:x="numeric",onComplete:M,pushPasswordManagerStrategy:V="increase-width",pasteTransformer:I,containerClassName:q,noScriptCSSFallback:y=Ft,nonce:m,render:S,children:R}=X,i=wt(X,["defaultValue","value","onChange","maxLength","textAlign","pattern","placeholder","inputMode","onComplete","pushPasswordManagerStrategy","pasteTransformer","containerClassName","noScriptCSSFallback","nonce","render","children"]);var z,ft,mt,pt,Rt;let[rt,at]=e.useState(typeof initialDefaultValue=="string"?initialDefaultValue:""),l=o!=null?o:rt,D=Tt(l),O=e.useCallback(a=>{r==null||r(a),at(a)},[r]),p=e.useMemo(()=>w?typeof w=="string"?new RegExp(w):w:null,[w]),d=e.useRef(null),K=e.useRef(null),J=e.useRef({value:l,onChange:O,isIOS:typeof window!="undefined"&&((ft=(z=window==null?void 0:window.CSS)==null?void 0:z.supports)==null?void 0:ft.call(z,"-webkit-touch-callout","none"))}),Y=e.useRef({prev:[(mt=d.current)==null?void 0:mt.selectionStart,(pt=d.current)==null?void 0:pt.selectionEnd,(Rt=d.current)==null?void 0:Rt.selectionDirection]});e.useImperativeHandle(G,()=>d.current,[]),e.useEffect(()=>{let a=d.current,n=K.current;if(!a||!n)return;J.current.value!==a.value&&J.current.onChange(a.value),Y.current.prev=[a.selectionStart,a.selectionEnd,a.selectionDirection];function c(){if(document.activeElement!==a){j(null),N(null);return}let s=a.selectionStart,P=a.selectionEnd,$=a.selectionDirection,v=a.maxLength,B=a.value,_=Y.current.prev,g=-1,E=-1,C;if(B.length!==0&&s!==null&&P!==null){let Bt=s===P,Wt=s===B.length&&B.length<v;if(Bt&&!Wt){let W=s;if(W===0)g=0,E=1,C="forward";else if(W===v)g=W-1,E=W,C="backward";else if(v>1&&B.length>1){let et=0;if(_[0]!==null&&_[1]!==null){C=W<_[1]?"backward":"forward";let At=_[0]===_[1]&&_[0]<v;C==="backward"&&!At&&(et=-1)}g=et+W,E=et+W+1}}g!==-1&&E!==-1&&g!==E&&a.setSelectionRange(g,E,C)}let vt=g!==-1?g:s,gt=E!==-1?E:P,Ht=C!=null?C:$;j(vt),N(gt),Y.current.prev=[vt,gt,Ht]}if(document.addEventListener("selectionchange",c,{capture:!0}),c(),document.activeElement===a&&Q(!0),!document.getElementById("input-otp-style")){let s=document.createElement("style");if(s.id="input-otp-style",m&&s.setAttribute("nonce",m),document.head.appendChild(s),s.sheet){let P="background: transparent !important; color: transparent !important; border-color: transparent !important; opacity: 0 !important; box-shadow: none !important; -webkit-box-shadow: none !important; -webkit-text-fill-color: transparent !important;";F(s.sheet,"[data-input-otp]::selection { background: transparent !important; color: transparent !important; }"),F(s.sheet,`[data-input-otp]:autofill { ${P} }`),F(s.sheet,`[data-input-otp]:-webkit-autofill { ${P} }`),F(s.sheet,"@supports (-webkit-touch-callout: none) { [data-input-otp] { letter-spacing: -.6em !important; font-weight: 100 !important; font-stretch: ultra-condensed; font-optical-sizing: none !important; left: -1px !important; right: 1px !important; } }"),F(s.sheet,"[data-input-otp] + * { pointer-events: all !important; }")}}let b=()=>{n&&n.style.setProperty("--root-height",`${a.clientHeight}px`)};b();let f=typeof ResizeObserver=="undefined"?null:new ResizeObserver(b);return f==null||f.observe(a),()=>{document.removeEventListener("selectionchange",c,{capture:!0}),f==null||f.disconnect()}},[]);let[ct,it]=e.useState(!1),[L,Q]=e.useState(!1),[H,j]=e.useState(null),[A,N]=e.useState(null);e.useEffect(()=>{let a=_t(()=>{var f,s,P,$;(f=d.current)==null||f.dispatchEvent(new Event("input"));let n=(s=d.current)==null?void 0:s.selectionStart,c=(P=d.current)==null?void 0:P.selectionEnd,b=($=d.current)==null?void 0:$.selectionDirection;n!==null&&c!==null&&(j(n),N(c),Y.current.prev=[n,c,b])});return()=>{a.forEach(n=>clearTimeout(n))}},[l,L]),e.useEffect(()=>{D!==void 0&&l!==D&&D.length<t&&l.length===t&&(M==null||M(l))},[t,M,D,l]);let k=Mt({containerRef:K,inputRef:d,pushPasswordManagerStrategy:V,isFocused:L}),st=e.useCallback(a=>{let n=a.currentTarget.value.slice(0,t);if(n.length>0&&p&&!p.test(n)){a.preventDefault();return}typeof D=="string"&&n.length<D.length&&document.dispatchEvent(new Event("selectionchange")),O(n)},[t,O,D,p]),lt=e.useCallback(()=>{var a;if(d.current){let n=Math.min(d.current.value.length,t-1),c=d.current.value.length;(a=d.current)==null||a.setSelectionRange(n,c),j(n),N(c)}Q(!0)},[t]),ut=e.useCallback(a=>{var g,E;let n=d.current;if(!I&&(!J.current.isIOS||!a.clipboardData||!n))return;let c=a.clipboardData.getData("text/plain"),b=I?I(c):c;a.preventDefault();let f=(g=d.current)==null?void 0:g.selectionStart,s=(E=d.current)==null?void 0:E.selectionEnd,v=(f!==s?l.slice(0,f)+b+l.slice(s):l.slice(0,f)+b+l.slice(f)).slice(0,t);if(v.length>0&&p&&!p.test(v))return;n.value=v,O(v);let B=Math.min(v.length,t-1),_=v.length;n.setSelectionRange(B,_),j(B),N(_)},[t,O,I,p,l]),It=e.useMemo(()=>({position:"relative",cursor:i.disabled?"default":"text",userSelect:"none",WebkitUserSelect:"none",pointerEvents:"none"}),[i.disabled]),dt=e.useMemo(()=>({position:"absolute",inset:0,width:k.willPushPWMBadge?`calc(100% + ${k.PWM_BADGE_SPACE_WIDTH})`:"100%",clipPath:k.willPushPWMBadge?`inset(0 ${k.PWM_BADGE_SPACE_WIDTH} 0 0)`:void 0,height:"100%",display:"flex",textAlign:u,opacity:"1",color:"transparent",pointerEvents:"all",background:"transparent",caretColor:"transparent",border:"0 solid transparent",outline:"0 solid transparent",boxShadow:"none",lineHeight:"1",letterSpacing:"-.5em",fontSize:"var(--root-height, 16px)",fontFamily:"monospace",fontVariantNumeric:"tabular-nums"}),[k.PWM_BADGE_SPACE_WIDTH,k.willPushPWMBadge,u]),yt=e.useMemo(()=>{var a;return e.createElement("input",Pt(bt({autoComplete:i.autoComplete||"one-time-code"},i),{"data-input-otp":!0,"data-input-otp-placeholder-shown":l.length===0||void 0,"data-input-otp-mss":H,"data-input-otp-mse":A,inputMode:x,pattern:p==null?void 0:p.source,"aria-placeholder":T,style:dt,maxLength:t,value:l,ref:d,spellCheck:(a=i.spellCheck)!=null?a:!1,onPaste:n=>{var c;ut(n),(c=i.onPaste)==null||c.call(i,n)},onChange:st,onMouseOver:n=>{var c;it(!0),(c=i.onMouseOver)==null||c.call(i,n)},onMouseLeave:n=>{var c;it(!1),(c=i.onMouseLeave)==null||c.call(i,n)},onFocus:n=>{var c;lt(),(c=i.onFocus)==null||c.call(i,n)},onBlur:n=>{var c;Q(!1),(c=i.onBlur)==null||c.call(i,n)}}))},[st,lt,ut,x,dt,t,A,H,T,i,p==null?void 0:p.source,l]),tt=e.useMemo(()=>({slots:Array.from({length:t}).map((a,n)=>{var s;let c=L&&H!==null&&A!==null&&(H===A&&n===H||n>=H&&n<A),b=l[n]!==void 0?l[n]:null,f=l[0]!==void 0?null:(s=T==null?void 0:T[n])!=null?s:null;return{char:b,placeholderChar:f,isActive:c,hasFakeCaret:c&&b===null}}),isFocused:L,isHovering:!i.disabled&&ct}),[L,ct,t,A,H,T,i.disabled,l]),Dt=e.useMemo(()=>S?S(tt):e.createElement(Nt.Provider,{value:tt},R),[R,tt,S]);return e.createElement(e.Fragment,null,y!==null&&e.createElement("noscript",null,e.createElement("style",null,y)),e.createElement("div",{ref:K,"data-input-otp-container":!0,translate:"no",style:It,className:q},Dt,e.createElement("div",{style:{position:"absolute",inset:0,pointerEvents:"none"}},yt)))});$t.displayName="Input";function F(o,r){try{o.insertRule(r)}catch(t){console.warn("input-otp could not insert CSS rule:",r)}}var Ft=`
18
+ [data-input-otp] {
19
+ --nojs-bg: white !important;
20
+ --nojs-fg: black !important;
@@ -0,0 +1,87 @@
1
+ diff --git a/node_modules/sonner/.bun-tag-eec9caba2bab3780 b/.bun-tag-eec9caba2bab3780
2
+ new file mode 100644
3
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
4
+ diff --git a/dist/index.js b/dist/index.js
5
+ index 394dbc2272f43b84642b0f9d5cc7eb1eacb0ffb3..6d141781a4faa9cc312f8c421c67dfe3717111f4 100644
6
+ --- a/dist/index.js
7
+ +++ b/dist/index.js
8
+ @@ -597,8 +597,8 @@ const Toast = (props)=>{
9
+ toast.id
10
+ ]);
11
+ React__default.default.useLayoutEffect(()=>{
12
+ - // Keep height up to date with the content in case it updates
13
+ - if (!mounted) return;
14
+ + // Measure after every render, including host density and presentation changes.
15
+ + if (!mounted || removed) return;
16
+ const toastNode = toastRef.current;
17
+ const originalHeight = toastNode.style.height;
18
+ toastNode.style.height = 'auto';
19
+ @@ -616,23 +616,15 @@ const Toast = (props)=>{
20
+ },
21
+ ...heights
22
+ ];
23
+ - } else {
24
+ + } else if (alreadyExists.height !== newHeight) {
25
+ return heights.map((height)=>height.toastId === toast.id ? {
26
+ ...height,
27
+ height: newHeight
28
+ } : height);
29
+ }
30
+ + return heights;
31
+ });
32
+ - }, [
33
+ - mounted,
34
+ - toast.title,
35
+ - toast.description,
36
+ - setHeights,
37
+ - toast.id,
38
+ - toast.jsx,
39
+ - toast.action,
40
+ - toast.cancel
41
+ - ]);
42
+ + });
43
+ const deleteToast = React__default.default.useCallback(()=>{
44
+ // Save the offset for the exit swipe animation
45
+ setRemoved(true);
46
+ diff --git a/dist/index.mjs b/dist/index.mjs
47
+ index c124f821a68f7070647a5a04441d0caa53689662..de84213523dc4ca54593cecacc40ab2d883a4f11 100644
48
+ --- a/dist/index.mjs
49
+ +++ b/dist/index.mjs
50
+ @@ -590,8 +590,8 @@ const Toast = (props)=>{
51
+ toast.id
52
+ ]);
53
+ React.useLayoutEffect(()=>{
54
+ - // Keep height up to date with the content in case it updates
55
+ - if (!mounted) return;
56
+ + // Measure after every render, including host density and presentation changes.
57
+ + if (!mounted || removed) return;
58
+ const toastNode = toastRef.current;
59
+ const originalHeight = toastNode.style.height;
60
+ toastNode.style.height = 'auto';
61
+ @@ -609,23 +609,15 @@ const Toast = (props)=>{
62
+ },
63
+ ...heights
64
+ ];
65
+ - } else {
66
+ + } else if (alreadyExists.height !== newHeight) {
67
+ return heights.map((height)=>height.toastId === toast.id ? {
68
+ ...height,
69
+ height: newHeight
70
+ } : height);
71
+ }
72
+ + return heights;
73
+ });
74
+ - }, [
75
+ - mounted,
76
+ - toast.title,
77
+ - toast.description,
78
+ - setHeights,
79
+ - toast.id,
80
+ - toast.jsx,
81
+ - toast.action,
82
+ - toast.cancel
83
+ - ]);
84
+ + });
85
+ const deleteToast = React.useCallback(()=>{
86
+ // Save the offset for the exit swipe animation
87
+ setRemoved(true);