From 2733a7c4f9e53bf193d0c41184aba7a36d8c6fee Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Thu, 23 Apr 2026 20:33:19 +0900 Subject: [PATCH] [#146] Move New Story button to top of sidebar with accent styling Repositioned + New Story from the bottom to directly below the Stories header. Styled as primary action with accent background and white text. Rebuilt frontend dist. Co-Authored-By: Claude Opus 4.6 (1M context) --- app/web/components/StoryBrowser.tsx | 24 +++++++++---------- .../{index-C2Vj4mnw.js => index-BvR_f6_r.js} | 2 +- app/web/dist/index.html | 2 +- package.json | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) rename app/web/dist/assets/{index-C2Vj4mnw.js => index-BvR_f6_r.js} (99%) diff --git a/app/web/components/StoryBrowser.tsx b/app/web/components/StoryBrowser.tsx index 666b7a9..ed283c8 100644 --- a/app/web/components/StoryBrowser.tsx +++ b/app/web/components/StoryBrowser.tsx @@ -117,6 +117,17 @@ export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectF Stories {stories.length} + {onNewStory && ( +
+ +
+ )}
{/* Untitled new story sessions */} {untitledSessions.map((id) => ( @@ -135,7 +146,7 @@ export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectF {stories.length === 0 && untitledSessions.length === 0 ? (

No stories yet.

-

Click "+ New Story" below to start writing.

+

Click "+ New Story" above to start writing.

) : ( stories.filter((s) => s.name !== "_example").map((story) => ( @@ -173,17 +184,6 @@ export function StoryBrowser({ authFetch, selectedStory, selectedFile, onSelectF )) )}
- {onNewStory && ( -
- -
- )} ); } diff --git a/app/web/dist/assets/index-C2Vj4mnw.js b/app/web/dist/assets/index-BvR_f6_r.js similarity index 99% rename from app/web/dist/assets/index-C2Vj4mnw.js rename to app/web/dist/assets/index-BvR_f6_r.js index ed3cd02..b0ae85d 100644 --- a/app/web/dist/assets/index-C2Vj4mnw.js +++ b/app/web/dist/assets/index-BvR_f6_r.js @@ -46,7 +46,7 @@ `+D[u].replace(" at new "," at ");return i.displayName&&Q.includes("")&&(Q=Q.replace("",i.displayName)),Q}while(1<=u&&0<=d);break}}}finally{$r=!1,Error.prepareStackTrace=l}return(l=i?i.displayName||i.name:"")?vi(l):""}function Ca(i,r){switch(i.tag){case 26:case 27:case 5:return vi(i.type);case 16:return vi("Lazy");case 13:return i.child!==r&&r!==null?vi("Suspense Fallback"):vi("Suspense");case 19:return vi("SuspenseList");case 0:case 15:return Gr(i.type,!1);case 11:return Gr(i.type.render,!1);case 1:return Gr(i.type,!0);case 31:return vi("Activity");default:return""}}function ka(i){try{var r="",l=null;do r+=Ca(i,l),l=i,i=i.return;while(i);return r}catch(u){return` Error generating stack: `+u.message+` `+u.stack}}var Zr=Object.prototype.hasOwnProperty,Qr=e.unstable_scheduleCallback,Zs=e.unstable_cancelCallback,Tu=e.unstable_shouldYield,Au=e.unstable_requestPaint,Qt=e.unstable_now,Du=e.unstable_getCurrentPriorityLevel,J=e.unstable_ImmediatePriority,he=e.unstable_UserBlockingPriority,Se=e.unstable_NormalPriority,Re=e.unstable_LowPriority,Fe=e.unstable_IdlePriority,yi=e.log,fn=e.unstable_setDisableYieldValue,Jt=null,xt=null;function ai(i){if(typeof yi=="function"&&fn(i),xt&&typeof xt.setStrictMode=="function")try{xt.setStrictMode(Jt,i)}catch{}}var Ge=Math.clz32?Math.clz32:t0,jn=Math.log,Ki=Math.LN2;function t0(i){return i>>>=0,i===0?32:31-(jn(i)/Ki|0)|0}var Ea=256,Ta=262144,Aa=4194304;function vr(i){var r=i&42;if(r!==0)return r;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Da(i,r,l){var u=i.pendingLanes;if(u===0)return 0;var d=0,m=i.suspendedLanes,v=i.pingedLanes;i=i.warmLanes;var w=u&134217727;return w!==0?(u=w&~m,u!==0?d=vr(u):(v&=w,v!==0?d=vr(v):l||(l=w&~i,l!==0&&(d=vr(l))))):(w=u&~m,w!==0?d=vr(w):v!==0?d=vr(v):l||(l=u&~i,l!==0&&(d=vr(l)))),d===0?0:r!==0&&r!==d&&(r&m)===0&&(m=d&-d,l=r&-r,m>=l||m===32&&(l&4194048)!==0)?r:d}function Qs(i,r){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&r)===0}function i0(i,r){switch(i){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Gd(){var i=Aa;return Aa<<=1,(Aa&62914560)===0&&(Aa=4194304),i}function Ru(i){for(var r=[],l=0;31>l;l++)r.push(i);return r}function Js(i,r){i.pendingLanes|=r,r!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function n0(i,r,l,u,d,m){var v=i.pendingLanes;i.pendingLanes=l,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=l,i.entangledLanes&=l,i.errorRecoveryDisabledLanes&=l,i.shellSuspendCounter=0;var w=i.entanglements,D=i.expirationTimes,I=i.hiddenUpdates;for(l=v&~l;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var u0=/[\n"\\]/g;function Li(i){return i.replace(u0,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Ou(i,r,l,u,d,m,v,w){i.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?i.type=v:i.removeAttribute("type"),r!=null?v==="number"?(r===0&&i.value===""||i.value!=r)&&(i.value=""+Bi(r)):i.value!==""+Bi(r)&&(i.value=""+Bi(r)):v!=="submit"&&v!=="reset"||i.removeAttribute("value"),r!=null?Hu(i,v,Bi(r)):l!=null?Hu(i,v,Bi(l)):u!=null&&i.removeAttribute("value"),d==null&&m!=null&&(i.defaultChecked=!!m),d!=null&&(i.checked=d&&typeof d!="function"&&typeof d!="symbol"),w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?i.name=""+Bi(w):i.removeAttribute("name")}function up(i,r,l,u,d,m,v,w){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(i.type=m),r!=null||l!=null){if(!(m!=="submit"&&m!=="reset"||r!=null)){Nu(i);return}l=l!=null?""+Bi(l):"",r=r!=null?""+Bi(r):l,w||r===i.value||(i.value=r),i.defaultValue=r}u=u??d,u=typeof u!="function"&&typeof u!="symbol"&&!!u,i.checked=w?i.checked:!!u,i.defaultChecked=!!u,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(i.name=v),Nu(i)}function Hu(i,r,l){r==="number"&&Ba(i.ownerDocument)===i||i.defaultValue===""+l||(i.defaultValue=""+l)}function rs(i,r,l,u){if(i=i.options,r){r={};for(var d=0;d"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Fu=!1;if(mn)try{var nl={};Object.defineProperty(nl,"passive",{get:function(){Fu=!0}}),window.addEventListener("test",nl,nl),window.removeEventListener("test",nl,nl)}catch{Fu=!1}var Pn=null,qu=null,za=null;function _p(){if(za)return za;var i,r=qu,l=r.length,u,d="value"in Pn?Pn.value:Pn.textContent,m=d.length;for(i=0;i=ll),xp=" ",wp=!1;function Cp(i,r){switch(i){case"keyup":return H0.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kp(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var os=!1;function U0(i,r){switch(i){case"compositionend":return kp(r);case"keypress":return r.which!==32?null:(wp=!0,xp);case"textInput":return i=r.data,i===xp&&wp?null:i;default:return null}}function P0(i,r){if(os)return i==="compositionend"||!Xu&&Cp(i,r)?(i=_p(),za=qu=Pn=null,os=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:l,offset:r-i};i=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Lp(l)}}function Np(i,r){return i&&r?i===r?!0:i&&i.nodeType===3?!1:r&&r.nodeType===3?Np(i,r.parentNode):"contains"in i?i.contains(r):i.compareDocumentPosition?!!(i.compareDocumentPosition(r)&16):!1:!1}function Op(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var r=Ba(i.document);r instanceof i.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)i=r.contentWindow;else break;r=Ba(i.document)}return r}function Zu(i){var r=i&&i.nodeName&&i.nodeName.toLowerCase();return r&&(r==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||r==="textarea"||i.contentEditable==="true")}var X0=mn&&"documentMode"in document&&11>=document.documentMode,us=null,Qu=null,cl=null,Ju=!1;function Hp(i,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ju||us==null||us!==Ba(u)||(u=us,"selectionStart"in u&&Zu(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),cl&&ul(cl,u)||(cl=u,u=Ao(Qu,"onSelect"),0>=v,d-=v,Ji=1<<32-Ge(r)+d|l<ke?(Ne=_e,_e=null):Ne=_e.sibling;var Pe=Y(N,_e,P[ke],ee);if(Pe===null){_e===null&&(_e=Ne);break}i&&_e&&Pe.alternate===null&&r(N,_e),B=m(Pe,B,ke),Ue===null?ge=Pe:Ue.sibling=Pe,Ue=Pe,_e=Ne}if(ke===P.length)return l(N,_e),Oe&&gn(N,ke),ge;if(_e===null){for(;keke?(Ne=_e,_e=null):Ne=_e.sibling;var or=Y(N,_e,Pe.value,ee);if(or===null){_e===null&&(_e=Ne);break}i&&_e&&or.alternate===null&&r(N,_e),B=m(or,B,ke),Ue===null?ge=or:Ue.sibling=or,Ue=or,_e=Ne}if(Pe.done)return l(N,_e),Oe&&gn(N,ke),ge;if(_e===null){for(;!Pe.done;ke++,Pe=P.next())Pe=ie(N,Pe.value,ee),Pe!==null&&(B=m(Pe,B,ke),Ue===null?ge=Pe:Ue.sibling=Pe,Ue=Pe);return Oe&&gn(N,ke),ge}for(_e=u(_e);!Pe.done;ke++,Pe=P.next())Pe=G(_e,N,ke,Pe.value,ee),Pe!==null&&(i&&Pe.alternate!==null&&_e.delete(Pe.key===null?ke:Pe.key),B=m(Pe,B,ke),Ue===null?ge=Pe:Ue.sibling=Pe,Ue=Pe);return i&&_e.forEach(function(px){return r(N,px)}),Oe&&gn(N,ke),ge}function Xe(N,B,P,ee){if(typeof P=="object"&&P!==null&&P.type===k&&P.key===null&&(P=P.props.children),typeof P=="object"&&P!==null){switch(P.$$typeof){case y:e:{for(var ge=P.key;B!==null;){if(B.key===ge){if(ge=P.type,ge===k){if(B.tag===7){l(N,B.sibling),ee=d(B,P.props.children),ee.return=N,N=ee;break e}}else if(B.elementType===ge||typeof ge=="object"&&ge!==null&&ge.$$typeof===Z&&Dr(ge)===B.type){l(N,B.sibling),ee=d(B,P.props),_l(ee,P),ee.return=N,N=ee;break e}l(N,B);break}else r(N,B);B=B.sibling}P.type===k?(ee=Cr(P.props.children,N.mode,ee,P.key),ee.return=N,N=ee):(ee=Wa(P.type,P.key,P.props,null,N.mode,ee),_l(ee,P),ee.return=N,N=ee)}return v(N);case b:e:{for(ge=P.key;B!==null;){if(B.key===ge)if(B.tag===4&&B.stateNode.containerInfo===P.containerInfo&&B.stateNode.implementation===P.implementation){l(N,B.sibling),ee=d(B,P.children||[]),ee.return=N,N=ee;break e}else{l(N,B);break}else r(N,B);B=B.sibling}ee=lc(P,N.mode,ee),ee.return=N,N=ee}return v(N);case Z:return P=Dr(P),Xe(N,B,P,ee)}if(H(P))return me(N,B,P,ee);if(U(P)){if(ge=U(P),typeof ge!="function")throw Error(s(150));return P=ge.call(P),ye(N,B,P,ee)}if(typeof P.then=="function")return Xe(N,B,Za(P),ee);if(P.$$typeof===j)return Xe(N,B,Ka(N,P),ee);Qa(N,P)}return typeof P=="string"&&P!==""||typeof P=="number"||typeof P=="bigint"?(P=""+P,B!==null&&B.tag===6?(l(N,B.sibling),ee=d(B,P),ee.return=N,N=ee):(l(N,B),ee=sc(P,N.mode,ee),ee.return=N,N=ee),v(N)):l(N,B)}return function(N,B,P,ee){try{ml=0;var ge=Xe(N,B,P,ee);return Ss=null,ge}catch(_e){if(_e===ys||_e===$a)throw _e;var Ue=bi(29,_e,null,N.mode);return Ue.lanes=ee,Ue.return=N,Ue}finally{}}}var Mr=lm(!0),am=lm(!1),Yn=!1;function vc(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yc(i,r){i=i.updateQueue,r.updateQueue===i&&(r.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function Vn(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function Kn(i,r,l){var u=i.updateQueue;if(u===null)return null;if(u=u.shared,(Ie&2)!==0){var d=u.pending;return d===null?r.next=r:(r.next=d.next,d.next=r),u.pending=r,r=qa(i),Wp(i,null,l),r}return Fa(i,u,r,l),qa(i)}function gl(i,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,Qd(i,l)}}function Sc(i,r){var l=i.updateQueue,u=i.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var d=null,m=null;if(l=l.firstBaseUpdate,l!==null){do{var v={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};m===null?d=m=v:m=m.next=v,l=l.next}while(l!==null);m===null?d=m=r:m=m.next=r}else d=m=r;l={baseState:u.baseState,firstBaseUpdate:d,lastBaseUpdate:m,shared:u.shared,callbacks:u.callbacks},i.updateQueue=l;return}i=l.lastBaseUpdate,i===null?l.firstBaseUpdate=r:i.next=r,l.lastBaseUpdate=r}var bc=!1;function vl(){if(bc){var i=vs;if(i!==null)throw i}}function yl(i,r,l,u){bc=!1;var d=i.updateQueue;Yn=!1;var m=d.firstBaseUpdate,v=d.lastBaseUpdate,w=d.shared.pending;if(w!==null){d.shared.pending=null;var D=w,I=D.next;D.next=null,v===null?m=I:v.next=I,v=D;var Q=i.alternate;Q!==null&&(Q=Q.updateQueue,w=Q.lastBaseUpdate,w!==v&&(w===null?Q.firstBaseUpdate=I:w.next=I,Q.lastBaseUpdate=D))}if(m!==null){var ie=d.baseState;v=0,Q=I=D=null,w=m;do{var Y=w.lane&-536870913,G=Y!==w.lane;if(G?(ze&Y)===Y:(u&Y)===Y){Y!==0&&Y===gs&&(bc=!0),Q!==null&&(Q=Q.next={lane:0,tag:w.tag,payload:w.payload,callback:null,next:null});e:{var me=i,ye=w;Y=r;var Xe=l;switch(ye.tag){case 1:if(me=ye.payload,typeof me=="function"){ie=me.call(Xe,ie,Y);break e}ie=me;break e;case 3:me.flags=me.flags&-65537|128;case 0:if(me=ye.payload,Y=typeof me=="function"?me.call(Xe,ie,Y):me,Y==null)break e;ie=_({},ie,Y);break e;case 2:Yn=!0}}Y=w.callback,Y!==null&&(i.flags|=64,G&&(i.flags|=8192),G=d.callbacks,G===null?d.callbacks=[Y]:G.push(Y))}else G={lane:Y,tag:w.tag,payload:w.payload,callback:w.callback,next:null},Q===null?(I=Q=G,D=ie):Q=Q.next=G,v|=Y;if(w=w.next,w===null){if(w=d.shared.pending,w===null)break;G=w,w=G.next,G.next=null,d.lastBaseUpdate=G,d.shared.pending=null}}while(!0);Q===null&&(D=ie),d.baseState=D,d.firstBaseUpdate=I,d.lastBaseUpdate=Q,m===null&&(d.shared.lanes=0),Qn|=v,i.lanes=v,i.memoizedState=ie}}function om(i,r){if(typeof i!="function")throw Error(s(191,i));i.call(r)}function um(i,r){var l=i.callbacks;if(l!==null)for(i.callbacks=null,i=0;im?m:8;var v=M.T,w={};M.T=w,Pc(i,!1,r,l);try{var D=d(),I=M.S;if(I!==null&&I(w,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var Q=n1(D,u);xl(i,r,Q,Ei(i))}else xl(i,r,u,Ei(i))}catch(ie){xl(i,r,{then:function(){},status:"rejected",reason:ie},Ei())}finally{q.p=m,v!==null&&w.types!==null&&(v.types=w.types),M.T=v}}function u1(){}function jc(i,r,l,u){if(i.tag!==5)throw Error(s(476));var d=Im(i).queue;Pm(i,d,r,W,l===null?u1:function(){return Fm(i),l(u)})}function Im(i){var r=i.memoizedState;if(r!==null)return r;r={memoizedState:W,baseState:W,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bn,lastRenderedState:W},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bn,lastRenderedState:l},next:null},i.memoizedState=r,i=i.alternate,i!==null&&(i.memoizedState=r),r}function Fm(i){var r=Im(i);r.next===null&&(r=i.alternate.memoizedState),xl(i,r.next.queue,{},Ei())}function Uc(){return Pt(Ul)}function qm(){return dt().memoizedState}function Wm(){return dt().memoizedState}function c1(i){for(var r=i.return;r!==null;){switch(r.tag){case 24:case 3:var l=Ei();i=Vn(l);var u=Kn(r,i,l);u!==null&&(pi(u,r,l),gl(u,r,l)),r={cache:pc()},i.payload=r;return}r=r.return}}function h1(i,r,l){var u=Ei();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},oo(i)?Vm(r,l):(l=nc(i,r,l,u),l!==null&&(pi(l,i,u),Km(l,r,u)))}function Ym(i,r,l){var u=Ei();xl(i,r,l,u)}function xl(i,r,l,u){var d={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(oo(i))Vm(r,d);else{var m=i.alternate;if(i.lanes===0&&(m===null||m.lanes===0)&&(m=r.lastRenderedReducer,m!==null))try{var v=r.lastRenderedState,w=m(v,l);if(d.hasEagerState=!0,d.eagerState=w,Si(w,v))return Fa(i,r,d,0),Ze===null&&Ia(),!1}catch{}finally{}if(l=nc(i,r,d,u),l!==null)return pi(l,i,u),Km(l,r,u),!0}return!1}function Pc(i,r,l,u){if(u={lane:2,revertLane:vh(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},oo(i)){if(r)throw Error(s(479))}else r=nc(i,l,u,2),r!==null&&pi(r,i,2)}function oo(i){var r=i.alternate;return i===Ce||r!==null&&r===Ce}function Vm(i,r){xs=to=!0;var l=i.pending;l===null?r.next=r:(r.next=l.next,l.next=r),i.pending=r}function Km(i,r,l){if((l&4194048)!==0){var u=r.lanes;u&=i.pendingLanes,l|=u,r.lanes=l,Qd(i,l)}}var wl={readContext:Pt,use:ro,useCallback:at,useContext:at,useEffect:at,useImperativeHandle:at,useLayoutEffect:at,useInsertionEffect:at,useMemo:at,useReducer:at,useRef:at,useState:at,useDebugValue:at,useDeferredValue:at,useTransition:at,useSyncExternalStore:at,useId:at,useHostTransitionStatus:at,useFormState:at,useActionState:at,useOptimistic:at,useMemoCache:at,useCacheRefresh:at};wl.useEffectEvent=at;var Xm={readContext:Pt,use:ro,useCallback:function(i,r){return ei().memoizedState=[i,r===void 0?null:r],i},useContext:Pt,useEffect:Mm,useImperativeHandle:function(i,r,l){l=l!=null?l.concat([i]):null,lo(4194308,4,Nm.bind(null,r,i),l)},useLayoutEffect:function(i,r){return lo(4194308,4,i,r)},useInsertionEffect:function(i,r){lo(4,2,i,r)},useMemo:function(i,r){var l=ei();r=r===void 0?null:r;var u=i();if(Br){ai(!0);try{i()}finally{ai(!1)}}return l.memoizedState=[u,r],u},useReducer:function(i,r,l){var u=ei();if(l!==void 0){var d=l(r);if(Br){ai(!0);try{l(r)}finally{ai(!1)}}}else d=r;return u.memoizedState=u.baseState=d,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:d},u.queue=i,i=i.dispatch=h1.bind(null,Ce,i),[u.memoizedState,i]},useRef:function(i){var r=ei();return i={current:i},r.memoizedState=i},useState:function(i){i=Lc(i);var r=i.queue,l=Ym.bind(null,Ce,r);return r.dispatch=l,[i.memoizedState,l]},useDebugValue:Oc,useDeferredValue:function(i,r){var l=ei();return Hc(l,i,r)},useTransition:function(){var i=Lc(!1);return i=Pm.bind(null,Ce,i.queue,!0,!1),ei().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,r,l){var u=Ce,d=ei();if(Oe){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Ze===null)throw Error(s(349));(ze&127)!==0||mm(u,r,l)}d.memoizedState=l;var m={value:l,getSnapshot:r};return d.queue=m,Mm(gm.bind(null,u,m,i),[i]),u.flags|=2048,Cs(9,{destroy:void 0},_m.bind(null,u,m,l,r),null),l},useId:function(){var i=ei(),r=Ze.identifierPrefix;if(Oe){var l=en,u=Ji;l=(u&~(1<<32-Ge(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=io++,0<\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof u.is=="string"?v.createElement("select",{is:u.is}):v.createElement("select"),u.multiple?m.multiple=!0:u.size&&(m.size=u.size);break;default:m=typeof u.is=="string"?v.createElement(d,{is:u.is}):v.createElement(d)}}m[jt]=r,m[oi]=u;e:for(v=r.child;v!==null;){if(v.tag===5||v.tag===6)m.appendChild(v.stateNode);else if(v.tag!==4&&v.tag!==27&&v.child!==null){v.child.return=v,v=v.child;continue}if(v===r)break e;for(;v.sibling===null;){if(v.return===null||v.return===r)break e;v=v.return}v.sibling.return=v.return,v=v.sibling}r.stateNode=m;e:switch(Ft(m,d,u),d){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&wn(r)}}return tt(r),eh(r,r.type,i===null?null:i.memoizedProps,r.pendingProps,l),null;case 6:if(i&&r.stateNode!=null)i.memoizedProps!==u&&wn(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(i=pe.current,ms(r)){if(i=r.stateNode,l=r.memoizedProps,u=null,d=Ut,d!==null)switch(d.tag){case 27:case 5:u=d.memoizedProps}i[jt]=r,i=!!(i.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||dg(i.nodeValue,l)),i||qn(r,!0)}else i=Do(i).createTextNode(u),i[jt]=r,r.stateNode=i}return tt(r),null;case 31:if(l=r.memoizedState,i===null||i.memoizedState!==null){if(u=ms(r),l!==null){if(i===null){if(!u)throw Error(s(318));if(i=r.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(s(557));i[jt]=r}else kr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;tt(r),i=!1}else l=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=l),i=!0;if(!i)return r.flags&256?(wi(r),r):(wi(r),null);if((r.flags&128)!==0)throw Error(s(558))}return tt(r),null;case 13:if(u=r.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(d=ms(r),u!==null&&u.dehydrated!==null){if(i===null){if(!d)throw Error(s(318));if(d=r.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(s(317));d[jt]=r}else kr(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;tt(r),d=!1}else d=cc(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=d),d=!0;if(!d)return r.flags&256?(wi(r),r):(wi(r),null)}return wi(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,i=i!==null&&i.memoizedState!==null,l&&(u=r.child,d=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(d=u.alternate.memoizedState.cachePool.pool),m=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(m=u.memoizedState.cachePool.pool),m!==d&&(u.flags|=2048)),l!==i&&l&&(r.child.flags|=8192),po(r,r.updateQueue),tt(r),null);case 4:return De(),i===null&&xh(r.stateNode.containerInfo),tt(r),null;case 10:return yn(r.type),tt(r),null;case 19:if(K(ft),u=r.memoizedState,u===null)return tt(r),null;if(d=(r.flags&128)!==0,m=u.rendering,m===null)if(d)kl(u,!1);else{if(ot!==0||i!==null&&(i.flags&128)!==0)for(i=r.child;i!==null;){if(m=eo(i),m!==null){for(r.flags|=128,kl(u,!1),i=m.updateQueue,r.updateQueue=i,po(r,i),r.subtreeFlags=0,i=l,l=r.child;l!==null;)Yp(l,i),l=l.sibling;return C(ft,ft.current&1|2),Oe&&gn(r,u.treeForkCount),r.child}i=i.sibling}u.tail!==null&&Qt()>yo&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304)}else{if(!d)if(i=eo(m),i!==null){if(r.flags|=128,d=!0,i=i.updateQueue,r.updateQueue=i,po(r,i),kl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!m.alternate&&!Oe)return tt(r),null}else 2*Qt()-u.renderingStartTime>yo&&l!==536870912&&(r.flags|=128,d=!0,kl(u,!1),r.lanes=4194304);u.isBackwards?(m.sibling=r.child,r.child=m):(i=u.last,i!==null?i.sibling=m:r.child=m,u.last=m)}return u.tail!==null?(i=u.tail,u.rendering=i,u.tail=i.sibling,u.renderingStartTime=Qt(),i.sibling=null,l=ft.current,C(ft,d?l&1|2:l&1),Oe&&gn(r,u.treeForkCount),i):(tt(r),null);case 22:case 23:return wi(r),wc(),u=r.memoizedState!==null,i!==null?i.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(tt(r),r.subtreeFlags&6&&(r.flags|=8192)):tt(r),l=r.updateQueue,l!==null&&po(r,l.retryQueue),l=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(l=i.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),i!==null&&K(Ar),null;case 24:return l=null,i!==null&&(l=i.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),yn(mt),tt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function _1(i,r){switch(oc(r),r.tag){case 1:return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 3:return yn(mt),De(),i=r.flags,(i&65536)!==0&&(i&128)===0?(r.flags=i&-65537|128,r):null;case 26:case 27:case 5:return Zt(r),null;case 31:if(r.memoizedState!==null){if(wi(r),r.alternate===null)throw Error(s(340));kr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 13:if(wi(r),i=r.memoizedState,i!==null&&i.dehydrated!==null){if(r.alternate===null)throw Error(s(340));kr()}return i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 19:return K(ft),null;case 4:return De(),null;case 10:return yn(r.type),null;case 22:case 23:return wi(r),wc(),i!==null&&K(Ar),i=r.flags,i&65536?(r.flags=i&-65537|128,r):null;case 24:return yn(mt),null;case 25:return null;default:return null}}function v_(i,r){switch(oc(r),r.tag){case 3:yn(mt),De();break;case 26:case 27:case 5:Zt(r);break;case 4:De();break;case 31:r.memoizedState!==null&&wi(r);break;case 13:wi(r);break;case 19:K(ft);break;case 10:yn(r.type);break;case 22:case 23:wi(r),wc(),i!==null&&K(Ar);break;case 24:yn(mt)}}function El(i,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var d=u.next;l=d;do{if((l.tag&i)===i){u=void 0;var m=l.create,v=l.inst;u=m(),v.destroy=u}l=l.next}while(l!==d)}}catch(w){We(r,r.return,w)}}function Gn(i,r,l){try{var u=r.updateQueue,d=u!==null?u.lastEffect:null;if(d!==null){var m=d.next;u=m;do{if((u.tag&i)===i){var v=u.inst,w=v.destroy;if(w!==void 0){v.destroy=void 0,d=r;var D=l,I=w;try{I()}catch(Q){We(d,D,Q)}}}u=u.next}while(u!==m)}}catch(Q){We(r,r.return,Q)}}function y_(i){var r=i.updateQueue;if(r!==null){var l=i.stateNode;try{um(r,l)}catch(u){We(i,i.return,u)}}}function S_(i,r,l){l.props=Lr(i.type,i.memoizedProps),l.state=i.memoizedState;try{l.componentWillUnmount()}catch(u){We(i,r,u)}}function Tl(i,r){try{var l=i.ref;if(l!==null){switch(i.tag){case 26:case 27:case 5:var u=i.stateNode;break;case 30:u=i.stateNode;break;default:u=i.stateNode}typeof l=="function"?i.refCleanup=l(u):l.current=u}}catch(d){We(i,r,d)}}function tn(i,r){var l=i.ref,u=i.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(d){We(i,r,d)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(d){We(i,r,d)}else l.current=null}function b_(i){var r=i.type,l=i.memoizedProps,u=i.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(d){We(i,i.return,d)}}function th(i,r,l){try{var u=i.stateNode;j1(u,i.type,l,r),u[oi]=r}catch(d){We(i,i.return,d)}}function x_(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&nr(i.type)||i.tag===4}function ih(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||x_(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&nr(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function nh(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(i,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(i),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=pn));else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode,r=null),i=i.child,i!==null))for(nh(i,r,l),i=i.sibling;i!==null;)nh(i,r,l),i=i.sibling}function mo(i,r,l){var u=i.tag;if(u===5||u===6)i=i.stateNode,r?l.insertBefore(i,r):l.appendChild(i);else if(u!==4&&(u===27&&nr(i.type)&&(l=i.stateNode),i=i.child,i!==null))for(mo(i,r,l),i=i.sibling;i!==null;)mo(i,r,l),i=i.sibling}function w_(i){var r=i.stateNode,l=i.memoizedProps;try{for(var u=i.type,d=r.attributes;d.length;)r.removeAttributeNode(d[0]);Ft(r,u,l),r[jt]=i,r[oi]=l}catch(m){We(i,i.return,m)}}var Cn=!1,vt=!1,rh=!1,C_=typeof WeakSet=="function"?WeakSet:Set,At=null;function g1(i,r){if(i=i.containerInfo,kh=Oo,i=Op(i),Zu(i)){if("selectionStart"in i)var l={start:i.selectionStart,end:i.selectionEnd};else e:{l=(l=i.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var d=u.anchorOffset,m=u.focusNode;u=u.focusOffset;try{l.nodeType,m.nodeType}catch{l=null;break e}var v=0,w=-1,D=-1,I=0,Q=0,ie=i,Y=null;t:for(;;){for(var G;ie!==l||d!==0&&ie.nodeType!==3||(w=v+d),ie!==m||u!==0&&ie.nodeType!==3||(D=v+u),ie.nodeType===3&&(v+=ie.nodeValue.length),(G=ie.firstChild)!==null;)Y=ie,ie=G;for(;;){if(ie===i)break t;if(Y===l&&++I===d&&(w=v),Y===m&&++Q===u&&(D=v),(G=ie.nextSibling)!==null)break;ie=Y,Y=ie.parentNode}ie=G}l=w===-1||D===-1?null:{start:w,end:D}}else l=null}l=l||{start:0,end:0}}else l=null;for(Eh={focusedElem:i,selectionRange:l},Oo=!1,At=r;At!==null;)if(r=At,i=r.child,(r.subtreeFlags&1028)!==0&&i!==null)i.return=r,At=i;else for(;At!==null;){switch(r=At,m=r.alternate,i=r.flags,r.tag){case 0:if((i&4)!==0&&(i=r.updateQueue,i=i!==null?i.events:null,i!==null))for(l=0;l title"))),Ft(m,u,l),m[jt]=i,Tt(m),u=m;break e;case"link":var v=Rg("link","href",d).get(u+(l.href||""));if(v){for(var w=0;wXe&&(v=Xe,Xe=ye,ye=v);var N=zp(w,ye),B=zp(w,Xe);if(N&&B&&(G.rangeCount!==1||G.anchorNode!==N.node||G.anchorOffset!==N.offset||G.focusNode!==B.node||G.focusOffset!==B.offset)){var P=ie.createRange();P.setStart(N.node,N.offset),G.removeAllRanges(),ye>Xe?(G.addRange(P),G.extend(B.node,B.offset)):(P.setEnd(B.node,B.offset),G.addRange(P))}}}}for(ie=[],G=w;G=G.parentNode;)G.nodeType===1&&ie.push({element:G,left:G.scrollLeft,top:G.scrollTop});for(typeof w.focus=="function"&&w.focus(),w=0;wl?32:l,M.T=null,l=hh,hh=null;var m=er,v=Dn;if(wt=0,Ds=er=null,Dn=0,(Ie&6)!==0)throw Error(s(331));var w=Ie;if(Ie|=4,N_(m.current),B_(m,m.current,v,l),Ie=w,Ll(0,!1),xt&&typeof xt.onPostCommitFiberRoot=="function")try{xt.onPostCommitFiberRoot(Jt,m)}catch{}return!0}finally{q.p=d,M.T=u,J_(i,r)}}function tg(i,r,l){r=Ni(l,r),r=Wc(i.stateNode,r,2),i=Kn(i,r,2),i!==null&&(Js(i,2),nn(i))}function We(i,r,l){if(i.tag===3)tg(i,i,l);else for(;r!==null;){if(r.tag===3){tg(r,i,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Jn===null||!Jn.has(u))){i=Ni(l,i),l=i_(2),u=Kn(r,l,2),u!==null&&(n_(l,u,r,i),Js(u,2),nn(u));break}}r=r.return}}function mh(i,r,l){var u=i.pingCache;if(u===null){u=i.pingCache=new S1;var d=new Set;u.set(r,d)}else d=u.get(r),d===void 0&&(d=new Set,u.set(r,d));d.has(l)||(ah=!0,d.add(l),i=k1.bind(null,i,r,l),r.then(i,i))}function k1(i,r,l){var u=i.pingCache;u!==null&&u.delete(r),i.pingedLanes|=i.suspendedLanes&l,i.warmLanes&=~l,Ze===i&&(ze&l)===l&&(ot===4||ot===3&&(ze&62914560)===ze&&300>Qt()-vo?(Ie&2)===0&&Rs(i,0):oh|=l,As===ze&&(As=0)),nn(i)}function ig(i,r){r===0&&(r=Gd()),i=wr(i,r),i!==null&&(Js(i,r),nn(i))}function E1(i){var r=i.memoizedState,l=0;r!==null&&(l=r.retryLane),ig(i,l)}function T1(i,r){var l=0;switch(i.tag){case 31:case 13:var u=i.stateNode,d=i.memoizedState;d!==null&&(l=d.retryLane);break;case 19:u=i.stateNode;break;case 22:u=i.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),ig(i,l)}function A1(i,r){return Qr(i,r)}var ko=null,Bs=null,_h=!1,Eo=!1,gh=!1,ir=0;function nn(i){i!==Bs&&i.next===null&&(Bs===null?ko=Bs=i:Bs=Bs.next=i),Eo=!0,_h||(_h=!0,R1())}function Ll(i,r){if(!gh&&Eo){gh=!0;do for(var l=!1,u=ko;u!==null;){if(i!==0){var d=u.pendingLanes;if(d===0)var m=0;else{var v=u.suspendedLanes,w=u.pingedLanes;m=(1<<31-Ge(42|i)+1)-1,m&=d&~(v&~w),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(l=!0,lg(u,m))}else m=ze,m=Da(u,u===Ze?m:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(m&3)===0||Qs(u,m)||(l=!0,lg(u,m));u=u.next}while(l);gh=!1}}function D1(){ng()}function ng(){Eo=_h=!1;var i=0;ir!==0&&P1()&&(i=ir);for(var r=Qt(),l=null,u=ko;u!==null;){var d=u.next,m=rg(u,r);m===0?(u.next=null,l===null?ko=d:l.next=d,d===null&&(Bs=l)):(l=u,(i!==0||(m&3)!==0)&&(Eo=!0)),u=d}wt!==0&&wt!==5||Ll(i),ir!==0&&(ir=0)}function rg(i,r){for(var l=i.suspendedLanes,u=i.pingedLanes,d=i.expirationTimes,m=i.pendingLanes&-62914561;0w)break;var Q=D.transferSize,ie=D.initiatorType;Q&&pg(ie)&&(D=D.responseEnd,v+=Q*(D"u"?null:document;function Eg(i,r,l){var u=Ls;if(u&&typeof r=="string"&&r){var d=Li(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),kg.has(d)||(kg.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function $1(i){Rn.D(i),Eg("dns-prefetch",i,null)}function G1(i,r){Rn.C(i,r),Eg("preconnect",i,r)}function Z1(i,r,l){Rn.L(i,r,l);var u=Ls;if(u&&i&&r){var d='link[rel="preload"][as="'+Li(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Li(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Li(l.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var m=d;switch(r){case"style":m=zs(i);break;case"script":m=Ns(i)}Ii.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Ii.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(Hl(m))||r==="script"&&u.querySelector(jl(m))||(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function Q1(i,r){Rn.m(i,r);var l=Ls;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Li(u)+'"][href="'+Li(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Ns(i)}if(!Ii.has(m)&&(i=_({rel:"modulepreload",href:i},r),Ii.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(jl(m)))return}u=l.createElement("link"),Ft(u,"link",i),Tt(u),l.head.appendChild(u)}}}function J1(i,r,l){Rn.S(i,r,l);var u=Ls;if(u&&i){var d=is(u).hoistableStyles,m=zs(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(Hl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Ii.get(m))&&Lh(i,l);var D=v=u.createElement("link");Tt(D),Ft(D,"link",i),D._p=new Promise(function(I,Q){D.onload=I,D.onerror=Q}),D.addEventListener("load",function(){w.loading|=1}),D.addEventListener("error",function(){w.loading|=2}),w.loading|=4,Mo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function ex(i,r){Rn.X(i,r);var l=Ls;if(l&&i){var u=is(l).hoistableScripts,d=Ns(i),m=u.get(d);m||(m=l.querySelector(jl(d)),m||(i=_({src:i,async:!0},r),(r=Ii.get(d))&&zh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function tx(i,r){Rn.M(i,r);var l=Ls;if(l&&i){var u=is(l).hoistableScripts,d=Ns(i),m=u.get(d);m||(m=l.querySelector(jl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Ii.get(d))&&zh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Tg(i,r,l,u){var d=(d=pe.current)?Ro(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=zs(l.href),l=is(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=zs(l.href);var m=is(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(Hl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Ii.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ii.set(i,l),m||ix(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Ns(l),l=is(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function zs(i){return'href="'+Li(i)+'"'}function Hl(i){return'link[rel="stylesheet"]['+i+"]"}function Ag(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function ix(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Ft(r,"link",l),Tt(r),i.head.appendChild(r))}function Ns(i){return'[src="'+Li(i)+'"]'}function jl(i){return"script[async]"+i}function Dg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Li(l.href)+'"]');if(u)return r.instance=u,Tt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Tt(u),Ft(u,"style",d),Mo(u,l.precedence,i),r.instance=u;case"stylesheet":d=zs(l.href);var m=i.querySelector(Hl(d));if(m)return r.state.loading|=4,r.instance=m,Tt(m),m;u=Ag(l),(d=Ii.get(d))&&Lh(u,d),m=(i.ownerDocument||i).createElement("link"),Tt(m);var v=m;return v._p=new Promise(function(w,D){v.onload=w,v.onerror=D}),Ft(m,"link",u),r.state.loading|=4,Mo(m,l.precedence,i),r.instance=m;case"script":return m=Ns(l.src),(d=i.querySelector(jl(m)))?(r.instance=d,Tt(d),d):(u=l,(d=Ii.get(m))&&(u=_({},l),zh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Tt(d),Ft(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,Mo(u,l.precedence,i));return r.instance}function Mo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function nx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Bg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function rx(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=zs(u.href),m=r.querySelector(Hl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Lo.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Tt(m);return}m=r.ownerDocument||r,u=Ag(u),(d=Ii.get(d))&&Lh(u,d),m=m.createElement("link"),Tt(m);var v=m;v._p=new Promise(function(w,D){v.onload=w,v.onerror=D}),Ft(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Lo.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var Nh=0;function sx(i,r){return i.stylesheets&&i.count===0&&No(i,i.stylesheets),0Nh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Lo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)No(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var zo=null;function No(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,zo=new Map,r.forEach(lx,i),zo=null,Lo.call(i))}function lx(i,r){if(!(r.state.loading&4)){var l=zo.get(i);if(l)var u=l.get(null);else{l=new Map,zo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wh.exports=wx(),Wh.exports}var kx=Cx();const Ex=gu(kx);function Tx({onLogin:e}){const[t,n]=ae.useState(""),[s,a]=ae.useState(null),[o,c]=ae.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return x.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:x.jsxs("div",{className:"w-full max-w-sm",children:[x.jsxs("div",{className:"border-border rounded border p-6",children:[x.jsxs("div",{className:"mb-6 text-center",children:[x.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),x.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),x.jsxs("form",{onSubmit:f,className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),x.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&x.jsx("p",{className:"text-error text-xs",children:s}),x.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),x.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Ax({onSetup:e}){const[t,n]=ae.useState(""),[s,a]=ae.useState(""),[o,c]=ae.useState(null),[f,p]=ae.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return x.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:x.jsx("div",{className:"w-full max-w-sm",children:x.jsxs("div",{className:"border-border rounded border p-6",children:[x.jsxs("div",{className:"mb-6 text-center",children:[x.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),x.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),x.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),x.jsxs("form",{onSubmit:h,className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),x.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),x.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&x.jsx("p",{className:"text-error text-xs",children:o}),x.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const iv="http://localhost:7777";function Gy({token:e}){const[t,n]=ae.useState(null),[s,a]=ae.useState(!1),[o,c]=ae.useState(!1),[f,p]=ae.useState(null),h=(b,k)=>fetch(b,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${iv}/api/wallet`).then(b=>b.json()).then(b=>n(b)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};ae.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const b=await h(`${iv}/api/wallet/create`,{method:"POST"}),k=await b.json();if(!b.ok)throw new Error(k.error||"Creation failed");g()}catch(b){p(b instanceof Error?b.message:"Failed to create wallet")}a(!1)},S=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=b=>`${b.slice(0,6)}...${b.slice(-4)}`;return x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&x.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&x.jsxs("div",{className:"space-y-3",children:[x.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&x.jsx("p",{className:"text-error text-xs",children:f}),x.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),x.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),x.jsx("button",{onClick:S,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),x.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"ETH"}),x.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"USDC"}),x.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"PLOT"}),x.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Network"}),x.jsx("span",{className:"text-foreground",children:"Base"})]})]}),x.jsxs("div",{className:"border-border border-t pt-3",children:[x.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),x.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),x.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Dx({token:e,onLogout:t}){const[n,s]=ae.useState(""),[a,o]=ae.useState(""),[c,f]=ae.useState(null),[p,h]=ae.useState(!1),[g,_]=ae.useState(!1),[S,y]=ae.useState(null),[b,k]=ae.useState("AI Writer"),[R,T]=ae.useState(""),[$,j]=ae.useState(""),[O,X]=ae.useState(!1),[L,re]=ae.useState(null),[Z,le]=ae.useState(""),[z,te]=ae.useState(null),[U,F]=ae.useState(!1),[V,H]=ae.useState(null),[M,q]=ae.useState(null),W=ae.useCallback((C,se)=>fetch(C,{...se,headers:{...se==null?void 0:se.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);ae.useEffect(()=>{W("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const ue=async()=>{if(!b.trim()){re("Agent name is required");return}if(!R.trim()){re("Description is required");return}X(!0),re(null);try{const C=await W("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:b,description:R,...$.trim()&&{genre:$}})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Registration failed");y({linked:!0,agentId:se.agentId,owsWallet:se.owsWallet})}catch(C){re(C instanceof Error?C.message:"Registration failed")}X(!1)},E=async()=>{if(!Z.trim()||!/^0x[a-fA-F0-9]{40}$/.test(Z)){H("Enter a valid wallet address (0x...)");return}F(!0),H(null),te(null);try{const C=await W("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:Z})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Failed to generate binding code");te(se)}catch(C){H(C instanceof Error?C.message:"Failed to generate binding code")}F(!1)},A=async(C,se)=>{await navigator.clipboard.writeText(C),q(se),setTimeout(()=>q(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await W("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const se=await C.json();throw new Error(se.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return x.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[x.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),S!=null&&S.linked?x.jsxs("div",{className:"space-y-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),x.jsxs("span",{className:"text-muted text-xs",children:["Agent #",S.agentId]})]}),S.owsWallet&&x.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",S.owsWallet.slice(0,6),"...",S.owsWallet.slice(-4)]}),S.owner&&x.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",S.owner.slice(0,6),"...",S.owner.slice(-4)]}),x.jsx("p",{className:"text-muted text-xs",children:x.jsx("a",{href:`https://plotlink.xyz/agents/${S.agentId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):x.jsxs("div",{className:"space-y-3",children:[x.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),x.jsx("input",{value:b,onChange:C=>k(C.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),x.jsx("input",{value:R,onChange:C=>T(C.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),x.jsx("input",{value:$,onChange:C=>j(C.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),L&&x.jsx("p",{className:"text-error text-xs",children:L}),x.jsx("button",{onClick:ue,disabled:O||!b.trim()||!R.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:O?"Registering...":"Register Agent Identity"})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),S!=null&&S.owner?x.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",x.jsxs("span",{className:"font-mono",children:[S.owner.slice(0,6),"...",S.owner.slice(-4)]})]}):x.jsxs("div",{className:"space-y-3",children:[x.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),x.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[x.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),x.jsx("p",{children:'2. Click "Generate Binding Code"'}),x.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),x.jsx("input",{value:Z,onChange:C=>le(C.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),V&&x.jsx("p",{className:"text-error text-xs",children:V}),x.jsx("button",{onClick:E,disabled:U||!Z.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:U?"Generating...":"Generate Binding Code"}),z&&x.jsxs("div",{className:"space-y-3 mt-3",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),x.jsxs("div",{className:"relative",children:[x.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.signature}),x.jsx("button",{onClick:()=>A(z.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:M==="signature"?"Copied!":"Copy"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),x.jsxs("div",{className:"relative",children:[x.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.owsWallet}),x.jsx("button",{onClick:()=>A(z.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:M==="wallet"?"Copied!":"Copy"})]})]}),x.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste both values in the "Link AI Writer" section.'})]})]})]}),x.jsx(Gy,{token:e}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),x.jsxs("div",{className:"space-y-3",children:[x.jsx("input",{type:"password",value:n,onChange:C=>s(C.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),x.jsx("input",{type:"password",value:a,onChange:C=>o(C.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&x.jsx("p",{className:"text-error text-xs",children:c}),p&&x.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),x.jsx("button",{onClick:K,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),x.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Rx="http://localhost:7777";function Mx({token:e}){const[t,n]=ae.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Rx}/api/dashboard`).then(f=>f.json()).then(n)};ae.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?x.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[x.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),x.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Address"}),x.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"ETH Balance"}),x.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"USDC Balance"}),x.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),x.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Royalties earned"}),x.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),x.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),x.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[x.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),x.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Stories published"}),x.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?x.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):x.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>x.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[x.jsxs("div",{className:"flex items-start justify-between",children:[x.jsxs("div",{children:[f.genre&&x.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),x.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),x.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&x.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),x.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),x.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),x.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),x.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),x.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),x.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>x.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),x.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&x.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),x.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[x.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&x.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&x.jsx("div",{className:"border-border rounded border p-4",children:x.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):x.jsx("div",{className:"flex h-full items-center justify-center",children:x.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const Bx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Lx={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function zx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=ae.useState([]),[p,h]=ae.useState(new Set),g=ae.useCallback(async()=>{try{const k=await e("/api/stories");if(k.ok){const R=await k.json();f(R.stories)}}catch{}},[e]);ae.useEffect(()=>{g();const k=setInterval(g,5e3);return()=>clearInterval(k)},[g]),ae.useEffect(()=>{t&&h(k=>new Set(k).add(t))},[t]);const _=k=>{var T;const R=k.map($=>{var j;return{file:$.file,num:(j=$.file.match(/^plot-(\d+)\.md$/))==null?void 0:j[1]}}).filter($=>$.num!=null).sort(($,j)=>parseInt(j.num)-parseInt($.num));return R.length>0?R[0].file:k.some($=>$.file==="genesis.md")?"genesis.md":k.some($=>$.file==="structure.md")?"structure.md":((T=k[0])==null?void 0:T.file)??null},S=k=>{h(R=>{const T=new Set(R);return T.has(k)?T.delete(k):T.add(k),T})},y=k=>{if(S(k.name),!p.has(k.name)){const R=_(k.files);R&&s(k.name,R)}},b=k=>{const R=T=>{if(T==="structure.md")return 0;if(T==="genesis.md")return 1;const $=T.match(/^plot-(\d+)\.md$/);return $?2+parseInt($[1]):100};return[...k].sort((T,$)=>R(T.file)-R($.file))};return x.jsxs("div",{className:"h-full flex flex-col",children:[x.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[x.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),x.jsx("span",{className:"text-xs text-muted",children:c.length})]}),x.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(k=>x.jsx("div",{children:x.jsxs("button",{onClick:()=>s(k,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===k?"bg-surface":""}`,children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),x.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},k)),c.length===0&&o.length===0?x.jsxs("div",{className:"p-3 text-sm text-muted",children:[x.jsx("p",{children:"No stories yet."}),x.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" below to start writing.'})]}):c.filter(k=>k.name!=="_example").map(k=>x.jsxs("div",{children:[x.jsxs("button",{onClick:()=>y(k),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[x.jsx("span",{className:"text-xs text-muted",children:p.has(k.name)?"▼":"▶"}),x.jsx("span",{className:"font-medium truncate",title:k.name,children:k.title||k.name}),x.jsxs("span",{className:"ml-auto text-xs text-muted",children:[k.publishedCount,"/",k.files.length]})]}),p.has(k.name)&&x.jsx("div",{className:"pl-4",children:b(k.files).map(R=>{const T=t===k.name&&n===R.file;return x.jsxs("button",{onClick:()=>s(k.name,R.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${T?"bg-surface font-medium":""}`,children:[x.jsx("span",{className:Lx[R.status],children:Bx[R.status]}),x.jsx("span",{className:"truncate font-mono",children:R.file})]},R.file)})})]},k.name))]}),a&&x.jsx("div",{className:"px-3 py-2 border-t border-border",children:x.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm text-accent hover:bg-surface rounded flex items-center gap-1.5",children:[x.jsx("span",{children:"+"}),x.jsx("span",{children:"New Story"})]})})]})}/** +`).replace(H1,"")}function dg(i,r){return r=fg(r),fg(i)===r}function Ke(i,r,l,u,d,m){switch(l){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||ss(i,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&ss(i,""+u);break;case"className":Ma(i,"class",u);break;case"tabIndex":Ma(i,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Ma(i,l,u);break;case"style":dp(i,u,m);break;case"data":if(r!=="object"){Ma(i,"data",u);break}case"src":case"href":if(u===""&&(r!=="a"||l!=="href")){i.removeAttribute(l);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){i.removeAttribute(l);break}u=La(""+u),i.setAttribute(l,u);break;case"action":case"formAction":if(typeof u=="function"){i.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof m=="function"&&(l==="formAction"?(r!=="input"&&Ke(i,r,"name",d.name,d,null),Ke(i,r,"formEncType",d.formEncType,d,null),Ke(i,r,"formMethod",d.formMethod,d,null),Ke(i,r,"formTarget",d.formTarget,d,null)):(Ke(i,r,"encType",d.encType,d,null),Ke(i,r,"method",d.method,d,null),Ke(i,r,"target",d.target,d,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){i.removeAttribute(l);break}u=La(""+u),i.setAttribute(l,u);break;case"onClick":u!=null&&(i.onclick=pn);break;case"onScroll":u!=null&&Be("scroll",i);break;case"onScrollEnd":u!=null&&Be("scrollend",i);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(d.children!=null)throw Error(s(60));i.innerHTML=l}}break;case"multiple":i.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":i.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){i.removeAttribute("xlink:href");break}l=La(""+u),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?i.setAttribute(l,""+u):i.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?i.setAttribute(l,""):i.removeAttribute(l);break;case"capture":case"download":u===!0?i.setAttribute(l,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?i.setAttribute(l,u):i.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?i.setAttribute(l,u):i.removeAttribute(l);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?i.removeAttribute(l):i.setAttribute(l,u);break;case"popover":Be("beforetoggle",i),Be("toggle",i),Ra(i,"popover",u);break;case"xlinkActuate":dn(i,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":dn(i,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":dn(i,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":dn(i,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":dn(i,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":dn(i,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":dn(i,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":dn(i,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":dn(i,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Ra(i,"is",u);break;case"innerText":case"textContent":break;default:(!(2w)break;var Q=D.transferSize,ie=D.initiatorType;Q&&pg(ie)&&(D=D.responseEnd,v+=Q*(D"u"?null:document;function Eg(i,r,l){var u=Ls;if(u&&typeof r=="string"&&r){var d=Li(r);d='link[rel="'+i+'"][href="'+d+'"]',typeof l=="string"&&(d+='[crossorigin="'+l+'"]'),kg.has(d)||(kg.add(d),i={rel:i,crossOrigin:l,href:r},u.querySelector(d)===null&&(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function $1(i){Rn.D(i),Eg("dns-prefetch",i,null)}function G1(i,r){Rn.C(i,r),Eg("preconnect",i,r)}function Z1(i,r,l){Rn.L(i,r,l);var u=Ls;if(u&&i&&r){var d='link[rel="preload"][as="'+Li(r)+'"]';r==="image"&&l&&l.imageSrcSet?(d+='[imagesrcset="'+Li(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(d+='[imagesizes="'+Li(l.imageSizes)+'"]')):d+='[href="'+Li(i)+'"]';var m=d;switch(r){case"style":m=zs(i);break;case"script":m=Ns(i)}Ii.has(m)||(i=_({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:i,as:r},l),Ii.set(m,i),u.querySelector(d)!==null||r==="style"&&u.querySelector(Hl(m))||r==="script"&&u.querySelector(jl(m))||(r=u.createElement("link"),Ft(r,"link",i),Tt(r),u.head.appendChild(r)))}}function Q1(i,r){Rn.m(i,r);var l=Ls;if(l&&i){var u=r&&typeof r.as=="string"?r.as:"script",d='link[rel="modulepreload"][as="'+Li(u)+'"][href="'+Li(i)+'"]',m=d;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Ns(i)}if(!Ii.has(m)&&(i=_({rel:"modulepreload",href:i},r),Ii.set(m,i),l.querySelector(d)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(jl(m)))return}u=l.createElement("link"),Ft(u,"link",i),Tt(u),l.head.appendChild(u)}}}function J1(i,r,l){Rn.S(i,r,l);var u=Ls;if(u&&i){var d=is(u).hoistableStyles,m=zs(i);r=r||"default";var v=d.get(m);if(!v){var w={loading:0,preload:null};if(v=u.querySelector(Hl(m)))w.loading=5;else{i=_({rel:"stylesheet",href:i,"data-precedence":r},l),(l=Ii.get(m))&&Lh(i,l);var D=v=u.createElement("link");Tt(D),Ft(D,"link",i),D._p=new Promise(function(I,Q){D.onload=I,D.onerror=Q}),D.addEventListener("load",function(){w.loading|=1}),D.addEventListener("error",function(){w.loading|=2}),w.loading|=4,Mo(v,r,u)}v={type:"stylesheet",instance:v,count:1,state:w},d.set(m,v)}}}function ex(i,r){Rn.X(i,r);var l=Ls;if(l&&i){var u=is(l).hoistableScripts,d=Ns(i),m=u.get(d);m||(m=l.querySelector(jl(d)),m||(i=_({src:i,async:!0},r),(r=Ii.get(d))&&zh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function tx(i,r){Rn.M(i,r);var l=Ls;if(l&&i){var u=is(l).hoistableScripts,d=Ns(i),m=u.get(d);m||(m=l.querySelector(jl(d)),m||(i=_({src:i,async:!0,type:"module"},r),(r=Ii.get(d))&&zh(i,r),m=l.createElement("script"),Tt(m),Ft(m,"link",i),l.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},u.set(d,m))}}function Tg(i,r,l,u){var d=(d=pe.current)?Ro(d):null;if(!d)throw Error(s(446));switch(i){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=zs(l.href),l=is(d).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){i=zs(l.href);var m=is(d).hoistableStyles,v=m.get(i);if(v||(d=d.ownerDocument||d,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(i,v),(m=d.querySelector(Hl(i)))&&!m._p&&(v.instance=m,v.state.loading=5),Ii.has(i)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ii.set(i,l),m||ix(d,i,l,v.state))),r&&u===null)throw Error(s(528,""));return v}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Ns(l),l=is(d).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,i))}}function zs(i){return'href="'+Li(i)+'"'}function Hl(i){return'link[rel="stylesheet"]['+i+"]"}function Ag(i){return _({},i,{"data-precedence":i.precedence,precedence:null})}function ix(i,r,l,u){i.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=i.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Ft(r,"link",l),Tt(r),i.head.appendChild(r))}function Ns(i){return'[src="'+Li(i)+'"]'}function jl(i){return"script[async]"+i}function Dg(i,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=i.querySelector('style[data-href~="'+Li(l.href)+'"]');if(u)return r.instance=u,Tt(u),u;var d=_({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(i.ownerDocument||i).createElement("style"),Tt(u),Ft(u,"style",d),Mo(u,l.precedence,i),r.instance=u;case"stylesheet":d=zs(l.href);var m=i.querySelector(Hl(d));if(m)return r.state.loading|=4,r.instance=m,Tt(m),m;u=Ag(l),(d=Ii.get(d))&&Lh(u,d),m=(i.ownerDocument||i).createElement("link"),Tt(m);var v=m;return v._p=new Promise(function(w,D){v.onload=w,v.onerror=D}),Ft(m,"link",u),r.state.loading|=4,Mo(m,l.precedence,i),r.instance=m;case"script":return m=Ns(l.src),(d=i.querySelector(jl(m)))?(r.instance=d,Tt(d),d):(u=l,(d=Ii.get(m))&&(u=_({},l),zh(u,d)),i=i.ownerDocument||i,d=i.createElement("script"),Tt(d),Ft(d,"link",u),i.head.appendChild(d),r.instance=d);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,Mo(u,l.precedence,i));return r.instance}function Mo(i,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=u.length?u[u.length-1]:null,m=d,v=0;v title"):null)}function nx(i,r,l){if(l===1||r.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return i=r.disabled,typeof r.precedence=="string"&&i==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function Bg(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function rx(i,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var d=zs(u.href),m=r.querySelector(Hl(d));if(m){r=m._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(i.count++,i=Lo.bind(i),r.then(i,i)),l.state.loading|=4,l.instance=m,Tt(m);return}m=r.ownerDocument||r,u=Ag(u),(d=Ii.get(d))&&Lh(u,d),m=m.createElement("link"),Tt(m);var v=m;v._p=new Promise(function(w,D){v.onload=w,v.onerror=D}),Ft(m,"link",u),l.instance=m}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(i.count++,l=Lo.bind(i),r.addEventListener("load",l),r.addEventListener("error",l))}}var Nh=0;function sx(i,r){return i.stylesheets&&i.count===0&&No(i,i.stylesheets),0Nh?50:800)+r);return i.unsuspend=l,function(){i.unsuspend=null,clearTimeout(u),clearTimeout(d)}}:null}function Lo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)No(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var zo=null;function No(i,r){i.stylesheets=null,i.unsuspend!==null&&(i.count++,zo=new Map,r.forEach(lx,i),zo=null,Lo.call(i))}function lx(i,r){if(!(r.state.loading&4)){var l=zo.get(i);if(l)var u=l.get(null);else{l=new Map,zo.set(i,l);for(var d=i.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Wh.exports=wx(),Wh.exports}var kx=Cx();const Ex=gu(kx);function Tx({onLogin:e}){const[t,n]=ae.useState(""),[s,a]=ae.useState(null),[o,c]=ae.useState(!1),f=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const h=await e(t);h&&a(h),c(!1)};return x.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:x.jsxs("div",{className:"w-full max-w-sm",children:[x.jsxs("div",{className:"border-border rounded border p-6",children:[x.jsxs("div",{className:"mb-6 text-center",children:[x.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),x.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),x.jsxs("form",{onSubmit:f,className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),x.jsx("input",{type:"password",value:t,onChange:p=>n(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&x.jsx("p",{className:"text-error text-xs",children:s}),x.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),x.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function Ax({onSetup:e}){const[t,n]=ae.useState(""),[s,a]=ae.useState(""),[o,c]=ae.useState(null),[f,p]=ae.useState(!1),h=async g=>{if(g.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const _=await e(t);_&&c(_),p(!1)};return x.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:x.jsx("div",{className:"w-full max-w-sm",children:x.jsxs("div",{className:"border-border rounded border p-6",children:[x.jsxs("div",{className:"mb-6 text-center",children:[x.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),x.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),x.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),x.jsxs("form",{onSubmit:h,className:"space-y-4",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),x.jsx("input",{type:"password",value:t,onChange:g=>n(g.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),x.jsx("input",{type:"password",value:s,onChange:g=>a(g.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&x.jsx("p",{className:"text-error text-xs",children:o}),x.jsx("button",{type:"submit",disabled:f||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:f?"setting up...":"create passphrase"})]})]})})})}const iv="http://localhost:7777";function Gy({token:e}){const[t,n]=ae.useState(null),[s,a]=ae.useState(!1),[o,c]=ae.useState(!1),[f,p]=ae.useState(null),h=(b,k)=>fetch(b,{...k,headers:{...k==null?void 0:k.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),g=()=>{h(`${iv}/api/wallet`).then(b=>b.json()).then(b=>n(b)).catch(()=>n({exists:!1,error:"Failed to load wallet"}))};ae.useEffect(()=>{g()},[]);const _=async()=>{a(!0),p(null);try{const b=await h(`${iv}/api/wallet/create`,{method:"POST"}),k=await b.json();if(!b.ok)throw new Error(k.error||"Creation failed");g()}catch(b){p(b instanceof Error?b.message:"Failed to create wallet")}a(!1)},S=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),c(!0),setTimeout(()=>c(!1),2e3))},y=b=>`${b.slice(0,6)}...${b.slice(-4)}`;return x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&x.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&x.jsxs("div",{className:"space-y-3",children:[x.jsx("p",{className:"text-muted text-xs",children:"No wallet created yet. Create one to enable autonomous transactions."}),f&&x.jsx("p",{className:"text-error text-xs",children:f}),x.jsx("button",{onClick:_,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),t&&t.exists&&t.address&&x.jsxs("div",{className:"space-y-3",children:[x.jsxs("div",{className:"flex items-center justify-between",children:[x.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Address (Base)"}),x.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:y(t.address)}),x.jsx("button",{onClick:S,className:"text-muted hover:text-accent text-xs transition-colors",children:o?"copied":"copy"})]}),x.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"ETH"}),x.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"USDC"}),x.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"PLOT"}),x.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Network"}),x.jsx("span",{className:"text-foreground",children:"Base"})]})]}),x.jsxs("div",{className:"border-border border-t pt-3",children:[x.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),x.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),x.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]})]})}function Dx({token:e,onLogout:t}){const[n,s]=ae.useState(""),[a,o]=ae.useState(""),[c,f]=ae.useState(null),[p,h]=ae.useState(!1),[g,_]=ae.useState(!1),[S,y]=ae.useState(null),[b,k]=ae.useState("AI Writer"),[R,T]=ae.useState(""),[$,j]=ae.useState(""),[O,X]=ae.useState(!1),[L,re]=ae.useState(null),[Z,le]=ae.useState(""),[z,te]=ae.useState(null),[U,F]=ae.useState(!1),[V,H]=ae.useState(null),[M,q]=ae.useState(null),W=ae.useCallback((C,se)=>fetch(C,{...se,headers:{...se==null?void 0:se.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);ae.useEffect(()=>{W("/api/settings/link-status").then(C=>C.json()).then(C=>y(C)).catch(()=>y({linked:!1}))},[]);const ue=async()=>{if(!b.trim()){re("Agent name is required");return}if(!R.trim()){re("Description is required");return}X(!0),re(null);try{const C=await W("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:b,description:R,...$.trim()&&{genre:$}})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Registration failed");y({linked:!0,agentId:se.agentId,owsWallet:se.owsWallet})}catch(C){re(C instanceof Error?C.message:"Registration failed")}X(!1)},E=async()=>{if(!Z.trim()||!/^0x[a-fA-F0-9]{40}$/.test(Z)){H("Enter a valid wallet address (0x...)");return}F(!0),H(null),te(null);try{const C=await W("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:Z})}),se=await C.json();if(!C.ok)throw new Error(se.error||"Failed to generate binding code");te(se)}catch(C){H(C instanceof Error?C.message:"Failed to generate binding code")}F(!1)},A=async(C,se)=>{await navigator.clipboard.writeText(C),q(se),setTimeout(()=>q(null),2e3)},K=async()=>{if(f(null),h(!1),!n||n.length<4){f("Passphrase must be at least 4 characters");return}if(n!==a){f("Passphrases do not match");return}_(!0);try{const C=await W("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:n})});if(!C.ok){const se=await C.json();throw new Error(se.error||"Reset failed")}h(!0),s(""),o(""),setTimeout(()=>h(!1),3e3)}catch(C){f(C instanceof Error?C.message:"Reset failed")}_(!1)};return x.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[x.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),S!=null&&S.linked?x.jsxs("div",{className:"space-y-2",children:[x.jsxs("div",{className:"flex items-center gap-2",children:[x.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),x.jsxs("span",{className:"text-muted text-xs",children:["Agent #",S.agentId]})]}),S.owsWallet&&x.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",S.owsWallet.slice(0,6),"...",S.owsWallet.slice(-4)]}),S.owner&&x.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",S.owner.slice(0,6),"...",S.owner.slice(-4)]}),x.jsx("p",{className:"text-muted text-xs",children:x.jsx("a",{href:`https://plotlink.xyz/agents/${S.agentId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):x.jsxs("div",{className:"space-y-3",children:[x.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),x.jsx("input",{value:b,onChange:C=>k(C.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),x.jsx("input",{value:R,onChange:C=>T(C.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),x.jsx("input",{value:$,onChange:C=>j(C.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),L&&x.jsx("p",{className:"text-error text-xs",children:L}),x.jsx("button",{onClick:ue,disabled:O||!b.trim()||!R.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:O?"Registering...":"Register Agent Identity"})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),S!=null&&S.owner?x.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",x.jsxs("span",{className:"font-mono",children:[S.owner.slice(0,6),"...",S.owner.slice(-4)]})]}):x.jsxs("div",{className:"space-y-3",children:[x.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),x.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[x.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),x.jsx("p",{children:'2. Click "Generate Binding Code"'}),x.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),x.jsx("input",{value:Z,onChange:C=>le(C.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),V&&x.jsx("p",{className:"text-error text-xs",children:V}),x.jsx("button",{onClick:E,disabled:U||!Z.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:U?"Generating...":"Generate Binding Code"}),z&&x.jsxs("div",{className:"space-y-3 mt-3",children:[x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),x.jsxs("div",{className:"relative",children:[x.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.signature}),x.jsx("button",{onClick:()=>A(z.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:M==="signature"?"Copied!":"Copy"})]})]}),x.jsxs("div",{children:[x.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),x.jsxs("div",{className:"relative",children:[x.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:z.owsWallet}),x.jsx("button",{onClick:()=>A(z.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:M==="wallet"?"Copied!":"Copy"})]})]}),x.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste both values in the "Link AI Writer" section.'})]})]})]}),x.jsx(Gy,{token:e}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),x.jsxs("div",{className:"space-y-3",children:[x.jsx("input",{type:"password",value:n,onChange:C=>s(C.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),x.jsx("input",{type:"password",value:a,onChange:C=>o(C.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&x.jsx("p",{className:"text-error text-xs",children:c}),p&&x.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),x.jsx("button",{onClick:K,disabled:g||!n.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:g?"updating...":"update passphrase"})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),x.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const Rx="http://localhost:7777";function Mx({token:e}){const[t,n]=ae.useState(null),s=(f,p)=>fetch(f,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),a=()=>{s(`${Rx}/api/dashboard`).then(f=>f.json()).then(n)};ae.useEffect(()=>{a()},[]);const o=f=>`${f.slice(0,6)}...${f.slice(-4)}`,c=f=>{if(!f)return"Unknown date";const p=new Date(f);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?x.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[x.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),x.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),x.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[x.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),x.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Address"}),x.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"ETH Balance"}),x.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"USDC Balance"}),x.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),x.jsxs("div",{className:"space-y-1.5",children:[x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),x.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Royalties earned"}),x.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),x.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),x.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[x.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),x.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),x.jsxs("div",{className:"flex justify-between text-xs",children:[x.jsx("span",{className:"text-muted",children:"Stories published"}),x.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),x.jsxs("div",{className:"border-border rounded border p-4",children:[x.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?x.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):x.jsx("div",{className:"space-y-3",children:t.stories.published.map(f=>x.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[x.jsxs("div",{className:"flex items-start justify-between",children:[x.jsxs("div",{children:[f.genre&&x.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:f.genre}),x.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:f.title}),x.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:f.storyName})]}),x.jsxs("div",{className:"flex items-center gap-2",children:[f.hasNotIndexed&&x.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),x.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[f.publishedFiles," published"]})]})]}),x.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium",children:f.plotCount}),x.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:f.storylineId?`#${f.storylineId}`:"—"}),x.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),x.jsxs("div",{className:"rounded bg-background p-1.5",children:[x.jsx("div",{className:"text-foreground text-sm font-medium",children:f.totalGasCostEth??"—"}),x.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),x.jsx("div",{className:"mt-2 space-y-1",children:f.files.map(p=>x.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[x.jsxs("div",{className:"flex items-center gap-1.5",children:[x.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),x.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&x.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),x.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[x.jsx("span",{className:"text-muted",children:c(f.latestPublishedAt)}),f.storylineId&&x.jsx("a",{href:`https://plotlink.xyz/story/${f.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},f.id))})]}),t.stories.pendingFiles>0&&x.jsx("div",{className:"border-border rounded border p-4",children:x.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):x.jsx("div",{className:"flex h-full items-center justify-center",children:x.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const Bx={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},Lx={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function zx({authFetch:e,selectedStory:t,selectedFile:n,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,f]=ae.useState([]),[p,h]=ae.useState(new Set),g=ae.useCallback(async()=>{try{const k=await e("/api/stories");if(k.ok){const R=await k.json();f(R.stories)}}catch{}},[e]);ae.useEffect(()=>{g();const k=setInterval(g,5e3);return()=>clearInterval(k)},[g]),ae.useEffect(()=>{t&&h(k=>new Set(k).add(t))},[t]);const _=k=>{var T;const R=k.map($=>{var j;return{file:$.file,num:(j=$.file.match(/^plot-(\d+)\.md$/))==null?void 0:j[1]}}).filter($=>$.num!=null).sort(($,j)=>parseInt(j.num)-parseInt($.num));return R.length>0?R[0].file:k.some($=>$.file==="genesis.md")?"genesis.md":k.some($=>$.file==="structure.md")?"structure.md":((T=k[0])==null?void 0:T.file)??null},S=k=>{h(R=>{const T=new Set(R);return T.has(k)?T.delete(k):T.add(k),T})},y=k=>{if(S(k.name),!p.has(k.name)){const R=_(k.files);R&&s(k.name,R)}},b=k=>{const R=T=>{if(T==="structure.md")return 0;if(T==="genesis.md")return 1;const $=T.match(/^plot-(\d+)\.md$/);return $?2+parseInt($[1]):100};return[...k].sort((T,$)=>R(T.file)-R($.file))};return x.jsxs("div",{className:"h-full flex flex-col",children:[x.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[x.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),x.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&x.jsx("div",{className:"px-3 py-2 border-b border-border",children:x.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[x.jsx("span",{children:"+"}),x.jsx("span",{children:"New Story"})]})}),x.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(k=>x.jsx("div",{children:x.jsxs("button",{onClick:()=>s(k,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===k?"bg-surface":""}`,children:[x.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),x.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},k)),c.length===0&&o.length===0?x.jsxs("div",{className:"p-3 text-sm text-muted",children:[x.jsx("p",{children:"No stories yet."}),x.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(k=>k.name!=="_example").map(k=>x.jsxs("div",{children:[x.jsxs("button",{onClick:()=>y(k),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[x.jsx("span",{className:"text-xs text-muted",children:p.has(k.name)?"▼":"▶"}),x.jsx("span",{className:"font-medium truncate",title:k.name,children:k.title||k.name}),x.jsxs("span",{className:"ml-auto text-xs text-muted",children:[k.publishedCount,"/",k.files.length]})]}),p.has(k.name)&&x.jsx("div",{className:"pl-4",children:b(k.files).map(R=>{const T=t===k.name&&n===R.file;return x.jsxs("button",{onClick:()=>s(k.name,R.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${T?"bg-surface font-medium":""}`,children:[x.jsx("span",{className:Lx[R.status],children:Bx[R.status]}),x.jsx("span",{className:"truncate font-mono",children:R.file})]},R.file)})})]},k.name))]})]})}/** * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved. * @license MIT * diff --git a/app/web/dist/index.html b/app/web/dist/index.html index 8ee5a61..7fc781a 100644 --- a/app/web/dist/index.html +++ b/app/web/dist/index.html @@ -7,7 +7,7 @@ - + diff --git a/package.json b/package.json index bcabfd5..7b8bcb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plotlink-ows", - "version": "1.0.10", + "version": "1.0.11", "bin": { "plotlink-ows": "./bin/plotlink-ows.js" },