diff --git a/files/views/pages.py b/files/views/pages.py index 39d17fb5..ff6c7395 100644 --- a/files/views/pages.py +++ b/files/views/pages.py @@ -256,7 +256,7 @@ def video_chapters(request, friendly_token): return HttpResponseRedirect("/") try: - data = json.loads(request.body)["chapters"] + data = json.loads(request.body)["segments"] chapters = [] for _, chapter_data in enumerate(data): start_time = chapter_data.get('startTime') diff --git a/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx b/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx index 70c7a1b1..67164b3d 100644 --- a/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx +++ b/frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx @@ -968,7 +968,7 @@ const TimelineControls = ({ useEffect(() => { const loadSavedSegments = () => { // Get savedSegments directly from window.MEDIA_DATA - let savedData = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.savedSegments) || null; + let savedData = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.chapters) || null; // If no saved segments, use default segments if (!savedData) { diff --git a/frontend-tools/chapters-editor/client/src/hooks/useVideoChapters.tsx b/frontend-tools/chapters-editor/client/src/hooks/useVideoChapters.tsx index 6996d096..0bc4feab 100644 --- a/frontend-tools/chapters-editor/client/src/hooks/useVideoChapters.tsx +++ b/frontend-tools/chapters-editor/client/src/hooks/useVideoChapters.tsx @@ -94,33 +94,7 @@ const useVideoChapters = () => { // Check if we have existing chapters from the backend const existingChapters = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.chapters) || - [ - /* { - name: 'Chapter 1', - from: '00:00:00', - to: '00:00:03', - }, - { - name: 'Chapter 2', - from: '00:00:03', - to: '00:00:06', - }, - { - name: 'Chapter 3', - from: '00:00:09', - to: '00:00:12', - }, - { - name: 'Chapter 4', - from: '00:00:15', - to: '00:00:18', - }, - { - name: 'Chapter 5', - from: '00:00:21', - to: '00:00:24', - }, */ - ]; + []; if (existingChapters.length > 0) { // Create segments from existing chapters @@ -128,8 +102,8 @@ const useVideoChapters = () => { const chapter = existingChapters[i]; // Parse time strings to seconds - const startTime = parseTimeToSeconds(chapter.from); - const endTime = parseTimeToSeconds(chapter.to); + const startTime = parseTimeToSeconds(chapter.startTime); + const endTime = parseTimeToSeconds(chapter.endTime); // Generate thumbnail for this segment const segmentThumbnail = await generateThumbnail(video, (startTime + endTime) / 2); @@ -140,7 +114,7 @@ const useVideoChapters = () => { startTime: startTime, endTime: endTime, thumbnail: segmentThumbnail, - chapterTitle: chapter.name, // Set the chapter title from backend data + chapterTitle: chapter.text, }; initialSegments.push(segment); @@ -768,7 +742,7 @@ const useVideoChapters = () => { // Convert chapters to backend expected format const backendChapters = chapters.map((chapter) => ({ - startTime: chapter.from, + startTime: chapter.from, endTime: chapter.to, text: chapter.name, })); diff --git a/static/chapters_editor/chapters-editor.js b/static/chapters_editor/chapters-editor.js index 97f5ac38..228bfe45 100644 --- a/static/chapters_editor/chapters-editor.js +++ b/static/chapters_editor/chapters-editor.js @@ -199,5 +199,5 @@ Check the render method of %s.`,Ke(ia)||"Unknown"));var u=Ir(i,o);u.payload={ele let root = createRoot(domContainer); root.render();`),t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError),t.transitionCallbacks!==void 0&&t.transitionCallbacks);var o=u0(e,Ys,null,n,a,r,i);Hs(o.current,e);var l=e.nodeType===bn?e.parentNode:e;return Ql(l),new sm(o)}function Xc(e){this._internalRoot=e}function KD(e){e&&dE(e)}Xc.prototype.unstable_scheduleHydration=KD;function JD(e,t,n){if(!Qc(e))throw new Error("hydrateRoot(...): Target container is not a DOM element.");M0(e),t===void 0&&f("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, )");var a=n??null,r=n!=null&&n.hydratedSources||null,i=!1,o=!1,l="",u=k0;n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(l=n.identifierPrefix),n.onRecoverableError!==void 0&&(u=n.onRecoverableError));var c=s0(t,null,e,Ys,a,i,o,l,u);if(Hs(c.current,e),Ql(e),r)for(var d=0;d2&&arguments[2]!==void 0?arguments[2]:null;if(!Qc(t))throw new Error("Target container is not a DOM element.");return FD(e,t,null,n)}function u_(e,t,n,a){return i_(e,t,n,a)}var fm={usingClientEntryPoint:!1,Events:[vi,Ho,zs,Im,Wm,Bp]};function s_(e,t){return fm.usingClientEntryPoint||f('You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".'),QD(e,t)}function c_(e,t,n){return fm.usingClientEntryPoint||f('You are importing hydrateRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".'),JD(e,t,n)}function f_(e){return Bb()&&f("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task."),Xr(e)}var d_=XD({findFiberByHostInstance:qi,bundleType:1,version:rm,rendererPackageName:"react-dom"});if(!d_&&St&&window.top===window.self&&(navigator.userAgent.indexOf("Chrome")>-1&&navigator.userAgent.indexOf("Edge")===-1||navigator.userAgent.indexOf("Firefox")>-1)){var j0=window.location.protocol;/^(https?|file):$/.test(j0)&&console.info("%cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools"+(j0==="file:"?` -You might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq`:""),"font-weight:bold")}pa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fm,pa.createPortal=l_,pa.createRoot=s_,pa.findDOMNode=n_,pa.flushSync=f_,pa.hydrate=a_,pa.hydrateRoot=c_,pa.render=r_,pa.unmountComponentAtNode=o_,pa.unstable_batchedUpdates=Bp,pa.unstable_renderSubtreeIntoContainer=u_,pa.version=rm,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}(),pa}hm.exports=V0();var B0=hm.exports,Sm,Tm=B0;{var Em=Tm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Sm=function(M,R){Em.usingClientEntryPoint=!0;try{return Tm.createRoot(M,R)}finally{Em.usingClientEntryPoint=!1}}}const P=M=>{if(isNaN(M))return"00:00:00.000";const R=Math.floor(M/3600),be=Math.floor(M%3600/60),Re=Math.floor(M%60),we=Math.round(M%1*1e3),ve=String(R).padStart(2,"0"),f=String(be).padStart(2,"0"),W=String(Re).padStart(2,"0"),ge=String(we).padStart(3,"0");return`${ve}:${f}:${W}.${ge}`},ki=M=>P(M),$0=M=>P(M),me={debug:(...M)=>{},error:(...M)=>console.error(...M),warn:(...M)=>console.warn(...M),info:(...M)=>console.info(...M)};var Q=Zc();const P0=({videoRef:M,currentTime:R,duration:be,isPlaying:Re,isMuted:we=!1,onPlayPause:ve,onSeek:f,onToggleMute:W})=>{var oe;const ge=Q.useRef(null),[re,Tt]=Q.useState(!1),[ce,je]=Q.useState(!1),[te,Be]=Q.useState(null),[Qe,I]=Q.useState(!1),xt=Q.useRef(!1),[ot,Le]=Q.useState({x:0}),[rt,Ce]=Q.useState(0),U=typeof window<"u"&&((oe=window.MEDIA_DATA)==null?void 0:oe.videoUrl)||"/videos/sample-video.mp4";Q.useEffect(()=>{if(Tt((()=>{const q=navigator.userAgent||navigator.vendor||window.opera;return/iPad|iPhone|iPod/.test(q)&&!window.MSStream})()),typeof window<"u"){const q=localStorage.getItem("video_initialized")==="true";je(q)}},[]),Q.useEffect(()=>{Re&&!ce&&(je(!0),typeof window<"u"&&localStorage.setItem("video_initialized","true"))},[Re,ce]),Q.useEffect(()=>{const Se=M.current;if(!Se)return;Se.setAttribute("playsinline","true"),Se.setAttribute("webkit-playsinline","true"),Se.setAttribute("x-webkit-airplay","allow");const q=()=>{xt.current||(Be(Se.currentTime),typeof window<"u"&&(window.lastSeekedPosition=Se.currentTime))},G=()=>{re&&(je(!0),localStorage.setItem("video_initialized","true"))},he=()=>{};return Se.addEventListener("timeupdate",q),Se.addEventListener("play",G),Se.addEventListener("pause",he),()=>{Se.removeEventListener("timeupdate",q),Se.removeEventListener("play",G),Se.removeEventListener("pause",he)}},[M,re,xt]),Q.useEffect(()=>{Be(R)},[R]);const Z=be>0?R/be*100:0,zt=Se=>{Se.preventDefault(),I(!0),xt.current=!0,Et(Se);const q=he=>{xt.current&&Et(he)},G=()=>{I(!1),xt.current=!1,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",G)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",G)},Et=Se=>{if(!ge.current)return;const q=ge.current.getBoundingClientRect(),G=Math.max(0,Math.min(1,(Se.clientX-q.left)/q.width)),he=be*G;Le({x:Se.clientX}),Ce(he),Be(he),typeof window<"u"&&(window.lastSeekedPosition=he),f(he)},st=Se=>{if(!ge.current||!Se.touches[0])return;Se.preventDefault(),I(!0),xt.current=!0,Ot(Se);const q=he=>{xt.current&&Ot(he)},G=()=>{I(!1),xt.current=!1,document.removeEventListener("touchmove",q),document.removeEventListener("touchend",G),document.removeEventListener("touchcancel",G)};document.addEventListener("touchmove",q,{passive:!1}),document.addEventListener("touchend",G),document.addEventListener("touchcancel",G)},Ot=Se=>{if(!ge.current)return;const q="touches"in Se?Se.touches[0]:null;if(!q)return;Se.preventDefault();const G=ge.current.getBoundingClientRect(),he=Math.max(0,Math.min(1,(q.clientX-G.left)/G.width)),mt=be*he;Le({x:q.clientX}),Ce(mt),Be(mt),typeof window<"u"&&(window.lastSeekedPosition=mt),f(mt)},ke=Se=>{if(!Qe&&ge.current){const q=ge.current.getBoundingClientRect(),G=(Se.clientX-q.left)/q.width,he=be*G;Be(he),typeof window<"u"&&(window.lastSeekedPosition=he),f(he)}},X=()=>{M.current&&(document.fullscreenElement?document.exitFullscreen():M.current.requestFullscreen())},tt=()=>{const Se=M.current;Se&&(Se.paused?re&&te!==null&&te>0?(Se.currentTime=te,setTimeout(()=>{M.current&&M.current.play().then(()=>{var q;me.debug("iOS: Play started successfully at position:",(q=M.current)==null?void 0:q.currentTime),ve()}).catch(q=>{console.error("iOS: Error playing video:",q)})},50)):Se.play().then(()=>{ve()}).catch(q=>{console.error("Error playing video:",q)}):(Se.pause(),ve()))};return p.jsxs("div",{className:"video-player-container",children:[p.jsxs("video",{ref:M,preload:"auto",crossOrigin:"anonymous",onClick:tt,playsInline:!0,"webkit-playsinline":"true","x-webkit-airplay":"allow",controls:!1,muted:we,children:[p.jsx("source",{src:U,type:"video/mp4"}),p.jsx("p",{children:"Your browser doesn't support HTML5 video."})]}),re&&!ce&&!Re&&p.jsx("div",{className:"ios-first-play-indicator",children:p.jsx("div",{className:"ios-play-message",children:"Tap Play to initialize video controls"})}),p.jsx("div",{className:`play-pause-indicator ${Re?"pause-icon":"play-icon"}`}),p.jsxs("div",{className:"video-controls",children:[p.jsxs("div",{className:"video-time-display",children:[p.jsx("span",{className:"video-current-time",children:ki(R)}),p.jsxs("span",{className:"video-duration",children:["/ ",ki(be)]})]}),p.jsxs("div",{ref:ge,className:`video-progress ${Qe?"dragging":""}`,onClick:ke,onMouseDown:zt,onTouchStart:st,children:[p.jsx("div",{className:"video-progress-fill",style:{width:`${Z}%`}}),p.jsx("div",{className:"video-scrubber",style:{left:`${Z}%`}}),Qe&&p.jsx("div",{className:"video-time-tooltip",style:{left:`${ot.x}px`,transform:"translateX(-50%)"},children:P(rt)})]}),p.jsxs("div",{className:"video-controls-buttons",children:[W&&p.jsx("button",{className:"mute-button","aria-label":we?"Unmute":"Mute",onClick:W,"data-tooltip":we?"Unmute":"Mute",children:we?p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"}),p.jsx("path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6"}),p.jsx("path",{d:"M17 16.95A7 7 0 0 1 5 12v-2m14 0v2a7 7 0 0 1-.11 1.23"}),p.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),p.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}):p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),p.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"})]})}),p.jsx("button",{className:"fullscreen-button","aria-label":"Fullscreen",onClick:X,"data-tooltip":"Toggle fullscreen",children:p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:p.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13-1a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 010-2h1.586l-2.293-2.293a1 1 0 011.414-1.414L15 13.586V12a1 1 0 011-1z",clipRule:"evenodd"})})})]})]})]})},nf=(M,R)=>{const be=Math.min(Math.max(M/(R||1),0),1),Re=210,we=40+Math.floor(be*20),ve=85+Math.floor(be*8);return`hsl(${Re}, ${we}%, ${ve}%)`},af=async(M,R)=>new Promise(be=>{const Re=document.createElement("canvas");Re.width=10,Re.height=10;const we=Re.getContext("2d");if(we){const f=nf(R,M.duration);we.fillStyle=f,we.fillRect(0,0,Re.width,Re.height)}const ve=Re.toDataURL("image/png",.5);be(ve)}),qu=({isOpen:M,onClose:R,title:be,children:Re,actions:we})=>{if(Q.useEffect(()=>{const f=W=>{W.key==="Escape"&&M&&R()};return document.addEventListener("keydown",f),M&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",f),document.body.style.overflow=""}},[M,R]),!M)return null;const ve=f=>{f.target===f.currentTarget&&R()};return p.jsx("div",{className:"modal-overlay",onClick:ve,children:p.jsxs("div",{className:"modal-container",onClick:f=>f.stopPropagation(),children:[p.jsxs("div",{className:"modal-header",children:[p.jsx("h2",{className:"modal-title",children:be}),p.jsx("button",{className:"modal-close-button",onClick:R,"aria-label":"Close modal",children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p.jsx("div",{className:"modal-content",children:Re}),we&&p.jsx("div",{className:"modal-actions",children:we})]})})},Y0=async(M,R)=>{try{const be=await fetch(`/api/v1/media/${M}/chapters`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(me.debug("response",be),!be.ok){if(be.status===404)return{success:!0,timestamp:new Date().toISOString()};try{const we=await be.json();return{success:!1,timestamp:new Date().toISOString(),error:we.error||"Auto-save failed"}}catch{return{success:!1,timestamp:new Date().toISOString(),error:"Auto-save failed"}}}const Re=await be.json();return Re.status==="success"?{success:!0,timestamp:Re.updated_at||new Date().toISOString(),...Re}:{success:!1,timestamp:new Date().toISOString(),error:Re.error||"Auto-save failed"}}catch{return{success:!0,timestamp:new Date().toISOString()}}},Cm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%23333333;}%20.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%20%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cpath%20class='st0'%20d='M350.45,277.5l-164.08,94.73c-16.55,9.56-37.24-2.39-37.24-21.5V161.27c0-19.11,20.69-31.06,37.24-21.5%20l164.08,94.73C367,244.06,367,267.94,350.45,277.5z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",xm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M208.15,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C218.47,375.57,213.85,380.19,208.15,380.19z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M395.04,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C405.36,375.57,400.74,380.19,395.04,380.19z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Rm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M85.26,277.5l164.08,94.73c16.55,9.56,37.24-2.39,37.24-21.5V161.27c0-19.11-20.69-31.06-37.24-21.5%20L85.26,234.5C68.71,244.06,68.71,267.94,85.26,277.5z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M377.47,375.59h41.42c11.19,0,20.26-9.07,20.26-20.26V156.67c0-11.19-9.07-20.26-20.26-20.26h-41.42%20c-11.19,0-20.26,9.07-20.26,20.26v198.67C357.21,366.52,366.28,375.59,377.47,375.59z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",I0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",W0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(28,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",q0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(30,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",G0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",X0={color:"#007bff",textDecoration:"none",fontWeight:"bold","&:hover":{textDecoration:"underline",color:"#0056b3"}},wm=M=>{let ve,f;if(M<=25)if(M<=0)ve="0%",f="none";else{const ge=-50*((M-0)/25);ve=`${M}%`,f=`translateX(${ge}%)`}else if(M>=75)if(M>=100)ve="100%",f="translateX(-100%)";else{const ge=-50-50*((M-75)/25);ve=`${M}%`,f=`translateX(${ge}%)`}else ve=`${M}%`,f="translateX(-50%)";return{left:ve,transform:f}},Q0=({currentTime:M,duration:R,thumbnails:be,trimStart:Re,trimEnd:we,splitPoints:ve,zoomLevel:f,clipSegments:W,selectedSegmentId:ge,onSelectedSegmentChange:re,onSegmentUpdate:Tt,onChapterSave:ce,onTrimStartChange:je,onTrimEndChange:te,onZoomChange:Be,onSeek:Qe,videoRef:I,hasUnsavedChanges:xt=!1,isIOSUninitialized:ot=!1,isPlaying:Le,setIsPlaying:rt,onPlayPause:Ce,isPlayingSegments:U=!1})=>{const Z=Q.useRef(null),zt=Q.useRef(null),Et=Q.useRef(null),[st,Ot]=Q.useState(null),ke=ge!==void 0?ge:st,X=v=>{re?re(v):Ot(v)},[tt,oe]=Q.useState(!1),[Se,q]=Q.useState({x:0,y:0}),[G,he]=Q.useState(0),[mt,At]=Q.useState(!1),[ct,en]=Q.useState(30),[jt,Ye]=Q.useState(!1),[ze,Ve]=Q.useState(null),[vn,Ze]=Q.useState(0),[Gt,St]=Q.useState(!1),it=Q.useRef(null),[an,on]=Q.useState(""),[ln,cn]=Q.useState(!1),ue=[...W].sort((v,w)=>v.startTime-w.startTime).find(v=>v.id===ke),[De,Te]=Q.useState(""),[Oe,et]=Q.useState(!1),Je=Q.useRef(null),Ie=Q.useRef(W);Q.useEffect(()=>{Ie.current=W},[W]);const We=Q.useCallback(async()=>{var v;try{et(!0);const w=Ie.current.map(L=>({startTime:P(L.startTime),endTime:P(L.endTime),name:L.name,chapterTitle:L.chapterTitle,text:L.chapterTitle}));me.debug("segments",w);const b=typeof window<"u"&&((v=window.MEDIA_DATA)==null?void 0:v.mediaId)||null||"1234";if(me.debug("mediaId",b),!b||w.length===0){me.debug("No mediaId or segments, skipping auto-save"),et(!1);return}me.debug("Auto-saving segments:",{mediaId:b,segments:w});const S=await Y0(b,{segments:w});if(S.success){me.debug("Auto-save successful");const T=new Date(S.timestamp).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Te(T),me.debug("Auto-save successful:",T)}else me.error("Auto-save failed:",S.error)}catch(w){me.error("Auto-save error:",w)}finally{et(!1)}},[]),ft=Q.useCallback(()=>{Je.current&&clearTimeout(Je.current);const v=setTimeout(()=>{We()},1e3);Je.current=v},[We]);Q.useEffect(()=>{on(ue&&ue.chapterTitle||"")},[ke,ue]);const pn=v=>{on(v),cn(!0),ke&&Tt&&Tt(ke,{chapterTitle:v})},Ln=v=>{const w=v;let E=null,b=null,S=G;const L=()=>{const T=w<0?Math.max(0,S+w):Math.min(R,S+w);S=T;const V=jt;if(Qe(T),he(T),Ze(T),Z.current){const j=Z.current.getBoundingClientRect(),F=T/R*100,ut=j.left+j.width*(F/100);q({x:ut,y:j.top-10});const ee=W.find(dt=>T>=dt.startTime&&T<=dt.endTime);if(ee)X(ee.id),oe(!1);else{X(null);const dt=fn(T);en(dt),oe(!0)}}V&&I.current&&(I.current.play(),Ye(!0))};return{onMouseDown:T=>{T.stopPropagation(),T.preventDefault(),S=G,L(),E=setTimeout(()=>{b=setInterval(L,200)},750);const V=()=>{E&&(clearTimeout(E),E=null),b&&(clearInterval(b),b=null),document.removeEventListener("mouseup",V),document.removeEventListener("mouseleave",V)};document.addEventListener("mouseup",V),document.addEventListener("mouseleave",V)},onTouchStart:T=>{T.stopPropagation(),T.preventDefault(),S=G,L(),E=setTimeout(()=>{b=setInterval(L,200)},750);const V=()=>{E&&(clearTimeout(E),E=null),b&&(clearInterval(b),b=null),document.removeEventListener("touchend",V),document.removeEventListener("touchcancel",V)};document.addEventListener("touchend",V),document.addEventListener("touchcancel",V)},onClick:T=>{T.stopPropagation()}}},[mn,K]=Q.useState(!1),[ye,Ae]=Q.useState(!1),[nt,Ut]=Q.useState(!1),[Wt,Ht]=Q.useState(!1),[zn,Xt]=Q.useState(""),[It,Ft]=Q.useState(""),[Fn,xa]=Q.useState(""),[ma,lr]=Q.useState("chapters"),Na=R>0?M/R*100:0,Jr=R>0?Re/R*100:0,Er=R>0?we/R*100:0,Zr=async()=>{var v;K(!1),Ae(!0),lr("chapters");try{const w=W.filter(E=>E.chapterTitle&&E.chapterTitle.trim()).map(E=>({name:E.chapterTitle||`Chapter ${E.id}`,from:P(E.startTime),to:P(E.endTime)}));if(w.length===0){Ft("No chapters with titles found"),Ht(!0),Ae(!1);return}if(ce){await ce(w),Ae(!1),Xt("Chapters saved successfully!");const E=typeof window<"u"&&((v=window.MEDIA_DATA)==null?void 0:v.mediaId)||null;E&&xa(`/view?m=${E}`),Ut(!0)}else Ft("Chapter save function not available"),Ht(!0),Ae(!1)}catch(w){me.error("Error saving chapters:",w),Ae(!1);const E=w instanceof Error?w.message:"An error occurred while saving chapters";Ft(E),Ht(!0)}};Q.useEffect(()=>{if(it.current&&Z.current&&f>1){const v=it.current.clientWidth,w=Z.current.clientWidth,E=M/R*w,b=Math.max(0,E-v/2);it.current.scrollTo({left:b,behavior:"smooth"});const S=Z.current.getBoundingClientRect();it.current.getBoundingClientRect();const T=S.left-it.current.scrollLeft+Na/100*S.width;(ke!==null||tt)&&(q({x:T,y:S.top-10}),he(M))}},[M,f,R,ke,tt,Na]),Q.useEffect(()=>{const v=I.current;if(!v||!ze||!jt||U)return;me.debug("Segment boundary check ACTIVATED for segment:",ze.id,"Start:",P(ze.startTime),"End:",P(ze.endTime));const w=()=>{const E=ze.endTime-v.currentTime;if(Math.round(E*10)%10===0&&me.debug("Segment playback - time remaining:",P(E),"Current:",P(v.currentTime),"End:",P(ze.endTime),"ContinuePastBoundary:",Gt),v.currentTime>ze.endTime){v.pause(),v.currentTime=ze.endTime,Ye(!1),St(!1),me.debug("Passed segment end - setting back to exact boundary:",P(ze.endTime));return}if(ze.endTime-v.currentTime<.05)if(Gt)me.debug("Continuing past segment boundary:",P(ze.endTime)),v.currentTime>ze.endTime&&(St(!1),Ve(null),sessionStorage.removeItem("continuingPastSegment"));else{v.pause(),v.currentTime=ze.endTime,Ye(!1),me.debug("Paused at segment end boundary:",P(ze.endTime));const S=[...W].sort((L,T)=>L.startTime-T.startTime).find(L=>L.startTime>ze.endTime);S&&Math.abs(S.startTime-ze.endTime)<.1&&(me.debug("Found adjacent next segment:",S.id),X(S.id),Ve(S),Ze(S.startTime),he(S.startTime),v.currentTime=S.startTime)}};return v.addEventListener("timeupdate",w),()=>{v.removeEventListener("timeupdate",w)}},[ze,jt,Gt,W]),Q.useEffect(()=>{if(I.current)if(I.current.paused)I.current.paused&&jt&&(Ze(M),he(M),Ye(!1),me.debug("Video paused at:",P(M)));else{Ze(M),he(M),ke!==null&&Ye(!0);const v=W.find(b=>M>=b.startTime&&M<=b.endTime),w=M/R*100;if(Z.current){const b=Z.current.offsetWidth,S=w/100*b;q({x:S,y:Z.current.getBoundingClientRect().top-10})}const E=sessionStorage.getItem("continuingPastSegment")==="true";if(v){const b=I.current,S=ze&&ze.id<0&&jt;if((ze==null?void 0:ze.id)!==v.id&&!S&&!E&&!Gt&&(me.debug(`Entered a new segment during playback: ${v.id}, setting as active`),Ve(v),X(v.id),oe(!1),St(!1),sessionStorage.removeItem("continuingPastSegment")),S&&b&&v){me.debug(`CUTAWAY BOUNDARY REACHED: Current position ${P(b.currentTime)} at segment ${v.id} - STOPPING at boundary ${P(v.startTime)}`),b.pause(),setTimeout(()=>{if(I.current){I.current.currentTime=v.startTime,Qe(v.startTime),Ze(v.startTime),he(v.startTime),St(!1),X(v.id),oe(!1);const T=()=>{I.current&&(I.current.currentTime=v.startTime,Qe(v.startTime),Ze(v.startTime),he(v.startTime),me.debug(`Position corrected to exact segment boundary: ${P(I.current.currentTime)} (target: ${P(v.startTime)})`))};setTimeout(T,10),setTimeout(T,20),setTimeout(T,50),setTimeout(T,100),setTimeout(T,200),I.current.addEventListener("seeked",T),I.current.addEventListener("canplay",T),I.current.addEventListener("waiting",T),setTimeout(()=>{I.current&&(I.current.removeEventListener("seeked",T),I.current.removeEventListener("canplay",T),I.current.removeEventListener("waiting",T))},300)}},10),Ye(!1),Ve(null);return}ze===null&&jt===!0||E||S?(ke!==v.id||tt)&&(me.debug("Tooltip updated for segment during continued playback:",v.id,S?"(cutaway playback - keeping virtual segment)":""),X(v.id),oe(!1),!S&&sessionStorage.getItem("lastSegmentId")!==v.id.toString()&&sessionStorage.removeItem("continuingPastSegment")):((ze==null?void 0:ze.id)!==v.id||tt)&&(me.debug("Playback moved into segment:",v.id),X(v.id),Ve(v),oe(!1),sessionStorage.setItem("lastSegmentId",v.id.toString()))}else if(ze!==null||!tt){X(null),Ve(null);const b=fn(M);en(b),b>=.5?oe(!0):oe(!1)}}},[M,jt,ze,ke,W]),Q.useEffect(()=>{const v=w=>{const E=w.target;mt&&!E.closest(".zoom-dropdown-container")&&At(!1)};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[mt]),Q.useEffect(()=>{const v=b=>{const{recordHistory:S,fromAutoSave:L}=b.detail;S&&!L&&ft()},w=()=>{ft()},E=b=>{const{recordHistory:S}=b.detail;S&&ft()};return document.addEventListener("update-segments",v),document.addEventListener("segment-drag-end",w),document.addEventListener("update-trim",E),document.addEventListener("delete-segment",ft),document.addEventListener("split-segment",ft),()=>{document.removeEventListener("update-segments",v),document.removeEventListener("segment-drag-end",w),document.removeEventListener("update-trim",E),document.removeEventListener("delete-segment",ft),document.removeEventListener("split-segment",ft),Je.current&&(me.debug("Clearing auto-save timer in cleanup:",Je.current),clearTimeout(Je.current))}},[ft]),Q.useEffect(()=>{W.length>0&&!De&&setTimeout(()=>{We()},500)},[De,We]),Q.useEffect(()=>{const v=()=>{var b;let E=typeof window<"u"&&((b=window.MEDIA_DATA)==null?void 0:b.savedSegments)||null;E||(E={segments:[{startTime:"00:00:00.000",endTime:"00:00:10.000",chapterTitle:"Chapter 1 (from saved data)"},{startTime:"00:00:12.000",endTime:"00:00:17.000",chapterTitle:"Chapter 2 (from saved data)"},{startTime:"00:00:20.000",endTime:"00:00:30.000",chapterTitle:"Chapter 3 (from saved data)"}],updated_at:"2025-06-24 14:59:14"});try{if(E&&E.segments&&E.segments.length>0){me.debug("Found saved segments:",E);const S=E.segments.map((T,V)=>({id:Date.now()+V,name:T.name||`Segment ${V+1}`,startTime:w(T.startTime),endTime:w(T.endTime),thumbnail:"",chapterTitle:T.chapterTitle||""})),L=new CustomEvent("update-segments",{detail:{segments:S,recordHistory:!1,fromAutoSave:!0}});if(document.dispatchEvent(L),E.updated_at){const V=new Date(E.updated_at).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Te(V)}}else me.debug("No saved segments found")}catch(S){console.error("Error loading saved segments:",S)}},w=E=>{const b=E.split(":");if(b.length!==3)return 0;const S=parseInt(b[0])||0,L=parseInt(b[1])||0,T=b[2].split("."),V=parseInt(T[0])||0,j=parseInt(T[1])||0;return S*3600+L*60+V+j/1e3};setTimeout(v,100)},[]),Q.useEffect(()=>()=>{},[ke,tt,jt]),Q.useEffect(()=>{const v=zt.current,w=Et.current,E=Z.current;if(!v||!w||!E)return;const b=S=>L=>{L.preventDefault();const T=E.getBoundingClientRect();let V=!0,j=S?Re:we;const F=dt=>new CustomEvent("trim-handle-event",{detail:{type:dt,isStart:S}});document.dispatchEvent(F("drag-start"));const ut=dt=>{if(!V)return;const Rt=T.width,hn=Math.max(0,Math.min(1,(dt.clientX-T.left)/Rt))*R;typeof window<"u"&&(window.lastSeekedPosition=hn),S?hnRe&&(document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:hn,isStart:!1,recordHistory:!1}})),j=hn)},ee=()=>{V=!1,document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",ee),S?document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:j,isStart:!0,recordHistory:!0,action:"adjust_trim_start"}})):document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:j,isStart:!1,recordHistory:!0,action:"adjust_trim_end"}})),document.dispatchEvent(F("drag-end"))};document.addEventListener("mousemove",ut),document.addEventListener("mouseup",ee)};return v.addEventListener("mousedown",b(!0)),w.addEventListener("mousedown",b(!1)),()=>{v.removeEventListener("mousedown",b(!0)),w.removeEventListener("mousedown",b(!1))}},[R,Re,we,je,te]);const ei=()=>{const v=be.length||10;return Array.from({length:v}).map((w,E)=>{const b=R/v,S=E*b,L=S+b,T=(S+L)/2,V=nf(T,R);return p.jsx("div",{className:"timeline-thumbnail",style:{width:`${100/v}%`,backgroundColor:V}},E)})},Ra=()=>ve.map((v,w)=>{const E=v/R*100;return p.jsx("div",{className:"split-point",style:{left:`${E}%`}},w)}),fn=v=>{const E=[...W].sort((T,V)=>T.startTime-V.startTime),b=E.find(T=>T.startTime>v),S=[...E].reverse().find(T=>T.endTime{if(!Z.current)return;const w=W.find(j=>{const F=v>=j.startTime&&v<=j.endTime,ut=Math.abs(v-j.startTime)<.001,ee=Math.abs(v-j.endTime)<.001;return F||ut||ee}),E=[...W].sort((j,F)=>j.startTime-F.startTime),b=E.find(j=>j.startTime>v),S=[...E].reverse().find(j=>j.endTime1&&it.current?V=L.left-it.current.scrollLeft+L.width*(T/100):V=L.left+L.width*(T/100),q({x:V,y:L.top-10})},ja=v=>{if(!Z.current||!it.current||ot)return;const w=I.current&&!I.current.paused;St(!1);const E=Z.current.getBoundingClientRect();let b;if(f>1){const T=it.current.scrollLeft,V=Z.current.clientWidth;b=(v.clientX-E.left+T)/V}else b=(v.clientX-E.left)/E.width;const S=b*R;me.debug("Timeline clicked at:",P(S),"distance from end:",P(R-S)),typeof window<"u"&&(window.lastSeekedPosition=S),Qe(S),he(S),Ze(S);const L=W.find(T=>{const V=S>=T.startTime&&S<=T.endTime,j=Math.abs(S-T.startTime)<.01,F=Math.abs(S-T.endTime)<.01;return V||j||F});if(L&&Ve(L),I.current)if(U&&w){if(L){const V=[...W].sort((j,F)=>j.startTime-F.startTime).findIndex(j=>j.id===L.id);if(V!==-1){const j=new CustomEvent("update-segment-index",{detail:{segmentIndex:V}});document.dispatchEvent(j),me.debug(`Segments playback mode: updating segment index to ${V} for timeline click in segment ${L.id}`)}}I.current.play().then(()=>{Ye(!0)}).catch(T=>{console.error("Error resuming segments playback:",T),Ye(!1)})}else w&&!U&&I.current.play().then(()=>{Ye(!0)}).catch(T=>{console.error("Error resuming playback:",T),Ye(!1)});if(v.target===Z.current||v.target.classList.contains("timeline-thumbnail"))if(L)X(L.id),oe(!1);else{X(null);const T=fn(S);en(T);let V;if(f>1){const ee=E.left-it.current.scrollLeft,dt=S/R;V=ee+dt*E.width}else V=v.clientX;q({x:V,y:E.top-10}),oe(!0);const j=[...W].sort((ee,dt)=>ee.startTime-dt.startTime),F=[...j].reverse().find(ee=>ee.endTimeee.startTime>S);me.debug("Clicked in cutaway area:",{position:P(S),availableSpace:P(T),prevSegmentEnd:F?P(F.endTime):"none",nextSegmentStart:ut?P(ut.startTime):"none"})}},Ua=(v,w)=>E=>{if(E.preventDefault(),E.stopPropagation(),!Z.current)return;Z.current.getBoundingClientRect().width;const S=W.find(On=>On.id===v);if(!S)return;const L=S.startTime,T=S.endTime,V={...S};document.body.style.cursor="ew-resize";const j=document.createElement("div");j.style.position="fixed",j.style.top="0",j.style.left="0",j.style.width="100vw",j.style.height="100vh",j.style.zIndex="1000",j.style.cursor="ew-resize",document.body.appendChild(j);let F=!0,ut=L,ee=T;document.dispatchEvent(new CustomEvent("segment-drag-start",{detail:{segmentId:v}}));const dt=On=>{if(!F||!Z.current)return;const wr=Z.current.getBoundingClientRect(),Yt=Math.max(0,Math.min(1,(On-wr.left)/wr.width))*R,ha=w?Yt:L,na=w?T:Yt;if(M>=ha&&M<=na)X(v),oe(!1);else{X(null);const yn=fn(M);en(yn),oe(!0)}const Wa=W.filter(yn=>yn.id!==v);let ya=L,aa=T;if(w){ya=Math.min(Yt,T-.5);const _t=Wa.filter(ra=>ra.endTime<=L).sort((ra,ni)=>ni.endTime-ra.endTime)[0];_t&&ya<_t.endTime&&(ya=_t.endTime),_t&&Math.abs(ya-_t.endTime)<.3&&(ya=_t.endTime),ut=ya}else{aa=Math.max(Yt,L+.5);const _t=Wa.filter(ra=>ra.startTime>=T).sort((ra,ni)=>ra.startTime-ni.startTime)[0];_t&&aa>_t.startTime&&(aa=_t.startTime),_t&&Math.abs(aa-_t.startTime)<.3&&(aa=_t.startTime),ee=aa}const Dr=W.map(yn=>yn.id===v?{...yn,startTime:ya,endTime:aa}:yn),Mi=new CustomEvent("update-segments",{detail:{segments:Dr,recordHistory:!1}});if(document.dispatchEvent(Mi),ke===v&&I.current){const yn=I.current.currentTime,_t=Dr.find(ur=>ur.id===v);if(_t){const ur=yn>=_t.startTime&&yn<=_t.endTime;me.debug(`During drag - playhead at ${P(yn)} is ${ur?"inside":"outside"} segment (${P(_t.startTime)} - ${P(_t.endTime)})`),!ur&&jt&&(I.current.pause(),Ye(!1),Ve(null)),yn<_t.startTime?(me.debug(`Adjusting display time to segment start: ${P(_t.startTime)}`),Ze(_t.startTime),he(_t.startTime)):yn>_t.endTime&&(me.debug(`Adjusting display time to segment end: ${P(_t.endTime)}`),Ze(_t.endTime),he(_t.endTime))}}},Rt=()=>{if(!F)return;F=!1,document.removeEventListener("mousemove",Ct),document.removeEventListener("mouseup",hn),document.removeEventListener("touchmove",Rr),document.removeEventListener("touchend",Ha),document.removeEventListener("touchcancel",Ha),document.body.style.cursor="",document.body.contains(j)&&document.body.removeChild(j);const On=W.map(Vn=>Vn.id===v?{...Vn,startTime:ut,endTime:ee}:Vn),wr=w?"adjust_segment_start":"adjust_segment_end";if(document.dispatchEvent(new CustomEvent("update-segments",{detail:{segments:On,recordHistory:!0,action:wr}})),ke===v&&I.current){const Vn=I.current.currentTime,Yt=On.find(ha=>ha.id===v);if(Yt){const ha=Vn>=Yt.startTime&&Vn<=Yt.endTime;me.debug(`Drag complete - playhead at ${P(Vn)} is ${ha?"inside":"outside"} segment (${P(Yt.startTime)} - ${P(Yt.endTime)})`);const na=Vn>=V.startTime&&Vn<=V.endTime;ha?(!na&&ha||na&&ha&&(Yt.startTime!==V.startTime||Yt.endTime!==V.endTime))&&Ve(Yt):(jt&&(I.current.pause(),Ye(!1),Ve(null),St(!1)),VnYt.endTime&&(me.debug(`Final adjustment - setting display time to segment end: ${P(Yt.endTime)}`),Ze(Yt.endTime),he(Yt.endTime)))}}},Ct=On=>{dt(On.clientX)},hn=()=>{Rt()},Rr=On=>{On.touches.length>0&&(On.preventDefault(),dt(On.touches[0].clientX))},Ha=()=>{Rt()};document.addEventListener("mousemove",Ct,{passive:!1}),document.addEventListener("mouseup",hn),document.addEventListener("touchmove",Rr,{passive:!1}),document.addEventListener("touchend",Ha),document.addEventListener("touchcancel",Ha)},Cr=v=>w=>{if(w.target.classList.contains("clip-segment-handle"))return;w.preventDefault(),w.stopPropagation(),St(!1);const E=I.current&&!I.current.paused;X(v);const b=W.find(ee=>ee.id===v);if(!b)return;const L=w.currentTarget.getBoundingClientRect(),T=(w.clientX-L.left)/L.width,V=b.startTime+T*(b.endTime-b.startTime),j=Math.max(b.startTime,Math.min(b.endTime,V));if(he(j),Ze(j),I.current){const ee=I.current.currentTime,dt=ee>=b.startTime&&ee<=b.endTime;me.debug(`Segment click - playhead at ${P(ee)} is ${dt?"inside":"outside"} segment (${P(b.startTime)} - ${P(b.endTime)})`),dt||(Math.abs(ee-b.startTime)Rt.startTime-Ct.startTime).findIndex(Rt=>Rt.id===v);if(dt!==-1){const Rt=new CustomEvent("update-segment-index",{detail:{segmentIndex:dt}});document.dispatchEvent(Rt)}I.current.play().then(()=>{Ye(!0)}).catch(Rt=>{console.error("Error continuing segments playback after segment click:",Rt)})}else E&&!U&&(Ve(b),St(!1),I.current.play().then(()=>{Ye(!0)}).catch(ee=>{console.error("Error resuming playback after segment click:",ee)}));const F=w.clientX,ut=L.top-10;if(q({x:F,y:ut}),f>1&&Z.current&&it.current){Z.current.getBoundingClientRect();const ee=Z.current.clientWidth,dt=it.current.clientWidth,Rt=j/R*ee,Ct=Math.max(0,Rt-dt/2);it.current.scrollTo({left:Ct,behavior:"smooth"}),setTimeout(()=>{if(Z.current&&it.current){const hn=Z.current.getBoundingClientRect(),Ha=j/R*ee-it.current.scrollLeft+hn.left;q({x:Ha,y:ut})}},300)}},xr=()=>W.map((v,w)=>{const E=v.startTime/R*100,b=(v.endTime-v.startTime)/R*100,S=nf((v.startTime+v.endTime)/2,R);return p.jsxs("div",{className:`clip-segment ${ke===v.id?"selected":""}`,style:{left:`${E}%`,width:`${b}%`,backgroundColor:S,borderWidth:"2px",borderStyle:"solid",borderColor:"rgba(0, 0, 0, 0.5)"},onClick:Cr(v.id),children:[p.jsxs("div",{className:"clip-segment-info",children:[p.jsxs("div",{className:"clip-segment-name",children:["Segment ",w+1]}),p.jsxs("div",{className:"clip-segment-time",children:[ki(v.startTime)," - ",ki(v.endTime)]}),p.jsxs("div",{className:"clip-segment-duration",children:["Duration: ",ki(v.endTime-v.startTime)]})]}),U?null:p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"clip-segment-handle left",title:"Resize segment start",onMouseDown:L=>{L.stopPropagation(),Ua(v.id,!0)(L)},onTouchStart:L=>{L.stopPropagation(),Ua(v.id,!0)(L)}}),p.jsx("div",{className:"clip-segment-handle right",title:"Resize segment end",onMouseDown:L=>{L.stopPropagation(),Ua(v.id,!1)(L)},onTouchStart:L=>{L.stopPropagation(),Ua(v.id,!1)(L)}})]})]},v.id)});Q.useEffect(()=>{const v=w=>{const{segmentId:E}=w.detail;if(W.filter(S=>S.id!==E).length===0){const S={id:Date.now(),name:"Full Video",startTime:0,endTime:R,thumbnail:""},L=new CustomEvent("update-segments",{detail:{segments:[S],recordHistory:!0,action:"create_full_video_segment"}});if(document.dispatchEvent(L),X(S.id),oe(!1),he(M),Ze(M),Ve(S),Z.current){const T=Z.current.getBoundingClientRect(),V=M/R*100,j=T.left+T.width*(V/100);q({x:j,y:T.top-10}),me.debug("Created full video segment:",{id:S.id,duration:P(R),currentPosition:P(M)})}}else if(ke===E){if(!W.find(T=>T.id===E))return;const L=fn(M);if(X(null),oe(!0),en(L),Z.current){const T=Z.current.getBoundingClientRect(),V=M/R*100,j=T.left+T.width*(V/100);q({x:j,y:T.top-10}),me.debug("Segment deleted, showing cutaway tooltip:",{position:P(M),availableSpace:P(L)})}}};return document.addEventListener("delete-segment",v),()=>{document.removeEventListener("delete-segment",v)}},[ke,W,M,R,Z]),Q.useEffect(()=>{const v=I.current;if(!v)return;const w=()=>{if(!I.current)return;const b=I.current,S=b.currentTime;St(!1);let L=R,T=null,V=null;T=W.find(F=>{const ut=S>=F.startTime&&S<=F.endTime,ee=Math.abs(S-F.startTime)<.001,dt=Math.abs(S-F.endTime)<.001;return ut||ee||dt}),V=W.filter(F=>{const ut=F.startTime>S,ee=Math.abs(F.startTime-S)>.001;return ut&&ee}).sort((F,ut)=>F.startTime-ut.startTime)[0],T?(L=T.endTime,Ve(T)):V&&(L=V.startTime);const j=()=>{if(!b)return;const F=b.currentTime;if(L-F<=.001||F>=L){b.pause();const ee=()=>{b&&(b.currentTime=L,Qe(L),Ze(L),he(L),me.debug("Position verification:",{target:P(L),actual:P(b.currentTime),difference:Math.abs(b.currentTime-L).toFixed(3)}))};ee(),setTimeout(ee,10),setTimeout(ee,20),setTimeout(ee,50),T?(X(T.id),oe(!1)):V?(X(V.id),oe(!1),Ve(V)):(X(null),oe(!0),Ve(null)),b.removeEventListener("timeupdate",j),rt(!1),Ye(!1),St(!1);return}};b.addEventListener("timeupdate",j),b.play().then(()=>{rt(!0),Ye(!0),me.debug("Playback started:",{from:P(S),to:P(L),currentSegment:T?`Segment ${T.id}`:"None",nextSegment:V?`Segment ${V.id}`:"None"})}).catch(F=>{console.error("Error playing video:",F)})},E=()=>{Ye(!1)};return v.addEventListener("play",w),v.addEventListener("pause",E),()=>{v.removeEventListener("play",w),v.removeEventListener("pause",E)}},[W,R,Qe]);const h=v=>{if(!Z.current)return;const w=Z.current.getBoundingClientRect(),b=(v.clientX-w.left)/w.width*R,S=Math.max(0,Math.min(R,b));typeof window<"u"&&(window.lastSeekedPosition=S)},[B,ne]=Q.useState(!1),fe=Q.useRef(!1),lt=v=>{if(ot)return;v.stopPropagation(),v.preventDefault(),ne(!0),fe.current=!0,En(M);const w=b=>{if(!Z.current||!it.current)return;const S=Z.current.getBoundingClientRect();let L;if(f>1){const V=it.current.scrollLeft,j=Z.current.clientWidth;L=(b.clientX-S.left+V)/j}else L=(b.clientX-S.left)/S.width;L=Math.max(0,Math.min(1,L));const T=L*R;he(T),Ze(T),En(T),typeof window<"u"&&(window.lastSeekedPosition=T),Qe(T)},E=()=>{ne(!1),fe.current=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",E)},qe=v=>{if(ot)return;v.stopPropagation(),v.preventDefault(),ne(!0),fe.current=!0,En(M);const w=b=>{if(!Z.current||!it.current||!b.touches[0])return;const S=Z.current.getBoundingClientRect();let L;if(f>1){const V=it.current.scrollLeft,j=Z.current.clientWidth;L=(b.touches[0].clientX-S.left+V)/j}else L=(b.touches[0].clientX-S.left)/S.width;L=Math.max(0,Math.min(1,L));const T=L*R;he(T),Ze(T),En(T),typeof window<"u"&&(window.lastSeekedPosition=T),Qe(T)},E=()=>{ne(!1),fe.current=!1,document.removeEventListener("touchmove",w),document.removeEventListener("touchend",E),document.removeEventListener("touchcancel",E)};document.addEventListener("touchmove",w,{passive:!1}),document.addEventListener("touchend",E),document.addEventListener("touchcancel",E)};return Q.useEffect(()=>{},[Fn,ma,nt]),Q.useEffect(()=>{let v,w;if(nt&&Fn){let E=10;v=setInterval(()=>{E--;const b=document.querySelector(".countdown");b&&(b.textContent=E.toString()),E<=0&&clearInterval(v)},1e3),w=setTimeout(()=>{window.location.href=Fn},1e4)}return()=>{v&&clearInterval(v),w&&clearTimeout(w)}},[nt,Fn]),Q.useEffect(()=>{!nt&&Fn&&(window.location.href=Fn)},[Fn,ma,nt]),p.jsxs("div",{className:`timeline-container-card ${U?"segments-playback-mode":""}`,children:[p.jsxs("div",{className:"timeline-header",children:[p.jsx("div",{className:"timeline-title",children:p.jsx("span",{className:"timeline-title-text",children:"Timeline"})}),p.jsxs("div",{className:"duration-time",children:["Total Segments:"," ",p.jsx("span",{children:P(W.reduce((v,w)=>v+(w.endTime-w.startTime),0))})]})]}),p.jsx("div",{ref:it,className:`timeline-scroll-container ${U?"segments-playback-mode":""}`,style:{overflow:f>1?"auto":"hidden"},children:p.jsxs("div",{ref:Z,className:"timeline-container",onClick:ja,onMouseMove:h,style:{width:`${f*100}%`,cursor:"pointer"},children:[p.jsxs("div",{className:"timeline-marker",style:{left:`${Na}%`},children:[p.jsx("div",{className:"timeline-marker-head",onClick:v=>{if(v.stopPropagation(),W.find(w=>M>=w.startTime&&M<=w.endTime),ke||tt){X(null),oe(!1);return}else En(M),me.debug("Opening tooltip at:",P(M))},children:p.jsx("span",{className:"timeline-marker-head-icon",children:ke||tt?"-":"+"})}),U?null:p.jsx("div",{className:`timeline-marker-drag ${B?"dragging":""}`,onMouseDown:lt,onTouchStart:qe,children:p.jsx("span",{className:"timeline-marker-drag-icon",children:"⋮"})})]}),W.length===0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"trim-line-marker",style:{left:`${Jr}%`},children:p.jsx("div",{ref:zt,className:"trim-handle left"})}),p.jsx("div",{className:"trim-line-marker",style:{left:`${Er}%`},children:p.jsx("div",{ref:Et,className:"trim-handle right"})})]}),xr(),Ra(),ei(),ke!==null&&p.jsxs("div",{className:`segment-tooltip two-row-tooltip ${U?"segments-playback-mode":""}`,style:{position:"absolute",...wm(Na)},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:[ke&&p.jsx("div",{className:"tooltip-chapter-editor",children:p.jsx("textarea",{className:"tooltip-chapter-input",placeholder:"Chapter Title",value:an,onChange:v=>pn(v.target.value),onBlur:We,onMouseLeave:We,rows:2,maxLength:200,onClick:v=>v.stopPropagation(),onMouseDown:v=>v.stopPropagation(),onMouseUp:v=>v.stopPropagation()})}),p.jsxs("div",{className:"tooltip-row",children:[p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Seek -50ms (click or hold)",disabled:U,...U?{}:Ln(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),p.jsx("div",{className:`tooltip-time-display ${U?"disabled":""}`,style:{pointerEvents:U?"none":"auto",cursor:U?"not-allowed":"default",opacity:U?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:P(vn)}),p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Seek +50ms (click or hold)",disabled:U,...U?{}:Ln(.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"+50ms"})]}),p.jsxs("div",{className:"tooltip-row tooltip-actions",children:[p.jsx("button",{className:`tooltip-action-btn delete ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Delete segment",disabled:U,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},onClick:v=>{v.stopPropagation();const w=new CustomEvent("delete-segment",{detail:{segmentId:ke}});document.dispatchEvent(w)},children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M3 6h18"}),p.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),p.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),p.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),p.jsx("button",{className:`tooltip-action-btn scissors ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Split segment at current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation();const w=new CustomEvent("split-segment",{detail:{segmentId:ke,time:G}});document.dispatchEvent(w)},children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"6",cy:"6",r:"3"}),p.jsx("circle",{cx:"6",cy:"18",r:"3"}),p.jsx("line",{x1:"20",y1:"4",x2:"8.12",y2:"15.88"}),p.jsx("line",{x1:"14.47",y1:"14.48",x2:"20",y2:"20"}),p.jsx("line",{x1:"8.12",y1:"8.12",x2:"12",y2:"12"})]})}),p.jsx("button",{className:`tooltip-action-btn play-from-start ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Play segment from beginning",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation();const w=W.find(E=>E.id===ke);if(w&&I.current){if(St(!0),Math.abs(I.current.currentTime-w.endTime)<.05){me.debug(`Already at end boundary (${P(I.current.currentTime)}), nudging position back slightly`);const E=Math.max(w.startTime,w.endTime-.1);I.current.currentTime=E,Qe(E),he(E),me.debug(`Position adjusted to ${P(E)}`)}else Qe(w.startTime),he(w.startTime);Ve(w),I.current.play().then(()=>{Ye(!0)}).catch(E=>{console.error("Error playing from beginning:",E)})}},children:p.jsx("img",{src:Rm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn ${Le?"pause":"play"} ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":Le?"Pause playback":"Play from current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation(),Le?I.current&&(I.current.pause(),Ye(!1),St(!1)):Ce()},children:Le?p.jsx("img",{src:xm,alt:"Pause",style:{width:"24px",height:"24px"}}):p.jsx("img",{src:Cm,alt:"Play",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn set-in ${U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":"Set start point at current position",disabled:U,onClick:v=>{if(v.stopPropagation(),W.find(E=>E.id===ke)){const E=W.map(S=>S.id===ke?{...S,startTime:G{if(v.stopPropagation(),W.find(E=>E.id===ke)){const E=W.map(S=>S.id===ke?{...S,endTime:G>S.startTime+.5?G:S.startTime+.5}:S),b=new CustomEvent("update-segments",{detail:{segments:E,recordHistory:!0,action:"adjust_end_time"}});document.dispatchEvent(b)}},children:p.jsx("img",{src:I0,alt:"Set end point",style:{width:"24px",height:"24px"}})})]})]}),tt&&ke===null&&p.jsxs("div",{className:`empty-space-tooltip two-row-tooltip ${U?"segments-playback-mode":""}`,style:{position:"absolute",...wm(Na)},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:[p.jsxs("div",{className:"tooltip-row",children:[p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Seek -50ms (click or hold)",disabled:U,...U?{}:Ln(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),p.jsx("div",{className:`tooltip-time-display ${U?"disabled":""}`,style:{pointerEvents:U?"none":"auto",cursor:U?"not-allowed":"default",opacity:U?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:P(G)}),p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":"Seek +50ms (click or hold)",disabled:U,...U?{}:Ln(.05),children:"+50ms"})]}),p.jsxs("div",{className:"tooltip-row tooltip-actions",children:[p.jsxs("button",{className:`tooltip-action-btn new-segment ${ct<.5||U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":ct<.5?"Not enough space for new segment":"Create new segment",disabled:ct<.5||U,onClick:async v=>{if(v.stopPropagation(),ct<.5)return;const w=G,E=w+ct,b={id:Date.now(),name:"segment",startTime:w,endTime:E,thumbnail:""},S=[...W,b],L=new CustomEvent("update-segments",{detail:{segments:S,recordHistory:!0,action:"create_segment"}});document.dispatchEvent(L),oe(!1),setTimeout(()=>{const T=S[S.length-1];T&&(X(T.id),me.debug("Created and selected new segment:",T.id))},100)},children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),p.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),p.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),p.jsx("span",{className:"tooltip-btn-text",children:"New"})]}),p.jsx("button",{className:`tooltip-action-btn play-from-start ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Play from beginning of cutaway",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{if(v.stopPropagation(),I.current){const w=G;St(!0);const E=[...W].sort((F,ut)=>F.startTime-ut.startTime),b=[...E].reverse().find(F=>F.endTimeF.startTime>w),T=L?L.startTime:R,V={id:-999,name:"Cutaway",startTime:S,endTime:T,thumbnail:""};Qe(S),he(S),Ye(!1),setTimeout(()=>{Ve(V)},0);const j=()=>{if(!I.current)return;const F=I.current.currentTime,ut=[...W].sort((Ct,hn)=>Ct.startTime-hn.startTime),ee=ut.find(Ct=>Ct.startTime>F-.3),dt=ee&&F>=ee.startTime-.25&&F<=ee.startTime+.1&&!Gt;ee&&F>=ee.startTime-.25&&F<=ee.startTime+.1&&me.debug(`Approaching boundary at ${P(ee.startTime)}, continuePastBoundary=${Gt}, willStop=${dt}`);const Rt=ut.find(Ct=>F>=Ct.startTime&&F<=Ct.endTime);if(Rt&&(ze==null?void 0:ze.id)!==Rt.id){me.debug(`Entered segment ${Rt.id} during cutaway playback`),Ve(Rt),X(Rt.id),oe(!1),I.current.removeEventListener("timeupdate",j),St(!1),sessionStorage.removeItem("continuingPastSegment");return}if(dt&&ee){me.debug(`CUTAWAY MANUAL BOUNDARY CHECK: Current position ${P(F)} approaching segment at ${P(ee.startTime)} (distance: ${Math.abs(F-ee.startTime).toFixed(3)}s) - STOPPING`),I.current.pause(),setTimeout(()=>{if(I.current){I.current.currentTime=ee.startTime,Qe(ee.startTime),Ze(ee.startTime),he(ee.startTime),St(!1),X(ee.id),oe(!1),Ve(ee);const Ct=()=>{I.current&&(I.current.currentTime=ee.startTime,Qe(ee.startTime),Ze(ee.startTime),he(ee.startTime),me.debug(`Position corrected to exact segment boundary: ${P(I.current.currentTime)} (target: ${P(ee.startTime)})`))};setTimeout(Ct,10),setTimeout(Ct,20),setTimeout(Ct,50),setTimeout(Ct,100),setTimeout(Ct,200),I.current.addEventListener("seeked",Ct),I.current.addEventListener("canplay",Ct),I.current.addEventListener("waiting",Ct),setTimeout(()=>{I.current&&(I.current.removeEventListener("seeked",Ct),I.current.removeEventListener("canplay",Ct),I.current.removeEventListener("waiting",Ct))},300)}},10),Ye(!1),Ve(null),I.current.removeEventListener("timeupdate",j);return}};I.current.addEventListener("timeupdate",j),setTimeout(()=>{I.current&&I.current.play().then(()=>{Ye(!0),me.debug("CUTAWAY PLAYBACK STARTED:",P(S),"to",P(T),b?`(after segment ${b.id}, offset +25ms from ${P(b.endTime)})`:"(from video start)",L?`(will stop at segment ${L.id})`:"(will play to end)")}).catch(F=>{console.error("Error playing cutaway:",F)})},50)}},children:p.jsx("img",{src:Rm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn ${Le?"pause":"play"} ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":Le?"Pause playback":"Play from here until next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation(),Le?I.current&&(I.current.pause(),Ye(!1),St(!1)):Ce()},children:Le?p.jsx("img",{src:xm,alt:"Pause",style:{width:"24px",height:"24px"}}):p.jsx("img",{src:Cm,alt:"Play",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn segment-end ${U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":"Adjust end of previous segment",disabled:U,onClick:v=>{v.stopPropagation();const E=[...W].sort((b,S)=>b.startTime-S.startTime).filter(b=>b.endTime<=G).sort((b,S)=>S.endTime-b.endTime)[0];if(E){const b=W.map(L=>L.id===E.id?{...L,endTime:G}:L),S=new CustomEvent("update-segments",{detail:{segments:b,recordHistory:!0,action:"adjust_previous_end_time"}});document.dispatchEvent(S),me.debug("Adjusted end of previous segment to:",P(G)),X(E.id),oe(!1)}else if(W.length>0){const b=[...W].sort((T,V)=>T.startTime-V.startTime);let S=!1,L=0;for(let T=0;TV&&Gj.endTime-V.endTime)[0];if(T&&T.endTimeF.id===T.id?{...F,endTime:R}:F),j=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_last_segment"}});document.dispatchEvent(j),X(T.id),oe(!1)}}}else if(G>0){const b={id:Date.now(),name:"segment",startTime:0,endTime:G,thumbnail:""},S=new CustomEvent("update-segments",{detail:{segments:[b],recordHistory:!0,action:"create_segment_from_start"}});document.dispatchEvent(S),me.debug("Created new segment from start to:",P(G)),X(b.id),oe(!1)}},children:p.jsx("img",{src:G0,alt:"Set end point",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn segment-start ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Adjust start of next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation();const E=[...W].sort((b,S)=>b.startTime-S.startTime).filter(b=>b.startTime>=G).sort((b,S)=>b.startTime-S.startTime)[0];if(E){const b=W.map(L=>L.id===E.id?{...L,startTime:G}:L),S=new CustomEvent("update-segments",{detail:{segments:b,recordHistory:!0,action:"adjust_next_start_time"}});document.dispatchEvent(S),me.debug("Adjusted start of next segment to:",P(G)),X(E.id),oe(!1)}else if(W.length>0){const b=[...W].sort((T,V)=>T.startTime-V.startTime);let S=!1,L=0;for(let T=0;TV&&Gb[b.length-1].endTime){const T={id:Date.now(),name:"segment",startTime:G,endTime:R,thumbnail:""},V=[...W,T],j=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"create_segment_to_end"}});document.dispatchEvent(j),me.debug("Created new segment from",P(G),"to end"),X(T.id),oe(!1)}else{const T=b[0];if(T&&T.startTime>0){const V=W.map(F=>F.id===T.id?{...F,startTime:0}:F),j=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_first_segment"}});document.dispatchEvent(j),X(T.id),oe(!1)}}}else if(G{if(v.key==="Enter"){const w=v.currentTarget.value;try{const E=w.split(":");let b=0,S=0,L=0,T=0;if(E.length===3){b=parseInt(E[0]),S=parseInt(E[1]);const j=E[2].split(".");L=parseInt(j[0]),j.length>1&&(T=parseInt(j[1].padEnd(3,"0").substring(0,3)))}else if(E.length===2){S=parseInt(E[0]);const j=E[1].split(".");L=parseInt(j[0]),j.length>1&&(T=parseInt(j[1].padEnd(3,"0").substring(0,3)))}const V=b*3600+S*60+L+T/1e3;if(!isNaN(V)&&V>=0&&V<=R){Qe(V);const j=F=>{const ut=W.find(ee=>{const dt=F>=ee.startTime&&F<=ee.endTime,Rt=Math.abs(F-ee.startTime)<.001,Ct=Math.abs(F-ee.endTime)<.001;return dt||Rt||Ct});if(Z.current&&it.current){const ee=Z.current.getBoundingClientRect();let dt;if(f>1)dt=ee.left-it.current.scrollLeft+F/R*ee.width;else{const Rt=F/R;dt=ee.left+ee.width*Rt}q({x:dt,y:ee.top-10}),he(F),ut?(X(ut.id),oe(!1)):(X(null),oe(!0))}};setTimeout(()=>j(V),10)}}catch(E){console.error("Invalid time format:",E)}}}}),p.jsx("div",{className:"time-button-group",children:(()=>{const v=()=>{const w=W.find(E=>{const b=M>=E.startTime&&M<=E.endTime,S=Math.abs(M-E.startTime)<.001,L=Math.abs(M-E.endTime)<.001;return b||S||L});if(Z.current&&it.current){const E=Z.current.getBoundingClientRect();let b;if(f>1)b=E.left-it.current.scrollLeft+M/R*E.width;else{const S=M/R;b=E.left+E.width*S}if(q({x:b,y:E.top-10}),he(M),w)X(w.id),oe(!1);else{const S=fn(M);en(S),S>=.5?(X(null),oe(!0)):(X(null),oe(!1))}}};return p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"time-button",onClick:()=>{Qe(M-.01),setTimeout(v,10)},"data-tooltip":"Move back 10ms",children:"-10ms"}),p.jsx("button",{className:"time-button",onClick:()=>{Qe(M-.001),setTimeout(v,10)},"data-tooltip":"Move back 1ms",children:"-1ms"}),p.jsx("button",{className:"time-button",onClick:()=>{Qe(M+.001),setTimeout(v,10)},"data-tooltip":"Move forward 1ms",children:"+1ms"}),p.jsx("button",{className:"time-button",onClick:()=>{Qe(M+.01),setTimeout(v,10)},"data-tooltip":"Move forward 10ms",children:"+10ms"})]})})()})]}),p.jsxs("div",{className:"controls-right",children:[p.jsxs("div",{className:"zoom-dropdown-container",children:[p.jsxs("button",{className:"zoom-button","data-tooltip":"Select zoom level",onClick:()=>At(!mt),children:["Zoom ",f,"x",p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),mt&&p.jsx("div",{className:"zoom-dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:1e3},children:[1,2,4,8,16,32,64,128,256,512,1024,2048,4096].map(v=>p.jsxs("div",{className:`zoom-option ${f===v?"selected":""}`,onClick:()=>{Be(v),At(!1)},children:[f===v&&p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Zoom ",v,"x"]},v))})]}),p.jsx("div",{className:"auto-saved-time",style:{color:Oe?"#1976d2":"gray",fontSize:"12px",marginLeft:"10px",display:"flex",alignItems:"center",gap:"5px"},children:Oe?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"auto-save-spinner",style:{display:"inline-block",width:"12px",height:"12px",border:"2px solid #f3f3f3",borderTop:"2px solid #1976d2",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Auto saving..."]}):De?`Auto saved: ${De}`:"Not saved yet"}),p.jsx("div",{className:"save-buttons-row",children:p.jsx("button",{onClick:()=>K(!0),className:"save-chapters-button","data-tooltip":"Save chapters",disabled:W.filter(v=>v.chapterTitle&&v.chapterTitle.trim()).length===0,children:"Save Chapters"})}),p.jsx(qu,{isOpen:mn,onClose:()=>K(!1),title:"Save Chapters",actions:p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"modal-button modal-button-secondary",onClick:()=>K(!1),children:"Cancel"}),p.jsx("button",{className:"modal-button modal-button-primary",onClick:Zr,children:"Save Chapters"})]}),children:p.jsxs("p",{className:"modal-message",children:["Are you sure you want to save the chapters? This will save"," ",W.filter(v=>v.chapterTitle&&v.chapterTitle.trim()).length," chapters to the database."]})}),p.jsxs(qu,{isOpen:ye,onClose:()=>{},title:"Processing Video",children:[p.jsx("div",{className:"modal-spinner",children:p.jsx("div",{className:"spinner"})}),p.jsx("p",{className:"modal-message text-center",children:"Please wait while your video is being processed..."})]}),p.jsx(qu,{isOpen:nt,onClose:()=>Ut(!1),title:"Video Edited Successfully",children:p.jsx("div",{className:"modal-success-content",children:p.jsxs("p",{className:"modal-message text-center redirect-message",children:["You will be redirected to your"," ",p.jsx("a",{href:Fn,className:"media-page-link",style:X0,children:"media page"})," in ",p.jsx("span",{className:"countdown",children:"10"})," seconds. Your chapters have been saved successfully."]})})}),p.jsxs(qu,{isOpen:Wt,onClose:()=>Ht(!1),title:"Video Processing Error",children:[p.jsxs("div",{className:"modal-error-content",children:[p.jsx("div",{className:"modal-error-icon",children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#F44336",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),p.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),p.jsx("p",{className:"modal-message text-center error-message",children:It})]}),p.jsx("div",{className:"modal-choices",children:p.jsxs("button",{onClick:()=>Ht(!1),className:"modal-choice-button centered-choice",children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Close"]})})]})]})]}),ot&&p.jsx("div",{className:"mobile-timeline-overlay",children:p.jsxs("div",{className:"mobile-timeline-message",children:[p.jsx("p",{children:"Please play the video first to enable timeline controls"}),p.jsx("div",{className:"mobile-play-icon"})]})})]})},K0=({onSplit:M,onReset:R,onUndo:be,onRedo:Re,onPlaySegments:we,onPlay:ve,canUndo:f,canRedo:W,isPlaying:ge=!1,isPlayingSegments:re=!1})=>{const[Tt,ce]=Q.useState(!1);Q.useEffect(()=>{const te=()=>{ce(window.innerWidth<=640)};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]);const je=()=>{ve()};return p.jsx("div",{className:"editing-tools-container",children:p.jsxs("div",{className:"flex-container single-row",children:[p.jsxs("div",{className:"button-group play-buttons-group",children:[p.jsx("button",{className:"button segments-button",onClick:we,"data-tooltip":re?"Stop segments playback":"Play segments in one continuous flow",style:{fontSize:"0.875rem"},children:re?p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),p.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),p.jsx("span",{className:"full-text",children:"Stop Preview"}),p.jsx("span",{className:"short-text",children:"Stop Preview"})]}):p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),p.jsx("span",{className:"full-text",children:"Play Preview"}),p.jsx("span",{className:"short-text",children:"Play Preview"})]})}),(!re||!Tt)&&p.jsx("button",{className:`button play-button ${re?"greyed-out":""}`,onClick:je,"data-tooltip":ge?"Pause video":"Play full video",style:{fontSize:"0.875rem"},disabled:re,children:ge&&!re?p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),p.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),p.jsx("span",{className:"full-text",children:"Pause"}),p.jsx("span",{className:"short-text",children:"Pause"})]}):p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),p.jsx("span",{className:"full-text",children:"Play"}),p.jsx("span",{className:"short-text",children:"Play"})]})})]}),p.jsxs("div",{className:"button-group secondary",children:[p.jsxs("button",{className:"button","aria-label":"Undo","data-tooltip":re?"Disabled during preview":"Undo last action",disabled:!f||re,onClick:be,children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M9 14 4 9l5-5"}),p.jsx("path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11"})]}),p.jsx("span",{className:"button-text",children:"Undo"})]}),p.jsxs("button",{className:"button","aria-label":"Redo","data-tooltip":re?"Disabled during preview":"Redo last undone action",disabled:!W||re,onClick:Re,children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"m15 14 5-5-5-5"}),p.jsx("path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5v0A5.5 5.5 0 0 0 9.5 20H13"})]}),p.jsx("span",{className:"button-text",children:"Redo"})]}),p.jsx("div",{className:"divider"}),p.jsxs("button",{className:"button",onClick:R,"data-tooltip":re?"Disabled during preview":"Reset to full video",disabled:re,children:[p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:p.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),p.jsx("span",{className:"reset-text",children:"Reset"})]})]})]})})},J0=({segments:M,selectedSegmentId:R})=>{const be=[...M].sort((ve,f)=>ve.startTime-f.startTime),Re=ve=>{const f=new CustomEvent("delete-segment",{detail:{segmentId:ve}});document.dispatchEvent(f)},we=ve=>`segment-default-color segment-color-${ve%8+1}`;return be.find(ve=>ve.id===R),p.jsxs("div",{className:"clip-segments-container",children:[p.jsx("h3",{className:"clip-segments-title",children:"Chapters"}),be.map((ve,f)=>p.jsxs("div",{className:`segment-item ${we(f)} ${R===ve.id?"selected":""}`,children:[p.jsxs("div",{className:"segment-content",children:[p.jsx("div",{className:"segment-thumbnail",style:{backgroundImage:`url(${ve.thumbnail})`}}),p.jsxs("div",{className:"segment-info",children:[p.jsx("div",{className:"segment-title",children:ve.chapterTitle?p.jsx("span",{className:"chapter-title",children:ve.chapterTitle}):p.jsxs("span",{className:"default-title",children:["Chapter ",f+1]})}),p.jsxs("div",{className:"segment-time",children:[ki(ve.startTime)," - ",ki(ve.endTime)]}),p.jsxs("div",{className:"segment-duration",children:["Duration: ",$0(ve.endTime-ve.startTime)]})]})]}),p.jsx("div",{className:"segment-actions",children:p.jsx("button",{className:"delete-button","aria-label":"Delete Segment","data-tooltip":"Delete this segment",onClick:()=>Re(ve.id),children:p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:p.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})})})]},ve.id)),be.length===0&&p.jsx("div",{className:"empty-message",children:"No chapters created yet. Use the split button to create chapter segments."})]})},Z0=({videoRef:M,onPlay:R})=>{const[be,Re]=Q.useState(!1);Q.useEffect(()=>{const f=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent);Re(f)},[]),Q.useEffect(()=>{const ve=M.current;if(!ve)return;const f=()=>{Re(!1)};return ve.addEventListener("play",f),()=>{ve.removeEventListener("play",f)}},[M]);const we=()=>{R()};return be?p.jsx("div",{className:"mobile-play-prompt-overlay",children:p.jsx("div",{className:"mobile-play-prompt",children:p.jsx("button",{className:"mobile-play-button",onClick:we,children:"Click to start editing..."})})}):null},eS=()=>{const M=z=>{const ue=z.split(":");if(ue.length!==3)return 0;const De=parseInt(ue[0],10)||0,Te=parseInt(ue[1],10)||0,Oe=parseFloat(ue[2])||0;return De*3600+Te*60+Oe},R=Q.useRef(null),[be,Re]=Q.useState(0),[we,ve]=Q.useState(0),[f,W]=Q.useState(!1),[ge,re]=Q.useState(!1),[Tt,ce]=Q.useState([]),[je,te]=Q.useState(0),[Be,Qe]=Q.useState(0),[I,xt]=Q.useState([]),[ot,Le]=Q.useState(1),[rt,Ce]=Q.useState([]),[U,Z]=Q.useState(null),[zt,Et]=Q.useState([]),[st,Ot]=Q.useState(-1),[ke,X]=Q.useState(!1),[tt,oe]=Q.useState(!1),[Se,q]=Q.useState(0);Q.useEffect(()=>{var z;if(zt.length>0){const ue=((z=zt[st])==null?void 0:z.action)||"";ue!=="save"&&ue!=="save_copy"&&ue!=="save_segments"&&X(!0)}},[zt,st]),Q.useEffect(()=>{const z=R.current;if(!z)return;const ue=()=>{ve(z.duration),Qe(z.duration),(async()=>{var K;let Ie=[];const We=typeof window<"u"&&((K=window.MEDIA_DATA)==null?void 0:K.chapters)||[];if(We.length>0)for(let ye=0;ye{Re(z.currentTime)},Te=()=>{W(!0),ln(!0)},Oe=()=>{W(!1)},et=()=>{W(!1),z.currentTime=je};return z.addEventListener("loadedmetadata",ue),z.addEventListener("timeupdate",De),z.addEventListener("play",Te),z.addEventListener("pause",Oe),z.addEventListener("ended",et),()=>{z.removeEventListener("loadedmetadata",ue),z.removeEventListener("timeupdate",De),z.removeEventListener("play",Te),z.removeEventListener("pause",Oe),z.removeEventListener("ended",et)}},[]);const G=z=>{const ue=R.current;if(!ue)return;const De=!ue.paused;ue.currentTime=z,Re(z),typeof window<"u"&&(window.lastSeekedPosition=z),De&&ue.play().then(()=>{W(!0)}).catch(Te=>{console.error("Error resuming playback:",Te),W(!1)})},he=z=>{const ue={trimStart:je,trimEnd:Be,splitPoints:[...I],clipSegments:JSON.parse(JSON.stringify(rt)),action:z||"manual_save"},De=zt[st],Te=()=>{if(!De||De.clipSegments.length!==ue.clipSegments.length)return!0;for(let Je=0;Je.001||Math.abs(Ie.endTime-We.endTime)>.001)return!0}return!1},Oe=!De||De.trimStart!==ue.trimStart||De.trimEnd!==ue.trimEnd||De.splitPoints.length!==ue.splitPoints.length||Te(),et=ue.action!==void 0;if(Oe||et){const Je=st;Et(Ie=>JeIe+1)}};Q.useEffect(()=>{const z=ue=>{if(ue.detail){const{time:De,isStart:Te,recordHistory:Oe,action:et}=ue.detail;Te?te(De):Qe(De),Oe&&setTimeout(()=>{he(et||(Te?"adjust_trim_start":"adjust_trim_end"))},10)}};return document.addEventListener("update-trim",z),()=>{document.removeEventListener("update-trim",z)}},[]),Q.useEffect(()=>{const z=Te=>{if(Te.detail&&Te.detail.segments){const Oe=Te.detail.recordHistory!==!1,et=Te.detail.action||"update_segments";Ce(Te.detail.segments),Oe&&setTimeout(()=>{const Je=JSON.parse(JSON.stringify(Te.detail.segments)),Ie={trimStart:je,trimEnd:Be,splitPoints:[...I],clipSegments:Je,action:et},We=st;Et(ft=>Weft+1)},20)}},ue=async Te=>{const Oe=Te;if(Oe.detail&&typeof Oe.detail.time=="number"&&typeof Oe.detail.segmentId=="number"){const et=Oe.detail.time,Je=Oe.detail.segmentId;G(et);const Ie=rt.find(mn=>mn.id===Je);if(!Ie||et<=Ie.startTime||et>=Ie.endTime)return;const We=[...rt],ft=We.findIndex(mn=>mn.id===Je);if(ft===-1)return;We.splice(ft,1);const pn={id:Date.now(),name:`${Ie.name}-A`,startTime:Ie.startTime,endTime:et,thumbnail:""},Ln={id:Date.now()+1,name:`${Ie.name}-B`,startTime:et,endTime:Ie.endTime,thumbnail:""};We.push(pn,Ln),We.sort((mn,K)=>mn.startTime-K.startTime),Ce(We),he("split_segment")}},De=async Te=>{const Oe=Te;if(Oe.detail&&typeof Oe.detail.segmentId=="number"){const et=Oe.detail.segmentId,Je=rt.filter(Ie=>Ie.id!==et);if(Je.length!==rt.length){if(Je.length===0&&R.current){const Ie={id:Date.now(),name:"segment",startTime:0,endTime:R.current.duration,thumbnail:""};te(0),Qe(R.current.duration),xt([]),Ce([Ie])}else Ce(Je);he("delete_segment")}}};return document.addEventListener("update-segments",z),document.addEventListener("split-segment",ue),document.addEventListener("delete-segment",De),()=>{document.removeEventListener("update-segments",z),document.removeEventListener("split-segment",ue),document.removeEventListener("delete-segment",De)}},[rt,we]);const mt=z=>{te(z),he("adjust_trim_start")},At=z=>{Qe(z),he("adjust_trim_end")},ct=async()=>{if(R.current&&!I.includes(be)){const z=[...I,be].sort((Te,Oe)=>Te-Oe);xt(z);const ue=[];let De=0;for(let Te=0;Te<=z.length;Te++){const Oe=Te{if(te(0),Qe(we),xt([]),!R.current)return;const z={id:Date.now(),name:"segment",startTime:0,endTime:we,thumbnail:""};Ce([z]),he("reset_all")},jt=()=>{if(st>0){const z=zt[st-1];me.debug(`** UNDO ** to position ${st-1}, action: ${z.action}, segments: ${z.clipSegments.length}`),me.debug("Segment details after undo:",z.clipSegments.map(ue=>`ID: ${ue.id}, Time: ${P(ue.startTime)} - ${P(ue.endTime)}`)),te(z.trimStart),Qe(z.trimEnd),xt([...z.splitPoints]),Ce(JSON.parse(JSON.stringify(z.clipSegments))),Ot(st-1)}},Ye=()=>{if(st`ID: ${ue.id}, Time: ${P(ue.startTime)} - ${P(ue.endTime)}`)),te(z.trimStart),Qe(z.trimEnd),xt([...z.splitPoints]),Ce(JSON.parse(JSON.stringify(z.clipSegments))),Ot(st+1)}},ze=z=>{Le(z)},Ve=()=>{const z=R.current;z&&(z.muted=!z.muted,re(!ge))},vn=(z,ue)=>{Ce(De=>De.map(Te=>Te.id===z?{...Te,...ue}:Te)),X(!0)},Ze=async z=>{var ue;try{const De=(ue=window.MEDIA_DATA)==null?void 0:ue.mediaId;if(!De){console.error("No media ID found");return}const Oe={chapters:z.map(ft=>({startTime:ft.from,endTime:ft.to,text:ft.name}))};console.log("Saving chapters:",Oe);const et=Gt(),Je={"Content-Type":"application/json"};et&&(Je["X-CSRFToken"]=et);const Ie=await fetch(`/api/v1/media/${De}/chapters`,{method:"POST",headers:Je,body:JSON.stringify(Oe)});if(!Ie.ok)throw new Error(`Failed to save chapters: ${Ie.status}`);const We=await Ie.json();console.log("Chapters saved successfully:",We),X(!1)}catch(De){console.error("Error saving chapters:",De)}},Gt=()=>{var Te;const De=`; ${document.cookie}`.split("; csrftoken=");return De.length===2&&((Te=De.pop())==null?void 0:Te.split(";").shift())||""},St=z=>{Z(z)},it=z=>{(!an||on)&&G(z)},an=typeof window<"u"&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),[on,ln]=Q.useState(!1);return Q.useEffect(()=>{if(!tt||!R.current)return;const z=R.current,ue=[...rt].sort((Te,Oe)=>Te.startTime-Oe.startTime),De=()=>{const Te=ue[Se];if(!Te)return;const Oe=z.currentTime;if(Oe=Te.endTime-.01)if(Se{console.error("Error continuing segment playback:",Je)})}else z.pause(),oe(!1),q(0),z.removeEventListener("timeupdate",De)};return z.addEventListener("timeupdate",De),z.paused&&ue.length>0&&(z.currentTime=ue[0].startTime,z.play().catch(console.error)),()=>{z.removeEventListener("timeupdate",De)}},[tt,Se,rt]),Q.useEffect(()=>{const z=ue=>{const{segmentIndex:De}=ue.detail;tt&&De!==Se&&q(De)};return document.addEventListener("update-segment-index",z),()=>{document.removeEventListener("update-segment-index",z)}},[tt,Se]),{videoRef:R,currentTime:be,duration:we,isPlaying:f,setIsPlaying:W,isMuted:ge,isPlayingSegments:tt,thumbnails:Tt,trimStart:je,trimEnd:Be,splitPoints:I,zoomLevel:ot,clipSegments:rt,selectedSegmentId:U,hasUnsavedChanges:ke,historyPosition:st,history:zt,handleTrimStartChange:mt,handleTrimEndChange:At,handleZoomChange:ze,handleMobileSafeSeek:it,handleSplit:ct,handleReset:en,handleUndo:jt,handleRedo:Ye,handlePlaySegments:()=>{const z=R.current;if(!(!z||rt.length===0))if(tt)z.pause(),oe(!1),q(0);else{oe(!0),q(0);const ue=[...rt].sort((De,Te)=>De.startTime-Te.startTime);z.currentTime=ue[0].startTime,z.play().catch(De=>{console.error("Error starting segments playback:",De),oe(!1)})}},toggleMute:Ve,handleSegmentUpdate:vn,handleChapterSave:Ze,handleSelectedSegmentChange:St,isMobile:an,videoInitialized:on,setVideoInitialized:ln}},tS=()=>{const{videoRef:M,currentTime:R,duration:be,isPlaying:Re,setIsPlaying:we,isMuted:ve,thumbnails:f,trimStart:W,trimEnd:ge,splitPoints:re,zoomLevel:Tt,clipSegments:ce,selectedSegmentId:je,hasUnsavedChanges:te,historyPosition:Be,history:Qe,handleTrimStartChange:I,handleTrimEndChange:xt,handleZoomChange:ot,handleMobileSafeSeek:Le,handleSplit:rt,handleReset:Ce,handleUndo:U,handleRedo:Z,toggleMute:zt,handleSegmentUpdate:Et,handleChapterSave:st,handleSelectedSegmentChange:Ot,isMobile:ke,videoInitialized:X,setVideoInitialized:tt,isPlayingSegments:oe,handlePlaySegments:Se}=eS(),q=()=>{if(!M.current)return;const G=M.current;if(Re){G.pause(),we(!1);return}const he=Number(G.currentTime.toFixed(6));let mt=be,At=null,ct=null;const en=[...ce].sort((Ye,ze)=>Ye.startTime-ze.startTime);At=en.find(Ye=>{const ze=Number(Ye.startTime.toFixed(6)),Ve=Number(Ye.endTime.toFixed(6));return he>ze&&heNumber(Ye.startTime.toFixed(6))>he)),At?mt=Number(At.endTime.toFixed(6)):ct&&(mt=Number(ct.startTime.toFixed(6)));const jt=()=>{if(!G)return;const Ye=Number(G.currentTime.toFixed(6));if(Number((mt-Ye).toFixed(6))<=0||Ye>=mt){G.pause();const Ve=()=>{if(!G)return;G.currentTime=mt,Le(mt);const vn=Number(G.currentTime.toFixed(6)),Ze=Number(Math.abs(vn-mt).toFixed(6));me.debug("Position verification:",{target:P(mt),actual:P(vn),difference:Ze}),Ze>0&&(G.currentTime=mt,Le(mt))};Ve(),setTimeout(Ve,5),setTimeout(Ve,10),setTimeout(Ve,20),setTimeout(Ve,50),G.removeEventListener("timeupdate",jt),we(!1),me.debug("Stopped at position:",{target:P(mt),actual:P(G.currentTime),type:At?"segment end":ct?"next segment start":"end of video",segment:At?{id:At.id,start:P(At.startTime),end:P(At.endTime)}:null,nextSegment:ct?{id:ct.id,start:P(ct.startTime),end:P(ct.endTime)}:null});return}};G.addEventListener("timeupdate",jt),G.play().then(()=>{we(!0),tt(!0),me.debug("Playback started:",{from:P(he),to:P(mt),currentSegment:At?{id:At.id,start:P(At.startTime),end:P(At.endTime)}:"None",nextSegment:ct?{id:ct.id,start:P(ct.startTime),end:P(ct.endTime)}:"None"})}).catch(Ye=>{console.error("Error playing video:",Ye)})};return p.jsxs("div",{className:"bg-background min-h-screen",children:[p.jsx(Z0,{videoRef:M,onPlay:q}),p.jsxs("div",{className:"container mx-auto px-4 py-6 max-w-6xl",children:[p.jsx(P0,{videoRef:M,currentTime:R,duration:be,isPlaying:Re,isMuted:ve,onPlayPause:q,onSeek:Le,onToggleMute:zt}),p.jsx(K0,{onSplit:rt,onReset:Ce,onUndo:U,onRedo:Z,onPlaySegments:Se,onPlay:q,isPlaying:Re,isPlayingSegments:oe,canUndo:Be>0,canRedo:Be{const M=document.getElementById("chapters-editor-root");M&&Sm(M).render(p.jsx(tS,{}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Dm):Dm()})(); +You might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq`:""),"font-weight:bold")}pa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fm,pa.createPortal=l_,pa.createRoot=s_,pa.findDOMNode=n_,pa.flushSync=f_,pa.hydrate=a_,pa.hydrateRoot=c_,pa.render=r_,pa.unmountComponentAtNode=o_,pa.unstable_batchedUpdates=Bp,pa.unstable_renderSubtreeIntoContainer=u_,pa.version=rm,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}(),pa}hm.exports=V0();var B0=hm.exports,Sm,Tm=B0;{var Em=Tm.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Sm=function(M,R){Em.usingClientEntryPoint=!0;try{return Tm.createRoot(M,R)}finally{Em.usingClientEntryPoint=!1}}}const P=M=>{if(isNaN(M))return"00:00:00.000";const R=Math.floor(M/3600),be=Math.floor(M%3600/60),Re=Math.floor(M%60),we=Math.round(M%1*1e3),ve=String(R).padStart(2,"0"),f=String(be).padStart(2,"0"),W=String(Re).padStart(2,"0"),ge=String(we).padStart(3,"0");return`${ve}:${f}:${W}.${ge}`},ki=M=>P(M),$0=M=>P(M),me={debug:(...M)=>{},error:(...M)=>console.error(...M),warn:(...M)=>console.warn(...M),info:(...M)=>console.info(...M)};var Q=Zc();const P0=({videoRef:M,currentTime:R,duration:be,isPlaying:Re,isMuted:we=!1,onPlayPause:ve,onSeek:f,onToggleMute:W})=>{var oe;const ge=Q.useRef(null),[re,Tt]=Q.useState(!1),[ce,je]=Q.useState(!1),[te,Be]=Q.useState(null),[Qe,I]=Q.useState(!1),xt=Q.useRef(!1),[ot,Le]=Q.useState({x:0}),[rt,Ce]=Q.useState(0),U=typeof window<"u"&&((oe=window.MEDIA_DATA)==null?void 0:oe.videoUrl)||"/videos/sample-video.mp4";Q.useEffect(()=>{if(Tt((()=>{const q=navigator.userAgent||navigator.vendor||window.opera;return/iPad|iPhone|iPod/.test(q)&&!window.MSStream})()),typeof window<"u"){const q=localStorage.getItem("video_initialized")==="true";je(q)}},[]),Q.useEffect(()=>{Re&&!ce&&(je(!0),typeof window<"u"&&localStorage.setItem("video_initialized","true"))},[Re,ce]),Q.useEffect(()=>{const Se=M.current;if(!Se)return;Se.setAttribute("playsinline","true"),Se.setAttribute("webkit-playsinline","true"),Se.setAttribute("x-webkit-airplay","allow");const q=()=>{xt.current||(Be(Se.currentTime),typeof window<"u"&&(window.lastSeekedPosition=Se.currentTime))},G=()=>{re&&(je(!0),localStorage.setItem("video_initialized","true"))},he=()=>{};return Se.addEventListener("timeupdate",q),Se.addEventListener("play",G),Se.addEventListener("pause",he),()=>{Se.removeEventListener("timeupdate",q),Se.removeEventListener("play",G),Se.removeEventListener("pause",he)}},[M,re,xt]),Q.useEffect(()=>{Be(R)},[R]);const Z=be>0?R/be*100:0,zt=Se=>{Se.preventDefault(),I(!0),xt.current=!0,Et(Se);const q=he=>{xt.current&&Et(he)},G=()=>{I(!1),xt.current=!1,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",G)};document.addEventListener("mousemove",q),document.addEventListener("mouseup",G)},Et=Se=>{if(!ge.current)return;const q=ge.current.getBoundingClientRect(),G=Math.max(0,Math.min(1,(Se.clientX-q.left)/q.width)),he=be*G;Le({x:Se.clientX}),Ce(he),Be(he),typeof window<"u"&&(window.lastSeekedPosition=he),f(he)},st=Se=>{if(!ge.current||!Se.touches[0])return;Se.preventDefault(),I(!0),xt.current=!0,Ot(Se);const q=he=>{xt.current&&Ot(he)},G=()=>{I(!1),xt.current=!1,document.removeEventListener("touchmove",q),document.removeEventListener("touchend",G),document.removeEventListener("touchcancel",G)};document.addEventListener("touchmove",q,{passive:!1}),document.addEventListener("touchend",G),document.addEventListener("touchcancel",G)},Ot=Se=>{if(!ge.current)return;const q="touches"in Se?Se.touches[0]:null;if(!q)return;Se.preventDefault();const G=ge.current.getBoundingClientRect(),he=Math.max(0,Math.min(1,(q.clientX-G.left)/G.width)),mt=be*he;Le({x:q.clientX}),Ce(mt),Be(mt),typeof window<"u"&&(window.lastSeekedPosition=mt),f(mt)},ke=Se=>{if(!Qe&&ge.current){const q=ge.current.getBoundingClientRect(),G=(Se.clientX-q.left)/q.width,he=be*G;Be(he),typeof window<"u"&&(window.lastSeekedPosition=he),f(he)}},X=()=>{M.current&&(document.fullscreenElement?document.exitFullscreen():M.current.requestFullscreen())},tt=()=>{const Se=M.current;Se&&(Se.paused?re&&te!==null&&te>0?(Se.currentTime=te,setTimeout(()=>{M.current&&M.current.play().then(()=>{var q;me.debug("iOS: Play started successfully at position:",(q=M.current)==null?void 0:q.currentTime),ve()}).catch(q=>{console.error("iOS: Error playing video:",q)})},50)):Se.play().then(()=>{ve()}).catch(q=>{console.error("Error playing video:",q)}):(Se.pause(),ve()))};return p.jsxs("div",{className:"video-player-container",children:[p.jsxs("video",{ref:M,preload:"auto",crossOrigin:"anonymous",onClick:tt,playsInline:!0,"webkit-playsinline":"true","x-webkit-airplay":"allow",controls:!1,muted:we,children:[p.jsx("source",{src:U,type:"video/mp4"}),p.jsx("p",{children:"Your browser doesn't support HTML5 video."})]}),re&&!ce&&!Re&&p.jsx("div",{className:"ios-first-play-indicator",children:p.jsx("div",{className:"ios-play-message",children:"Tap Play to initialize video controls"})}),p.jsx("div",{className:`play-pause-indicator ${Re?"pause-icon":"play-icon"}`}),p.jsxs("div",{className:"video-controls",children:[p.jsxs("div",{className:"video-time-display",children:[p.jsx("span",{className:"video-current-time",children:ki(R)}),p.jsxs("span",{className:"video-duration",children:["/ ",ki(be)]})]}),p.jsxs("div",{ref:ge,className:`video-progress ${Qe?"dragging":""}`,onClick:ke,onMouseDown:zt,onTouchStart:st,children:[p.jsx("div",{className:"video-progress-fill",style:{width:`${Z}%`}}),p.jsx("div",{className:"video-scrubber",style:{left:`${Z}%`}}),Qe&&p.jsx("div",{className:"video-time-tooltip",style:{left:`${ot.x}px`,transform:"translateX(-50%)"},children:P(rt)})]}),p.jsxs("div",{className:"video-controls-buttons",children:[W&&p.jsx("button",{className:"mute-button","aria-label":we?"Unmute":"Mute",onClick:W,"data-tooltip":we?"Unmute":"Mute",children:we?p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"}),p.jsx("path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12M15 9.34V4a3 3 0 0 0-5.94-.6"}),p.jsx("path",{d:"M17 16.95A7 7 0 0 1 5 12v-2m14 0v2a7 7 0 0 1-.11 1.23"}),p.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),p.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]}):p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),p.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"})]})}),p.jsx("button",{className:"fullscreen-button","aria-label":"Fullscreen",onClick:X,"data-tooltip":"Toggle fullscreen",children:p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:p.jsx("path",{fillRule:"evenodd",d:"M3 4a1 1 0 011-1h4a1 1 0 010 2H6.414l2.293 2.293a1 1 0 01-1.414 1.414L5 6.414V8a1 1 0 01-2 0V4zm9 1a1 1 0 010-2h4a1 1 0 011 1v4a1 1 0 01-2 0V6.414l-2.293 2.293a1 1 0 11-1.414-1.414L13.586 5H12zm-9 7a1 1 0 012 0v1.586l2.293-2.293a1 1 0 011.414 1.414L6.414 15H8a1 1 0 010 2H4a1 1 0 01-1-1v-4zm13-1a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 010-2h1.586l-2.293-2.293a1 1 0 011.414-1.414L15 13.586V12a1 1 0 011-1z",clipRule:"evenodd"})})})]})]})]})},nf=(M,R)=>{const be=Math.min(Math.max(M/(R||1),0),1),Re=210,we=40+Math.floor(be*20),ve=85+Math.floor(be*8);return`hsl(${Re}, ${we}%, ${ve}%)`},af=async(M,R)=>new Promise(be=>{const Re=document.createElement("canvas");Re.width=10,Re.height=10;const we=Re.getContext("2d");if(we){const f=nf(R,M.duration);we.fillStyle=f,we.fillRect(0,0,Re.width,Re.height)}const ve=Re.toDataURL("image/png",.5);be(ve)}),qu=({isOpen:M,onClose:R,title:be,children:Re,actions:we})=>{if(Q.useEffect(()=>{const f=W=>{W.key==="Escape"&&M&&R()};return document.addEventListener("keydown",f),M&&(document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",f),document.body.style.overflow=""}},[M,R]),!M)return null;const ve=f=>{f.target===f.currentTarget&&R()};return p.jsx("div",{className:"modal-overlay",onClick:ve,children:p.jsxs("div",{className:"modal-container",onClick:f=>f.stopPropagation(),children:[p.jsxs("div",{className:"modal-header",children:[p.jsx("h2",{className:"modal-title",children:be}),p.jsx("button",{className:"modal-close-button",onClick:R,"aria-label":"Close modal",children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p.jsx("div",{className:"modal-content",children:Re}),we&&p.jsx("div",{className:"modal-actions",children:we})]})})},Y0=async(M,R)=>{try{const be=await fetch(`/api/v1/media/${M}/chapters`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(me.debug("response",be),!be.ok){if(be.status===404)return{success:!0,timestamp:new Date().toISOString()};try{const we=await be.json();return{success:!1,timestamp:new Date().toISOString(),error:we.error||"Auto-save failed"}}catch{return{success:!1,timestamp:new Date().toISOString(),error:"Auto-save failed"}}}const Re=await be.json();return Re.status==="success"?{success:!0,timestamp:Re.updated_at||new Date().toISOString(),...Re}:{success:!1,timestamp:new Date().toISOString(),error:Re.error||"Auto-save failed"}}catch{return{success:!0,timestamp:new Date().toISOString()}}},Cm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%23333333;}%20.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%20%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cpath%20class='st0'%20d='M350.45,277.5l-164.08,94.73c-16.55,9.56-37.24-2.39-37.24-21.5V161.27c0-19.11,20.69-31.06,37.24-21.5%20l164.08,94.73C367,244.06,367,267.94,350.45,277.5z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",xm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M208.15,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C218.47,375.57,213.85,380.19,208.15,380.19z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M395.04,380.19h-91.19c-5.7,0-10.32-4.62-10.32-10.32V142.13c0-5.7,4.62-10.32,10.32-10.32h91.19%20c5.7,0,10.32,4.62,10.32,10.32v227.74C405.36,375.57,400.74,380.19,395.04,380.19z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Rm="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20style='enable-background:new%200%200%20512%20512;'%20version='1.1'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cstyle%20type='text/css'%3e.st0{fill:%23333333;}.st1{fill:none;stroke:%23333333;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;}%3c/style%3e%3cg%20id='Layer_1'/%3e%3cg%20id='Layer_2'%3e%3cg%3e%3cg%3e%3cpath%20class='st0'%20d='M85.26,277.5l164.08,94.73c16.55,9.56,37.24-2.39,37.24-21.5V161.27c0-19.11-20.69-31.06-37.24-21.5%20L85.26,234.5C68.71,244.06,68.71,267.94,85.26,277.5z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st0'%20d='M377.47,375.59h41.42c11.19,0,20.26-9.07,20.26-20.26V156.67c0-11.19-9.07-20.26-20.26-20.26h-41.42%20c-11.19,0-20.26,9.07-20.26,20.26v198.67C357.21,366.52,366.28,375.59,377.47,375.59z'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",I0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",W0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(28,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",q0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M5,3V29a1,1,0,0,0,1,1H26a1,1,0,0,0,1-1V25H25v3H7V4H25V7h2V3a1,1,0,0,0-1-1H6A1,1,0,0,0,5,3Z'/%3e%3cg%20transform='translate(30,%200)%20scale(-1,%201)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",G0="data:image/svg+xml,%3c?xml%20version='1.0'%20?%3e%3csvg%20height='32'%20viewBox='0%200%2032%2032'%20width='32'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle/%3e%3cg%20data-name='1'%20id='_1'%3e%3cpath%20d='M27,3V29a1,1,0,0,1-1,1H6a1,1,0,0,1-1-1V27H7v1H25V4H7V7H5V3A1,1,0,0,1,6,2H26A1,1,0,0,1,27,3Z'/%3e%3cg%20transform='translate(2,%200)'%3e%3cpath%20d='M10.71,20.29,7.41,17H18V15H7.41l3.3-3.29L9.29,10.29l-5,5a1,1,0,0,0,0,1.42l5,5Z'%20id='logout_account_exit_door'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",X0={color:"#007bff",textDecoration:"none",fontWeight:"bold","&:hover":{textDecoration:"underline",color:"#0056b3"}},wm=M=>{let ve,f;if(M<=25)if(M<=0)ve="0%",f="none";else{const ge=-50*((M-0)/25);ve=`${M}%`,f=`translateX(${ge}%)`}else if(M>=75)if(M>=100)ve="100%",f="translateX(-100%)";else{const ge=-50-50*((M-75)/25);ve=`${M}%`,f=`translateX(${ge}%)`}else ve=`${M}%`,f="translateX(-50%)";return{left:ve,transform:f}},Q0=({currentTime:M,duration:R,thumbnails:be,trimStart:Re,trimEnd:we,splitPoints:ve,zoomLevel:f,clipSegments:W,selectedSegmentId:ge,onSelectedSegmentChange:re,onSegmentUpdate:Tt,onChapterSave:ce,onTrimStartChange:je,onTrimEndChange:te,onZoomChange:Be,onSeek:Qe,videoRef:I,hasUnsavedChanges:xt=!1,isIOSUninitialized:ot=!1,isPlaying:Le,setIsPlaying:rt,onPlayPause:Ce,isPlayingSegments:U=!1})=>{const Z=Q.useRef(null),zt=Q.useRef(null),Et=Q.useRef(null),[st,Ot]=Q.useState(null),ke=ge!==void 0?ge:st,X=v=>{re?re(v):Ot(v)},[tt,oe]=Q.useState(!1),[Se,q]=Q.useState({x:0,y:0}),[G,he]=Q.useState(0),[mt,At]=Q.useState(!1),[ct,en]=Q.useState(30),[jt,Ye]=Q.useState(!1),[ze,Ve]=Q.useState(null),[vn,Ze]=Q.useState(0),[Gt,St]=Q.useState(!1),it=Q.useRef(null),[an,on]=Q.useState(""),[ln,cn]=Q.useState(!1),ue=[...W].sort((v,w)=>v.startTime-w.startTime).find(v=>v.id===ke),[De,Te]=Q.useState(""),[Oe,et]=Q.useState(!1),Je=Q.useRef(null),Ie=Q.useRef(W);Q.useEffect(()=>{Ie.current=W},[W]);const We=Q.useCallback(async()=>{var v;try{et(!0);const w=Ie.current.map(L=>({startTime:P(L.startTime),endTime:P(L.endTime),name:L.name,chapterTitle:L.chapterTitle,text:L.chapterTitle}));me.debug("segments",w);const b=typeof window<"u"&&((v=window.MEDIA_DATA)==null?void 0:v.mediaId)||null||"1234";if(me.debug("mediaId",b),!b||w.length===0){me.debug("No mediaId or segments, skipping auto-save"),et(!1);return}me.debug("Auto-saving segments:",{mediaId:b,segments:w});const S=await Y0(b,{segments:w});if(S.success){me.debug("Auto-save successful");const T=new Date(S.timestamp).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Te(T),me.debug("Auto-save successful:",T)}else me.error("Auto-save failed:",S.error)}catch(w){me.error("Auto-save error:",w)}finally{et(!1)}},[]),ft=Q.useCallback(()=>{Je.current&&clearTimeout(Je.current);const v=setTimeout(()=>{We()},1e3);Je.current=v},[We]);Q.useEffect(()=>{on(ue&&ue.chapterTitle||"")},[ke,ue]);const pn=v=>{on(v),cn(!0),ke&&Tt&&Tt(ke,{chapterTitle:v})},Ln=v=>{const w=v;let E=null,b=null,S=G;const L=()=>{const T=w<0?Math.max(0,S+w):Math.min(R,S+w);S=T;const V=jt;if(Qe(T),he(T),Ze(T),Z.current){const j=Z.current.getBoundingClientRect(),F=T/R*100,ut=j.left+j.width*(F/100);q({x:ut,y:j.top-10});const ee=W.find(dt=>T>=dt.startTime&&T<=dt.endTime);if(ee)X(ee.id),oe(!1);else{X(null);const dt=fn(T);en(dt),oe(!0)}}V&&I.current&&(I.current.play(),Ye(!0))};return{onMouseDown:T=>{T.stopPropagation(),T.preventDefault(),S=G,L(),E=setTimeout(()=>{b=setInterval(L,200)},750);const V=()=>{E&&(clearTimeout(E),E=null),b&&(clearInterval(b),b=null),document.removeEventListener("mouseup",V),document.removeEventListener("mouseleave",V)};document.addEventListener("mouseup",V),document.addEventListener("mouseleave",V)},onTouchStart:T=>{T.stopPropagation(),T.preventDefault(),S=G,L(),E=setTimeout(()=>{b=setInterval(L,200)},750);const V=()=>{E&&(clearTimeout(E),E=null),b&&(clearInterval(b),b=null),document.removeEventListener("touchend",V),document.removeEventListener("touchcancel",V)};document.addEventListener("touchend",V),document.addEventListener("touchcancel",V)},onClick:T=>{T.stopPropagation()}}},[mn,K]=Q.useState(!1),[ye,Ae]=Q.useState(!1),[nt,Ut]=Q.useState(!1),[Wt,Ht]=Q.useState(!1),[zn,Xt]=Q.useState(""),[It,Ft]=Q.useState(""),[Fn,xa]=Q.useState(""),[ma,lr]=Q.useState("chapters"),Na=R>0?M/R*100:0,Jr=R>0?Re/R*100:0,Er=R>0?we/R*100:0,Zr=async()=>{var v;K(!1),Ae(!0),lr("chapters");try{const w=W.filter(E=>E.chapterTitle&&E.chapterTitle.trim()).map(E=>({name:E.chapterTitle||`Chapter ${E.id}`,from:P(E.startTime),to:P(E.endTime)}));if(w.length===0){Ft("No chapters with titles found"),Ht(!0),Ae(!1);return}if(ce){await ce(w),Ae(!1),Xt("Chapters saved successfully!");const E=typeof window<"u"&&((v=window.MEDIA_DATA)==null?void 0:v.mediaId)||null;E&&xa(`/view?m=${E}`),Ut(!0)}else Ft("Chapter save function not available"),Ht(!0),Ae(!1)}catch(w){me.error("Error saving chapters:",w),Ae(!1);const E=w instanceof Error?w.message:"An error occurred while saving chapters";Ft(E),Ht(!0)}};Q.useEffect(()=>{if(it.current&&Z.current&&f>1){const v=it.current.clientWidth,w=Z.current.clientWidth,E=M/R*w,b=Math.max(0,E-v/2);it.current.scrollTo({left:b,behavior:"smooth"});const S=Z.current.getBoundingClientRect();it.current.getBoundingClientRect();const T=S.left-it.current.scrollLeft+Na/100*S.width;(ke!==null||tt)&&(q({x:T,y:S.top-10}),he(M))}},[M,f,R,ke,tt,Na]),Q.useEffect(()=>{const v=I.current;if(!v||!ze||!jt||U)return;me.debug("Segment boundary check ACTIVATED for segment:",ze.id,"Start:",P(ze.startTime),"End:",P(ze.endTime));const w=()=>{const E=ze.endTime-v.currentTime;if(Math.round(E*10)%10===0&&me.debug("Segment playback - time remaining:",P(E),"Current:",P(v.currentTime),"End:",P(ze.endTime),"ContinuePastBoundary:",Gt),v.currentTime>ze.endTime){v.pause(),v.currentTime=ze.endTime,Ye(!1),St(!1),me.debug("Passed segment end - setting back to exact boundary:",P(ze.endTime));return}if(ze.endTime-v.currentTime<.05)if(Gt)me.debug("Continuing past segment boundary:",P(ze.endTime)),v.currentTime>ze.endTime&&(St(!1),Ve(null),sessionStorage.removeItem("continuingPastSegment"));else{v.pause(),v.currentTime=ze.endTime,Ye(!1),me.debug("Paused at segment end boundary:",P(ze.endTime));const S=[...W].sort((L,T)=>L.startTime-T.startTime).find(L=>L.startTime>ze.endTime);S&&Math.abs(S.startTime-ze.endTime)<.1&&(me.debug("Found adjacent next segment:",S.id),X(S.id),Ve(S),Ze(S.startTime),he(S.startTime),v.currentTime=S.startTime)}};return v.addEventListener("timeupdate",w),()=>{v.removeEventListener("timeupdate",w)}},[ze,jt,Gt,W]),Q.useEffect(()=>{if(I.current)if(I.current.paused)I.current.paused&&jt&&(Ze(M),he(M),Ye(!1),me.debug("Video paused at:",P(M)));else{Ze(M),he(M),ke!==null&&Ye(!0);const v=W.find(b=>M>=b.startTime&&M<=b.endTime),w=M/R*100;if(Z.current){const b=Z.current.offsetWidth,S=w/100*b;q({x:S,y:Z.current.getBoundingClientRect().top-10})}const E=sessionStorage.getItem("continuingPastSegment")==="true";if(v){const b=I.current,S=ze&&ze.id<0&&jt;if((ze==null?void 0:ze.id)!==v.id&&!S&&!E&&!Gt&&(me.debug(`Entered a new segment during playback: ${v.id}, setting as active`),Ve(v),X(v.id),oe(!1),St(!1),sessionStorage.removeItem("continuingPastSegment")),S&&b&&v){me.debug(`CUTAWAY BOUNDARY REACHED: Current position ${P(b.currentTime)} at segment ${v.id} - STOPPING at boundary ${P(v.startTime)}`),b.pause(),setTimeout(()=>{if(I.current){I.current.currentTime=v.startTime,Qe(v.startTime),Ze(v.startTime),he(v.startTime),St(!1),X(v.id),oe(!1);const T=()=>{I.current&&(I.current.currentTime=v.startTime,Qe(v.startTime),Ze(v.startTime),he(v.startTime),me.debug(`Position corrected to exact segment boundary: ${P(I.current.currentTime)} (target: ${P(v.startTime)})`))};setTimeout(T,10),setTimeout(T,20),setTimeout(T,50),setTimeout(T,100),setTimeout(T,200),I.current.addEventListener("seeked",T),I.current.addEventListener("canplay",T),I.current.addEventListener("waiting",T),setTimeout(()=>{I.current&&(I.current.removeEventListener("seeked",T),I.current.removeEventListener("canplay",T),I.current.removeEventListener("waiting",T))},300)}},10),Ye(!1),Ve(null);return}ze===null&&jt===!0||E||S?(ke!==v.id||tt)&&(me.debug("Tooltip updated for segment during continued playback:",v.id,S?"(cutaway playback - keeping virtual segment)":""),X(v.id),oe(!1),!S&&sessionStorage.getItem("lastSegmentId")!==v.id.toString()&&sessionStorage.removeItem("continuingPastSegment")):((ze==null?void 0:ze.id)!==v.id||tt)&&(me.debug("Playback moved into segment:",v.id),X(v.id),Ve(v),oe(!1),sessionStorage.setItem("lastSegmentId",v.id.toString()))}else if(ze!==null||!tt){X(null),Ve(null);const b=fn(M);en(b),b>=.5?oe(!0):oe(!1)}}},[M,jt,ze,ke,W]),Q.useEffect(()=>{const v=w=>{const E=w.target;mt&&!E.closest(".zoom-dropdown-container")&&At(!1)};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[mt]),Q.useEffect(()=>{const v=b=>{const{recordHistory:S,fromAutoSave:L}=b.detail;S&&!L&&ft()},w=()=>{ft()},E=b=>{const{recordHistory:S}=b.detail;S&&ft()};return document.addEventListener("update-segments",v),document.addEventListener("segment-drag-end",w),document.addEventListener("update-trim",E),document.addEventListener("delete-segment",ft),document.addEventListener("split-segment",ft),()=>{document.removeEventListener("update-segments",v),document.removeEventListener("segment-drag-end",w),document.removeEventListener("update-trim",E),document.removeEventListener("delete-segment",ft),document.removeEventListener("split-segment",ft),Je.current&&(me.debug("Clearing auto-save timer in cleanup:",Je.current),clearTimeout(Je.current))}},[ft]),Q.useEffect(()=>{W.length>0&&!De&&setTimeout(()=>{We()},500)},[De,We]),Q.useEffect(()=>{const v=()=>{var b;let E=typeof window<"u"&&((b=window.MEDIA_DATA)==null?void 0:b.chapters)||null;E||(E={segments:[{startTime:"00:00:00.000",endTime:"00:00:10.000",chapterTitle:"Chapter 1 (from saved data)"},{startTime:"00:00:12.000",endTime:"00:00:17.000",chapterTitle:"Chapter 2 (from saved data)"},{startTime:"00:00:20.000",endTime:"00:00:30.000",chapterTitle:"Chapter 3 (from saved data)"}],updated_at:"2025-06-24 14:59:14"});try{if(E&&E.segments&&E.segments.length>0){me.debug("Found saved segments:",E);const S=E.segments.map((T,V)=>({id:Date.now()+V,name:T.name||`Segment ${V+1}`,startTime:w(T.startTime),endTime:w(T.endTime),thumbnail:"",chapterTitle:T.chapterTitle||""})),L=new CustomEvent("update-segments",{detail:{segments:S,recordHistory:!1,fromAutoSave:!0}});if(document.dispatchEvent(L),E.updated_at){const V=new Date(E.updated_at).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).replace(",","");Te(V)}}else me.debug("No saved segments found")}catch(S){console.error("Error loading saved segments:",S)}},w=E=>{const b=E.split(":");if(b.length!==3)return 0;const S=parseInt(b[0])||0,L=parseInt(b[1])||0,T=b[2].split("."),V=parseInt(T[0])||0,j=parseInt(T[1])||0;return S*3600+L*60+V+j/1e3};setTimeout(v,100)},[]),Q.useEffect(()=>()=>{},[ke,tt,jt]),Q.useEffect(()=>{const v=zt.current,w=Et.current,E=Z.current;if(!v||!w||!E)return;const b=S=>L=>{L.preventDefault();const T=E.getBoundingClientRect();let V=!0,j=S?Re:we;const F=dt=>new CustomEvent("trim-handle-event",{detail:{type:dt,isStart:S}});document.dispatchEvent(F("drag-start"));const ut=dt=>{if(!V)return;const Rt=T.width,hn=Math.max(0,Math.min(1,(dt.clientX-T.left)/Rt))*R;typeof window<"u"&&(window.lastSeekedPosition=hn),S?hnRe&&(document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:hn,isStart:!1,recordHistory:!1}})),j=hn)},ee=()=>{V=!1,document.removeEventListener("mousemove",ut),document.removeEventListener("mouseup",ee),S?document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:j,isStart:!0,recordHistory:!0,action:"adjust_trim_start"}})):document.dispatchEvent(new CustomEvent("update-trim",{detail:{time:j,isStart:!1,recordHistory:!0,action:"adjust_trim_end"}})),document.dispatchEvent(F("drag-end"))};document.addEventListener("mousemove",ut),document.addEventListener("mouseup",ee)};return v.addEventListener("mousedown",b(!0)),w.addEventListener("mousedown",b(!1)),()=>{v.removeEventListener("mousedown",b(!0)),w.removeEventListener("mousedown",b(!1))}},[R,Re,we,je,te]);const ei=()=>{const v=be.length||10;return Array.from({length:v}).map((w,E)=>{const b=R/v,S=E*b,L=S+b,T=(S+L)/2,V=nf(T,R);return p.jsx("div",{className:"timeline-thumbnail",style:{width:`${100/v}%`,backgroundColor:V}},E)})},Ra=()=>ve.map((v,w)=>{const E=v/R*100;return p.jsx("div",{className:"split-point",style:{left:`${E}%`}},w)}),fn=v=>{const E=[...W].sort((T,V)=>T.startTime-V.startTime),b=E.find(T=>T.startTime>v),S=[...E].reverse().find(T=>T.endTime{if(!Z.current)return;const w=W.find(j=>{const F=v>=j.startTime&&v<=j.endTime,ut=Math.abs(v-j.startTime)<.001,ee=Math.abs(v-j.endTime)<.001;return F||ut||ee}),E=[...W].sort((j,F)=>j.startTime-F.startTime),b=E.find(j=>j.startTime>v),S=[...E].reverse().find(j=>j.endTime1&&it.current?V=L.left-it.current.scrollLeft+L.width*(T/100):V=L.left+L.width*(T/100),q({x:V,y:L.top-10})},ja=v=>{if(!Z.current||!it.current||ot)return;const w=I.current&&!I.current.paused;St(!1);const E=Z.current.getBoundingClientRect();let b;if(f>1){const T=it.current.scrollLeft,V=Z.current.clientWidth;b=(v.clientX-E.left+T)/V}else b=(v.clientX-E.left)/E.width;const S=b*R;me.debug("Timeline clicked at:",P(S),"distance from end:",P(R-S)),typeof window<"u"&&(window.lastSeekedPosition=S),Qe(S),he(S),Ze(S);const L=W.find(T=>{const V=S>=T.startTime&&S<=T.endTime,j=Math.abs(S-T.startTime)<.01,F=Math.abs(S-T.endTime)<.01;return V||j||F});if(L&&Ve(L),I.current)if(U&&w){if(L){const V=[...W].sort((j,F)=>j.startTime-F.startTime).findIndex(j=>j.id===L.id);if(V!==-1){const j=new CustomEvent("update-segment-index",{detail:{segmentIndex:V}});document.dispatchEvent(j),me.debug(`Segments playback mode: updating segment index to ${V} for timeline click in segment ${L.id}`)}}I.current.play().then(()=>{Ye(!0)}).catch(T=>{console.error("Error resuming segments playback:",T),Ye(!1)})}else w&&!U&&I.current.play().then(()=>{Ye(!0)}).catch(T=>{console.error("Error resuming playback:",T),Ye(!1)});if(v.target===Z.current||v.target.classList.contains("timeline-thumbnail"))if(L)X(L.id),oe(!1);else{X(null);const T=fn(S);en(T);let V;if(f>1){const ee=E.left-it.current.scrollLeft,dt=S/R;V=ee+dt*E.width}else V=v.clientX;q({x:V,y:E.top-10}),oe(!0);const j=[...W].sort((ee,dt)=>ee.startTime-dt.startTime),F=[...j].reverse().find(ee=>ee.endTimeee.startTime>S);me.debug("Clicked in cutaway area:",{position:P(S),availableSpace:P(T),prevSegmentEnd:F?P(F.endTime):"none",nextSegmentStart:ut?P(ut.startTime):"none"})}},Ua=(v,w)=>E=>{if(E.preventDefault(),E.stopPropagation(),!Z.current)return;Z.current.getBoundingClientRect().width;const S=W.find(On=>On.id===v);if(!S)return;const L=S.startTime,T=S.endTime,V={...S};document.body.style.cursor="ew-resize";const j=document.createElement("div");j.style.position="fixed",j.style.top="0",j.style.left="0",j.style.width="100vw",j.style.height="100vh",j.style.zIndex="1000",j.style.cursor="ew-resize",document.body.appendChild(j);let F=!0,ut=L,ee=T;document.dispatchEvent(new CustomEvent("segment-drag-start",{detail:{segmentId:v}}));const dt=On=>{if(!F||!Z.current)return;const wr=Z.current.getBoundingClientRect(),Yt=Math.max(0,Math.min(1,(On-wr.left)/wr.width))*R,ha=w?Yt:L,na=w?T:Yt;if(M>=ha&&M<=na)X(v),oe(!1);else{X(null);const yn=fn(M);en(yn),oe(!0)}const Wa=W.filter(yn=>yn.id!==v);let ya=L,aa=T;if(w){ya=Math.min(Yt,T-.5);const _t=Wa.filter(ra=>ra.endTime<=L).sort((ra,ni)=>ni.endTime-ra.endTime)[0];_t&&ya<_t.endTime&&(ya=_t.endTime),_t&&Math.abs(ya-_t.endTime)<.3&&(ya=_t.endTime),ut=ya}else{aa=Math.max(Yt,L+.5);const _t=Wa.filter(ra=>ra.startTime>=T).sort((ra,ni)=>ra.startTime-ni.startTime)[0];_t&&aa>_t.startTime&&(aa=_t.startTime),_t&&Math.abs(aa-_t.startTime)<.3&&(aa=_t.startTime),ee=aa}const Dr=W.map(yn=>yn.id===v?{...yn,startTime:ya,endTime:aa}:yn),Mi=new CustomEvent("update-segments",{detail:{segments:Dr,recordHistory:!1}});if(document.dispatchEvent(Mi),ke===v&&I.current){const yn=I.current.currentTime,_t=Dr.find(ur=>ur.id===v);if(_t){const ur=yn>=_t.startTime&&yn<=_t.endTime;me.debug(`During drag - playhead at ${P(yn)} is ${ur?"inside":"outside"} segment (${P(_t.startTime)} - ${P(_t.endTime)})`),!ur&&jt&&(I.current.pause(),Ye(!1),Ve(null)),yn<_t.startTime?(me.debug(`Adjusting display time to segment start: ${P(_t.startTime)}`),Ze(_t.startTime),he(_t.startTime)):yn>_t.endTime&&(me.debug(`Adjusting display time to segment end: ${P(_t.endTime)}`),Ze(_t.endTime),he(_t.endTime))}}},Rt=()=>{if(!F)return;F=!1,document.removeEventListener("mousemove",Ct),document.removeEventListener("mouseup",hn),document.removeEventListener("touchmove",Rr),document.removeEventListener("touchend",Ha),document.removeEventListener("touchcancel",Ha),document.body.style.cursor="",document.body.contains(j)&&document.body.removeChild(j);const On=W.map(Vn=>Vn.id===v?{...Vn,startTime:ut,endTime:ee}:Vn),wr=w?"adjust_segment_start":"adjust_segment_end";if(document.dispatchEvent(new CustomEvent("update-segments",{detail:{segments:On,recordHistory:!0,action:wr}})),ke===v&&I.current){const Vn=I.current.currentTime,Yt=On.find(ha=>ha.id===v);if(Yt){const ha=Vn>=Yt.startTime&&Vn<=Yt.endTime;me.debug(`Drag complete - playhead at ${P(Vn)} is ${ha?"inside":"outside"} segment (${P(Yt.startTime)} - ${P(Yt.endTime)})`);const na=Vn>=V.startTime&&Vn<=V.endTime;ha?(!na&&ha||na&&ha&&(Yt.startTime!==V.startTime||Yt.endTime!==V.endTime))&&Ve(Yt):(jt&&(I.current.pause(),Ye(!1),Ve(null),St(!1)),VnYt.endTime&&(me.debug(`Final adjustment - setting display time to segment end: ${P(Yt.endTime)}`),Ze(Yt.endTime),he(Yt.endTime)))}}},Ct=On=>{dt(On.clientX)},hn=()=>{Rt()},Rr=On=>{On.touches.length>0&&(On.preventDefault(),dt(On.touches[0].clientX))},Ha=()=>{Rt()};document.addEventListener("mousemove",Ct,{passive:!1}),document.addEventListener("mouseup",hn),document.addEventListener("touchmove",Rr,{passive:!1}),document.addEventListener("touchend",Ha),document.addEventListener("touchcancel",Ha)},Cr=v=>w=>{if(w.target.classList.contains("clip-segment-handle"))return;w.preventDefault(),w.stopPropagation(),St(!1);const E=I.current&&!I.current.paused;X(v);const b=W.find(ee=>ee.id===v);if(!b)return;const L=w.currentTarget.getBoundingClientRect(),T=(w.clientX-L.left)/L.width,V=b.startTime+T*(b.endTime-b.startTime),j=Math.max(b.startTime,Math.min(b.endTime,V));if(he(j),Ze(j),I.current){const ee=I.current.currentTime,dt=ee>=b.startTime&&ee<=b.endTime;me.debug(`Segment click - playhead at ${P(ee)} is ${dt?"inside":"outside"} segment (${P(b.startTime)} - ${P(b.endTime)})`),dt||(Math.abs(ee-b.startTime)Rt.startTime-Ct.startTime).findIndex(Rt=>Rt.id===v);if(dt!==-1){const Rt=new CustomEvent("update-segment-index",{detail:{segmentIndex:dt}});document.dispatchEvent(Rt)}I.current.play().then(()=>{Ye(!0)}).catch(Rt=>{console.error("Error continuing segments playback after segment click:",Rt)})}else E&&!U&&(Ve(b),St(!1),I.current.play().then(()=>{Ye(!0)}).catch(ee=>{console.error("Error resuming playback after segment click:",ee)}));const F=w.clientX,ut=L.top-10;if(q({x:F,y:ut}),f>1&&Z.current&&it.current){Z.current.getBoundingClientRect();const ee=Z.current.clientWidth,dt=it.current.clientWidth,Rt=j/R*ee,Ct=Math.max(0,Rt-dt/2);it.current.scrollTo({left:Ct,behavior:"smooth"}),setTimeout(()=>{if(Z.current&&it.current){const hn=Z.current.getBoundingClientRect(),Ha=j/R*ee-it.current.scrollLeft+hn.left;q({x:Ha,y:ut})}},300)}},xr=()=>W.map((v,w)=>{const E=v.startTime/R*100,b=(v.endTime-v.startTime)/R*100,S=nf((v.startTime+v.endTime)/2,R);return p.jsxs("div",{className:`clip-segment ${ke===v.id?"selected":""}`,style:{left:`${E}%`,width:`${b}%`,backgroundColor:S,borderWidth:"2px",borderStyle:"solid",borderColor:"rgba(0, 0, 0, 0.5)"},onClick:Cr(v.id),children:[p.jsxs("div",{className:"clip-segment-info",children:[p.jsxs("div",{className:"clip-segment-name",children:["Segment ",w+1]}),p.jsxs("div",{className:"clip-segment-time",children:[ki(v.startTime)," - ",ki(v.endTime)]}),p.jsxs("div",{className:"clip-segment-duration",children:["Duration: ",ki(v.endTime-v.startTime)]})]}),U?null:p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"clip-segment-handle left",title:"Resize segment start",onMouseDown:L=>{L.stopPropagation(),Ua(v.id,!0)(L)},onTouchStart:L=>{L.stopPropagation(),Ua(v.id,!0)(L)}}),p.jsx("div",{className:"clip-segment-handle right",title:"Resize segment end",onMouseDown:L=>{L.stopPropagation(),Ua(v.id,!1)(L)},onTouchStart:L=>{L.stopPropagation(),Ua(v.id,!1)(L)}})]})]},v.id)});Q.useEffect(()=>{const v=w=>{const{segmentId:E}=w.detail;if(W.filter(S=>S.id!==E).length===0){const S={id:Date.now(),name:"Full Video",startTime:0,endTime:R,thumbnail:""},L=new CustomEvent("update-segments",{detail:{segments:[S],recordHistory:!0,action:"create_full_video_segment"}});if(document.dispatchEvent(L),X(S.id),oe(!1),he(M),Ze(M),Ve(S),Z.current){const T=Z.current.getBoundingClientRect(),V=M/R*100,j=T.left+T.width*(V/100);q({x:j,y:T.top-10}),me.debug("Created full video segment:",{id:S.id,duration:P(R),currentPosition:P(M)})}}else if(ke===E){if(!W.find(T=>T.id===E))return;const L=fn(M);if(X(null),oe(!0),en(L),Z.current){const T=Z.current.getBoundingClientRect(),V=M/R*100,j=T.left+T.width*(V/100);q({x:j,y:T.top-10}),me.debug("Segment deleted, showing cutaway tooltip:",{position:P(M),availableSpace:P(L)})}}};return document.addEventListener("delete-segment",v),()=>{document.removeEventListener("delete-segment",v)}},[ke,W,M,R,Z]),Q.useEffect(()=>{const v=I.current;if(!v)return;const w=()=>{if(!I.current)return;const b=I.current,S=b.currentTime;St(!1);let L=R,T=null,V=null;T=W.find(F=>{const ut=S>=F.startTime&&S<=F.endTime,ee=Math.abs(S-F.startTime)<.001,dt=Math.abs(S-F.endTime)<.001;return ut||ee||dt}),V=W.filter(F=>{const ut=F.startTime>S,ee=Math.abs(F.startTime-S)>.001;return ut&&ee}).sort((F,ut)=>F.startTime-ut.startTime)[0],T?(L=T.endTime,Ve(T)):V&&(L=V.startTime);const j=()=>{if(!b)return;const F=b.currentTime;if(L-F<=.001||F>=L){b.pause();const ee=()=>{b&&(b.currentTime=L,Qe(L),Ze(L),he(L),me.debug("Position verification:",{target:P(L),actual:P(b.currentTime),difference:Math.abs(b.currentTime-L).toFixed(3)}))};ee(),setTimeout(ee,10),setTimeout(ee,20),setTimeout(ee,50),T?(X(T.id),oe(!1)):V?(X(V.id),oe(!1),Ve(V)):(X(null),oe(!0),Ve(null)),b.removeEventListener("timeupdate",j),rt(!1),Ye(!1),St(!1);return}};b.addEventListener("timeupdate",j),b.play().then(()=>{rt(!0),Ye(!0),me.debug("Playback started:",{from:P(S),to:P(L),currentSegment:T?`Segment ${T.id}`:"None",nextSegment:V?`Segment ${V.id}`:"None"})}).catch(F=>{console.error("Error playing video:",F)})},E=()=>{Ye(!1)};return v.addEventListener("play",w),v.addEventListener("pause",E),()=>{v.removeEventListener("play",w),v.removeEventListener("pause",E)}},[W,R,Qe]);const h=v=>{if(!Z.current)return;const w=Z.current.getBoundingClientRect(),b=(v.clientX-w.left)/w.width*R,S=Math.max(0,Math.min(R,b));typeof window<"u"&&(window.lastSeekedPosition=S)},[B,ne]=Q.useState(!1),fe=Q.useRef(!1),lt=v=>{if(ot)return;v.stopPropagation(),v.preventDefault(),ne(!0),fe.current=!0,En(M);const w=b=>{if(!Z.current||!it.current)return;const S=Z.current.getBoundingClientRect();let L;if(f>1){const V=it.current.scrollLeft,j=Z.current.clientWidth;L=(b.clientX-S.left+V)/j}else L=(b.clientX-S.left)/S.width;L=Math.max(0,Math.min(1,L));const T=L*R;he(T),Ze(T),En(T),typeof window<"u"&&(window.lastSeekedPosition=T),Qe(T)},E=()=>{ne(!1),fe.current=!1,document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",E)},qe=v=>{if(ot)return;v.stopPropagation(),v.preventDefault(),ne(!0),fe.current=!0,En(M);const w=b=>{if(!Z.current||!it.current||!b.touches[0])return;const S=Z.current.getBoundingClientRect();let L;if(f>1){const V=it.current.scrollLeft,j=Z.current.clientWidth;L=(b.touches[0].clientX-S.left+V)/j}else L=(b.touches[0].clientX-S.left)/S.width;L=Math.max(0,Math.min(1,L));const T=L*R;he(T),Ze(T),En(T),typeof window<"u"&&(window.lastSeekedPosition=T),Qe(T)},E=()=>{ne(!1),fe.current=!1,document.removeEventListener("touchmove",w),document.removeEventListener("touchend",E),document.removeEventListener("touchcancel",E)};document.addEventListener("touchmove",w,{passive:!1}),document.addEventListener("touchend",E),document.addEventListener("touchcancel",E)};return Q.useEffect(()=>{},[Fn,ma,nt]),Q.useEffect(()=>{let v,w;if(nt&&Fn){let E=10;v=setInterval(()=>{E--;const b=document.querySelector(".countdown");b&&(b.textContent=E.toString()),E<=0&&clearInterval(v)},1e3),w=setTimeout(()=>{window.location.href=Fn},1e4)}return()=>{v&&clearInterval(v),w&&clearTimeout(w)}},[nt,Fn]),Q.useEffect(()=>{!nt&&Fn&&(window.location.href=Fn)},[Fn,ma,nt]),p.jsxs("div",{className:`timeline-container-card ${U?"segments-playback-mode":""}`,children:[p.jsxs("div",{className:"timeline-header",children:[p.jsx("div",{className:"timeline-title",children:p.jsx("span",{className:"timeline-title-text",children:"Timeline"})}),p.jsxs("div",{className:"duration-time",children:["Total Segments:"," ",p.jsx("span",{children:P(W.reduce((v,w)=>v+(w.endTime-w.startTime),0))})]})]}),p.jsx("div",{ref:it,className:`timeline-scroll-container ${U?"segments-playback-mode":""}`,style:{overflow:f>1?"auto":"hidden"},children:p.jsxs("div",{ref:Z,className:"timeline-container",onClick:ja,onMouseMove:h,style:{width:`${f*100}%`,cursor:"pointer"},children:[p.jsxs("div",{className:"timeline-marker",style:{left:`${Na}%`},children:[p.jsx("div",{className:"timeline-marker-head",onClick:v=>{if(v.stopPropagation(),W.find(w=>M>=w.startTime&&M<=w.endTime),ke||tt){X(null),oe(!1);return}else En(M),me.debug("Opening tooltip at:",P(M))},children:p.jsx("span",{className:"timeline-marker-head-icon",children:ke||tt?"-":"+"})}),U?null:p.jsx("div",{className:`timeline-marker-drag ${B?"dragging":""}`,onMouseDown:lt,onTouchStart:qe,children:p.jsx("span",{className:"timeline-marker-drag-icon",children:"⋮"})})]}),W.length===0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"trim-line-marker",style:{left:`${Jr}%`},children:p.jsx("div",{ref:zt,className:"trim-handle left"})}),p.jsx("div",{className:"trim-line-marker",style:{left:`${Er}%`},children:p.jsx("div",{ref:Et,className:"trim-handle right"})})]}),xr(),Ra(),ei(),ke!==null&&p.jsxs("div",{className:`segment-tooltip two-row-tooltip ${U?"segments-playback-mode":""}`,style:{position:"absolute",...wm(Na)},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:[ke&&p.jsx("div",{className:"tooltip-chapter-editor",children:p.jsx("textarea",{className:"tooltip-chapter-input",placeholder:"Chapter Title",value:an,onChange:v=>pn(v.target.value),onBlur:We,onMouseLeave:We,rows:2,maxLength:200,onClick:v=>v.stopPropagation(),onMouseDown:v=>v.stopPropagation(),onMouseUp:v=>v.stopPropagation()})}),p.jsxs("div",{className:"tooltip-row",children:[p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Seek -50ms (click or hold)",disabled:U,...U?{}:Ln(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),p.jsx("div",{className:`tooltip-time-display ${U?"disabled":""}`,style:{pointerEvents:U?"none":"auto",cursor:U?"not-allowed":"default",opacity:U?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:P(vn)}),p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Seek +50ms (click or hold)",disabled:U,...U?{}:Ln(.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"+50ms"})]}),p.jsxs("div",{className:"tooltip-row tooltip-actions",children:[p.jsx("button",{className:`tooltip-action-btn delete ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Delete segment",disabled:U,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},onClick:v=>{v.stopPropagation();const w=new CustomEvent("delete-segment",{detail:{segmentId:ke}});document.dispatchEvent(w)},children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M3 6h18"}),p.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),p.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),p.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}),p.jsx("button",{className:`tooltip-action-btn scissors ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Split segment at current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation();const w=new CustomEvent("split-segment",{detail:{segmentId:ke,time:G}});document.dispatchEvent(w)},children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"6",cy:"6",r:"3"}),p.jsx("circle",{cx:"6",cy:"18",r:"3"}),p.jsx("line",{x1:"20",y1:"4",x2:"8.12",y2:"15.88"}),p.jsx("line",{x1:"14.47",y1:"14.48",x2:"20",y2:"20"}),p.jsx("line",{x1:"8.12",y1:"8.12",x2:"12",y2:"12"})]})}),p.jsx("button",{className:`tooltip-action-btn play-from-start ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Play segment from beginning",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation();const w=W.find(E=>E.id===ke);if(w&&I.current){if(St(!0),Math.abs(I.current.currentTime-w.endTime)<.05){me.debug(`Already at end boundary (${P(I.current.currentTime)}), nudging position back slightly`);const E=Math.max(w.startTime,w.endTime-.1);I.current.currentTime=E,Qe(E),he(E),me.debug(`Position adjusted to ${P(E)}`)}else Qe(w.startTime),he(w.startTime);Ve(w),I.current.play().then(()=>{Ye(!0)}).catch(E=>{console.error("Error playing from beginning:",E)})}},children:p.jsx("img",{src:Rm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn ${Le?"pause":"play"} ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":Le?"Pause playback":"Play from current position",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation(),Le?I.current&&(I.current.pause(),Ye(!1),St(!1)):Ce()},children:Le?p.jsx("img",{src:xm,alt:"Pause",style:{width:"24px",height:"24px"}}):p.jsx("img",{src:Cm,alt:"Play",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn set-in ${U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":"Set start point at current position",disabled:U,onClick:v=>{if(v.stopPropagation(),W.find(E=>E.id===ke)){const E=W.map(S=>S.id===ke?{...S,startTime:G{if(v.stopPropagation(),W.find(E=>E.id===ke)){const E=W.map(S=>S.id===ke?{...S,endTime:G>S.startTime+.5?G:S.startTime+.5}:S),b=new CustomEvent("update-segments",{detail:{segments:E,recordHistory:!0,action:"adjust_end_time"}});document.dispatchEvent(b)}},children:p.jsx("img",{src:I0,alt:"Set end point",style:{width:"24px",height:"24px"}})})]})]}),tt&&ke===null&&p.jsxs("div",{className:`empty-space-tooltip two-row-tooltip ${U?"segments-playback-mode":""}`,style:{position:"absolute",...wm(Na)},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:[p.jsxs("div",{className:"tooltip-row",children:[p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Seek -50ms (click or hold)",disabled:U,...U?{}:Ln(-.05),style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},children:"-50ms"}),p.jsx("div",{className:`tooltip-time-display ${U?"disabled":""}`,style:{pointerEvents:U?"none":"auto",cursor:U?"not-allowed":"default",opacity:U?.6:1,userSelect:"none",WebkitUserSelect:"none"},onClick:v=>{U&&(v.stopPropagation(),v.preventDefault())},children:P(G)}),p.jsx("button",{className:`tooltip-time-btn ${U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":"Seek +50ms (click or hold)",disabled:U,...U?{}:Ln(.05),children:"+50ms"})]}),p.jsxs("div",{className:"tooltip-row tooltip-actions",children:[p.jsxs("button",{className:`tooltip-action-btn new-segment ${ct<.5||U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":ct<.5?"Not enough space for new segment":"Create new segment",disabled:ct<.5||U,onClick:async v=>{if(v.stopPropagation(),ct<.5)return;const w=G,E=w+ct,b={id:Date.now(),name:"segment",startTime:w,endTime:E,thumbnail:""},S=[...W,b],L=new CustomEvent("update-segments",{detail:{segments:S,recordHistory:!0,action:"create_segment"}});document.dispatchEvent(L),oe(!1),setTimeout(()=>{const T=S[S.length-1];T&&(X(T.id),me.debug("Created and selected new segment:",T.id))},100)},children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),p.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),p.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),p.jsx("span",{className:"tooltip-btn-text",children:"New"})]}),p.jsx("button",{className:`tooltip-action-btn play-from-start ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Play from beginning of cutaway",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{if(v.stopPropagation(),I.current){const w=G;St(!0);const E=[...W].sort((F,ut)=>F.startTime-ut.startTime),b=[...E].reverse().find(F=>F.endTimeF.startTime>w),T=L?L.startTime:R,V={id:-999,name:"Cutaway",startTime:S,endTime:T,thumbnail:""};Qe(S),he(S),Ye(!1),setTimeout(()=>{Ve(V)},0);const j=()=>{if(!I.current)return;const F=I.current.currentTime,ut=[...W].sort((Ct,hn)=>Ct.startTime-hn.startTime),ee=ut.find(Ct=>Ct.startTime>F-.3),dt=ee&&F>=ee.startTime-.25&&F<=ee.startTime+.1&&!Gt;ee&&F>=ee.startTime-.25&&F<=ee.startTime+.1&&me.debug(`Approaching boundary at ${P(ee.startTime)}, continuePastBoundary=${Gt}, willStop=${dt}`);const Rt=ut.find(Ct=>F>=Ct.startTime&&F<=Ct.endTime);if(Rt&&(ze==null?void 0:ze.id)!==Rt.id){me.debug(`Entered segment ${Rt.id} during cutaway playback`),Ve(Rt),X(Rt.id),oe(!1),I.current.removeEventListener("timeupdate",j),St(!1),sessionStorage.removeItem("continuingPastSegment");return}if(dt&&ee){me.debug(`CUTAWAY MANUAL BOUNDARY CHECK: Current position ${P(F)} approaching segment at ${P(ee.startTime)} (distance: ${Math.abs(F-ee.startTime).toFixed(3)}s) - STOPPING`),I.current.pause(),setTimeout(()=>{if(I.current){I.current.currentTime=ee.startTime,Qe(ee.startTime),Ze(ee.startTime),he(ee.startTime),St(!1),X(ee.id),oe(!1),Ve(ee);const Ct=()=>{I.current&&(I.current.currentTime=ee.startTime,Qe(ee.startTime),Ze(ee.startTime),he(ee.startTime),me.debug(`Position corrected to exact segment boundary: ${P(I.current.currentTime)} (target: ${P(ee.startTime)})`))};setTimeout(Ct,10),setTimeout(Ct,20),setTimeout(Ct,50),setTimeout(Ct,100),setTimeout(Ct,200),I.current.addEventListener("seeked",Ct),I.current.addEventListener("canplay",Ct),I.current.addEventListener("waiting",Ct),setTimeout(()=>{I.current&&(I.current.removeEventListener("seeked",Ct),I.current.removeEventListener("canplay",Ct),I.current.removeEventListener("waiting",Ct))},300)}},10),Ye(!1),Ve(null),I.current.removeEventListener("timeupdate",j);return}};I.current.addEventListener("timeupdate",j),setTimeout(()=>{I.current&&I.current.play().then(()=>{Ye(!0),me.debug("CUTAWAY PLAYBACK STARTED:",P(S),"to",P(T),b?`(after segment ${b.id}, offset +25ms from ${P(b.endTime)})`:"(from video start)",L?`(will stop at segment ${L.id})`:"(will play to end)")}).catch(F=>{console.error("Error playing cutaway:",F)})},50)}},children:p.jsx("img",{src:Rm,alt:"Play from beginning",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn ${Le?"pause":"play"} ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":Le?"Pause playback":"Play from here until next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation(),Le?I.current&&(I.current.pause(),Ye(!1),St(!1)):Ce()},children:Le?p.jsx("img",{src:xm,alt:"Pause",style:{width:"24px",height:"24px"}}):p.jsx("img",{src:Cm,alt:"Play",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn segment-end ${U?"disabled":""}`,style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},"data-tooltip":U?"Disabled during preview":"Adjust end of previous segment",disabled:U,onClick:v=>{v.stopPropagation();const E=[...W].sort((b,S)=>b.startTime-S.startTime).filter(b=>b.endTime<=G).sort((b,S)=>S.endTime-b.endTime)[0];if(E){const b=W.map(L=>L.id===E.id?{...L,endTime:G}:L),S=new CustomEvent("update-segments",{detail:{segments:b,recordHistory:!0,action:"adjust_previous_end_time"}});document.dispatchEvent(S),me.debug("Adjusted end of previous segment to:",P(G)),X(E.id),oe(!1)}else if(W.length>0){const b=[...W].sort((T,V)=>T.startTime-V.startTime);let S=!1,L=0;for(let T=0;TV&&Gj.endTime-V.endTime)[0];if(T&&T.endTimeF.id===T.id?{...F,endTime:R}:F),j=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_last_segment"}});document.dispatchEvent(j),X(T.id),oe(!1)}}}else if(G>0){const b={id:Date.now(),name:"segment",startTime:0,endTime:G,thumbnail:""},S=new CustomEvent("update-segments",{detail:{segments:[b],recordHistory:!0,action:"create_segment_from_start"}});document.dispatchEvent(S),me.debug("Created new segment from start to:",P(G)),X(b.id),oe(!1)}},children:p.jsx("img",{src:G0,alt:"Set end point",style:{width:"24px",height:"24px"}})}),p.jsx("button",{className:`tooltip-action-btn segment-start ${U?"disabled":""}`,"data-tooltip":U?"Disabled during preview":"Adjust start of next segment",style:{userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",touchAction:"manipulation",cursor:U?"not-allowed":"pointer",WebkitTapHighlightColor:"transparent"},disabled:U,onClick:v=>{v.stopPropagation();const E=[...W].sort((b,S)=>b.startTime-S.startTime).filter(b=>b.startTime>=G).sort((b,S)=>b.startTime-S.startTime)[0];if(E){const b=W.map(L=>L.id===E.id?{...L,startTime:G}:L),S=new CustomEvent("update-segments",{detail:{segments:b,recordHistory:!0,action:"adjust_next_start_time"}});document.dispatchEvent(S),me.debug("Adjusted start of next segment to:",P(G)),X(E.id),oe(!1)}else if(W.length>0){const b=[...W].sort((T,V)=>T.startTime-V.startTime);let S=!1,L=0;for(let T=0;TV&&Gb[b.length-1].endTime){const T={id:Date.now(),name:"segment",startTime:G,endTime:R,thumbnail:""},V=[...W,T],j=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"create_segment_to_end"}});document.dispatchEvent(j),me.debug("Created new segment from",P(G),"to end"),X(T.id),oe(!1)}else{const T=b[0];if(T&&T.startTime>0){const V=W.map(F=>F.id===T.id?{...F,startTime:0}:F),j=new CustomEvent("update-segments",{detail:{segments:V,recordHistory:!0,action:"extend_first_segment"}});document.dispatchEvent(j),X(T.id),oe(!1)}}}else if(G{if(v.key==="Enter"){const w=v.currentTarget.value;try{const E=w.split(":");let b=0,S=0,L=0,T=0;if(E.length===3){b=parseInt(E[0]),S=parseInt(E[1]);const j=E[2].split(".");L=parseInt(j[0]),j.length>1&&(T=parseInt(j[1].padEnd(3,"0").substring(0,3)))}else if(E.length===2){S=parseInt(E[0]);const j=E[1].split(".");L=parseInt(j[0]),j.length>1&&(T=parseInt(j[1].padEnd(3,"0").substring(0,3)))}const V=b*3600+S*60+L+T/1e3;if(!isNaN(V)&&V>=0&&V<=R){Qe(V);const j=F=>{const ut=W.find(ee=>{const dt=F>=ee.startTime&&F<=ee.endTime,Rt=Math.abs(F-ee.startTime)<.001,Ct=Math.abs(F-ee.endTime)<.001;return dt||Rt||Ct});if(Z.current&&it.current){const ee=Z.current.getBoundingClientRect();let dt;if(f>1)dt=ee.left-it.current.scrollLeft+F/R*ee.width;else{const Rt=F/R;dt=ee.left+ee.width*Rt}q({x:dt,y:ee.top-10}),he(F),ut?(X(ut.id),oe(!1)):(X(null),oe(!0))}};setTimeout(()=>j(V),10)}}catch(E){console.error("Invalid time format:",E)}}}}),p.jsx("div",{className:"time-button-group",children:(()=>{const v=()=>{const w=W.find(E=>{const b=M>=E.startTime&&M<=E.endTime,S=Math.abs(M-E.startTime)<.001,L=Math.abs(M-E.endTime)<.001;return b||S||L});if(Z.current&&it.current){const E=Z.current.getBoundingClientRect();let b;if(f>1)b=E.left-it.current.scrollLeft+M/R*E.width;else{const S=M/R;b=E.left+E.width*S}if(q({x:b,y:E.top-10}),he(M),w)X(w.id),oe(!1);else{const S=fn(M);en(S),S>=.5?(X(null),oe(!0)):(X(null),oe(!1))}}};return p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"time-button",onClick:()=>{Qe(M-.01),setTimeout(v,10)},"data-tooltip":"Move back 10ms",children:"-10ms"}),p.jsx("button",{className:"time-button",onClick:()=>{Qe(M-.001),setTimeout(v,10)},"data-tooltip":"Move back 1ms",children:"-1ms"}),p.jsx("button",{className:"time-button",onClick:()=>{Qe(M+.001),setTimeout(v,10)},"data-tooltip":"Move forward 1ms",children:"+1ms"}),p.jsx("button",{className:"time-button",onClick:()=>{Qe(M+.01),setTimeout(v,10)},"data-tooltip":"Move forward 10ms",children:"+10ms"})]})})()})]}),p.jsxs("div",{className:"controls-right",children:[p.jsxs("div",{className:"zoom-dropdown-container",children:[p.jsxs("button",{className:"zoom-button","data-tooltip":"Select zoom level",onClick:()=>At(!mt),children:["Zoom ",f,"x",p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),mt&&p.jsx("div",{className:"zoom-dropdown",style:{position:"absolute",top:"100%",left:0,zIndex:1e3},children:[1,2,4,8,16,32,64,128,256,512,1024,2048,4096].map(v=>p.jsxs("div",{className:`zoom-option ${f===v?"selected":""}`,onClick:()=>{Be(v),At(!1)},children:[f===v&&p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Zoom ",v,"x"]},v))})]}),p.jsx("div",{className:"auto-saved-time",style:{color:Oe?"#1976d2":"gray",fontSize:"12px",marginLeft:"10px",display:"flex",alignItems:"center",gap:"5px"},children:Oe?p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"auto-save-spinner",style:{display:"inline-block",width:"12px",height:"12px",border:"2px solid #f3f3f3",borderTop:"2px solid #1976d2",borderRadius:"50%",animation:"spin 1s linear infinite"}}),"Auto saving..."]}):De?`Auto saved: ${De}`:"Not saved yet"}),p.jsx("div",{className:"save-buttons-row",children:p.jsx("button",{onClick:()=>K(!0),className:"save-chapters-button","data-tooltip":"Save chapters",disabled:W.filter(v=>v.chapterTitle&&v.chapterTitle.trim()).length===0,children:"Save Chapters"})}),p.jsx(qu,{isOpen:mn,onClose:()=>K(!1),title:"Save Chapters",actions:p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"modal-button modal-button-secondary",onClick:()=>K(!1),children:"Cancel"}),p.jsx("button",{className:"modal-button modal-button-primary",onClick:Zr,children:"Save Chapters"})]}),children:p.jsxs("p",{className:"modal-message",children:["Are you sure you want to save the chapters? This will save"," ",W.filter(v=>v.chapterTitle&&v.chapterTitle.trim()).length," chapters to the database."]})}),p.jsxs(qu,{isOpen:ye,onClose:()=>{},title:"Processing Video",children:[p.jsx("div",{className:"modal-spinner",children:p.jsx("div",{className:"spinner"})}),p.jsx("p",{className:"modal-message text-center",children:"Please wait while your video is being processed..."})]}),p.jsx(qu,{isOpen:nt,onClose:()=>Ut(!1),title:"Video Edited Successfully",children:p.jsx("div",{className:"modal-success-content",children:p.jsxs("p",{className:"modal-message text-center redirect-message",children:["You will be redirected to your"," ",p.jsx("a",{href:Fn,className:"media-page-link",style:X0,children:"media page"})," in ",p.jsx("span",{className:"countdown",children:"10"})," seconds. Your chapters have been saved successfully."]})})}),p.jsxs(qu,{isOpen:Wt,onClose:()=>Ht(!1),title:"Video Processing Error",children:[p.jsxs("div",{className:"modal-error-content",children:[p.jsx("div",{className:"modal-error-icon",children:p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"#F44336",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),p.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}),p.jsx("p",{className:"modal-message text-center error-message",children:It})]}),p.jsx("div",{className:"modal-choices",children:p.jsxs("button",{onClick:()=>Ht(!1),className:"modal-choice-button centered-choice",children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),p.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Close"]})})]})]})]}),ot&&p.jsx("div",{className:"mobile-timeline-overlay",children:p.jsxs("div",{className:"mobile-timeline-message",children:[p.jsx("p",{children:"Please play the video first to enable timeline controls"}),p.jsx("div",{className:"mobile-play-icon"})]})})]})},K0=({onSplit:M,onReset:R,onUndo:be,onRedo:Re,onPlaySegments:we,onPlay:ve,canUndo:f,canRedo:W,isPlaying:ge=!1,isPlayingSegments:re=!1})=>{const[Tt,ce]=Q.useState(!1);Q.useEffect(()=>{const te=()=>{ce(window.innerWidth<=640)};return te(),window.addEventListener("resize",te),()=>window.removeEventListener("resize",te)},[]);const je=()=>{ve()};return p.jsx("div",{className:"editing-tools-container",children:p.jsxs("div",{className:"flex-container single-row",children:[p.jsxs("div",{className:"button-group play-buttons-group",children:[p.jsx("button",{className:"button segments-button",onClick:we,"data-tooltip":re?"Stop segments playback":"Play segments in one continuous flow",style:{fontSize:"0.875rem"},children:re?p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),p.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),p.jsx("span",{className:"full-text",children:"Stop Preview"}),p.jsx("span",{className:"short-text",children:"Stop Preview"})]}):p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),p.jsx("span",{className:"full-text",children:"Play Preview"}),p.jsx("span",{className:"short-text",children:"Play Preview"})]})}),(!re||!Tt)&&p.jsx("button",{className:`button play-button ${re?"greyed-out":""}`,onClick:je,"data-tooltip":ge?"Pause video":"Play full video",style:{fontSize:"0.875rem"},disabled:re,children:ge&&!re?p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("line",{x1:"10",y1:"15",x2:"10",y2:"9"}),p.jsx("line",{x1:"14",y1:"15",x2:"14",y2:"9"})]}),p.jsx("span",{className:"full-text",children:"Pause"}),p.jsx("span",{className:"short-text",children:"Pause"})]}):p.jsxs(p.Fragment,{children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("circle",{cx:"12",cy:"12",r:"10"}),p.jsx("polygon",{points:"10 8 16 12 10 16 10 8"})]}),p.jsx("span",{className:"full-text",children:"Play"}),p.jsx("span",{className:"short-text",children:"Play"})]})})]}),p.jsxs("div",{className:"button-group secondary",children:[p.jsxs("button",{className:"button","aria-label":"Undo","data-tooltip":re?"Disabled during preview":"Undo last action",disabled:!f||re,onClick:be,children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"M9 14 4 9l5-5"}),p.jsx("path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5v0a5.5 5.5 0 0 1-5.5 5.5H11"})]}),p.jsx("span",{className:"button-text",children:"Undo"})]}),p.jsxs("button",{className:"button","aria-label":"Redo","data-tooltip":re?"Disabled during preview":"Redo last undone action",disabled:!W||re,onClick:Re,children:[p.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[p.jsx("path",{d:"m15 14 5-5-5-5"}),p.jsx("path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5v0A5.5 5.5 0 0 0 9.5 20H13"})]}),p.jsx("span",{className:"button-text",children:"Redo"})]}),p.jsx("div",{className:"divider"}),p.jsxs("button",{className:"button",onClick:R,"data-tooltip":re?"Disabled during preview":"Reset to full video",disabled:re,children:[p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:p.jsx("path",{fillRule:"evenodd",d:"M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z",clipRule:"evenodd"})}),p.jsx("span",{className:"reset-text",children:"Reset"})]})]})]})})},J0=({segments:M,selectedSegmentId:R})=>{const be=[...M].sort((ve,f)=>ve.startTime-f.startTime),Re=ve=>{const f=new CustomEvent("delete-segment",{detail:{segmentId:ve}});document.dispatchEvent(f)},we=ve=>`segment-default-color segment-color-${ve%8+1}`;return be.find(ve=>ve.id===R),p.jsxs("div",{className:"clip-segments-container",children:[p.jsx("h3",{className:"clip-segments-title",children:"Chapters"}),be.map((ve,f)=>p.jsxs("div",{className:`segment-item ${we(f)} ${R===ve.id?"selected":""}`,children:[p.jsxs("div",{className:"segment-content",children:[p.jsx("div",{className:"segment-thumbnail",style:{backgroundImage:`url(${ve.thumbnail})`}}),p.jsxs("div",{className:"segment-info",children:[p.jsx("div",{className:"segment-title",children:ve.chapterTitle?p.jsx("span",{className:"chapter-title",children:ve.chapterTitle}):p.jsxs("span",{className:"default-title",children:["Chapter ",f+1]})}),p.jsxs("div",{className:"segment-time",children:[ki(ve.startTime)," - ",ki(ve.endTime)]}),p.jsxs("div",{className:"segment-duration",children:["Duration: ",$0(ve.endTime-ve.startTime)]})]})]}),p.jsx("div",{className:"segment-actions",children:p.jsx("button",{className:"delete-button","aria-label":"Delete Segment","data-tooltip":"Delete this segment",onClick:()=>Re(ve.id),children:p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",children:p.jsx("path",{fillRule:"evenodd",d:"M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z",clipRule:"evenodd"})})})})]},ve.id)),be.length===0&&p.jsx("div",{className:"empty-message",children:"No chapters created yet. Use the split button to create chapter segments."})]})},Z0=({videoRef:M,onPlay:R})=>{const[be,Re]=Q.useState(!1);Q.useEffect(()=>{const f=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent);Re(f)},[]),Q.useEffect(()=>{const ve=M.current;if(!ve)return;const f=()=>{Re(!1)};return ve.addEventListener("play",f),()=>{ve.removeEventListener("play",f)}},[M]);const we=()=>{R()};return be?p.jsx("div",{className:"mobile-play-prompt-overlay",children:p.jsx("div",{className:"mobile-play-prompt",children:p.jsx("button",{className:"mobile-play-button",onClick:we,children:"Click to start editing..."})})}):null},eS=()=>{const M=z=>{const ue=z.split(":");if(ue.length!==3)return 0;const De=parseInt(ue[0],10)||0,Te=parseInt(ue[1],10)||0,Oe=parseFloat(ue[2])||0;return De*3600+Te*60+Oe},R=Q.useRef(null),[be,Re]=Q.useState(0),[we,ve]=Q.useState(0),[f,W]=Q.useState(!1),[ge,re]=Q.useState(!1),[Tt,ce]=Q.useState([]),[je,te]=Q.useState(0),[Be,Qe]=Q.useState(0),[I,xt]=Q.useState([]),[ot,Le]=Q.useState(1),[rt,Ce]=Q.useState([]),[U,Z]=Q.useState(null),[zt,Et]=Q.useState([]),[st,Ot]=Q.useState(-1),[ke,X]=Q.useState(!1),[tt,oe]=Q.useState(!1),[Se,q]=Q.useState(0);Q.useEffect(()=>{var z;if(zt.length>0){const ue=((z=zt[st])==null?void 0:z.action)||"";ue!=="save"&&ue!=="save_copy"&&ue!=="save_segments"&&X(!0)}},[zt,st]),Q.useEffect(()=>{const z=R.current;if(!z)return;const ue=()=>{ve(z.duration),Qe(z.duration),(async()=>{var K;let Ie=[];const We=typeof window<"u"&&((K=window.MEDIA_DATA)==null?void 0:K.chapters)||[];if(We.length>0)for(let ye=0;ye{Re(z.currentTime)},Te=()=>{W(!0),ln(!0)},Oe=()=>{W(!1)},et=()=>{W(!1),z.currentTime=je};return z.addEventListener("loadedmetadata",ue),z.addEventListener("timeupdate",De),z.addEventListener("play",Te),z.addEventListener("pause",Oe),z.addEventListener("ended",et),()=>{z.removeEventListener("loadedmetadata",ue),z.removeEventListener("timeupdate",De),z.removeEventListener("play",Te),z.removeEventListener("pause",Oe),z.removeEventListener("ended",et)}},[]);const G=z=>{const ue=R.current;if(!ue)return;const De=!ue.paused;ue.currentTime=z,Re(z),typeof window<"u"&&(window.lastSeekedPosition=z),De&&ue.play().then(()=>{W(!0)}).catch(Te=>{console.error("Error resuming playback:",Te),W(!1)})},he=z=>{const ue={trimStart:je,trimEnd:Be,splitPoints:[...I],clipSegments:JSON.parse(JSON.stringify(rt)),action:z||"manual_save"},De=zt[st],Te=()=>{if(!De||De.clipSegments.length!==ue.clipSegments.length)return!0;for(let Je=0;Je.001||Math.abs(Ie.endTime-We.endTime)>.001)return!0}return!1},Oe=!De||De.trimStart!==ue.trimStart||De.trimEnd!==ue.trimEnd||De.splitPoints.length!==ue.splitPoints.length||Te(),et=ue.action!==void 0;if(Oe||et){const Je=st;Et(Ie=>JeIe+1)}};Q.useEffect(()=>{const z=ue=>{if(ue.detail){const{time:De,isStart:Te,recordHistory:Oe,action:et}=ue.detail;Te?te(De):Qe(De),Oe&&setTimeout(()=>{he(et||(Te?"adjust_trim_start":"adjust_trim_end"))},10)}};return document.addEventListener("update-trim",z),()=>{document.removeEventListener("update-trim",z)}},[]),Q.useEffect(()=>{const z=Te=>{if(Te.detail&&Te.detail.segments){const Oe=Te.detail.recordHistory!==!1,et=Te.detail.action||"update_segments";Ce(Te.detail.segments),Oe&&setTimeout(()=>{const Je=JSON.parse(JSON.stringify(Te.detail.segments)),Ie={trimStart:je,trimEnd:Be,splitPoints:[...I],clipSegments:Je,action:et},We=st;Et(ft=>Weft+1)},20)}},ue=async Te=>{const Oe=Te;if(Oe.detail&&typeof Oe.detail.time=="number"&&typeof Oe.detail.segmentId=="number"){const et=Oe.detail.time,Je=Oe.detail.segmentId;G(et);const Ie=rt.find(mn=>mn.id===Je);if(!Ie||et<=Ie.startTime||et>=Ie.endTime)return;const We=[...rt],ft=We.findIndex(mn=>mn.id===Je);if(ft===-1)return;We.splice(ft,1);const pn={id:Date.now(),name:`${Ie.name}-A`,startTime:Ie.startTime,endTime:et,thumbnail:""},Ln={id:Date.now()+1,name:`${Ie.name}-B`,startTime:et,endTime:Ie.endTime,thumbnail:""};We.push(pn,Ln),We.sort((mn,K)=>mn.startTime-K.startTime),Ce(We),he("split_segment")}},De=async Te=>{const Oe=Te;if(Oe.detail&&typeof Oe.detail.segmentId=="number"){const et=Oe.detail.segmentId,Je=rt.filter(Ie=>Ie.id!==et);if(Je.length!==rt.length){if(Je.length===0&&R.current){const Ie={id:Date.now(),name:"segment",startTime:0,endTime:R.current.duration,thumbnail:""};te(0),Qe(R.current.duration),xt([]),Ce([Ie])}else Ce(Je);he("delete_segment")}}};return document.addEventListener("update-segments",z),document.addEventListener("split-segment",ue),document.addEventListener("delete-segment",De),()=>{document.removeEventListener("update-segments",z),document.removeEventListener("split-segment",ue),document.removeEventListener("delete-segment",De)}},[rt,we]);const mt=z=>{te(z),he("adjust_trim_start")},At=z=>{Qe(z),he("adjust_trim_end")},ct=async()=>{if(R.current&&!I.includes(be)){const z=[...I,be].sort((Te,Oe)=>Te-Oe);xt(z);const ue=[];let De=0;for(let Te=0;Te<=z.length;Te++){const Oe=Te{if(te(0),Qe(we),xt([]),!R.current)return;const z={id:Date.now(),name:"segment",startTime:0,endTime:we,thumbnail:""};Ce([z]),he("reset_all")},jt=()=>{if(st>0){const z=zt[st-1];me.debug(`** UNDO ** to position ${st-1}, action: ${z.action}, segments: ${z.clipSegments.length}`),me.debug("Segment details after undo:",z.clipSegments.map(ue=>`ID: ${ue.id}, Time: ${P(ue.startTime)} - ${P(ue.endTime)}`)),te(z.trimStart),Qe(z.trimEnd),xt([...z.splitPoints]),Ce(JSON.parse(JSON.stringify(z.clipSegments))),Ot(st-1)}},Ye=()=>{if(st`ID: ${ue.id}, Time: ${P(ue.startTime)} - ${P(ue.endTime)}`)),te(z.trimStart),Qe(z.trimEnd),xt([...z.splitPoints]),Ce(JSON.parse(JSON.stringify(z.clipSegments))),Ot(st+1)}},ze=z=>{Le(z)},Ve=()=>{const z=R.current;z&&(z.muted=!z.muted,re(!ge))},vn=(z,ue)=>{Ce(De=>De.map(Te=>Te.id===z?{...Te,...ue}:Te)),X(!0)},Ze=async z=>{var ue;try{const De=(ue=window.MEDIA_DATA)==null?void 0:ue.mediaId;if(!De){console.error("No media ID found");return}const Oe={chapters:z.map(ft=>({startTime:ft.from,endTime:ft.to,text:ft.name}))};console.log("Saving chapters:",Oe);const et=Gt(),Je={"Content-Type":"application/json"};et&&(Je["X-CSRFToken"]=et);const Ie=await fetch(`/api/v1/media/${De}/chapters`,{method:"POST",headers:Je,body:JSON.stringify(Oe)});if(!Ie.ok)throw new Error(`Failed to save chapters: ${Ie.status}`);const We=await Ie.json();console.log("Chapters saved successfully:",We),X(!1)}catch(De){console.error("Error saving chapters:",De)}},Gt=()=>{var Te;const De=`; ${document.cookie}`.split("; csrftoken=");return De.length===2&&((Te=De.pop())==null?void 0:Te.split(";").shift())||""},St=z=>{Z(z)},it=z=>{(!an||on)&&G(z)},an=typeof window<"u"&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),[on,ln]=Q.useState(!1);return Q.useEffect(()=>{if(!tt||!R.current)return;const z=R.current,ue=[...rt].sort((Te,Oe)=>Te.startTime-Oe.startTime),De=()=>{const Te=ue[Se];if(!Te)return;const Oe=z.currentTime;if(Oe=Te.endTime-.01)if(Se{console.error("Error continuing segment playback:",Je)})}else z.pause(),oe(!1),q(0),z.removeEventListener("timeupdate",De)};return z.addEventListener("timeupdate",De),z.paused&&ue.length>0&&(z.currentTime=ue[0].startTime,z.play().catch(console.error)),()=>{z.removeEventListener("timeupdate",De)}},[tt,Se,rt]),Q.useEffect(()=>{const z=ue=>{const{segmentIndex:De}=ue.detail;tt&&De!==Se&&q(De)};return document.addEventListener("update-segment-index",z),()=>{document.removeEventListener("update-segment-index",z)}},[tt,Se]),{videoRef:R,currentTime:be,duration:we,isPlaying:f,setIsPlaying:W,isMuted:ge,isPlayingSegments:tt,thumbnails:Tt,trimStart:je,trimEnd:Be,splitPoints:I,zoomLevel:ot,clipSegments:rt,selectedSegmentId:U,hasUnsavedChanges:ke,historyPosition:st,history:zt,handleTrimStartChange:mt,handleTrimEndChange:At,handleZoomChange:ze,handleMobileSafeSeek:it,handleSplit:ct,handleReset:en,handleUndo:jt,handleRedo:Ye,handlePlaySegments:()=>{const z=R.current;if(!(!z||rt.length===0))if(tt)z.pause(),oe(!1),q(0);else{oe(!0),q(0);const ue=[...rt].sort((De,Te)=>De.startTime-Te.startTime);z.currentTime=ue[0].startTime,z.play().catch(De=>{console.error("Error starting segments playback:",De),oe(!1)})}},toggleMute:Ve,handleSegmentUpdate:vn,handleChapterSave:Ze,handleSelectedSegmentChange:St,isMobile:an,videoInitialized:on,setVideoInitialized:ln}},tS=()=>{const{videoRef:M,currentTime:R,duration:be,isPlaying:Re,setIsPlaying:we,isMuted:ve,thumbnails:f,trimStart:W,trimEnd:ge,splitPoints:re,zoomLevel:Tt,clipSegments:ce,selectedSegmentId:je,hasUnsavedChanges:te,historyPosition:Be,history:Qe,handleTrimStartChange:I,handleTrimEndChange:xt,handleZoomChange:ot,handleMobileSafeSeek:Le,handleSplit:rt,handleReset:Ce,handleUndo:U,handleRedo:Z,toggleMute:zt,handleSegmentUpdate:Et,handleChapterSave:st,handleSelectedSegmentChange:Ot,isMobile:ke,videoInitialized:X,setVideoInitialized:tt,isPlayingSegments:oe,handlePlaySegments:Se}=eS(),q=()=>{if(!M.current)return;const G=M.current;if(Re){G.pause(),we(!1);return}const he=Number(G.currentTime.toFixed(6));let mt=be,At=null,ct=null;const en=[...ce].sort((Ye,ze)=>Ye.startTime-ze.startTime);At=en.find(Ye=>{const ze=Number(Ye.startTime.toFixed(6)),Ve=Number(Ye.endTime.toFixed(6));return he>ze&&heNumber(Ye.startTime.toFixed(6))>he)),At?mt=Number(At.endTime.toFixed(6)):ct&&(mt=Number(ct.startTime.toFixed(6)));const jt=()=>{if(!G)return;const Ye=Number(G.currentTime.toFixed(6));if(Number((mt-Ye).toFixed(6))<=0||Ye>=mt){G.pause();const Ve=()=>{if(!G)return;G.currentTime=mt,Le(mt);const vn=Number(G.currentTime.toFixed(6)),Ze=Number(Math.abs(vn-mt).toFixed(6));me.debug("Position verification:",{target:P(mt),actual:P(vn),difference:Ze}),Ze>0&&(G.currentTime=mt,Le(mt))};Ve(),setTimeout(Ve,5),setTimeout(Ve,10),setTimeout(Ve,20),setTimeout(Ve,50),G.removeEventListener("timeupdate",jt),we(!1),me.debug("Stopped at position:",{target:P(mt),actual:P(G.currentTime),type:At?"segment end":ct?"next segment start":"end of video",segment:At?{id:At.id,start:P(At.startTime),end:P(At.endTime)}:null,nextSegment:ct?{id:ct.id,start:P(ct.startTime),end:P(ct.endTime)}:null});return}};G.addEventListener("timeupdate",jt),G.play().then(()=>{we(!0),tt(!0),me.debug("Playback started:",{from:P(he),to:P(mt),currentSegment:At?{id:At.id,start:P(At.startTime),end:P(At.endTime)}:"None",nextSegment:ct?{id:ct.id,start:P(ct.startTime),end:P(ct.endTime)}:"None"})}).catch(Ye=>{console.error("Error playing video:",Ye)})};return p.jsxs("div",{className:"bg-background min-h-screen",children:[p.jsx(Z0,{videoRef:M,onPlay:q}),p.jsxs("div",{className:"container mx-auto px-4 py-6 max-w-6xl",children:[p.jsx(P0,{videoRef:M,currentTime:R,duration:be,isPlaying:Re,isMuted:ve,onPlayPause:q,onSeek:Le,onToggleMute:zt}),p.jsx(K0,{onSplit:rt,onReset:Ce,onUndo:U,onRedo:Z,onPlaySegments:Se,onPlay:q,isPlaying:Re,isPlayingSegments:oe,canUndo:Be>0,canRedo:Be{const M=document.getElementById("chapters-editor-root");M&&Sm(M).render(p.jsx(tS,{}))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Dm):Dm()})(); //# sourceMappingURL=chapters-editor.js.map diff --git a/static/chapters_editor/chapters-editor.js.map b/static/chapters_editor/chapters-editor.js.map index 323984a8..05b58db1 100644 --- a/static/chapters_editor/chapters-editor.js.map +++ b/static/chapters_editor/chapters-editor.js.map @@ -1 +1 @@ -{"version":3,"file":"chapters-editor.js","sources":["../../frontend-tools/chapters-editor/node_modules/react/cjs/react.development.js","../../frontend-tools/chapters-editor/node_modules/react/index.js","../../frontend-tools/chapters-editor/node_modules/react/cjs/react-jsx-runtime.development.js","../../frontend-tools/chapters-editor/node_modules/react/jsx-runtime.js","../../frontend-tools/chapters-editor/node_modules/scheduler/cjs/scheduler.development.js","../../frontend-tools/chapters-editor/node_modules/scheduler/index.js","../../frontend-tools/chapters-editor/node_modules/react-dom/cjs/react-dom.development.js","../../frontend-tools/chapters-editor/node_modules/react-dom/index.js","../../frontend-tools/chapters-editor/node_modules/react-dom/client.js","../../frontend-tools/chapters-editor/client/src/lib/timeUtils.ts","../../frontend-tools/chapters-editor/client/src/lib/logger.ts","../../frontend-tools/chapters-editor/client/src/components/VideoPlayer.tsx","../../frontend-tools/chapters-editor/client/src/lib/videoUtils.ts","../../frontend-tools/chapters-editor/client/src/components/Modal.tsx","../../frontend-tools/chapters-editor/client/src/services/videoApi.ts","../../frontend-tools/chapters-editor/client/src/assets/play-icon.svg","../../frontend-tools/chapters-editor/client/src/assets/pause-icon.svg","../../frontend-tools/chapters-editor/client/src/assets/play-from-beginning-icon.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-end-new.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-start-new.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-start-new-cutaway.svg","../../frontend-tools/chapters-editor/client/src/assets/segment-end-new-cutaway.svg","../../frontend-tools/chapters-editor/client/src/components/TimelineControls.tsx","../../frontend-tools/chapters-editor/client/src/components/EditingTools.tsx","../../frontend-tools/chapters-editor/client/src/components/ClipSegments.tsx","../../frontend-tools/chapters-editor/client/src/components/IOSPlayPrompt.tsx","../../frontend-tools/chapters-editor/client/src/hooks/useVideoChapters.tsx","../../frontend-tools/chapters-editor/client/src/App.tsx","../../frontend-tools/chapters-editor/client/src/main.tsx"],"sourcesContent":["/**\n * @license React\n * react.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var ReactVersion = '18.3.1';\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\n/**\n * Keeps track of the current dispatcher.\n */\nvar ReactCurrentDispatcher = {\n /**\n * @internal\n * @type {ReactComponent}\n */\n current: null\n};\n\n/**\n * Keeps track of the current batch's configuration such as how long an update\n * should suspend for if it needs to.\n */\nvar ReactCurrentBatchConfig = {\n transition: null\n};\n\nvar ReactCurrentActQueue = {\n current: null,\n // Used to reproduce behavior of `batchedUpdates` in legacy mode.\n isBatchingLegacy: false,\n didScheduleLegacyUpdate: false\n};\n\n/**\n * Keeps track of the current owner.\n *\n * The current owner is the component who should own any components that are\n * currently being constructed.\n */\nvar ReactCurrentOwner = {\n /**\n * @internal\n * @type {ReactComponent}\n */\n current: null\n};\n\nvar ReactDebugCurrentFrame = {};\nvar currentExtraStackFrame = null;\nfunction setExtraStackFrame(stack) {\n {\n currentExtraStackFrame = stack;\n }\n}\n\n{\n ReactDebugCurrentFrame.setExtraStackFrame = function (stack) {\n {\n currentExtraStackFrame = stack;\n }\n }; // Stack implementation injected by the current renderer.\n\n\n ReactDebugCurrentFrame.getCurrentStack = null;\n\n ReactDebugCurrentFrame.getStackAddendum = function () {\n var stack = ''; // Add an extra top frame while an element is being validated\n\n if (currentExtraStackFrame) {\n stack += currentExtraStackFrame;\n } // Delegate to the injected renderer-specific implementation\n\n\n var impl = ReactDebugCurrentFrame.getCurrentStack;\n\n if (impl) {\n stack += impl() || '';\n }\n\n return stack;\n };\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar ReactSharedInternals = {\n ReactCurrentDispatcher: ReactCurrentDispatcher,\n ReactCurrentBatchConfig: ReactCurrentBatchConfig,\n ReactCurrentOwner: ReactCurrentOwner\n};\n\n{\n ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;\n ReactSharedInternals.ReactCurrentActQueue = ReactCurrentActQueue;\n}\n\n// by calls to these methods by a Babel plugin.\n//\n// In PROD (or in packages without access to React internals),\n// they are left as they are instead.\n\nfunction warn(format) {\n {\n {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n printWarning('warn', format, args);\n }\n }\n}\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\nvar didWarnStateUpdateForUnmountedComponent = {};\n\nfunction warnNoop(publicInstance, callerName) {\n {\n var _constructor = publicInstance.constructor;\n var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';\n var warningKey = componentName + \".\" + callerName;\n\n if (didWarnStateUpdateForUnmountedComponent[warningKey]) {\n return;\n }\n\n error(\"Can't call %s on a component that is not yet mounted. \" + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);\n\n didWarnStateUpdateForUnmountedComponent[warningKey] = true;\n }\n}\n/**\n * This is the abstract API for an update queue.\n */\n\n\nvar ReactNoopUpdateQueue = {\n /**\n * Checks whether or not this composite component is mounted.\n * @param {ReactClass} publicInstance The instance we want to test.\n * @return {boolean} True if mounted, false otherwise.\n * @protected\n * @final\n */\n isMounted: function (publicInstance) {\n return false;\n },\n\n /**\n * Forces an update. This should only be invoked when it is known with\n * certainty that we are **not** in a DOM transaction.\n *\n * You may want to call this when you know that some deeper aspect of the\n * component's state has changed but `setState` was not called.\n *\n * This will not invoke `shouldComponentUpdate`, but it will invoke\n * `componentWillUpdate` and `componentDidUpdate`.\n *\n * @param {ReactClass} publicInstance The instance that should rerender.\n * @param {?function} callback Called after component is updated.\n * @param {?string} callerName name of the calling function in the public API.\n * @internal\n */\n enqueueForceUpdate: function (publicInstance, callback, callerName) {\n warnNoop(publicInstance, 'forceUpdate');\n },\n\n /**\n * Replaces all of the state. Always use this or `setState` to mutate state.\n * You should treat `this.state` as immutable.\n *\n * There is no guarantee that `this.state` will be immediately updated, so\n * accessing `this.state` after calling this method may return the old value.\n *\n * @param {ReactClass} publicInstance The instance that should rerender.\n * @param {object} completeState Next state.\n * @param {?function} callback Called after component is updated.\n * @param {?string} callerName name of the calling function in the public API.\n * @internal\n */\n enqueueReplaceState: function (publicInstance, completeState, callback, callerName) {\n warnNoop(publicInstance, 'replaceState');\n },\n\n /**\n * Sets a subset of the state. This only exists because _pendingState is\n * internal. This provides a merging strategy that is not available to deep\n * properties which is confusing. TODO: Expose pendingState or don't use it\n * during the merge.\n *\n * @param {ReactClass} publicInstance The instance that should rerender.\n * @param {object} partialState Next partial state to be merged with state.\n * @param {?function} callback Called after component is updated.\n * @param {?string} Name of the calling function in the public API.\n * @internal\n */\n enqueueSetState: function (publicInstance, partialState, callback, callerName) {\n warnNoop(publicInstance, 'setState');\n }\n};\n\nvar assign = Object.assign;\n\nvar emptyObject = {};\n\n{\n Object.freeze(emptyObject);\n}\n/**\n * Base class helpers for the updating state of a component.\n */\n\n\nfunction Component(props, context, updater) {\n this.props = props;\n this.context = context; // If a component has string refs, we will assign a different object later.\n\n this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the\n // renderer.\n\n this.updater = updater || ReactNoopUpdateQueue;\n}\n\nComponent.prototype.isReactComponent = {};\n/**\n * Sets a subset of the state. Always use this to mutate\n * state. You should treat `this.state` as immutable.\n *\n * There is no guarantee that `this.state` will be immediately updated, so\n * accessing `this.state` after calling this method may return the old value.\n *\n * There is no guarantee that calls to `setState` will run synchronously,\n * as they may eventually be batched together. You can provide an optional\n * callback that will be executed when the call to setState is actually\n * completed.\n *\n * When a function is provided to setState, it will be called at some point in\n * the future (not synchronously). It will be called with the up to date\n * component arguments (state, props, context). These values can be different\n * from this.* because your function may be called after receiveProps but before\n * shouldComponentUpdate, and this new state, props, and context will not yet be\n * assigned to this.\n *\n * @param {object|function} partialState Next partial state or function to\n * produce next partial state to be merged with current state.\n * @param {?function} callback Called after state is updated.\n * @final\n * @protected\n */\n\nComponent.prototype.setState = function (partialState, callback) {\n if (typeof partialState !== 'object' && typeof partialState !== 'function' && partialState != null) {\n throw new Error('setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.');\n }\n\n this.updater.enqueueSetState(this, partialState, callback, 'setState');\n};\n/**\n * Forces an update. This should only be invoked when it is known with\n * certainty that we are **not** in a DOM transaction.\n *\n * You may want to call this when you know that some deeper aspect of the\n * component's state has changed but `setState` was not called.\n *\n * This will not invoke `shouldComponentUpdate`, but it will invoke\n * `componentWillUpdate` and `componentDidUpdate`.\n *\n * @param {?function} callback Called after update is complete.\n * @final\n * @protected\n */\n\n\nComponent.prototype.forceUpdate = function (callback) {\n this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');\n};\n/**\n * Deprecated APIs. These APIs used to exist on classic React classes but since\n * we would like to deprecate them, we're not going to move them over to this\n * modern base class. Instead, we define a getter that warns if it's accessed.\n */\n\n\n{\n var deprecatedAPIs = {\n isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],\n replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']\n };\n\n var defineDeprecationWarning = function (methodName, info) {\n Object.defineProperty(Component.prototype, methodName, {\n get: function () {\n warn('%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);\n\n return undefined;\n }\n });\n };\n\n for (var fnName in deprecatedAPIs) {\n if (deprecatedAPIs.hasOwnProperty(fnName)) {\n defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);\n }\n }\n}\n\nfunction ComponentDummy() {}\n\nComponentDummy.prototype = Component.prototype;\n/**\n * Convenience component with default shallow equality check for sCU.\n */\n\nfunction PureComponent(props, context, updater) {\n this.props = props;\n this.context = context; // If a component has string refs, we will assign a different object later.\n\n this.refs = emptyObject;\n this.updater = updater || ReactNoopUpdateQueue;\n}\n\nvar pureComponentPrototype = PureComponent.prototype = new ComponentDummy();\npureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.\n\nassign(pureComponentPrototype, Component.prototype);\npureComponentPrototype.isPureReactComponent = true;\n\n// an immutable object with a single mutable value\nfunction createRef() {\n var refObject = {\n current: null\n };\n\n {\n Object.seal(refObject);\n }\n\n return refObject;\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n var warnAboutAccessingKey = function () {\n {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n var warnAboutAccessingRef = function () {\n {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * Create and return a new ReactElement of the given type.\n * See https://reactjs.org/docs/react-api.html#createelement\n */\n\nfunction createElement(type, config, children) {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null;\n var self = null;\n var source = null;\n\n if (config != null) {\n if (hasValidRef(config)) {\n ref = config.ref;\n\n {\n warnIfStringRefCannotBeAutoConverted(config);\n }\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n self = config.__self === undefined ? null : config.__self;\n source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n }\n } // Children can be more than one argument, and those are transferred onto\n // the newly allocated props object.\n\n\n var childrenLength = arguments.length - 2;\n\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = Array(childrenLength);\n\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 2];\n }\n\n {\n if (Object.freeze) {\n Object.freeze(childArray);\n }\n }\n\n props.children = childArray;\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n {\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n}\nfunction cloneAndReplaceKey(oldElement, newKey) {\n var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);\n return newElement;\n}\n/**\n * Clone and return a new ReactElement using element as the starting point.\n * See https://reactjs.org/docs/react-api.html#cloneelement\n */\n\nfunction cloneElement(element, config, children) {\n if (element === null || element === undefined) {\n throw new Error(\"React.cloneElement(...): The argument must be a React element, but you passed \" + element + \".\");\n }\n\n var propName; // Original props are copied\n\n var props = assign({}, element.props); // Reserved names are extracted\n\n var key = element.key;\n var ref = element.ref; // Self is preserved since the owner is preserved.\n\n var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a\n // transpiler, and the original source is probably a better indicator of the\n // true owner.\n\n var source = element._source; // Owner will be preserved, unless ref is overridden\n\n var owner = element._owner;\n\n if (config != null) {\n if (hasValidRef(config)) {\n // Silently steal the ref from the parent.\n ref = config.ref;\n owner = ReactCurrentOwner.current;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n } // Remaining properties override existing props\n\n\n var defaultProps;\n\n if (element.type && element.type.defaultProps) {\n defaultProps = element.type.defaultProps;\n }\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n if (config[propName] === undefined && defaultProps !== undefined) {\n // Resolve default props\n props[propName] = defaultProps[propName];\n } else {\n props[propName] = config[propName];\n }\n }\n }\n } // Children can be more than one argument, and those are transferred onto\n // the newly allocated props object.\n\n\n var childrenLength = arguments.length - 2;\n\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = Array(childrenLength);\n\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 2];\n }\n\n props.children = childArray;\n }\n\n return ReactElement(element.type, key, ref, self, source, owner, props);\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\nfunction isValidElement(object) {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n}\n\nvar SEPARATOR = '.';\nvar SUBSEPARATOR = ':';\n/**\n * Escape and wrap key so it is safe to use as a reactid\n *\n * @param {string} key to be escaped.\n * @return {string} the escaped key.\n */\n\nfunction escape(key) {\n var escapeRegex = /[=:]/g;\n var escaperLookup = {\n '=': '=0',\n ':': '=2'\n };\n var escapedString = key.replace(escapeRegex, function (match) {\n return escaperLookup[match];\n });\n return '$' + escapedString;\n}\n/**\n * TODO: Test that a single child and an array with one item have the same key\n * pattern.\n */\n\n\nvar didWarnAboutMaps = false;\nvar userProvidedKeyEscapeRegex = /\\/+/g;\n\nfunction escapeUserProvidedKey(text) {\n return text.replace(userProvidedKeyEscapeRegex, '$&/');\n}\n/**\n * Generate a key string that identifies a element within a set.\n *\n * @param {*} element A element that could contain a manual key.\n * @param {number} index Index that is used if a manual key is not provided.\n * @return {string}\n */\n\n\nfunction getElementKey(element, index) {\n // Do some typechecking here since we call this blindly. We want to ensure\n // that we don't block potential future ES APIs.\n if (typeof element === 'object' && element !== null && element.key != null) {\n // Explicit key\n {\n checkKeyStringCoercion(element.key);\n }\n\n return escape('' + element.key);\n } // Implicit key determined by the index in the set\n\n\n return index.toString(36);\n}\n\nfunction mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {\n var type = typeof children;\n\n if (type === 'undefined' || type === 'boolean') {\n // All of the above are perceived as null.\n children = null;\n }\n\n var invokeCallback = false;\n\n if (children === null) {\n invokeCallback = true;\n } else {\n switch (type) {\n case 'string':\n case 'number':\n invokeCallback = true;\n break;\n\n case 'object':\n switch (children.$$typeof) {\n case REACT_ELEMENT_TYPE:\n case REACT_PORTAL_TYPE:\n invokeCallback = true;\n }\n\n }\n }\n\n if (invokeCallback) {\n var _child = children;\n var mappedChild = callback(_child); // If it's the only child, treat the name as if it was wrapped in an array\n // so that it's consistent if the number of children grows:\n\n var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;\n\n if (isArray(mappedChild)) {\n var escapedChildKey = '';\n\n if (childKey != null) {\n escapedChildKey = escapeUserProvidedKey(childKey) + '/';\n }\n\n mapIntoArray(mappedChild, array, escapedChildKey, '', function (c) {\n return c;\n });\n } else if (mappedChild != null) {\n if (isValidElement(mappedChild)) {\n {\n // The `if` statement here prevents auto-disabling of the safe\n // coercion ESLint rule, so we must manually disable it below.\n // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key\n if (mappedChild.key && (!_child || _child.key !== mappedChild.key)) {\n checkKeyStringCoercion(mappedChild.key);\n }\n }\n\n mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as\n // traverseAllChildren used to do for objects as children\n escapedPrefix + ( // $FlowFixMe Flow incorrectly thinks React.Portal doesn't have a key\n mappedChild.key && (!_child || _child.key !== mappedChild.key) ? // $FlowFixMe Flow incorrectly thinks existing element's key can be a number\n // eslint-disable-next-line react-internal/safe-string-coercion\n escapeUserProvidedKey('' + mappedChild.key) + '/' : '') + childKey);\n }\n\n array.push(mappedChild);\n }\n\n return 1;\n }\n\n var child;\n var nextName;\n var subtreeCount = 0; // Count of children found in the current subtree.\n\n var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;\n\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n child = children[i];\n nextName = nextNamePrefix + getElementKey(child, i);\n subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);\n }\n } else {\n var iteratorFn = getIteratorFn(children);\n\n if (typeof iteratorFn === 'function') {\n var iterableChildren = children;\n\n {\n // Warn about using Maps as children\n if (iteratorFn === iterableChildren.entries) {\n if (!didWarnAboutMaps) {\n warn('Using Maps as children is not supported. ' + 'Use an array of keyed ReactElements instead.');\n }\n\n didWarnAboutMaps = true;\n }\n }\n\n var iterator = iteratorFn.call(iterableChildren);\n var step;\n var ii = 0;\n\n while (!(step = iterator.next()).done) {\n child = step.value;\n nextName = nextNamePrefix + getElementKey(child, ii++);\n subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);\n }\n } else if (type === 'object') {\n // eslint-disable-next-line react-internal/safe-string-coercion\n var childrenString = String(children);\n throw new Error(\"Objects are not valid as a React child (found: \" + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + \"). \" + 'If you meant to render a collection of children, use an array ' + 'instead.');\n }\n }\n\n return subtreeCount;\n}\n\n/**\n * Maps children that are typically specified as `props.children`.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrenmap\n *\n * The provided mapFunction(child, index) will be called for each\n * leaf child.\n *\n * @param {?*} children Children tree container.\n * @param {function(*, int)} func The map function.\n * @param {*} context Context for mapFunction.\n * @return {object} Object containing the ordered map of results.\n */\nfunction mapChildren(children, func, context) {\n if (children == null) {\n return children;\n }\n\n var result = [];\n var count = 0;\n mapIntoArray(children, result, '', '', function (child) {\n return func.call(context, child, count++);\n });\n return result;\n}\n/**\n * Count the number of children that are typically specified as\n * `props.children`.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrencount\n *\n * @param {?*} children Children tree container.\n * @return {number} The number of children.\n */\n\n\nfunction countChildren(children) {\n var n = 0;\n mapChildren(children, function () {\n n++; // Don't return anything\n });\n return n;\n}\n\n/**\n * Iterates through children that are typically specified as `props.children`.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrenforeach\n *\n * The provided forEachFunc(child, index) will be called for each\n * leaf child.\n *\n * @param {?*} children Children tree container.\n * @param {function(*, int)} forEachFunc\n * @param {*} forEachContext Context for forEachContext.\n */\nfunction forEachChildren(children, forEachFunc, forEachContext) {\n mapChildren(children, function () {\n forEachFunc.apply(this, arguments); // Don't return anything.\n }, forEachContext);\n}\n/**\n * Flatten a children object (typically specified as `props.children`) and\n * return an array with appropriately re-keyed children.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrentoarray\n */\n\n\nfunction toArray(children) {\n return mapChildren(children, function (child) {\n return child;\n }) || [];\n}\n/**\n * Returns the first child in a collection of children and verifies that there\n * is only one child in the collection.\n *\n * See https://reactjs.org/docs/react-api.html#reactchildrenonly\n *\n * The current implementation of this function assumes that a single child gets\n * passed without a wrapper, but the purpose of this helper function is to\n * abstract away the particular structure of children.\n *\n * @param {?object} children Child collection structure.\n * @return {ReactElement} The first and only `ReactElement` contained in the\n * structure.\n */\n\n\nfunction onlyChild(children) {\n if (!isValidElement(children)) {\n throw new Error('React.Children.only expected to receive a single React element child.');\n }\n\n return children;\n}\n\nfunction createContext(defaultValue) {\n // TODO: Second argument used to be an optional `calculateChangedBits`\n // function. Warn to reserve for future use?\n var context = {\n $$typeof: REACT_CONTEXT_TYPE,\n // As a workaround to support multiple concurrent renderers, we categorize\n // some renderers as primary and others as secondary. We only expect\n // there to be two concurrent renderers at most: React Native (primary) and\n // Fabric (secondary); React DOM (primary) and React ART (secondary).\n // Secondary renderers store their context values on separate fields.\n _currentValue: defaultValue,\n _currentValue2: defaultValue,\n // Used to track how many concurrent renderers this context currently\n // supports within in a single renderer. Such as parallel server rendering.\n _threadCount: 0,\n // These are circular\n Provider: null,\n Consumer: null,\n // Add these to use same hidden class in VM as ServerContext\n _defaultValue: null,\n _globalName: null\n };\n context.Provider = {\n $$typeof: REACT_PROVIDER_TYPE,\n _context: context\n };\n var hasWarnedAboutUsingNestedContextConsumers = false;\n var hasWarnedAboutUsingConsumerProvider = false;\n var hasWarnedAboutDisplayNameOnConsumer = false;\n\n {\n // A separate object, but proxies back to the original context object for\n // backwards compatibility. It has a different $$typeof, so we can properly\n // warn for the incorrect usage of Context as a Consumer.\n var Consumer = {\n $$typeof: REACT_CONTEXT_TYPE,\n _context: context\n }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here\n\n Object.defineProperties(Consumer, {\n Provider: {\n get: function () {\n if (!hasWarnedAboutUsingConsumerProvider) {\n hasWarnedAboutUsingConsumerProvider = true;\n\n error('Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?');\n }\n\n return context.Provider;\n },\n set: function (_Provider) {\n context.Provider = _Provider;\n }\n },\n _currentValue: {\n get: function () {\n return context._currentValue;\n },\n set: function (_currentValue) {\n context._currentValue = _currentValue;\n }\n },\n _currentValue2: {\n get: function () {\n return context._currentValue2;\n },\n set: function (_currentValue2) {\n context._currentValue2 = _currentValue2;\n }\n },\n _threadCount: {\n get: function () {\n return context._threadCount;\n },\n set: function (_threadCount) {\n context._threadCount = _threadCount;\n }\n },\n Consumer: {\n get: function () {\n if (!hasWarnedAboutUsingNestedContextConsumers) {\n hasWarnedAboutUsingNestedContextConsumers = true;\n\n error('Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?');\n }\n\n return context.Consumer;\n }\n },\n displayName: {\n get: function () {\n return context.displayName;\n },\n set: function (displayName) {\n if (!hasWarnedAboutDisplayNameOnConsumer) {\n warn('Setting `displayName` on Context.Consumer has no effect. ' + \"You should set it directly on the context with Context.displayName = '%s'.\", displayName);\n\n hasWarnedAboutDisplayNameOnConsumer = true;\n }\n }\n }\n }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty\n\n context.Consumer = Consumer;\n }\n\n {\n context._currentRenderer = null;\n context._currentRenderer2 = null;\n }\n\n return context;\n}\n\nvar Uninitialized = -1;\nvar Pending = 0;\nvar Resolved = 1;\nvar Rejected = 2;\n\nfunction lazyInitializer(payload) {\n if (payload._status === Uninitialized) {\n var ctor = payload._result;\n var thenable = ctor(); // Transition to the next state.\n // This might throw either because it's missing or throws. If so, we treat it\n // as still uninitialized and try again next time. Which is the same as what\n // happens if the ctor or any wrappers processing the ctor throws. This might\n // end up fixing it if the resolution was a concurrency bug.\n\n thenable.then(function (moduleObject) {\n if (payload._status === Pending || payload._status === Uninitialized) {\n // Transition to the next state.\n var resolved = payload;\n resolved._status = Resolved;\n resolved._result = moduleObject;\n }\n }, function (error) {\n if (payload._status === Pending || payload._status === Uninitialized) {\n // Transition to the next state.\n var rejected = payload;\n rejected._status = Rejected;\n rejected._result = error;\n }\n });\n\n if (payload._status === Uninitialized) {\n // In case, we're still uninitialized, then we're waiting for the thenable\n // to resolve. Set it as pending in the meantime.\n var pending = payload;\n pending._status = Pending;\n pending._result = thenable;\n }\n }\n\n if (payload._status === Resolved) {\n var moduleObject = payload._result;\n\n {\n if (moduleObject === undefined) {\n error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\\n\\nYour code should look like: \\n ' + // Break up imports to avoid accidentally parsing them as dependencies.\n 'const MyComponent = lazy(() => imp' + \"ort('./MyComponent'))\\n\\n\" + 'Did you accidentally put curly braces around the import?', moduleObject);\n }\n }\n\n {\n if (!('default' in moduleObject)) {\n error('lazy: Expected the result of a dynamic imp' + 'ort() call. ' + 'Instead received: %s\\n\\nYour code should look like: \\n ' + // Break up imports to avoid accidentally parsing them as dependencies.\n 'const MyComponent = lazy(() => imp' + \"ort('./MyComponent'))\", moduleObject);\n }\n }\n\n return moduleObject.default;\n } else {\n throw payload._result;\n }\n}\n\nfunction lazy(ctor) {\n var payload = {\n // We use these fields to store the result.\n _status: Uninitialized,\n _result: ctor\n };\n var lazyType = {\n $$typeof: REACT_LAZY_TYPE,\n _payload: payload,\n _init: lazyInitializer\n };\n\n {\n // In production, this would just set it on the object.\n var defaultProps;\n var propTypes; // $FlowFixMe\n\n Object.defineProperties(lazyType, {\n defaultProps: {\n configurable: true,\n get: function () {\n return defaultProps;\n },\n set: function (newDefaultProps) {\n error('React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');\n\n defaultProps = newDefaultProps; // Match production behavior more closely:\n // $FlowFixMe\n\n Object.defineProperty(lazyType, 'defaultProps', {\n enumerable: true\n });\n }\n },\n propTypes: {\n configurable: true,\n get: function () {\n return propTypes;\n },\n set: function (newPropTypes) {\n error('React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');\n\n propTypes = newPropTypes; // Match production behavior more closely:\n // $FlowFixMe\n\n Object.defineProperty(lazyType, 'propTypes', {\n enumerable: true\n });\n }\n }\n });\n }\n\n return lazyType;\n}\n\nfunction forwardRef(render) {\n {\n if (render != null && render.$$typeof === REACT_MEMO_TYPE) {\n error('forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).');\n } else if (typeof render !== 'function') {\n error('forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);\n } else {\n if (render.length !== 0 && render.length !== 2) {\n error('forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.');\n }\n }\n\n if (render != null) {\n if (render.defaultProps != null || render.propTypes != null) {\n error('forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?');\n }\n }\n }\n\n var elementType = {\n $$typeof: REACT_FORWARD_REF_TYPE,\n render: render\n };\n\n {\n var ownName;\n Object.defineProperty(elementType, 'displayName', {\n enumerable: false,\n configurable: true,\n get: function () {\n return ownName;\n },\n set: function (name) {\n ownName = name; // The inner component shouldn't inherit this display name in most cases,\n // because the component may be used elsewhere.\n // But it's nice for anonymous functions to inherit the name,\n // so that our component-stack generation logic will display their frames.\n // An anonymous function generally suggests a pattern like:\n // React.forwardRef((props, ref) => {...});\n // This kind of inner function is not used elsewhere so the side effect is okay.\n\n if (!render.name && !render.displayName) {\n render.displayName = name;\n }\n }\n });\n }\n\n return elementType;\n}\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction memo(type, compare) {\n {\n if (!isValidElementType(type)) {\n error('memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);\n }\n }\n\n var elementType = {\n $$typeof: REACT_MEMO_TYPE,\n type: type,\n compare: compare === undefined ? null : compare\n };\n\n {\n var ownName;\n Object.defineProperty(elementType, 'displayName', {\n enumerable: false,\n configurable: true,\n get: function () {\n return ownName;\n },\n set: function (name) {\n ownName = name; // The inner component shouldn't inherit this display name in most cases,\n // because the component may be used elsewhere.\n // But it's nice for anonymous functions to inherit the name,\n // so that our component-stack generation logic will display their frames.\n // An anonymous function generally suggests a pattern like:\n // React.memo((props) => {...});\n // This kind of inner function is not used elsewhere so the side effect is okay.\n\n if (!type.name && !type.displayName) {\n type.displayName = name;\n }\n }\n });\n }\n\n return elementType;\n}\n\nfunction resolveDispatcher() {\n var dispatcher = ReactCurrentDispatcher.current;\n\n {\n if (dispatcher === null) {\n error('Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for' + ' one of the following reasons:\\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\\n' + '2. You might be breaking the Rules of Hooks\\n' + '3. You might have more than one copy of React in the same app\\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');\n }\n } // Will result in a null access error if accessed outside render phase. We\n // intentionally don't throw our own error because this is in a hot path.\n // Also helps ensure this is inlined.\n\n\n return dispatcher;\n}\nfunction useContext(Context) {\n var dispatcher = resolveDispatcher();\n\n {\n // TODO: add a more generic warning for invalid values.\n if (Context._context !== undefined) {\n var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs\n // and nobody should be using this in existing code.\n\n if (realContext.Consumer === Context) {\n error('Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');\n } else if (realContext.Provider === Context) {\n error('Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?');\n }\n }\n }\n\n return dispatcher.useContext(Context);\n}\nfunction useState(initialState) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useState(initialState);\n}\nfunction useReducer(reducer, initialArg, init) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useReducer(reducer, initialArg, init);\n}\nfunction useRef(initialValue) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useRef(initialValue);\n}\nfunction useEffect(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useEffect(create, deps);\n}\nfunction useInsertionEffect(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useInsertionEffect(create, deps);\n}\nfunction useLayoutEffect(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useLayoutEffect(create, deps);\n}\nfunction useCallback(callback, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useCallback(callback, deps);\n}\nfunction useMemo(create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useMemo(create, deps);\n}\nfunction useImperativeHandle(ref, create, deps) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useImperativeHandle(ref, create, deps);\n}\nfunction useDebugValue(value, formatterFn) {\n {\n var dispatcher = resolveDispatcher();\n return dispatcher.useDebugValue(value, formatterFn);\n }\n}\nfunction useTransition() {\n var dispatcher = resolveDispatcher();\n return dispatcher.useTransition();\n}\nfunction useDeferredValue(value) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useDeferredValue(value);\n}\nfunction useId() {\n var dispatcher = resolveDispatcher();\n return dispatcher.useId();\n}\nfunction useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {\n var dispatcher = resolveDispatcher();\n return dispatcher.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n}\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher$1.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher$1.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('')) {\n _frame = _frame.replace('', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher$1.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n setExtraStackFrame(stack);\n } else {\n setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n\nfunction getDeclarationErrorAddendum() {\n if (ReactCurrentOwner.current) {\n var name = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n}\n\nfunction getSourceInfoErrorAddendumForProps(elementProps) {\n if (elementProps !== null && elementProps !== undefined) {\n return getSourceInfoErrorAddendum(elementProps.__source);\n }\n\n return '';\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n {\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\nfunction createElementWithValidation(type, props, children) {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendumForProps(props);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n {\n error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n }\n\n var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n for (var i = 2; i < arguments.length; i++) {\n validateChildKeys(arguments[i], type);\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n}\nvar didWarnAboutDeprecatedCreateFactory = false;\nfunction createFactoryWithValidation(type) {\n var validatedFactory = createElementWithValidation.bind(null, type);\n validatedFactory.type = type;\n\n {\n if (!didWarnAboutDeprecatedCreateFactory) {\n didWarnAboutDeprecatedCreateFactory = true;\n\n warn('React.createFactory() is deprecated and will be removed in ' + 'a future major release. Consider using JSX ' + 'or use React.createElement() directly instead.');\n } // Legacy hook: remove it\n\n\n Object.defineProperty(validatedFactory, 'type', {\n enumerable: false,\n get: function () {\n warn('Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');\n\n Object.defineProperty(this, 'type', {\n value: type\n });\n return type;\n }\n });\n }\n\n return validatedFactory;\n}\nfunction cloneElementWithValidation(element, props, children) {\n var newElement = cloneElement.apply(this, arguments);\n\n for (var i = 2; i < arguments.length; i++) {\n validateChildKeys(arguments[i], newElement.type);\n }\n\n validatePropTypes(newElement);\n return newElement;\n}\n\nfunction startTransition(scope, options) {\n var prevTransition = ReactCurrentBatchConfig.transition;\n ReactCurrentBatchConfig.transition = {};\n var currentTransition = ReactCurrentBatchConfig.transition;\n\n {\n ReactCurrentBatchConfig.transition._updatedFibers = new Set();\n }\n\n try {\n scope();\n } finally {\n ReactCurrentBatchConfig.transition = prevTransition;\n\n {\n if (prevTransition === null && currentTransition._updatedFibers) {\n var updatedFibersCount = currentTransition._updatedFibers.size;\n\n if (updatedFibersCount > 10) {\n warn('Detected a large number of updates inside startTransition. ' + 'If this is due to a subscription please re-write it to use React provided hooks. ' + 'Otherwise concurrent mode guarantees are off the table.');\n }\n\n currentTransition._updatedFibers.clear();\n }\n }\n }\n}\n\nvar didWarnAboutMessageChannel = false;\nvar enqueueTaskImpl = null;\nfunction enqueueTask(task) {\n if (enqueueTaskImpl === null) {\n try {\n // read require off the module object to get around the bundlers.\n // we don't want them to detect a require and bundle a Node polyfill.\n var requireString = ('require' + Math.random()).slice(0, 7);\n var nodeRequire = module && module[requireString]; // assuming we're in node, let's try to get node's\n // version of setImmediate, bypassing fake timers if any.\n\n enqueueTaskImpl = nodeRequire.call(module, 'timers').setImmediate;\n } catch (_err) {\n // we're in a browser\n // we can't use regular timers because they may still be faked\n // so we try MessageChannel+postMessage instead\n enqueueTaskImpl = function (callback) {\n {\n if (didWarnAboutMessageChannel === false) {\n didWarnAboutMessageChannel = true;\n\n if (typeof MessageChannel === 'undefined') {\n error('This browser does not have a MessageChannel implementation, ' + 'so enqueuing tasks via await act(async () => ...) will fail. ' + 'Please file an issue at https://github.com/facebook/react/issues ' + 'if you encounter this warning.');\n }\n }\n }\n\n var channel = new MessageChannel();\n channel.port1.onmessage = callback;\n channel.port2.postMessage(undefined);\n };\n }\n }\n\n return enqueueTaskImpl(task);\n}\n\nvar actScopeDepth = 0;\nvar didWarnNoAwaitAct = false;\nfunction act(callback) {\n {\n // `act` calls can be nested, so we track the depth. This represents the\n // number of `act` scopes on the stack.\n var prevActScopeDepth = actScopeDepth;\n actScopeDepth++;\n\n if (ReactCurrentActQueue.current === null) {\n // This is the outermost `act` scope. Initialize the queue. The reconciler\n // will detect the queue and use it instead of Scheduler.\n ReactCurrentActQueue.current = [];\n }\n\n var prevIsBatchingLegacy = ReactCurrentActQueue.isBatchingLegacy;\n var result;\n\n try {\n // Used to reproduce behavior of `batchedUpdates` in legacy mode. Only\n // set to `true` while the given callback is executed, not for updates\n // triggered during an async event, because this is how the legacy\n // implementation of `act` behaved.\n ReactCurrentActQueue.isBatchingLegacy = true;\n result = callback(); // Replicate behavior of original `act` implementation in legacy mode,\n // which flushed updates immediately after the scope function exits, even\n // if it's an async function.\n\n if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {\n var queue = ReactCurrentActQueue.current;\n\n if (queue !== null) {\n ReactCurrentActQueue.didScheduleLegacyUpdate = false;\n flushActQueue(queue);\n }\n }\n } catch (error) {\n popActScope(prevActScopeDepth);\n throw error;\n } finally {\n ReactCurrentActQueue.isBatchingLegacy = prevIsBatchingLegacy;\n }\n\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n var thenableResult = result; // The callback is an async function (i.e. returned a promise). Wait\n // for it to resolve before exiting the current scope.\n\n var wasAwaited = false;\n var thenable = {\n then: function (resolve, reject) {\n wasAwaited = true;\n thenableResult.then(function (returnValue) {\n popActScope(prevActScopeDepth);\n\n if (actScopeDepth === 0) {\n // We've exited the outermost act scope. Recursively flush the\n // queue until there's no remaining work.\n recursivelyFlushAsyncActWork(returnValue, resolve, reject);\n } else {\n resolve(returnValue);\n }\n }, function (error) {\n // The callback threw an error.\n popActScope(prevActScopeDepth);\n reject(error);\n });\n }\n };\n\n {\n if (!didWarnNoAwaitAct && typeof Promise !== 'undefined') {\n // eslint-disable-next-line no-undef\n Promise.resolve().then(function () {}).then(function () {\n if (!wasAwaited) {\n didWarnNoAwaitAct = true;\n\n error('You called act(async () => ...) without await. ' + 'This could lead to unexpected testing behaviour, ' + 'interleaving multiple act calls and mixing their ' + 'scopes. ' + 'You should - await act(async () => ...);');\n }\n });\n }\n }\n\n return thenable;\n } else {\n var returnValue = result; // The callback is not an async function. Exit the current scope\n // immediately, without awaiting.\n\n popActScope(prevActScopeDepth);\n\n if (actScopeDepth === 0) {\n // Exiting the outermost act scope. Flush the queue.\n var _queue = ReactCurrentActQueue.current;\n\n if (_queue !== null) {\n flushActQueue(_queue);\n ReactCurrentActQueue.current = null;\n } // Return a thenable. If the user awaits it, we'll flush again in\n // case additional work was scheduled by a microtask.\n\n\n var _thenable = {\n then: function (resolve, reject) {\n // Confirm we haven't re-entered another `act` scope, in case\n // the user does something weird like await the thenable\n // multiple times.\n if (ReactCurrentActQueue.current === null) {\n // Recursively flush the queue until there's no remaining work.\n ReactCurrentActQueue.current = [];\n recursivelyFlushAsyncActWork(returnValue, resolve, reject);\n } else {\n resolve(returnValue);\n }\n }\n };\n return _thenable;\n } else {\n // Since we're inside a nested `act` scope, the returned thenable\n // immediately resolves. The outer scope will flush the queue.\n var _thenable2 = {\n then: function (resolve, reject) {\n resolve(returnValue);\n }\n };\n return _thenable2;\n }\n }\n }\n}\n\nfunction popActScope(prevActScopeDepth) {\n {\n if (prevActScopeDepth !== actScopeDepth - 1) {\n error('You seem to have overlapping act() calls, this is not supported. ' + 'Be sure to await previous act() calls before making a new one. ');\n }\n\n actScopeDepth = prevActScopeDepth;\n }\n}\n\nfunction recursivelyFlushAsyncActWork(returnValue, resolve, reject) {\n {\n var queue = ReactCurrentActQueue.current;\n\n if (queue !== null) {\n try {\n flushActQueue(queue);\n enqueueTask(function () {\n if (queue.length === 0) {\n // No additional work was scheduled. Finish.\n ReactCurrentActQueue.current = null;\n resolve(returnValue);\n } else {\n // Keep flushing work until there's none left.\n recursivelyFlushAsyncActWork(returnValue, resolve, reject);\n }\n });\n } catch (error) {\n reject(error);\n }\n } else {\n resolve(returnValue);\n }\n }\n}\n\nvar isFlushing = false;\n\nfunction flushActQueue(queue) {\n {\n if (!isFlushing) {\n // Prevent re-entrance.\n isFlushing = true;\n var i = 0;\n\n try {\n for (; i < queue.length; i++) {\n var callback = queue[i];\n\n do {\n callback = callback(true);\n } while (callback !== null);\n }\n\n queue.length = 0;\n } catch (error) {\n // If something throws, leave the remaining callbacks on the queue.\n queue = queue.slice(i + 1);\n throw error;\n } finally {\n isFlushing = false;\n }\n }\n }\n}\n\nvar createElement$1 = createElementWithValidation ;\nvar cloneElement$1 = cloneElementWithValidation ;\nvar createFactory = createFactoryWithValidation ;\nvar Children = {\n map: mapChildren,\n forEach: forEachChildren,\n count: countChildren,\n toArray: toArray,\n only: onlyChild\n};\n\nexports.Children = Children;\nexports.Component = Component;\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.Profiler = REACT_PROFILER_TYPE;\nexports.PureComponent = PureComponent;\nexports.StrictMode = REACT_STRICT_MODE_TYPE;\nexports.Suspense = REACT_SUSPENSE_TYPE;\nexports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;\nexports.act = act;\nexports.cloneElement = cloneElement$1;\nexports.createContext = createContext;\nexports.createElement = createElement$1;\nexports.createFactory = createFactory;\nexports.createRef = createRef;\nexports.forwardRef = forwardRef;\nexports.isValidElement = isValidElement;\nexports.lazy = lazy;\nexports.memo = memo;\nexports.startTransition = startTransition;\nexports.unstable_act = act;\nexports.useCallback = useCallback;\nexports.useContext = useContext;\nexports.useDebugValue = useDebugValue;\nexports.useDeferredValue = useDeferredValue;\nexports.useEffect = useEffect;\nexports.useId = useId;\nexports.useImperativeHandle = useImperativeHandle;\nexports.useInsertionEffect = useInsertionEffect;\nexports.useLayoutEffect = useLayoutEffect;\nexports.useMemo = useMemo;\nexports.useReducer = useReducer;\nexports.useRef = useRef;\nexports.useState = useState;\nexports.useSyncExternalStore = useSyncExternalStore;\nexports.useTransition = useTransition;\nexports.version = ReactVersion;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react.production.min.js');\n} else {\n module.exports = require('./cjs/react.development.js');\n}\n","/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n'use strict';\n\nvar React = require('react');\n\n// ATTENTION\n// When adding new symbols to this file,\n// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'\n// The Symbol used to tag the ReactElement-like types.\nvar REACT_ELEMENT_TYPE = Symbol.for('react.element');\nvar REACT_PORTAL_TYPE = Symbol.for('react.portal');\nvar REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');\nvar REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');\nvar REACT_PROFILER_TYPE = Symbol.for('react.profiler');\nvar REACT_PROVIDER_TYPE = Symbol.for('react.provider');\nvar REACT_CONTEXT_TYPE = Symbol.for('react.context');\nvar REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');\nvar REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');\nvar REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');\nvar REACT_MEMO_TYPE = Symbol.for('react.memo');\nvar REACT_LAZY_TYPE = Symbol.for('react.lazy');\nvar REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');\nvar MAYBE_ITERATOR_SYMBOL = Symbol.iterator;\nvar FAUX_ITERATOR_SYMBOL = '@@iterator';\nfunction getIteratorFn(maybeIterable) {\n if (maybeIterable === null || typeof maybeIterable !== 'object') {\n return null;\n }\n\n var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];\n\n if (typeof maybeIterator === 'function') {\n return maybeIterator;\n }\n\n return null;\n}\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nfunction error(format) {\n {\n {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\n// -----------------------------------------------------------------------------\n\nvar enableScopeAPI = false; // Experimental Create Event Handle API.\nvar enableCacheElement = false;\nvar enableTransitionTracing = false; // No known bugs, but needs performance testing\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n// stuff. Intended to enable React core members to more easily debug scheduling\n// issues in DEV builds.\n\nvar enableDebugTracing = false; // Track which Fiber(s) schedule render work.\n\nvar REACT_MODULE_REFERENCE;\n\n{\n REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');\n}\n\nfunction isValidElementType(type) {\n if (typeof type === 'string' || typeof type === 'function') {\n return true;\n } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).\n\n\n if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {\n return true;\n }\n\n if (typeof type === 'object' && type !== null) {\n if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object\n // types supported by any Flight configuration anywhere since\n // we don't know which Flight build this will end up being used\n // with.\n type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction getWrappedName(outerType, innerType, wrapperName) {\n var displayName = outerType.displayName;\n\n if (displayName) {\n return displayName;\n }\n\n var functionName = innerType.displayName || innerType.name || '';\n return functionName !== '' ? wrapperName + \"(\" + functionName + \")\" : wrapperName;\n} // Keep in sync with react-reconciler/getComponentNameFromFiber\n\n\nfunction getContextName(type) {\n return type.displayName || 'Context';\n} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.\n\n\nfunction getComponentNameFromType(type) {\n if (type == null) {\n // Host root, text node or just invalid type.\n return null;\n }\n\n {\n if (typeof type.tag === 'number') {\n error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');\n }\n }\n\n if (typeof type === 'function') {\n return type.displayName || type.name || null;\n }\n\n if (typeof type === 'string') {\n return type;\n }\n\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return 'Fragment';\n\n case REACT_PORTAL_TYPE:\n return 'Portal';\n\n case REACT_PROFILER_TYPE:\n return 'Profiler';\n\n case REACT_STRICT_MODE_TYPE:\n return 'StrictMode';\n\n case REACT_SUSPENSE_TYPE:\n return 'Suspense';\n\n case REACT_SUSPENSE_LIST_TYPE:\n return 'SuspenseList';\n\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_CONTEXT_TYPE:\n var context = type;\n return getContextName(context) + '.Consumer';\n\n case REACT_PROVIDER_TYPE:\n var provider = type;\n return getContextName(provider._context) + '.Provider';\n\n case REACT_FORWARD_REF_TYPE:\n return getWrappedName(type, type.render, 'ForwardRef');\n\n case REACT_MEMO_TYPE:\n var outerName = type.displayName || null;\n\n if (outerName !== null) {\n return outerName;\n }\n\n return getComponentNameFromType(type.type) || 'Memo';\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n return getComponentNameFromType(init(payload));\n } catch (x) {\n return null;\n }\n }\n\n // eslint-disable-next-line no-fallthrough\n }\n }\n\n return null;\n}\n\nvar assign = Object.assign;\n\n// Helpers to patch console.logs to avoid logging during side-effect free\n// replaying on render function. This currently only patches the object\n// lazily which won't cover if the log function was extracted eagerly.\n// We could also eagerly patch the method.\nvar disabledDepth = 0;\nvar prevLog;\nvar prevInfo;\nvar prevWarn;\nvar prevError;\nvar prevGroup;\nvar prevGroupCollapsed;\nvar prevGroupEnd;\n\nfunction disabledLog() {}\n\ndisabledLog.__reactDisabledLog = true;\nfunction disableLogs() {\n {\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n prevLog = console.log;\n prevInfo = console.info;\n prevWarn = console.warn;\n prevError = console.error;\n prevGroup = console.group;\n prevGroupCollapsed = console.groupCollapsed;\n prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099\n\n var props = {\n configurable: true,\n enumerable: true,\n value: disabledLog,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n info: props,\n log: props,\n warn: props,\n error: props,\n group: props,\n groupCollapsed: props,\n groupEnd: props\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n disabledDepth++;\n }\n}\nfunction reenableLogs() {\n {\n disabledDepth--;\n\n if (disabledDepth === 0) {\n /* eslint-disable react-internal/no-production-logging */\n var props = {\n configurable: true,\n enumerable: true,\n writable: true\n }; // $FlowFixMe Flow thinks console is immutable.\n\n Object.defineProperties(console, {\n log: assign({}, props, {\n value: prevLog\n }),\n info: assign({}, props, {\n value: prevInfo\n }),\n warn: assign({}, props, {\n value: prevWarn\n }),\n error: assign({}, props, {\n value: prevError\n }),\n group: assign({}, props, {\n value: prevGroup\n }),\n groupCollapsed: assign({}, props, {\n value: prevGroupCollapsed\n }),\n groupEnd: assign({}, props, {\n value: prevGroupEnd\n })\n });\n /* eslint-enable react-internal/no-production-logging */\n }\n\n if (disabledDepth < 0) {\n error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');\n }\n }\n}\n\nvar ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;\nvar prefix;\nfunction describeBuiltInComponentFrame(name, source, ownerFn) {\n {\n if (prefix === undefined) {\n // Extract the VM specific prefix used by each line.\n try {\n throw Error();\n } catch (x) {\n var match = x.stack.trim().match(/\\n( *(at )?)/);\n prefix = match && match[1] || '';\n }\n } // We use the prefix to ensure our stacks line up with native stack frames.\n\n\n return '\\n' + prefix + name;\n }\n}\nvar reentry = false;\nvar componentFrameCache;\n\n{\n var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;\n componentFrameCache = new PossiblyWeakMap();\n}\n\nfunction describeNativeComponentFrame(fn, construct) {\n // If something asked for a stack inside a fake render, it should get ignored.\n if ( !fn || reentry) {\n return '';\n }\n\n {\n var frame = componentFrameCache.get(fn);\n\n if (frame !== undefined) {\n return frame;\n }\n }\n\n var control;\n reentry = true;\n var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.\n\n Error.prepareStackTrace = undefined;\n var previousDispatcher;\n\n {\n previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function\n // for warnings.\n\n ReactCurrentDispatcher.current = null;\n disableLogs();\n }\n\n try {\n // This should throw.\n if (construct) {\n // Something should be setting the props in the constructor.\n var Fake = function () {\n throw Error();\n }; // $FlowFixMe\n\n\n Object.defineProperty(Fake.prototype, 'props', {\n set: function () {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n throw Error();\n }\n });\n\n if (typeof Reflect === 'object' && Reflect.construct) {\n // We construct a different control for this case to include any extra\n // frames added by the construct call.\n try {\n Reflect.construct(Fake, []);\n } catch (x) {\n control = x;\n }\n\n Reflect.construct(fn, [], Fake);\n } else {\n try {\n Fake.call();\n } catch (x) {\n control = x;\n }\n\n fn.call(Fake.prototype);\n }\n } else {\n try {\n throw Error();\n } catch (x) {\n control = x;\n }\n\n fn();\n }\n } catch (sample) {\n // This is inlined manually because closure doesn't do it for us.\n if (sample && control && typeof sample.stack === 'string') {\n // This extracts the first frame from the sample that isn't also in the control.\n // Skipping one frame that we assume is the frame that calls the two.\n var sampleLines = sample.stack.split('\\n');\n var controlLines = control.stack.split('\\n');\n var s = sampleLines.length - 1;\n var c = controlLines.length - 1;\n\n while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {\n // We expect at least one stack frame to be shared.\n // Typically this will be the root most one. However, stack frames may be\n // cut off due to maximum stack limits. In this case, one maybe cut off\n // earlier than the other. We assume that the sample is longer or the same\n // and there for cut off earlier. So we should find the root most frame in\n // the sample somewhere in the control.\n c--;\n }\n\n for (; s >= 1 && c >= 0; s--, c--) {\n // Next we find the first one that isn't the same which should be the\n // frame that called our sample function and the control.\n if (sampleLines[s] !== controlLines[c]) {\n // In V8, the first line is describing the message but other VMs don't.\n // If we're about to return the first line, and the control is also on the same\n // line, that's a pretty good indicator that our sample threw at same line as\n // the control. I.e. before we entered the sample frame. So we ignore this result.\n // This can happen if you passed a class to function component, or non-function.\n if (s !== 1 || c !== 1) {\n do {\n s--;\n c--; // We may still have similar intermediate frames from the construct call.\n // The next one that isn't the same should be our match though.\n\n if (c < 0 || sampleLines[s] !== controlLines[c]) {\n // V8 adds a \"new\" prefix for native classes. Let's remove it to make it prettier.\n var _frame = '\\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled \"\"\n // but we have a user-provided \"displayName\"\n // splice it in to make the stack more readable.\n\n\n if (fn.displayName && _frame.includes('')) {\n _frame = _frame.replace('', fn.displayName);\n }\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, _frame);\n }\n } // Return the line we found.\n\n\n return _frame;\n }\n } while (s >= 1 && c >= 0);\n }\n\n break;\n }\n }\n }\n } finally {\n reentry = false;\n\n {\n ReactCurrentDispatcher.current = previousDispatcher;\n reenableLogs();\n }\n\n Error.prepareStackTrace = previousPrepareStackTrace;\n } // Fallback to just using the name if we couldn't make it throw.\n\n\n var name = fn ? fn.displayName || fn.name : '';\n var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';\n\n {\n if (typeof fn === 'function') {\n componentFrameCache.set(fn, syntheticFrame);\n }\n }\n\n return syntheticFrame;\n}\nfunction describeFunctionComponentFrame(fn, source, ownerFn) {\n {\n return describeNativeComponentFrame(fn, false);\n }\n}\n\nfunction shouldConstruct(Component) {\n var prototype = Component.prototype;\n return !!(prototype && prototype.isReactComponent);\n}\n\nfunction describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {\n\n if (type == null) {\n return '';\n }\n\n if (typeof type === 'function') {\n {\n return describeNativeComponentFrame(type, shouldConstruct(type));\n }\n }\n\n if (typeof type === 'string') {\n return describeBuiltInComponentFrame(type);\n }\n\n switch (type) {\n case REACT_SUSPENSE_TYPE:\n return describeBuiltInComponentFrame('Suspense');\n\n case REACT_SUSPENSE_LIST_TYPE:\n return describeBuiltInComponentFrame('SuspenseList');\n }\n\n if (typeof type === 'object') {\n switch (type.$$typeof) {\n case REACT_FORWARD_REF_TYPE:\n return describeFunctionComponentFrame(type.render);\n\n case REACT_MEMO_TYPE:\n // Memo may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);\n\n case REACT_LAZY_TYPE:\n {\n var lazyComponent = type;\n var payload = lazyComponent._payload;\n var init = lazyComponent._init;\n\n try {\n // Lazy may contain any component type so we recursively resolve it.\n return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);\n } catch (x) {}\n }\n }\n }\n\n return '';\n}\n\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\n\nvar loggedTypeFailures = {};\nvar ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame.setExtraStackFrame(null);\n }\n }\n}\n\nfunction checkPropTypes(typeSpecs, values, location, componentName, element) {\n {\n // $FlowFixMe This is okay but Flow doesn't know it.\n var has = Function.call.bind(hasOwnProperty);\n\n for (var typeSpecName in typeSpecs) {\n if (has(typeSpecs, typeSpecName)) {\n var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to\n // fail the render phase where it didn't fail before. So we log it.\n // After these have been cleaned up, we'll let them throw.\n\n try {\n // This is intentionally an invariant that gets caught. It's the same\n // behavior as without this statement except with a better message.\n if (typeof typeSpecs[typeSpecName] !== 'function') {\n // eslint-disable-next-line react-internal/prod-error-codes\n var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');\n err.name = 'Invariant Violation';\n throw err;\n }\n\n error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');\n } catch (ex) {\n error$1 = ex;\n }\n\n if (error$1 && !(error$1 instanceof Error)) {\n setCurrentlyValidatingElement(element);\n\n error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);\n\n setCurrentlyValidatingElement(null);\n }\n\n if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {\n // Only monitor this failure once because there tends to be a lot of the\n // same error.\n loggedTypeFailures[error$1.message] = true;\n setCurrentlyValidatingElement(element);\n\n error('Failed %s type: %s', location, error$1.message);\n\n setCurrentlyValidatingElement(null);\n }\n }\n }\n }\n}\n\nvar isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare\n\nfunction isArray(a) {\n return isArrayImpl(a);\n}\n\n/*\n * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol\n * and Temporal.* types. See https://github.com/facebook/react/pull/22064.\n *\n * The functions in this module will throw an easier-to-understand,\n * easier-to-debug exception with a clear errors message message explaining the\n * problem. (Instead of a confusing exception thrown inside the implementation\n * of the `value` object).\n */\n// $FlowFixMe only called in DEV, so void return is not possible.\nfunction typeName(value) {\n {\n // toStringTag is needed for namespaced types like Temporal.Instant\n var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;\n var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';\n return type;\n }\n} // $FlowFixMe only called in DEV, so void return is not possible.\n\n\nfunction willCoercionThrow(value) {\n {\n try {\n testStringCoercion(value);\n return false;\n } catch (e) {\n return true;\n }\n }\n}\n\nfunction testStringCoercion(value) {\n // If you ended up here by following an exception call stack, here's what's\n // happened: you supplied an object or symbol value to React (as a prop, key,\n // DOM attribute, CSS property, string ref, etc.) and when React tried to\n // coerce it to a string using `'' + value`, an exception was thrown.\n //\n // The most common types that will cause this exception are `Symbol` instances\n // and Temporal objects like `Temporal.Instant`. But any object that has a\n // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this\n // exception. (Library authors do this to prevent users from using built-in\n // numeric operators like `+` or comparison operators like `>=` because custom\n // methods are needed to perform accurate arithmetic or comparison.)\n //\n // To fix the problem, coerce this object or symbol value to a string before\n // passing it to React. The most reliable way is usually `String(value)`.\n //\n // To find which value is throwing, check the browser or debugger console.\n // Before this exception was thrown, there should be `console.error` output\n // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the\n // problem and how that type was used: key, atrribute, input value prop, etc.\n // In most cases, this console output also shows the component and its\n // ancestor components where the exception happened.\n //\n // eslint-disable-next-line react-internal/safe-string-coercion\n return '' + value;\n}\nfunction checkKeyStringCoercion(value) {\n {\n if (willCoercionThrow(value)) {\n error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));\n\n return testStringCoercion(value); // throw (to help callers find troubleshooting comments)\n }\n }\n}\n\nvar ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;\nvar RESERVED_PROPS = {\n key: true,\n ref: true,\n __self: true,\n __source: true\n};\nvar specialPropKeyWarningShown;\nvar specialPropRefWarningShown;\nvar didWarnAboutStringRefs;\n\n{\n didWarnAboutStringRefs = {};\n}\n\nfunction hasValidRef(config) {\n {\n if (hasOwnProperty.call(config, 'ref')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.ref !== undefined;\n}\n\nfunction hasValidKey(config) {\n {\n if (hasOwnProperty.call(config, 'key')) {\n var getter = Object.getOwnPropertyDescriptor(config, 'key').get;\n\n if (getter && getter.isReactWarning) {\n return false;\n }\n }\n }\n\n return config.key !== undefined;\n}\n\nfunction warnIfStringRefCannotBeAutoConverted(config, self) {\n {\n if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {\n var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);\n\n if (!didWarnAboutStringRefs[componentName]) {\n error('Component \"%s\" contains the string ref \"%s\". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);\n\n didWarnAboutStringRefs[componentName] = true;\n }\n }\n }\n}\n\nfunction defineKeyPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingKey = function () {\n if (!specialPropKeyWarningShown) {\n specialPropKeyWarningShown = true;\n\n error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingKey.isReactWarning = true;\n Object.defineProperty(props, 'key', {\n get: warnAboutAccessingKey,\n configurable: true\n });\n }\n}\n\nfunction defineRefPropWarningGetter(props, displayName) {\n {\n var warnAboutAccessingRef = function () {\n if (!specialPropRefWarningShown) {\n specialPropRefWarningShown = true;\n\n error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);\n }\n };\n\n warnAboutAccessingRef.isReactWarning = true;\n Object.defineProperty(props, 'ref', {\n get: warnAboutAccessingRef,\n configurable: true\n });\n }\n}\n/**\n * Factory method to create a new React element. This no longer adheres to\n * the class pattern, so do not use new to call it. Also, instanceof check\n * will not work. Instead test $$typeof field against Symbol.for('react.element') to check\n * if something is a React Element.\n *\n * @param {*} type\n * @param {*} props\n * @param {*} key\n * @param {string|object} ref\n * @param {*} owner\n * @param {*} self A *temporary* helper to detect places where `this` is\n * different from the `owner` when React.createElement is called, so that we\n * can warn. We want to get rid of owner and replace string `ref`s with arrow\n * functions, and as long as `this` and owner are the same, there will be no\n * change in behavior.\n * @param {*} source An annotation object (added by a transpiler or otherwise)\n * indicating filename, line number, and/or other information.\n * @internal\n */\n\n\nvar ReactElement = function (type, key, ref, self, source, owner, props) {\n var element = {\n // This tag allows us to uniquely identify this as a React Element\n $$typeof: REACT_ELEMENT_TYPE,\n // Built-in properties that belong on the element\n type: type,\n key: key,\n ref: ref,\n props: props,\n // Record the component responsible for creating this element.\n _owner: owner\n };\n\n {\n // The validation flag is currently mutative. We put it on\n // an external backing store so that we can freeze the whole object.\n // This can be replaced with a WeakMap once they are implemented in\n // commonly used development environments.\n element._store = {}; // To make comparing ReactElements easier for testing purposes, we make\n // the validation flag non-enumerable (where possible, which should\n // include every environment we run tests in), so the test framework\n // ignores it.\n\n Object.defineProperty(element._store, 'validated', {\n configurable: false,\n enumerable: false,\n writable: true,\n value: false\n }); // self and source are DEV only properties.\n\n Object.defineProperty(element, '_self', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: self\n }); // Two elements created in two different places should be considered\n // equal for testing purposes and therefore we hide it from enumeration.\n\n Object.defineProperty(element, '_source', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: source\n });\n\n if (Object.freeze) {\n Object.freeze(element.props);\n Object.freeze(element);\n }\n }\n\n return element;\n};\n/**\n * https://github.com/reactjs/rfcs/pull/107\n * @param {*} type\n * @param {object} props\n * @param {string} key\n */\n\nfunction jsxDEV(type, config, maybeKey, source, self) {\n {\n var propName; // Reserved names are extracted\n\n var props = {};\n var key = null;\n var ref = null; // Currently, key can be spread in as a prop. This causes a potential\n // issue if key is also explicitly declared (ie.
\n // or
). We want to deprecate key spread,\n // but as an intermediary step, we will use jsxDEV for everything except\n //
, because we aren't currently able to tell if\n // key is explicitly declared to be undefined or not.\n\n if (maybeKey !== undefined) {\n {\n checkKeyStringCoercion(maybeKey);\n }\n\n key = '' + maybeKey;\n }\n\n if (hasValidKey(config)) {\n {\n checkKeyStringCoercion(config.key);\n }\n\n key = '' + config.key;\n }\n\n if (hasValidRef(config)) {\n ref = config.ref;\n warnIfStringRefCannotBeAutoConverted(config, self);\n } // Remaining properties are added to a new props object\n\n\n for (propName in config) {\n if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {\n props[propName] = config[propName];\n }\n } // Resolve default props\n\n\n if (type && type.defaultProps) {\n var defaultProps = type.defaultProps;\n\n for (propName in defaultProps) {\n if (props[propName] === undefined) {\n props[propName] = defaultProps[propName];\n }\n }\n }\n\n if (key || ref) {\n var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;\n\n if (key) {\n defineKeyPropWarningGetter(props, displayName);\n }\n\n if (ref) {\n defineRefPropWarningGetter(props, displayName);\n }\n }\n\n return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);\n }\n}\n\nvar ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;\nvar ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;\n\nfunction setCurrentlyValidatingElement$1(element) {\n {\n if (element) {\n var owner = element._owner;\n var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);\n ReactDebugCurrentFrame$1.setExtraStackFrame(stack);\n } else {\n ReactDebugCurrentFrame$1.setExtraStackFrame(null);\n }\n }\n}\n\nvar propTypesMisspellWarningShown;\n\n{\n propTypesMisspellWarningShown = false;\n}\n/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param {?object} object\n * @return {boolean} True if `object` is a ReactElement.\n * @final\n */\n\n\nfunction isValidElement(object) {\n {\n return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;\n }\n}\n\nfunction getDeclarationErrorAddendum() {\n {\n if (ReactCurrentOwner$1.current) {\n var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);\n\n if (name) {\n return '\\n\\nCheck the render method of `' + name + '`.';\n }\n }\n\n return '';\n }\n}\n\nfunction getSourceInfoErrorAddendum(source) {\n {\n if (source !== undefined) {\n var fileName = source.fileName.replace(/^.*[\\\\\\/]/, '');\n var lineNumber = source.lineNumber;\n return '\\n\\nCheck your code at ' + fileName + ':' + lineNumber + '.';\n }\n\n return '';\n }\n}\n/**\n * Warn if there's no key explicitly set on dynamic arrays of children or\n * object keys are not valid. This allows us to keep track of children between\n * updates.\n */\n\n\nvar ownerHasKeyUseWarning = {};\n\nfunction getCurrentComponentErrorInfo(parentType) {\n {\n var info = getDeclarationErrorAddendum();\n\n if (!info) {\n var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;\n\n if (parentName) {\n info = \"\\n\\nCheck the top-level render call using <\" + parentName + \">.\";\n }\n }\n\n return info;\n }\n}\n/**\n * Warn if the element doesn't have an explicit key assigned to it.\n * This element is in an array. The array could grow and shrink or be\n * reordered. All children that haven't already been validated are required to\n * have a \"key\" property assigned to it. Error statuses are cached so a warning\n * will only be shown once.\n *\n * @internal\n * @param {ReactElement} element Element that requires a key.\n * @param {*} parentType element's parent's type.\n */\n\n\nfunction validateExplicitKey(element, parentType) {\n {\n if (!element._store || element._store.validated || element.key != null) {\n return;\n }\n\n element._store.validated = true;\n var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);\n\n if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {\n return;\n }\n\n ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a\n // property, it may be the creator of the child that's responsible for\n // assigning it a key.\n\n var childOwner = '';\n\n if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {\n // Give the component that originally created this child.\n childOwner = \" It was passed a child from \" + getComponentNameFromType(element._owner.type) + \".\";\n }\n\n setCurrentlyValidatingElement$1(element);\n\n error('Each child in a list should have a unique \"key\" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);\n\n setCurrentlyValidatingElement$1(null);\n }\n}\n/**\n * Ensure that every element either is passed in a static location, in an\n * array with an explicit keys property defined, or in an object literal\n * with valid key property.\n *\n * @internal\n * @param {ReactNode} node Statically passed child of any type.\n * @param {*} parentType node's parent's type.\n */\n\n\nfunction validateChildKeys(node, parentType) {\n {\n if (typeof node !== 'object') {\n return;\n }\n\n if (isArray(node)) {\n for (var i = 0; i < node.length; i++) {\n var child = node[i];\n\n if (isValidElement(child)) {\n validateExplicitKey(child, parentType);\n }\n }\n } else if (isValidElement(node)) {\n // This element was passed in a valid location.\n if (node._store) {\n node._store.validated = true;\n }\n } else if (node) {\n var iteratorFn = getIteratorFn(node);\n\n if (typeof iteratorFn === 'function') {\n // Entry iterators used to provide implicit keys,\n // but now we print a separate warning for them later.\n if (iteratorFn !== node.entries) {\n var iterator = iteratorFn.call(node);\n var step;\n\n while (!(step = iterator.next()).done) {\n if (isValidElement(step.value)) {\n validateExplicitKey(step.value, parentType);\n }\n }\n }\n }\n }\n }\n}\n/**\n * Given an element, validate that its props follow the propTypes definition,\n * provided by the type.\n *\n * @param {ReactElement} element\n */\n\n\nfunction validatePropTypes(element) {\n {\n var type = element.type;\n\n if (type === null || type === undefined || typeof type === 'string') {\n return;\n }\n\n var propTypes;\n\n if (typeof type === 'function') {\n propTypes = type.propTypes;\n } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.\n // Inner props are checked in the reconciler.\n type.$$typeof === REACT_MEMO_TYPE)) {\n propTypes = type.propTypes;\n } else {\n return;\n }\n\n if (propTypes) {\n // Intentionally inside to avoid triggering lazy initializers:\n var name = getComponentNameFromType(type);\n checkPropTypes(propTypes, element.props, 'prop', name, element);\n } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {\n propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:\n\n var _name = getComponentNameFromType(type);\n\n error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');\n }\n\n if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {\n error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');\n }\n }\n}\n/**\n * Given a fragment, validate that it can only be provided with fragment props\n * @param {ReactElement} fragment\n */\n\n\nfunction validateFragmentProps(fragment) {\n {\n var keys = Object.keys(fragment.props);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n\n if (key !== 'children' && key !== 'key') {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);\n\n setCurrentlyValidatingElement$1(null);\n break;\n }\n }\n\n if (fragment.ref !== null) {\n setCurrentlyValidatingElement$1(fragment);\n\n error('Invalid attribute `ref` supplied to `React.Fragment`.');\n\n setCurrentlyValidatingElement$1(null);\n }\n }\n}\n\nvar didWarnAboutKeySpread = {};\nfunction jsxWithValidation(type, props, key, isStaticChildren, source, self) {\n {\n var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to\n // succeed and there will likely be errors in render.\n\n if (!validType) {\n var info = '';\n\n if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {\n info += ' You likely forgot to export your component from the file ' + \"it's defined in, or you might have mixed up default and named imports.\";\n }\n\n var sourceInfo = getSourceInfoErrorAddendum(source);\n\n if (sourceInfo) {\n info += sourceInfo;\n } else {\n info += getDeclarationErrorAddendum();\n }\n\n var typeString;\n\n if (type === null) {\n typeString = 'null';\n } else if (isArray(type)) {\n typeString = 'array';\n } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {\n typeString = \"<\" + (getComponentNameFromType(type.type) || 'Unknown') + \" />\";\n info = ' Did you accidentally export a JSX literal instead of a component?';\n } else {\n typeString = typeof type;\n }\n\n error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);\n }\n\n var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.\n // TODO: Drop this when these are no longer allowed as the type argument.\n\n if (element == null) {\n return element;\n } // Skip key warning if the type isn't valid since our key validation logic\n // doesn't expect a non-string/function type and can throw confusing errors.\n // We don't want exception behavior to differ between dev and prod.\n // (Rendering will throw with a helpful message and as soon as the type is\n // fixed, the key warnings will appear.)\n\n\n if (validType) {\n var children = props.children;\n\n if (children !== undefined) {\n if (isStaticChildren) {\n if (isArray(children)) {\n for (var i = 0; i < children.length; i++) {\n validateChildKeys(children[i], type);\n }\n\n if (Object.freeze) {\n Object.freeze(children);\n }\n } else {\n error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');\n }\n } else {\n validateChildKeys(children, type);\n }\n }\n }\n\n {\n if (hasOwnProperty.call(props, 'key')) {\n var componentName = getComponentNameFromType(type);\n var keys = Object.keys(props).filter(function (k) {\n return k !== 'key';\n });\n var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';\n\n if (!didWarnAboutKeySpread[componentName + beforeExample]) {\n var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';\n\n error('A props object containing a \"key\" prop is being spread into JSX:\\n' + ' let props = %s;\\n' + ' <%s {...props} />\\n' + 'React keys must be passed directly to JSX without using spread:\\n' + ' let props = %s;\\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);\n\n didWarnAboutKeySpread[componentName + beforeExample] = true;\n }\n }\n }\n\n if (type === REACT_FRAGMENT_TYPE) {\n validateFragmentProps(element);\n } else {\n validatePropTypes(element);\n }\n\n return element;\n }\n} // These two functions exist to still get child warnings in dev\n// even with the prod transform. This means that jsxDEV is purely\n// opt-in behavior for better messages but that we won't stop\n// giving you warnings if you use production apis.\n\nfunction jsxWithValidationStatic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, true);\n }\n}\nfunction jsxWithValidationDynamic(type, props, key) {\n {\n return jsxWithValidation(type, props, key, false);\n }\n}\n\nvar jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.\n// for now we can ship identical prod functions\n\nvar jsxs = jsxWithValidationStatic ;\n\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsx;\nexports.jsxs = jsxs;\n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.min.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","/**\n * @license React\n * scheduler.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var enableSchedulerDebugging = false;\nvar enableProfiling = false;\nvar frameYieldMs = 5;\n\nfunction push(heap, node) {\n var index = heap.length;\n heap.push(node);\n siftUp(heap, node, index);\n}\nfunction peek(heap) {\n return heap.length === 0 ? null : heap[0];\n}\nfunction pop(heap) {\n if (heap.length === 0) {\n return null;\n }\n\n var first = heap[0];\n var last = heap.pop();\n\n if (last !== first) {\n heap[0] = last;\n siftDown(heap, last, 0);\n }\n\n return first;\n}\n\nfunction siftUp(heap, node, i) {\n var index = i;\n\n while (index > 0) {\n var parentIndex = index - 1 >>> 1;\n var parent = heap[parentIndex];\n\n if (compare(parent, node) > 0) {\n // The parent is larger. Swap positions.\n heap[parentIndex] = node;\n heap[index] = parent;\n index = parentIndex;\n } else {\n // The parent is smaller. Exit.\n return;\n }\n }\n}\n\nfunction siftDown(heap, node, i) {\n var index = i;\n var length = heap.length;\n var halfLength = length >>> 1;\n\n while (index < halfLength) {\n var leftIndex = (index + 1) * 2 - 1;\n var left = heap[leftIndex];\n var rightIndex = leftIndex + 1;\n var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.\n\n if (compare(left, node) < 0) {\n if (rightIndex < length && compare(right, left) < 0) {\n heap[index] = right;\n heap[rightIndex] = node;\n index = rightIndex;\n } else {\n heap[index] = left;\n heap[leftIndex] = node;\n index = leftIndex;\n }\n } else if (rightIndex < length && compare(right, node) < 0) {\n heap[index] = right;\n heap[rightIndex] = node;\n index = rightIndex;\n } else {\n // Neither child is smaller. Exit.\n return;\n }\n }\n}\n\nfunction compare(a, b) {\n // Compare sort index first, then task id.\n var diff = a.sortIndex - b.sortIndex;\n return diff !== 0 ? diff : a.id - b.id;\n}\n\n// TODO: Use symbols?\nvar ImmediatePriority = 1;\nvar UserBlockingPriority = 2;\nvar NormalPriority = 3;\nvar LowPriority = 4;\nvar IdlePriority = 5;\n\nfunction markTaskErrored(task, ms) {\n}\n\n/* eslint-disable no-var */\n\nvar hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';\n\nif (hasPerformanceNow) {\n var localPerformance = performance;\n\n exports.unstable_now = function () {\n return localPerformance.now();\n };\n} else {\n var localDate = Date;\n var initialTime = localDate.now();\n\n exports.unstable_now = function () {\n return localDate.now() - initialTime;\n };\n} // Max 31 bit integer. The max integer size in V8 for 32-bit systems.\n// Math.pow(2, 30) - 1\n// 0b111111111111111111111111111111\n\n\nvar maxSigned31BitInt = 1073741823; // Times out immediately\n\nvar IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out\n\nvar USER_BLOCKING_PRIORITY_TIMEOUT = 250;\nvar NORMAL_PRIORITY_TIMEOUT = 5000;\nvar LOW_PRIORITY_TIMEOUT = 10000; // Never times out\n\nvar IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap\n\nvar taskQueue = [];\nvar timerQueue = []; // Incrementing id counter. Used to maintain insertion order.\n\nvar taskIdCounter = 1; // Pausing the scheduler is useful for debugging.\nvar currentTask = null;\nvar currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrance.\n\nvar isPerformingWork = false;\nvar isHostCallbackScheduled = false;\nvar isHostTimeoutScheduled = false; // Capture local references to native APIs, in case a polyfill overrides them.\n\nvar localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null;\nvar localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null;\nvar localSetImmediate = typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom\n\nvar isInputPending = typeof navigator !== 'undefined' && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined ? navigator.scheduling.isInputPending.bind(navigator.scheduling) : null;\n\nfunction advanceTimers(currentTime) {\n // Check for tasks that are no longer delayed and add them to the queue.\n var timer = peek(timerQueue);\n\n while (timer !== null) {\n if (timer.callback === null) {\n // Timer was cancelled.\n pop(timerQueue);\n } else if (timer.startTime <= currentTime) {\n // Timer fired. Transfer to the task queue.\n pop(timerQueue);\n timer.sortIndex = timer.expirationTime;\n push(taskQueue, timer);\n } else {\n // Remaining timers are pending.\n return;\n }\n\n timer = peek(timerQueue);\n }\n}\n\nfunction handleTimeout(currentTime) {\n isHostTimeoutScheduled = false;\n advanceTimers(currentTime);\n\n if (!isHostCallbackScheduled) {\n if (peek(taskQueue) !== null) {\n isHostCallbackScheduled = true;\n requestHostCallback(flushWork);\n } else {\n var firstTimer = peek(timerQueue);\n\n if (firstTimer !== null) {\n requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);\n }\n }\n }\n}\n\nfunction flushWork(hasTimeRemaining, initialTime) {\n\n\n isHostCallbackScheduled = false;\n\n if (isHostTimeoutScheduled) {\n // We scheduled a timeout but it's no longer needed. Cancel it.\n isHostTimeoutScheduled = false;\n cancelHostTimeout();\n }\n\n isPerformingWork = true;\n var previousPriorityLevel = currentPriorityLevel;\n\n try {\n if (enableProfiling) {\n try {\n return workLoop(hasTimeRemaining, initialTime);\n } catch (error) {\n if (currentTask !== null) {\n var currentTime = exports.unstable_now();\n markTaskErrored(currentTask, currentTime);\n currentTask.isQueued = false;\n }\n\n throw error;\n }\n } else {\n // No catch in prod code path.\n return workLoop(hasTimeRemaining, initialTime);\n }\n } finally {\n currentTask = null;\n currentPriorityLevel = previousPriorityLevel;\n isPerformingWork = false;\n }\n}\n\nfunction workLoop(hasTimeRemaining, initialTime) {\n var currentTime = initialTime;\n advanceTimers(currentTime);\n currentTask = peek(taskQueue);\n\n while (currentTask !== null && !(enableSchedulerDebugging )) {\n if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {\n // This currentTask hasn't expired, and we've reached the deadline.\n break;\n }\n\n var callback = currentTask.callback;\n\n if (typeof callback === 'function') {\n currentTask.callback = null;\n currentPriorityLevel = currentTask.priorityLevel;\n var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;\n\n var continuationCallback = callback(didUserCallbackTimeout);\n currentTime = exports.unstable_now();\n\n if (typeof continuationCallback === 'function') {\n currentTask.callback = continuationCallback;\n } else {\n\n if (currentTask === peek(taskQueue)) {\n pop(taskQueue);\n }\n }\n\n advanceTimers(currentTime);\n } else {\n pop(taskQueue);\n }\n\n currentTask = peek(taskQueue);\n } // Return whether there's additional work\n\n\n if (currentTask !== null) {\n return true;\n } else {\n var firstTimer = peek(timerQueue);\n\n if (firstTimer !== null) {\n requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);\n }\n\n return false;\n }\n}\n\nfunction unstable_runWithPriority(priorityLevel, eventHandler) {\n switch (priorityLevel) {\n case ImmediatePriority:\n case UserBlockingPriority:\n case NormalPriority:\n case LowPriority:\n case IdlePriority:\n break;\n\n default:\n priorityLevel = NormalPriority;\n }\n\n var previousPriorityLevel = currentPriorityLevel;\n currentPriorityLevel = priorityLevel;\n\n try {\n return eventHandler();\n } finally {\n currentPriorityLevel = previousPriorityLevel;\n }\n}\n\nfunction unstable_next(eventHandler) {\n var priorityLevel;\n\n switch (currentPriorityLevel) {\n case ImmediatePriority:\n case UserBlockingPriority:\n case NormalPriority:\n // Shift down to normal priority\n priorityLevel = NormalPriority;\n break;\n\n default:\n // Anything lower than normal priority should remain at the current level.\n priorityLevel = currentPriorityLevel;\n break;\n }\n\n var previousPriorityLevel = currentPriorityLevel;\n currentPriorityLevel = priorityLevel;\n\n try {\n return eventHandler();\n } finally {\n currentPriorityLevel = previousPriorityLevel;\n }\n}\n\nfunction unstable_wrapCallback(callback) {\n var parentPriorityLevel = currentPriorityLevel;\n return function () {\n // This is a fork of runWithPriority, inlined for performance.\n var previousPriorityLevel = currentPriorityLevel;\n currentPriorityLevel = parentPriorityLevel;\n\n try {\n return callback.apply(this, arguments);\n } finally {\n currentPriorityLevel = previousPriorityLevel;\n }\n };\n}\n\nfunction unstable_scheduleCallback(priorityLevel, callback, options) {\n var currentTime = exports.unstable_now();\n var startTime;\n\n if (typeof options === 'object' && options !== null) {\n var delay = options.delay;\n\n if (typeof delay === 'number' && delay > 0) {\n startTime = currentTime + delay;\n } else {\n startTime = currentTime;\n }\n } else {\n startTime = currentTime;\n }\n\n var timeout;\n\n switch (priorityLevel) {\n case ImmediatePriority:\n timeout = IMMEDIATE_PRIORITY_TIMEOUT;\n break;\n\n case UserBlockingPriority:\n timeout = USER_BLOCKING_PRIORITY_TIMEOUT;\n break;\n\n case IdlePriority:\n timeout = IDLE_PRIORITY_TIMEOUT;\n break;\n\n case LowPriority:\n timeout = LOW_PRIORITY_TIMEOUT;\n break;\n\n case NormalPriority:\n default:\n timeout = NORMAL_PRIORITY_TIMEOUT;\n break;\n }\n\n var expirationTime = startTime + timeout;\n var newTask = {\n id: taskIdCounter++,\n callback: callback,\n priorityLevel: priorityLevel,\n startTime: startTime,\n expirationTime: expirationTime,\n sortIndex: -1\n };\n\n if (startTime > currentTime) {\n // This is a delayed task.\n newTask.sortIndex = startTime;\n push(timerQueue, newTask);\n\n if (peek(taskQueue) === null && newTask === peek(timerQueue)) {\n // All tasks are delayed, and this is the task with the earliest delay.\n if (isHostTimeoutScheduled) {\n // Cancel an existing timeout.\n cancelHostTimeout();\n } else {\n isHostTimeoutScheduled = true;\n } // Schedule a timeout.\n\n\n requestHostTimeout(handleTimeout, startTime - currentTime);\n }\n } else {\n newTask.sortIndex = expirationTime;\n push(taskQueue, newTask);\n // wait until the next time we yield.\n\n\n if (!isHostCallbackScheduled && !isPerformingWork) {\n isHostCallbackScheduled = true;\n requestHostCallback(flushWork);\n }\n }\n\n return newTask;\n}\n\nfunction unstable_pauseExecution() {\n}\n\nfunction unstable_continueExecution() {\n\n if (!isHostCallbackScheduled && !isPerformingWork) {\n isHostCallbackScheduled = true;\n requestHostCallback(flushWork);\n }\n}\n\nfunction unstable_getFirstCallbackNode() {\n return peek(taskQueue);\n}\n\nfunction unstable_cancelCallback(task) {\n // remove from the queue because you can't remove arbitrary nodes from an\n // array based heap, only the first one.)\n\n\n task.callback = null;\n}\n\nfunction unstable_getCurrentPriorityLevel() {\n return currentPriorityLevel;\n}\n\nvar isMessageLoopRunning = false;\nvar scheduledHostCallback = null;\nvar taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main\n// thread, like user events. By default, it yields multiple times per frame.\n// It does not attempt to align with frame boundaries, since most tasks don't\n// need to be frame aligned; for those that do, use requestAnimationFrame.\n\nvar frameInterval = frameYieldMs;\nvar startTime = -1;\n\nfunction shouldYieldToHost() {\n var timeElapsed = exports.unstable_now() - startTime;\n\n if (timeElapsed < frameInterval) {\n // The main thread has only been blocked for a really short amount of time;\n // smaller than a single frame. Don't yield yet.\n return false;\n } // The main thread has been blocked for a non-negligible amount of time. We\n\n\n return true;\n}\n\nfunction requestPaint() {\n\n}\n\nfunction forceFrameRate(fps) {\n if (fps < 0 || fps > 125) {\n // Using console['error'] to evade Babel and ESLint\n console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');\n return;\n }\n\n if (fps > 0) {\n frameInterval = Math.floor(1000 / fps);\n } else {\n // reset the framerate\n frameInterval = frameYieldMs;\n }\n}\n\nvar performWorkUntilDeadline = function () {\n if (scheduledHostCallback !== null) {\n var currentTime = exports.unstable_now(); // Keep track of the start time so we can measure how long the main thread\n // has been blocked.\n\n startTime = currentTime;\n var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the\n // error can be observed.\n //\n // Intentionally not using a try-catch, since that makes some debugging\n // techniques harder. Instead, if `scheduledHostCallback` errors, then\n // `hasMoreWork` will remain true, and we'll continue the work loop.\n\n var hasMoreWork = true;\n\n try {\n hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);\n } finally {\n if (hasMoreWork) {\n // If there's more work, schedule the next message event at the end\n // of the preceding one.\n schedulePerformWorkUntilDeadline();\n } else {\n isMessageLoopRunning = false;\n scheduledHostCallback = null;\n }\n }\n } else {\n isMessageLoopRunning = false;\n } // Yielding to the browser will give it a chance to paint, so we can\n};\n\nvar schedulePerformWorkUntilDeadline;\n\nif (typeof localSetImmediate === 'function') {\n // Node.js and old IE.\n // There's a few reasons for why we prefer setImmediate.\n //\n // Unlike MessageChannel, it doesn't prevent a Node.js process from exiting.\n // (Even though this is a DOM fork of the Scheduler, you could get here\n // with a mix of Node.js 15+, which has a MessageChannel, and jsdom.)\n // https://github.com/facebook/react/issues/20756\n //\n // But also, it runs earlier which is the semantic we want.\n // If other browsers ever implement it, it's better to use it.\n // Although both of these would be inferior to native scheduling.\n schedulePerformWorkUntilDeadline = function () {\n localSetImmediate(performWorkUntilDeadline);\n };\n} else if (typeof MessageChannel !== 'undefined') {\n // DOM and Worker environments.\n // We prefer MessageChannel because of the 4ms setTimeout clamping.\n var channel = new MessageChannel();\n var port = channel.port2;\n channel.port1.onmessage = performWorkUntilDeadline;\n\n schedulePerformWorkUntilDeadline = function () {\n port.postMessage(null);\n };\n} else {\n // We should only fallback here in non-browser environments.\n schedulePerformWorkUntilDeadline = function () {\n localSetTimeout(performWorkUntilDeadline, 0);\n };\n}\n\nfunction requestHostCallback(callback) {\n scheduledHostCallback = callback;\n\n if (!isMessageLoopRunning) {\n isMessageLoopRunning = true;\n schedulePerformWorkUntilDeadline();\n }\n}\n\nfunction requestHostTimeout(callback, ms) {\n taskTimeoutID = localSetTimeout(function () {\n callback(exports.unstable_now());\n }, ms);\n}\n\nfunction cancelHostTimeout() {\n localClearTimeout(taskTimeoutID);\n taskTimeoutID = -1;\n}\n\nvar unstable_requestPaint = requestPaint;\nvar unstable_Profiling = null;\n\nexports.unstable_IdlePriority = IdlePriority;\nexports.unstable_ImmediatePriority = ImmediatePriority;\nexports.unstable_LowPriority = LowPriority;\nexports.unstable_NormalPriority = NormalPriority;\nexports.unstable_Profiling = unstable_Profiling;\nexports.unstable_UserBlockingPriority = UserBlockingPriority;\nexports.unstable_cancelCallback = unstable_cancelCallback;\nexports.unstable_continueExecution = unstable_continueExecution;\nexports.unstable_forceFrameRate = forceFrameRate;\nexports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;\nexports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;\nexports.unstable_next = unstable_next;\nexports.unstable_pauseExecution = unstable_pauseExecution;\nexports.unstable_requestPaint = unstable_requestPaint;\nexports.unstable_runWithPriority = unstable_runWithPriority;\nexports.unstable_scheduleCallback = unstable_scheduleCallback;\nexports.unstable_shouldYield = shouldYieldToHost;\nexports.unstable_wrapCallback = unstable_wrapCallback;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/scheduler.production.min.js');\n} else {\n module.exports = require('./cjs/scheduler.development.js');\n}\n","/**\n * @license React\n * react-dom.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\nvar Scheduler = require('scheduler');\n\nvar ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;\n\nvar suppressWarning = false;\nfunction setSuppressWarning(newSuppressWarning) {\n {\n suppressWarning = newSuppressWarning;\n }\n} // In DEV, calls to console.warn and console.error get replaced\n// by calls to these methods by a Babel plugin.\n//\n// In PROD (or in packages without access to React internals),\n// they are left as they are instead.\n\nfunction warn(format) {\n {\n if (!suppressWarning) {\n for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n printWarning('warn', format, args);\n }\n }\n}\nfunction error(format) {\n {\n if (!suppressWarning) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n\n printWarning('error', format, args);\n }\n }\n}\n\nfunction printWarning(level, format, args) {\n // When changing this logic, you might want to also\n // update consoleWithStackDev.www.js as well.\n {\n var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;\n var stack = ReactDebugCurrentFrame.getStackAddendum();\n\n if (stack !== '') {\n format += '%s';\n args = args.concat([stack]);\n } // eslint-disable-next-line react-internal/safe-string-coercion\n\n\n var argsWithFormat = args.map(function (item) {\n return String(item);\n }); // Careful: RN currently depends on this prefix\n\n argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it\n // breaks IE9: https://github.com/facebook/react/issues/13610\n // eslint-disable-next-line react-internal/no-production-logging\n\n Function.prototype.apply.call(console[level], console, argsWithFormat);\n }\n}\n\nvar FunctionComponent = 0;\nvar ClassComponent = 1;\nvar IndeterminateComponent = 2; // Before we know whether it is function or class\n\nvar HostRoot = 3; // Root of a host tree. Could be nested inside another node.\n\nvar HostPortal = 4; // A subtree. Could be an entry point to a different renderer.\n\nvar HostComponent = 5;\nvar HostText = 6;\nvar Fragment = 7;\nvar Mode = 8;\nvar ContextConsumer = 9;\nvar ContextProvider = 10;\nvar ForwardRef = 11;\nvar Profiler = 12;\nvar SuspenseComponent = 13;\nvar MemoComponent = 14;\nvar SimpleMemoComponent = 15;\nvar LazyComponent = 16;\nvar IncompleteClassComponent = 17;\nvar DehydratedFragment = 18;\nvar SuspenseListComponent = 19;\nvar ScopeComponent = 21;\nvar OffscreenComponent = 22;\nvar LegacyHiddenComponent = 23;\nvar CacheComponent = 24;\nvar TracingMarkerComponent = 25;\n\n// -----------------------------------------------------------------------------\n\nvar enableClientRenderFallbackOnTextMismatch = true; // TODO: Need to review this code one more time before landing\n// the react-reconciler package.\n\nvar enableNewReconciler = false; // Support legacy Primer support on internal FB www\n\nvar enableLazyContextPropagation = false; // FB-only usage. The new API has different semantics.\n\nvar enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber\n\nvar enableSuspenseAvoidThisFallback = false; // Enables unstable_avoidThisFallback feature in Fizz\n// React DOM Chopping Block\n//\n// Similar to main Chopping Block but only flags related to React DOM. These are\n// grouped because we will likely batch all of them into a single major release.\n// -----------------------------------------------------------------------------\n// Disable support for comment nodes as React DOM containers. Already disabled\n// in open source, but www codebase still relies on it. Need to remove.\n\nvar disableCommentsAsDOMContainers = true; // Disable javascript: URL strings in href for XSS protection.\n// and client rendering, mostly to allow JSX attributes to apply to the custom\n// element's object properties instead of only HTML attributes.\n// https://github.com/facebook/react/issues/11347\n\nvar enableCustomElementPropertySupport = false; // Disables children for