PageSourceSearch

https://creatorfans.co/_next/static/chunks/1dh7rh17wkhdg.js

js creatorfans.co collected 2026-10-05 08:45:55 UTC 63,984 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,318525,982348,355,242988,662058,e=>{"use strict";var t=e.i(848277),n=e.i(330668),r=e.i(696086),a=e.i(466905),l=e.i(398697),s=e.i(112816),i=e.i(65725),c=e.i(412022),o=e.i(156407);function d(e,{reservationId:t,callId:n}){return t?e.find(e=>e.id===t):n?e.find(e=>e.callId===n):void 0}function u(e,t,n){return e.filter(e=>e.memberId===t&&e.id!==n&&""!==(e.afterMemo??"").trim()).sort((e,t)=>e.scheduledAt>t.scheduledAt?-1:+(e.scheduledAt<t.scheduledAt)).map(e=>({reservationId:e.id,scheduledAt:e.scheduledAt,content:e.afterMemo??""}))}e.s(["findCallReservation",0,d,"pastCallMemosForMember",0,u],982348);var m=e.i(777979);function x(e){let t=[];return{enqueue:async function n(n){let r=e();if(r){if(!r.remoteDescription)return void t.push(n);await f(r,n)}},flush:async function n(){let n=e();if(n?.remoteDescription)for(let e of t.splice(0,t.length))await f(n,e)},reset:function(){t.length=0}}}async function f(e,t){try{await e.addIceCandidate(t)}catch{}}function p(e){return e.streams[0]??new MediaStream([e.track])}function h(e){return"insufficient_points"===e?"insufficient_points":null}function b(e){return JSON.stringify({channel:"CallSignalingChannel",call_id:e})}let g={ringback:.5,ringtone:1},y={ringback:{tones:[{at:0,duration:1,frequency:440},{at:2,duration:1,frequency:440}],cycle:4,gain:.1},ringtone:{tones:[{at:0,duration:.4,frequency:880},{at:.5,duration:.4,frequency:660}],cycle:1.6,gain:.2}},v=[{at:0,duration:.16,frequency:520},{at:.18,duration:.28,frequency:380}],N=null;function k(){let e;if(N)return N;let t=(e=window).AudioContext??e.webkitAudioContext??null;return t?N=new t:null}let j=null;function w(e){if(j)return j;let t=(async()=>{let t=await fetch("/sounds/call-ring.mp3");if(!t.ok)throw Error(`ringtone fetch failed: ${t.status}`);let n=await t.arrayBuffer();return await e.decodeAudioData(n)})().catch(e=>{throw j===t&&(j=null),e});return j=t,t}function z(e,t,n,r){for(let a of t){let t=e.createOscillator(),l=e.createGain();t.type="sine",t.frequency.value=a.frequency;let s=r+a.at,i=s+a.duration;l.gain.setValueAtTime(0,s),l.gain.linearRampToValueAtTime(n,s+.02),l.gain.setValueAtTime(n,Math.max(s+.02,i-.02)),l.gain.linearRampToValueAtTime(0,i),t.connect(l).connect(e.destination),t.start(s),t.stop(i)}}let S={stop:()=>{}};function C(e){(0,n.useEffect)(()=>{if(!e)return;let t=function(e){let t=k();if(!t)return S;let n=!1,r=null,a=null,l=null;return t.resume().catch(()=>{}),w(t).then(l=>{if(n)return;let s=t.createBufferSource();s.buffer=l,s.loop=!0;let i=t.createGain();i.gain.value=g[e],s.connect(i).connect(t.destination),s.start(),r=s,a=i}).catch(()=>{(()=>{if(n||l)return;let r=y[e],a=()=>{n||z(t,r.tones,r.gain,t.currentTime)};a(),l=setInterval(a,1e3*r.cycle)})()}),{stop:()=>{if(n=!0,r){try{r.stop()}catch{}r.disconnect(),r=null}a&&(a.disconnect(),a=null),l&&(clearInterval(l),l=null)}}}(e);return()=>t.stop()},[e])}function I(e){return Math.ceil(Math.max(0,e)/60)}function M(e,t){return Math.max(1,I(e))*t}var E=e.i(576053),_=e.i(660954),A=e.i(235884);let D=(0,A.default)("mic-off",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]]),O=(0,A.default)("phone-off",[["path",{d:"M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272",key:"1wngk7"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}],["path",{d:"M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473",key:"10hv5p"}]]);var P=e.i(808872),R=e.i(242286),T=e.i(487635),L=e.i(764293),U=e.i(186109),J=e.i(157660),$=e.i(62260),B=e.i(541428);let q=()=>()=>{};function F(){return window.location.origin}function W({target:e,open:r,partnerName:a,partnerImageUrl:i,onClose:c,onOpenThread:o,onUnreadCountChange:d}){let u=(0,$.useT)(),m=function({target:e,open:t}){let{accessToken:r,memberApiReady:a,tryRefresh:i}=(0,s.useAuth)(),{creatorId:c,memberId:o,viewer:d}
1=e,[u,m]=(0,n.useState)([]),[x,f]=(0,n.useState)("loading"),[p,h]=(0,n.useState)(null),[b,g]=(0,n.useState)(!1),[y,v]=(0,n.useState)(null),N=!!(r&&a),k=(0,n.useCallback)(()=>"member"===d&&r?(0,J.fetchDmFee)({accessToken:r,creatorId:c,refreshOnUnauthorized:i}).then(h).catch(()=>{}):Promise.resolve(),[r,c,i,d]);(0,n.useEffect)(()=>{if(!N||!r)return;let e=!0,t=()=>{(0,J.fetchDirectMessageHistory)({accessToken:r,creatorId:c,memberId:o,limit:50,refreshOnUnauthorized:i}).then(t=>{e&&(m(t.items),f("idle"))}).catch(()=>{e&&f(e=>"loading"===e?"error":e)}),"member"===d&&(0,J.fetchDmFee)({accessToken:r,creatorId:c,refreshOnUnauthorized:i}).then(t=>{e&&h(t)}).catch(()=>{})};t();let n=window.setInterval(t,1e4);return()=>{e=!1,window.clearInterval(n)}},[r,c,o,N,i,d]);let j=(0,n.useMemo)(()=>u.filter(e=>e.senderType!==d&&"unread"===e.readStatus).length,[u,d]);(0,n.useEffect)(()=>{t&&0!==j&&N&&r&&(0,J.markDirectMessagesRead)({accessToken:r,creatorId:c,memberId:o,refreshOnUnauthorized:i}).then(()=>{m(e=>e.map(e=>e.senderType!==d&&"unread"===e.readStatus?{...e,readStatus:"read"}:e))}).catch(()=>{})},[r,c,o,t,N,i,j,d]);let w=(0,n.useCallback)(async e=>{let t=e.trim();if(!N||!r||!t||t.length>1e3)return!1;g(!0),v(null);try{let e=await (0,J.postDirectMessage)({accessToken:r,creatorId:c,memberId:o,body:t,refreshOnUnauthorized:i});return m(t=>[e,...t.filter(t=>t.id!==e.id)]),k(),!0}catch(e){return v(e instanceof l.ApiError&&402===e.status?"insufficient_points":"failed"),!1}finally{g(!1)}},[r,c,k,o,N,i]);return{items:u,loadState:x,unreadCount:j,sendMode:"creator"===d?"free":p?p.freeDuringCall?"free_during_call":p.hasPlan?(p.usePoint??0)>0?"paid":"free":"disabled":"unknown",usePoint:p?.usePoint??null,sending:b,sendError:y,send:w,accessToken:r,tryRefresh:i}}({target:e,open:r}),[x,f]=(0,n.useState)(""),p=(0,n.useSyncExternalStore)(q,F,()=>""),h=(0,n.useRef)(null),b=(0,n.useMemo)(()=>[...m.items].reverse(),[m.items]),g=b[b.length-1]?.id??null;if((0,n.useEffect)(()=>{d(r?0:m.unreadCount)},[m.unreadCount,d,r]),(0,n.useEffect)(()=>{r&&g&&h.current?.scrollIntoView({block:"end"})},[g,r]),!r)return null;let y="free_during_call"===m.sendMode||"free"===m.sendMode,v=x.trim().length,N=async()=>{await m.send(x)&&f("")};return(0,t.jsxs)("section",{role:"dialog","aria-label":a?u("inCallDm.title",{name:a}):u("inCallDm.titleFallback"),className:"fixed inset-x-0 bottom-0 z-[51] mx-auto flex h-[65%] w-full max-w-[430px] flex-col rounded-t-2xl bg-white text-zinc-900 shadow-2xl lg:inset-y-0 lg:right-auto lg:left-[calc(50%+215px)] lg:mx-0 lg:h-auto lg:w-[380px] lg:max-w-none lg:rounded-none lg:border-l lg:border-zinc-200 dark:bg-zinc-950 dark:text-zinc-100 dark:lg:border-zinc-800",children:[(0,t.jsxs)("header",{className:"flex items-center gap-2 border-b border-zinc-200 px-4 py-3 dark:border-zinc-800",children:[(0,t.jsx)(L.DirectMessageAvatar,{src:i??null,name:a,className:"size-8"}),(0,t.jsx)("p",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:a?u("inCallDm.title",{name:a}):u("inCallDm.titleFallback")}),(0,t.jsx)("button",{type:"button",onClick:c,"aria-label":u("inCallDm.close"),className:"flex size-8 items-center justify-center rounded-full text-zinc-500 hover:bg-zinc-100 dark:text-zinc-400 dark:hover:bg-zinc-800",children:(0,t.jsx)(T.X,{className:"size-5","aria-hidden":!0})})]}),(0,t.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-3",children:"loading"===m.loadState?(0,t.jsx)("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:u("inCallDm.loading")}):"error"===m.loadState?(0,t.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:u("inCallDm.loadError")}):0===b.length?(0,t.jsx)("p",{className:"text-sm text-zinc-500 dark:text-zinc-400",children:u("inCallDm.empty")}):(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[b.map(n=>{let r=n.senderType===e.viewer;return(0,t.jsxs)("div",{className:(0,B.cn)("flex items-end gap-1",r?"flex-row-reverse":"flex-row"),children:[(0,t.jsx)(U.MessageBody,{item:n,isSelf:r,origin:p,accessToken:m.accessToken,refreshOnUnauthorized:m.tryRefresh}),(0,t.jsx)("span",{className:"flex-shrink-0 text-[10px] text-zinc-400 dark:text-zinc-500",children:new Date(n.createdAt).toLocaleTimeString("ja-JP",{hour:"2-digit",minute:"2-digit"})})]},n.id)}),(0,t.jsx)("div",{ref:h})]})}),(0,t.jsxs)("div",{className:"border-t border-zinc-200 px-4 pt-2 pb-[calc(env(safe-area-inset-bottom)+0.75rem)] dark:border-zinc-800",children:["free_during_call"===m.sendMode&&(0,t.jsx)("p",{className:"mb-2 rounded-lg bg-status-success-bg px-3 py-1.5 text-xs font-semibold text-status-success",children:u("inCallDm.freeDuringCall")}),"paid"===m.sendMode&&(0,t.jsxs)("div",{className:"mb-2 rounded-lg bg-zinc-50 px-3 py-2 text-xs text-zinc-600 dark:bg-zinc-900 dark:text-zinc-300",children:[(0,t.jsxs)("p",{className:"flex items-center gap-1",children:[(0,t.jsx)(R.Coins,{className:"size-3.5 shrink-0 text-amber-500","aria-hidden":!0}
1),u("inCallDm.paidNotice",{point:(m.usePoint??0).toLocaleString()})]}),o&&(0,t.jsx)("button",{type:"button",onClick:o,className:"mt-2 w-full rounded-full bg-pink-500 py-2 text-xs font-semibold text-white hover:bg-pink-600",children:u("inCallDm.openThread")})]}),"disabled"===m.sendMode&&(0,t.jsx)("p",{className:"py-2 text-center text-xs text-zinc-500 dark:text-zinc-400",children:u("inCallDm.disabled")}),m.sendError&&(0,t.jsx)("p",{className:"mb-2 text-xs text-red-600 dark:text-red-400",children:u("insufficient_points"===m.sendError?"inCallDm.insufficientPoints":"inCallDm.sendError")}),y&&(0,t.jsxs)("form",{className:"flex items-end gap-2",onSubmit:e=>{e.preventDefault(),N()},children:[(0,t.jsx)("textarea",{value:x,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&!e.nativeEvent.isComposing&&(e.preventDefault(),N())},maxLength:1e3,rows:2,placeholder:u("inCallDm.placeholder"),"aria-label":u("inCallDm.placeholder"),className:"max-h-32 min-h-10 flex-1 resize-none rounded-2xl border border-zinc-300 bg-zinc-50 px-3 py-2 text-sm outline-none focus:border-pink-400 focus:bg-white dark:border-zinc-700 dark:bg-zinc-900 dark:focus:bg-zinc-800"}),(0,t.jsx)("button",{type:"submit",disabled:m.sending||0===v,className:"h-10 shrink-0 rounded-full bg-pink-500 px-4 text-sm font-semibold text-white transition disabled:cursor-not-allowed disabled:opacity-50",children:u("inCallDm.send")})]})]})]})}function G({stream:e,muted:r}){let[a]=(0,n.useState)(()=>{let e;return(e=window).AudioContext??e.webkitAudioContext??null}),[l,s]=(0,n.useState)(0),i=(0,n.useRef)(null);if((0,n.useEffect)(()=>{if(!e||!a)return;let t=new a,n=t.createMediaStreamSource(e),r=t.createAnalyser();r.fftSize=2048,n.connect(r);let l=new Float32Array(r.fftSize),c=()=>{"suspended"===t.state&&t.resume().catch(()=>{}),r.getFloatTimeDomainData(l);let e=0;for(let t=0;t<l.length;t+=1)e+=l[t]*l[t];s(Math.sqrt(e/l.length)),i.current=requestAnimationFrame(c)};return i.current=requestAnimationFrame(c),()=>{null!=i.current&&(cancelAnimationFrame(i.current),i.current=null),t.close().catch(()=>{})}},[e,a]),!a)return null;let c=e&&!r?Math.min(100,Math.round(400*l)):0;return(0,t.jsxs)("div",{className:"flex w-full items-center gap-3 rounded-xl bg-zinc-800 px-4 py-3","aria-label":"マイク入力レベル",children:[r?(0,t.jsx)(D,{className:"size-4 shrink-0 text-zinc-500","aria-hidden":!0}):(0,t.jsx)(_.Mic,{className:"size-4 shrink-0 text-zinc-300","aria-hidden":!0}),(0,t.jsx)("span",{className:"shrink-0 text-sm text-zinc-300",children:"マイク入力"}),r?(0,t.jsx)("span",{className:"flex-1 text-right text-xs text-zinc-500",children:"ミュート中"}):(0,t.jsx)("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-zinc-700",children:(0,t.jsx)("div",{className:"h-full rounded-full bg-emerald-500 transition-[width] duration-75",style:{width:`${c}%`},"aria-hidden":!0})})]})}var V=e.i(816506);function K(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("ja-JP",{timeZone:"Asia/Tokyo",year:"numeric",month:"numeric",day:"numeric"}).format(t)}function H({memos:e,tone:r,fanDetailHref:a}){var l;let[s,i]=(0,n.useState)(!1),[c,o]=(0,n.useState)(!1);if(0===e.length)return null;let[d,...u]=e,m=u.slice(0,2),x="dark"===r,f=x?"text-[11px] text-zinc-400":"text-[11px] text-zinc-500 dark:text-zinc-400",p=x?"whitespace-pre-wrap wrap-anywhere text-[13px] text-zinc-100":"whitespace-pre-wrap wrap-anywhere text-[13px] text-zinc-800 dark:text-zinc-200",h=x?"text-xs font-semibold text-violet-300 hover:text-violet-200":"text-xs font-semibold text-pink-600 hover:text-pink-700 dark:text-pink-400";return(0,t.jsxs)("section",{"aria-label":"あなたのメモ(前回まで)",className:(0,B.cn)("w-full rounded-lg px-3 py-2 text-left",x?"bg-zinc-800":"bg-zinc-50 dark:bg-zinc-800/60"),children:[(0,t.jsx)("p",{className:(0,B.cn)("text-[11px] font-semibold",x?"text-zinc-300":"text-zinc-500 dark:text-zinc-400"),children:"あなたのメモ(前回まで)"}),c?(0,t.jsx)("ul",{className:"mt-1 space-y-2",children:e.map(e=>(0,t.jsxs)("li",{children:[(0,t.jsx)("p",{className:f,children:K(e.scheduledAt)}),(0,t.jsx)("p",{className:p,children:e.content})]},e.reservationId))}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"mt-1",children:[(0,t.jsx)("p",{className:f,children:K(d.scheduledAt)}),(0,t.jsx)("p",{className:(0,B.cn)(p,!s&&"line-clamp-4"),children:d.content}),!s&&((l=d.content).split("\n").length>4||l.length>120)?(0,t.jsx)("button",{type:"button",onClick:()=>i(!0),className:h,children:"続きを読む"}):null]}),m.length>0?(0,t.jsx)("ul",{className:"mt-2 space-y-1",children:m.map(e=>(0,t.jsxs)("li",{className:"flex min-w-0 items-baseline gap-2",children:[(0,t.jsx)("span",{className:(0,B.cn)("shrink-0",f),children:K(e.scheduledAt)}),(0,t.jsx)("span",{className:(0,B.cn)("min-w-0 truncate text-[13px]",x?"text-zinc-200":"text-zinc-700 dark:text-zinc-300"),children:e.content.replace(/\s+/g," ").trim()})]},e.reservationId))}):null,e.length>1?a?(0,t.jsx)(V.default,{href:a,className:(0,B.cn)("mt-2 inline-block",h),children:"すべて見る"}):(0,t.jsx)("button",{type:"button",onClick:()=>o(!0),className:(0,B.cn)("mt-2 block",h),children:"すべて見る"}):null]})]})}e.s(["PastCallMemos",0,H],355);var X=e.i(889406);function Z(e){let t=Math.floor(e/60).toString().padStart(2,"0"),n=(e%60).toString().padStart(2,"0");return`${t}:${n}`}
1function Q({callState:e,remoteStream:r,localStream:a,creatorName:l,creatorProfileImageUrl:s,pricePerMinute:i,selectedDurationMinutes:c=30,authorizedSeconds:o,expiresAt:d,serverOffsetMs:u=0,pointBalance:m,balanceAsOfSeconds:x=0,isCaller:f=!1,micSuspended:p=!1,onLogEvent:h,onHangUp:b,onOpenChat:g,directMessage:y,pastMemos:v}){let N=(0,$.useT)(),k=(0,n.useRef)(null),j=(0,n.useRef)(!1),w=(0,n.useRef)(!1),[z,S]=(0,n.useState)(0),[A,R]=(0,n.useState)(()=>Date.now()),[T,L]=(0,n.useState)(0),[U,J]=(0,n.useState)(!1),[q,F]=(0,n.useState)(!1),[V,K]=(0,n.useState)(!1),[et,en]=(0,n.useState)(!1),[er,ea]=(0,n.useState)(!1),[el,es]=(0,n.useState)(0),ei=(0,n.useMemo)(()=>(0,X.isIosSafari)(),[]),ec=(0,n.useMemo)(()=>(0,X.isMobileCallAudioRouting)(),[]);C("ringing"===e?"ringback":null);let eo=(0,n.useMemo)(()=>{if(!d)return null;let e=Date.parse(d);return Number.isNaN(e)?null:e},[d]),ed=null!=eo,eu=ed?Math.max(0,Math.round((eo-(A+u))/1e3)):Math.max(0,(o??60*c)-z),em=null!=i?M(z,i):null,ex=null!=i?I(x)*i:0,ef=null!=m&&null!=em?Math.max(0,m-Math.max(0,em-ex)):null;(0,n.useEffect)(()=>{let e=k.current;if(!e||!r)return;let t=!1;w.current=!1;let n=(0,X.shouldApplyCallSpeakerRouting)({speakerOn:q,speakerUnavailable:ei,mobileRouting:ec,sinkAlreadySet:j.current});(0,X.syncRemoteCallAudio)({audioEl:e,remoteStream:r,speakerOn:q,applySpeakerRouting:n}).then(e=>{t||(n&&(j.current=!0),w.current="playing"===e,en("blocked"===e))});let a=()=>{t||!w.current||e.ended||en(!0)};return e.addEventListener("pause",a),()=>{t=!0,e.removeEventListener("pause",a)}},[r,q,ei,ec]);let ep=(0,n.useCallback)(()=>{let e=k.current;e&&e.play().then(()=>{w.current=!0,en(!1)}).catch(()=>{en(!0)})},[]);(0,n.useEffect)(()=>{if("connected"!==e)return;let t=setTimeout(()=>R(Date.now()),0),n=setInterval(()=>{S(e=>e+1),R(Date.now())},1e3);return()=>{clearTimeout(t),clearInterval(n)}},[e]),(0,n.useEffect)(()=>{if("ringing"!==e)return;let t=setInterval(()=>L(e=>e+1),1e3);return()=>{clearInterval(t),L(0)}},[e]);let eh=f&&"ringing"===e&&T>=30;if((0,n.useEffect)(()=>{"connected"===e&&ed&&eu<=0&&b()},[e,ed,eu,b]),(0,n.useEffect)(()=>{if(!a)return;let e=a.getAudioTracks()[0];e&&(e.enabled=!U)},[U,a]),"idle"===e||"ended"===e)return null;let eb=null!=y&&"connected"===e,eg=eb&&el>0?(0,t.jsx)("span",{"aria-label":N("inCallDm.unreadAria",{count:el}),className:"flex min-w-5 items-center justify-center rounded-full bg-pink-500 px-1.5 text-[11px] leading-5 font-bold text-white",children:el>99?"99+":el}):null,ey=q?"スピーカーON":"スピーカー",ev="connected"===e&&et,eN=void 0!==v&&("connected"===e||f&&"ringing"===e),ek="connecting"===e?"接続中...":"ringing"===e?"呼び出し中...":"error"===e?"エラー":"通話中";return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("audio",{ref:k,autoPlay:!0,playsInline:!0,className:"sr-only","aria-hidden":!0}),V?(0,t.jsx)("div",{className:"pointer-events-none fixed inset-x-0 top-0 z-50 flex justify-center px-4 pt-[calc(env(safe-area-inset-top)+0.5rem)]",children:(0,t.jsxs)("div",{className:"pointer-events-auto flex w-full max-w-[430px] items-center justify-between rounded-2xl bg-zinc-900 px-4 py-3 shadow-xl",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"size-2 animate-pulse rounded-full bg-green-400"}),(0,t.jsx)("span",{className:"text-sm font-semibold text-white",children:l??"通話中"}),(0,t.jsx)("span",{className:"text-sm text-zinc-400",children:Z(z)}),eg]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[ev&&(0,t.jsx)("button",{type:"button",onClick:ep,className:"rounded-lg bg-amber-500 px-3 py-1.5 text-xs font-semibold text-zinc-900 hover:bg-amber-400",children:"音声オン"}),(0,t.jsx)("button",{type:"button",onClick:()=>K(!1),className:"rounded-lg bg-zinc-700 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-600",children:"開く"}),(0,t.jsx)("button",{type:"button",onClick:b,"aria-label":"通話を終了",className:"flex size-8 items-center justify-center rounded-full bg-red-500 hover:bg-red-600",children:(0,t.jsx)(O,{className:"size-4"})})]})]})}):(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex justify-center bg-black/40",children:(0,t.jsxs)("div",{className:"relative flex h-full w-full max-w-[430px] flex-col bg-zinc-900 text-white",children:[(0,t.jsxs)("div",{className:"relative flex items-center px-4 pb-2 pt-12",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{ea(!1),K(!0)},className:"flex items-center gap-1 text-sm text-zinc-400 hover:text-white",children:[(0,t.jsx)(ee,{className:"size-4"}),"最小化"]}),(0,t.jsx)("span",{className:"absolute left-1/2 -translate-x-1/2 text-sm font-semibold text-zinc-200",children:ek})]}),p&&(0,t.jsx)("div",{className:"mx-4 mb-1 rounded-lg bg-amber-500/15 px-3 py-2 text-center text-sm font-semibold text-amber-300",children:"マイクが一時停止しています。他のアプリでの通話を終了し、この画面に戻ってください"}),ev&&(0,t.jsx)("button",{type:"button",onClick:ep,className:"mx-4 mb-1 rounded-lg bg-amber-500/15 px-3 py-2 text-center text-sm font-semibold text-amber-300",children:"相手の声が再生さã
1‚Œã¦ã„ません。タップして音声をオンにする"}),"error"!==e&&(0,t.jsx)("p",{className:"mx-4 mb-1 rounded-lg bg-zinc-800 px-3 py-2 text-center text-xs text-zinc-300",children:"通話の品質を安定させるため、このサイトから離れないでください。DMは可能です。"}),(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col items-center gap-4 overflow-y-auto px-6 pb-2 pt-6",children:[(0,t.jsx)("div",{className:(0,B.cn)("rounded-full p-[3px]","connected"===e?"bg-gradient-to-br from-violet-400 via-purple-500 to-pink-500 animate-pulse":"bg-zinc-600"),children:(0,t.jsx)("div",{className:"rounded-full bg-zinc-900 p-[2px]",children:s?(0,t.jsx)("img",{src:s,alt:l??"",className:"size-28 rounded-full object-cover"}):(0,t.jsx)("div",{className:"flex size-28 items-center justify-center rounded-full bg-gradient-to-br from-pink-300 to-purple-400 text-4xl font-bold text-white",children:(l??"?").charAt(0)})})}),(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("p",{className:"text-2xl font-bold text-white",children:l??"通話中"}),(0,t.jsx)("p",{className:"mt-0.5 text-sm text-zinc-400",children:"connected"===e?"通話中":ek})]}),"connected"===e&&(0,t.jsx)("p",{className:"text-6xl font-bold tabular-nums tracking-tight text-white",children:Z(z)}),eh&&(0,t.jsx)("p",{className:"rounded-lg bg-amber-500/15 px-3 py-1.5 text-center text-sm font-semibold text-amber-300",children:"相手の応答がありません。呼び出しをやめて、もう一度発信できます。"}),"connected"===e&&null!=em&&(0,t.jsxs)("p",{className:"text-sm text-zinc-400",children:["消費 ",em.toLocaleString(),"pt",null!=ef&&` 残り ${ef.toLocaleString()}pt`]}),"connected"===e&&(0,t.jsx)("div",{className:"flex w-full items-center justify-between rounded-xl bg-zinc-800 px-4 py-3",children:(0,t.jsxs)("span",{className:"text-sm text-zinc-300",children:["残り時間"," ",(0,t.jsx)("span",{className:"font-semibold text-white",children:function(e){if(e<=0)return"0秒";let t=Math.floor(e/60),n=e%60;return 0===t?`${n}秒`:0===n?`${t}分`:`${t}分${n}秒`}(eu)})]})}),"connected"===e&&(0,t.jsx)(G,{stream:a,muted:U||p}),ei&&(0,t.jsx)("p",{className:"w-full rounded-xl bg-zinc-800 px-4 py-3 text-center text-sm text-zinc-300",children:"Safariではスピーカー機能は利用できません。"}),eN&&(0,t.jsx)(H,{memos:v,tone:"dark"})]}),(0,t.jsxs)("div",{className:"px-6 pb-10 pt-4",children:[(0,t.jsxs)("div",{className:"mb-6 flex justify-around",children:[(0,t.jsx)(Y,{icon:U?(0,t.jsx)(D,{className:"size-6"}):(0,t.jsx)(_.Mic,{className:"size-6"}),label:U?"ミュート中":"ミュート",active:U,onClick:()=>{h?.(!U?"self_mute_on":"self_mute_off"),J(e=>!e)}}),(0,t.jsx)(Y,{icon:(0,t.jsx)(P.Volume2,{className:"size-6"}),label:ey,active:q,disabled:ei,onClick:()=>F(e=>!e)}),eb?(0,t.jsx)(Y,{icon:(0,t.jsx)(E.MessageSquare,{className:"size-6"}),label:"チャット",active:er,badge:eg,expanded:er,onClick:()=>ea(e=>!e)}):g&&(0,t.jsx)(Y,{icon:(0,t.jsx)(E.MessageSquare,{className:"size-6"}),label:"チャット",onClick:()=>{K(!0),g()}})]}),(0,t.jsxs)("button",{type:"button",onClick:b,className:"flex w-full items-center justify-center gap-3 rounded-2xl bg-zinc-800 py-5 text-base font-bold text-white transition-colors hover:bg-zinc-700",children:[(0,t.jsx)(O,{className:"size-6"}),f&&"ringing"===e?"呼び出しをやめる":"通話を終了"]})]})]})}),eb&&(0,t.jsx)(W,{target:y,open:er&&!V,partnerName:l,partnerImageUrl:s,onClose:()=>ea(!1),onOpenThread:g?()=>{ea(!1),K(!0),g()}:void 0,onUnreadCountChange:es})]})}function Y({icon:e,label:n,active:r,disabled:a,badge:l,expanded:s,onClick:i}){return(0,t.jsxs)("button",{type:"button",onClick:i,disabled:a,"aria-disabled":a,"aria-expanded":s,className:(0,B.cn)("flex flex-col items-center gap-1.5",a&&"cursor-not-allowed opacity-50"),children:[(0,t.jsxs)("span",{className:(0,B.cn)("relative flex size-14 items-center justify-center rounded-full transition-colors",r?"bg-violet-500 text-white":"bg-zinc-700 text-zinc-200"),children:[e,l?(0,t.jsx)("span",{className:"absolute -top-1 -right-1",children:l}):null]}),(0,t.jsx)("span",{className:"text-xs text-zinc-400",children:n})]})}function ee({className:e}){return(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})})}var et=e.i(397599),en=e.i(635169);function er({creatorName:e,creatorProfileImageUrl:r,durationSeconds:l,consumedPoints:s,endedByInsufficientPoints:i=!1,callId:c,accessToken:o,onClose:d}
1){let[u,m]=(0,n.useState)(0),[x,f]=(0,n.useState)(0),[p,h]=(0,n.useState)(""),[b,g]=(0,n.useState)(!1),[y,v]=(0,n.useState)(!1),[N,k]=(0,n.useState)(null),j=async()=>{if(!y&&!(u<1)){if(!c||!o)return void g(!0);v(!0),k(null);try{await (0,a.submitCallReview)({accessToken:o,callId:c,rating:u,comment:p.trim()||void 0}),g(!0)}catch{k("レビューの送信に失敗しました。時間をおいて再度お試しください。")}finally{v(!1)}}};return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 px-4",children:(0,t.jsxs)("div",{className:"w-full max-w-sm overflow-hidden rounded-2xl bg-white shadow-2xl",children:[(0,t.jsxs)("div",{className:"bg-gradient-to-br from-pink-500 to-violet-600 px-6 py-8 text-center",children:[(0,t.jsx)("div",{className:"mx-auto mb-3 flex size-16 items-center justify-center rounded-full bg-white/20",children:r?(0,t.jsx)("img",{src:r,alt:e??"",className:"size-16 rounded-full object-cover"}):(0,t.jsx)(et.Phone,{className:"size-8 text-white"})}),(0,t.jsx)("p",{className:"text-lg font-bold text-white",children:"通話が終了しました"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-pink-100",children:[e??"クリエイター","との通話"]})]}),i&&(0,t.jsx)("div",{className:"border-b bg-amber-50 px-6 py-3 text-center text-sm font-medium text-amber-700",children:"ポイントが不足したため通話が終了しました"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 divide-x border-b",children:[(0,t.jsxs)("div",{className:"px-6 py-4 text-center",children:[(0,t.jsx)("p",{className:"mb-1 text-xs text-zinc-500",children:"通話時間"}),(0,t.jsx)("p",{className:"text-lg font-bold text-zinc-900",children:function(e){if(e<=0)return"0秒";let t=Math.floor(e/60),n=e%60;return 0===t?`${n}秒`:0===n?`${t}分`:`${t}分${n}秒`}(l)})]}),(0,t.jsxs)("div",{className:"px-6 py-4 text-center",children:[(0,t.jsx)("p",{className:"mb-1 text-xs text-zinc-500",children:"消費ポイント"}),(0,t.jsx)("p",{className:"text-lg font-bold text-zinc-900",children:null!=s?`${s.toLocaleString()}pt`:"-"})]})]}),b?(0,t.jsxs)("div",{className:"px-6 py-8 text-center",children:[(0,t.jsx)("p",{className:"mb-4 text-sm text-zinc-600",children:"レビューありがとうございます!"}),(0,t.jsx)("button",{type:"button",onClick:d,className:"w-full rounded-xl bg-pink-500 py-3 text-sm font-bold text-white transition-colors hover:bg-pink-600",children:"閉じる"})]}):(0,t.jsxs)("div",{className:"px-6 py-5",children:[(0,t.jsx)("p",{className:"mb-3 text-center text-sm font-semibold text-zinc-800",children:"通話はいかがでしたか?"}),(0,t.jsx)("div",{className:"mb-4 flex justify-center gap-2",children:[1,2,3,4,5].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>m(e),onMouseEnter:()=>f(e),onMouseLeave:()=>f(0),children:(0,t.jsx)(en.Star,{className:(0,B.cn)("size-8 transition-colors",e<=(x||u)?"fill-amber-400 text-amber-400":"text-zinc-300")})},e))}),u>0&&(0,t.jsx)("textarea",{value:p,onChange:e=>h(e.target.value),placeholder:"コメントを入力(任意)",rows:3,className:"mb-4 w-full resize-none rounded-lg border border-zinc-200 p-3 text-sm text-zinc-900 placeholder-zinc-400 focus:border-pink-400 focus:outline-none"}),N&&(0,t.jsx)("p",{className:"mb-3 text-center text-xs font-medium text-red-500",children:N}),(0,t.jsxs)("div",{className:"flex gap-2",children:[u>0&&(0,t.jsx)("button",{type:"button",onClick:()=>void j(),disabled:y,className:"flex-1 rounded-xl bg-pink-500 py-3 text-sm font-bold text-white transition-colors hover:bg-pink-600 disabled:opacity-60",children:y?"送信中…":"レビューを送信"}),(0,t.jsx)("button",{type:"button",onClick:d,className:"flex-1 rounded-xl border border-zinc-200 py-3 text-sm font-semibold text-zinc-700 transition-colors hover:bg-zinc-50",children:"閉じる"})]})]})]})})}var ea=e.i(480380),el=e.i(382501),es=e.i(812306);function ei(e){return e.totalPoint}function ec(e){return[...e].sort((e,t)=>new Date(e.scheduledAt).getTime()-new Date(t.scheduledAt).getTime())}let eo={not_found:"予約が見つかりませんでした",forbidden:"この予約は操作できません",conflict:"すでに確定・キャンセル済みです"};e.s(["MAX_BULK_APPROVE",0,100,"reservationPoint",0,ei,"sortPendingReservations",0,ec,"sumReservationPoint",0,function(e,t){return e.filter(e=>t.has(e.id)).reduce((e,t)=>
1e+ei(t),0)},"summarizeBulkApprove",0,function(e,t){let n=new Map(t.results.map(e=>[e.reservationId,e])),r=[],a={},l=0;for(let t of e){var s;let e=n.get(t);if(e&&("approved"===e.status||"already"===e.status)){l+=1;continue}r.push(t),a[t]=(s=e?e.reason:null)&&eo[s]?eo[s]:"承認できませんでした"}return{approvedCount:l,failedCount:r.length,failedIds:r,reasonById:a}}],242988);var ed=e.i(687632),eu=e.i(679900);let em="creator_pending_reservation_dismissed",ex=()=>()=>{};function ef(){try{let e=sessionStorage.getItem(em);if(!e)return new Set;let t=JSON.parse(e);return new Set(Array.isArray(t)?t.filter(e=>"string"==typeof e):[])}catch{return new Set}}function ep(){let e=(0,r.usePathname)(),{accessToken:a,memberApiReady:l,isCreatorMode:c,hasCreatorProfile:o}=(0,s.useAuth)(),d=(0,n.useSyncExternalStore)(ex,()=>!0,()=>!1),[u,m]=(0,n.useState)([]),[x,f]=(0,n.useState)(new Set),[p,h]=(0,n.useState)(!1),[b,g]=(0,n.useState)(null),[y,v]=(0,n.useState)(null),N=(0,n.useRef)(null),k=(0,es.useMicPermissionGate)(),j=(0,n.useCallback)(async()=>{if(!a||!l||!c||!0!==o){m([]),f(new Set);return}try{let{reservations:e}=await (0,i.fetchCreatorReservations)({accessToken:a}),t=ef(),n=ec(e.filter(e=>"pending"===e.status&&!t.has(e.id)));m(n),f(e=>{let t=new Set(n.map(e=>e.id));return new Set([...e].filter(e=>t.has(e)))}),g(null)}catch{m([]),f(new Set)}},[a,l,c,o]);(0,n.useEffect)(()=>{N.current!==e&&(N.current=e,j())},[e,j]),(0,n.useEffect)(()=>{if(!a||!c)return;let e=()=>void j();return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[a,c,j]);let w=()=>{m([]),f(new Set)},z=u.length>0&&x.size===u.length,S=()=>{for(let e of u)!function(e){let t=ef();t.add(e),sessionStorage.setItem(em,JSON.stringify([...t]))}(e.id);w()},C=async()=>{if(!a||p||0===x.size)return;let e=[...x];h(!0),g(null),v(null);try{let t=await (0,i.bulkApproveReservations)({accessToken:a,reservationIds:e}),n=new Set(t.results.filter(e=>"skipped"!==e.status).map(e=>e.reservationId)),r=t.results.filter(e=>"skipped"===e.status).length,l=u.filter(e=>!n.has(e.id));if(r>0&&v(`${r}件は承認できませんでした。`),0===l.length&&0===r){w(),j();return}m(l),f(e=>{let t=new Set(l.map(e=>e.id));return new Set([...e].filter(e=>t.has(e)))}),j()}catch{g("承認に失敗しました。時間をおいて再度お試しください。")}finally{h(!1)}},I=async()=>{p||0===x.size||await k.ensureMicThen(()=>{C()})},M=u.length,E=x.size,_=(0,n.useMemo)(()=>u.filter(e=>x.has(e.id)).reduce((e,t)=>e+ei(t),0),[u,x]);return d&&0!==M?(0,el.createPortal)((0,t.jsxs)(t.Fragment,{children:[k.gateOpen&&(0,t.jsx)("div",{className:"fixed inset-0 z-[80]",children:(0,t.jsx)(eu.MicPermissionDialog,{open:k.gateOpen,onClose:k.closeGate,onPassed:k.passGate,actionLabel:"承認に進む"})}),(0,t.jsxs)("div",{className:"fixed inset-0 z-[70] flex items-end sm:items-center sm:justify-center",children:[(0,t.jsx)("button",{type:"button","aria-label":"閉じる",onClick:S,className:"absolute inset-0 bg-black/60"}),(0,t.jsxs)("div",{className:"relative mx-auto flex max-h-[85vh] w-full max-w-[430px] flex-col rounded-t-2xl bg-white shadow-2xl dark:bg-zinc-900 sm:rounded-2xl",role:"dialog","aria-labelledby":"creator-pending-reservation-title",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:"border-b border-zinc-100 p-5 dark:border-zinc-800",children:[(0,t.jsxs)("h3",{id:"creator-pending-reservation-title",className:"text-center text-base font-bold text-zinc-900 dark:text-zinc-100",children:["承認待ちの予約(",M,"件)"]}),(0,t.jsxs)("label",{className:"mt-3 flex items-center justify-end gap-2 text-sm font-medium text-zinc-700 dark:text-zinc-300",children:[(0,t.jsx)("input",{type:"checkbox",checked:z,onChange:()=>{f(z?new Set:new Set(u.map(e=>e.id)))},className:"size-4 shrink-0 rounded border-zinc-300 text-pink-500 focus:ring-pink-400 dark:border-zinc-600"}),"全選択"]})]}),(0,t.jsx)("ul",{className:"flex-1 divide-y divide-zinc-100 overflow-y-auto dark:divide-zinc-800",children:u.map(e=>{let n=x.has(e.id);return(0,t.jsx)("li",{children:(0,t.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 px-5 py-3 hover:bg-zinc-50 dark:hover:bg-zinc-800/50",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:()=>{var t;return t=e.id,void f(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n})},className:"mt-0.5 size-4 shrink-0 rounded border-zinc-300 text-pink-500 focus:ring-pink-400 dark:border-zinc-600"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100",children:e.memberName??"ファン"}),(0,t.jsxs)("p",{className:"mt-0.5 text-xs text-zinc-500 dark:text-zinc-400",children:[(0,ed.formatJstTime)(new Date(e.scheduledAt)),"(",e.durationMinutes,"分)"]}),(0,t.jsxs)("p",{className:"mt-1 text-xs text-zinc-600 dark:text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-400 dark:text-zinc-500",children:"ポイント(手数料込)"}),(0,t.jsxs)("span",{className:"ml-1 font-semibold text-zinc-900 dark:text-zinc-100",children:[ei(e).toLocaleStr
1ing(),"pt"]})]})]})]})},e.id)})}),(0,t.jsxs)("div",{className:"border-t border-zinc-100 p-5 dark:border-zinc-800",children:[y&&(0,t.jsx)("p",{className:"mb-2 text-center text-xs text-amber-600 dark:text-amber-400",children:y}),b&&(0,t.jsx)("p",{className:"mb-2 text-center text-xs text-rose-600 dark:text-rose-400",children:b}),E>0&&(0,t.jsxs)("p",{className:"mb-2 text-center text-xs text-zinc-500 dark:text-zinc-400",children:["合計 ",_.toLocaleString(),"pt(手数料込)"]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("button",{type:"button",disabled:p||0===E,onClick:()=>void I(),className:"flex items-center justify-center gap-1 rounded-lg bg-pink-500 py-2.5 text-sm font-semibold text-white hover:bg-pink-600 disabled:opacity-50",children:[p&&(0,t.jsx)(ea.Loader2,{className:"size-4 animate-spin","aria-hidden":!0}),"選択した",E,"件を承認"]}),(0,t.jsx)("button",{type:"button",disabled:p,onClick:S,className:"rounded-lg border border-zinc-200 py-2.5 text-sm font-semibold text-zinc-700 disabled:opacity-50 dark:border-zinc-700 dark:text-zinc-300",children:"後で確認する"})]})]})]})]})]}),document.body):null}var eh=e.i(221038),eb=e.i(937202),eg=e.i(311866),ey=e.i(566154),ev=e.i(807263),eN=e.i(138735);function ek({memberName:e,durationSeconds:n,actionLabel:r,hasDraft:a,onOpen:l,onClose:s}){return(0,t.jsx)("div",{role:"status",className:"fixed inset-x-0 bottom-4 z-[60] mx-auto w-[90%] max-w-sm",children:(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-2xl border border-zinc-200 bg-white p-3 shadow-lg dark:border-zinc-700 dark:bg-zinc-900",children:[(0,t.jsxs)("button",{type:"button",onClick:l,className:"flex min-w-0 flex-1 items-center gap-3 text-left",children:[(0,t.jsx)("span",{className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-pink-50 text-pink-600 dark:bg-pink-950 dark:text-pink-400",children:(0,t.jsx)(eN.NotebookPen,{className:"size-5","aria-hidden":!0})}),(0,t.jsxs)("span",{className:"min-w-0",children:[(0,t.jsxs)("span",{className:"block truncate text-sm font-semibold text-zinc-900 dark:text-zinc-100",children:[e??"ファン","さんとの通話が終わりました"]}),(0,t.jsxs)("span",{className:"block text-xs text-zinc-500 dark:text-zinc-400",children:["通話 ",function(e){if(e<=0)return"0秒";let t=Math.floor(e/60),n=e%60;return 0===t?`${n}秒`:0===n?`${t}分`:`${t}分${n}秒`}(n)]}),(0,t.jsxs)("span",{className:"mt-0.5 flex items-center gap-2 text-xs font-semibold",children:[(0,t.jsx)("span",{className:"text-pink-600 dark:text-pink-400",children:r}),a?(0,t.jsx)("span",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"下書きあり"}):null]})]})]}),(0,t.jsx)("button",{type:"button",onClick:s,"aria-label":"閉じる",className:"shrink-0 rounded-lg p-1.5 text-zinc-400 hover:bg-zinc-100 hover:text-zinc-600 dark:hover:bg-zinc-800 dark:hover:text-zinc-200",children:(0,t.jsx)(T.X,{className:"size-4","aria-hidden":!0})})]})})}function ej({creatorId:e,reservationId:r,memberName:a,durationSeconds:l,savedMemo:i,hidden:c,onOpenFanDetail:o,onDone:d}){let{accessToken:u,tryRefresh:m}=(0,s.useAuth)(),[x,f]=(0,n.useState)(i??""),[p,h]=(0,n.useState)(!1),[b,g]=(0,n.useState)(null),{value:y,hasDraft:v,updateDraft:N,settleDraft:k}=(0,ey.useCallMemoDraft)({creatorId:e,reservationId:r,savedValue:x});async function j(e){if(!u)return g(eb.SAVE_FAILED_MESSAGE),!1;g(null);try{let t=await (0,eg.updateReservationAfterMemo)({accessToken:u,reservationId:r,content:e,refreshOnUnauthorized:m});return k(e),f(t.afterMemo??""),h(!1),d(),!0}catch{return g(eb.SAVE_FAILED_MESSAGE),!1}}function w(){(!v||window.confirm(eb.CLOSE_WITH_DRAFT_MESSAGE))&&(g(null),h(!1))}if((0,ev.useUnsavedChangesWarning)(v),c)return null;let z=`${a??"ファン"}さんとの通話メモ`;return(0,t.jsxs)(t.Fragment,{children:[p?null:(0,t.jsx)(ek,{memberName:a,durationSeconds:l,actionLabel:""===x?"メモを書く":"メモを見る・直す",hasDraft:v,onOpen:function(){null===i?o():h(!0)},onClose:d}),p?(0,el.createPortal)((0,t.jsx)("div",{className:"fixed inset-0 z-[60] flex items-end bg-black/50 sm:items-center sm:justify-center",onClick:w,children:(0,t.jsxs)("div",{className:"relative mx-auto max-h-[88vh] w-full max-w-md overflow-y-auto rounded-t-2xl bg-white p-6 dark:bg-zinc-900 sm:rounded-2xl",onClick:e=>
1e.stopPropagation(),role:"dialog","aria-labelledby":"call-ended-memo-title",children:[(0,t.jsx)("h3",{id:"call-ended-memo-title",className:"text-center text-base font-bold text-zinc-900 dark:text-zinc-100",children:"通話メモ"}),(0,t.jsxs)("p",{className:"mt-1 text-center text-xs text-zinc-500 dark:text-zinc-400",children:[a??"ファン","さんとの通話で聞いたことを残しておけます。メモはファンには見えません。"]}),(0,t.jsx)(eh.MemoField,{initialValue:x,value:y,onValueChange:N,onSave:j,label:`${z}の本文`,placeholder:"この通話についての覚え書き",rows:5}),b?(0,t.jsx)("p",{role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:b}):null,(0,t.jsx)("button",{type:"button",onClick:w,className:"mt-4 w-full rounded-xl border border-zinc-200 px-4 py-2 text-sm font-semibold text-zinc-600 hover:bg-zinc-50 dark:border-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-800",children:"あとで書く"})]})}),document.body):null]})}function ew({className:e}){return(0,t.jsx)("p",{className:(0,B.cn)("rounded-lg border border-amber-100 bg-amber-50 px-3 py-2 text-left text-xs text-amber-700 dark:border-amber-900/40 dark:bg-amber-900/20 dark:text-amber-300",e),children:"通話中に他のアプリやサイトへ移動したり、画面をロック(スリープ)すると、相手に声が届かなくなることがあります。通話中はこの画面を開いたままにしてください"})}function ez({callerName:e,callerImageUrl:n,scheduledDurationMinutes:r,showPointWarning:a,onAnswer:l,onDecline:s}){let i,c,o,d=e??"不明なユーザー";return(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:(0,t.jsxs)("div",{className:"w-80 rounded-2xl bg-white p-6 text-center shadow-xl dark:bg-zinc-900",children:[(0,t.jsx)("div",{className:"mx-auto mb-4 size-20 overflow-hidden rounded-full bg-gradient-to-br from-pink-300 to-purple-400",children:n?(0,t.jsx)("img",{src:n,alt:d,className:"size-20 rounded-full object-cover"}):(0,t.jsx)("div",{className:"flex size-20 items-center justify-center text-2xl font-bold text-white",children:d.charAt(0)})}),(0,t.jsx)("p",{className:"mb-1 text-sm text-zinc-500 dark:text-zinc-400",children:"着信"}),(0,t.jsx)("p",{className:"mb-3 text-lg font-semibold text-zinc-900 dark:text-zinc-100",children:d}),null!=r&&(0,t.jsxs)("p",{className:"mb-4 text-sm text-zinc-600 dark:text-zinc-300",children:["予定通話時間 ",r,"分",(0,t.jsxs)("span",{className:"ml-1 text-zinc-400 dark:text-zinc-500",children:["(〜",(c=String((i=new Date(Date.now()+6e4*r)).getHours()).padStart(2,"0"),o=String(i.getMinutes()).padStart(2,"0"),`${c}:${o}`)," まで)"]})]}),a&&(0,t.jsx)("div",{className:"mb-3 rounded-lg border border-amber-100 bg-amber-50 px-3 py-2 text-left text-xs text-amber-700",children:"⚠️ ポイントがなくなると、途中で通話が切れるのでご注意ください。通話中のポイント購入も可能です。"}),(0,t.jsx)(ew,{className:"mb-5"}),(0,t.jsxs)("div",{className:"flex justify-center gap-6",children:[(0,t.jsxs)("button",{type:"button",onClick:s,className:"flex flex-col items-center gap-1",children:[(0,t.jsx)("span",{className:"flex size-14 items-center justify-center rounded-full bg-red-500 text-white hover:bg-red-600",children:(0,t.jsx)(O,{className:"size-6"})}),(0,t.jsx)("span",{className:"text-xs text-zinc-600 dark:text-zinc-400",children:"拒否"})]}),(0,t.jsxs)("button",{type:"button",onClick:l,className:"flex flex-col items-center gap-1",children:[(0,t.jsxs)("span",{className:"relative flex size-14 items-center justify-center rounded-full bg-green-500 text-white hover:bg-green-600",children:[(0,t.jsx)("span",{className:"absolute inset-0 animate-ping rounded-full bg-green-400 opacity-40"}),(0,t.jsx)(et.Phone,{className:"relative size-6"})]}),(0,t.jsx)("span",{className:"text-xs text-zinc-600 dark:text-zinc-400",children:"応答"})]})]})]})})}e.s(["CallPrecautionNote",0,ew],662058);let eS=(0,n.createContext)({startReservationCall:async()=>({ok:!1,message:"not ready"}),startReservationCallWithGate:async()=>({ok:!1,message:"not ready"}),busy:!1});e.s(["CallProvider",0,function({children:e}){let{accessToken:f,memberApiReady:g,memberId:y,hasCreatorProfile:N,myCreatorId:j}=(0,s.useAuth)(),S=(0,r.useRouter)(),{gateOpen:I,speakerTest:E,allowEarlyProceed:_,ensureMicThen:A,passGate:D,closeGate:O}
1=(0,es.useMicPermissionGate)(),[P,R]=(0,n.useState)("応答して通話を開始"),T=(0,n.useRef)(null),L=(0,n.useCallback)(()=>{let e=T.current;T.current=null,e?.(null)},[]),U=(0,n.useCallback)(()=>{L(),O()},[L,O]),[J,$]=(0,n.useState)(null),[B,q]=(0,n.useState)(null),[F,W]=(0,n.useState)(null),G=(0,n.useRef)(null),V=(0,n.useRef)(null),K=(0,n.useRef)(null),H=(0,n.useRef)(null);(0,n.useEffect)(()=>{K.current=B},[B]);let[X,Z]=(0,n.useState)(null),[Y,ee]=(0,n.useState)(0),[et,en]=(0,n.useState)(null),[ea,el]=(0,n.useState)(null),[ei,ec]=(0,n.useState)(null),eo=(0,n.useRef)(null),ed=(0,n.useRef)(null),em=(0,n.useRef)(!1),ex=(0,n.useRef)(null),ef=(0,n.useRef)(f);(0,n.useEffect)(()=>{ef.current=f},[f]);let eh=(0,n.useCallback)(()=>ef.current?(0,a.buildCableUrl)(ef.current):null,[]),{callState:eb,remoteStream:eg,localStream:ey,micSuspended:ev,startCall:eN,joinCall:ek,hangUp:ew,sendCallLog:eC}=function({callId:e,accessToken:t,iceCredentials:r,cableUrl:l,resolveCableUrl:s,primedLocalStreamRef:i,onSignalingMessage:c,onCallEnded:o,onCallDeclined:d}){let[u,f]=(0,n.useState)("idle"),[g,y]=(0,n.useState)(null),[v,N]=(0,n.useState)(null),[k,j]=(0,n.useState)(!1),w=(0,n.useRef)(null),z=(0,n.useRef)(null),S=(0,n.useRef)(null),C=(0,n.useRef)(null),I=(0,n.useRef)(!1),M=(0,n.useRef)(!0),E=(0,n.useRef)(null),_=(0,n.useRef)(null),A=(0,n.useRef)(0),D=(0,n.useRef)(()=>{}),O=(0,n.useRef)("idle");(0,n.useEffect)(()=>{O.current=u},[u]);let P=(0,n.useRef)(s);(0,n.useEffect)(()=>{P.current=s},[s]);let R=(0,n.useCallback)(t=>{let n=z.current;n&&n.readyState===WebSocket.OPEN&&n.send(JSON.stringify({command:"message",identifier:b(e),data:JSON.stringify({action:"relay",...t})}))},[e]),T=(0,n.useCallback)((t,n)=>{let r=z.current;r&&r.readyState===WebSocket.OPEN&&r.send(JSON.stringify({command:"message",identifier:b(e),data:JSON.stringify({action:"report_log",event_type:t,payload:n})}))},[e]),L=(0,n.useCallback)(e=>{e.getAudioTracks().forEach(e=>{e.onmute=()=>{j(!0),T("mic_muted")},e.onunmute=()=>{j(!1),T("mic_unmuted")},e.onended=()=>{T("mic_ended")}})},[T]),U=(0,n.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),J=(0,n.useCallback)(()=>{_.current&&(clearTimeout(_.current),_.current=null)},[]),$=(0,n.useCallback)(()=>{M.current=!0,U(),J(),E.current=null,w.current?.close(),w.current=null,S.current?.getTracks().forEach(e=>e.stop()),S.current=null,N(null),y(null),j(!1),z.current?.close(),z.current=null},[U,J]),B=(0,n.useCallback)(()=>{I.current||(I.current=!0,o?.(null,null),f("ended"),$())},[o,$]),q=(0,n.useCallback)(()=>{if(M.current||I.current||_.current)return;let e=A.current;A.current=e+1,_.current=setTimeout(()=>{_.current=null,D.current()},Math.min(500*2**e,8e3))},[]),F=(0,n.useCallback)(()=>{if(M.current||I.current||!l)return;let e=E.current;if(!e)return;let t=z.current;if(t&&(t.readyState===WebSocket.OPEN||t.readyState===WebSocket.CONNECTING))return;let n=new WebSocket(P.current?.()??l);z.current=n,n.onopen=()=>{A.current=0,e.onOpen(n)},n.onmessage=e.onMessage,n.onerror=()=>{try{n.close()}catch{}},n.onclose=()=>{z.current===n&&(z.current=null),M.current||I.current||q()}},[l,q]);(0,n.useEffect)(()=>{D.current=F},[F]),(0,n.useEffect)(()=>{let e=()=>{if(M.current||I.current)return;let e=z.current;e&&(e.readyState===WebSocket.OPEN||e.readyState===WebSocket.CONNECTING)||(J(),A.current=0,D.current())},t=()=>{"visible"===document.visibilityState&&e()};return window.addEventListener("online",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("online",e),document.removeEventListener("visibilitychange",t)}},[J]);let W=(0,n.useCallback)((e,t)=>{e.oniceconnectionstatechange=()=>{let n=e.iceConnectionState;if("connected"===n||"completed"===n)U();else if("disconnected"===n){if(t?.onDisconnected?.(),C.current)return;C.current=setTimeout(()=>{C.current=null,B()},1e4)}else"failed"===n&&(U(),B())}},[U,B]),G=(0,n.useCallback)(async()=>{if(e&&l&&r&&t)try{f("connecting"),I.current=!1,M.current=!1,A.current=0;let n=await (0,m.takePrimedOrAcquireCallAudio)(i);S.current=n,N(n),L(n);let l=new RTCPeerConnection({iceServers:r.iceServers});w.current=l;let s=x(()=>w.current);
1n.getTracks().forEach(e=>l.addTrack(e,n)),l.ontrack=e=>{y(p(e))};let u=null,g=async()=>{l.localDescription?.type!=="offer"&&(u??=(async()=>{let e=await l.createOffer();await l.setLocalDescription(e)})(),await u)},v=!1,k=async(e=!1)=>{if(e){v=!0;let e=await l.createOffer({iceRestart:!0});await l.setLocalDescription(e)}else await g();let t=l.localDescription?.sdp;t&&R({type:"offer",sdp:t})};W(l,{onDisconnected:()=>{k(!0).catch(()=>void 0)}});let j=async e=>{let t;try{t=JSON.parse(e.data)}catch{return}let n=t.message;n&&(c?.(n),"call_answered"===n.type||"ready_for_offer"===n.type?await k():"answer"===n.type&&n.sdp?(await l.setRemoteDescription({type:"answer",sdp:n.sdp}),v=!1,await s.flush(),f("connected")):"ice_candidate"===n.type&&n.candidate?await s.enqueue(n.candidate):"call_declined"===n.type?(d?.(),f("ended"),$()):"call_ended"===n.type&&(I.current||(I.current=!0,o?.(n.duration_seconds??null,h(n.reason))),f("ended"),$()))};l.onicecandidate=e=>{e.candidate&&R({type:"ice_candidate",candidate:e.candidate.toJSON()})},E.current={onOpen:n=>{if(n.send(JSON.stringify({command:"subscribe",identifier:b(e)})),"connected"===O.current){v&&k().catch(()=>void 0);return}f("ringing"),(0,a.fetchCall)({accessToken:t,callId:e}).then(e=>{if("connected"===e.status)return k()}).catch(()=>void 0)},onMessage:j},F()}catch{f("error"),$()}},[e,l,r,t,i,R,$,W,F,c,o,d,L]),V=(0,n.useCallback)(async()=>{if(e&&l&&r)try{f("connecting"),I.current=!1,M.current=!1,A.current=0;let t=await (0,m.takePrimedOrAcquireCallAudio)(i);S.current=t,N(t),L(t);let n=new RTCPeerConnection({iceServers:r.iceServers});w.current=n,W(n);let a=x(()=>w.current);t.getTracks().forEach(e=>n.addTrack(e,t)),n.ontrack=e=>{y(p(e))};let l=async e=>{let t;try{t=JSON.parse(e.data)}catch{return}if("confirm_subscription"===t.type){"connected"!==O.current&&R({type:"ready_for_offer"});return}let r=t.message;if(r)if(c?.(r),"offer"===r.type&&r.sdp){await n.setRemoteDescription({type:"offer",sdp:r.sdp}),await a.flush();let e=await n.createAnswer();await n.setLocalDescription(e),R({type:"answer",sdp:e.sdp}),f("connected")}else"ice_candidate"===r.type&&r.candidate?await a.enqueue(r.candidate):"call_declined"===r.type?(d?.(),f("ended"),$()):"call_ended"===r.type&&(I.current||(I.current=!0,o?.(r.duration_seconds??null,h(r.reason))),f("ended"),$())};n.onicecandidate=e=>{e.candidate&&R({type:"ice_candidate",candidate:e.candidate.toJSON()})},E.current={onOpen:t=>{t.send(JSON.stringify({command:"subscribe",identifier:b(e)}))},onMessage:l},F()}catch{f("error"),$()}},[e,l,r,i,R,$,W,F,c,o,d,L]),K=(0,n.useCallback)(()=>{I.current=!0,f("ended"),$()},[$]);return(0,n.useEffect)(()=>{if("connected"!==u)return;let e=setInterval(()=>{let e=w.current;e&&e.getStats().then(e=>{let t=[];e.forEach(e=>t.push(e)),T("stats",function(e){let t={};for(let n of e)"audio"===n.kind&&("media-source"===n.type?"number"==typeof n.audioLevel&&(t.audio_level=n.audioLevel):"outbound-rtp"===n.type?"number"==typeof n.packetsSent&&(t.packets_sent=n.packetsSent):"inbound-rtp"===n.type&&("number"==typeof n.packetsReceived&&(t.packets_received=n.packetsReceived),"number"==typeof n.audioLevel&&(t.inbound_audio_level=n.audioLevel)));return t}(t))}).catch(()=>void 0)},1e4);return()=>clearInterval(e)},[u,T]),(0,n.useEffect)(()=>()=>{$()},[$]),{callState:u,localStream:v,remoteStream:g,micSuspended:k,startCall:G,joinCall:V,hangUp:K,sendCallLog:T}}({callId:B?.session.id??null,accessToken:f,iceCredentials:B?.ice??null,cableUrl:B?.cable??null,resolveCableUrl:eh,primedLocalStreamRef:H,onCallEnded:(e,t)=>{let n=K.current;em.current="insufficient_points"===t,f&&n&&(0,a.endCall)({accessToken:f,callId:n.session.id}),"insufficient_points"===t&&W(n?.payer?"ポイントが不足したため通話が終了しました":"相手のポイントが不足したため通話が終了しました"),q(null)},onCallDeclined:()=>q(null)});(0,n.useEffect)(()=>{B&&("caller"===B.role?eN():ek())},[B?.session.id]);let eI=(0,n.useCallback)(()=>{f&&(0,c.fetchPointBalance)({accessToken:f}).then(e=>{let t=ed.current;Z(e.balance),ee(null!=t?Math.floor((Date.now()-t)/1e3):0)}).catch(()=>{})},[f]);!function({callId:e,cableUrl:t,enabled:r,onPointGranted:a}){let l=(0,n.useRef)(null),s=(0,n.useRef)(a);(0,n.useEffect)(()=>{s.current=a},[a]),(0,n.useEffect)(()=>
1{if(!r||!e||!t)return;let n=JSON.stringify({channel:"CallMeteringChannel",call_id:e}),a=new WebSocket(t);l.current=a;let i=null,c=()=>{a.readyState===WebSocket.OPEN&&a.send(JSON.stringify({command:"message",identifier:n,data:JSON.stringify({action:"keepalive"})}))};return a.onopen=()=>{a.send(JSON.stringify({command:"subscribe",identifier:n}))},a.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if("confirm_subscription"===t.type&&t.identifier===n){if(i)return;c(),i=setInterval(c,15e3);return}if("reject_subscription"===t.type&&t.identifier===n){i&&clearInterval(i),i=null;return}t.message?.type==="point_granted"&&s.current?.()},()=>{i&&clearInterval(i),a.close(),l.current=null}},[r,e,t])}({callId:B?.payer?B.session.id:null,cableUrl:B?.payer?B.cable:null,enabled:(B?.payer??!1)&&"connected"===eb,onPointGranted:eI}),(0,n.useEffect)(()=>{if("connected"===eb)ed.current=Date.now();else if("ended"===eb){let e=ex.current;if(e?.payer){let t=null!=ed.current?Math.floor((Date.now()-ed.current)/1e3):0,n=null!=e.pricePerMinute?t>0?M(t,e.pricePerMinute):0:null,r=em.current;(t>0||null!=n||r)&&en({durationSeconds:t,consumedPoints:n,creatorName:e.partnerName,creatorProfileImageUrl:e.partnerImageUrl,endedByInsufficientPoints:r,callId:e.callId})}ed.current=null,em.current=!1,ee(0)}},[eb]),(0,n.useEffect)(()=>{if(!f||!g)return;let e=!0;return(0,c.fetchPointBalance)({accessToken:f}).then(t=>{e&&Z(t.balance)}).catch(()=>{}),()=>{e=!1}},[f,g]);let eM=(0,n.useCallback)(async()=>{if(f&&!K.current){try{let{reservations:e}=await (0,i.fetchMyReservations)({accessToken:f}),t=e.find(e=>"started"===e.status&&e.callId&&"member"!==e.callInitiatedBy);if(t?.callId){let e=await (0,a.fetchCall)({accessToken:f,callId:t.callId});if("pending"===e.status&&"member"!==e.initiatedBy&&!K.current)return void $(e=>e||{callId:t.callId,creatorId:t.creatorId,callerName:t.creatorName,callerImageUrl:t.creatorImageUrl,scheduledDurationMinutes:t.durationMinutes,initiatedBy:"creator",reservationId:null,memberId:null})}}catch{}if(!0===N&&!K.current)try{let{reservations:e}=await (0,i.fetchCreatorReservations)({accessToken:f}),t=e.find(e=>"started"===e.status&&e.callId&&"member"===e.callInitiatedBy);if(!t?.callId)return;let n=await (0,a.fetchCall)({accessToken:f,callId:t.callId});if("pending"!==n.status||"member"!==n.initiatedBy||K.current)return;$(e=>e||{callId:t.callId,creatorId:t.creatorId,callerName:t.memberName,callerImageUrl:t.memberImageUrl,scheduledDurationMinutes:t.durationMinutes,initiatedBy:"member",reservationId:t.id,memberId:t.memberId})}catch{}}},[f,N]);(0,n.useEffect)(()=>{if(!y||!f||!g)return;let e=JSON.stringify({channel:"MemberCallNotificationsChannel",member_id:y}),t=!1,n=0,r=null,l=e=>{let t;try{t=JSON.parse(e.data)}catch{return}let n=t.message;!n||("call_resolved"===n.type?$(e=>e&&e.callId===n.call_id?null:e):"incoming_call"===n.type&&n.call_id&&n.creator_id&&"member"!==n.initiated_by&&(K.current||$({callId:n.call_id,creatorId:n.creator_id,callerName:n.caller_name??null,callerImageUrl:n.caller_image_url??null,scheduledDurationMinutes:n.scheduled_duration_minutes??null,initiatedBy:"creator",reservationId:null,memberId:null})))},s=()=>{r&&(clearTimeout(r),r=null)},i=()=>
1{if(t)return;let s=G.current;if(s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING))return;let c=new WebSocket((0,a.buildCableUrl)(f));G.current=c,c.onopen=()=>{n=0,c.send(JSON.stringify({command:"subscribe",identifier:e})),eM()},c.onmessage=l,c.onerror=()=>{try{c.close()}catch{}},c.onclose=()=>{G.current===c&&(G.current=null),t||(()=>{if(t||r)return;let e=Math.min(1e3*2**n,1e4);n+=1,r=setTimeout(()=>{r=null,i()},e)})()}},c=()=>{n=0,s(),i(),eM()},o=()=>{"visible"===document.visibilityState&&c()};return i(),document.addEventListener("visibilitychange",o),window.addEventListener("online",c),()=>{t=!0,s(),document.removeEventListener("visibilitychange",o),window.removeEventListener("online",c),G.current?.close(),G.current=null}},[y,f,g,eM]),(0,n.useEffect)(()=>{if(!f||!g||!0!==N)return;let e=JSON.stringify({channel:"CreatorCallNotificationsChannel"}),t=!1,n=0,r=null,l=e=>{let t;try{t=JSON.parse(e.data)}catch{return}let n=t.message;n&&("call_resolved"===n.type?$(e=>e&&e.callId===n.call_id?null:e):"incoming_call"!==n.type||!n.call_id||!n.creator_id||n.initiated_by&&"member"!==n.initiated_by||K.current||$({callId:n.call_id,creatorId:n.creator_id,callerName:n.caller_name??null,callerImageUrl:n.caller_image_url??null,scheduledDurationMinutes:n.scheduled_duration_minutes??null,initiatedBy:"member",reservationId:null,memberId:null}))},s=()=>{r&&(clearTimeout(r),r=null)},i=()=>
1{if(t)return;let s=V.current;if(s&&(s.readyState===WebSocket.OPEN||s.readyState===WebSocket.CONNECTING))return;let c=new WebSocket((0,a.buildCableUrl)(f));V.current=c,c.onopen=()=>{n=0,c.send(JSON.stringify({command:"subscribe",identifier:e})),eM()},c.onmessage=l,c.onerror=()=>{try{c.close()}catch{}},c.onclose=()=>{V.current===c&&(V.current=null),t||(()=>{if(t||r)return;let e=Math.min(1e3*2**n,1e4);n+=1,r=setTimeout(()=>{r=null,i()},e)})()}},c=()=>{n=0,s(),i(),eM()},o=()=>{"visible"===document.visibilityState&&c()};return i(),document.addEventListener("visibilitychange",o),window.addEventListener("online",c),()=>{t=!0,s(),document.removeEventListener("visibilitychange",o),window.removeEventListener("online",c),V.current?.close(),V.current=null}},[f,g,N,eM]),(0,n.useEffect)(()=>{let e=()=>{let e;(e=k())&&("suspended"===e.state&&e.resume().catch(()=>{}),w(e).catch(()=>{}))},t={once:!0,passive:!0};return window.addEventListener("pointerdown",e,t),window.addEventListener("keydown",e,t),()=>{window.removeEventListener("pointerdown",e),window.removeEventListener("keydown",e)}},[]);let eE=(0,n.useCallback)(async()=>{if(!0!==N)return;let e=ex.current;if(!e||e.payer)return;let t=eo.current,n=null!=t?Math.floor((Date.now()-t)/1e3):0,r=e.reservationId,a=e.memberId,l=e.memberName,s=null;if(f)try{({reservations:s}=await (0,i.fetchCreatorReservations)({accessToken:f}))}catch{s=null}let c=s?d(s,{reservationId:r,callId:e.callId}):void 0;if(!r||!a){if(!c)return;r=c.id,a=c.memberId,l=c.memberName}r&&a&&el({reservationId:r,memberId:a,memberName:l,durationSeconds:n,savedMemo:c?c.afterMemo??"":null})},[f,N]),e_=(0,n.useRef)("idle");(0,n.useEffect)(()=>{let e=e_.current;if(e_.current=eb,"connected"===eb&&(eo.current=Date.now()),"connected"===e&&"ended"===eb){let e;(e=k())&&(e.resume().catch(()=>{}),z(e,v,.18,e.currentTime)),eE()}},[eb,eE]);let eA=B?.session.id??null,eD=!!B&&!B.payer,eO=B?.session.callerMemberId??null;(0,n.useEffect)(()=>{if(!eA||!eD||!eO||!0!==N)return;let e=ef.current;if(!e)return;let t=!1,n=ex.current?.reservationId??null;return(0,i.fetchCreatorReservations)({accessToken:e}).then(({reservations:e})=>{if(t)return;let r=d(e,{reservationId:n,callId:eA});ec({callId:eA,memos:u(e,eO,r?.id??n)})}).catch(()=>{}),()=>{t=!0}},[eA,eD,eO,N]),C(J?"ringtone":null),(0,n.useEffect)(()=>{J||U()},[J,U]);let eP=(0,n.useCallback)(async()=>{if(!J||!f)return;let e="creator"===J.initiatedBy;try{let[t,n]=await Promise.all([(0,a.answerCall)({accessToken:f,callId:J.callId}),(0,a.fetchIceCredentials)({accessToken:f})]),r=null;if(e)try{let{reservations:e}=await (0,i.fetchMyReservations)({accessToken:f}),t=e.find(e=>e.callId===J.callId||e.creatorId===J.creatorId&&("started"===e.status||"confirmed"===e.status));t&&(r=t.pointPerMinute)}catch{}ex.current={payer:e,partnerName:J.callerName,partnerImageUrl:J.callerImageUrl,pricePerMinute:r,callId:t.id,reservationId:J.reservationId,memberId:J.memberId,memberName:J.callerName},q({role:"callee",payer:e,session:t,ice:n,cable:(0,a.buildCableUrl)(f),partnerName:J.callerName,partnerImageUrl:J.callerImageUrl,pricePerMinute:r,serverOffsetMs:(0,a.serverClockOffsetMs)(t.serverNow)}),$(null)}catch{$(null)}},[J,f]),eR=(0,n.useCallback)(async()=>{if(J&&f)try{await (0,a.declineCall)({accessToken:f,callId:J.callId})}catch{}finally{$(null)}},[J,f]),eT=(0,n.useCallback)(()=>{let e=K.current;f&&e&&("caller"===e.role&&"connected"!==eb?(0,a.declineCall)({accessToken:f,callId:e.session.id}):(0,a.endCall)({accessToken:f,callId:e.session.id})),ew(),q(null)},[f,ew,eb]),eL=(0,n.useCallback)(async(e,{as:t="creator"}={})=>{if(!f)return{ok:!1,message:"ログインが必要です"};if(K.current)return{ok:!1,message:"すでに通話中です"};let n="member"===t,r=n?e.creatorName:e.memberName,s=n?e.creatorImageUrl:e.memberImageUrl,c=n?e.pointPerMinute:null,o=null;try{o=await (0,m.primeCallAudio)()}catch{return{ok:!1,message:"マイクにアクセスできませんでした。Safari の「設定 → Safari → マイク」でこのサイトを許可するか、URL バー左の aA → ウェブサイトの設定 からマイクを許可してから再度お試しください。"}}H.current=o;try{let l=n?await (0,i.startReservationAsMember)({accessToken:f,reservationId:e.id}):await (0,i.startReservationAsCreator)({accessToken:f,reservationId:e.id}),d=l.callId;if(!d)return(0,m.stopMediaStream)(o),H.current=null,{ok:!1,message:"通話の
1開始に失敗しました"};let u=await (0,a.fetchIceCredentials)({accessToken:f});return ex.current={payer:n,partnerName:r,partnerImageUrl:s,pricePerMinute:c,callId:d,reservationId:e.id,memberId:e.memberId,memberName:e.memberName},q({role:"caller",payer:n,session:{id:d,callerMemberId:e.memberId,creatorId:e.creatorId,status:"pending",initiatedBy:t,connectedAt:null,durationSeconds:null,authorizedSeconds:60*e.durationMinutes,expiresAt:l.expiresAt,serverNow:l.serverNow??null,createdAt:e.scheduledAt},ice:u,cable:(0,a.buildCableUrl)(f),partnerName:r,partnerImageUrl:s,pricePerMinute:c,serverOffsetMs:(0,a.serverClockOffsetMs)(l.serverNow)}),{ok:!0}}catch(e){if((0,m.stopMediaStream)(o),H.current=null,e instanceof l.ApiError&&409===e.status&&e.body?.error==="opponent_ringing")return eM(),{ok:!1,message:"相手から発信されています。着信に応答してください"};return{ok:!1,message:e instanceof l.ApiError&&"string"==typeof e.body?.message?e.body.message:"通話の開始に失敗しました。予約時間内かご確認ください。"}}},[f,eM]),eU=(0,n.useCallback)((e,t={})=>new Promise(n=>{L(),T.current=n,R("通話を開始"),A(()=>{T.current=null,eL(e,t).then(n)},{speakerTest:!0})}),[L,A,eL]),eJ=(0,n.useCallback)(()=>{L(),R("応答して通話を開始"),A(()=>void eP(),{speakerTest:!0,allowEarlyProceed:!0})},[L,A,eP]),e$=null!=J||null!=B,eB=B?.session.creatorId??null,eq=B?B.payer?y:B.session.callerMemberId:null,eF=B?.payer?"member":"creator",eW=(0,n.useMemo)(()=>eB&&eq?{creatorId:eB,memberId:eq,viewer:eF}:null,[eB,eq,eF]);return(0,t.jsxs)(eS.Provider,{value:{startReservationCall:eL,startReservationCallWithGate:eU,busy:e$},children:[e,J&&!B&&(0,t.jsx)(ez,{callerName:J.callerName,callerImageUrl:J.callerImageUrl,scheduledDurationMinutes:J.scheduledDurationMinutes,showPointWarning:"creator"===J.initiatedBy,onAnswer:eJ,onDecline:()=>void eR()}),(0,t.jsx)(eu.MicPermissionDialog,{open:I,onClose:U,onPassed:D,actionLabel:P,speakerTest:E,allowEarlyProceed:_}),(0,t.jsx)(Q,{callState:eb,remoteStream:eg,localStream:ey,creatorName:B?.partnerName??null,creatorProfileImageUrl:B?.partnerImageUrl,isCaller:B?.role==="caller",micSuspended:ev,onLogEvent:eC,pricePerMinute:B?.payer?B.pricePerMinute:void 0,authorizedSeconds:B?.session.authorizedSeconds,expiresAt:B?.session.expiresAt,serverOffsetMs:B?.serverOffsetMs,pointBalance:B?.payer?X:void 0,balanceAsOfSeconds:Y,onHangUp:eT,pastMemos:B&&!B.payer&&ei?.callId===B.session.id?ei.memos:void 0,onOpenChat:(()=>{let e=B?.session.creatorId;if(!e)return;let t=B.payer?y:B.session.callerMemberId;if(t)return()=>S.push(o.routes.directMessageThread(e,t))})(),directMessage:eW},B?.session.id),et&&(0,t.jsx)(er,{creatorName:et.creatorName,creatorProfileImageUrl:et.creatorProfileImageUrl,durationSeconds:et.durationSeconds,consumedPoints:et.consumedPoints,endedByInsufficientPoints:et.endedByInsufficientPoints,callId:et.callId,accessToken:f,onClose:()=>en(null)}),ea&&(0,t.jsx)(ej,{creatorId:j,reservationId:ea.reservationId,memberName:ea.memberName,durationSeconds:ea.durationSeconds,savedMemo:ea.savedMemo,hidden:null!==J||I||"connecting"===eb||"ringing"===eb||"connected"===eb,onOpenFanDetail:()=>{let e=`${o.routes.creator.dashboard.fanDetail(ea.memberId)}#call-${encodeURIComponent(ea.reservationId)}`;el(null),S.push(e)},onDone:()=>el(null)},ea.reservationId),(0,t.jsx)(ep,{}),F&&(0,t.jsx)("div",{className:"fixed inset-x-0 top-4 z-[60] mx-auto w-[90%] max-w-sm",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-amber-50 px-4 py-3 text-sm font-medium text-amber-700 shadow-lg ring-1 ring-amber-200",children:[(0,t.jsx)("span",{children:F}),(0,t.jsx)("button",{type:"button",onClick:()=>W(null),className:"shrink-0 rounded-md px-2 py-1 text-xs font-semibold text-amber-600 hover:bg-amber-100",children:"閉じる"})]})})]})},"useCallContext",0,function(){return(0,n.useContext)(eS)}],318525)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.