PageSourceSearch

https://travelvibes.ai/_next/static/chunks/4123.b8fa12214dae437a.js

js travelvibes.ai collected 2026-10-05 14:54:00 UTC 139,792 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="889a93d7-502e-435a-914c-6abe30c5f8b0",e._sentryDebugIdIdentifier="sentry-dbid-889a93d7-502e-435a-914c-6abe30c5f8b0")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4123],{53971:(e,t,r)=>{async function o(){try{var e,t,r;let o=window.Clerk;return null!=(r=await (null==o||null==(t=o.session)||null==(e=t.getToken)?void 0:e.call(t)))?r:null}catch(e){return null}}async function a(){let e=await o();return{"Content-Type":"application/json",...e?{"X-Clerk-Session-Token":e}:{}}}r.d(t,{k:()=>a})},62793:(e,t,r)=>{r.d(t,{B:()=>o});function o(e,t){return t?"$".concat(parseFloat(e.toPrecision(8))):"$".concat((Math.ceil(100*e)/100).toFixed(2))}},74123:(e,t,r)=>{r.r(t),r.d(t,{InfoTip:()=>eh,JsonDebugOverlay:()=>ef,extractErrorMessage:()=>em,parseHtmlToDocNode:()=>eb});var o=r(95155),a=r(12115),n=r(47650),s=r(97600),l=r(16456),i=r(34101),c=r(31763),d=r(29592),u=r(65550);let p=l.Ik({entity_id:l.Yj().min(1),place_id:l.Yj().min(1),name:l.Yj().min(1).optional().nullable(),address:l.Yj().min(1).optional().nullable(),location:l.Ik({lat:l.ai().nullable(),lng:l.ai().nullable()}).optional().nullable(),rating:l.ai().min(0).max(5).optional().nullable(),website_url:l.Yj().optional().nullable(),photo_name:l.Yj().optional().nullable(),photo_url:l.Yj().optional().nullable(),rating_count:l.ai().optional().nullable(),price_level:l.Yj().optional().nullable(),price_range:l.Yj().optional().nullable(),opening_hours:l.Yj().optional().nullable(),is_open_now:l.zM().optional().nullable(),business_status:l.Yj().optional().nullable(),place_type:l.Yj().optional().nullable(),types:l.YO(l.Yj()).optional().nullable(),utc_offset:l.ai().optional().nullable(),google_maps_url:l.Yj().optional().nullable(),phone:l.Yj().optional().nullable()});var h=r(72341),m=r(85750),b=r(62793),g=r(26444),x=r(4701),f=r(95644),y=r(83731),v=r(44671),k=r(50727),w=r(33931),j=r(66377),N=r(17e3),S=r(84109),C=r(4652),T=r(39498),D=r(50099),E=r(91497),P=r(3454),I=r(34494),A=r(75928),_=r(28336),O=r(90681),F=r(18653),R=r(70595),B=r(18067),U=r(2180),L=r(75645),M=r(53971),H=r(16350),z=r(46693),W=r(28923),K=r(10823),J=r(72251);let G=[{value:"travels as a couple",label:"Traveling with",key:"companions",emoji:"\uD83D\uDC6B"},{value:"relaxed, no alarm clocks",label:"Pace",key:"pace",emoji:"\uD83D\uDC22"},{value:"temples, gardens, architecture photography",label:"Must-sees",key:"must_sees",emoji:"\uD83D\uDC40"}];var Y=r(66050);let $="rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text)",V="rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) disabled:opacity-40";function X(e){var t,r,n;let s,{tripId:l}=e,i=(0,c.useUiStore)(e=>e.debugToken),d=(0,c.useUiStore)(e=>e.debugAdminToken),u=(0,c.useUiStore)(e=>e.setDebugAdminToken),p=(0,c.useUiStore)(e=>e.debugFullPrecisionCost),[h,m]=(0,a.useState)(!1),[g,x]=(0,a.useState)(""),[f,y]=(0,a.useState)(null),[v,k]=(0,a.useState)(""),[w,j]=(0,a.useState)(null),[N,S]=(0,a.useState)(null),[C,T]=(0,a.useState)(!1),[D,E]=(0,a.useState)(""),[P,I]=(0,a.useState)(!1),[A,_]=(0,a.useState)(""),[O,F]=(0,a.useState)(""),[R,B]=(0,a.useState)(""),[U,L]=(0,a.useState)(""),[M,H]=(0,a.useState)(!1),z=()=>({"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{},...d?{"X-Debug-Admin-Token":d}:{}}),W=e=>null==e?"–":(0,b.B)(e,p);async function K(){y(null);try{let e=await fetch("/api/debug-auth",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}},body:JSON.stringify({scope:"admin",adminCode:g})}),t=await e.json().catch(()=>({}));(null==t?void 0:t.ok)&&t.adminToken?(u(t.adminToken),x("")):y((null==t?void 0:t.error)==="admin_not_configured"?"DEBUG_ADMIN_CODE not configured":"Wrong password")}catch(e){y("Request failed")}}async function J(){S(null),T(!0),j(null);try{let t=await fetch("/api/debug/user-admin",{method:"POST",headers:z(),body:JSON.stringify({action:"lookup",identifier:v,tripId:l})});if(403===t.status){u(null),S("Admin session expired — re-enter password");return}let r=await t.json().catch(()=>({}));if(!t.ok){var e;S(null!=(e=null==r?void 0:r.error)?e:"Error ".concat(t.status));return}j(r),E(""),_(""),F(""),B(""),L(""),H(!1)}catch(e){S("Request failed")}finally{T(!1)}}async function G(e,t,r,o){S(null),T(!0);try{let a=await fetch("/api/debug/user-admin",{method:"POST",headers:z(),body:JSON.stringify({action:"write",identifier:v,field:e,value:t,expectedCurrentValue:r,tripId:l,...o})});if(403===a.status){u(null),S("Admin session expired — re-enter password");return}let n=await a.json().catch(()=>({}));if(!a.ok)return void S((null==n?void 0:n.error)?"".concat(n.error).concat(null!=n.currentValue?" (current ".concat(W(n.currentValue),")"):""):"Error ".concat(a.status));await J()}catch(e){S("Request failed")}finally{T(!1)}}let Y="text-(--tt-gray-light-400) dark:text-(--tt-gray-dark-600)",X="rounded-md bg-(--tt-sidebar-bg-color) px-2 py-0.5 text-[11px] font-mono";return(0,o.jsxs)("div",{className:"px-3 md:px-4 py-2 border-t border-t-amber-500/30",children:[(0,o.jsx)("div",{className:"mb-1 text-[10px] font-medium text-amber-600 dar
1k:text-amber-400",children:"User Admin — changes ANOTHER user's real rate-limit state (gated by admin password)"}),h?d?(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,o.jsx)("input",{placeholder:"email / user_… / distinctId",value:v,onChange:e=>k(e.target.value),onKeyDown:e=>"Enter"===e.key&&v.trim()&&J(),className:"".concat($," w-64")}),(0,o.jsx)("button",{type:"button",onClick:J,disabled:C||!v.trim(),className:V,children:C?"…":"Get current costs"}),(0,o.jsx)("button",{type:"button",onClick:()=>u(null),className:V,title:"Revoke admin session",children:"Lock"})]}),N&&(0,o.jsx)("div",{className:"rounded border border-rose-500/30 bg-rose-500/10 px-2 py-1 text-[11px] font-mono text-rose-700 dark:text-rose-200",children:N}),w&&(0,o.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px] font-mono",children:[w.identity.email&&(0,o.jsx)("span",{children:w.identity.email}),w.links.personUrl&&(0,o.jsx)("a",{href:w.links.personUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",children:"[PH]"}),(0,o.jsx)("span",{className:Y,children:(s=w.identity.canonicalKey).length>18?s.slice(0,18)+"…":s}),!w.identity.matchedClerkUser&&(0,o.jsx)("span",{className:"text-amber-500",children:"no clerk match"})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[(0,o.jsxs)("span",{className:X,children:["User: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:W(w.userCost)})]}),(0,o.jsxs)("span",{className:X,children:["Snap: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:W(w.snapshot)})]}),(0,o.jsxs)("span",{className:X,children:["Spend: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:W(w.cycleSpend)})," / ",W(w.budget),(0,o.jsx)(eh,{text:"Cycle spend = User − Snap; limit hits at budget (+ paid & granted credit)."})]}),(0,o.jsxs)("span",{className:X,children:["Granted: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:W(w.grantedCredit)}),(0,o.jsx)(eh,{text:"Non-expiring granted credit: raises the free cap / extends the subscriber cycle allowance. Survives renewal and cancellation."})]}),null!=w.tripCost&&(0,o.jsxs)("span",{className:X,children:["Trip: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:W(w.tripCost)})]}),(0,o.jsxs)("span",{className:X,children:["Bypass: ",(0,o.jsx)("span",{className:w.bypass?"text-green-500":"text-(--tt-theme-text)",children:w.bypass?"ON":"OFF"})]}),(0,o.jsxs)("span",{className:X,children:["Sub: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:(null==(t=w.subscription)?void 0:t.active)?"".concat(null!=(r=w.subscription.plan)?r:"?"," $").concat(((null!=(n=w.subscription.priceCents)?n:0)/100).toFixed(0)):"none"})]})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("button",{type:"button",onClick:()=>void G("bypass",!w.bypass),disabled:C,className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(w.bypass?"border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-300":V),children:w.bypass?"Bypass OFF":"Bypass ON (1h)"}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:"grant $",value:D,onChange:e=>E(e.target.value),className:"".concat($," w-20")}),(0,o.jsx)("button",{type:"button",onClick:function(){if(!w)return;let e=parseFloat(D);if(!Number.isFinite(e))return void S("Invalid grant amount");G("grantedCredit",w.grantedCredit+e,w.grantedCredit)},disabled:C||!D,className:V,children:"Grant credit"}),(0,o.jsx)(eh,{text:"Adds $X of non-expiring granted credit — works for free AND paid users, survives renewals and cancellation. No ceiling on this human lever."})]}),(0,o.jsx)("button",{type:"button",onClick:()=>I(e=>!e),className:V,children:P?"Hide advanced":"Advanced"})]}),P&&(0,o.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-lg border border-(--tt-border-color) p-2",children:[(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("span",{className:"".concat(Y," w-16 text-[11px]"),children:"User $"}),(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:W(w.userCost),value:A,onChange:e=>_(e.target.value),className:"".concat($," w-24")}),(0,o.jsx)("button",{type:"button",disabled:C||!A,onClick:()=>void G("userCost",parseFloat(A),w.userCost),className:V,children:"Set (abs)"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("span",{className:"".concat(Y," w-16 text-[11px]"),children:"Snap $"}),(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:W(w.snapshot),value:O,onChange:e=>F(e.target.value),className:"".concat($," w-24")}),(0,o.jsx)("button",{type:"button",disabled:C||!O,onClick:()=>{var e;G("snapshot",parseFloat(O),null!=(e=w.snapshot)?e:0)},className:V,children:"Set (abs)"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("span",{className:"".concat(Y," w-16 text-[11px]"),children:"Granted $"}),(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:W(w.grantedCredit),value:R,onChange:e=>B(e.target.value),className:"".concat($," w-24")}),(0,o.jsx)("button",{type:"button",disabled:C||!R,onClick:()=>void G("grantedCredit",parseFloat(R),w.grantedCredit),className:V,children:"Set (abs)"})]}),l&&(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,o.jsx)("span",{className:"".concat(Y," w-16 text-[11px]"),children:"Trip $"}),(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:W(w.tripCost),value:U,onChange:e=>L(e.target.value),className:"".concat($," w-24")}),(0,o.jsxs)("label",{className:"flex items-center gap-1 text-[10px] text-amber-500",children:[(0,o.jsx)("input",{type:"checkbox",checked:M,onChange:e=>H(e.target.checked)}),"global (not user-specific)"]}),(0,o.jsx)("button",{type:"button",disabled:C||!U||!M,onClick:()=>{var e;G("tripCost",parseFloat(U),null!=(e=w.tripCost)?e:0,{confirmGlobalTripCost:!0})},className:V,children:"Set (abs)"})]})]})]})]}):(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("input",{type:"password",placeholder:"Admin password",value:g,onChange:e=>x(e.target.value),onKeyDown:e=>"Enter"===e.key&&K(),className:"".concat($," w-44")}),(0,o.jsx)("button",{type:"button",onClick:K,disabled:!g,className:V,children:"Unlock"}),(0,o.jsx)("button",{type:"button",onClick:()=>{m(!1),x(""),y(null)},className:V,children:"Cancel"}),f&&(0,o.jsx)("span",{className:"text-xs text-red-500",children:f})]}):(0,o.jsx)("button",{type:"button",onClick:()=>m(!0),className:V,children:"Change user cost (remote)…"})]})}let Z=[{id:"anthropic/claude-sonnet-5",label:"Anthropic \xb7 Sonnet 5"},{id:"anthropic/claude-sonnet-4.6",label:"Anthropic \xb7 Sonnet 4.6 (prod)"},{id:"anthropic/claude-sonnet-4.5",label:"Anthropic \xb7 Sonnet 4.5"},{id:"anthropic/claude-opus-5",label:"Anthropic \xb7 Opus 5"},{id:"anthropic/claude-opus-4-8",label:"Anthropic \xb7 Opus 4.8"},{id:"anthropic/claude-opus-4-5-20251101",label:"Anthropic \xb7 Opus 4.5"},{id:"anthropic/claude-haiku-4-5",label:"Anthropic \xb7 Haiku 4.5"},{id:"openai/gpt-5.2",label:"OpenAI \xb7 GPT-5.2"},{id:"google/gemini-3-flash",label:"Google \xb7 Gemini 3 Flash"},...(0,r(6878).SW)()],q=[{plan:"starter",cents:400,label:"Starter $4 (legacy)"},{plan:"starter",cents:800,label:"Starter $8 (new)"},{plan:"power",cents:1600,label:"Power $16 (legacy)"},{plan:"power",cents:2e3,label:"Power $20 (new)"}],Q=[{value:"vegetarian",label:"Dietary",key:"diet",emoji:"\uD83E\uDD6C"},{value:"travels solo",label:"Traveling with",key:"companions",emoji:"\uD83E\uDDCD"},{value:"high energy, 18k steps/day",label:"Pace",key:"pace",emoji:"⚡"},{value:"food halls, rooftops, comedy",label:"Must-sees",key:"must_sees",emoji:"\uD83D\uDC40"}],ee=[{label:"Free Trip 1 — Chalmette, LA (big itinerary)",documentId:"90d95bf6-d5a1-4782-aeda-4ef167dc8669"},{label:"Free Trip 2 — Schenectady, NY (Unlock+PDF)",documentId:"8573b39b-0eb6-4ec9-8f77-d6b3b7e5cff7"},{label:"Free Trip 3 — Winter Garden, FL (long chat)",documentId:"e136bec2-9a97-4f38-af07-1ff577d3789a"},{label:"Free Trip 4 — Seattle, WA",documentId:"295199f1-625a-4252-a302-26442ef8b22e"}];function et(e){var t,r;let{editor:n,ydoc:s,tripId:l,debugToken:i,onClose:p,setError:h,setSuccess:b,updateOverlayFromEditor:$,setEntitiesJson:V}=e,et=(0,y.sf)(),[er,eo]=(0,a.useState)(!1),[ea,en]=(0,a.useState)(()=>{var e,t;return null!=(t=null==(e=et.has_opted_out_capturing)?void 0:e.call(et))&&t}),[es,el]=(0,a.useState)(()=>c.useUiStore.getState().debugDelayUsageSSE?"delayUsageSSE":""),[ei,ec]=(0,a.useState)(!1),[ed,eu]=(0,a.useState)(null),[ep,eg]=(0,a.useState)(!1),[ex,ef]=(0,a.useState)(!1),[ey,ev]=(0,a.useState)(!1),[ek,ew]=(0,a.useState)(!1),[ej,eN]=(0,a.useState)(!1),[eS,eC]=(0,a.useState)(()=>{var e,t;return null!=(t=null==(e=n.storage.contentLock)?void 0:e.shouldLock)&&t}),[eT,eD]=(0,a.useState)(null),[eE,eP]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=()=>{try{eP((0,B.W2)(s,{expensive:!0}))}catch(e){}};e();let t=setInterval(e,2500);return()=>clearInterval(t)},[s]);let[eI,eA]=(0,a.useState)(!1),[e_,eO]=(0,a.useState)(""),[eF,eR]=(0,a.useState)(""),[eB,eU]=(0,a.useState)(!1),[eL,eM]=(0,a.useState)(null),[eH,ez]=(0,a.useState)(!1),eW=async()=>
1{if(!eB){eU(!0),h(null),b(null);try{let e=(0,g.m7)(s),t=(0,g.r8)(s,e),r=n.getHTML(),o=await fetch("/api/debug/test-cache-poison-log",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}},body:JSON.stringify({messages:t,chatId:e,documentId:l,documentHtml:r,tripId:l,tripUrl:window.location.href})}),a=await o.json().catch(()=>({}));if(!o.ok||!(null==a?void 0:a.ok))throw Error((null==a?void 0:a.error)||"HTTP ".concat(o.status));let c=a.blobUrl||"(no URL returned)";b("Cache-poison test OK.\nChat: ".concat(e," (").concat(a.chatMessagesCount," msgs)\nBP1: ").concat(a.systemPromptBytes,"B \xb7 Doc: ").concat(a.documentBytes,"B \xb7 Total messages in blob: ").concat(a.messagesCount,"\nTrace: ").concat(a.traceId,"\nBlob: ").concat(c,'\nPostHog event "chat:cache_poison_suspected" fired with test=true.'))}catch(e){h("Cache-poison test failed: ".concat(em(e)))}finally{eU(!1)}}},eK=async()=>{try{var e;let t=await fetch("/api/debug/bedrock-throttle-status",{headers:{...i?{Authorization:"Bearer ".concat(i)}:{}}}),r=await t.json().catch(()=>null);(null==r?void 0:r.ok)&&eM({throttled:!!r.throttled,untilMs:null!=(e=r.untilMs)?e:null})}catch(e){}},eJ=async()=>{h(null),b(null);try{let e=await fetch("/api/debug/set-bedrock-throttle",{method:"POST",headers:{...i?{Authorization:"Bearer ".concat(i)}:{}}}),t=await e.json().catch(()=>({}));if(!e.ok||!(null==t?void 0:t.ok))throw Error((null==t?void 0:t.error)||"HTTP ".concat(e.status));b("Set the Bedrock throttle flag. Next chat request goes straight to AI Gateway (no Bedrock).")}catch(e){h("Set Bedrock throttle failed: ".concat(em(e)))}finally{eK()}},eG=async()=>{h(null),b(null);try{let e=await fetch("/api/debug/clear-bedrock-throttle",{method:"POST",headers:{...i?{Authorization:"Bearer ".concat(i)}:{}}}),t=await e.json().catch(()=>({}));if(!e.ok||!(null==t?void 0:t.ok))throw Error((null==t?void 0:t.error)||"HTTP ".concat(e.status));b("Cleared the Bedrock throttle flag (Redis + local mirror). Bedrock is used again.")}catch(e){h("Clear Bedrock throttle failed: ".concat(em(e)))}finally{eK()}},eY=async()=>{if(!eH){ez(!0),h(null),b(null);try{var e;let t=await fetch("/api/debug/bedrock-model-check",{headers:{...i?{Authorization:"Bearer ".concat(i)}:{}}}),r=await t.json().catch(()=>({}));if(!t.ok||!(null==r?void 0:r.ok))throw Error((null==r?void 0:r.error)||"HTTP ".concat(t.status));let o=r.results.map(e=>{var t;return"".concat(e.ok?"✅":"❌"," ").concat(e.label," \xb7 ").concat(e.bedrockId).concat(e.wired?"":" (NOT in routing map → Gateway)"," — ")+"".concat(e.ok?"".concat(e.latencyMs,"ms"):null!=(t=e.error)?t:"failed")});b("Bedrock activation — region ".concat(null!=(e=r.region)?e:"?",", USE_BEDROCK=").concat(r.useBedrock,":\n").concat(o.join("\n")))}catch(e){h("Bedrock activation check failed: ".concat(em(e)))}finally{ez(!1)}}},[e$,eV]=(0,a.useState)(!1),eX=async()=>{if(e$)return;if(d.useTripStore.getState().autoRecoveryInProgress)return void h("Auto-recovery is already running for this trip — wait for it to finish or reload.");if(!window.confirm("Reset this device's local copy of the trip?\n\nDeletes this browser's IndexedDB copy and RELOADS into the server copy.\nNothing is written to the server — the canonical document is untouched.\nAnything this device never managed to sync is lost with the copy.\n\nThe page will reload. Use a disposable test-trip for testing."))return;if(eV(!0),h(null),b(null),!l){h("No trip id"),eV(!1);return}b("Resetting — deleting the local copy, then reloading…");let e=await (0,F.c)({room:l,source:"debug"});e.ok||(h("wipe_blocked"===e.reason?"IndexedDB delete BLOCKED — another tab still holds this trip's database. Close it and retry.":"offline"===e.reason?"Refused: the browser is offline. The reset re-downloads the document, so it needs a connection.":"Local reset failed: ".concat(em(e.error))),eV(!1))},[eZ,eq]=(0,a.useState)(!1),[eQ,e0]=(0,a.useState)("starter"),[e1,e5]=(0,a.useState)(800),[e2,e3]=(0,a.useState)(""),[e6,e4]=(0,a.useState)(""),[e8,e7]=(0,a.useState)(""),[e9,te]=(0,a.useState)(null),tt=(0,c.useUiStore)(e=>e.debugModelId),tr=(0,c.useUiStore)(e=>e.setDebugModelId),to=(0,c.useUiStore)(e=>e.debugStripeTestMode),ta=(0,c.useUiStore)(e=>e.setDebugStripeTestMode),tn=(0,c.useUiStore)(e=>e.debugToolBlocksCollapsed),ts=(0,c.useUiStore)(e=>
1e.setDebugToolBlocksCollapsed),tl=(0,c.useUiStore)(e=>e.debugFullPrecisionCost),ti=(0,c.useUiStore)(e=>e.setDebugFullPrecisionCost),tc=(0,c.useUiStore)(e=>e.setDebugDelayUsageSSE),td=(0,c.useUiStore)(e=>e.debugRateLimitBypass),tu=(0,c.useUiStore)(e=>e.setDebugRateLimitBypass),tp=(0,c.useUiStore)(e=>e.debugForceFree),th=(0,c.useUiStore)(e=>e.setDebugForceFree),tm=(0,c.useUiStore)(e=>e.debugSignUpGateBypass),tb=(0,c.useUiStore)(e=>e.setDebugSignUpGateBypass),tg=(0,c.useUiStore)(e=>e.debugSimulateUploadFail),tx=(0,c.useUiStore)(e=>e.setDebugSimulateUploadFail),tf=(0,U.S)(e=>e.checkStatus);(0,a.useEffect)(()=>{var e;let t=null==(e=et.get_distinct_id)?void 0:e.call(et),r=new URLSearchParams;t&&r.set("distinctId",t),l&&r.set("tripId",l),t&&i&&fetch("/api/debug/subscription-status?".concat(new URLSearchParams({distinctId:t})),{headers:{Authorization:"Bearer ".concat(i)}}).then(e=>e.json()).then(e=>{var t;eq(null!=(t=null==e?void 0:e.active)&&t),(null==e?void 0:e.plan)&&e0(e.plan),"number"==typeof(null==e?void 0:e.priceCents)&&e5(e.priceCents)}).catch(()=>{}),t&&fetch("/api/rate-limit/debug-bypass?".concat(new URLSearchParams({distinctId:t})),{headers:i?{Authorization:"Bearer ".concat(i)}:{}}).then(e=>e.json()).then(e=>{var t;return tu(null!=(t=null==e?void 0:e.bypass)&&t)}).catch(()=>{}),eK()},[l]);let ty=async()=>{if(!eT){eD("iceland"),h(null),b(null);try{let e=await fetch("/api/sample-document/iceland",{method:"GET"}),t=await e.json();if(!e.ok||!(null==t?void 0:t.ok))throw Error("string"==typeof(null==t?void 0:t.error)?t.error:"Failed to load sample (".concat(e.status,")"));let r="string"==typeof(null==t?void 0:t.html)?t.html:"";if(!r.trim())throw Error("Sample HTML is empty.");let o=(0,Y.DI)(r);try{eb(n,o).check()}catch(e){console.warn("[debug] Iceland sample schema validation warning:",e)}n.commands.setContent(o),$(),b("Loaded Iceland sample document from disk.")}catch(e){h(em(e))}finally{eD(null)}}},tv=async()=>{if(!eT){eD("keywest"),h(null),b(null);try{let e=await fetch("/api/sample-document/key-west",{method:"GET"}),t=await e.json();if(!e.ok||!(null==t?void 0:t.ok))throw Error("string"==typeof(null==t?void 0:t.error)?t.error:"Failed to load sample (".concat(e.status,")"));let r="string"==typeof(null==t?void 0:t.markdown)?t.markdown:"";if(!r.trim())throw Error("Sample markdown is empty.");let o=await fetch("/api/gpt/create_trip_draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({initial_context:r,user_preferences:Q})}),a=await o.json();if(!o.ok||!(null==a?void 0:a.ok))throw Error("string"==typeof(null==a?void 0:a.error)?a.error:"Failed to create trip (".concat(o.status,")"));let n=a.trip_url;if(!n)throw Error("No trip_url returned from API");b("Created trip. Redirecting in 1 second...");let s=es?n+"?simulateCollabTimeout=".concat(es):n;await new Promise(e=>setTimeout(e,1e3)),window.location.href=s}catch(e){h(em(e))}finally{eD(null)}}},tk=async()=>{if(!eT){eD("keywest-simple"),h(null),b(null);try{let e=await fetch("/api/sample-document/key-west-simple",{method:"GET"}),t=await e.json();if(!e.ok||!(null==t?void 0:t.ok))throw Error("string"==typeof(null==t?void 0:t.error)?t.error:"Failed to load sample (".concat(e.status,")"));let r="string"==typeof(null==t?void 0:t.markdown)?t.markdown:"";if(!r.trim())throw Error("Sample markdown is empty.");let o=await fetch("/api/gpt/create_trip_draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({initial_context:r,user_preferences:Q})}),a=await o.json();if(!o.ok||!(null==a?void 0:a.ok))throw Error("string"==typeof(null==a?void 0:a.error)?a.error:"Failed to create trip (".concat(o.status,")"));let n=a.trip_url;if(!n)throw Error("No trip_url returned from API");b("Created trip. Redirecting in 1 second...");let s=es?n+"?simulateCollabTimeout=".concat(es):n;await new Promise(e=>setTimeout(e,1e3)),window.location.href=s}catch(e){h(em(e))}finally{eD(null)}}},tw=async(e,t,r)=>{if(!eT){eD(e),h(null),b(null);try{let e=await fetch("/api/gpt/create_trip_draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({initial_context:t,user_preferences:r})}),o=await e.json();if(!e.ok||!(null==o?void 0:o.ok))throw Error("string"==typeof(null==o?void 0:o.error)?o.error:"Failed to create trip (".concat(e.status,")"));let a=o.trip_url;if(!a)throw Error("No trip_url returned from API");b("Created trip. Redirecting in 1 second...");let n=es?a+"?simulateCollabTimeout=".concat(es):a;await new Promise(e=>setTimeout(e,1e3)),window.location.href=n}catch(e){h(em(e))}finally{eD(null)}}},tj=async()=>{let e;if(!eT&&e_.trim()){if(eF.trim()){let t;try{t=JSON.parse(eF)}
1catch(e){h("user_preferences is not valid JSON");return}if(!Array.isArray(t))return void h("user_preferences must be a JSON array");e=t}eD("custom-import"),h(null),b(null);try{let t=await fetch("/api/gpt/create_trip_draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({initial_context:e_,...e?{user_preferences:e}:{}})}),r=await t.json();if(!t.ok||!(null==r?void 0:r.ok))throw Error("string"==typeof(null==r?void 0:r.error)?r.error:"Failed to create trip (".concat(t.status,")"));let o=r.trip_url;if(!o)throw Error("No trip_url returned from API");b("Created trip. Redirecting..."),eA(!1);let a=es?o+"?simulateCollabTimeout=".concat(es):o;await new Promise(e=>setTimeout(e,1e3)),window.location.href=a}catch(e){h(em(e))}finally{eD(null)}}},tN=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"d83fc5f4-fff6-48e0-8602-5e01313e4c25",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"demo";if(eT)return;eD(t),h(null),b(null);let r=null;try{let t=await fetch("/api/collaboration",{method:"POST"}),o=await t.json(),a=null==o?void 0:o.token;if(!a)throw Error("Failed to get collaboration token");let l=new f.JA,i="".concat(m.LH).concat(e);r=new v.d3({name:i,appId:m.r4,token:a,document:l}),await new Promise((e,t)=>{let o=setTimeout(()=>{t(Error("Sync timeout (10s) - source document may not exist"))},1e4);r.on("synced",()=>{clearTimeout(o),e()})});let c=(0,g.m7)(l,null),d=(0,g.r8)(l,c),p=(0,u.Q2)(l),h={};p.forEach((e,t)=>{h[t]=e});let y="",F=null;try{F=new x.KE({extensions:[k.W,w.OV.configure({document:l}),j.xJ,j.Q1,N.z,S.n.configure({types:["heading","paragraph"]}),C.f4.configure({multicolor:!0}),T._0,T.L2.configure({nested:!0}),D.o5,E.R,P.d,I._,A.G,_.w,O._]}),await new Promise(e=>setTimeout(e,500)),y=F.getHTML()}catch(e){}finally{null==F||F.destroy()}let R=(0,g.m7)(s,null);if(s.transact(()=>{(0,g.g7)(s,R),(0,g.Ex)(s,R,d);let e=(0,u.Q2)(s);for(let t of Array.from(e.keys()))e.delete(t);for(let[e,t]of Object.entries(h))(0,u.W_)(s,e,t)}),(0,g.z1)(s,R),y.trim()&&n.commands.setContent(y),$(),V(JSON.stringify(h,null,2)),b("Loaded from ".concat(e,": ").concat(d.length," messages, ").concat(Object.keys(h).length," entities. Reloading in 2s...")),r)try{r.destroy(),r=null}catch(e){}await new Promise(e=>setTimeout(e,2e3)),window.location.reload()}catch(e){h(em(e)),eD(null)}finally{if(r)try{r.destroy()}catch(e){}}},tS="text-[10px] w-14 shrink-0 font-medium text-(--tt-gray-light-400) dark:text-(--tt-gray-dark-600)";return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"shrink-0 border-b border-b-(--tt-border-color) px-3 md:px-4 py-1.5 md:py-2",children:[(0,o.jsx)("div",{className:"mb-1 text-[10px] font-medium text-(--tt-gray-light-500) dark:text-(--tt-gray-dark-600)",children:"Settings — only affects your view"}),(0,o.jsxs)("div",{className:"grid md:grid-cols-2 gap-x-4 gap-y-1 items-start",children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"AI"}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("span",{className:"text-[10px] text-(--tt-gray-light-500) dark:text-(--tt-gray-dark-500)",children:"Planning"}),(0,o.jsx)("select",{value:tt,onChange:e=>tr(e.target.value),className:"h-7 rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 text-[11px] text-(--tt-theme-text) focus:outline-none focus:ring-1 focus:ring-(--tt-border-color)","aria-label":"Planning model",children:Z.map(e=>(0,o.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,o.jsx)(eh,{text:"Model used for normal planning chat responses."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>ti(!tl),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(tl?"border-violet-500/50 bg-violet-500/10 text-violet-700 dark:text-violet-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Cost ",tl?"FULL":"ROUNDED"]}),(0,o.jsx)(eh,{text:"Show full precision cost or rounded to 2 decimals"})]}),(0,o.jsx)("span",{className:"inline-flex items-center rounded-full px-2.5 py-1 text-[11px] font-semibold "+(null===eL?"bg-(--tt-gray-light-100) text-(--tt-gray-light-500) dark:bg-(--tt-gray-dark-100) dark:text-(--tt-gray-dark-500)":eL.throttled?"bg-rose-500/15 text-rose-700 dark:text-rose-300":"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300"),title:"Current shared Bedrock throttle flag (Redis). Throttled = chat routes to AI Gateway.",children:null===eL?"Bedrock: …":eL.throttled?"Throttled → Gateway":"Bedrock active"}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:eJ,className:"rounded-lg border border-orange-500/50 bg-orange-500/10 px-3 py-1 text-xs font-medium text-orange-700 transition-colors hover:bg-orange-500/20 dark:text-orange-300",children:"Set throttle"}),(0,o.jsx)(eh,{text:"Set the shared Bedrock throttle flag (Redis). The next chat request routes straight to AI Gateway with NO Bedrock call — this is the fleet-wide failover. Non-prod only."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:eG,className:"rounded-lg border border-emerald-500/50 bg-emerald-500/10 px-3 py-1 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-500/20 dark:text-emerald-300",children:"Clear throttle"}),(0,o.jsx)(eh,{text:"Delete the shared Bedrock throttle flag (Redis) so Bedrock 
1is used again immediately."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:eY,disabled:eH,className:"rounded-lg border border-sky-500/50 bg-sky-500/10 px-3 py-1 text-xs font-medium text-sky-700 transition-colors hover:bg-sky-500/20 disabled:opacity-40 dark:text-sky-300",children:eH?"Checking…":"Check activation"}),(0,o.jsx)(eh,{text:"Live 1-token probe of each model directly on AWS Bedrock (bypassing the Gateway fallback). Confirms Opus 4.8 / Sonnet 5 / Fable 5 actually invoke on Bedrock — result shows ✅/❌ + latency. Models not in the routing map are flagged (they currently go via Gateway). Safe in prod."})]})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"Flags"}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>{let e=!eS;n.commands.setContentLockDebugOverride(e),eC(e)},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(eS?"border-rose-500/50 bg-rose-500/10 text-rose-700 dark:text-rose-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Content Lock ",eS?"ON":"OFF"]}),(0,o.jsx)(eh,{text:"Show/hide Day 3+ paywall lock in your editor only"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>ts(!tn),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(tn?"border-sky-500/50 bg-sky-500/10 text-sky-700 dark:text-sky-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Tool blocks ",tn?"COLLAPSED":"EXPANDED"]}),(0,o.jsx)(eh,{text:"Collapse tool/step debug blocks in the chat panel"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>tb(!tm),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(tm?"border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Sign-Up Gate ",tm?"OFF":"ON"]}),(0,o.jsx)(eh,{text:"Bypass the sign-up/login gate so you can chat without being interrupted. Client-side only."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>tx(!tg),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(tg?"border-rose-500/50 bg-rose-500/10 text-rose-700 dark:text-rose-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Simulate upload fail ",tg?"ON":"OFF"]}),(0,o.jsx)(eh,{text:"Force /api/uploads/files to fail with a synthetic network error so you can test the uploadFailed banner + Retry flow. In-memory only — page reload resets it."})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,o.jsx)("span",{className:"text-xs font-medium text-(--tt-theme-text)",children:"S11 frame:"}),[1024,2048,4096,8192].map(e=>(0,o.jsxs)("button",{type:"button",onClick:()=>{window.confirm("Inject ONE ".concat(e/1024,"MB incompressible update into THIS trip's Y.Doc?\n\nIf the single frame exceeds the server message limit → close 1009 + reconnect loop. Use only on a disposable test-trip."))&&d.useTripStore.getState()._debugInjectLargeDocState({sizeKB:e})},className:"rounded-lg border border-rose-500/50 bg-rose-500/10 px-2 py-1 text-xs font-medium text-rose-700 transition-colors hover:bg-rose-500/20 dark:text-rose-300",children:[e/1024,"MB"]},e)),(0,o.jsx)("button",{type:"button",onClick:()=>{window.confirm("Write 40 \xd7 100KB as SEPARATE small updates (~4MB total) into THIS trip?\n\nGrows total state but each frame is small → should NOT trigger 1009 (control: proves total size is irrelevant). Disposable test-tr
1ip only.")&&d.useTripStore.getState()._debugInjectLargeDocState({mode:"many",sizeKB:100,count:40})},className:"rounded-lg border border-amber-500/50 bg-amber-500/10 px-2 py-1 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-500/20 dark:text-amber-300",children:"Many\xd7small"}),(0,o.jsx)("button",{type:"button",onClick:()=>{window.confirm('Arm the "Document is locked" banner for THIS trip?\n\nNothing happens yet — pressing Repair on the banner then runs the real recovery: it tears down collab, rebuilds the document server-side, and WIPES this browser\'s local copy. Disposable test-trip only.')&&d.useTripStore.setState({lockedDocDetected:!0})},className:"rounded-lg border border-rose-500/50 bg-rose-500/10 px-2 py-1 text-xs font-medium text-rose-700 transition-colors hover:bg-rose-500/20 dark:text-rose-300",children:"Arm locked-doc"}),(0,o.jsx)("button",{type:"button",onClick:()=>{d.useTripStore.getState()._debugClearOversized()},className:"rounded-lg border border-emerald-500/50 bg-emerald-500/10 px-2 py-1 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-500/20 dark:text-emerald-300",children:"Clear"}),(0,o.jsx)("button",{type:"button",onClick:()=>{if(window.confirm("Simulate Maria's case on THIS trip?\n\n1) Inject a ~120MB oversized update → close 1009 + reconnect loop\n2) Add a REAL scratchpad edit + chat message that get STUCK behind it\n\nResult: server stays small, client balloons, real edits never sync.\n~120MB is safely over the ~100MB threshold observed in prod. Disposable test-trip ONLY.\nIf no 1009 appears, bump higher in console: _debugInjectLargeDocState({ sizeKB: 200000 }).")){h(null),b(null);try{let e="UNSYNCED-".concat(Date.now().toString(36));d.useTripStore.getState()._debugInjectLargeDocState({sizeKB:122880}),n.commands.focus("end"),n.commands.insertContent("<p>".concat(e," scratchpad edit during flicker</p>"));let t=(0,g.m7)(s),r=(0,g.r8)(s,t);(0,g.Ex)(s,t,[...r,{id:"u-".concat(e),role:"user",parts:[{type:"text",text:"".concat(e," chat msg during flicker")}]}]),b("Simulated. Marker: ".concat(e,"\n")+"Watch console for '[S11] WS close 1009' + the offline banner flicker.\n"+"Server should stay unchanged — confirm with: node --env-file=.env.local scripts/measure-ydoc-size.mjs ".concat(null!=l?l:"<tripId>","\n")+"EXPECTED AFTER THE RESET (inverted by TRA-778): doc size small, sync OK, and the marker GONE. The repair deletes this device’s local copy; the marker was written after the 1009 started, so it never reached the server and goes with the copy. Accepted trade, not a regression — the readable scratchpad is versioned out of band by the manual-edit backup spine. Before TRA-778 the repair uploaded this copy instead, which is what re-minted every id and doubled other devices.")}catch(e){h(em(e))}}},className:"rounded-lg border border-fuchsia-500/50 bg-fuchsia-500/10 px-2 py-1 text-xs font-medium text-fuchsia-700 transition-colors hover:bg-fuchsia-500/20 dark:text-fuchsia-300",children:"Simulate Maria"}),(0,o.jsx)("button",{type:"button",onClick:()=>{if(window.confirm("Simulate dean's case (content_oversized) on THIS trip?\n\nInjects ~8MB of base64 image content into the SCRATCHPAD (a content root that\ncompaction KEEPS). Then click 'Recover': the compacted doc stays > 4MB →\nrecovery FAILS with reason=content_oversized (our self-imposed cap).\n\nDisposable test-trip ONLY.")){h(null),b(null);try{let e=e=>{let t=Math.ceil(3*e/4),r="";for(let e=0;e<t;e+=48e3){let o=Math.min(48e3,t-e),a=new Uint8Array(o);crypto.getRandomValues(a);let n="";for(let e=0;e<o;e++)n+=String.fromCharCode(a[e]);r+=btoa(n)}return r},t=Math.ceil(8);n.commands.focus("end");for(let r=0;r<t;r++){let t=e(1048576);n.commands.insertContent('<img src="data:image/png;base64,'.concat(t,'" alt="dean-sim-').concat(r,'">'))}b("Injected ~".concat("8","MB base64 into the scratchpad (").concat(t," images).\n")+"NOTE (TRA-778): 'content_oversized' no longer exists — the client rebuild that owned that cap is gone.\n~8MB is under maxPayload, so this content SYNCS — it lives in the canonical, not stuck locally. 'Reset local copy' therefore does nothing for this class: the reload pulls the same base64 straight back. That is the honest outcome — a CONTENT problem (relocate-base64), not a local-history one.")}catch(e){h(em(e))}}},className:"rounded-lg border border-purple-500/50 bg-purple-500/10 px-2 py-1 text-xs font-medium text-purple-700 transition-colors hover:bg-purple-500/20 dark:text-purple-300",children:"Simulate dean"}),(0,o.jsx)("button",{type:"button",onClick:eX,disabled:e$,className:"rounded-lg border border-sky-500/50 bg-sky-500/10 px-2 py-1 text-xs font-medium text-sky-700 transition-colors hover:bg-sky-500/20 dark:text-sky-300 "+(e$?"opacity-60 cursor-not-allowed":""),children:e$?"Resetting…":"Reset local copy"}),(0,o.jsx)("button",{type:"button",onClick:()=>
1{if(d.useTripStore.getState().oversizedDocAtLoad){b(null),h("Doc is OVERSIZED — in-place Heal can't sync its deletes over the 1009-stuck WebSocket (it would only change THIS tab → false success). Use 'Reset local copy' first, then Heal once the reloaded doc is syncing again.");return}let e=(0,R.q_)(s);if(window.confirm("Heal scratchpad duplication on THIS trip?\n\n"+"detectSelfDuplication → duplicated=".concat(e.duplicated,", factor=").concat(e.factor," (1 = clean)\n\n")+"Runs dedupeScratchpad on the LIVE local doc IN PLACE. Deletions sync to the server over\nWS as Yjs tombstones → duplicates won't return from a stale IDB. IDB is NOT wiped; chat stays.\nIf the doc is OVERSIZED (WS stuck in 1009), use 'Reset local copy' first.\n\nTest on a CLONE first.")){h(null),b(null);try{let e=(0,R.zd)(s);b("Healed. Removed ".concat(e.removedBlocks," blocks in ").concat(e.runsRemoved," run(s); kept ").concat(e.keptBlocks,".\n")+"Title factor ".concat(e.titleFactorBefore," → ").concat(e.titleFactorAfter," (1 = clean).\n")+"Deletions are syncing to the server over WS. Reload + open in a 2nd browser to confirm: content\nappears once and an edit to existing text applies (no multiple_matches).")}catch(e){h(em(e))}}},className:"rounded-lg border border-teal-500/50 bg-teal-500/10 px-2 py-1 text-xs font-medium text-teal-700 transition-colors hover:bg-teal-500/20 dark:text-teal-300",children:"Heal duplication"}),(0,o.jsx)(eh,{text:"TRA-531 heal: runs dedupeScratchpad on the LIVE local doc in place — removes repeated contiguous block-runs (lossless for legit repeats like per-city 'Where to Eat'). Deletions sync to the server over WS as Yjs tombstones, so duplicates don't return from a stale IDB; IDB is NOT wiped so chat stays. Use on a NORMAL-size doc (WS alive). If the doc is OVERSIZED (1009 loop), reset the local copy first, then heal the reloaded doc. Verify after: content appears once and an edit to existing text applies without multiple_matches. Test on a CLONE first."}),(0,o.jsx)(eh,{text:"TRA-510 recovery: runs the fix — captures scratchpad + chat, backs up to Redis, wipes the bloated local IndexedDB, rebuilds from the clean server copy, and re-applies your content. Stops the 1009 loop, shrinks the doc, preserves edits. After clicking, verify the UNSYNCED-… marker survived and the console shows no more 1009. Pairs with 'Simulate Maria'."}),(0,o.jsx)(eh,{text:"TRA-510 repro: recreates Maria's incident — injects a ~120MB oversized update (→ close 1009 + reconnect loop, so the server stays SMALL while the client Y.Doc balloons) AND makes a REAL scratchpad edit + chat message that get stuck behind the un-syncable frame. Server-side stays unchanged (verify with scripts/measure-ydoc-size.mjs). Use this to develop + verify the recovery: after the fix, the marker edit/message must survive, doc size must shrink, and sync must succeed. Disposable test-trip ONLY."}),(0,o.jsx)(eh,{text:"S11 probe (per-MESSAGE theory). Each rose button writes ONE incompressible (random-bytes) update of that size in one transaction → one WS frame. If a frame exceeds the server maxPayload, Tiptap closes with 1009 and HocuspocusProvider auto-reconnects → syncStep2 re-sends it → loop. Sweep 1→8MB (Clear between) to find the real limit. 'Many\xd7small' writes 40\xd7100KB as separate small frames (large total, small frames) → should NOT trigger, proving total Y.Doc size is irrelevant. 'Clear' empties travelvibes:__debug_oversized in local state → stops a running 1009 loop (poison-pill cure). Watch console for 'Outbound frame: X KB' + '[S11] WS close 1009'. WARNING: writes into the CURRENT trip and propagates to Tiptap Cloud — disposable test-trip only."})]})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"IDB metrics"}),eE?(0,o.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 font-mono text-[11px] text-gray-600 dark:text-gray-400",children:[(0,o.jsxs)("span",{children:["size ",(0,o.jsxs)("b",{children:[(eE.bytes/1024).toFixed(1),"KB"]})]}),(0,o.jsxs)("span",{children:["structs ",(0,o.jsx)("b",{children:null!=(t=eE.structs)?t:"—"})]}),(0,o.jsxs)("span",{children:["del ",(0,o.jsx)("b",{children:null!=(r=eE.deletedStructs)?r:"—"})]}),(0,o.jsxs)("span",{children:["reEnc ",(0,o.jsx)("b",{children:null!=eE.reencodeRatio?eE.reencodeRatio.toFixed(2):"—"})]}),(0,o.jsxs)("span",{children:["dupF ",(0,o.jsx)("b",{children:eE.dupFactor})]}),(0,o.jsxs)("span",{children:["clients ",(0,o.jsx)("b",{children:eE.clients})]}),(0,o.jsxs)("span",{children:["blocks ",(0,o.jsx)("b",{children:eE.scratchpadBlocks})]}),(0,o.jsxs)("span",{children:["msgs ",(0,o.jsx)("b",{children:eE.chatMsgCount})]}),(0,o.jsxs)("span",{children:["snaps ",(0,o.jsx)("b",{children:eE.docSnapshotCount})]}),(0,o.jsxs)("span",{children:["ent ",(0,o.jsx)("b",{children:eE.entityCount})]})]}):(0,o.jsx)("span",{className:"text-[11px] text-gray-500",children:"measuring…"}),(0,o.jsx)(eh,{text:"TRA-531 live Y.Doc metrics (measureDocMetrics, expensive incl. structs/reEnc/dupFactor). Watch during a session: structs climbing across reconnects = re-persist churn (#1);
1 dupF>1 = self-duplication; snaps/ent only growing = uncapped content. After the P1+ fixes these stay flat: size ∝ content, dupF=1, snaps≤7, structs steady across reconnects."})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"Payments"}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>ta(!to),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(to?"border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Stripe ",to?"TEST":"LIVE"]}),(0,o.jsx)(eh,{text:"Use Stripe test mode for checkouts — no real charges"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsxs)("button",{type:"button",onClick:async()=>{var e;let t=null==(e=et.get_distinct_id)?void 0:e.call(et);if(!t)return;let r=eZ&&!tp,o=!r;th(r);let a=await fetch("/api/subscription/debug-reset",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}},body:JSON.stringify({distinctId:t,setActive:o,plan:eQ,priceCents:e1})});if(!a.ok)return void h("Sub toggle failed (".concat(a.status,"): re-enter debug mode to refresh token"));eq(o),await tf()},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(eZ&&!tp?"border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Sub: ",eZ&&!tp?"".concat(eQ.toUpperCase()," $").concat(e1/100):"OFF"]}),eZ&&!tp&&(0,o.jsxs)("select",{value:"".concat(eQ,":").concat(e1),onChange:async e=>{var t;let[r,o]=e.target.value.split(":"),a=Number(o);e0(r),e5(a);let n=null==(t=et.get_distinct_id)?void 0:t.call(et);n&&(await fetch("/api/subscription/debug-reset",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}},body:JSON.stringify({distinctId:n,setActive:!0,plan:r,priceCents:a})}),await tf())},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text)",children:[!q.some(e=>"".concat(e.plan,":").concat(e.cents)==="".concat(eQ,":").concat(e1))&&(0,o.jsx)("option",{value:"".concat(eQ,":").concat(e1),disabled:!0,children:"".concat(eQ.toUpperCase()," $").concat(e1/100," (current)")}),q.map(e=>(0,o.jsx)("option",{value:"".concat(e.plan,":").concat(e.cents),children:e.label},"".concat(e.plan,":").concat(e.cents)))]}),(0,o.jsx)(eh,{text:"Toggle your subscription + choose tier/version (writes plan + priceCents to Redis; current door = $4 Starter / $20 Power, grandfathered $8 Starter / $16 Power for price-based budgets $4→$3, $8→$5). OFF also sets a sticky per-request 'force free' override so even a real Stripe subscriber stays free for chat — the self-heal can't bounce it back. Free cost gate then applies: $1.50 → blocking modal."})]})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"Costs"}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:"User $",value:e2,onChange:e=>e3(e.target.value),className:"w-20 rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text)"}),(0,o.jsx)("button",{type:"button",onClick:async()=>{var e;let t=parseFloat(e2);if(!Number.isFinite(t))return void te("Invalid number");let r=null==(e=et.get_distinct_id)?void 0:e.call(et);if(!r)return void te("No distinct ID");let o=await fetch("/api/debug/set-cost",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}},body:JSON.stringify({type:"user",distinctId:r,cost:t})});if(!o.ok)return void te("Failed (".concat(o.status,")"));te(null)},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"Set User"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:"Trip $",value:e6,onChange:e=>e4(e.target.value),className:"w-20 rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text)"}),(0,o.jsx)("button",{type:"button",onClick:async()=>{let e=parseFloat(e6);if(!Number.isFinite(e))return void te("Invalid number");if(!l)return void te("No trip ID");let t=await fetch("/api/debug/set-cost",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}}
1,body:JSON.stringify({type:"trip",tripId:l,cost:e})});if(!t.ok)return void te("Failed (".concat(t.status,")"));te(null)},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"Set Trip"})]}),(0,o.jsxs)("div",{className:"flex items-center gap-1",children:[(0,o.jsx)("input",{type:"number",step:"0.5",placeholder:"Snapshot $",value:e8,onChange:e=>e7(e.target.value),className:"w-20 rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text)"}),(0,o.jsx)("button",{type:"button",onClick:async()=>{var e;let t=parseFloat(e8);if(!Number.isFinite(t))return void te("Invalid number");let r=null==(e=et.get_distinct_id)?void 0:e.call(et);if(!r)return void te("No distinct ID");let o=await fetch("/api/debug/set-cost",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}},body:JSON.stringify({type:"snapshot",distinctId:r,cost:t})});if(!o.ok)return void te("Failed (".concat(o.status,")"));te(null)},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"Set Snapshot"})]}),e9&&(0,o.jsx)("span",{className:"text-xs text-red-500",children:e9}),(0,o.jsx)(eh,{text:"User = cumulative cost (all-time). Trip = trip cost. Snapshot = cost at billing cycle start (spent this cycle = User - Snapshot)."})]}),(0,o.jsx)("div",{className:"md:col-span-2",children:(0,o.jsx)(X,{tripId:l})}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"Analytics"}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>{let e=!er;eo(e),et.debug(e)},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(er?"border-emerald-500/50 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["PostHog ",er?"ON":"OFF"]}),(0,o.jsx)(eh,{text:"Show verbose PostHog logs in browser console"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:()=>{ea?et.opt_in_capturing():et.opt_out_capturing(),en(!ea)},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(ea?"border-red-500/50 bg-red-500/10 text-red-700 dark:text-red-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Tracking ",ea?"PAUSED":"ON"]}),(0,o.jsx)(eh,{text:"Stop all PostHog event tracking from this browser. Auto-paused in debug mode. Persists in localStorage."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{type:"button",onClick:async()=>{var e;let t=null==(e=et.get_distinct_id)?void 0:e.call(et);if(!t)return;let r=!td,o=await fetch("/api/rate-limit/debug-bypass",{method:"POST",headers:{"Content-Type":"application/json",...i?{Authorization:"Bearer ".concat(i)}:{}},body:JSON.stringify({distinctId:t,bypass:r})});if(!o.ok)return void h("Rate limit toggle failed (".concat(o.status,"): re-enter debug mode to refresh token"));tu(r)},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(td?"border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:["Rate Limit: ",td?"OFF":"ON"]}),(0,o.jsx)(eh,{text:"Bypass all rate limit checks for your account. Only affects your chat requests."})]})]})]})]}),(0,o.jsxs)("div",{className:"shrink-0 border-b border-b-(--tt-border-color) px-3 md:px-4 py-1.5 md:py-2",children:[(0,o.jsx)("div",{className:"mb-1 text-[10px] font-medium text-(--tt-gray-light-500) dark:text-(--tt-gray-dark-600)",children:"Test"}),(0,o.jsxs)("div",{className:"grid md:grid-cols-2 gap-x-4 gap-y-1 items-start",children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"Data"}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:ty,disabled:!!eT,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+("iceland"===eT?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"iceland"===eT?"Loading…":"Iceland"}),(0,o.jsx)(eh,{text:"Load Iceland sample HTML into the current document"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:tv,disabled:!!eT,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+("
1keywest"===eT?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"keywest"===eT?"Creating…":"Key West"}),(0,o.jsx)(eh,{text:"Simulate a GPT import — creates a new trip from Key West markdown"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:tk,disabled:!!eT,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+("keywest-simple"===eT?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"keywest-simple"===eT?"Creating…":"Key West Simple"}),(0,o.jsx)(eh,{text:"Simulate a GPT import — simplified Key West version"})]}),(0,o.jsxs)("div",{className:"relative flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>eN(e=>!e),disabled:!!eT,className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(eT&&eT.startsWith("free-")?"opacity-60 cursor-not-allowed border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":ej?"border-teal-500/50 bg-teal-500/10 text-teal-700 dark:text-teal-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:eT&&eT.startsWith("free-")?"Loading…":"Free Trip Samples ▾"}),(0,o.jsx)(eh,{text:"Load a REAL production trip — full scratchpad + entire chat history (user + agent) + entities — into the CURRENT trip, then reload. Same mechanism as \xabDemo Project\xbb. OVERWRITES this trip's content, so use a disposable test-trip."}),ej&&(0,o.jsx)("div",{className:"absolute top-full left-0 mt-1 z-50 w-64 rounded-lg border border-(--tt-border-color) bg-(--tt-card-bg-color) shadow-xl overflow-hidden",children:ee.map(e=>(0,o.jsx)("button",{type:"button",disabled:!!eT,onClick:()=>{eN(!1),tN(e.documentId,"free-".concat(e.documentId))},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color) last:border-b-0 disabled:opacity-60 disabled:cursor-not-allowed",children:e.label},e.documentId))})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>eA(!0),disabled:!!eT,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+("custom-import"===eT?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"custom-import"===eT?"Creating…":"Custom GPT Import"}),(0,o.jsx)(eh,{text:"Paste custom markdown and create a GPT import trip"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>tw("example-import",'# \uD83D\uDDFD Solo Explorer NYC Sprint\nThree days of neighborhoods, views, museums, food, and "oh wow I accidentally walked 18,000 steps" energy.\n\n---\n\n## \uD83D\uDDD3️ Day 1: Manhattan — Icons + downtown wandering\n\n\uD83C\uDF05 **Morning:**\n- ✈️ Arrive + drop bags\n- \uD83D\uDEB6 Bryant Park → NYPL → Grand Central\n\n\uD83D\uDD5B **Midday:**\n- \uD83C\uDF5C Los Tacos No. 1\n- \uD83C\uDFAD MoMA or Summit One Vanderbilt\n\n\uD83C\uDF19 **Evening:**\n- \uD83C\uDF03 Walk the High Line\n- \uD83C\uDF55 Joe\'s Pizza + West Village wander\n\n---\n\n## \uD83D\uDDD3️ Day 2: Brooklyn — Bridges, food, views\n\n\uD83C\uDF05 **Morning:**\n- \uD83D\uDE87 Subway to DUMBO\n- \uD83D\uDEB6 Brooklyn Bridge Park + Manhattan Bridge photo spot\n\n\uD83D\uDD5B **Midday:**\n- \uD83E\uDD6F Bagelsmith or Frankel\'s\n- \uD83D\uDECD️ Williamsburg vintage shops\n\n\uD83C\uDF19 **Evening:**\n- \uD83C\uDF05 Domino Park sunset\n- \uD83C\uDF5C Ramen at Tonchin Brooklyn or pizza at L\'industrie\n\n---\n\n## \uD83D\uDDD3️ Day 3: Uptown + Pride-month flavor\n\n\uD83C\uDF05 **Morning:**\n- \uD83C\uDF33 Central Park ramble\n- \uD83C\uDFDB️ The Met or Natural History Museum\n\n\uD83D\uDD5B **Midday:**\n- \uD83C\uDF7D️ Harlem brunch\n- \uD83C\uDFA8 The Studio Museum area / Harlem wander\n\n\uD83C\uDF19 **Evening:**\n- \uD83C\uDFF3️‍\uD83C\uDF08 Optional NYC Pride drag brunch/event energy if tickets fit\n- \uD83C\uDF03 Rooftop view or comedy show\n\nNYC Pride has a drag brunch fundraiser on Saturday, June 20, and broader Pride Month events are running through June, so I\'d keep one flexible slot for that if it sounds fun.\n\n---\n\n## \uD83C\uDFE8 Stay\n- \uD83C\uDFE8 Look at budget/mid stays in **Long Island City, Downtown Brooklyn, or Upper West Side**\n- \uD83D\uDE87 Prioritize being near a subway over being "cute"\n- \uD83D\uDCB8 Save lodging money for activities/views/shows — very correct NYC behavior\n\n---\n\n## \uD83D\uDCA1 Key Tips\n- \uD83D\uDE87 Use OMNY tap-to-pay for subways\n- \uD83D\uDC5F Bring your best walking shoes, not your cutest villains\n- \uD83C\uDF9F️ Book one paid "wow" activity: Summit, Broadway rush, or a food tour\n- \uD83E\uDDF3 Pack light if you\'re hotel-hopping or using bag storage\n- \uD83C\uDF19 Solo evenings: comedy clubs, rooftops, and food halls are easy wins\n\nHeads up — I (ChatGPT) am working from general knowledge, so some spots might be off, make sure to double-check. If you want verified places, maps, local events, and insights — I can build the full itinerary in Travel Vibes, a specialized AI trip planner.\n\nQuick actions — type a word:\n\n\uD83D\uDD04 `swap` — Replace an activity\n\uD83D\uDCA1 `more` — Pack my days with more activities\n\uD83D\uDE0C `chill` — Make it more relaxed\n✨ `enhance` — Build detailed ready-to-go itinerary in Travel Vibes\n\uD83C\uDFAD `shows` — Add Broadway/comedy/nightlife options\n\nWant me to build your trip plan in Travel Vibes?',Q),disabled:!!eT,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+("example-import"===eT?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"example-import"===eT?"Creating…":"Example GPT Import"}),(0,o.jsx)(eh,{text:"Simulate a GPT import — solo NYC sprint sample itinerary"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>tw("example-import-no-food","# \uD83C\uDFEF Kyoto Slow Days — 3 Days\nTemples in the morning, backstreets in the afternoon, and no alarm clocks.\n\n**May 12–14, 2026 \xb7 3 Days \xb7 Couple \xb7 Kyoto**\n\nLegend: \uD83D\uDFE2 booked \xb7 \uD83D\uDD34 needs booking\n\n## ✈️ Flights\n| Date | Route | Flight | Status |\n|---|---|---|---|\n| May 12 | SFO → KIX | UA 37 | \uD83D\uDFE2 Booked |\n| May 14 | KIX → SFO | UA 38 | \uD83D\uDFE2 Booked |\n\n## \uD83C\uDFE8 Accommodation\n| Dates | Hotel | Nights | Status |\n|---|---|---|---|\n| May 12–14 | Gion machiya guesthouse | 2 | \uD83D\uDD34 Book here |\n\n## ✅ Booking Checklist\n- [ ] Re
1serve the Gion machiya\n- [ ] Buy Arashiyama bamboo grove early-entry slot\n- [ ] Book the Fushimi Inari night walk\n\n## \uD83D\uDDFA️ Activity Plan\n\n### Day 1 \xb7 Tuesday, May 12 — Higashiyama\n**Location:** Arrive Kansai → Gion\n\n| Time | Activity | Duration | Notes |\n|---|---|---|---|\n| 14:00 | Check in, drop bags | 1h | Machiya check-in is manual |\n| 15:30 | Kiyomizu-dera | 2h | Go before the afternoon crowd |\n| 18:00 | Dinner in the neighbourhood | 1.5h | Plenty of options around the lanes |\n\n### Day 2 \xb7 Wednesday, May 13 — Arashiyama\n**Location:** Arashiyama → Gion\n\n| Time | Activity | Duration | Notes |\n|---|---|---|---|\n| 08:30 | Bamboo grove | 1h | Early, before the tour buses |\n| 10:00 | Tenryu-ji garden | 1.5h | Pay for the garden only |\n| 12:30 | Lunch near the temple | 1h | The main street has several places |\n| 15:00 | Monkey park hike | 2h | Steep but short |\n\n### Day 3 \xb7 Thursday, May 14 — Fushimi & departure\n**Location:** Fushimi → KIX\n\n| Time | Activity | Duration | Notes |\n|---|---|---|---|\n| 08:00 | Fushimi Inari torii gates | 2h | Go up to the Yotsutsuji lookout |\n| 11:00 | Nishiki Market wander | 1.5h | Grab something on the way through |\n| 14:00 | Haruka express to KIX | 1.5h | Reserve a seat with luggage space |\n\n## \uD83D\uDCDD Important Notes\n- Most temple gardens close at 17:00 — the schedule is built around that\n- IC cards work on buses and trains; buy one at the airport\n\n## \uD83D\uDCB0 Budget Breakdown\n| Category | Estimate (couple) |\n|---|---|\n| Stay | $190/night |\n| Food | $70–100/day |\n| Transport | $20/day |\n\n## \uD83D\uDCA1 Key Tips\n- Buses beat trains inside Kyoto, but they are slow at rush hour\n- Carry cash — small temples and shops are cash-only\n\n## \uD83C\uDF92 Packing\n- [ ] Passport + travel insurance\n- [ ] Shoes you can slip off at temples\n- [ ] A light rain layer",[...G]),disabled:!!eT,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+("example-import-no-food"===eT?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"example-import-no-food"===eT?"Creating…":"Example GPT Import (no food)"}),(0,o.jsx)(eh,{text:"TRA-743 before/after: a RICH GPT import (tables, sections) with no Food block on any day — meals are unnamed slots. Its traveler facts mention no food at all (the other button's say 'vegetarian' and 'food halls', which would ask for the very thing we are testing). Say yes to the enhance offer and see whether the agent completes the day shape on its own."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>tN(),disabled:!!eT,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+("demo"===eT?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"demo"===eT?"Loading…":"Demo Project"}),(0,o.jsx)(eh,{text:"Load full demo project (document, chat, entities) from production"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:eW,disabled:eB||!i,className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors "+(eB||!i?"opacity-60 cursor-not-allowed bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:eB?"Running…":"Test Cache Poison Log"}),(0,o.jsx)(eh,{text:"Posts current chat messages to /api/debug/test-cache-poison-log. Writes a test blob under cache-poison-test/ and fires the 'chat:cache_poison_suspected' PostHog event with test=true — verifies the pipeline end-to-end."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{d.useTripStore.setState({input:"DEBUG: вызови инструмент debugInspirationCache, чтобы протестировать кэш Pexels с битой ссылкой."}),d.useTripStore.getState().sendMessage(),p()},className:"rounded-lg border border-(--tt-border-color) px-3 py-1 text-xs font-medium transition-colors bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"Test Broken Cache"}),(0,o.jsx)(eh,{text:"TRA-529: sends a chat message that calls the debugInspirationCache tool — seeds the Pexels cache with a deliberately broken URL, then fetches through the cache wrapper. The tool-call card shows staleDetected / reSearched / brokenWasReplaced (liveness-check + re-search). Registered outside production only."})]})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"Popups"}),(0,o.jsxs)("div",{className:"relative flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>eg(e=>!e),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(ep?"border-orange-500/50 bg-orange-500/10 text-orange-700 dark:text-orange-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"Rate Limit Popups ▾"}),(0,o.jsx)(eh,{text:"Preview rate limit popups for different user/trip tiers"}),ep&&(0,o.jsx)("div",{className:"absolute top-full left-0 mt-1 z-50 w-52 rounded-lg border border-(--tt-border-color) bg-(--tt-card-bg-color) shadow-xl overflow-hidden",children:[{label:"Cost limit — Free user",data:{limitType:"cost_limit",resetAt:null,isPaid:!1,isTripPaid:!1,count:J.PE,limit:J.PE}},{label:"12h — Free user",data:{limitType:"user_12h",resetAt:Date.now()+216e5,isPaid:!1,isTripPaid:!1,count:J.__,limit:J.__}},{label:"12h — Paid user",data:{limitType:"user_12h",resetAt:Date.now()+216e5,isPaid:!0,isTripPaid:!0,count:J.iS,limit:J.iS}},{label:"Lifetime — Free user",data:{limitType:"user_lifetime",resetAt:null,isPaid:!1,isTripPaid:!1,count:J.PB,limit:J.PB}},{label:"Lifetime — Paid user",data:{limitType:"user_lifetime",resetAt:null,isPaid:!0,isTripPaid:!0,count:J.tB,limit:J.tB}},{label:"Trip — Free trip",data:{limitType:"trip_lifetime",resetAt:null,isPaid:!1,isTripPaid:!1,count:J.a6,limit:J.a6}},{label:"Trip — Paid trip",data:{limitType:"trip_lifetime",resetAt:null,isPaid:!0,isTripPaid:!0,count:J.UH,limit:J.UH}},{label:"Cost — Subscriber (starter)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:3,limit:3,currentPlan:"starter",priceCents:400}},{label:"Cost — Subscriber (interview offer)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:3,limit:3,currentPlan:"starter",priceCents:400,researchInterview:"eligible"}},{label:"Cost — Subscriber (finish interview)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:3,limit:3,currentPlan:"starter",priceCents:400,researchInterview:"incomplete"}},{label:"Cost — Subscriber ($16 power)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:13,limit:13,currentPlan:"power",priceCents:1600}},{label:"Cost — Power $20 (refill + Max)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:15,limit:15,currentPlan:"power",priceCents:2e3,refillAvailable:!0,refillsToUnblock:1,refillUnitCents:1500,autoRefillUnitCents:1500,autoRefillCap:3,refillsThisCycle:0}},{label:"Cost — Power $20 (repeat refiller)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:15,limit:15,currentPlan:"power",priceCents:2e3,refillAvailable:!0,refillsToUnblock:1,refillUnitCents:1500,autoRefillUnitCents:1500,autoRefillCap:3,refillsThisCycle:2,repeatRefiller:!0}},{label:"Cost — Power $20 (cap reached)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:15,limit:15,currentPlan:"power",priceCents:2e3,refillAvailable:!0,refillsToUnblock:1,refillUnitCents:1500,autoRefillUnitCents:1500,autoRefillCap:3,refillsThisCycle:3,autoRefillEnabled:!0,autoRefillCapReached:!0}},{label:"Cost — Max $50",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:45,limit:45,currentPlan:"max",priceCents:5e3,refillAvailable:!0,refillsToUnblock:1,refillUnitCents:2e3,autoRefillUnitCents:2e3,autoRefillCap:3,refillsThisCycle:0}},{label:"Cost — Max $50 (can't unblock)",data:{limitType:"cost_limit_subscriber",resetAt:Date.now()+1296e6,isPaid:!0,isTripPaid:!0,count:45,limit:45,currentPlan:"max",priceCents:5e3,refillAvailable:!0,refillsToUnblock:7,refillUnitCents:2500,autoRefillUnitCents:2e3,autoRefillCap:3,refillsThisCycle:0}},{label:"Cost — Trip unlock",data:{limitType:"cost_limit_trip_unlock",resetAt:null,isPaid:!0,isTripPaid:!0,count:13,limit:13}}].map(e=>(0,o.jsx)("button",{type:"button",onClick:()=>{(0,K.dd)(),eu(e.data),ec(!0),eg(!1)},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color) last:border-b-0",children:e.label},e.label))})]}),(0,o.jsxs)("div",{className:"relative flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>ef(e=>!e),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(ex?"border-orange-500/50 bg-orange-500/10 text-orange-700 dark:text-orange-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"Payment Popups ▾"}),(0,o.jsx)(eh,{text:"Preview payment-related popups"}),ex&&(0,o.jsxs)("div",{className:"absolute top-full left-0 mt-1 z-50 w-52 rounded-lg border border-(--tt-border-color) bg-(--tt-card-bg-color) shadow-xl overflow-hidden",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{(0,K.dd)(),ef(!1),p(),U.S.getState().setShowModal(!0,H.Zf.DEBUG)},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:"Unlock a greater trip experience"}),(0,o.jsx)("button",{type:"button",onClick:()=>{ef(!1),p(),window.dispatchEvent(new CustomEvent("copy-trap-triggered",{detail:{textLength:999}}))},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors",children:"Copy Blocked"})]})]}),(0,o.jsxs)("div",{className:"relative flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>ev(e=>!e),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(ey?"border-orange-500/50 bg-orange-500/10 text-orange-700 dark:text-orange-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"Sell Follow-up ▾"}),(0,o.jsx)(eh,{text:"Fire the post-paywall-dismissal agent pitch per trigger. Direct buttons bypass client eligibility + caps (repeatable); the reply lands in chat. Server prerequisites: 'Sub' (Payments row) must read OFF, and EITHER 'Rate Limit' reads OFF OR user cost (RL → User) is under $1.50 — otherwise sell mode owns the turn and the pitch is skipped."}),ey&&(0,o.jsxs)("div",{className:"absolute top-full left-0 mt-1 z-50 w-56 rounded-lg border border-(--tt-border-color) bg-(--tt-card-bg-color) shadow-xl overflow-hidden",children:[[{label:"PDF exp
1ort",trigger:H.Zf.PDF_EXPORT},{label:"Share link",trigger:H.Zf.SHARE_LINK},{label:"Unlock link (inline)",trigger:H.Zf.UNLOCK_LINK},{label:"Locked-day banner",trigger:H.Zf.LOCKED_DAY_BANNER},{label:"Content-lock banner",trigger:H.Zf.CONTENT_LOCK_BANNER},{label:"Pacing link",trigger:H.Zf.PACING_LINK},{label:"Copy blocked",trigger:H.Zf.COPY_BLOCKED},{label:"Map route",trigger:H.Zf.MAP_ROUTE},{label:"Map ask-in-chat",trigger:H.Zf.MAP_ASK_IN_CHAT}].map(e=>(0,o.jsxs)("button",{type:"button",onClick:()=>{ev(!1),p(),d.useTripStore.getState().sendMessage({sellFollowup:e.trigger})},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:["▶ ",e.label]},e.trigger)),(0,o.jsx)("button",{type:"button",onClick:()=>{ev(!1),p(),U.S.getState().setShowModal(!0,H.Zf.PDF_EXPORT)},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:"Real flow: paywall as pdf_export (dismiss to fire; eligibility + caps apply)"}),(0,o.jsx)("button",{type:"button",onClick:()=>{ev(!1);let e=d.useTripStore.getState().roomId;try{localStorage.removeItem("tv:sell-followup:".concat(e))}catch(e){}},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors",children:"Reset follow-up caps for this trip"})]})]}),(0,o.jsxs)("div",{className:"relative flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>ew(e=>!e),className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(ek?"border-orange-500/50 bg-orange-500/10 text-orange-700 dark:text-orange-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"Survey Popups ▾"}),ek&&(0,o.jsxs)("div",{className:"absolute top-full left-0 mt-1 z-50 w-52 rounded-lg border border-(--tt-border-color) bg-(--tt-card-bg-color) shadow-xl overflow-hidden",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{ew(!1),p();try{localStorage.removeItem("travelvibes:onboarding_survey_done")}catch(e){}c.useUiStore.getState().setDebugForceOnboarding(!0),U.S.getState().setShowSuccessPopup(!0,"subscription")},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:"Emulate payment return (chat survey)"}),(0,o.jsx)("button",{type:"button",onClick:()=>{ew(!1),p(),c.useUiStore.getState().setDebugForceFallback(!0),(async()=>{try{localStorage.removeItem("travelvibes:onboarding_survey_done")}catch(e){}let e=await (0,M.k)(),t=d.useTripStore.getState().roomId;await fetch("/api/survey/complete",{method:"DELETE",headers:e}),await Promise.all(L.HG.flatMap(r=>[fetch("/api/user/memory",{method:"DELETE",headers:e,body:JSON.stringify({key:r,scope:"user"})}),...t?[fetch("/api/user/memory",{method:"DELETE",headers:e,body:JSON.stringify({key:r,scope:"trip",tripId:t})})]:[]])),console.log("[debug] fallback interview armed — send a normal chat message to see the 'late' opening")})()},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:"Emulate lost sentinel (fallback interview)"}),(0,o.jsx)("button",{type:"button",onClick:()=>{ew(!1),(async()=>{let e=await (0,M.k)(),t=d.useTripStore.getState().roomId;await Promise.all(L.HG.flatMap(r=>[fetch("/api/user/memory",{method:"DELETE",headers:e,body:JSON.stringify({key:r,scope:"user"})}),...t?[fetch("/api/user/memory",{method:"DELETE",headers:e,body:JSON.stringify({key:r,scope:"trip",tripId:t})})]:[]])),console.log("[debug] onboarding answers cleared (user + trip tiers)")})(),p()},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:"Reset onboarding answers"}),(0,o.jsx)("button",{type:"button",onClick:()=>{ew(!1),(async()=>{var e,t;let r=await (0,M.k)(),o=d.useTripStore.getState().roomId,a=o?"?tripId=".concat(encodeURIComponent(o)):"",n=await fetch("/api/user/memory".concat(a),{headers:r}).then(e=>e.json()),s=Object.keys(null!=(e=null==n?void 0:n.user)?e:{}),l=o?Object.keys(null!=(t=null==n?void 0:n.trip)?t:{}):[];await Promise.all([...s.map(e=>fetch("/api/user/memory",{method:"DELETE",headers:r,body:JSON.stringify({key:e,scope:"user"})})),...l.map(e=>fetch("/api/user/memory",{method:"DELETE",headers:r,body:JSON.stringify({key:e,scope:"trip",tripId:o})}
1))]),console.log("[debug] wiped memory: ".concat(s.length," user + ").concat(l.length," trip keys"))})(),p()},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:"Wipe ALL memory (user + this trip)"}),(0,o.jsx)("button",{type:"button",onClick:()=>{ew(!1),(async()=>{try{localStorage.removeItem("travelvibes:onboarding_survey_done")}catch(e){}let e=await fetch("/api/survey/complete",{method:"DELETE",headers:await (0,M.k)()}),t=await e.json().catch(()=>({}));console.log("[debug] survey:completed — ".concat((null==t?void 0:t.cleared)?"cleared for signed-in user":"no-op (not signed in)"))})(),p()},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors border-b border-b-(--tt-border-color)",children:"Reset survey completed (this account)"}),(0,o.jsx)("button",{type:"button",onClick:()=>{ew(!1),p();try{localStorage.removeItem("travelvibes:onboarding_survey_done"),localStorage.removeItem("travelvibes:interview_offer_shown")}catch(e){}U.S.getState().setShowInterviewOffer(!0)},className:"w-full text-left px-3 py-2 text-xs text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) transition-colors",children:"Free user survey (interview offer)"})]})]}),(0,o.jsx)("button",{type:"button",onClick:()=>{p(),localStorage.removeItem("travelvibes:onboarding_seen"),U.S.getState().onboardingCompleted&&U.S.setState({onboardingCompleted:!1}),window.dispatchEvent(new CustomEvent("debug:show-onboarding"))},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) px-3 py-1 text-xs font-medium transition-colors",children:"Welcome popup"}),(0,o.jsx)("button",{type:"button",onClick:()=>{p(),z.ST.getState().debugTriggerChip()},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) px-3 py-1 text-xs font-medium transition-colors",children:"Interview chip"}),(0,o.jsx)("button",{type:"button",onClick:()=>{p(),window.dispatchEvent(new CustomEvent("debug:show-cancellation-winback"))},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200) px-3 py-1 text-xs font-medium transition-colors",children:"After Sub Cancel"})]}),(0,o.jsxs)("div",{className:"md:col-span-2 flex flex-wrap items-center gap-2",children:[(0,o.jsx)("span",{className:tS,children:"Conn"}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{let{_ws:e,_provider:t}=d.useTripStore.getState();if(e){let t=e.webSocket;e.disconnect(),t||d.useTripStore.setState({isOffline:!0,_disconnectedAt:Date.now()})}else t&&t.disconnect()},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-3 py-1 text-xs font-medium text-(--tt-theme-text) transition-colors hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"WS Disconnect"}),(0,o.jsx)(eh,{text:"Force-disconnect the WebSocket (triggers offline banner)"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{let{_ws:e,_provider:t}=d.useTripStore.getState();e?e.connect():t&&t.connect()},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-3 py-1 text-xs font-medium text-(--tt-theme-text) transition-colors hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"WS Connect"}),(0,o.jsx)(eh,{text:"Force-reconnect the WebSocket"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{let{roomId:e,destroyCollab:t,initCollab:r}=d.useTripStore.getState();e&&(t(),d.useTripStore.getState().initCollab(e))},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-3 py-1 text-xs font-medium text-(--tt-theme-text) transition-colors hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"BFCache Sim"}),(0,o.jsx)(eh,{text:"Simulate a back-forward cache restore (destroys and re-inits collab)"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("select",{value:es,onChange:e=>{el(e.target.value),tc("delayUsageSSE"===e.target.value)},className:"h-7 rounded-lg border px-2 text-[11px] font-medium transition-colors focus:outline-none focus:ring-1 focus:ring-(--tt-border-color) "+(es?"border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text)"),children:[(0,o.jsx)("option",{value:"",children:"Collab: Normal"}),(0,o.jsx)("option",{value:"slow",children:"Collab: Slow (15s)"}),(0,o.jsx)("option",{value:"hangToken",children:"Collab: Hang Token"}),(0,o.jsx)("option",{value:"hangProvider",children:"Collab: Hang Provider"}),(0,o.jsx)("option",{value:"noIdb",children:"Collab: No IDB Data"}),(0,o.jsx)("option",{value:"errorTransition",children:"Error: transitionToReady"}),(0,o.jsx)("option",{value:"errorIdb",children:"Error: IDB Crash"}),(0,o.jsx)("option",{value:"raceDestroy",children:"Race: Destroy in 2s"}),(0,o.jsx)("option",{value:"delayUsageSSE",children:"SSE: Delay Usage 15s"})]}),(0,o.jsx)(eh,{text:"Simulate connection issues and timing edge cases"})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{d.useTripStore.setState(e=>({messages:[...e.messages,{id:"a-failed-".concat(Date.now()),role:"assistant",parts:[{type:"text",text:"[response failed — connection error or empty completion]"}],metadata:{failed:!0}}]})),p()},className:"rounded-lg border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-3 py-1 text-xs font-medium text-(--tt-theme-text) transition-colors hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"Failed Banner"}),(0,o.jsx)(eh,{text:"Inject a fake assistant message with metadata.failed=true — verifies the 'Response failed' banner UI without needing a real stream error"})]})]})]})]}),ei&&ed&&l&&(0,o.jsx)(W.RateLimitPopup,{data:ed,tripId:l,onClose:()=>ec(!1)}),eI&&(0,o.jsx)("div",{className:"fixed inset-0 z-[99999] flex items-center justify-center bg-black/50 backdrop-blur-sm",children:(0,o.jsxs)("div",{className:"flex w-full max-w-lg flex-col gap-3 rounded-2xl border border-(--tt-border-color) bg-(--tt-card-bg-color) p-4 shadow-2xl",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between",children:[(0,o.jsx)("span",{className:"text-sm font-semibold text-(--tt-theme-text)",children:"Custom GPT Import"}),(0,o.jsx)("button",{type:"button",onClick:()=>eA(!1),className:"rounded px-2 py-1 text-xs font-medium text-(--tt-gray-light-600) hover:bg-(--tt-gray-light-100) transition-colors dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)",children:"Cancel"})]}),(0,o.jsx)("textarea",{value:e_,onChange:e=>eO(e.target.value),placeholder:"Paste GPT itinerary markdown here...",rows:12,spellCheck:!1,className:"w-full resize-none rounded-xl border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) p-3 font-mono text-xs leading-relaxed text-(--tt-theme-text) placeholder:text-(--tt-gray-light-400) focus:outline-none focus:ring-1 focus:ring-(--tt-border-color)"}),(0,o.jsx)("span",{className:"text-xs font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:"Optional user_preferences (JSON array)"}),(0,o.jsx)("textarea",{value:eF,onChange:e=>eR(e.target.value),placeholder:'[{"value":"vegetarian","label":"Dietary","emoji":"\uD83E\uDD6C"}
1]',rows:4,spellCheck:!1,className:"w-full resize-none rounded-xl border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) p-3 font-mono text-xs leading-relaxed text-(--tt-theme-text) placeholder:text-(--tt-gray-light-400) focus:outline-none focus:ring-1 focus:ring-(--tt-border-color)"}),(0,o.jsx)("div",{className:"flex justify-end",children:(0,o.jsx)("button",{type:"button",onClick:tj,disabled:!e_.trim()||!!eT,className:"rounded-lg border px-4 py-2 text-xs font-medium transition-colors "+(!e_.trim()||eT?"opacity-60 cursor-not-allowed border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:"custom-import"===eT?"Creating…":"Send"})})]})})]})}function er(e){return e?{Authorization:"Bearer ".concat(e)}:{}}function eo(e){let{ydoc:t,tripId:r,debugToken:n,debugFullPrecisionCost:s,setError:l,setSuccess:i}=e,[c,d]=(0,a.useState)(null),[u,p]=(0,a.useState)(!1),[h,m]=(0,a.useState)(null),[x,f]=(0,a.useState)([]),[y,v]=(0,a.useState)(!1),[k,w]=(0,a.useState)(()=>(0,g.Jv)(t).filter(e=>e.id.startsWith("recovered:ph:")).map(e=>e.id)),[j,N]=(0,a.useState)(()=>(0,g.Jv)(t).some(e=>e.id.startsWith("recovered:ph:"))),[S,C]=(0,a.useState)(!1),T=async()=>{var e,o,a,s,l;if(r&&!u){p(!0),m(null),f([]);try{let l=await fetch("/api/debug/trip-ai-cost-posthog?tripId=".concat(encodeURIComponent(r)),{headers:er(n)});if(!l.ok)return void m("Error: ".concat(l.status));let i=await l.json();d({totalCost:i.totalCost,eventCount:i.eventCount,sources:i.sources});let c=(0,g.Jv)(t),u=e=>{var t,r;if("number"==typeof e.createdAt&&e.createdAt>0)return e.createdAt;if(null==(t=e.id)?void 0:t.startsWith("user-")){let t=Number(e.id.slice(5));if(Number.isFinite(t)&&t>1e12)return t}let o=null==(r=e.parts)?void 0:r.find(e=>(null==e?void 0:e.type)==="data-usage"&&(null==e?void 0:e.id));if(null==o?void 0:o.id){let e=Number(o.id.split(":").pop());if(Number.isFinite(e)&&e>1e12)return e}return null},p=c.filter(e=>"assistant"===e.role),h=c.filter(e=>"user"===e.role),x=0,y=[],v=new Map;for(let t of null!=(e=i.events)?e:[]){let e=null!=(o=t.traceId)?o:"no-trace:".concat(t.timestamp),r=null!=(a=v.get(e))?a:[];r.push(t),v.set(e,r)}for(let[e,t]of v){let r=t.reduce((e,t)=>e+(t.cost&&t.cost>0?t.cost:0),0);if(r<=0)continue;let o=new Date(t[0].timestamp).getTime(),a=new Date(t[t.length-1].timestamp).getTime(),n=p.find(e=>{let t=u(e);return!!t&&t>=o-6e4&&t<=a+6e4});if(!n){let a=null,n=null,s=1/0;for(let e of h){let t=u(e);if(!t||t>o)continue;let r=o-t;r<s&&(s=r,n=e.id,a=e.parts.filter(e=>(null==e?void 0:e.type)==="text"&&"string"==typeof(null==e?void 0:e.text)).map(e=>e.text).join(", ").slice(0,300)||null)}y.push({timestamp:t[0].timestamp,cost:r,model:t[0].model,inputPreview:a,traceId:e.startsWith("no-trace:")?null:e,chatId:t[0].chatId,userMsgId:n,traceEvents:t.map(e=>({cost:e.cost,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheReadTokens:e.cacheReadTokens,cacheCreationTokens:e.cacheCreationTokens,model:e.model,timestamp:e.timestamp}))});continue}if(n.parts.some(e=>{var t;return(null==e?void 0:e.type)==="data-usage"&&"number"==typeof(null==e||null==(t=e.data)?void 0:t.cost)}))continue;let l=t[t.length-1];n.parts.push({type:"data-usage",id:"usage:recovered:posthog:".concat(t[0].timestamp),data:{model:null!=(s=l.model)?s:"unknown",inputTokens:t.reduce((e,t)=>{var r;return e+(null!=(r=t.inputTokens)?r:0)},0),outputTokens:t.reduce((e,t)=>{var r;return e+(null!=(r=t.outputTokens)?r:0)},0),cacheRead:t.reduce((e,t)=>{var r;return e+(null!=(r=t.cacheReadTokens)?r:0)},0),cacheWrite:t.reduce((e,t)=>{var r;return e+(null!=(r=t.cacheCreationTokens)?r:0)},0),cost:r,stepCount:t.length>1?t.length:void 0}}),x++}if(x>0){let e=p.filter(e=>e.parts.some(e=>{var t;return null==e||null==(t=e.id)?void 0:t.startsWith("usage:recovered:posthog:")})),r=t.getMap("travelvibes:chats");for(let[o]of r.entries()){let a=e.filter(e=>{var t,a;let n=r.get(o),s=null==n||null==(t=n.get)?void 0:t.call(n,"messagesById");return null==s||null==(a=s.has)?void 0:a.call(s,e.id)});a.length>0&&(0,g.Ex)(t,o,a,"posthog-recovery")}}f(y);let k=[];if(x>0&&k.push("".concat(x," patched")),y.length>0){let e=y.reduce((e,t)=>
1e+t.cost,0);k.push("".concat(y.length," unmatched (").concat((0,b.B)(e,!0),")"))}0===x&&0===y.length&&k.push("all in sync"),m(k.join(", "))}catch(e){m("Error: ".concat(null!=(l=null==e?void 0:e.message)?l:String(e)))}finally{p(!1)}}},D=(0,a.useRef)(!1);(0,a.useEffect)(()=>{r&&!D.current&&(D.current=!0,T())},[r]);let E=async()=>{var e,o,a,s,l,i,c,d,u,p,h,b;if(r&&!S&&0!==x.length){C(!0);try{let b=await fetch("/api/debug/trip-ai-cost-posthog?tripId=".concat(encodeURIComponent(r),"&recover=true"),{headers:er(n)});if(!b.ok)return void m("Error: ".concat(b.status));let f=await b.json(),y=[...null!=(e=null==f?void 0:f.responses)?e:[]],v=[...null!=(o=null==f?void 0:f.userMessages)?o:[]],k=[],j=t.getMap("travelvibes:chats"),S=new Map,C=new Map;for(let[e,t]of j.entries()){let r=null==t||null==(a=t.get)?void 0:a.call(t,"order"),o=null==t||null==(s=t.get)?void 0:s.call(t,"messagesById");if(!(null==r?void 0:r.toArray)||!o)continue;let n=[];for(let t of r.toArray()){let r=String(t);S.set(r,e);let a=null==(l=o.get)?void 0:l.call(o,r),s="number"==typeof(null==a?void 0:a.createdAt)?a.createdAt:0;n.push({id:r,createdAt:s})}C.set(e,n)}let T=e=>{let t,r=1/0;for(let[o,a]of C)for(let n of a){let a=Math.abs(n.createdAt-e);a<r&&(r=a,t=o)}return r<6e5?t:void 0},D=(e,t)=>{let r=C.get(e);if(!r)return null;let o=null;for(let e of r)e.createdAt>0&&e.createdAt<t&&(o=e.id);return o},E=(e,t,r)=>{let o,a=1/0;for(let n of e){let e=new Date(n.timestamp).getTime(),s=e-t;s>=-5e3&&e<=r&&s<a&&(a=s,o=n)}return o&&e.splice(e.indexOf(o),1),o};for(let e of x){let r,o=null!=(i=e.traceId)?i:e.timestamp,a=new Date(e.timestamp).getTime(),n=new Date(e.traceEvents[e.traceEvents.length-1].timestamp).getTime(),s=e.userMsgId?S.get(e.userMsgId):void 0,l=null!=(c=null!=s?s:T(a))?c:(0,g.m7)(t);if(e.userMsgId&&S.has(e.userMsgId)&&e.userMsgId)r=e.userMsgId;else{r=D(l,a);let n=E(v,a-12e4,a+5e3),s=null!=(u=null!=(d=null==n?void 0:n.message)?d:e.inputPreview)?u:"[recovered from PostHog]",i="recovered:ph:user:".concat(o),c=n?new Date(n.timestamp).getTime():a-1e3;(0,g.nH)(t,l,r,{id:i,role:"user",createdAt:c,parts:[{type:"text",text:s}]},"posthog-recovery"),k.push(i),r=i}let m=E(y,a,n+3e5),b=null!=(p=null==m?void 0:m.message)?p:"[recovered from PostHog — response text unavailable]",x="recovered:ph:".concat(o);(0,g.nH)(t,l,r,{id:x,role:"assistant",createdAt:a,parts:[{type:"text",text:b},{type:"data-usage",id:"usage:recovered:ph:".concat(o),data:{model:null!=(h=e.traceEvents[e.traceEvents.length-1].model)?h:"unknown",inputTokens:e.traceEvents.reduce((e,t)=>{var r;return e+(null!=(r=t.inputTokens)?r:0)},0),outputTokens:e.traceEvents.reduce((e,t)=>{var r;return e+(null!=(r=t.outputTokens)?r:0)},0),cacheRead:e.traceEvents.reduce((e,t)=>{var r;return e+(null!=(r=t.cacheReadTokens)?r:0)},0),cacheWrite:e.traceEvents.reduce((e,t)=>{var r;return e+(null!=(r=t.cacheCreationTokens)?r:0)},0),cost:e.cost,stepCount:e.traceEvents.length>1?e.traceEvents.length:void 0}}]},"posthog-recovery"),k.push(x)}w(k),N(!0),m("".concat(k.length," msgs recovered from PH"))}catch(e){m("Recovery error: ".concat(null!=(b=null==e?void 0:e.message)?b:String(e)))}finally{C(!1)}}};return r?(0,o.jsx)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:(0,o.jsxs)("span",{className:"relative",children:[(0,o.jsxs)("span",{className:"rounded-md bg-(--tt-sidebar-bg-color) px-2 py-0.5 text-[11px] font-mono font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:["PH:",(0,o.jsx)(eh,{text:"PostHog AI cost — total $ai_generation events for this trip (prod + dev projects)"})," ",u?"...":c?"".concat((0,b.B)(c.totalCost,s)," (").concat(c.eventCount,"ev").concat(c.sources?" \xb7 ".concat(c.sources.prod,"p+").concat(c.sources.dev,"d"):"",")"):"–"]}),(0,o.jsx)("button",{type:"button",onClick:T,disabled:u,className:"ml-0.5 rounded-md px-1 py-0.5 text-[11px] font-mono text-(--tt-gray-light-400) hover:text-(--tt-theme-text) transition-colors dark:text-(--tt-gray-dark-600) dark:hover:text-(--tt-gray-dark-500) disabled:opacity-30",title:"Refresh PostHog sync",children:"↻"}),h&&(0,o.jsx)("button",{type:"button",onClick:()=>x.length>0&&v(e=>!e),className:"ml-1 rounded-md bg-(--tt-sidebar-bg-color) px-2 py-0.5 text-[11px] font-mono font-medium transition-colors ".concat(x.length>0&&!j?"text-amber-500 hover:text-amber-400 cursor-pointer":j?"text-green-500 cursor-pointer":"text-(--tt-gray-light-400) dark:text-(--tt-gray-dark-600) cursor-default"),children:h}),x.length>0&&!j&&(0,o.jsx)("button",{type:"button",onClick:E,disabled:S,className:"ml-1 rounded-md bg-amber-500/20 px-2 py-0.5 text-[11px] font-mono font-medium text-amber-500 hover:bg-amber-500/30 transition-colors disabled:opacity-50",title:"Create synthetic Yjs messages from PostHog data (response text + cost)",children:S?"Recovering...":"Recover ".concat(x.length)}),j&&(0,o.jsx)("button",{type:"button",onClick:()=>{let e=t.getMap("travelvibes:chats");for(let r of k)for(let[o]of e.entries())(0,g.zq)(t,o,r,"posthog-recovery-undo");w([]),N(!1);let r=x.reduce((e,t)=>
1e+t.cost,0);m("".concat(x.length," unmatched (").concat((0,b.B)(r,!0),")"))},className:"ml-1 rounded-md bg-red-500/20 px-2 py-0.5 text-[11px] font-mono font-medium text-red-400 hover:bg-red-500/30 transition-colors",title:"Remove recovered messages from Yjs",children:"Undo"}),y&&x.length>0&&(0,o.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 w-96 rounded-lg border border-(--tt-border-color) bg-(--tt-card-bg-color) p-2 shadow-xl text-[11px] font-mono",children:[(0,o.jsx)("div",{className:"mb-1 font-semibold text-(--tt-theme-text)",children:"Unmatched PostHog events (no Yjs assistant message by trace):"}),(0,o.jsx)("div",{className:"max-h-60 overflow-y-auto space-y-1.5",children:x.map((e,t)=>{var r,a;return(0,o.jsxs)("div",{className:"rounded border border-(--tt-border-color) p-1.5",children:[(0,o.jsxs)("div",{className:"flex justify-between text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:[(0,o.jsx)("span",{children:new Date(e.timestamp).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),(0,o.jsx)("span",{children:null!=(a=null==(r=e.model)?void 0:r.replace("anthropic.",""))?a:"?"}),(0,o.jsx)("span",{className:"text-amber-500",children:(0,b.B)(e.cost,!0)})]}),e.inputPreview&&(0,o.jsx)("div",{className:"mt-1 text-[10px] leading-tight text-(--tt-gray-light-500) dark:text-(--tt-gray-dark-500) line-clamp-3 whitespace-pre-wrap wrap-break-word",children:e.inputPreview})]},t)})}),(0,o.jsx)("div",{className:"mt-1 border-t border-(--tt-border-color) pt-1 text-(--tt-gray-light-400) dark:text-(--tt-gray-dark-600)",children:"Events reached PostHog but messages missing from Yjs (tab closed before persist?)"})]})]})}):null}function ea(e){let{ydoc:t,tripId:r,debugToken:n,debugFullPrecisionCost:s,setError:l,setSuccess:i}=e,d=(0,y.sf)(),u=(0,U.S)(e=>e.checkStatus),[p,h]=(0,a.useState)(!1),[m,b]=(0,a.useState)(!1),[g,x]=(0,a.useState)(null),[f,v]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{var e;
1let t=null==(e=d.get_distinct_id)?void 0:e.call(d),o=new URLSearchParams;t&&o.set("distinctId",t),r&&o.set("tripId",r),fetch("/api/unlock/status?".concat(o)).then(e=>e.json()).then(e=>{var t,r;return h(null!=(r=null==e||null==(t=e.creatorSubscription)?void 0:t.active)&&r)}).catch(()=>{})},[r]),(0,a.useEffect)(()=>{r&&fetch("/api/admin/trip-unlock?tripId=".concat(r),{headers:er(n)}).then(e=>e.json()).then(e=>{var t;return x(null!=(t=null==e?void 0:e.unlocked)&&t)}).catch(()=>{})},[r,n]),(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{className:"shrink-0 border-b border-b-(--tt-border-color) px-3 md:px-4 py-1.5 md:py-2",children:[(0,o.jsx)("div",{className:"mb-1 md:mb-1.5 text-[10px] font-medium text-amber-600 dark:text-amber-400",children:"Admin — changes real state, affects all users viewing this trip"}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-2 md:gap-3",children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",disabled:!r||m,onClick:async()=>{if(r){b(!0);try{let e=!p,t=await fetch("/api/subscription/debug-reset",{method:"POST",headers:{"Content-Type":"application/json",...n?{Authorization:"Bearer ".concat(n)}:{}},body:JSON.stringify({tripId:r,targetCreator:!0,setActive:e})});if(!t.ok)return void l("Creator sub toggle failed (".concat(t.status,"): re-enter debug mode to refresh token"));h(e),await u()}finally{b(!1)}}},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(!r||m?"opacity-50 cursor-not-allowed border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":p?"border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:m?"Updating…":"Trip Creator Sub: ".concat(p?"ACTIVE":"OFF")}),(0,o.jsx)(eh,{text:"Toggle the trip creator's subscription in Redis. Affects all users viewing this trip."})]}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsx)("button",{type:"button",disabled:!r||f,onClick:async()=>{if(r){v(!0);try{let e=!g,t=await fetch("/api/admin/trip-unlock",{method:"POST",headers:{"Content-Type":"application/json",...n?{Authorization:"Bearer ".concat(n)}:{}},body:JSON.stringify({tripId:r,unlock:e})});if(!t.ok)return void l("Trip unlock toggle failed (".concat(t.status,"): re-enter debug mode to refresh token"));x(e),await u()}finally{v(!1)}}},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors "+(!r||f?"opacity-50 cursor-not-allowed border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600)":g?"border-green-500/50 bg-green-500/10 text-green-700 dark:text-green-300":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:f?"Updating…":"Trip: ".concat(g?"UNLOCKED":"LOCKED")}),(0,o.jsx)(eh,{text:"Unlock/lock this trip for all users (no payment needed). Use for partners, demos, etc."})]}),(0,o.jsx)("div",{className:"flex items-center",children:(0,o.jsx)("button",{type:"button",onClick:()=>{c.useUiStore.getState().closeDebugJsonOverlay(),c.useUiStore.getState().openClerkAuth(window.location.pathname)},className:"rounded-lg border px-3 py-1 text-xs font-medium transition-colors border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)",children:"Open Clerk Sign-In"})})]})]})})}function en(e){var t,r;let{tripId:n,debugToken:s}=e,l=(0,y.sf)(),i=null!=(r=null==(t=l.get_distinct_id)?void 0:t.call(l))?r:"",[c,d]=(0,a.useState)([]),[u,p]=(0,a.useState)(!1),[h,m]=(0,a.useState)(null),[b,g]=(0,a.useState)(!1);if((0,a.useEffect)(()=>{n&&(p(!0),fetch("/api/debug/trip-active-users?tripId=".concat(encodeURIComponent(n)),{headers:er(s)}).then(e=>e.ok?e.json():Promise.reject(Error("HTTP ".concat(e.status)))).then(e=>{var t;d(null!=(t=e.users)?t:[]),m(null)}).catch(e=>{d([]),m(e instanceof Error?e.message:"failed")}).finally(()=>p(!1)))},[n,s]),!n)return null;let x="text-(--tt-gray-light-400) dark:text-(--tt-gray-dark-600)",f="underline hover:text-(--tt-theme-text) transition-colors",v=c.filter(e=>e.distinctId!==i),k=b?v:v.slice(0,2),w=v.length-2;return(0,o.jsx)("div",{className:"shrink-0 border-b border-b-(--tt-border-color) px-3 md:px-4 py-1.5 md:py-2",children:(0,o.jsxs)("div",{className:"flex flex-col gap-1 text-[11px] font-mono text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("span",{className:x,children:"trip users"}),u&&(0,o.jsx)("span",{className:x,children:"loading..."}),!u&&0===v.length&&(0,o.jsx)("span",{className:x,children:null!=h?h:"no data"})]}),k.map(e=>{var t;return(0,o.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.email&&(0,o.jsx)("span",{children:e.email}),(0,o.jsx)("a",{href:e.personUrl,target:"_blank",rel:"noopener noreferrer",className:f,title:"PostHog person",children:"[PH]"}),e.clerkUrl&&(0,o.jsx)("a",{href:e.clerkUrl,target:"_blank",rel:"noopener noreferrer",className:f,title:"Clerk user",children:"[CK]"}),(0,o.jsx)("span",{className:x,children:(t=e.distinctId).length>16?t.slice(0,16)+"...":t}),(0,o.jsxs)("span",{className:x,children:["(",e.events," events, ",function(e){if(!e)return"";let t=new Date(e),r=Math.floor((Date.now()-t.getTime())/36e5);if(r<1)return"<1h ago";if(r<24)return"".concat(r,"h ago");let o=Math.floor(r/24);return"".concat(o,"d ago")}(e.lastSeen),")"]})]},e.distinctId)}),!b&&w>0&&(0,o.jsxs)("button",{onClick:()=>g(!0),className:"".concat(x," hover:text-(--tt-theme-text) transition-colors text-left"),children:["+",w," more..."]})]})})}let es=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"],el={C1:"place links point at a real Google result",C2:"written rating matches Google",C3:"name in the text matches the linked place",C4:"stated weekday is that date's weekday",C5:"no two stops at once, no backwards day",C6:"the hop fits in the time given",C7:"all four appendices present",C8:"no year drift in tool arguments",C9:"every day names places to eat",C10:"every day shows a map"},ei="text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)";function ec(e){let{tripId:t,debugToken:r}=e,[n,s]=(0,a.useState)(null),[l,i]=(0,a.useState)(null),[c,d]=(0,a.useState)(null),[u,p]=(0,a.useState)(null),[h,m]=(0,a.useState)(!1),b=(0,a.useCallback)(()=>r?{Authorization:"Bearer ".concat(r)}:void 0,[r]);(0,a.useEffect)(()=>{let e=!1;return m(!0),fetch("/api/debug/factcheck?tripId=".concat(encodeURIComponent(t)),{headers:b()}).then(async e=>{if(!e.ok)throw Error("HTTP ".concat(e.status));return e.json()}).then(t=>{e||(s(t.runs),i(t.enabled))}).catch(t=>{e||p(t instanceof Error?t.message:String(t))}).finally(()=>{e||m(!1)}),()=>{e=!0}},[t,b]);let g=async e=>{p(null);try{let r=await fetch("/api/debug/factcheck?tripId=".concat(encodeURIComponent(t),"&runId=").concat(encodeURIComponent(e)),{headers:b()});if(!r.ok)throw Error("HTTP ".concat(r.status));let{run:o}=await r.json();d(o)}catch(e){p(e instanceof Error?e.message:String(e))}};return u?(0,o.jsx)("div",{className:"rounded border border-rose-500/30 bg-rose-500/10 px-2 py-1 text-[11px] font-mono text-rose-700 dark:text-rose-200",children:u}):h||null===n?(0,o.jsx)("div",{className:"text-[11px] ".concat(ei),children:"Loading…"}):0===n.length?(0,o.jsxs)("div",{className:"space-y-1 text-[11px] ".concat(ei),children:[(0,o.jsx)("div",{className:"text-(--tt-theme-text)",children:"No fact-check runs recorded for this trip."}),(0,o.jsx)("div",{children:!1===l?"The hook is OFF (FACTCHECK_ENABLED is not set), so nothing was ever measured. This is not a clean result.":"The hook is on. A run is recorded after the agent rewrites the whole document — rebuild the trip to get one."})]}):(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,o.jsx)("span",{className:"text-[10px] uppercase tracking-wide ".concat(ei),children:"Runs"}),n.map(e=>(0,o.jsx)("button",{type:"button",onClick:()=>g(e.runId),className:"rounded border px-2 py-0.5 text-[11px] font-mono transition-colors "+((null==c?void 0:c.runId)===e.runId?"border-(--tt-border-color) bg-(--tt-card-bg-color) text-(--tt-theme-text)":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) ".concat(ei," hover:text-(--tt-theme-text)")),title:"".concat(e.trigger).concat(e.modelId?" \xb7 ".concat(e.modelId):""),children:new Date(e.createdAt).toLocaleStr
1ing()},e.runId))]}),c&&(0,o.jsx)(ed,{run:c}),!c&&(0,o.jsx)("div",{className:"text-[11px] ".concat(ei),children:"Pick a run."})]})}function ed(e){var t;let{run:r}=e,{checks:a,observed:n,yearAnchor:s}=r.result,l=n.unverifiableProse;return(0,o.jsxs)("div",{className:"space-y-2",children:[(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono ".concat(ei),children:[(0,o.jsxs)("span",{children:["trigger ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:r.trigger})]}),(0,o.jsxs)("span",{children:["lang ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:r.result.documentLanguage})]}),(0,o.jsxs)("span",{children:["year"," ",(0,o.jsxs)("span",{className:"text-(--tt-theme-text)",children:[null!=(t=s.value)?t:"unknown"," (",s.source,")"]})]}),(0,o.jsxs)("span",{children:["days ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:n.days})]})]}),r.readerError&&(0,o.jsxs)("div",{className:"rounded border border-amber-500/30 bg-amber-500/10 px-2 py-1 text-[11px] text-amber-700 dark:text-amber-200",children:["The reader failed (",r.readerError,") — every check needing a structure could not run. Not a clean result."]}),(0,o.jsxs)("table",{className:"w-full text-[11px] font-mono",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{className:ei,children:[(0,o.jsx)("th",{className:"text-left font-medium",children:"check"}),(0,o.jsx)("th",{className:"text-left font-medium",children:"asks"}),(0,o.jsx)("th",{className:"text-right font-medium",children:"broken"}),(0,o.jsx)("th",{className:"text-right font-medium",children:"looked at"})]})}),(0,o.jsx)("tbody",{children:es.map(e=>{let t=a[e],r=null===t.defects?"blind":0===t.checked?"empty":t.defects>0?"defects":"clean",n="blind"===r||"empty"===r;return(0,o.jsxs)("tr",{className:"border-t border-t-(--tt-border-color)",children:[(0,o.jsx)("td",{className:"py-0.5 text-(--tt-theme-text)",children:e}),(0,o.jsxs)("td",{className:"py-0.5 pr-2 ".concat(ei),children:[el[e],"blind"===r&&t.unavailable?" — could not look: ".concat(t.unavailable):"","empty"===r?" — nothing of this kind in the document":""]}),(0,o.jsx)("td",{className:"py-0.5 text-right "+(n?ei:"defects"===r?"text-rose-600 dar
1k:text-rose-300":"text-(--tt-theme-text)"),children:n?"—":t.defects}),(0,o.jsx)("td",{className:"py-0.5 text-right ".concat(n?ei:"text-(--tt-theme-text)"),children:n?"—":t.checked})]},e)})})]}),es.some(e=>a[e].findings.length>0)&&(0,o.jsxs)("details",{open:!0,className:"rounded border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) px-2 py-1",children:[(0,o.jsxs)("summary",{className:"cursor-pointer select-none text-[10px] font-semibold uppercase tracking-wide ".concat(ei),children:["findings (",es.reduce((e,t)=>e+a[t].findings.length,0),")"]}),(0,o.jsx)("div",{className:"mt-1 space-y-1",children:es.flatMap(e=>a[e].findings.map((t,r)=>(0,o.jsxs)("div",{className:"text-[11px] leading-relaxed",children:[(0,o.jsxs)("span",{className:"font-mono text-(--tt-theme-text)",children:["[",e,"]"]})," ",(0,o.jsx)("span",{className:ei,children:t.anchor}),(0,o.jsxs)("div",{className:"pl-6",children:["says ",(0,o.jsx)("span",{className:"text-rose-600 dark:text-rose-300",children:t.stated})," / actually"," ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:t.actual})]})]},"".concat(e,":").concat(r))))})]}),(0,o.jsxs)("div",{className:"space-y-0.5 text-[11px] ".concat(ei),children:[(0,o.jsx)("div",{className:"text-[10px] font-semibold uppercase tracking-wide",children:"counted, never called defects"}),(0,o.jsxs)("div",{children:["grounded stops"," ",(0,o.jsxs)("span",{className:"text-(--tt-theme-text)",children:[n.stopsWithToken,"/",n.stops,null!==n.groundedStopRate&&" (".concat(Math.round(100*n.groundedStopRate),"%)")]})," ","— the ceiling on what C1 and C2 can ever see"]}),(0,o.jsxs)("div",{children:["ratings ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:n.ratingsTotal}),", of which untraceable"," ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:n.ratingsUngrounded})," (never summed into C2)"]}),(0,o.jsxs)("div",{children:["hops too far for a road speed to judge"," ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:n.longHopsUnchecked})," — C6 declines them"]}),(0,o.jsxs)("div",{children:["not checkable by anything:"," ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:l.prices})," prices,"," ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:l.travelTimes})," travel times,"," ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:l.openingHours})," opening hours,"," ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:l.urls})," urls"," — travel times and opening hours match English only and undercount"]})]})]})}var eu=r(8042);let ep=l.g1(l.Yj(),p);function eh(e){let{text:t}=e,[r,n]=(0,a.useState)(!1),[s,l]=(0,a.useState)(null),i=(0,a.useRef)(null),c=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(!r)return;let e=e=>{i.current&&!i.current.contains(e.target)&&c.current&&!c.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),(0,o.jsxs)("span",{ref:i,className:"relative ml-1 inline-flex shrink-0",children:[(0,o.jsx)("button",{type:"button",onClick:()=>{if(!r&&i.current){let e=i.current.getBoundingClientRect(),t=Math.min(260,window.innerWidth-16),r=e.left+e.width/2-t/2;r=Math.max(8,Math.min(r,window.innerWidth-t-8)),l({top:e.bottom+6,left:r})}n(e=>!e)},className:"inline-flex h-3.5 w-3.5 cursor-pointer items-center justify-center rounded-full border border-(--tt-border-color) text-[8px] font-bold leading-none text-(--tt-gray-light-500) hover:bg-(--tt-gray-light-100) dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)",children:"i"}),r&&s&&(0,o.jsx)("span",{ref:c,className:"fixed z-[9999] whitespace-normal rounded-lg border border-(--tt-border-color) bg-(--tt-card-bg-color) px-2.5 py-1.5 text-[11px] leading-snug text-(--tt-theme-text) shadow-lg",style:{top:s.top,left:s.left,width:"max-content",maxWidth:260},children:t})]})}function em(e){if(!e)return"Unknown error";if("string"==typeof e)return e;if(e instanceof Error)return e.message||String(e);try{return JSON.stringify(e)}catch(t){return String(e)}}function eb(e,t){let r=new window.DOMParser().parseFromString(t,"text/html");return s.S4.fromSchema(e.schema).parse(r.body,{preserveWhitespace:"full"})}function eg(e,t){let r=eb(e,t),o=function(e,t){let r=s.ZF.fromSchema(e.schema),o=window.document.createElement("div"),a=r.serializeFragment(t.content,{document:window.document});return o.appendChild(a),o.innerHTML}(e,r),a=function(e){let t=[],r=(e,o)=>{var a,n,s;let l="  ".repeat(o);if(e.nodeType===Node.TEXT_NODE){let r=null!=(a=e.textContent)?a:"";if(!/\S/.test(r))return;t.push(l+r);return}if(e.nodeType===Node.COMMENT_NODE){let r=null!=(n=e.textContent)?n:"";t.push(l+"\x3c!--".concat(r,"--\x3e"));return}if(e.nodeType!==Node.ELEMENT_NODE)return;if(!e.childNodes||0===e.childNodes.length)return void t.push(l+e.outerHTML);if(1===e.childNodes.length&&e.childNodes[0].nodeType===Node.TEXT_NODE){let r=null!=(s=e.childNodes[0].textContent)?s:"";if(/\S/.test(r)){let o=e.tagName.toLowerCase(),a=Array.from(e.attributes).map(e=>" ".concat(e.name,'="').concat(e.value.replaceAll('"',"&quot;"),'"')).join("");t.push("".concat(l,"<").concat(o).concat(a,">").concat(r,"</").concat(o,">"));return}}let i=e.tagName.toLowerCase();if("script"===i||"style"===i)return void t.push(l+e.outerHTML);let c=Array.from(e.attributes).map(e=>" ".concat(e.name,'="').concat(e.value.replaceAll('"',"&quot;"),'"')).join("");
1t.push("".concat(l,"<").concat(i).concat(c,">")),e.childNodes.forEach(e=>r(e,o+1)),t.push("".concat(l,"</").concat(i,">"))};return e.childNodes.forEach(e=>r(e,0)),t.join("\n").trim()+"\n"}(new window.DOMParser().parseFromString(o,"text/html").body);return{canonical:o,pretty:a}}let ex=[{label:"\uD83D\uDD0C Load failed",message:"Load failed",retryable:!0},{label:"\uD83D\uDD0C Failed to fetch",message:"Failed to fetch",retryable:!0},{label:"\uD83E\uDDE0 Bedrock overloaded",message:"ServiceUnavailableException: Bedrock is overloaded",retryable:!0},{label:"\uD83D\uDED1 Server error (500)",message:"Failed after 4 attempts. Last error: Internal Server Error",retryable:!0},{label:"\uD83D\uDEAB Bad Request (400)",message:"Bad Request",retryable:!1}];function ef(e){let{jsonData:t,editor:r,ydoc:s,onClose:l,tripId:p}=e,x=(0,a.useRef)(null),f=(0,d.useTripStore)(e=>"streaming"===e.status),y=(0,d.useTripStore)(e=>e.debugBreakActiveStream),v=(0,d.useTripStore)(e=>{var t;return null==(t=e.messages.at(-1))?void 0:t.role}),k=(0,a.useMemo)(()=>JSON.stringify(t,null,2),[t]),w=(0,a.useMemo)(()=>!!t&&"object"==typeof t&&("document"in t||"metadata"in t),[t]),j=(0,a.useMemo)(()=>(function(e){if(!e||"object"!=typeof e)return;let t=e.metadata;if(!(!t||"object"!=typeof t||Array.isArray(t)))return t})(t),[t]),[N,S]=(0,a.useState)("html"),[C,T]=(0,a.useState)("raw"),[D,E]=(0,a.useState)(()=>k),P=(0,a.useRef)(r.getHTML()),[I,A]=(0,a.useState)(()=>r.getHTML()),[_,O]=(0,a.useState)(()=>{try{let{pretty:e}=eg(r,r.getHTML());return e}catch(e){return r.getHTML()}}),[F,R]=(0,a.useState)(null),[B,U]=(0,a.useState)(null),[L,M]=(0,a.useState)(!1),[H,z]=(0,a.useState)(null),[W,K]=(0,a.useState)(null),[J,G]=(0,a.useState)(null),[Y,$]=(0,a.useState)(null),V=(0,c.useUiStore)(e=>e.debugFullPrecisionCost),X=(0,c.useUiStore)(e=>e.debugToken),Z=(0,c.useUiStore)(e=>e.debugBreakServerAfterSteps),q=(0,c.useUiStore)(e=>e.setDebugBreakServerAfterSteps),Q=(0,c.useUiStore)(e=>e.debugBreakClaudeCode),ee=(0,c.useUiStore)(e=>e.setDebugBreakClaudeCode),er=(0,a.useMemo)(()=>{let e=(0,g._f)(s).filter(e=>"user"===e.role),t=e.length;if(0===t)return{count:0,planningTime:null};let r=1/0,o=-1/0,a=!1;for(let t of e){var n,l;let e=null!=(l=t.createdAt)?l:null;if(null==e&&(null==(n=t.id)?void 0:n.startsWith("user-"))){let r=Number(t.id.slice(5));e=Number.isFinite(r)?r:null}null!=e&&(a=!0,e<r&&(r=e),e>o&&(o=e))}if(!a||r===o)return{count:t,planningTime:null};let i=(o-r)/36e5;return{count:t,planningTime:i>=24?"".concat((i/24).toFixed(1),"d"):"".concat(i.toFixed(1),"h")}},[s]),es=(0,a.useMemo)(()=>{let e=(0,g.Jv)(s),t=0;for(let o of e){if("assistant"!==o.role)continue;let e=o.parts.filter(eu.T3).filter(e=>"number"==typeof e.data.cost);
1if(e.length>0){var r;let o=e.find(e=>{var t;return(null!=(t=e.data.stepCount)?t:0)>1});t+=o?null!=(r=o.data.cost)?r:0:e.reduce((e,t)=>{var r;return e+(null!=(r=t.data.cost)?r:0)},0)}}return t},[s]),[el,ei]=(0,a.useState)(()=>{try{let e=(0,u.Rk)(s);return JSON.stringify(e,null,2)}catch(e){return"{}"}});(0,a.useEffect)(()=>{var e;if(!p)return;let t=null==(e=h.default.get_distinct_id)?void 0:e.call(h.default);t&&X&&(fetch("/api/debug/set-cost?".concat(new URLSearchParams({type:"user",distinctId:t})),{headers:{Authorization:"Bearer ".concat(X)}}).then(e=>e.json()).then(e=>{var t;return z(null!=(t=null==e?void 0:e.cost)?t:null)}).catch(()=>{}),p&&fetch("/api/debug/set-cost?".concat(new URLSearchParams({type:"trip",tripId:p})),{headers:{Authorization:"Bearer ".concat(X)}}).then(e=>e.json()).then(e=>{var t;return K(null!=(t=null==e?void 0:e.cost)?t:null)}).catch(()=>{}),fetch("/api/debug/set-cost?".concat(new URLSearchParams({type:"snapshot",distinctId:t})),{headers:{Authorization:"Bearer ".concat(X)}}).then(e=>e.json()).then(e=>{var t;return G(null!=(t=null==e?void 0:e.cost)?t:null)}).catch(()=>{}),p&&fetch("/api/admin/trip-unlock?".concat(new URLSearchParams({tripId:p})),{headers:{Authorization:"Bearer ".concat(X)}}).then(e=>e.json()).then(e=>{var t;return $((null==e?void 0:e.tier)==="trial"?null!=(t=null==e?void 0:e.costSnapshot)?t:0:null)}).catch(()=>{}))},[p,X]),(0,a.useEffect)(()=>{let e=e=>{"Escape"===e.key&&l()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[l]);let ed=()=>{if(!L){M(!0),R(null),U(null);try{if("html"===N){let t="raw"===C?I:_;if("string"!=typeof t||!t.trim())throw Error("HTML is empty.");eb(r,t).check();let o=(0,i.$p)(r,P.current,t);if(!o.ok){var e;throw Error(null!=(e=o.error)?e:"Failed to apply HTML diff")}P.current=r.getHTML(),U("Saved: HTML diff applied successfully.");return}let t=JSON.parse(D),o=t&&"object"==typeof t&&("document"in t||"metadata"in t),a=o?null==t?void 0:t.document:t,n=o?null==t?void 0:t.metadata:void 0;if(!a||"object"!=typeof a)throw Error("Missing/invalid `document` JSON. Provide either a TipTap document JSON, or { document, metadata }.");if(r.state.schema.nodeFromJSON(a).check(),r.commands.setContent(a),n&&"object"==typeof n){let e=s.getMap("travelvibes:meta");s.transact(()=>{Object.entries(n).forEach(t=>{let[r,o]=t;e.set(r,null===o?null:Array.isArray(o)||"object"==typeof o?JSON.stringify(o):o)})})}U("Saved: document JSON validated and applied.")}catch(e){R(em(e))}finally{M(!1)}}},ef=()=>{R(null),U(null);try{let t=JSON.parse(el),r=ep.safeParse(t);if(!r.success){var e;let t=r.error.errors[0];throw Error("Invalid entities: ".concat(null==t||null==(e=t.path)?void 0:e.join(".")," - ").concat(null==t?void 0:t.message))}let o=(0,u.Q2)(s);s.transact(()=>{for(let[e,t]of(o.clear(),Object.entries(r.data)))(0,u.W_)(s,e,t)}),U("Saved ".concat(Object.keys(r.data).length," entities to Yjs."))}catch(e){R(em(e))}};return(0,n.createPortal)((0,o.jsx)("div",{className:"fixed inset-0 z-[999999] flex items-center justify-center bg-black/50 backdrop-blur-sm",onMouseDown:e=>{e.target===e.currentTarget&&l()},children:(0,o.jsxs)("div",{className:"flex h-full w-full flex-col overflow-y-auto bg-(--tt-card-bg-color) md:h-[85vh] md:w-2/3 md:rounded-2xl md:border md:border-(--tt-border-color) md:shadow-2xl",children:[(0,o.jsxs)("div",{className:"shrink-0 flex items-center justify-between border-b border-b-(--tt-border-color) px-3 md:px-4 py-2",children:[(0,o.jsx)("span",{className:"text-sm font-semibold text-(--tt-theme-text)",children:"Debug"}),(0,o.jsx)("div",{className:"flex items-center gap-2",children:(0,o.jsx)("button",{type:"button",onClick:l,className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-(--tt-gray-light-600) hover:bg-(--tt-gray-light-100) hover:text-(--tt-theme-text) transition-colors dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)",children:"✕ Esc"})})]}),(0,o.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center gap-2 border-b border-b-(--tt-border-color) px-3 md:px-4 py-2",children:[(0,o.jsx)("span",{className:"text-xs font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:"Break stream
1:"}),ex.map(e=>(0,o.jsx)("button",{type:"button",onClick:()=>y(e.message),disabled:!f,title:f?'Fail with "'.concat(e.message,'" — ').concat(e.retryable?"retryable (auto-retry countdown)":"deterministic (manual banner, no auto-retry)"):"Send a message first — enabled while it streams",className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-100 disabled:opacity-40 disabled:hover:bg-transparent dark:text-amber-300 dark:hover:bg-amber-900",children:e.label},e.message)),(0,o.jsx)("button",{type:"button",onClick:()=>{var e,t,r,o;(0,m.s_)(Date.now()+12e4);let a=d.useTripStore.getState();try{null==(t=a._ws)||null==(e=t.disconnect)||e.call(t)}catch(e){}try{null==(o=a._ws)||null==(r=o.connect)||r.call(o)}catch(e){}},title:"2-minute bad-token window + reconnect: every dial gets a server-side auth reject (S4 loop). Watch connection:auth_failed events / console.",className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-red-700 transition-colors hover:bg-red-100 dark:text-red-300 dark:hover:bg-red-950/40",children:"\uD83D\uDD11 Auth fail loop (2m)"})]}),(0,o.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center gap-2 border-b border-b-(--tt-border-color) px-3 md:px-4 py-2",children:[(0,o.jsxs)("span",{className:"text-xs font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:["Break SERVER stream:",(0,o.jsx)(eh,{text:"Kills the turn server-side after N finished steps, then send a message. N≥1 → money was already debited → chat:turn_wasted with refundable=true (the only case TRA-656 refunds). N=0 → nothing billed → refundable=false."})]}),[0,1,2].map(e=>(0,o.jsxs)("button",{type:"button",onClick:()=>q(e),title:0===e?"Break before any step is billed → debited_usd 0 → refundable FALSE":"Break after ".concat(e," billed step(s) → debited_usd > 0 → refundable TRUE"),className:"shrink-0 rounded px-2 py-1 text-xs font-medium transition-colors "+(Z===e?"bg-rose-600 text-white":"text-rose-700 hover:bg-rose-100 dark:text-rose-300 dark:hover:bg-rose-950/40"),children:["\uD83D\uDCA5 after ",e," step",1===e?"":"s"]},e)),(0,o.jsx)("button",{type:"button",onClick:()=>q(null),disabled:null===Z,className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-(--tt-gray-light-600) transition-colors hover:bg-(--tt-gray-light-100) disabled:opacity-40 disabled:hover:bg-transparent dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)",children:"Off"}),null!==Z&&(0,o.jsxs)("span",{className:"text-[11px] font-mono text-rose-700 dark:text-rose-300",children:["armed — the next message will die after ",Z," step(s)"]})]}),(0,o.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center gap-2 border-b border-b-(--tt-border-color) px-3 md:px-4 py-2",children:[(0,o.jsxs)("span",{className:"text-xs font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:["Break claude-code:",(0,o.jsx)(eh,{text:"Kills the claude-code attempt after its session opened and its account was latched — the commonest production failure — so the turn falls over for real. 'first' kills only the first attempt, 'all' kills every attempt of the turn; with one attempt per turn they are the same. Needs a claude-code turn (NEXT_PUBLIC_CLAUDE_CODE_DEFAULT) and the debug token. Costs one real session open, and a paid generation whenever the turn ends up on Bedrock."})]}),["first","all"].map(e=>(0,o.jsxs)("button",{type:"button",onClick:()=>ee(e),title:"first"===e?"Kill only the FIRST claude-code attempt — expect the route: span to show one lost account and the answer still served by claude-code.":"Kill EVERY claude-code attempt — expect the route: span to list every account and the answer served by bedrock.",className:"shrink-0 rounded px-2 py-1 text-xs font-medium transition-colors "+(Q===e?"bg-violet-600 text-white":"text-violet-700 hover:bg-violet-100 dark:text-violet-300 dark:hover:bg-violet-950/40"),children:["\uD83E\uDEAB ","first"===e?"1st attempt":"all attempts"]},e)),(0,o.jsx)("button",{type:"button",onClick:()=>ee(null),disabled:null===Q,className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-(--tt-gray-light-600) transition-colors hover:bg-(--tt-gray-light-100) disabled:opacity-40 disabled:hover:bg-transparent dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)",children:"Off"}),null!==Q&&(0,o.jsxs)("span",{className:"text-[11px] font-mono text-violet-700 dark:text-violet-300",children:["armed — the next message will lose ","first"===Q?"its first":"every"," claude-code attempt"]})]}),(0,o.jsxs)("div",{className:"shrink-0 flex flex-wrap items-center gap-2 border-b border-b-(--tt-border-color) px-3 md:px-4 py-2",children:[(0,o.jsxs)("span",{className:"text-xs font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:["claude-code:",(0,o.jsx)(eh,{text:"Sends what a retry after a lost stream sends: no new user message and no card-answer label. Needs a claude-code session over the HTTP transport (CLAUDE_CODE_SERVICE_URL — the local transport always reports reused=false) and a press within 5 min of the last answer. Works with or without earlier tool calls. Watch the server log: DECIDE plan=restart reused=false newUserTurn=false continuation=none fresh=true, and the answer served by claude-code = fixed. plan=desync or plan=resume … then a Bedrock replay = the TRA-832 bug."})]}),(0,o.jsx)("button",{type:"button",onClick:()=>void d.useTripStore.getState().sendMessage({continueFromToolResult:!0}),disabled:f||"assistant"!==v,title:f?"Wait for the current answer to finish":"assistant"!==v?"Send a message and let it answer first — the last message must be the assistant's":"Resend with NO new user message, like a retry: expect a fresh session answered on claude-code",className:"shrink-0 rounded px-2 py-1 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-100 disabled:opacity-40 disabled:hover:bg-transparent dark:text-amber-300 dark:hover:bg-amber-900",children:"\uD83D\uDD73️ Empty resume (TRA-832)"})]}
1),(0,o.jsx)(en,{tripId:p,debugToken:X}),(0,o.jsxs)("div",{className:"shrink-0 border-b border-b-(--tt-border-color) px-3 md:px-4 py-1.5 md:py-2 flex flex-col gap-1",children:[(0,o.jsx)("div",{className:"text-[10px] font-medium text-(--tt-gray-light-500) dark:text-(--tt-gray-dark-600)",children:"Stats"}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,o.jsxs)("span",{className:"rounded-md bg-(--tt-sidebar-bg-color) px-2 py-0.5 text-[11px] font-mono font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:["AI: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:(0,b.B)(es,V)}),(0,o.jsx)(eh,{text:"AI generation cost (from Yjs data-usage parts). Maps/Search costs are in the RL trip counter below (their per-op breakdown left with the tip routes, 2026-07-25)."})]}),er.count>0&&(0,o.jsxs)("span",{className:"rounded-md bg-(--tt-sidebar-bg-color) px-2 py-0.5 text-[11px] font-mono font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:[(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:er.count})," msgs",er.planningTime&&(0,o.jsxs)(o.Fragment,{children:[" \xb7 ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:er.planningTime})]})]})]}),(0,o.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,o.jsx)(eo,{ydoc:s,tripId:p,debugToken:X,debugFullPrecisionCost:V,setError:R,setSuccess:U}),(null!==W||null!==H||null!==J)&&(0,o.jsxs)("span",{className:"ml-auto rounded-md bg-(--tt-sidebar-bg-color) px-2 py-0.5 text-[11px] font-mono font-medium text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:["RL:",(0,o.jsx)(eh,{text:"Rate-limit costs from Redis. Used by the server to enforce usage caps."}),null!==W&&(0,o.jsxs)(o.Fragment,{children:[" Trip: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:(0,b.B)(W,V)}),(0,o.jsx)(eh,{text:"Trip cumulative cost in Redis (rate-limit counter)"})]}),null!==H&&(0,o.jsxs)(o.Fragment,{children:[null!==W&&" \xb7"," User: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:(0,b.B)(H,V)}),(0,o.jsx)(eh,{text:"User all-time cumulative cost in Redis (across all trips)"})]}),null!==J&&(0,o.jsxs)(o.Fragment,{children:[(null!==W||null!==H)&&" \xb7"," Snap: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:(0,b.B)(J,V)}),(0,o.jsx)(eh,{text:"Subscription cost snapshot at billing cycle start. Cycle spend = User − Snap. (Not the trial snapshot.)"})]}),null!==Y&&(0,o.jsxs)(o.Fragment,{children:[" \xb7 Trial snap: ",(0,o.jsx)("span",{className:"text-(--tt-theme-text)",children:(0,b.B)(Y,V)}),(0,o.jsx)(eh,{text:"$4 trial snapshot: trip cost frozen at purchase. Trial spend = Trip − Trial snap, budget $3 (limit at Trip ≥ snap + 3)."})]})]})]})]}),(0,o.jsx)(et,{editor:r,ydoc:s,tripId:p,debugToken:X,onClose:l,setError:R,setSuccess:U,updateOverlayFromEditor:()=>{let e=r.getHTML();P.current=e,A(e),O(()=>{try{let{pretty:t}=eg(r,e);return t}catch(t){return e}});let t=r.getJSON();w?E(JSON.stringify({document:t,metadata:null!=j?j:{}},null,2)):E(JSON.stringify(t,null,2))},setEntitiesJson:ei}),(0,o.jsx)("div",{className:"border-t border-t-amber-500/30",children:(0,o.jsx)(ea,{ydoc:s,tripId:p,debugToken:X,debugFullPrecisionCost:V,setError:R,setSuccess:U})}),(0,o.jsxs)("div",{className:"p-3 flex flex-col gap-3",children:[(F||B)&&(0,o.jsxs)("div",{children:[F&&(0,o.jsx)("div",{className:"rounded border border-rose-500/30 bg-rose-500/10 px-3 py-2 text-xs text-rose-700 font-mono whitespace-pre-wrap dark:text-rose-200",children:F}),!F&&B&&(0,o.jsx)("div",{className:"rounded border border-emerald-500/30 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-800 font-mono whitespace-pre-wrap break-all dark:text-emerald-200",children:B})]}),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsxs)("span",{className:"text-sm font-medium text-(--tt-theme-text)",children:["entities"===N?"Entities":"factcheck"===N?"Fact-check":"Document"," ",(0,o.jsx)("span",{className:"opacity-60",children:"factcheck"===N?"(read-only)":"(editable)"})]}),(0,o.jsx)("div",{className:"flex items-center gap-1 rounded border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) p-1",children:["json","html","entities","factcheck"].map(e=>(0,o.jsx)("button",{type:"button",onClick:()=>S(e),className:"rounded px-2 py-0.5 text-[11px] font-medium transition-colors "+(N===e?"bg-(--tt-card-bg-color) text-(--tt-theme-text)":"text-(--tt-gray-light-600) hover:bg-(--tt-gray-light-100) hover:text-(--tt-theme-text) dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)"),children:"json"===e?"JSON":"html"===e?"HTML":"entities"===e?"Entities":"Factcheck"},e))}),"html"===N&&(0,o.jsxs)("div",{className:"flex items-center gap-1 rounded border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) p-1",children:[(0,o.jsx)("button",{type:"button",onClick:()=>T("raw"),className:"rounded px-2 py-0.5 text-[11px] font-medium transition-colors "+("raw"===C?"bg-(--tt-card-bg-color) text-(--tt-theme-text)":"text-(--tt-gray-light-600) hover:bg-(--tt-gray-light-100) hover:text-(--tt-theme-text) dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)"),children:"Raw"}),(0,o.jsx)("button",{type:"button",onClick:()=>T("normalized"),className:"rounded px-2 py-0.5 text-[11px] font-medium transition-colors "+("normalized"===C?"bg-(--tt-card-bg-color) text-(--tt-theme-text)":"text-(--tt-gray-light-600) hover:bg-(--tt-gray-light-100) hover:text-(--tt-theme-text) dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)"),children:"Normalized"})]})]}),(0,o.jsx)("button",{type:"button",onClick:()=>{var e,t;try{let t="entities"===N?el:"json"===N?D:"raw"===C?I:_;null==(e=navigator.clipboard)||e.writeText(t)}
1catch(e){null==(t=x.current)||t.select(),document.execCommand("copy")}},className:"rounded px-2 py-1 text-[11px] font-medium text-(--tt-gray-light-600) hover:bg-(--tt-gray-light-100) hover:text-(--tt-theme-text) transition-colors dark:text-(--tt-gray-dark-500) dark:hover:bg-(--tt-gray-dark-200)",children:"Copy"})]}),"factcheck"===N?(0,o.jsx)("div",{className:"w-full max-h-[320px] overflow-auto rounded-xl border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) p-3",children:p?(0,o.jsx)(ec,{tripId:p,debugToken:X}):(0,o.jsx)("div",{className:"text-[11px] text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:"No trip id on this surface — fact-check runs are stored per trip."})}):(0,o.jsx)("textarea",{ref:x,value:"entities"===N?el:"json"===N?D:"raw"===C?I:_,readOnly:"html"===N&&"normalized"===C,onChange:e=>"entities"===N?ei(e.target.value):"json"===N?E(e.target.value):"raw"===C?A(e.target.value):O(e.target.value),spellCheck:!1,placeholder:"entities"===N?'{ "place:abc": { "name": "...", "location": { "lat": 0, "lng": 0 } } }':void 0,className:"w-full h-[200px] resize-none rounded-xl border border-(--tt-border-color) bg-(--tt-sidebar-bg-color) p-3 font-mono text-xs leading-relaxed text-(--tt-theme-text) focus:outline-none focus:ring-1 focus:ring-(--tt-border-color)"})]}),(0,o.jsxs)("div",{className:"shrink-0 flex items-center justify-between pt-2 border-t border-t-(--tt-border-color)",children:[(0,o.jsx)("div",{className:"text-[11px] text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)",children:"factcheck"===N?(0,o.jsxs)("span",{children:["Read from ",(0,o.jsxs)("span",{className:"font-mono text-(--tt-theme-text) opacity-70",children:["factcheck:run:","{tripId}",":","{runId}"]})," in Redis"]}):"entities"===N?(0,o.jsxs)("span",{children:["Stored in ",(0,o.jsx)("span",{className:"font-mono text-(--tt-theme-text) opacity-70",children:'ydoc.getMap("travelvibes:entities")'})]}):"json"===N?(0,o.jsxs)("span",{children:["Export uses ",(0,o.jsx)("span",{className:"font-mono text-(--tt-theme-text) opacity-70",children:"editor.getJSON()"})]}):(0,o.jsxs)("span",{children:["Export uses ",(0,o.jsx)("span",{className:"font-mono text-(--tt-theme-text) opacity-70",children:"editor.getHTML()"})]})}),(0,o.jsx)("button",{type:"button",onClick:()=>{ed(),ef()},disabled:L||"factcheck"===N||"html"===N&&"normalized"===C,className:"rounded-lg border px-4 py-2 text-xs font-medium transition-colors "+(L||"factcheck"===N||"html"===N&&"normalized"===C?"opacity-60 cursor-not-allowed border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-gray-light-600) dark:text-(--tt-gray-dark-500)":"border-(--tt-border-color) bg-(--tt-sidebar-bg-color) text-(--tt-theme-text) hover:bg-(--tt-gray-light-100) dark:hover:bg-(--tt-gray-dark-200)"),children:L?"Saving…":"Save Document & Entities"})]})]})]})}),document.body)}},83731:(e,t,r)=>{r.d(t,{sf:()=>i,so:()=>s});var o=r(72341),a=r(12115),n=(0,a.createContext)({client:o.default,bootstrap:void 0});function s(e){var t,r,s=e.children,l=e.client,i=e.apiKey,c=e.options,d=(0,a.useRef)(null),u=(0,a.useMemo)(function(){return l?(i&&console.warn("[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`."),c&&console.warn("[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`."),l):(i||console.warn("[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior."),o.default)},[l,i,JSON.stringify(c)]);return(0,a.useEffect)(function(){if(!l){var e=d.current;e?(i!==e.apiKey&&console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop."),c&&!function e(t,r,o){if(void 0===o&&(o=new WeakMap),t===r)return!0;
1if("object"!=typeof t||null===t||"object"!=typeof r||null===r)return!1;if(o.has(t)&&o.get(t)===r)return!0;o.set(t,r);var a=Object.keys(t),n=Object.keys(r);if(a.length!==n.length)return!1;for(var s=0;s<a.length;s++){var l=a[s];if(!n.includes(l)||!e(t[l],r[l],o))return!1}return!0}(c,e.options)&&o.default.set_config(c)):(o.default.__loaded&&console.warn("[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues."),o.default.init(i,c)),d.current={apiKey:i,options:null!=c?c:{}}}},[l,i,JSON.stringify(c)]),a.createElement(n.Provider,{value:{client:u,bootstrap:null!=(t=null==c?void 0:c.bootstrap)?t:null==(r=null==l?void 0:l.config)?void 0:r.bootstrap}},s)}var l=function(e){return"function"==typeof e},i=function(){return(0,a.useContext)(n).client},c=function(e,t){return(c=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},d=function(){return(d=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var a in t=arguments[r])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e}).apply(this,arguments)};function u(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,o=Object.getOwnPropertySymbols(e);a<o.length;a++)0>t.indexOf(o[a])&&Object.prototype.propertyIsEnumerable.call(e,o[a])&&(r[o[a]]=e[o[a]]);return r}function p(e){var t=e.children,r=e.onIntersect,o=e.onClick,a=e.trackView,n=e.options,s=u(e,["children","onIntersect","onClick","trackView","options"]),l=useRef(null),i=useMemo(function(){return d({threshold:.1},n)},[null==n?void 0:n.threshold,null==n?void 0:n.root,null==n?void 0:n.rootMargin]);return useEffect(function(){if(null!==l.current&&a){var e=new IntersectionObserver(function(e){return r(e[0])},i);return e.observe(l.current),function(){return e.disconnect()}}},[i,a,r]),React.createElement("div",d({ref:l},s,{onClick:o}),t)}"function"==typeof SuppressedError&&SuppressedError;var h={componentStack:null,exceptionEvent:null,error:null},m={INVALID_FALLBACK:"[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element."};!function(e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function t(){this.constructor=r}function r(t){var r=e.call(this,t)||this;return r.state=h,r}c(r,e),r.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t),r.prototype.componentDidCatch=function(e,t){var r,o=this.props.additionalProperties;l(o)?r=o(e):"object"==typeof o&&(r=o);var a=this.context.client.captureException(e,r),n=t.componentStack;this.setState({error:e,componentStack:null!=n?n:null,exceptionEvent:a})},r.prototype.render=function(){var e=this.props,t=e.children,r=e.fallback,o=this.state;if(null==o.componentStack)return l(t)?t():t;var n=l(r)?a.createElement(r,{error:o.error,componentStack:o.componentStack,exceptionEvent:o.exceptionEvent}):r;return a.isValidElement(n)?n:(console.warn(m.INVALID_FALLBACK),a.createElement(a.Fragment,null))},r.contextType=n}(a.Component)}}]);

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.