@buoy-gg/jotai 7.0.63 → 7.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/web/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- "use client";var lt=Object.defineProperty;var sa=Object.getOwnPropertyDescriptor;var ca=Object.getOwnPropertyNames;var da=Object.prototype.hasOwnProperty;var ua=(e,t)=>{for(var a in t)lt(e,a,{get:t[a],enumerable:true})},st=(e,t,a,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ca(t))!da.call(e,o)&&o!==a&&lt(e,o,{get:()=>t[o],enumerable:!(r=sa(t,o))||r.enumerable});return e},ha=(e,t,a)=>(st(e,t,"default"),a&&st(a,t,"default"));var Rr=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{createRestoreScope as ga,emptyRestoreResult as ma,failedRestore as fa,registerStateSnapshotProvider as pa,unionKeys as ya}from"@buoy-gg/shared-ui/web";import{boundedDeepEqual as ba}from"@buoy-gg/shared-ui/web/dataViewer";import{ChangeLog as Ca,entityColor as va,formatValuePreview as wa,shallowDiffSummary as xa}from"@buoy-gg/shared-ui/web";var Va={count:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",nav:"#F97316",form:"#EF4444",modal:"#A855F7",filter:"#84CC16"};function ct(e){return va(e,Va)}function Ta(e,t=40){return wa(e,{maxLength:t,functionLabel:"(fn)"})}var Sa=xa,Aa=class extends Ca{constructor(){super(...arguments);this.atoms=new Map;this.atomListeners=new Set}addAtomChange(e){if(!this.canRecord())return;let{atomLabel:t,prevValue:a,nextValue:r,category:o="write"}=e,n=a!==r,{summary:s,changedKeys:i,changedCount:d}=Sa(a,r),m=Ta(r),y={id:this.nextId(),atomLabel:t,timestamp:Date.now(),prevValue:a,nextValue:r,hasValueChange:n,category:o,changedKeys:i,changedKeysCount:d,diffSummary:s,valuePreview:m,isSlowUpdate:false};this.push(y);let E=this.atoms.get(t);E&&E.changeCount++,this.notifyListeners(),this.notifyAtomListeners()}getAtomChanges(){return this.getAll()}getAtomChangeById(e){return this.getById(e)}clearAtomChanges(){for(let e of this.atoms.values())e.changeCount=0;this.clear(),this.notifyAtomListeners()}getAtomSnapshots(){return Array.from(this.atoms.values()).map(e=>{let t;try{t=e.getValue()}catch{t=void 0}return{label:e.label,changeCount:e.changeCount,color:e.color,currentValue:t,writeKind:e.writeKind}})}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let a=new Map;for(let n of this.items){let s=n.prevValue;(!s||s.__buoyValueOnDevice!==true)&&a.set(n.id,n)}let r=e.slice(0,this.max).map(n=>{let s=a.get(n.id),i=n.prevValue;return s&&i?.__buoyValueOnDevice===true?{...n,prevValue:s.prevValue,nextValue:s.nextValue}:n}),o=new Map;for(let[n,s]of this.atoms)try{let i=s.getValue(),d=i;(!d||d.__buoyValueOnDevice!==true)&&o.set(n,i)}catch{}this.atoms=new Map(t.map(n=>{let s=n.currentValue,i=o.get(n.label),d=i!==void 0&&s?.__buoyValueOnDevice===true?i:n.currentValue;return[n.label,{label:n.label,changeCount:n.changeCount,color:n.color,getValue:()=>d,writeKind:n.writeKind}]})),this.setItems(r),this.notifyAtomListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateAtomValue(e,t){let a=this.atoms.get(e);a&&(this.atoms.set(e,{...a,getValue:()=>t}),this.notifyAtomListeners())}registerAtom(e,t,a,r){if(this.atoms.has(e))return;let o={label:e,changeCount:0,color:ct(e),getValue:t,setValue:a,writeKind:r};this.atoms.set(e,o),this.notifyAtomListeners()}setAtomValue(e,t){let a=this.atoms.get(e);if(!a)throw new Error(`Atom "${e}" is not registered`);if(!a.setValue)throw new Error(`Atom "${e}" is read-only (derived) \u2014 cannot set`);a.setValue(t)}unregisterAtom(e){this.atoms.delete(e),this.notifyAtomListeners()}getAtoms(){return Array.from(this.atoms.values())}getAtom(e){return this.atoms.get(e)}getAtomColor(e){return this.atoms.get(e)?.color??ct(e)}filterAtomChanges(e){let t=this.getAll();if(e.searchText){let a=e.searchText.toLowerCase();t=t.filter(r=>r.atomLabel.toLowerCase().includes(a)||r.valuePreview.toLowerCase().includes(a)||r.changedKeys.some(o=>o.toLowerCase().includes(a)))}return e.atomLabels&&e.atomLabels.length>0&&(t=t.filter(a=>e.atomLabels.includes(a.atomLabel))),e.onlyWithChanges&&(t=t.filter(a=>a.hasValueChange)),t}getStats(){let e=this.items.length,t=this.items.filter(a=>a.hasValueChange).length;return{totalChanges:e,changesWithValueChange:t,changesWithoutValueChange:e-t,atomCount:this.atoms.size}}getUniqueAtomLabels(){return Array.from(this.atoms.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToAtoms(e){return this.atomListeners.add(e),()=>this.atomListeners.delete(e)}notifyAtomListeners(){let e=this.getAtoms();this.atomListeners.forEach(t=>t(e))}},p=new Aa;function Ia(){let e=p.getAtoms();if(e.length===0)return{canCapture:false,canRestore:false,detail:"No Jotai atoms registered \u2014 pass your atoms to watchAtoms() / watchDefaultStoreAtoms()"};let t=e.filter(a=>a.setValue).length;return{canCapture:true,canRestore:t>0,detail:t<e.length?`${e.length-t} derived atom(s) recompute automatically and are not restored`:void 0}}async function Da(){let e=[],t={},a=0;for(let r of p.getAtoms())try{let o=r.getValue();if(typeof o=="function"){e.push(`atom "${r.label}": function value not capturable`);continue}r.setValue||(a+=1),t[r.label]={value:o,writable:!!r.setValue}}catch(o){e.push(`atom "${r.label}": capture failed (${String(o)})`)}return a>0&&e.push(`${a} derived atom(s) captured for inspection only (recompute on restore)`),{data:{atoms:t},warnings:e}}async function Ba(e,t){let a=e,r=ga(t),o=ma();if(!a?.atoms)return fa("empty jotai snapshot");let n=0;for(let[i,d]of Object.entries(a.atoms)){if(!r.allows(i))continue;if(!d.writable){n+=1;continue}let m=p.getAtom(i);if(!m){o.skipped.push({id:i,reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!m.setValue){o.skipped.push({id:i,reason:"atom is now read-only (derived)"});continue}try{m.setValue(d.value),o.applied+=1}catch(y){o.skipped.push({id:i,reason:String(y)}),o.ok=false}}n>0&&o.warnings.push(`${n} derived atom(s) left to recompute`);let s=r.excludedWarning("atom(s)");return s&&o.warnings.push(s),o}async function ka(e,t){let a=e?.atoms??{},r=t===void 0,o={};if(r)for(let i of p.getAtoms())try{o[i.label]={value:i.getValue(),writable:!!i.setValue}}catch{}else Object.assign(o,t?.atoms??{});let n=[],s=[];for(let i of ya(o,a)){if(!(i in a)){r?s.push(`atom "${i}" not in snapshot \u2014 untouched`):n.push({key:i,label:i,verdict:"removed",oldValue:o[i]?.value});continue}let d=a[i],m=i in o&&ba(o[i].value,d.value);if(!d.writable){n.push({key:i,label:i,verdict:m?"unchanged":"recomputes",reason:m?void 0:"derived atom \u2014 recomputes from its sources",oldValue:o[i]?.value,newValue:d.value});continue}if(r){let y=p.getAtom(i);if(!y){n.push({key:i,label:i,verdict:"wont-apply",reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!y.setValue){n.push({key:i,label:i,verdict:"wont-apply",reason:"atom is now read-only (derived)"});continue}}i in o?m?n.push({key:i,label:i,verdict:"unchanged"}):n.push({key:i,label:i,verdict:"changed",oldValue:o[i].value,newValue:d.value}):n.push({key:i,label:i,verdict:"added",newValue:d.value})}return{items:n,notes:s}}pa({id:"jotai",label:"Jotai",status:Ia,capture:Da,restore:Ba,previewItems:ka});import{useState as _,useMemo as Q,useRef as Ve,useCallback as D,useEffect as dt}from"react";var ut={};ua(ut,{AccessibilityInfo:()=>Pa,ActivityIndicator:()=>Bo,Alert:()=>$o,Animated:()=>Ra,AppRegistry:()=>Ha,AppState:()=>Wa,Appearance:()=>za,BackHandler:()=>Fa,Button:()=>ko,CheckBox:()=>to,Clipboard:()=>Ma,DeviceEventEmitter:()=>yo,Dimensions:()=>ja,Easing:()=>Oa,FlatList:()=>Ee,I18nManager:()=>Na,Image:()=>ao,ImageBackground:()=>oo,InteractionManager:()=>Ja,Keyboard:()=>Ka,KeyboardAvoidingView:()=>no,LayoutAnimation:()=>_a,Linking:()=>Ua,LogBox:()=>po,Modal:()=>Io,NativeEventEmitter:()=>Ga,NativeModules:()=>Ea,PanResponder:()=>Ya,Picker:()=>ro,PixelRatio:()=>qa,Platform:()=>Qa,Pressable:()=>Ao,ProgressBar:()=>io,RefreshControl:()=>lo,SafeAreaView:()=>so,ScrollView:()=>he,SectionList:()=>co,Share:()=>Za,StatusBar:()=>uo,StyleSheet:()=>ne,Switch:()=>Do,Text:()=>b,TextInput:()=>Vo,Touchable:()=>ho,TouchableHighlight:()=>To,TouchableNativeFeedback:()=>go,TouchableOpacity:()=>re,TouchableWithoutFeedback:()=>So,UIManager:()=>Xa,Vibration:()=>eo,View:()=>c,VirtualizedList:()=>mo,YellowBox:()=>fo,findNodeHandle:()=>Lo,unstable_createElement:()=>$a,useColorScheme:()=>bo,useLocaleContext:()=>Co,useWindowDimensions:()=>vo});ha(ut,La);import*as La from"react-native-web";import{unstable_createElement as $a,NativeModules as Ea,AccessibilityInfo as Pa,Animated as Ra,Appearance as za,AppRegistry as Ha,AppState as Wa,BackHandler as Fa,Clipboard as Ma,Dimensions as ja,Easing as Oa,I18nManager as Na,Keyboard as Ka,InteractionManager as Ja,LayoutAnimation as _a,Linking as Ua,NativeEventEmitter as Ga,PanResponder as Ya,PixelRatio as qa,Platform as Qa,Share as Za,StyleSheet as ne,UIManager as Xa,Vibration as eo,CheckBox as to,FlatList as Ee,Image as ao,ImageBackground as oo,KeyboardAvoidingView as no,Picker as ro,ProgressBar as io,RefreshControl as lo,SafeAreaView as so,SectionList as co,StatusBar as uo,Touchable as ho,TouchableNativeFeedback as go,VirtualizedList as mo,YellowBox as fo,LogBox as po,DeviceEventEmitter as yo,useColorScheme as bo,useLocaleContext as Co,useWindowDimensions as vo}from"react-native-web";import*as F from"react-native-web";import{createElement as wo,forwardRef as xo}from"react";function j(e){let t=xo((r,o)=>{let{accessibilityState:n,accessibilityValue:s,...i}=r;for(let d of["busy","checked","disabled","expanded","selected"])n?.[d]!==void 0&&i[`aria-${d}`]===void 0&&(i[`aria-${d}`]=n[d]);for(let[d,m]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[d]!==void 0&&i[`aria-${m}`]===void 0&&(i[`aria-${m}`]=s[d]);return wo(e,{...i,ref:o})}),a=e.State;return a&&Object.assign(t,{State:a}),t.displayName=e.displayName??e.name??"NativeWebView",t}var c=j(F.View),b=j(F.Text),Vo=j(F.TextInput),re=j(F.TouchableOpacity),To=j(F.TouchableHighlight),So=j(F.TouchableWithoutFeedback),Ao=j(F.Pressable),he=j(F.ScrollView),Io=j(F.Modal),Do=j(F.Switch),Bo=j(F.ActivityIndicator),ko=j(F.Button),Lo=F.findNodeHandle,$o={alert(e,t,a,r){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let n=document.createElement("h2");if(n.textContent=e,n.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(n),t){let m=document.createElement("p");m.textContent=t,m.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(m)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=a?.length?a:[{text:"OK"}],d=()=>{o.close?.(),o.remove()};for(let m of i){let y=document.createElement("button");y.type="button",y.textContent=m.text??"OK",y.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${m.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,y.onclick=()=>{d(),m.onPress?.()},s.appendChild(y)}o.addEventListener("cancel",m=>{m.preventDefault(),r?.cancelable!==false&&(d(),r?.onDismiss?.())}),o.appendChild(s),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{JsModal as Eo,ModalHeader as B,TabSelector as Po,macOSColors as Ro,night as k,Search as zo,Filter as Ho,Power as Wo,ToolEmptyState as Pe,resolveListEmptyState as ht,devToolsStorageKeys as Fo,ProUpgradeModal as Mo,PowerToggleButton as jo,ToolbarCopyButton as Re,ToolbarClearButton as Oo,truncatePayload as ge,TickProvider as gt,useLimit as No,windowDragProps as Ko,EVENT_LIST_PRESET as mt}from"@buoy-gg/shared-ui/web";import{useIsPro as Jo}from"@buoy-gg/license/web";import{useCallback as _o,useMemo as ft}from"react";import{useChangeLog as Uo,useSubscribedValue as Go}from"@buoy-gg/shared-ui/web";function Yo(e,t){let a=e;if(t.searchText){let r=t.searchText.toLowerCase();a=a.filter(o=>o.atomLabel.toLowerCase().includes(r)||o.valuePreview.toLowerCase().includes(r)||o.changedKeys.some(n=>n.toLowerCase().includes(r)))}return t.atomLabels&&t.atomLabels.length>0&&(a=a.filter(r=>t.atomLabels.includes(r.atomLabel))),t.onlyWithChanges&&(a=a.filter(r=>r.hasValueChange)),a}var qo=()=>p.getAtoms(),Qo=e=>p.subscribeToAtoms(e);function pt(){let e=Uo(p,{filterItems:Yo}),t=Go(qo,Qo),a=ft(()=>{let n=e.items.length,s=e.items.filter(i=>i.hasValueChange).length;return{totalChanges:n,changesWithValueChange:s,changesWithoutValueChange:n-s,atomCount:t.length}},[e.items,t]),r=ft(()=>p.getUniqueAtomLabels(),[t]),o=_o(n=>p.getAtomChangeById(n),[]);return{atomChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:a,atoms:t,clearChanges:p.clearAtomChanges.bind(p),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,atomLabels:r,getChangeById:o}}import{memo as Zo}from"react";import{ChangeRow as Xo,night as en}from"@buoy-gg/shared-ui/web";import{jsx as tn}from"react/jsx-runtime";function an(e,t){return t}function on(e,t){return e==="initial"?en.color.textTertiary:p.getAtomColor(t)}function ze(e,t=20){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="boolean"||typeof e=="number")return String(e);if(typeof e=="string")return`"${e.length>t?e.slice(0,t-1)+"\u2026":e}"`;if(Array.isArray(e))return e.length===0?"[]":`[${e.length} item${e.length===1?"":"s"}]`;if(typeof e=="object"){let a=Object.keys(e);return a.length===0?"{}":`{${a.slice(0,2).join(", ")}${a.length>2?"\u2026":""}}`}return String(e).slice(0,t)}function nn(e){return e.hasValueChange?`${ze(e.prevValue)} \u2192 ${ze(e.nextValue)}`:"no change"}function rn(e){return e.category==="initial"?"INIT":"WRITE"}function ln(e){let t=e.nextValue;return typeof t=="object"&&t!==null&&!Array.isArray(t)?e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.valuePreview||"atom()":ze(t)}var yt=Zo(function({change:e,onPress:t,testID:a}){let r=on(e.category,e.atomLabel),o=an(e.category,e.atomLabel),n=nn(e),s=ln(e),i=rn(e);return tn(Xo,{statusColor:r,statusLabel:o,sublabel:n,primaryText:s,timestamp:e.timestamp,badgeText:i,changed:e.hasValueChange,onPress:()=>t(e),testID:a})});import{memo as sn,useState as He,useCallback as me,useMemo as bt}from"react";import{buoyColors as fe,night as v,EventStepperFooter as Ct,formatRelativeTime as Te,parseValue as Se,Info as cn,Zap as vt,FileText as dn,Database as un,GitBranch as hn,copyToClipboard as gn,ProUpgradeModal as mn,DiffModeTabs as fn,CompareBar as pn,DetailViewToggle as yn,monoFont as K}from"@buoy-gg/shared-ui/web";import{DataViewer as bn,SplitDiffViewer as Cn,TreeDiffViewer as vn,diffThemes as wn}from"@buoy-gg/shared-ui/web/dataViewer";import{useIsPro as xn}from"@buoy-gg/license/web";var u="buoy-jotai";function Ae(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Vn(e,t){return`${u}-row-${Ae(e)}-${t}`}function wt(e){return`${u}-atom-${Ae(e)}`}function Tn(e){let t=new Map,a=new Map;for(let r of e){let o=(t.get(r.atomLabel)??0)+1;t.set(r.atomLabel,o),a.set(r.id,Vn(r.atomLabel,o))}return a}import{jsx as h,jsxs as R}from"react/jsx-runtime";var Sn=[{key:"change",label:"CHANGE",icon:dn},{key:"value",label:"VALUE",icon:un},{key:"diff",label:"DIFF",icon:hn}],An=["diff"];function In(e){switch(e){case"initial":return{label:"INITIAL",color:v.color.textTertiary,bgColor:v.color.textTertiary+"26"};default:return{label:"WRITE",color:fe.success,bgColor:fe.success+"26"}}}function Dn(e){let t=new Date(e),a=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0"),o=t.getSeconds().toString().padStart(2,"0"),n=t.getMilliseconds().toString().padStart(3,"0");return`${a}:${r}:${o}.${n}`}function xt(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Bn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Vt(e){return e==="initial"?"INIT":"WRITE"}var kn=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}],Ln=sn(function({change:e}){let t=xn(),[a,r]=He(false),o=In(e.category),n=p.getAtomColor(e.atomLabel),s=me(async()=>{if(!t){r(true);return}await gn(e.nextValue)},[e.nextValue,t]);return R(he,{style:f.container,contentContainerStyle:f.content,showsVerticalScrollIndicator:false,testID:`${u}-detail-scroll`,children:[R(c,{style:f.card,testID:`${u}-info-card`,children:[h(c,{style:f.sectionHeader,children:R(c,{style:f.sectionHeaderLeft,children:[h(cn,{size:14,color:v.color.accent}),h(b,{style:f.sectionTitle,children:"CHANGE INFO"})]})}),R(c,{style:f.cardContent,children:[R(c,{style:f.infoRow,children:[h(b,{style:f.infoLabel,children:"Atom"}),h(b,{style:[f.infoValue,f.infoValueMono,{color:n}],numberOfLines:1,ellipsizeMode:"middle",testID:`${u}-info-atom`,children:e.atomLabel})]}),R(c,{style:f.infoRow,children:[h(b,{style:f.infoLabel,children:"Time"}),h(b,{style:[f.infoValue,f.infoValueMono],testID:`${u}-info-time`,children:Dn(e.timestamp)})]}),R(c,{style:f.badgeRow,children:[h(c,{style:[f.categoryBadge,{backgroundColor:o.bgColor}],children:h(b,{style:[f.categoryText,{color:o.color}],testID:`${u}-info-category`,children:o.label})}),e.hasValueChange?R(c,{style:f.changesBadge,children:[h(vt,{size:10,color:fe.success}),h(b,{style:f.changesText,testID:`${u}-info-changes`,children:e.diffSummary||"changed"})]}):h(c,{style:f.noChangesBadge,children:h(b,{style:f.noChangesText,testID:`${u}-info-no-changes`,children:"no change"})})]})]})]}),e.changedKeys.length>0&&R(c,{style:f.card,testID:`${u}-keys-card`,children:[R(c,{style:f.sectionHeader,children:[R(c,{style:f.sectionHeaderLeft,children:[h(vt,{size:14,color:v.color.accent}),h(b,{style:f.sectionTitle,children:"CHANGED KEYS"})]}),h(c,{style:f.countBadge,children:h(b,{style:f.countText,testID:`${u}-keys-count`,children:e.changedKeys.length})})]}),h(c,{style:f.cardContent,children:h(c,{style:f.keysContainer,children:e.changedKeys.map(i=>h(c,{style:f.keyBadge,children:h(b,{style:f.keyText,testID:`${u}-key-${Ae(i)}`,children:i})},i))})})]}),h(c,{style:f.actionsRow,children:h(c,{style:[f.actionButton,f.actionButtonCopy],onTouchEnd:s,testID:`${u}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:h(b,{style:[f.actionButtonText,{color:v.color.accent}],children:"COPY VALUE"})})}),h(mn,{visible:a,onClose:()=>r(false),featureName:"Copy"})]})});function Tt({change:e,changes:t,selectedIndex:a,onIndexChange:r,disableInternalFooter:o=false,initialView:n="change"}){let[s,i]=He(n),[d,m]=He("tree"),y=t.length,E=p.getAtomColor(e.atomLabel),w=Vt(e.category),C=Bn(Se(e.nextValue)),T=y-a,A=a<y-1?a+1:null,W=A!==null?t[A]:null,z=T-1,ie=bt(()=>({index:A??0,label:z>0?`#${z}`:"Initial",timestamp:W?xt(W.timestamp):"",relativeTime:W?Te(new Date(W.timestamp)):"value",badge:W?h(c,{style:[L.changeBadgeSmall,{backgroundColor:`${p.getAtomColor(W.atomLabel)}20`}],children:h(b,{style:[L.changeTextSmall,{color:p.getAtomColor(W.atomLabel)}],children:Vt(W.category)})}):void 0}),[A,W,z]),Z=bt(()=>({index:a,label:`#${T}`,timestamp:xt(e.timestamp),relativeTime:Te(new Date(e.timestamp)),badge:h(c,{style:[L.changeBadgeSmall,{backgroundColor:`${E}20`}],children:h(b,{style:[L.changeTextSmall,{color:E}],children:w})})}),[a,e.timestamp,E,w,T]),ye=me(()=>{let Y=Se(e.nextValue);return R(c,{style:L.contentCard,testID:`${u}-value-card`,children:[R(c,{style:L.valueHeader,children:[h(b,{style:L.valueLabel,children:"VALUE AFTER CHANGE"}),R(c,{style:L.valueHeaderBadges,children:[h(c,{style:[L.changeBadge,{backgroundColor:`${E}20`}],children:h(b,{style:[L.changeText,{color:E}],children:w})}),h(c,{style:L.typeBadge,children:h(b,{style:L.typeText,testID:`${u}-value-type`,children:C.toUpperCase()})})]})]}),h(c,{style:f.dataViewerContainer,children:h(bn,{title:"",data:Y,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextValue,E,w,C]),le=me(()=>{let Y=Se(e.prevValue),Ce=Se(e.nextValue);return d==="split"?h(he,{style:{flex:1},showsVerticalScrollIndicator:true,children:h(Cn,{oldValue:Y,newValue:Ce,theme:wn.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):h(vn,{oldValue:Y,newValue:Ce})},[e.prevValue,e.nextValue,d]),se=me(()=>{r(Math.min(y-1,a+1))},[a,y,r]),N=me(()=>{r(Math.max(0,a-1))},[a,r]),be=e.prevValue===void 0,ce=!o&&y>1;return R(c,{style:L.container,children:[h(yn,{views:Sn,activeView:s,onViewChange:i,disabledKeys:be?An:void 0,testIDPrefix:u}),R(c,{style:[L.contentArea,ce&&L.contentAreaFooterPad],children:[s==="change"&&h(Ln,{change:e}),s==="value"&&h(c,{style:L.stateContainer,children:ye()}),s==="diff"&&R(c,{style:L.diffContainer,testID:`${u}-diff`,children:[h(fn,{tabs:kn,activeTab:d,onTabChange:m,testIDPrefix:`${u}-diff-tab`}),h(pn,{leftEvent:ie,rightEvent:Z}),h(c,{style:L.diffContent,testID:`${u}-diff-content`,children:le()})]})]}),ce&&h(Ct,{currentIndex:T-1,totalItems:y,onPrevious:se,onNext:N,itemLabel:"Change",subtitle:Te(new Date(e.timestamp)),absolute:true})]})}function St({change:e,changes:t,selectedIndex:a,onIndexChange:r}){let o=t.length;if(o<=1)return null;let n=o-a;return h(Ct,{currentIndex:n-1,totalItems:o,onPrevious:()=>r(Math.min(o-1,a+1)),onNext:()=>r(Math.max(0,a-1)),itemLabel:"Change",subtitle:Te(new Date(e.timestamp))})}var L=ne.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:v.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:v.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:v.color.textSecondary,fontFamily:K,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:K,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:v.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:v.color.textTertiary,fontFamily:K},valueBox:{backgroundColor:v.color.bg,borderRadius:6,borderWidth:1,borderColor:v.color.border,padding:8},valueText:{fontSize:12,color:v.color.text,fontFamily:K,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:K}}),f=ne.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:v.color.surface,borderRadius:6,borderWidth:1,borderColor:v.color.accentBorderStrong,overflow:"hidden",shadowColor:v.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:v.color.accentBorder,backgroundColor:v.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:v.color.accent,fontFamily:K},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:v.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:v.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:K},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:fe.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:fe.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:v.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:v.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:v.color.accentSoft,borderWidth:1,borderColor:v.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:v.color.accent,fontFamily:K},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:v.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:v.color.accent,fontFamily:K},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:v.color.accentBorder,backgroundColor:v.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:K,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as $n}from"react";import{CompactRow as En,night as We,ToolEmptyState as At,resolveListEmptyState as Pn,monoFont as It}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as Fe}from"react/jsx-runtime";function Rn(e){try{let t=e.getValue();if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"on device";if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return t.length===0?"[]":`[${t.length} item${t.length===1?"":"s"}]`;if(typeof t=="object"){let a=Object.keys(t);return a.length===0?"{}":a.length<=3?a.join(", "):`${a.slice(0,2).join(", ")} +${a.length-2}`}return String(t).slice(0,40)}catch{return""}}function zn(e){return e.writeKind==="value"?"primitive":e.writeKind==="action"?"custom write":e.setValue?"writable":"derived"}function Hn(){return U(At,{testID:`${u}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:`Use watchAtoms(store, { atomName }) to register your Jotai atoms.
2
- They will appear here with their current value.`})}function Wn({atoms:e,searchQuery:t,onOpenAtom:a}){let r=$n(()=>{if(!t)return e;let o=t.toLowerCase();return e.filter(n=>n.label.toLowerCase().includes(o))},[e,t]);return r.length===0&&!t?U(Hn,{}):r.length===0&&t?U(At,{testID:`${u}-atoms-no-match`,...Pn({subject:"atoms",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})}):Fe(he,{style:G.container,contentContainerStyle:G.scrollContent,showsVerticalScrollIndicator:true,testID:`${u}-atoms-scroll`,children:[Fe(c,{style:G.sectionHeader,children:[U(b,{style:G.sectionTitle,children:"ATOMS"}),U(c,{style:G.sectionCountBadge,children:U(b,{style:G.sectionCountText,testID:`${u}-atoms-count`,children:r.length})})]}),r.map(o=>{let n=Rn(o),s=p.getAtomColor(o.label),i=wt(o.label);return Fe(c,{style:G.atomRowWrapper,children:[U(En,{statusDotColor:s,statusLabel:zn(o),primaryText:o.label,secondaryText:n||void 0,showChevron:true,onPress:()=>a(o.label),testID:i,statusTestID:`${i}-kind`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-preview`}),o.changeCount>0&&U(c,{style:[G.absCountBadge,{backgroundColor:s+"22",borderColor:s+"55"}],pointerEvents:"none",children:U(b,{style:[G.absCountText,{color:s}],testID:`${i}-count`,children:String(o.changeCount)})})]},o.label)})]})}var G=ne.create({container:{flex:1},atomRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:It},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:We.color.textTertiary},sectionCountBadge:{backgroundColor:We.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:We.color.accent,fontFamily:It}});import{useCallback as Fn,useEffect as Mn,useMemo as Me,useState as Dt}from"react";import{buoyColors as je,ExpandedInfoRow as Oe,FileJson as jn,night as I,PillBadge as Ne,parseValue as Bt,monoFont as pe}from"@buoy-gg/shared-ui/web";import{DataViewer as On,LiveExplorer as Nn,ValueEditModal as Kn,updateNestedDataByPath as Jn,deleteNestedDataByPath as _n}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as Un,jsx as V,jsxs as O}from"react/jsx-runtime";var Gn=300,te=`${u}-atom-detail`;function Yn(e){let t=a=>a.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${te}-explorer-root`:`${te}-explorer-${e.map(t).filter(Boolean).join("-")}`}function qn(e,t){if(!e.setValue)return"Derived atom \u2014 its value recomputes from other atoms and has no setter. Edit the atoms it reads from instead.";if(typeof t=="function")return"This atom holds a function \u2014 nothing here to edit as data.";if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"The value stayed on the device (too large for the wire) \u2014 open the tool on-device to edit it.";if(t&&typeof t=="object"){let a=Object.getPrototypeOf(t);if(!(a===Object.prototype||a===null||Array.isArray(t)||t instanceof Map||t instanceof Set))return`This atom holds a ${t.constructor?.name??"class"} instance \u2014 rebuilding it from edited fields would drop its prototype. Edit via app code.`}return null}function Qn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`array \xB7 ${e.length}`:typeof e}function kt({atom:e,onViewHistory:t}){let a=wt(e.label),[r,o]=Dt(0);Mn(()=>{let C=()=>o(W=>W+1),T=p.subscribe(C),A=p.subscribeToAtoms(C);return()=>{T(),A()}},[]);let n=Me(()=>{try{return e.getValue()}catch{return}},[e,r]),s=qn(e,n),[i,d]=Dt(false),m=Me(()=>{if(s===null)return{update:(C,T)=>{let A=e.getValue();e.setValue?.(C.length===0?T:Jn(A,C,T))},remove:C=>{if(C.length===0)return;let T=e.getValue();e.setValue?.(_n(T,C))},canRemove:C=>C.length>0}},[e,s]),y=Me(()=>{if(n&&typeof n=="object"){let C={};for(let[T,A]of Object.entries(n))typeof A!="function"&&(C[T]=A);return Bt(C)}return Bt(n)},[n,r]),E=Fn(C=>{e.setValue?.(C),d(false)},[e]),w=e.setValue===void 0?{color:I.color.textTertiary,label:"READ-ONLY (DERIVED)"}:e.writeKind==="action"?{color:je.warning,label:"CUSTOM WRITE"}:{color:je.success,label:"PRIMITIVE"};return O(c,{style:x.root,children:[O(he,{testID:`${te}-scroll`,style:x.scroll,contentContainerStyle:x.scrollContent,keyboardShouldPersistTaps:"handled",children:[V(c,{style:x.section,children:O(c,{style:x.editorContainer,children:[O(c,{style:x.sectionHeaderRow,children:[V(b,{testID:`${te}-editor-header`,style:x.sectionHeaderText,children:"Value Editor"}),s===null?O(re,{onPress:()=>d(true),testID:`${te}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:x.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[V(jn,{size:13,color:I.color.accent}),V(b,{style:x.rawButtonText,children:"Raw"})]}):null]}),V(c,{style:x.sectionBody,children:s===null?O(Un,{children:[V(Nn,{editable:true,label:e.label,value:n,defaultExpanded:[e.label],writer:m,dataVersion:r,testIDForPath:Yn,debounceMs:Gn}),V(b,{style:x.editorHint,children:e.writeKind==="action"?"This atom has a custom write \u2014 the edited value is handed to it as its argument (a set for atomWithStorage, an ACTION for a reducer atom).":"Edits write into the live atom as you make them \u2014 the whole value is replaced, jotai's own semantics."})]}):V(b,{style:x.blockedText,testID:`${te}-edit-blocked`,children:s})})]})}),V(c,{style:x.section,children:O(c,{style:x.infoContainer,children:[V(b,{style:x.sectionHeaderTextPlain,children:"Atom Details"}),O(c,{style:x.infoBody,children:[O(Oe,{label:"Type",children:[V(Ne,{color:e.color,testID:`${a}-type`,children:"JOTAI"}),V(b,{style:x.valueTypeText,testID:`${a}-valuetype`,children:Qn(n)})]}),V(Oe,{label:"Write",children:V(Ne,{color:w.color,testID:`${te}-write`,children:w.label})}),e.changeCount>0&&O(Oe,{label:"Changes",children:[V(Ne,{color:je.warning,testID:`${a}-changes`,children:String(e.changeCount)}),V(re,{onPress:()=>t(e.label),style:x.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${a}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.label} history`,children:V(b,{style:[x.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]})]})]})}),V(c,{style:x.section,children:O(c,{style:x.infoContainer,children:[V(b,{style:x.sectionHeaderTextPlain,children:"Value Explorer"}),V(c,{style:x.viewerBody,testID:`${a}-value`,children:y&&typeof y=="object"?V(On,{title:"",data:y,showTypeFilter:true,rawMode:true,initialExpanded:false}):V(b,{style:x.primitiveText,testID:`${a}-primitive`,children:String(n??"undefined")})})]})})]}),i&&s===null?V(Kn,{path:[],value:n,onSave:E,onCancel:()=>d(false),saveLabel:"Apply",testIDPrefix:`${u}-value`}):null]})}var x=ne.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:I.color.surface,borderRadius:6,borderWidth:1,borderColor:I.color.accent+"4D",overflow:"hidden",shadowColor:I.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:I.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:I.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:I.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:pe},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:I.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:I.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:I.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:I.color.surface,borderRadius:6,borderWidth:1,borderColor:I.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:I.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:I.color.textSecondary,borderBottomWidth:1,borderBottomColor:I.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:pe},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:I.color.bg,minHeight:60},primitiveText:{color:I.color.text,fontSize:12,fontFamily:pe,padding:14},valueTypeText:{color:I.color.textTertiary,fontSize:10,fontFamily:pe,marginLeft:6},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:pe}});import{useMemo as Zn}from"react";import{EntityFilterView as Xn}from"@buoy-gg/shared-ui/web";import{jsx as er}from"react/jsx-runtime";var tr=["\u2022 count -> hides countAtom from atoms & events","\u2022 auth -> hides authAtom, authStatusAtom","\u2022 user -> hides userAtom from both tabs"];function ar({ignoredPatterns:e,onTogglePattern:t,onAddPattern:a,atoms:r}){let o=Zn(()=>r.map(n=>({name:n.label,color:n.color})),[r]);return er(Xn,{entities:o,ignoredPatterns:e,onTogglePattern:t,onAddPattern:a,entityNoun:"ATOMS",entitySingular:"atom",entityKey:"atom",testIDPrefix:u,slug:Ae,howItWorks:"Patterns hide matching atoms from both the Atoms tab and the Events tab. Tap an atom above to quickly add it as a filter.",examples:tr,emptyMessage:"No atoms are being watched yet."})}import{Fragment as Lt,jsx as g,jsxs as H}from"react/jsx-runtime";function or({isEnabled:e,searchText:t,totalChanges:a}){let r=ht({subject:"changes",search:t,total:a,capturing:e,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return g(Pe,{...r,testID:`${u}-empty`})}function Ke({visible:e,onClose:t,onBack:a,onMinimize:r,enableSharedModalDimensions:o=false,inline:n=false,initialTab:s,initialSelectedChangeId:i,initialDetailView:d,onChangeSelect:m,onAtomExpand:y}){let E=Jo(),w=No("jotai.changes"),[C,T]=_(false),[A,W]=_(s??"atoms"),[z,ie]=_(null),[Z,ye]=_(null),[le,se]=_(false),[N,be]=_(new Set),{atomChanges:ce,filteredChanges:Y,stats:Ce,filter:Er,setFilter:de,atoms:ue,clearChanges:Ht,isEnabled:ve,toggleCapture:Wt}=pt(),J=Q(()=>N.size===0?Y:Y.filter(l=>!Array.from(N).some(S=>l.atomLabel.toLowerCase().includes(S.toLowerCase()))),[Y,N]),ae=Q(()=>N.size===0?ue:ue.filter(l=>!Array.from(N).some(S=>l.label.toLowerCase().includes(S.toLowerCase()))),[ue,N]),Ft=Q(()=>z?ce.filter(l=>l.atomLabel===z).length:0,[ce,z]),we=Q(()=>z?J.filter(l=>l.atomLabel===z):J,[J,z]),Be=Q(()=>we.slice(0,w),[we,w]),ke=Q(()=>Math.max(0,we.length-w),[we.length,w]),Mt=ke>0,P=Be,[Le,X]=_(null),ee=Q(()=>{if(Le===null)return null;let l=P.findIndex(S=>S.id===Le);return l>=0?l:null},[Le,P]),M=ee!==null?P[ee]:null,Ye=Ve(null);dt(()=>{if(!m)return;let l=M?.id??null;l===null||l===Ye.current||(Ye.current=l,m(M))},[M,m]);let qe=Ve(null);dt(()=>{!i||qe.current===i||!P.some(l=>l.id===i)||(qe.current=i,X(i))},[i,P]);let[q,$e]=_(""),[jt,xe]=_(false),Pr=Ve(null),Ot=Ve(null),Nt=D(l=>{},[]),Kt=l=>{$e(l),A==="events"&&de(S=>({...S,searchText:l}))},Jt=D(()=>{$e(""),de(l=>({...l,searchText:""})),xe(false)},[de]),Qe=D(l=>{X(l.id)},[]),_t=D(()=>{T(true)},[]),Ut=D(()=>{X(null)},[]),Ze=D(l=>{let S=P[l];S&&X(S.id)},[P]),Gt=D(l=>{ie(l),X(null)},[]),Yt=D(()=>{ie(null),X(null)},[]),qt=D(l=>{ye(l),y?.(l)},[y]),Qt=D(()=>{ye(null)},[]),Zt=D(()=>ae.reduce((l,S)=>{try{let oe=S.getValue();l[S.label]=ge(oe)}catch{l[S.label]=null}return l},{}),[ae]),Xt=D(()=>J.map(l=>({id:l.id,atomLabel:l.atomLabel,timestamp:l.timestamp,prevValue:ge(l.prevValue),nextValue:ge(l.nextValue),hasValueChange:l.hasValueChange,changedKeys:l.changedKeys})),[J]),ea=D(()=>P.map(l=>({id:l.id,atomLabel:l.atomLabel,timestamp:l.timestamp,prevValue:ge(l.prevValue),nextValue:ge(l.nextValue),hasValueChange:l.hasValueChange,changedKeys:l.changedKeys})),[P]),ta=D(l=>{be(S=>{let oe=new Set(S);return oe.has(l)?oe.delete(l):oe.add(l),oe})},[]),aa=D(l=>{be(S=>new Set([...S,l]))},[]),oa=D(l=>{W(l),ie(null),X(null),se(false),q&&($e(""),de(S=>({...S,searchText:""}))),xe(false)},[q,de]),Xe=D(l=>l.id,[]),et=Q(()=>Tn(P),[P]),tt=D(({item:l})=>g(yt,{change:l,onPress:Qe,testID:et.get(l.id)}),[Qe,et]),at=N.size>0,ot=()=>le?H(B,{children:[g(B.Navigation,{onBack:()=>se(false)}),g(B.Content,{title:"Filters",centered:true,testID:`${u}-filters-title`})]}):M?H(B,{children:[g(B.Navigation,{onBack:Ut}),g(B.Content,{title:`${M.atomLabel}/${M.category}`,centered:true,testID:`${u}-detail-title`})]}):z?H(B,{children:[g(B.Navigation,{onBack:Yt}),g(B.Content,{title:`${z} History`,centered:true,testID:`${u}-history-title`}),g(B.Actions,{children:g(Re,{value:ea,disabled:P.length===0,buttonStyle:$.headerActionButton,testID:`${u}-copy`})})]}):Z?H(B,{children:[g(B.Navigation,{onBack:Qt}),g(B.Content,{title:Z,centered:true,testID:`${u}-atom-detail-title`})]}):H(B,{children:[a&&g(B.Navigation,{onBack:a}),g(B.Content,{title:"",children:jt?g(B.Search,{value:q,onChangeText:Kt,onCancel:Jt,placeholder:A==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${u}-search-field`,containerTestID:`${u}-search`,clearTestID:`${u}-search-clear`,onBlur:()=>{q.length===0&&xe(false)}}):g(Po,{tabs:[{key:"atoms",label:`Atoms${ae.length>0?` (${ae.length})`:""}`},{key:"events",label:`Events${J.length>0?` (${J.length})`:""}`}],activeTab:A,onTabChange:oa,testIDPrefix:`${u}-tab`})}),H(B.Actions,{children:[g(re,{onPress:()=>xe(true),style:$.headerActionButton,testID:`${u}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:g(zo,{size:14,color:k.color.textSecondary})}),g(re,{onPress:()=>se(true),style:[$.headerActionButton,at&&$.headerActionButtonActive],testID:`${u}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:g(Ho,{size:14,color:at?k.color.accent:k.color.textSecondary})}),A==="atoms"&&g(Re,{value:Zt,disabled:ae.length===0,buttonStyle:$.headerActionButton,testID:`${u}-copy`}),A==="events"&&H(Lt,{children:[g(Re,{value:Xt,disabled:J.length===0,buttonStyle:$.headerActionButton,testID:`${u}-copy`}),g(jo,{isEnabled:ve,onToggle:Wt,accessibilityLabel:"Toggle Jotai atom capture",testID:`${u}-power`}),g(Oo,{onPress:Ht,disabled:J.length===0,buttonStyle:$.headerActionButton,testID:`${u}-clear`})]})]})]}),na=()=>{if(le)return g(ar,{ignoredPatterns:N,onTogglePattern:ta,onAddPattern:aa,atoms:ue});if(M&&ee!==null)return g(Tt,{change:M,changes:P,selectedIndex:ee,onIndexChange:Ze,disableInternalFooter:true,initialView:d});if(z)return P.length>0?g(Ee,{testID:`${u}-history-list`,data:P,renderItem:tt,keyExtractor:Xe,contentContainerStyle:$.listContent,showsVerticalScrollIndicator:true,...mt}):g(Pe,{testID:`${u}-history-empty`,...ht({subject:"changes",search:q,total:q.trim()?Ft:0,capturing:ve,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${z} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${z}.`}})});if(Z){let l=ue.find(S=>S.label===Z)??null;return l?g(kt,{atom:l,onViewHistory:Gt}):g(Pe,{testID:`${u}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${Z} is not in the registry any more.`})}return A==="atoms"?g(Wn,{atoms:ae,searchQuery:q,onOpenAtom:qt}):H(Lt,{children:[!ve&&H(c,{style:$.disabledBanner,testID:`${u}-banner-disabled`,children:[g(Wo,{size:14,color:k.color.warning}),g(b,{style:$.disabledText,children:"Atom capture is disabled"})]}),Mt&&H(re,{style:$.lockedBanner,onPress:_t,activeOpacity:.8,testID:`${u}-locked`,accessibilityRole:"button",children:[H(b,{style:$.lockedText,testID:`${u}-locked-text`,children:[ke," older"," ",ke===1?"change":"changes"," locked"]}),g(c,{style:$.upgradeBadge,children:g(b,{style:$.upgradeBadgeText,children:"UPGRADE"})})]}),Be.length>0?g(Ee,{ref:Ot,testID:`${u}-list`,data:Be,renderItem:tt,keyExtractor:Xe,contentContainerStyle:$.listContent,showsVerticalScrollIndicator:true,...mt}):g(or,{isEnabled:ve,searchText:q,totalChanges:Ce.totalChanges})]})},ra=o?Fo.modal.root():"buoy-jotai-modal";if(!e)return null;let nt=M&&ee!==null?g(St,{change:M,changes:P,selectedIndex:ee,onIndexChange:Ze}):null,ia=M&&P.length>1?68:0,la=!le&&!(M&&ee!==null)&&(z!=null||A==="events"||A==="atoms"),rt=g(c,{style:$.container,children:na()}),it=g(Mo,{visible:C,onClose:()=>T(false),featureName:"Full Atom History"});return n?H(gt,{children:[H(c,{style:$.inlineRoot,children:[g(c,{style:$.inlineHeader,...Ko,children:ot()}),rt,nt]}),it]}):H(gt,{children:[g(Eo,{visible:e,onClose:t,onMinimize:r,persistenceKey:ra,header:{showToggleButton:true,customContent:ot()},onModeChange:Nt,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:la,styles:{},footer:nt,footerHeight:ia,children:rt}),it]})}function nr(e={}){return g(Ke,{...e,inline:true,visible:true,onClose:()=>{}})}var $=ne.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ro.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:k.color.buttonSurface,borderWidth:1,borderColor:k.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:k.color.accentSoft,borderColor:k.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:k.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:k.color.warning+"20"},disabledText:{color:k.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:k.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:k.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:k.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:k.color.accentBorder},lockedText:{color:k.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:k.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:k.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{JotaiIcon as Je,JOTAI_ICON_COLOR as rr}from"@buoy-gg/shared-ui/web";import{createToolFactory as ir,defineToolPreset as lr}from"@buoy-gg/shared-ui/web";import{jsx as $t}from"react/jsx-runtime";var Et=lr({id:"jotai",name:"JOTAI",description:"Jotai atom & state inspector",slot:"both",icon:({size:e})=>$t(Je,{size:e}),component:Ke,props:{enableSharedModalDimensions:false}}),sr=ir(Et,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}),e=>({icon:({size:t})=>$t(Je,{size:t,color:e.iconColor})}));import{getDefaultStore as cr}from"jotai/vanilla";import{atom as dr}from"jotai/vanilla";var ur=dr(null),_e=ur.write,Pt=typeof _e=="function"?String(_e):null;function hr(e){let t=e,a=t?.write;return typeof a!="function"?"action":a===_e||t!==null&&"init"in t&&Pt!==null&&String(a)===Pt?"value":"action"}function Rt(e,t,a){let r=a?.enabled!==false,o=[];for(let[n,s]of Object.entries(t)){let i=s,d=Symbol.for(`@@buoy-jotai/watched/${n}`);if(i[d])continue;i[d]=true;let m;try{m=e.get(s)}catch{m=void 0}let y=typeof s.write=="function",E=e.set&&y?C=>{e.set(s,C)}:void 0;p.registerAtom(n,()=>{try{return e.get(s)}catch{return}},E,y?hr(s):void 0),r&&p.addAtomChange({atomLabel:n,prevValue:void 0,nextValue:m,category:"initial"});let w=e.sub(s,()=>{try{let C=e.get(s);p.addAtomChange({atomLabel:n,prevValue:m,nextValue:C,category:"write"}),m=C}catch{}});o.push(()=>{w(),delete i[d],p.unregisterAtom(n)})}return()=>o.forEach(n=>n())}function gr(e,t){let a=cr();return Rt(a,e,t)}function mr(e){return p.getAtom(e)!==void 0}import{WIRE_DETAIL_LIMIT_BYTES as fr,createSyncAdapter as pr,capDetail as yr,detailByIdAction as br,expandKeyedArrays as Cr,memoByIdentity as vr,onDeviceMarker as wr,patchFromPath as xr,readParams as Ue,readPath as Vr,refusalText as Tr,shapeSummary as Ie,suggestedPatch as Sr,toWire as Ar,typedEditViolations as Ir,unshapedLists as Dr}from"@buoy-gg/shared-ui/web";var De=wr("Value","Atom values stay on the device \u2014 fetched on demand via getChangeDetail / getAtomValue."),Ge=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function zt(e,t){if(!Ge(e)||!Ge(t))return t;let a={...e};for(let[r,o]of Object.entries(t))a[r]=r in e?zt(e[r],o):o;return a}function Br(e,t){let a=e;for(let r of t.split(".")){if(!Ge(a)||!(r in a))return false;a=a[r]}return Array.isArray(a)?a.length>0:!!a&&typeof a=="object"}var kr=vr(e=>({...e,prevValue:De,nextValue:De})),Lr=e=>Ar(e,De),$r=pr({version:2,getSnapshot:()=>({changes:p.getAtomChanges().map(kr),atoms:p.getAtomSnapshots().map(e=>({...e,currentValue:Lr(e.currentValue)}))}),subscribe:[e=>p.subscribe(e),e=>p.subscribeToAtoms(e)],actions:{clearEvents:()=>{p.clearAtomChanges()},getChangeDetail:br(e=>p.getAtomChangeById(e),(e,t)=>({prevValue:t(e.prevValue),nextValue:t(e.nextValue)})),getAtomValue:e=>{let{label:t,path:a}=Ue(e);if(!t)return{found:false,reason:"missing label"};let r=p.getAtom(t);if(!r)return{found:false,reason:"unknown label"};let o;try{o=r.getValue()}catch{o=void 0}try{JSON.stringify(o)}catch{return{found:true,label:t,currentValue:De}}if(a){let n=Vr(o,a);return n.ok?{found:true,label:t,path:a,shape:Ie(n.value),currentValue:n.value}:{found:false,reason:n.error}}return{found:true,label:t,...Ie(o)?{shape:Ie(o)}:{},currentValue:yr(o,fr)}},listAtoms:e=>{let{includeValues:t=false,limit:a}=Ue(e),r=p.getAtoms(),o=(typeof a=="number"&&a>0?r.slice(0,a):r).map(n=>{let s;if(t)try{s=n.getValue()}catch{s=void 0}let i;try{i=Ie(n.getValue())}catch{i=void 0}return{label:n.label,changes:n.changeCount,writable:typeof n.setValue=="function",...i?{shape:i}:{},...t?{currentValue:s}:{}}});return{atoms:o,total:r.length,returned:o.length,includedValues:t}},setAtom:e=>{let{label:t,value:a,merge:r,path:o,force:n}=Ue(e);if(!t)throw new Error("setAtom requires a `label`");let s=p.getAtom(t),i;try{i=s?.getValue()}catch{i=void 0}let d=a,m=[],y=[],E=r===true||o!==void 0;if(o!==void 0){if(a===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${o}" to.`};let w=xr(i,o,a);if(!w.ok)return{ok:false,error:`Refused: ${w.error}`};d=w.patch}if(!n&&E&&i!==void 0){let w=Cr(i,d);if(w.error)return{ok:false,error:`Refused: ${w.error}`};d=w.patch,m=w.notes,y=Dr(i).filter(T=>Br(d,T));let C=Ir(i,d,{noun:"atom"});if(C.length){let T=Sr(d,C);return{ok:false,error:Tr(C,"atom",T),violations:C,...T?{suggestedValue:T}:{}}}}return p.setAtomValue(t,E?zt(i,d):d),{ok:true,...o!==void 0?{path:o}:{},...m.length?{keyed:m}:{},...y.length?{unchecked:y.map(w=>`\`${w}\` was empty, so nothing knows what its items look like and the shape of what you added was NOT checked.`)}:{}}}}});export{rr as JOTAI_ICON_COLOR,yt as JotaiAtomChangeItem,Tt as JotaiAtomDetailContent,St as JotaiAtomDetailFooter,kt as JotaiAtomValueDetailContent,Je as JotaiIcon,Ke as JotaiModal,nr as JotaiToolView,sr as createJotaiTool,mr as isAtomWatched,p as jotaiStateStore,$r as jotaiSyncAdapter,Et as jotaiToolPreset,pt as useJotaiAtomChanges,Rt as watchAtoms,gr as watchDefaultStoreAtoms};
1
+ "use client";var ct=Object.defineProperty;var fo=Object.getOwnPropertyDescriptor;var po=Object.getOwnPropertyNames;var yo=Object.prototype.hasOwnProperty;var bo=(e,t)=>{for(var o in t)ct(e,o,{get:t[o],enumerable:true})},dt=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of po(t))!yo.call(e,a)&&a!==o&&ct(e,a,{get:()=>t[a],enumerable:!(r=fo(t,a))||r.enumerable});return e},vo=(e,t,o)=>(dt(e,t,"default"),o&&dt(o,t,"default"));var Ur=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{createRestoreScope as Co,emptyRestoreResult as wo,failedRestore as xo,registerStateSnapshotProvider as To,unionKeys as Vo}from"@buoy-gg/shared-ui/web";import{boundedDeepEqual as So}from"@buoy-gg/shared-ui/web/dataViewer";import{ChangeLog as Ao,entityColor as Io,formatValuePreview as Do,shallowDiffSummary as Lo}from"@buoy-gg/shared-ui/web";var ko={count:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",nav:"#F97316",form:"#EF4444",modal:"#A855F7",filter:"#84CC16"};function ut(e){return Io(e,ko)}function Eo(e,t=40){return Do(e,{maxLength:t,functionLabel:"(fn)"})}var Bo=Lo,$o=class extends Ao{constructor(){super(...arguments);this.atoms=new Map;this.atomListeners=new Set}addAtomChange(e){if(!this.canRecord())return;let{atomLabel:t,prevValue:o,nextValue:r,category:a="write"}=e,n=o!==r,{summary:l,changedKeys:i,changedCount:d}=Bo(o,r),f=Eo(r),c={id:this.nextId(),atomLabel:t,timestamp:Date.now(),prevValue:o,nextValue:r,hasValueChange:n,category:a,changedKeys:i,changedKeysCount:d,diffSummary:l,valuePreview:f,isSlowUpdate:false};this.push(c);let V=this.atoms.get(t);V&&V.changeCount++,this.notifyListeners(),this.notifyAtomListeners()}getAtomChanges(){return this.getAll()}getAtomChangeById(e){return this.getById(e)}clearAtomChanges(){for(let e of this.atoms.values())e.changeCount=0;this.clear(),this.notifyAtomListeners()}getAtomSnapshots(){return Array.from(this.atoms.values()).map(e=>{let t;try{t=e.getValue()}catch{t=void 0}return{label:e.label,changeCount:e.changeCount,color:e.color,currentValue:t,writeKind:e.writeKind}})}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let o=new Map;for(let n of this.items){let l=n.prevValue;(!l||l.__buoyValueOnDevice!==true)&&o.set(n.id,n)}let r=e.slice(0,this.max).map(n=>{let l=o.get(n.id),i=n.prevValue;return l&&i?.__buoyValueOnDevice===true?{...n,prevValue:l.prevValue,nextValue:l.nextValue}:n}),a=new Map;for(let[n,l]of this.atoms)try{let i=l.getValue(),d=i;(!d||d.__buoyValueOnDevice!==true)&&a.set(n,i)}catch{}this.atoms=new Map(t.map(n=>{let l=n.currentValue,i=a.get(n.label),d=i!==void 0&&l?.__buoyValueOnDevice===true?i:n.currentValue;return[n.label,{label:n.label,changeCount:n.changeCount,color:n.color,getValue:()=>d,writeKind:n.writeKind}]})),this.setItems(r),this.notifyAtomListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateAtomValue(e,t){let o=this.atoms.get(e);o&&(this.atoms.set(e,{...o,getValue:()=>t}),this.notifyAtomListeners())}registerAtom(e,t,o,r){if(this.atoms.has(e))return;let a={label:e,changeCount:0,color:ut(e),getValue:t,setValue:o,writeKind:r};this.atoms.set(e,a),this.notifyAtomListeners()}setAtomValue(e,t){let o=this.atoms.get(e);if(!o)throw new Error(`Atom "${e}" is not registered`);if(!o.setValue)throw new Error(`Atom "${e}" is read-only (derived) \u2014 cannot set`);o.setValue(t)}unregisterAtom(e){this.atoms.delete(e),this.notifyAtomListeners()}getAtoms(){return Array.from(this.atoms.values())}getAtom(e){return this.atoms.get(e)}getAtomColor(e){return this.atoms.get(e)?.color??ut(e)}filterAtomChanges(e){let t=this.getAll();if(e.searchText){let o=e.searchText.toLowerCase();t=t.filter(r=>r.atomLabel.toLowerCase().includes(o)||r.valuePreview.toLowerCase().includes(o)||r.changedKeys.some(a=>a.toLowerCase().includes(o)))}return e.atomLabels&&e.atomLabels.length>0&&(t=t.filter(o=>e.atomLabels.includes(o.atomLabel))),e.onlyWithChanges&&(t=t.filter(o=>o.hasValueChange)),t}getStats(){let e=this.items.length,t=this.items.filter(o=>o.hasValueChange).length;return{totalChanges:e,changesWithValueChange:t,changesWithoutValueChange:e-t,atomCount:this.atoms.size}}getUniqueAtomLabels(){return Array.from(this.atoms.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToAtoms(e){return this.atomListeners.add(e),()=>this.atomListeners.delete(e)}notifyAtomListeners(){let e=this.getAtoms();this.atomListeners.forEach(t=>t(e))}},y=new $o;function Po(){let e=y.getAtoms();if(e.length===0)return{canCapture:false,canRestore:false,detail:"No Jotai atoms registered \u2014 pass your atoms to watchAtoms() / watchDefaultStoreAtoms()"};let t=e.filter(o=>o.setValue).length;return{canCapture:true,canRestore:t>0,detail:t<e.length?`${e.length-t} derived atom(s) recompute automatically and are not restored`:void 0}}async function Ro(){let e=[],t={},o=0;for(let r of y.getAtoms())try{let a=r.getValue();if(typeof a=="function"){e.push(`atom "${r.label}": function value not capturable`);continue}r.setValue||(o+=1),t[r.label]={value:a,writable:!!r.setValue}}catch(a){e.push(`atom "${r.label}": capture failed (${String(a)})`)}return o>0&&e.push(`${o} derived atom(s) captured for inspection only (recompute on restore)`),{data:{atoms:t},warnings:e}}async function zo(e,t){let o=e,r=Co(t),a=wo();if(!o?.atoms)return xo("empty jotai snapshot");let n=0;for(let[i,d]of Object.entries(o.atoms)){if(!r.allows(i))continue;if(!d.writable){n+=1;continue}let f=y.getAtom(i);if(!f){a.skipped.push({id:i,reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!f.setValue){a.skipped.push({id:i,reason:"atom is now read-only (derived)"});continue}try{f.setValue(d.value),a.applied+=1}catch(c){a.skipped.push({id:i,reason:String(c)}),a.ok=false}}n>0&&a.warnings.push(`${n} derived atom(s) left to recompute`);let l=r.excludedWarning("atom(s)");return l&&a.warnings.push(l),a}async function Ho(e,t){let o=e?.atoms??{},r=t===void 0,a={};if(r)for(let i of y.getAtoms())try{a[i.label]={value:i.getValue(),writable:!!i.setValue}}catch{}else Object.assign(a,t?.atoms??{});let n=[],l=[];for(let i of Vo(a,o)){if(!(i in o)){r?l.push(`atom "${i}" not in snapshot \u2014 untouched`):n.push({key:i,label:i,verdict:"removed",oldValue:a[i]?.value});continue}let d=o[i],f=i in a&&So(a[i].value,d.value);if(!d.writable){n.push({key:i,label:i,verdict:f?"unchanged":"recomputes",reason:f?void 0:"derived atom \u2014 recomputes from its sources",oldValue:a[i]?.value,newValue:d.value});continue}if(r){let c=y.getAtom(i);if(!c){n.push({key:i,label:i,verdict:"wont-apply",reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!c.setValue){n.push({key:i,label:i,verdict:"wont-apply",reason:"atom is now read-only (derived)"});continue}}i in a?f?n.push({key:i,label:i,verdict:"unchanged"}):n.push({key:i,label:i,verdict:"changed",oldValue:a[i].value,newValue:d.value}):n.push({key:i,label:i,verdict:"added",newValue:d.value})}return{items:n,notes:l}}To({id:"jotai",label:"Jotai",status:Po,capture:Ro,restore:zo,previewItems:Ho});import{useState as _,useMemo as Q,useRef as Ve,useCallback as L,useEffect as ht}from"react";var gt={};bo(gt,{AccessibilityInfo:()=>Fo,ActivityIndicator:()=>Fa,Alert:()=>Ka,Animated:()=>Oo,AppRegistry:()=>Ko,AppState:()=>Jo,Appearance:()=>No,BackHandler:()=>_o,Button:()=>Oa,CheckBox:()=>sa,Clipboard:()=>Uo,DeviceEventEmitter:()=>Ta,Dimensions:()=>Go,Easing:()=>Yo,FlatList:()=>Pe,I18nManager:()=>qo,Image:()=>ca,ImageBackground:()=>da,InteractionManager:()=>Zo,Keyboard:()=>Qo,KeyboardAvoidingView:()=>ua,LayoutAnimation:()=>Xo,Linking:()=>ea,LogBox:()=>xa,Modal:()=>Ma,NativeEventEmitter:()=>ta,NativeModules:()=>jo,PanResponder:()=>oa,Picker:()=>ha,PixelRatio:()=>aa,Platform:()=>na,Pressable:()=>Wa,ProgressBar:()=>ga,RefreshControl:()=>ma,SafeAreaView:()=>fa,ScrollView:()=>ge,SectionList:()=>pa,Share:()=>ra,StatusBar:()=>ya,StyleSheet:()=>ne,Switch:()=>ja,Text:()=>b,TextInput:()=>Ra,Touchable:()=>ba,TouchableHighlight:()=>za,TouchableNativeFeedback:()=>va,TouchableOpacity:()=>re,TouchableWithoutFeedback:()=>Ha,UIManager:()=>ia,Vibration:()=>la,View:()=>u,VirtualizedList:()=>Ca,YellowBox:()=>wa,findNodeHandle:()=>Na,unstable_createElement:()=>Mo,useColorScheme:()=>Va,useLocaleContext:()=>Sa,useWindowDimensions:()=>Aa});vo(gt,Wo);import*as Wo from"react-native-web";import{unstable_createElement as Mo,NativeModules as jo,AccessibilityInfo as Fo,Animated as Oo,Appearance as No,AppRegistry as Ko,AppState as Jo,BackHandler as _o,Clipboard as Uo,Dimensions as Go,Easing as Yo,I18nManager as qo,Keyboard as Qo,InteractionManager as Zo,LayoutAnimation as Xo,Linking as ea,NativeEventEmitter as ta,PanResponder as oa,PixelRatio as aa,Platform as na,Share as ra,StyleSheet as ne,UIManager as ia,Vibration as la,CheckBox as sa,FlatList as Pe,Image as ca,ImageBackground as da,KeyboardAvoidingView as ua,Picker as ha,ProgressBar as ga,RefreshControl as ma,SafeAreaView as fa,SectionList as pa,StatusBar as ya,Touchable as ba,TouchableNativeFeedback as va,VirtualizedList as Ca,YellowBox as wa,LogBox as xa,DeviceEventEmitter as Ta,useColorScheme as Va,useLocaleContext as Sa,useWindowDimensions as Aa}from"react-native-web";import*as M from"react-native-web";import{createElement as Re,forwardRef as mt,useCallback as Ia,useRef as Da}from"react";import{useEffect as La,useState as ka}from"react";import{createPortal as Ea}from"react-dom";var Ba='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as $a}from"react/jsx-runtime";var he=Symbol.for("@buoy-gg/portal-host"),ft=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function pt(){let e=document;if(e[he])return e[he].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Ba});let o=()=>{let c=document.fullscreenElement,V=c&&c.tagName!=="CANVAS"?c:document.body;t.parentElement!==V&&V.appendChild(t)},r=new Map,a=c=>{(!t.contains(c.target)||!ft(c.target))&&r.set(c.code||c.key,{key:c.key,code:c.code,location:c.location,keyCode:c.keyCode,which:c.which,altKey:c.altKey,ctrlKey:c.ctrlKey,metaKey:c.metaKey,shiftKey:c.shiftKey})},n=c=>{r.delete(c.code||c.key)},l=()=>r.clear(),i=()=>{let c=[...r.values()];r.clear();for(let V of c)document.dispatchEvent(new KeyboardEvent("keyup",{...V,bubbles:true}))},d=c=>{ft(c.target)&&c.stopPropagation()},f=c=>c.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",a,true),document.addEventListener("keyup",n,true),window.addEventListener("blur",l),t.addEventListener("focusin",i),t.addEventListener("keydown",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",f,{passive:true}),e[he]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",a,true),document.removeEventListener("keyup",n,true),window.removeEventListener("blur",l),t.remove(),delete e[he]}},t}function Pa({children:e}){let[t,o]=ka(null);return La(()=>{let r=pt(),a=document[he];return a.users++,o(r),()=>{--a.users===0&&a.dispose()}},[]),t?Ea($a("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function F(e){let t=mt((r,a)=>{let{accessibilityState:n,accessibilityValue:l,...i}=r;for(let d of["busy","checked","disabled","expanded","selected"])n?.[d]!==void 0&&i[`aria-${d}`]===void 0&&(i[`aria-${d}`]=n[d]);for(let[d,f]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[d]!==void 0&&i[`aria-${f}`]===void 0&&(i[`aria-${f}`]=l[d]);return Re(e,{...i,ref:a})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var u=F(M.View),b=F(M.Text),Ra=F(M.TextInput),re=F(M.TouchableOpacity),za=F(M.TouchableHighlight),Ha=F(M.TouchableWithoutFeedback),Wa=F(M.Pressable),ge=F(M.ScrollView),yt=mt((e,t)=>{let o=Da(null),r=Ia(a=>{if(a){let n=a;for(;n.parentElement&&n.parentElement!==document.body;)n=n.parentElement;n.parentElement===document.body&&(o.current=n,Object.assign(n.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),pt().appendChild(n))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(a):t&&(t.current=a)},[t]);return Re(Pa,null,Re(M.Modal,{...e,ref:r}))});yt.displayName="Modal";var Ma=F(yt),ja=F(M.Switch),Fa=F(M.ActivityIndicator),Oa=F(M.Button),Na=M.findNodeHandle,Ka={alert(e,t,o,r){if(typeof document>"u")return;let a=document.createElement("dialog");a.dataset.buoyRoot="",a.setAttribute("aria-label",e),a.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let n=document.createElement("h2");if(n.textContent=e,n.style.cssText="font-size:18px;margin:0 0 12px",a.appendChild(n),t){let f=document.createElement("p");f.textContent=t,f.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",a.appendChild(f)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=o?.length?o:[{text:"OK"}],d=()=>{a.close?.(),a.remove()};for(let f of i){let c=document.createElement("button");c.type="button",c.textContent=f.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${f.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{d(),f.onPress?.()},l.appendChild(c)}a.addEventListener("cancel",f=>{f.preventDefault(),r?.cancelable!==false&&(d(),r?.onDismiss?.())}),a.appendChild(l),document.body.appendChild(a),a.showModal?a.showModal():a.setAttribute("open","")}};import{JsModal as Ja,ModalHeader as k,TabSelector as _a,macOSColors as Ua,night as E,Search as Ga,Filter as Ya,Power as qa,ToolEmptyState as ze,resolveListEmptyState as bt,devToolsStorageKeys as Qa,ProUpgradeModal as Za,PowerToggleButton as Xa,ToolbarCopyButton as He,ToolbarClearButton as en,truncatePayload as me,TickProvider as vt,useLimit as tn,windowDragProps as on,EVENT_LIST_PRESET as Ct}from"@buoy-gg/shared-ui/web";import{useIsPro as an}from"@buoy-gg/license/web";import{useCallback as nn,useMemo as wt}from"react";import{useChangeLog as rn,useSubscribedValue as ln}from"@buoy-gg/shared-ui/web";function sn(e,t){let o=e;if(t.searchText){let r=t.searchText.toLowerCase();o=o.filter(a=>a.atomLabel.toLowerCase().includes(r)||a.valuePreview.toLowerCase().includes(r)||a.changedKeys.some(n=>n.toLowerCase().includes(r)))}return t.atomLabels&&t.atomLabels.length>0&&(o=o.filter(r=>t.atomLabels.includes(r.atomLabel))),t.onlyWithChanges&&(o=o.filter(r=>r.hasValueChange)),o}var cn=()=>y.getAtoms(),dn=e=>y.subscribeToAtoms(e);function xt(){let e=rn(y,{filterItems:sn}),t=ln(cn,dn),o=wt(()=>{let n=e.items.length,l=e.items.filter(i=>i.hasValueChange).length;return{totalChanges:n,changesWithValueChange:l,changesWithoutValueChange:n-l,atomCount:t.length}},[e.items,t]),r=wt(()=>y.getUniqueAtomLabels(),[t]),a=nn(n=>y.getAtomChangeById(n),[]);return{atomChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:o,atoms:t,clearChanges:y.clearAtomChanges.bind(y),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,atomLabels:r,getChangeById:a}}import{memo as un}from"react";import{ChangeRow as hn,night as gn}from"@buoy-gg/shared-ui/web";import{jsx as mn}from"react/jsx-runtime";function fn(e,t){return t}function pn(e,t){return e==="initial"?gn.color.textTertiary:y.getAtomColor(t)}function We(e,t=20){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="boolean"||typeof e=="number")return String(e);if(typeof e=="string")return`"${e.length>t?e.slice(0,t-1)+"\u2026":e}"`;if(Array.isArray(e))return e.length===0?"[]":`[${e.length} item${e.length===1?"":"s"}]`;if(typeof e=="object"){let o=Object.keys(e);return o.length===0?"{}":`{${o.slice(0,2).join(", ")}${o.length>2?"\u2026":""}}`}return String(e).slice(0,t)}function yn(e){return e.hasValueChange?`${We(e.prevValue)} \u2192 ${We(e.nextValue)}`:"no change"}function bn(e){return e.category==="initial"?"INIT":"WRITE"}function vn(e){let t=e.nextValue;return typeof t=="object"&&t!==null&&!Array.isArray(t)?e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.valuePreview||"atom()":We(t)}var Tt=un(function({change:e,onPress:t,testID:o}){let r=pn(e.category,e.atomLabel),a=fn(e.category,e.atomLabel),n=yn(e),l=vn(e),i=bn(e);return mn(hn,{statusColor:r,statusLabel:a,sublabel:n,primaryText:l,timestamp:e.timestamp,badgeText:i,changed:e.hasValueChange,onPress:()=>t(e),testID:o})});import{memo as Cn,useState as Me,useCallback as fe,useMemo as Vt}from"react";import{buoyColors as pe,night as C,EventStepperFooter as St,formatRelativeTime as Se,parseValue as Ae,Info as wn,Zap as At,FileText as xn,Database as Tn,GitBranch as Vn,copyToClipboard as Sn,ProUpgradeModal as An,DiffModeTabs as In,CompareBar as Dn,DetailViewToggle as Ln,monoFont as K}from"@buoy-gg/shared-ui/web";import{DataViewer as kn,SplitDiffViewer as En,TreeDiffViewer as Bn,diffThemes as $n}from"@buoy-gg/shared-ui/web/dataViewer";import{useIsPro as Pn}from"@buoy-gg/license/web";var h="buoy-jotai";function Ie(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Rn(e,t){return`${h}-row-${Ie(e)}-${t}`}function It(e){return`${h}-atom-${Ie(e)}`}function zn(e){let t=new Map,o=new Map;for(let r of e){let a=(t.get(r.atomLabel)??0)+1;t.set(r.atomLabel,a),o.set(r.id,Rn(r.atomLabel,a))}return o}import{jsx as g,jsxs as R}from"react/jsx-runtime";var Hn=[{key:"change",label:"CHANGE",icon:xn},{key:"value",label:"VALUE",icon:Tn},{key:"diff",label:"DIFF",icon:Vn}],Wn=["diff"];function Mn(e){switch(e){case"initial":return{label:"INITIAL",color:C.color.textTertiary,bgColor:C.color.textTertiary+"26"};default:return{label:"WRITE",color:pe.success,bgColor:pe.success+"26"}}}function jn(e){let t=new Date(e),o=t.getHours().toString().padStart(2,"0"),r=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0"),n=t.getMilliseconds().toString().padStart(3,"0");return`${o}:${r}:${a}.${n}`}function Dt(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Fn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Lt(e){return e==="initial"?"INIT":"WRITE"}var On=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}],Nn=Cn(function({change:e}){let t=Pn(),[o,r]=Me(false),a=Mn(e.category),n=y.getAtomColor(e.atomLabel),l=fe(async()=>{if(!t){r(true);return}await Sn(e.nextValue)},[e.nextValue,t]);return R(ge,{style:p.container,contentContainerStyle:p.content,showsVerticalScrollIndicator:false,testID:`${h}-detail-scroll`,children:[R(u,{style:p.card,testID:`${h}-info-card`,children:[g(u,{style:p.sectionHeader,children:R(u,{style:p.sectionHeaderLeft,children:[g(wn,{size:14,color:C.color.accent}),g(b,{style:p.sectionTitle,children:"CHANGE INFO"})]})}),R(u,{style:p.cardContent,children:[R(u,{style:p.infoRow,children:[g(b,{style:p.infoLabel,children:"Atom"}),g(b,{style:[p.infoValue,p.infoValueMono,{color:n}],numberOfLines:1,ellipsizeMode:"middle",testID:`${h}-info-atom`,children:e.atomLabel})]}),R(u,{style:p.infoRow,children:[g(b,{style:p.infoLabel,children:"Time"}),g(b,{style:[p.infoValue,p.infoValueMono],testID:`${h}-info-time`,children:jn(e.timestamp)})]}),R(u,{style:p.badgeRow,children:[g(u,{style:[p.categoryBadge,{backgroundColor:a.bgColor}],children:g(b,{style:[p.categoryText,{color:a.color}],testID:`${h}-info-category`,children:a.label})}),e.hasValueChange?R(u,{style:p.changesBadge,children:[g(At,{size:10,color:pe.success}),g(b,{style:p.changesText,testID:`${h}-info-changes`,children:e.diffSummary||"changed"})]}):g(u,{style:p.noChangesBadge,children:g(b,{style:p.noChangesText,testID:`${h}-info-no-changes`,children:"no change"})})]})]})]}),e.changedKeys.length>0&&R(u,{style:p.card,testID:`${h}-keys-card`,children:[R(u,{style:p.sectionHeader,children:[R(u,{style:p.sectionHeaderLeft,children:[g(At,{size:14,color:C.color.accent}),g(b,{style:p.sectionTitle,children:"CHANGED KEYS"})]}),g(u,{style:p.countBadge,children:g(b,{style:p.countText,testID:`${h}-keys-count`,children:e.changedKeys.length})})]}),g(u,{style:p.cardContent,children:g(u,{style:p.keysContainer,children:e.changedKeys.map(i=>g(u,{style:p.keyBadge,children:g(b,{style:p.keyText,testID:`${h}-key-${Ie(i)}`,children:i})},i))})})]}),g(u,{style:p.actionsRow,children:g(u,{style:[p.actionButton,p.actionButtonCopy],onTouchEnd:l,testID:`${h}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:g(b,{style:[p.actionButtonText,{color:C.color.accent}],children:"COPY VALUE"})})}),g(An,{visible:o,onClose:()=>r(false),featureName:"Copy"})]})});function kt({change:e,changes:t,selectedIndex:o,onIndexChange:r,disableInternalFooter:a=false,initialView:n="change"}){let[l,i]=Me(n),[d,f]=Me("tree"),c=t.length,V=y.getAtomColor(e.atomLabel),w=Lt(e.category),v=Fn(Ae(e.nextValue)),S=c-o,I=o<c-1?o+1:null,W=I!==null?t[I]:null,z=S-1,ie=Vt(()=>({index:I??0,label:z>0?`#${z}`:"Initial",timestamp:W?Dt(W.timestamp):"",relativeTime:W?Se(new Date(W.timestamp)):"value",badge:W?g(u,{style:[B.changeBadgeSmall,{backgroundColor:`${y.getAtomColor(W.atomLabel)}20`}],children:g(b,{style:[B.changeTextSmall,{color:y.getAtomColor(W.atomLabel)}],children:Lt(W.category)})}):void 0}),[I,W,z]),Z=Vt(()=>({index:o,label:`#${S}`,timestamp:Dt(e.timestamp),relativeTime:Se(new Date(e.timestamp)),badge:g(u,{style:[B.changeBadgeSmall,{backgroundColor:`${V}20`}],children:g(b,{style:[B.changeTextSmall,{color:V}],children:w})})}),[o,e.timestamp,V,w,S]),be=fe(()=>{let Y=Ae(e.nextValue);return R(u,{style:B.contentCard,testID:`${h}-value-card`,children:[R(u,{style:B.valueHeader,children:[g(b,{style:B.valueLabel,children:"VALUE AFTER CHANGE"}),R(u,{style:B.valueHeaderBadges,children:[g(u,{style:[B.changeBadge,{backgroundColor:`${V}20`}],children:g(b,{style:[B.changeText,{color:V}],children:w})}),g(u,{style:B.typeBadge,children:g(b,{style:B.typeText,testID:`${h}-value-type`,children:v.toUpperCase()})})]})]}),g(u,{style:p.dataViewerContainer,children:g(kn,{title:"",data:Y,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextValue,V,w,v]),le=fe(()=>{let Y=Ae(e.prevValue),Ce=Ae(e.nextValue);return d==="split"?g(ge,{style:{flex:1},showsVerticalScrollIndicator:true,children:g(En,{oldValue:Y,newValue:Ce,theme:$n.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):g(Bn,{oldValue:Y,newValue:Ce})},[e.prevValue,e.nextValue,d]),se=fe(()=>{r(Math.min(c-1,o+1))},[o,c,r]),N=fe(()=>{r(Math.max(0,o-1))},[o,r]),ve=e.prevValue===void 0,ce=!a&&c>1;return R(u,{style:B.container,children:[g(Ln,{views:Hn,activeView:l,onViewChange:i,disabledKeys:ve?Wn:void 0,testIDPrefix:h}),R(u,{style:[B.contentArea,ce&&B.contentAreaFooterPad],children:[l==="change"&&g(Nn,{change:e}),l==="value"&&g(u,{style:B.stateContainer,children:be()}),l==="diff"&&R(u,{style:B.diffContainer,testID:`${h}-diff`,children:[g(In,{tabs:On,activeTab:d,onTabChange:f,testIDPrefix:`${h}-diff-tab`}),g(Dn,{leftEvent:ie,rightEvent:Z}),g(u,{style:B.diffContent,testID:`${h}-diff-content`,children:le()})]})]}),ce&&g(St,{currentIndex:S-1,totalItems:c,onPrevious:se,onNext:N,itemLabel:"Change",subtitle:Se(new Date(e.timestamp)),absolute:true})]})}function Et({change:e,changes:t,selectedIndex:o,onIndexChange:r}){let a=t.length;if(a<=1)return null;let n=a-o;return g(St,{currentIndex:n-1,totalItems:a,onPrevious:()=>r(Math.min(a-1,o+1)),onNext:()=>r(Math.max(0,o-1)),itemLabel:"Change",subtitle:Se(new Date(e.timestamp))})}var B=ne.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:C.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:C.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:C.color.textSecondary,fontFamily:K,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:K,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:C.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:C.color.textTertiary,fontFamily:K},valueBox:{backgroundColor:C.color.bg,borderRadius:6,borderWidth:1,borderColor:C.color.border,padding:8},valueText:{fontSize:12,color:C.color.text,fontFamily:K,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:K}}),p=ne.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:C.color.surface,borderRadius:6,borderWidth:1,borderColor:C.color.accentBorderStrong,overflow:"hidden",shadowColor:C.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:C.color.accentBorder,backgroundColor:C.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:C.color.accent,fontFamily:K},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:C.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:C.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:K},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:pe.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:pe.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:C.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:C.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:C.color.accentSoft,borderWidth:1,borderColor:C.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:C.color.accent,fontFamily:K},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:C.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:C.color.accent,fontFamily:K},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:C.color.accentBorder,backgroundColor:C.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:K,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as Kn}from"react";import{CompactRow as Jn,night as je,ToolEmptyState as Bt,resolveListEmptyState as _n,monoFont as $t}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as Fe}from"react/jsx-runtime";function Un(e){try{let t=e.getValue();if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"on device";if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return t.length===0?"[]":`[${t.length} item${t.length===1?"":"s"}]`;if(typeof t=="object"){let o=Object.keys(t);return o.length===0?"{}":o.length<=3?o.join(", "):`${o.slice(0,2).join(", ")} +${o.length-2}`}return String(t).slice(0,40)}catch{return""}}function Gn(e){return e.writeKind==="value"?"primitive":e.writeKind==="action"?"custom write":e.setValue?"writable":"derived"}function Yn(){return U(Bt,{testID:`${h}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:`Use watchAtoms(store, { atomName }) to register your Jotai atoms.
2
+ They will appear here with their current value.`})}function qn({atoms:e,searchQuery:t,onOpenAtom:o}){let r=Kn(()=>{if(!t)return e;let a=t.toLowerCase();return e.filter(n=>n.label.toLowerCase().includes(a))},[e,t]);return r.length===0&&!t?U(Yn,{}):r.length===0&&t?U(Bt,{testID:`${h}-atoms-no-match`,..._n({subject:"atoms",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})}):Fe(ge,{style:G.container,contentContainerStyle:G.scrollContent,showsVerticalScrollIndicator:true,testID:`${h}-atoms-scroll`,children:[Fe(u,{style:G.sectionHeader,children:[U(b,{style:G.sectionTitle,children:"ATOMS"}),U(u,{style:G.sectionCountBadge,children:U(b,{style:G.sectionCountText,testID:`${h}-atoms-count`,children:r.length})})]}),r.map(a=>{let n=Un(a),l=y.getAtomColor(a.label),i=It(a.label);return Fe(u,{style:G.atomRowWrapper,children:[U(Jn,{statusDotColor:l,statusLabel:Gn(a),primaryText:a.label,secondaryText:n||void 0,showChevron:true,onPress:()=>o(a.label),testID:i,statusTestID:`${i}-kind`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-preview`}),a.changeCount>0&&U(u,{style:[G.absCountBadge,{backgroundColor:l+"22",borderColor:l+"55"}],pointerEvents:"none",children:U(b,{style:[G.absCountText,{color:l}],testID:`${i}-count`,children:String(a.changeCount)})})]},a.label)})]})}var G=ne.create({container:{flex:1},atomRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:$t},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:je.color.textTertiary},sectionCountBadge:{backgroundColor:je.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:je.color.accent,fontFamily:$t}});import{useCallback as Qn,useEffect as Zn,useMemo as Oe,useState as Pt}from"react";import{buoyColors as Ne,ExpandedInfoRow as Ke,FileJson as Xn,night as D,PillBadge as Je,parseValue as Rt,monoFont as ye}from"@buoy-gg/shared-ui/web";import{DataViewer as er,LiveExplorer as tr,ValueEditModal as or,updateNestedDataByPath as ar,deleteNestedDataByPath as nr}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as rr,jsx as T,jsxs as O}from"react/jsx-runtime";var ir=300,te=`${h}-atom-detail`;function lr(e){let t=o=>o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${te}-explorer-root`:`${te}-explorer-${e.map(t).filter(Boolean).join("-")}`}function sr(e,t){if(!e.setValue)return"Derived atom \u2014 its value recomputes from other atoms and has no setter. Edit the atoms it reads from instead.";if(typeof t=="function")return"This atom holds a function \u2014 nothing here to edit as data.";if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"The value stayed on the device (too large for the wire) \u2014 open the tool on-device to edit it.";if(t&&typeof t=="object"){let o=Object.getPrototypeOf(t);if(!(o===Object.prototype||o===null||Array.isArray(t)||t instanceof Map||t instanceof Set))return`This atom holds a ${t.constructor?.name??"class"} instance \u2014 rebuilding it from edited fields would drop its prototype. Edit via app code.`}return null}function cr(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`array \xB7 ${e.length}`:typeof e}function zt({atom:e,onViewHistory:t}){let o=It(e.label),[r,a]=Pt(0);Zn(()=>{let v=()=>a(W=>W+1),S=y.subscribe(v),I=y.subscribeToAtoms(v);return()=>{S(),I()}},[]);let n=Oe(()=>{try{return e.getValue()}catch{return}},[e,r]),l=sr(e,n),[i,d]=Pt(false),f=Oe(()=>{if(l===null)return{update:(v,S)=>{let I=e.getValue();e.setValue?.(v.length===0?S:ar(I,v,S))},remove:v=>{if(v.length===0)return;let S=e.getValue();e.setValue?.(nr(S,v))},canRemove:v=>v.length>0}},[e,l]),c=Oe(()=>{if(n&&typeof n=="object"){let v={};for(let[S,I]of Object.entries(n))typeof I!="function"&&(v[S]=I);return Rt(v)}return Rt(n)},[n,r]),V=Qn(v=>{e.setValue?.(v),d(false)},[e]),w=e.setValue===void 0?{color:D.color.textTertiary,label:"READ-ONLY (DERIVED)"}:e.writeKind==="action"?{color:Ne.warning,label:"CUSTOM WRITE"}:{color:Ne.success,label:"PRIMITIVE"};return O(u,{style:x.root,children:[O(ge,{testID:`${te}-scroll`,style:x.scroll,contentContainerStyle:x.scrollContent,keyboardShouldPersistTaps:"handled",children:[T(u,{style:x.section,children:O(u,{style:x.editorContainer,children:[O(u,{style:x.sectionHeaderRow,children:[T(b,{testID:`${te}-editor-header`,style:x.sectionHeaderText,children:"Value Editor"}),l===null?O(re,{onPress:()=>d(true),testID:`${te}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:x.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[T(Xn,{size:13,color:D.color.accent}),T(b,{style:x.rawButtonText,children:"Raw"})]}):null]}),T(u,{style:x.sectionBody,children:l===null?O(rr,{children:[T(tr,{editable:true,label:e.label,value:n,defaultExpanded:[e.label],writer:f,dataVersion:r,testIDForPath:lr,debounceMs:ir}),T(b,{style:x.editorHint,children:e.writeKind==="action"?"This atom has a custom write \u2014 the edited value is handed to it as its argument (a set for atomWithStorage, an ACTION for a reducer atom).":"Edits write into the live atom as you make them \u2014 the whole value is replaced, jotai's own semantics."})]}):T(b,{style:x.blockedText,testID:`${te}-edit-blocked`,children:l})})]})}),T(u,{style:x.section,children:O(u,{style:x.infoContainer,children:[T(b,{style:x.sectionHeaderTextPlain,children:"Atom Details"}),O(u,{style:x.infoBody,children:[O(Ke,{label:"Type",children:[T(Je,{color:e.color,testID:`${o}-type`,children:"JOTAI"}),T(b,{style:x.valueTypeText,testID:`${o}-valuetype`,children:cr(n)})]}),T(Ke,{label:"Write",children:T(Je,{color:w.color,testID:`${te}-write`,children:w.label})}),e.changeCount>0&&O(Ke,{label:"Changes",children:[T(Je,{color:Ne.warning,testID:`${o}-changes`,children:String(e.changeCount)}),T(re,{onPress:()=>t(e.label),style:x.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${o}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.label} history`,children:T(b,{style:[x.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]})]})]})}),T(u,{style:x.section,children:O(u,{style:x.infoContainer,children:[T(b,{style:x.sectionHeaderTextPlain,children:"Value Explorer"}),T(u,{style:x.viewerBody,testID:`${o}-value`,children:c&&typeof c=="object"?T(er,{title:"",data:c,showTypeFilter:true,rawMode:true,initialExpanded:false}):T(b,{style:x.primitiveText,testID:`${o}-primitive`,children:String(n??"undefined")})})]})})]}),i&&l===null?T(or,{path:[],value:n,onSave:V,onCancel:()=>d(false),saveLabel:"Apply",testIDPrefix:`${h}-value`}):null]})}var x=ne.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:D.color.surface,borderRadius:6,borderWidth:1,borderColor:D.color.accent+"4D",overflow:"hidden",shadowColor:D.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:D.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:D.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:D.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:ye},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:D.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:D.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:D.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:D.color.surface,borderRadius:6,borderWidth:1,borderColor:D.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:D.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:D.color.textSecondary,borderBottomWidth:1,borderBottomColor:D.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:ye},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:D.color.bg,minHeight:60},primitiveText:{color:D.color.text,fontSize:12,fontFamily:ye,padding:14},valueTypeText:{color:D.color.textTertiary,fontSize:10,fontFamily:ye,marginLeft:6},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:ye}});import{useMemo as dr}from"react";import{EntityFilterView as ur}from"@buoy-gg/shared-ui/web";import{jsx as hr}from"react/jsx-runtime";var gr=["\u2022 count -> hides countAtom from atoms & events","\u2022 auth -> hides authAtom, authStatusAtom","\u2022 user -> hides userAtom from both tabs"];function mr({ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,atoms:r}){let a=dr(()=>r.map(n=>({name:n.label,color:n.color})),[r]);return hr(ur,{entities:a,ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,entityNoun:"ATOMS",entitySingular:"atom",entityKey:"atom",testIDPrefix:h,slug:Ie,howItWorks:"Patterns hide matching atoms from both the Atoms tab and the Events tab. Tap an atom above to quickly add it as a filter.",examples:gr,emptyMessage:"No atoms are being watched yet."})}import{Fragment as Ht,jsx as m,jsxs as H}from"react/jsx-runtime";function fr({isEnabled:e,searchText:t,totalChanges:o}){let r=bt({subject:"changes",search:t,total:o,capturing:e,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return m(ze,{...r,testID:`${h}-empty`})}function _e({visible:e,onClose:t,onBack:o,onMinimize:r,enableSharedModalDimensions:a=false,inline:n=false,initialTab:l,initialSelectedChangeId:i,initialDetailView:d,onChangeSelect:f,onAtomExpand:c}){let V=an(),w=tn("jotai.changes"),[v,S]=_(false),[I,W]=_(l??"atoms"),[z,ie]=_(null),[Z,be]=_(null),[le,se]=_(false),[N,ve]=_(new Set),{atomChanges:ce,filteredChanges:Y,stats:Ce,filter:Jr,setFilter:de,atoms:ue,clearChanges:Nt,isEnabled:we,toggleCapture:Kt}=xt(),J=Q(()=>N.size===0?Y:Y.filter(s=>!Array.from(N).some(A=>s.atomLabel.toLowerCase().includes(A.toLowerCase()))),[Y,N]),oe=Q(()=>N.size===0?ue:ue.filter(s=>!Array.from(N).some(A=>s.label.toLowerCase().includes(A.toLowerCase()))),[ue,N]),Jt=Q(()=>z?ce.filter(s=>s.atomLabel===z).length:0,[ce,z]),xe=Q(()=>z?J.filter(s=>s.atomLabel===z):J,[J,z]),ke=Q(()=>xe.slice(0,w),[xe,w]),Ee=Q(()=>Math.max(0,xe.length-w),[xe.length,w]),_t=Ee>0,P=ke,[Be,X]=_(null),ee=Q(()=>{if(Be===null)return null;let s=P.findIndex(A=>A.id===Be);return s>=0?s:null},[Be,P]),j=ee!==null?P[ee]:null,Qe=Ve(null);ht(()=>{if(!f)return;let s=j?.id??null;s===null||s===Qe.current||(Qe.current=s,f(j))},[j,f]);let Ze=Ve(null);ht(()=>{!i||Ze.current===i||!P.some(s=>s.id===i)||(Ze.current=i,X(i))},[i,P]);let[q,$e]=_(""),[Ut,Te]=_(false),_r=Ve(null),Gt=Ve(null),Yt=L(s=>{},[]),qt=s=>{$e(s),I==="events"&&de(A=>({...A,searchText:s}))},Qt=L(()=>{$e(""),de(s=>({...s,searchText:""})),Te(false)},[de]),Xe=L(s=>{X(s.id)},[]),Zt=L(()=>{S(true)},[]),Xt=L(()=>{X(null)},[]),et=L(s=>{let A=P[s];A&&X(A.id)},[P]),eo=L(s=>{ie(s),X(null)},[]),to=L(()=>{ie(null),X(null)},[]),oo=L(s=>{be(s),c?.(s)},[c]),ao=L(()=>{be(null)},[]),no=L(()=>oe.reduce((s,A)=>{try{let ae=A.getValue();s[A.label]=me(ae)}catch{s[A.label]=null}return s},{}),[oe]),ro=L(()=>J.map(s=>({id:s.id,atomLabel:s.atomLabel,timestamp:s.timestamp,prevValue:me(s.prevValue),nextValue:me(s.nextValue),hasValueChange:s.hasValueChange,changedKeys:s.changedKeys})),[J]),io=L(()=>P.map(s=>({id:s.id,atomLabel:s.atomLabel,timestamp:s.timestamp,prevValue:me(s.prevValue),nextValue:me(s.nextValue),hasValueChange:s.hasValueChange,changedKeys:s.changedKeys})),[P]),lo=L(s=>{ve(A=>{let ae=new Set(A);return ae.has(s)?ae.delete(s):ae.add(s),ae})},[]),so=L(s=>{ve(A=>new Set([...A,s]))},[]),co=L(s=>{W(s),ie(null),X(null),se(false),q&&($e(""),de(A=>({...A,searchText:""}))),Te(false)},[q,de]),tt=L(s=>s.id,[]),ot=Q(()=>zn(P),[P]),at=L(({item:s})=>m(Tt,{change:s,onPress:Xe,testID:ot.get(s.id)}),[Xe,ot]),nt=N.size>0,rt=()=>le?H(k,{children:[m(k.Navigation,{onBack:()=>se(false)}),m(k.Content,{title:"Filters",centered:true,testID:`${h}-filters-title`})]}):j?H(k,{children:[m(k.Navigation,{onBack:Xt}),m(k.Content,{title:`${j.atomLabel}/${j.category}`,centered:true,testID:`${h}-detail-title`})]}):z?H(k,{children:[m(k.Navigation,{onBack:to}),m(k.Content,{title:`${z} History`,centered:true,testID:`${h}-history-title`}),m(k.Actions,{children:m(He,{value:io,disabled:P.length===0,buttonStyle:$.headerActionButton,testID:`${h}-copy`})})]}):Z?H(k,{children:[m(k.Navigation,{onBack:ao}),m(k.Content,{title:Z,centered:true,testID:`${h}-atom-detail-title`})]}):H(k,{children:[o&&m(k.Navigation,{onBack:o}),m(k.Content,{title:"",children:Ut?m(k.Search,{value:q,onChangeText:qt,onCancel:Qt,placeholder:I==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${h}-search-field`,containerTestID:`${h}-search`,clearTestID:`${h}-search-clear`,onBlur:()=>{q.length===0&&Te(false)}}):m(_a,{tabs:[{key:"atoms",label:`Atoms${oe.length>0?` (${oe.length})`:""}`},{key:"events",label:`Events${J.length>0?` (${J.length})`:""}`}],activeTab:I,onTabChange:co,testIDPrefix:`${h}-tab`})}),H(k.Actions,{children:[m(re,{onPress:()=>Te(true),style:$.headerActionButton,testID:`${h}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:m(Ga,{size:14,color:E.color.textSecondary})}),m(re,{onPress:()=>se(true),style:[$.headerActionButton,nt&&$.headerActionButtonActive],testID:`${h}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:m(Ya,{size:14,color:nt?E.color.accent:E.color.textSecondary})}),I==="atoms"&&m(He,{value:no,disabled:oe.length===0,buttonStyle:$.headerActionButton,testID:`${h}-copy`}),I==="events"&&H(Ht,{children:[m(He,{value:ro,disabled:J.length===0,buttonStyle:$.headerActionButton,testID:`${h}-copy`}),m(Xa,{isEnabled:we,onToggle:Kt,accessibilityLabel:"Toggle Jotai atom capture",testID:`${h}-power`}),m(en,{onPress:Nt,disabled:J.length===0,buttonStyle:$.headerActionButton,testID:`${h}-clear`})]})]})]}),uo=()=>{if(le)return m(mr,{ignoredPatterns:N,onTogglePattern:lo,onAddPattern:so,atoms:ue});if(j&&ee!==null)return m(kt,{change:j,changes:P,selectedIndex:ee,onIndexChange:et,disableInternalFooter:true,initialView:d});if(z)return P.length>0?m(Pe,{testID:`${h}-history-list`,data:P,renderItem:at,keyExtractor:tt,contentContainerStyle:$.listContent,showsVerticalScrollIndicator:true,...Ct}):m(ze,{testID:`${h}-history-empty`,...bt({subject:"changes",search:q,total:q.trim()?Jt:0,capturing:we,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${z} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${z}.`}})});if(Z){let s=ue.find(A=>A.label===Z)??null;return s?m(zt,{atom:s,onViewHistory:eo}):m(ze,{testID:`${h}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${Z} is not in the registry any more.`})}return I==="atoms"?m(qn,{atoms:oe,searchQuery:q,onOpenAtom:oo}):H(Ht,{children:[!we&&H(u,{style:$.disabledBanner,testID:`${h}-banner-disabled`,children:[m(qa,{size:14,color:E.color.warning}),m(b,{style:$.disabledText,children:"Atom capture is disabled"})]}),_t&&H(re,{style:$.lockedBanner,onPress:Zt,activeOpacity:.8,testID:`${h}-locked`,accessibilityRole:"button",children:[H(b,{style:$.lockedText,testID:`${h}-locked-text`,children:[Ee," older"," ",Ee===1?"change":"changes"," locked"]}),m(u,{style:$.upgradeBadge,children:m(b,{style:$.upgradeBadgeText,children:"UPGRADE"})})]}),ke.length>0?m(Pe,{ref:Gt,testID:`${h}-list`,data:ke,renderItem:at,keyExtractor:tt,contentContainerStyle:$.listContent,showsVerticalScrollIndicator:true,...Ct}):m(fr,{isEnabled:we,searchText:q,totalChanges:Ce.totalChanges})]})},ho=a?Qa.modal.root():"buoy-jotai-modal";if(!e)return null;let it=j&&ee!==null?m(Et,{change:j,changes:P,selectedIndex:ee,onIndexChange:et}):null,go=j&&P.length>1?68:0,mo=!le&&!(j&&ee!==null)&&(z!=null||I==="events"||I==="atoms"),lt=m(u,{style:$.container,children:uo()}),st=m(Za,{visible:v,onClose:()=>S(false),featureName:"Full Atom History"});return n?H(vt,{children:[H(u,{style:$.inlineRoot,children:[m(u,{style:$.inlineHeader,...on,children:rt()}),lt,it]}),st]}):H(vt,{children:[m(Ja,{visible:e,onClose:t,onMinimize:r,persistenceKey:ho,header:{showToggleButton:true,customContent:rt()},onModeChange:Yt,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:mo,styles:{},footer:it,footerHeight:go,children:lt}),st]})}function pr(e={}){return m(_e,{...e,inline:true,visible:true,onClose:()=>{}})}var $=ne.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ua.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:E.color.buttonSurface,borderWidth:1,borderColor:E.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:E.color.accentSoft,borderColor:E.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:E.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:E.color.warning+"20"},disabledText:{color:E.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:E.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:E.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:E.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:E.color.accentBorder},lockedText:{color:E.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:E.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:E.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{JotaiIcon as Ue,JOTAI_ICON_COLOR as yr}from"@buoy-gg/shared-ui/web";import{createToolFactory as br,defineToolPreset as vr}from"@buoy-gg/shared-ui/web";import{jsx as Wt}from"react/jsx-runtime";var Mt=vr({id:"jotai",name:"JOTAI",description:"Jotai atom & state inspector",slot:"both",icon:({size:e})=>Wt(Ue,{size:e}),component:_e,props:{enableSharedModalDimensions:false}}),Cr=br(Mt,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}),e=>({icon:({size:t})=>Wt(Ue,{size:t,color:e.iconColor})}));import{getDefaultStore as wr}from"jotai/vanilla";import{atom as xr}from"jotai/vanilla";var Tr=xr(null),Ge=Tr.write,jt=typeof Ge=="function"?String(Ge):null;function Vr(e){let t=e,o=t?.write;return typeof o!="function"?"action":o===Ge||t!==null&&"init"in t&&jt!==null&&String(o)===jt?"value":"action"}function Ft(e,t,o){let r=o?.enabled!==false,a=[];for(let[n,l]of Object.entries(t)){let i=l,d=Symbol.for(`@@buoy-jotai/watched/${n}`);if(i[d])continue;i[d]=true;let f;try{f=e.get(l)}catch{f=void 0}let c=typeof l.write=="function",V=e.set&&c?v=>{e.set(l,v)}:void 0;y.registerAtom(n,()=>{try{return e.get(l)}catch{return}},V,c?Vr(l):void 0),r&&y.addAtomChange({atomLabel:n,prevValue:void 0,nextValue:f,category:"initial"});let w=e.sub(l,()=>{try{let v=e.get(l);y.addAtomChange({atomLabel:n,prevValue:f,nextValue:v,category:"write"}),f=v}catch{}});a.push(()=>{w(),delete i[d],y.unregisterAtom(n)})}return()=>a.forEach(n=>n())}function Sr(e,t){let o=wr();return Ft(o,e,t)}function Ar(e){return y.getAtom(e)!==void 0}import{WIRE_DETAIL_LIMIT_BYTES as Ir,createSyncAdapter as Dr,capDetail as Lr,detailByIdAction as kr,expandKeyedArrays as Er,memoByIdentity as Br,onDeviceMarker as $r,patchFromPath as Pr,readParams as Ye,readPath as Rr,refusalText as zr,shapeSummary as De,suggestedPatch as Hr,toWire as Wr,typedEditViolations as Mr,unshapedLists as jr}from"@buoy-gg/shared-ui/web";var Le=$r("Value","Atom values stay on the device \u2014 fetched on demand via getChangeDetail / getAtomValue."),qe=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Ot(e,t){if(!qe(e)||!qe(t))return t;let o={...e};for(let[r,a]of Object.entries(t))o[r]=r in e?Ot(e[r],a):a;return o}function Fr(e,t){let o=e;for(let r of t.split(".")){if(!qe(o)||!(r in o))return false;o=o[r]}return Array.isArray(o)?o.length>0:!!o&&typeof o=="object"}var Or=Br(e=>({...e,prevValue:Le,nextValue:Le})),Nr=e=>Wr(e,Le),Kr=Dr({version:2,getSnapshot:()=>({changes:y.getAtomChanges().map(Or),atoms:y.getAtomSnapshots().map(e=>({...e,currentValue:Nr(e.currentValue)}))}),subscribe:[e=>y.subscribe(e),e=>y.subscribeToAtoms(e)],actions:{clearEvents:()=>{y.clearAtomChanges()},getChangeDetail:kr(e=>y.getAtomChangeById(e),(e,t)=>({prevValue:t(e.prevValue),nextValue:t(e.nextValue)})),getAtomValue:e=>{let{label:t,path:o}=Ye(e);if(!t)return{found:false,reason:"missing label"};let r=y.getAtom(t);if(!r)return{found:false,reason:"unknown label"};let a;try{a=r.getValue()}catch{a=void 0}try{JSON.stringify(a)}catch{return{found:true,label:t,currentValue:Le}}if(o){let n=Rr(a,o);return n.ok?{found:true,label:t,path:o,shape:De(n.value),currentValue:n.value}:{found:false,reason:n.error}}return{found:true,label:t,...De(a)?{shape:De(a)}:{},currentValue:Lr(a,Ir)}},listAtoms:e=>{let{includeValues:t=false,limit:o}=Ye(e),r=y.getAtoms(),a=(typeof o=="number"&&o>0?r.slice(0,o):r).map(n=>{let l;if(t)try{l=n.getValue()}catch{l=void 0}let i;try{i=De(n.getValue())}catch{i=void 0}return{label:n.label,changes:n.changeCount,writable:typeof n.setValue=="function",...i?{shape:i}:{},...t?{currentValue:l}:{}}});return{atoms:a,total:r.length,returned:a.length,includedValues:t}},setAtom:e=>{let{label:t,value:o,merge:r,path:a,force:n}=Ye(e);if(!t)throw new Error("setAtom requires a `label`");let l=y.getAtom(t),i;try{i=l?.getValue()}catch{i=void 0}let d=o,f=[],c=[],V=r===true||a!==void 0;if(a!==void 0){if(o===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${a}" to.`};let w=Pr(i,a,o);if(!w.ok)return{ok:false,error:`Refused: ${w.error}`};d=w.patch}if(!n&&V&&i!==void 0){let w=Er(i,d);if(w.error)return{ok:false,error:`Refused: ${w.error}`};d=w.patch,f=w.notes,c=jr(i).filter(S=>Fr(d,S));let v=Mr(i,d,{noun:"atom"});if(v.length){let S=Hr(d,v);return{ok:false,error:zr(v,"atom",S),violations:v,...S?{suggestedValue:S}:{}}}}return y.setAtomValue(t,V?Ot(i,d):d),{ok:true,...a!==void 0?{path:a}:{},...f.length?{keyed:f}:{},...c.length?{unchecked:c.map(w=>`\`${w}\` was empty, so nothing knows what its items look like and the shape of what you added was NOT checked.`)}:{}}}}});export{yr as JOTAI_ICON_COLOR,Tt as JotaiAtomChangeItem,kt as JotaiAtomDetailContent,Et as JotaiAtomDetailFooter,zt as JotaiAtomValueDetailContent,Ue as JotaiIcon,_e as JotaiModal,pr as JotaiToolView,Cr as createJotaiTool,Ar as isAtomWatched,y as jotaiStateStore,Kr as jotaiSyncAdapter,Mt as jotaiToolPreset,xt as useJotaiAtomChanges,Ft as watchAtoms,Sr as watchDefaultStoreAtoms};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/jotai",
3
- "version": "7.0.63",
3
+ "version": "7.0.65",
4
4
  "description": "Inspect registered Jotai atoms, observed writes, retained history and current values in a React Native app.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -38,8 +38,8 @@
38
38
  "./lib/web/**/*.mjs"
39
39
  ],
40
40
  "dependencies": {
41
- "@buoy-gg/shared-ui": "^7.0.63",
42
- "@buoy-gg/license": "^7.0.63"
41
+ "@buoy-gg/shared-ui": "^7.0.65",
42
+ "@buoy-gg/license": "^7.0.65"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "jotai": ">=2.0.0",