1import{B as P}from"./chunk-DcxUmD-z.js";import{by as x,aL as i}from"./index-5yA9CUzc.js";import"./chunk-Cl_8PWDN.js";import"./chunk-Bzo9Tunx.js";import"./chunk-BeHpvERE.js";import"./chunk-DaCLkmJg.js";import"./chunk-BNWfZVZZ.js";import"./chunk-mAyixyGg.js";import"./chunk-PeZDclay.js";const D=10999,C=96,A=220,q=.32,F=.48,H=1.1,R=8,V=80;class k extends HTMLElement{#e=null;#t=null;#s=null;constructor(){super();let t=(HTMLElement.prototype.hasOwnProperty("attachInternals")?this.attachInternals():void 0)?.shadowRoot;t||(t=this.attachShadow({mode:"open"}),t.innerHTML=x),this.addEventListener("click",e=>{e.target instanceof HTMLDialogElement&&e.target.matches(":modal")&&e.target.close()}),this.addEventListener("click",e=>{if(e.target instanceof HTMLElement&&e.target.classList.contains("scroll-sheet-overlay")){const a=this.querySelector("dialog");a?.open&&a.close()}}),this.addEventListener("snap-position-change",e=>{const a=this.querySelector(":scope > dialog > bottom-sheet");if(e.target===a&&(e.detail&&(this.dataset.sheetState=e.detail.sheetState,i("sheet-snap-position-change",{source:"manager-root-listener",sheetState:e.detail.sheetState,snapIndex:e.detail.snapIndex,scrollTop:e.target instanceof HTMLElement?Math.round(e.target.scrollTop):null})),e.detail?.sheetState==="collapsed"&&e.target instanceof HTMLElement&&e.target.hasAttribute("swipe-to-dismiss")&&e.target.checkVisibility())){const l=e.target.parentElement;l instanceof HTMLDialogElement&&getComputedStyle(l).getPropertyValue("translate")==="0px"&&(i("sheet-close-trigger",{source:"manager-collapsed-listener",reason:"collapsed-sentinel",scrollTop:Math.round(e.target.scrollTop)}),l.close())}}),this.#o()}#o(){const c=new MutationObserver(()=>{const r=this.querySelector("dialog"),t=this.querySelector("bottom-sheet");if(!r||!t)return;if(c.disconnect(),!this.querySelector(".scroll-sheet-overlay")){const s=document.createElement("div");s.className="scroll-sheet-overlay",s.style.position="fixed",s.style.inset="0",s.style.background="rgba(0,0,0,0.4)",s.style.pointerEvents="none",s.style.zIndex=String(D),s.style.opacity="0",s.style.transition="opacity 0.12s ease-in",s.addEventListener("wheel",o=>{s.dataset.blockScroll==="true"&&o.preventDefault()},{passive:!1}),s.addEventListener("touchmove",o=>{s.dataset.blockScroll==="true"&&o.preventDefault()},{passive:!1}),this.insertBefore(s,this.firstChild)}const e=this.querySelector(".scroll-sheet-overlay");let a=!1,l=!1,n=t.scrollTop,h=0,d=0;const p=()=>{a=!1,l=!1,n=t.scrollTop,h=0,d=0},b=()=>{n=t.scrollTop,h=performance.now(),t.dataset.sheetState&&t.dataset.sheetState!=="collapsed"&&(a=!0)},L=()=>
1{if(!r.open||l||!t.hasAttribute("swipe-to-dismiss")||!a)return;const s=t.scrollHeight-t.clientHeight;if(s<=0)return;const o=t.scrollTop,M=performance.now(),S=h>0?M-h:0,O=o<n,T=n-o,m=S>=R&&S<=V?T/S:0;if(o<n){const _=performance.now();_-d>=120&&(d=_,i("sheet-drag-progress",{scrollTop:Math.round(o),maxScroll:Math.round(s),downwardDeltaPx:Math.round(T),downwardVelocityPxPerMs:Number(m.toFixed(3)),sheetState:t.dataset.sheetState??null}))}if(n=o,h=M,!O)return;const y=Math.min(A,Math.max(C,s*q)),v=Math.max(y,s*F),I=m>=H&&o<=v;o>y&&!I||(l=!0,i("sheet-close-trigger",{source:"manager-early-close",reason:I?"velocity-threshold":"distance-threshold",scrollTop:Math.round(o),thresholdPx:Math.round(y),velocityThresholdPx:Math.round(v),downwardVelocityPxPerMs:Number(m.toFixed(3))}),r.close())},w=s=>{const o=s.detail;o&&(n=t.scrollTop,h=performance.now(),o.sheetState!=="collapsed"&&(a=!0),i("sheet-snap-position-change",{source:"manager-sheet-listener",sheetState:o.sheetState,snapIndex:o.snapIndex,scrollTop:Math.round(t.scrollTop)}))},u=()=>this.dataset.overlayMode!=="scroll"?(e.style.opacity="0",e.style.pointerEvents="none",!0):!1,g=()=>{e.style.pointerEvents="auto",u()||(e.style.opacity="var(--scroll-sheet-overlay-opacity, 0)")},f=new MutationObserver(()=>{if(r.open){if(p(),i("sheet-dialog-open",{scrollTop:Math.round(t.scrollTop)}),requestAnimationFrame(b),u())return;g(),r.addEventListener("close",()=>{i("sheet-dialog-close",{scrollTop:Math.round(t.scrollTop),sheetState:t.dataset.sheetState??null}),p(),e.style.opacity="0",e.style.pointerEvents="none"},{once:!0})}else p(),e.style.opacity="0",e.style.pointerEvents="none"});f.observe(r,{attributes:!0,attributeFilter:["open"]}),this.#t=f;const E=new MutationObserver(()=>{u()||r.open&&g()});E.observe(this,{attributes:!0,attributeFilter:["data-overlay-mode"]}),this.#s=E,t.addEventListener("snap-position-change",w),t.addEventListener("scroll",L,{passive:!0})});c.observe(this,{childList:!0,subtree:!0}),this.#e=c,requestAnimationFrame(()=>{if(this.querySelector("dialog")&&(c.disconnect(),this.querySelector("dialog"),this.querySelector("bottom-sheet"))){c.takeRecords();const t=document.createComment("");this.appendChild(t),t.remove()}})}disconnectedCallback(){this.#e?.disconnect(),this.#e=null,this.#t?.disconnect(),this.#t=null,this.#s?.disconnect(),this.#s=null}}function K(){customElements.get("bottom-sheet")||customElements.define("bottom-sheet",P),customElements.get("bottom-sheet-dialog-manager")||customElements.define("bottom-sheet-dialog-manager",k)}export{P as BottomSheet,k as BottomSheetDialogManager,K as registerSheetElements};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.