"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),J=require("../index-DnaHaH_0.js"),Q=require("../Slot-ghrohQLA.js"),X=require("react"),s=require("../useOpenChangeComplete-Dk-u_f2y.js"),p=require("../useCollapsiblePanel-D1dCo0lf.js");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const b=Y(X),I={...p.collapsibleOpenStateMapping,...s.transitionStatusMapping},_=b.forwardRef(function(t,n){const{render:o,className:a,defaultOpen:i=!1,disabled:R=!1,onOpenChange:d,open:y,...u}=t,f=s.useStableCallback(d),l=p.useCollapsibleRoot({open:y,defaultOpen:i,onOpenChange:f,disabled:R}),r=b.useMemo(()=>({open:l.open,disabled:l.disabled,transitionStatus:l.transitionStatus}),[l.open,l.disabled,l.transitionStatus]),g=b.useMemo(()=>({...l,onOpenChange:f,state:r}),[l,f,r]),c=s.useRenderElement("div",t,{state:r,ref:n,props:u,stateAttributesMapping:I});return h.jsx(p.CollapsibleRootContext.Provider,{value:g,children:c})});process.env.NODE_ENV!=="production"&&(_.displayName="CollapsibleRoot");const Z={...p.triggerOpenStateMapping,...s.transitionStatusMapping},F=b.forwardRef(function(t,n){const{panelId:o,open:a,handleTrigger:i,state:R,disabled:d}=p.useCollapsibleRootContext(),{className:y,disabled:u=d,id:f,render:l,nativeButton:r=!0,...g}=t,{getButtonProps:c,buttonRef:O}=s.useButton({disabled:u,focusableWhenDisabled:!0,native:r}),m=b.useMemo(()=>({"aria-controls":a?o:void 0,"aria-expanded":a,disabled:u,onClick:i}),[o,u,a,i]);return s.useRenderElement("button",t,{state:R,ref:[n,O],props:[m,g,c],stateAttributesMapping:Z})});process.env.NODE_ENV!=="production"&&(F.displayName="CollapsibleTrigger");let q=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const A=b.forwardRef(function(t,n){const{className:o,hiddenUntilFound:a,keepMounted:i,render:R,id:d,...y}=t;process.env.NODE_ENV!=="production"&&s.useIsoLayoutEffect(()=>{a&&i===!1&&p.warn("The `keepMounted={false}` prop on a Collapsible will be ignored when using `hiddenUntilFound` since it requires the Panel to remain mounted even when closed.")},[a,i]);const{abortControllerRef:u,animationTypeRef:f,height:l,mounted:r,onOpenChange:g,open:c,panelId:O,panelRef:m,runOnceAnimationsFinish:j,setDimensions:w,setHiddenUntilFound:T,setKeepMounted:k,setMounted:L,setPanelIdState:S,setOpen:B,setVisible:H,state:D,transitionDimensionRef:W,visible:$,width:M,transitionStatus:v}=p.useCollapsibleRootContext(),N=a??!1,C=i??!1;s.useIsoLayoutEffect(()=>{if(d)return S(d),()=>{S(void 0)}},[d,S]),s.useIsoLayoutEffect(()=>{T(N)},[T,N]),s.useIsoLayoutEffect(()=>{k(C)},[k,C]);const{props:z}=p.useCollapsiblePanel({abortControllerRef:u,animationTypeRef:f,externalRef:n,height:l,hiddenUntilFound:N,id:O,keepMounted:C,mounted:r,onOpenChange:g,open:c,panelRef:m,runOnceAnimationsFinish:j,setDimensions:w,setMounted:L,setOpen:B,setVisible:H,transitionDimensionRef:W,visible:$,width:M});s.useOpenChangeComplete({open:c&&v==="idle",ref:m,onComplete(){c&&w({height:void 0,width:void 0})}});const K=b.useMemo(()=>({...D,transitionStatus:v}),[D,v]),G=s.useRenderElement("div",t,{state:K,ref:[n,m],props:[z,{style:{[q.collapsiblePanelHeight]:l===void 0?"auto":`${l}px`,[q.collapsiblePanelWidth]:M===void 0?"auto":`${M}px`}},y],stateAttributesMapping:I});return C||N||!C&&r?G:null});process.env.NODE_ENV!=="production"&&(A.displayName="CollapsiblePanel");function P(e,t){const n=e?Q.Slot:t;return e?({...o})=>h.jsx(n,{...o}):void 0}const x=({asChild:e=!1,className:t,children:n,hiddenUntilFound:o=!0,...a})=>{const i=P(e,"div");return h.jsx(A,{"data-spark-component":"collapsible-content",className:J.cx("overflow-hidden","h-[var(--collapsible-panel-height)]","transition-all duration-200","motion-reduce:transition-none","data-[starting-style]:h-0","data-[ending-style]:h-0",t),render:i,hiddenUntilFound:o,...a,children:n})};x.displayName="Collapsible.Content";const U=({asChild:e=!1,children:t,...n})=>{const o=P(e,"div");return h.jsx(_,{"data-spark-component":"collapsible",render:o,...n,children:t})};U.displayName="Collapsible";const E=({asChild:e=!1,children:t,...n})=>{const o=P(e,"button");return h.jsx(F,{"data-spark-component":"collapsible-trigger",render:o,...n,children:t})};E.displayName="Collapsible.Trigger";const V=Object.assign(U,{Trigger:E,Content:x});V.displayName="Collapsible";E.displayName="Collapsible.Trigger";x.displayName="Collapsible.Content";exports.Collapsible=V;
//# sourceMappingURL=index.js.map
