PageSourceSearch

https://jin.imajin.ai/_next/static/chunks/87396-22bc7446c7da6fa9.js

js imajin.ai collected 2026-10-05 14:38:04 UTC 53,860 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[87396],{87396:(e,t,a)=>{a.d(t,{Ee:()=>W,GV:()=>ea,fk:()=>K,Ow:()=>el,ImajinFooter:()=>_,h2:()=>J,nt:()=>G,F0:()=>ec,jq:()=>z,ph:()=>R,ToastProvider:()=>E,yx:()=>v,dj:()=>L});var r=a(25118),n=a(32846),s=a(36254),l=a(67781),i=a(43113),o=a(58530),c=a(9756),d=a(55797),u=a(72741),x=a(36407),g=a(45767),m=a(17946),h=a(94160),p=a(70237),f=a(57358),y=a(62405);a(67234);var b=a(64204);function v(e,t){let[a,n]=(0,r.useState)([]),[s,l]=(0,r.useState)(!1),[i,o]=(0,r.useState)(null),[c,d]=(0,r.useState)(null);return(0,r.useEffect)(()=>{o(void 0===globalThis.window?null:localStorage.getItem("imajin:acting-as"))},[]),(0,r.useEffect)(()=>{e&&(l(!0),fetch("".concat(e,"/api/groups"),{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{Array.isArray(e)?n(e):(null==e?void 0:e.groups)&&n(e.groups)}).catch(()=>{}).finally(()=>l(!1)))},[e]),(0,r.useEffect)(()=>{if(!t||!i)return void d(null);fetch("".concat(t,"/api/forest/").concat(encodeURIComponent(i),"/config/public")).then(e=>e.ok?e.json():null).then(e=>{e&&d(e)}).catch(()=>{})},[e,t,i]),{identities:a,loading:s,activeIdentity:i,activeConfig:c,setActiveIdentity:function(e){void 0!==globalThis.window&&(e?(localStorage.setItem("imajin:acting-as",e),document.cookie="x-acting-as=".concat(e,"; path=/; max-age=31536000; SameSite=Lax")):(localStorage.removeItem("imajin:acting-as"),document.cookie="x-acting-as=; path=/; max-age=0"),globalThis.dispatchEvent(new CustomEvent("imajin:acting-as-changed",{detail:{did:e}}))),o(e),globalThis.location.reload()}}}function j(e){var t,a,s;let{registryUrl:l,currentService:i,tier:o="anonymous",inline:c=!1,variant:d="list",authUrl:u,enabledServices:x}=e,[g,m]=(0,r.useState)([]),[h,p]=(0,r.useState)(!1),f=(0,r.useRef)(null),y="hard"===o||"creator"===o,{identities:b,activeIdentity:j,setActiveIdentity:N}=v(y&&u?u:null,null);(0,r.useEffect)(()=>{fetch("".concat(l,"/api/specs")).then(e=>e.ok?e.json():null).then(e=>{(null==e?void 0:e.services)&&m(e.services)}).catch(()=>{})},[l]),(0,r.useEffect)(()=>{if(h)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e);function e(e){f.current&&!f.current.contains(e.target)&&p(!1)}},[h]);let k=function(e,t){let a="hard"===t||"creator"===t;return e.filter(e=>"internal"!==e.visibility&&("public"===e.visibility||("authenticated"===e.visibility||"creator"===e.visibility)&&a))}(g,o);x&&x.length>0&&(k=k.filter(e=>x.includes(e.name)));let{kernel:w,core:D,creator:C,developer:S,meta:E}={kernel:(s=k).filter(e=>"kernel"===e.category),core:s.filter(e=>"core"===e.category),creator:s.filter(e=>"creator"===e.category),developer:s.filter(e=>"developer"===e.category),meta:s.filter(e=>"meta"===e.category)},L=(null==(t=g.find(e=>"kernel"===e.name))?void 0:t.url)||(null==(a=g.find(e=>"www"===e.name))?void 0:a.url)||"#";function I(e){let t=e.name===i,a=!!e.externalUrl;return(0,n.jsxs)("a",{href:e.url,...a&&{target:"_blank",rel:"noopener noreferrer"},className:"flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition no-underline ".concat(t?"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400 font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"),children:[(0,n.jsx)("span",{className:"text-lg flex-shrink-0",children:e.icon}),(0,n.jsx)("span",{children:e.label})]},e.name)}function T(e){let t=e.name===i;return(0,n.jsxs)("a",{href:e.url,className:"flex flex-col items-center justify-center w-16 h-16 rounded-lg text-center transition no-underline ".concat(t?"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"),children:[(0,n.jsx)("span",{className:"text-2xl",children:e.icon}),(0,n.jsx)("span",{className:"text-[10px] mt-0.5 leading-tight",children:e.label})]},e.name)}let A=y&&(b.length>0||u)?(0,n.jsxs)("div",{className:"border-t border-gray-200 dark:border-gray-800 mt-1 pt-1",children:[(0,n.jsx)("div",{className:"px-3 pt-1 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Switch To"}),b.map(e=>{var t;let a=e.groupDid===j;return(0,n.jsxs)("button",{type:"button",onClick:()=>{N(a?null:e.groupDid),p(!1)},className:"w-full text-left flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition ".concat(a?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300 font-medium":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800"),children:[(0,n.jsx)("span",{className:"text-lg flex-shrink-0",children:"community"===(t=e.scope)?"\uD83C\uDFDB️":"org"===t?"\uD83C\uDFE2":"family"===t?"\uD83D\uDC68‍\uD83D\uDC69‍\uD83D\uDC66":"node"===t?"\uD83D\uDDA5️":"agent"===t?"\uD83E\uDD16":"device"===t?"\uD83D\uDCF1":"\uD83D\uDC64"}),(0,n.jsx)("span",{children:e.name||e.handle||e.groupDid.slice(0,12)}
1),a&&(0,n.jsx)("span",{className:"ml-auto text-amber-600 dark:text-amber-400 font-bold text-xs",children:"✓"})]},e.groupDid)})]}):null,R=(0,n.jsx)("div",{className:"border-t border-gray-200 dark:border-gray-800 mt-1 pt-1",children:(0,n.jsx)("a",{href:"".concat(L,"/"),className:"flex items-center gap-2 px-3 py-2 rounded-lg text-xs text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition no-underline",children:"See all apps →"})}),F="grid"===d?(0,n.jsxs)(n.Fragment,{children:[w.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"col-span-4 px-3 pt-1 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Kernel Services"}),(0,n.jsx)("div",{className:"grid grid-cols-4 gap-1 px-2",children:w.map(T)})]}),D.length>0&&(0,n.jsx)("div",{className:"grid grid-cols-4 gap-1 px-2",children:D.map(T)}),C.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"col-span-4 px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Creator Tools"}),(0,n.jsx)("div",{className:"grid grid-cols-4 gap-1 px-2",children:C.map(T)})]}),S.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"col-span-4 px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Developers"}),(0,n.jsx)("div",{className:"grid grid-cols-4 gap-1 px-2",children:S.map(T)})]}),A,R]}):(0,n.jsxs)(n.Fragment,{children:[w.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 pt-1 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Kernel Services"}),w.map(I)]}),D.length>0&&(0,n.jsx)("div",{children:D.map(I)}),C.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Creator Tools"}),C.map(I)]}),S.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Developers"}),S.map(I)]}),E.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"px-3 pt-2 pb-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Project"}),E.map(I)]}),A,R]});return c?(0,n.jsx)("div",{className:"space-y-0.5",children:F}):(0,n.jsxs)("div",{className:"relative",ref:f,children:[(0,n.jsx)("button",{type:"button",onClick:()=>p(!h),className:"px-3 py-1.5 rounded-lg text-sm transition flex items-center gap-1.5 ".concat(h?"bg-orange-100 dark:bg-orange-900/30 text-orange-600 dark:text-orange-400":"text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800"),children:"grid"===d?(0,n.jsxs)("span",{className:"grid grid-cols-2 gap-0.5 w-4 h-4",children:[(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-sm bg-current"}),(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-sm bg-current"}),(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-sm bg-current"}),(0,n.jsx)("span",{className:"w-1.5 h-1.5 rounded-sm bg-current"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:"\uD83D\uDE80"}),(0,n.jsx)("span",{className:"hidden sm:inline",children:"Launcher"})]})}),h&&(0,n.jsx)("div",{className:"absolute left-0 mt-2 ".concat("grid"===d?"w-72":"w-56"," bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-xl shadow-xl py-2 z-50"),children:0===k.length?(0,n.jsx)("div",{className:"px-4 py-3 text-sm text-gray-400",children:"Loading..."}):F})]})}function N(e,t){switch(t.type){case"ADD":return[...e,t.toast].slice(-5);case"REMOVE":return e.filter(e=>e.id!==t.id);default:return e}}var k=(0,r.createContext)(null),w={success:"border-l-green-500",error:"border-l-red-500",warning:"border-l-amber-500",info:"border-l-blue-500"},D={success:4e3,error:0,warning:6e3,info:4e3};function C(e){let{id:t,duration:a,onDismiss:n}=e;return(0,r.useEffect)(()=>{let e=setTimeout(()=>n(t),a);return()=>clearTimeout(e)},[t,a,n]),null}function S(e){let{toast:t,onDismiss:a}=e;return(0,n.jsxs)("div",{className:"flex items-start gap-3 bg-gray-900 text-white px-4 py-3 rounded-lg shadow-lg border-l-4 ".concat(w[t.type]," min-w-[280px] max-w-sm"),style:{animation:"toastSlideIn 0.2s ease-out"},children:[(0,n.jsx)("p",{className:"flex-1 text-sm",children:t.message}),(0,n.jsx)("button",{type:"button",onClick:a,className:"text-gray-400 hover:text-white transition-colors shrink-0 text-lg leading-none","aria-label":"Dismiss",children:"\xd7"})]})}function E(e){let{children:t}=e,[a,s]=(0,r.useReducer)(N,[]),l=(0,r.useCallback)(e=>{s({type:"REMOVE",id:e})},[]),i=(0,r.useCallback)((e,t)=>{s({type:"ADD",toast:{id:function(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();if("undefined"!=typeof crypto&&crypto.getRandomValues){let e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}return"".concat(Date.now().toString(36),"-toast")}(),type:e,message:t,sticky:"error"===e}})},[]),o=(0,r.useMemo)(()=>({toast:{success:e=>i("success",e),error:e=>i("error",e),warning:e=>i("warning",e),info:e=>i("info",e)}}),[i]);return(0,n.jsxs)(k.Provider,{value:o,children:[t,(0,n.jsxs)("div",{className:"fixed bottom-4 right-4 z-[9999] flex flex-col gap-2 items-end","aria-live":"polite",children:[(0,n.jsx)("style",{children:"\n          @keyframes toastSlideIn {\n            from { transform: translateX(calc(100% + 1rem)); opacity: 0; }\n            to { transform: translateX(0); opacity: 1; }\n          }\n        "}),a.map(e=>(0,n.jsxs)(r.Fragment,{children:[!e.sticky&&D[e.type]>0&&(0,n.jsx)(C,{id:e.id,duration:D[e.type],onDismiss:l}),(0,n.jsx)(S,{toast:e,onDismiss:()=>l(e.id)})]},e.id))]})]})}function L(){let e=(0,r.useContext)(k);if(!e)throw Error("useToast must be used within a ToastProvider");return e}var I=(0,r.createContext)(null),T={unreadCount:0,notifications:[],markAsRead:async()=>{},markAllAsRead:async()=>{},refresh:async()=>{}};async function A(e,t,a){try{var r,n;let s=await fetch("".concat(e,"/api/notifications?limit=1"),{credentials:"include"});if(!s.ok)return;let l=await s.json(),i=null!=(n=null==(r=l.notifications)?void 0:r[0])?n:l[0];if(!i||i.id===t.current)return;t.current=i.id,"urgent"===i.urgency?a.current.warning(i.title):a.current.info(i.title)}catch(e){}}function R(e){let{children:t}=e,a="https://jin.imajin.ai/notify",[s,l]=(0,r.useState)(0),[i,o]=(0,r.useState)([]),c=(0,r.useRef)(!1),d=(0,r.useRef)(-1),u=(0,r.useRef)(null),{toast:x}=L(),g=(0,r.useRef)(x);g.current=x;let m=(0,r.useCallback)(async()=>
1{if(a)try{var e;let t=await fetch("".concat(a,"/api/notifications/unread"),{credentials:"include"});if(!t.ok)return;let r=null!=(e=(await t.json()).count)?e:0;d.current>=0&&r>d.current&&await A(a,u,g),d.current=r,l(r)}catch(e){c.current||(console.warn("[notifications] notify service unavailable — bell will show 0 unread"),c.current=!0)}},[a]);(0,r.useEffect)(()=>{if(!a)return;m();let e=setInterval(m,3e4);return()=>clearInterval(e)},[a,m]);let h=(0,r.useCallback)(async()=>{if(a)try{var e,t;let r=await fetch("".concat(a,"/api/notifications?limit=20"),{credentials:"include"});if(!r.ok)return;let n=await r.json();o(null!=(t=null!=(e=n.notifications)?e:n)?t:[])}catch(e){}},[a]),p=(0,r.useCallback)(async e=>{if(a)try{await fetch("".concat(a,"/api/notifications/").concat(e,"/read"),{method:"POST",credentials:"include"}),o(t=>t.map(t=>t.id===e?{...t,read:!0}:t)),l(e=>Math.max(0,e-1))}catch(e){}},[a]),f=(0,r.useCallback)(async()=>{if(a)try{await fetch("".concat(a,"/api/notifications/read-all"),{method:"POST",credentials:"include"}),o(e=>e.map(e=>({...e,read:!0}))),l(0),d.current=0}catch(e){}},[a]),y=(0,r.useMemo)(()=>({unreadCount:s,notifications:i,markAsRead:p,markAllAsRead:f,refresh:h}),[s,i,p,f,h]);return(0,n.jsx)(I.Provider,{value:y,children:t})}function F(e){let t=Math.floor((Date.now()-new Date(e).getTime())/6e4);if(t<1)return"just now";if(t<60)return"".concat(t,"m ago");let a=Math.floor(t/60);if(a<24)return"".concat(a,"h ago");let r=Math.floor(a/24);return 1===r?"Yesterday":"".concat(r,"d ago")}function M(e){let{className:t}=e;return(0,n.jsxs)("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[(0,n.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,n.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}function P(e){return e.length>30?"".concat(e.slice(0,20),"…").concat(e.slice(-6)):e}function U(e){var t;let{notification:a,onDone:s}=e,[l,i]=(0,r.useState)(null),o=null!=(t=a.data)?t:{},c="string"==typeof o.requesterDid?o.requesterDid:"",d="string"==typeof o.did?o.did:"",u="string"==typeof o.appDid?o.appDid:"",x="string"==typeof o.purpose?o.purpose:"",g=Array.isArray(o.fields)?o.fields.filter(e=>"string"==typeof e):[],m=""!==u&&u!==d,h=m?u:c||d;async function p(){i("approve");try{await fetch("/api/broker/consent",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({subject:void 0,grantedTo:c,purpose:x,allowedFields:g.length>
10?g:[x]})})}catch(e){}finally{s()}}async function f(){i("deny"),s()}let y=P(h);return(0,n.jsxs)("div",{className:"px-4 py-3 border-b border-gray-800 last:border-0 ".concat(a.read?"":"bg-amber-500/5"),children:[(0,n.jsxs)("div",{className:"flex items-start gap-2 mb-2",children:[(0,n.jsx)("span",{className:"shrink-0 w-2 h-2 rounded-full mt-1.5",children:!a.read&&(0,n.jsx)("span",{className:"block w-2 h-2 rounded-full bg-amber-500","aria-hidden":"true"})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"text-sm font-medium text-white",children:a.title}),y&&(0,n.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 truncate",title:h,children:y}),m&&(0,n.jsxs)("p",{className:"text-xs text-amber-500/80 mt-0.5 truncate",title:d,children:["on behalf of you (",P(d),")"]}),g.length>0&&(0,n.jsx)("p",{className:"text-xs text-gray-400 mt-0.5",children:g.join(", ")}),(0,n.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:F(a.createdAt)})]})]}),(0,n.jsxs)("div",{className:"flex gap-2 pl-4",children:[(0,n.jsx)("button",{type:"button",onClick:p,disabled:null!==l,className:"flex-1 py-1.5 text-xs font-medium bg-amber-500 hover:bg-amber-400 text-black rounded transition disabled:opacity-50",children:"approve"===l?"…":"Approve"}),(0,n.jsx)("button",{type:"button",onClick:f,disabled:null!==l,className:"flex-1 py-1.5 text-xs font-medium bg-white/10 hover:bg-white/20 text-gray-300 hover:text-white rounded transition disabled:opacity-50",children:"deny"===l?"…":"Deny"})]})]})}function B(){var e;let{unreadCount:t,notifications:a,markAsRead:s,markAllAsRead:l,refresh:i}=null!=(e=(0,r.useContext)(I))?e:T,[o,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)(!1),x=(0,r.useRef)(null),g=(0,r.useCallback)(async()=>{o?c(!1):(c(!0),u(!0),await i(),u(!1))},[o,i]);(0,r.useEffect)(()=>{if(o)return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)};function e(e){x.current&&!x.current.contains(e.target)&&c(!1)}function t(e){"Escape"===e.key&&c(!1)}},[o]);let m=a.some(e=>!e.read),h=t>0?", ".concat(t," unread"):"";return(0,n.jsxs)("div",{className:"relative",ref:x,children:[(0,n.jsxs)("button",{type:"button",onClick:g,className:"relative p-2 rounded-lg transition ".concat(o?"bg-gray-100 dark:bg-gray-800":"hover:bg-gray-100 dark:hover:bg-gray-800"),title:"Notifications","aria-label":"Notifications".concat(h),"aria-expanded":o,children:[(0,n.jsx)(M,{className:"w-5 h-5 text-gray-600 dark:text-gray-300"}),t>0&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 bg-red-500 text-white text-[10px] font-bold rounded-full min-w-[1.1rem] h-[1.1rem] flex items-center justify-center px-1 leading-none pointer-events-none",children:t>99?"99+":t})]}),o&&(0,n.jsxs)("div",{className:"absolute right-0 mt-2 w-80 bg-gray-900 border border-gray-700 rounded-lg shadow-lg z-50 flex flex-col max-h-[24rem]",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-700 shrink-0",children:[(0,n.jsx)("span",{className:"text-sm font-semibold text-white",children:"Notifications"}),m&&(0,n.jsx)("button",{type:"button",onClick:()=>l(),className:"text-xs text-blue-400 hover:text-blue-300 transition",children:"Mark all as read"})]}),(0,n.jsx)("div",{className:"overflow-y-auto flex-1",children:d?(0,n.jsx)("div",{className:"px-4 py-6 text-center text-sm text-gray-400",children:"Loading…"}):0===a.length?(0,n.jsx)("div",{className:"px-4 py-6 text-center text-sm text-gray-400",children:"No notifications yet"}):a.map(e=>"broker:consent-request"!==e.scope||e.read?(0,n.jsxs)("button",{type:"button",onClick:()=>s(e.id),className:"w-full text-left px-4 py-3 border-b border-gray-800 last:border-0 hover:bg-gray-800 transition flex items-start gap-3 ".concat(e.read?"":"bg-gray-800/50"),children:[(0,n.jsx)("span",{className:"shrink-0 w-2 h-2 rounded-full mt-1.5 flex items-center justify-center",children:!e.read&&(0,n.jsx)("span",{className:"block w-2 h-2 rounded-full bg-blue-500","aria-hidden":"true"})}),(0,n.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,n.jsx)("p",{className:"text-sm font-medium text-white truncate",children:e.title}),e.body&&(0,n.jsx)("p",{className:"text-xs text-gray-400 mt-0.5 line-clamp-2",children:e.body}),(0,n.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:F(e.createdAt)})]})]},e.id):(0,n.jsx)(U,{notification:e,onDone:()=>s(e.id)},e.id))})]})]})}function O(e,t,a,r){let n=null==r?void 0:r[e];if(n)return n;if(a.includes("localhost")||t.includes("localhost")){let t=(0,s.c9)(e,"dev");return t?"http://localhost:".concat(t):"http://localhost:3000"}if(t.replace(/^https?:\/\//,"").includes(".")){let a=t.endsWith("/")?t.slice(0,-1):t;return"www"===e||"kernel"===e?a:"".concat(a,"/").concat(e)}return"".concat(t).concat(e,".").concat(a)}function V(e){return"community"===e?"\uD83C\uDFDB️":"org"===e?"\uD83C\uDFE2":"family"===e?"\uD83D\uDC68‍\uD83D\uDC69‍\uD83D\uDC66":"node"===e?"\uD83D\uDDA5️":"agent"===e?"\uD83E\uDD16":"device"===e?"\uD83D\uDCF1":"\uD83D\uDC64"}function z(e){var t;let{currentService:a,servicePrefix:s="https://",domain:l="imajin.ai",identity:i,unreadMessages:o=0,serviceUrls:c,children:d}=e,[u,x]=(0,r.useState)(!1);(0,r.useEffect)(()=>{x("hub"===new URLSearchParams(globalThis.location.search).get("embed"))},[]);let g={connections:O("connections",s,l,c),messages:O("chat",s,l,c),profile:O("profile",s,l,c)},m=s.includes("dev-"),[h,p]=(0,r.useState)(!1),[f,y]=(0,r.useState)(!1),b=(0,r.useRef)(null),[N,k]=(0,r.useState)("dark");function w(){let e="dark"===N?"light":"dark";k(e),localStorage.setItem("theme",e),"dark"===e?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")}(0,r.useEffect)(()=>{k("light"===localStorage.getItem("theme")?"light":"dark")},[]);let D=function(e,t,a){let[n,s]=(0,r.useState)(null);return(0,r.useEffect)(()=>{let r=O("auth",e,t,a),n=O("profile",e,t,a);async function l(){try{let t=await fetch("".concat(r,"/api/session"),{credentials:"include"});if(t.ok){var e;let a=await t.json();s({isLoggedIn:!0,handle:a.handle||null,did:a.did||null,name:a.name||null,tier:a.tier||null,onLogout:async()=>{try{await fetch("".concat(r,"/api/logout"),{method:"POST",credentials:"include"})}catch(e){}s({isLoggedIn:!1,onLogin:()=>{globalThis.location.href="".concat(r,"/login?next=").concat(encodeURIComponent(globalThis.location.href))},onRegister:()=>{globalThis.location.href="".concat(r,"/register")}})},onViewProfile:(null!=(e=a.handle)?e:a.did)?()=>{var e;globalThis.location.href="".concat(n,"/").concat(null!=(e=a.handle)?e:a.did)}:void 0,onEditProfile:()=>{globalThis.location.href="".concat(n,"/edit")},onLogin:()=>{globalThis.location.href="".concat(r,"/login?next=").concat(encodeURIComponent(globalThis.location.href))},onRegister:()=>{globalThis.location.href="".concat(r,"/register")}})}else s({isLoggedIn:!1,onLogin:()=>{globalThis.location.href="".concat(r,"/login?next=").concat(encodeURIComponent(globalThis.location.href))},onRegister:()=>{globalThis.location.href="".concat(r,"/register")}})}catch(e){s(null)}}l();let i=()=>l();return globalThis.addEventListener("imajin:session-changed",i),()=>globalThis.removeEventListener("imajin:session-changed",i)},[e,t,a]),n}(s,l,c),C=null!=i?i:D,S=O("registry",s,l,c),E=(null==C?void 0:C.isLoggedIn)?"soft"===C.tier?"soft":"hard":"anonymous",[L,I]=(0,r.useState)(null),[T,A]=(0,r.useState)(null),[R,F]=(0,r.useState)(0);(0,r.useEffect)(()=>{let e=()=>F(e=>e+1);return globalThis.addEventListener("imajin:acting-as-changed",e),()=>globalThis.removeEventListener("imajin:acting-as-changed",e)},[]),(0,r.useEffect)(()=>
1{if(!(null==C?void 0:C.isLoggedIn)||!(null==C?void 0:C.did)){I(null),A(null);return}let e=localStorage.getItem("imajin:acting-as")||C.did,t=O("pay",s,l,c);fetch("".concat(t,"/api/balance/").concat(encodeURIComponent(e)),{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{let t=Array.isArray(null==e?void 0:e.balances)?e.balances:null,a=null==t?void 0:t.find(e=>"MJN"===e.unit),r=null==t?void 0:t.find(e=>"MJNx"===e.unit);if(t){var n,s;I(null!=(n=null==a?void 0:a.amount)?n:null),A(null!=(s=null==r?void 0:r.amount)?s:null)}else I(null),A(null)}).catch(()=>{})},[null==C?void 0:C.isLoggedIn,null==C?void 0:C.did,s,l,c,R]);let[M,P]=(0,r.useState)(o);(0,r.useEffect)(()=>{if(!(null==C?void 0:C.isLoggedIn)||(null==C?void 0:C.tier)==="soft")return void P(0);let e=O("chat",s,l,c);function t(){fetch("".concat(e,"/api/conversations/unread"),{credentials:"include"}).then(e=>e.ok?e.json():null).then(e=>{(null==e?void 0:e.total)!=null&&P(e.total)}).catch(()=>{})}t();let a=setInterval(t,6e4);return()=>clearInterval(a)},[null==C?void 0:C.isLoggedIn,null==C?void 0:C.tier,s,l,c]);let U=O("auth",s,l,c),z=O("profile",s,l,c),{identities:q,activeIdentity:_,activeConfig:X,setActiveIdentity:G}=v((null==C?void 0:C.isLoggedIn)&&(null==C?void 0:C.tier)!=="soft"?U:null,(null==C?void 0:C.isLoggedIn)&&(null==C?void 0:C.tier)!=="soft"?z:null),H=null!=(t=q.find(e=>e.groupDid===_))?t:null;return(0,r.useEffect)(()=>{function e(e){b.current&&!b.current.contains(e.target)&&p(!1)}if(h)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]),u?null:(0,n.jsxs)("nav",{className:"w-full border-b border-gray-200 dark:border-gray-800 bg-white/80 dark:bg-gray-900/80 backdrop-blur-sm relative z-50",children:[m&&(0,n.jsx)("div",{className:"w-full bg-amber-500/90 text-black text-xs font-bold text-center py-1 tracking-wide",children:"⚠ DEVELOPMENT ENVIRONMENT"}),(0,n.jsxs)("div",{className:"max-w-6xl mx-auto px-4 py-3 flex items-center gap-2",children:[(0,n.jsx)("a",{href:O("www",s,l,c),className:"flex items-center hover:opacity-80 transition shrink-0",children:(0,n.jsx)("span",{className:"w-8 h-8 rounded-lg bg-amber-500/10 dark:bg-amber-500/20 flex items-center justify-center",children:(0,n.jsx)("span",{className:"text-xl font-bold text-amber-500",children:"人"})})}),(0,n.jsx)("div",{className:"flex-1 min-w-0",children:d}),(0,n.jsxs)("div",{className:"hidden sm:flex items-center gap-1",children:[(0,n.jsx)(j,{registryUrl:S,currentService:a,tier:E,variant:"grid",authUrl:(null==C?void 0:C.isLoggedIn)&&(null==C?void 0:C.tier)!=="soft"?U:void 0,enabledServices:null==X?void 0:X.enabledServices}),(null==C?void 0:C.isLoggedIn)&&(null==C?void 0:C.tier)!=="soft"&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("a",{href:g.messages,className:"relative p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition no-underline",title:"Messages",children:[(0,n.jsx)("span",{className:"text-lg",children:"\uD83D\uDCAC"}),M>0&&(0,n.jsx)("span",{className:"absolute -top-0.5 -right-0.5 bg-orange-500 text-white text-[10px] font-bold rounded-full min-w-[1.1rem] h-[1.1rem] flex items-center justify-center px-1",children:M>99?"99+":M})]}),(0,n.jsx)("a",{href:g.connections,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition no-underline",title:"Connections",children:(0,n.jsx)("span",{className:"text-lg",children:"\uD83E\uDD1D"})})]})]}),(0,n.jsx)("div",{className:"hidden sm:flex items-center",children:(0,n.jsx)(B,{})}),(0,n.jsx)("button",{type:"button",onClick:()=>y(!f),className:"sm:hidden p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition",children:(0,n.jsx)("span",{className:"text-xl",children:f?"✕":"☰"})}),(0,n.jsx)("div",{className:"flex items-center gap-2",children:(()=>{if((null==C?void 0:C.isLoggedIn)&&(null==C?void 0:C.tier)==="soft")return(0,n.jsx)("button",{type:"button",onClick:()=>{var e;return null==(e=C.onLogout)?void 0:e.call(C)},className:"px-3 py-1.5 rounded-lg text-sm text-red-600 dark:text-red-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition",children:"Logout"});if(null==C?void 0:C.isLoggedIn){var e;return(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[null!==L&&L>0&&(0,n.jsxs)("a",{href:O("pay",s,l,c),className:"text-sm font-medium text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/20 px-2.5 py-1 rounded-full hover:bg-green-100 dark:hover:bg-green-900/40 transition no-underline",children:["$",L.toFixed(2)]}),null!==T&&T>0&&(0,n.jsxs)("a",{href:O("pay",s,l,c),className:"text-sm font-medium text-amber-600 dar
1k:text-amber-400 bg-amber-50 dark:bg-amber-900/20 px-2.5 py-1 rounded-full hover:bg-amber-100 dark:hover:bg-amber-900/40 transition no-underline",children:["人",Math.round(T)]}),(0,n.jsxs)("div",{className:"relative",ref:b,children:[(0,n.jsxs)("button",{type:"button",onClick:()=>p(!h),className:"flex items-center gap-2 px-3 py-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition",children:[(0,n.jsx)("span",{className:"text-xl",children:H?V(H.scope):"\uD83D\uDC64"}),(0,n.jsxs)("span",{className:"flex flex-col items-start",style:{gap:"2px"},children:[H&&(0,n.jsx)("span",{className:"text-[10px] text-amber-600 dark:text-amber-400 font-medium leading-none",children:"acting as"}),(0,n.jsx)("span",{className:"text-sm font-medium leading-none",children:H?H.name||H.handle||"Identity":C.handle?"@".concat(C.handle):C.name?C.name:(null==(e=C.did)?void 0:e.slice(0,12))+"..."})]})]}),h&&(0,n.jsxs)("div",{className:"absolute right-0 mt-2 w-52 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-800 rounded-lg shadow-lg py-1 z-50",children:["soft"!==C.tier&&(0,n.jsxs)(n.Fragment,{children:[C.onViewProfile&&(0,n.jsxs)("button",{type:"button",onClick:()=>{var e;null==(e=C.onViewProfile)||e.call(C),p(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2",children:[(0,n.jsx)("span",{children:"\uD83D\uDC64"})," View Profile"]}),C.onEditProfile&&(0,n.jsxs)("button",{type:"button",onClick:()=>{var e;null==(e=C.onEditProfile)||e.call(C),p(!1)},className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2",children:[(0,n.jsx)("span",{children:"✏️"})," Edit Profile"]}),(0,n.jsxs)("a",{href:"".concat(O("auth",s,l,c),"/settings/security"),className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDD12"})," Security"]}),(0,n.jsxs)("a",{href:"".concat(O("notify",s,l,c),"/settings"),className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDD14"})," Notifications"]}),(0,n.jsx)("hr",{className:"my-1 border-gray-200 dark:border-gray-800"}),(0,n.jsxs)("a",{href:g.messages,className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDCAC"})," Messages",M>0&&(0,n.jsx)("span",{className:"ml-auto bg-orange-500 text-white text-xs font-bold rounded-full px-2 py-0.5 min-w-[1.25rem] text-center",children:M})]}),(0,n.jsxs)("a",{href:g.connections,className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83E\uDD1D"})," Connections"]}),(0,n.jsxs)("a",{href:O("pay",s,l,c),className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDCB0"})," Wallet"]}),(0,n.jsxs)("a",{href:O("media",s,l,c),className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDCC1"})," Media"]}),(0,n.jsxs)("a",{href:O("auth",s,l,c),className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDD11"})," Identities"]}),(0,n.jsx)("hr",{className:"my-1 border-gray-200 dark:border-gray-800"}),(0,n.jsx)("div",{className:"px-4 py-1 text-[10px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500",children:"Switch To"}),_&&C&&(0,n.jsx)("div",{className:"flex items-center group/identity",children:(0,n.jsxs)("button",{type:"button",onClick:()=>{G(null),p(!1)},className:"flex-1 text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2",children:[(0,n.jsx)("span",{children:"\uD83D\uDC64"}),(0,n.jsx)("span",{children:C.handle?"@".concat(C.handle):C.name||"Personal"})]})}),q.slice(0,5).map(e=>{let t=e.groupDid===_;return(0,n.jsxs)("div",{className:"flex items-center group/identity",children:[(0,n.jsxs)("button",{type:"button",onClick:()=>{G(t?null:e.groupDid),p(!1)},className:"flex-1 text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2",children:[(0,n.jsx)("span",{children:V(e.scope)}),(0,n.jsx)("span",{className:t?"font-medium":"",children:e.name||e.handle||e.groupDid.slice(0,12)}
1),t&&(0,n.jsx)("span",{className:"ml-auto text-amber-600 dark:text-amber-400 font-bold text-xs",children:"✓"})]}),(0,n.jsx)("a",{href:"".concat(U,"/groups/").concat(encodeURIComponent(e.groupDid),"/settings"),onClick:e=>e.stopPropagation(),className:"pr-3 py-2 text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition opacity-0 group-hover/identity:opacity-100 no-underline text-sm",title:"Settings",children:"⚙️"})]},e.groupDid)}),q.length>5&&(0,n.jsx)("a",{href:O("auth",s,l,c),className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit text-gray-500 dark:text-gray-400",children:"View all →"}),(0,n.jsx)("hr",{className:"my-1 border-gray-200 dark:border-gray-800"}),(0,n.jsxs)("button",{type:"button",onClick:w,className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2",children:[(0,n.jsx)("span",{children:"dark"===N?"☀️":"\uD83C\uDF19"})," ","dark"===N?"Light Mode":"Dark Mode"]}),(0,n.jsxs)("a",{href:"".concat(O("www",s,l,c),"/bugs"),className:"w-full text-left px-4 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2 no-underline text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDC1B"})," Report a Bug"]})]}),C.onLogout&&(0,n.jsxs)(n.Fragment,{children:["soft"!==C.tier&&(0,n.jsx)("hr",{className:"my-1 border-gray-200 dark:border-gray-800"}),(0,n.jsxs)("button",{type:"button",onClick:()=>{var e;null==(e=C.onLogout)||e.call(C),p(!1)},className:"w-full text-left px-4 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-gray-100 dark:hover:bg-gray-800 transition flex items-center gap-2",children:[(0,n.jsx)("span",{children:"\uD83D\uDEAA"})," Logout"]})]})]})]})]})}return C?(0,n.jsx)(n.Fragment,{children:C.onLogin&&(0,n.jsx)("button",{type:"button",onClick:C.onLogin,className:"px-3 py-1.5 rounded-lg text-sm bg-[#F59E0B] text-black hover:bg-[#D97706] transition font-medium",children:"Login"})}):null})()})]}),f&&(0,n.jsxs)("div",{className:"sm:hidden border-t border-gray-200 dark:border-gray-800 px-4 py-3",children:[d&&(0,n.jsx)("div",{className:"mb-3",children:d}),(0,n.jsx)(j,{registryUrl:S,currentService:a,tier:E,inline:!0,variant:"grid",authUrl:(null==C?void 0:C.isLoggedIn)&&(null==C?void 0:C.tier)!=="soft"?U:void 0,enabledServices:null==X?void 0:X.enabledServices}),(null==C?void 0:C.isLoggedIn)&&(null==C?void 0:C.tier)!=="soft"&&(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-3 pt-3 border-t border-gray-200 dark:border-gray-800",children:[(0,n.jsxs)("a",{href:g.messages,className:"flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition no-underline text-sm text-inherit",children:[(0,n.jsx)("span",{children:"\uD83D\uDCAC"})," Messages",M>0&&(0,n.jsx)("span",{className:"bg-orange-500 text-white text-xs font-bold rounded-full px-2 py-0.5 min-w-[1.25rem] text-center",children:M})]}),(0,n.jsxs)("a",{href:g.connections,className:"flex items-center gap-2 px-3 py-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition no-underline text-sm text-inherit",children:[(0,n.jsx)("span",{children:"\uD83E\uDD1D"})," Connections"]})]})]})]})}function q(){let e="0.8.13",t="4432",a=e.includes("dev"),r=t?"".concat(e,"+").concat(t):e;return(0,n.jsxs)("a",{href:"".concat((0,s.Nb)("kernel"),"/build"),className:"text-xs hover:underline ".concat(a?"text-yellow-600":"text-gray-500"),children:[s.nX," ",r," \xb7 build ","1d73a86d".slice(0,7)]})}function _(e){let{className:t}=e,[a,l]=(0,r.useState)("/subscribe");return(0,r.useEffect)(()=>{let e=function(e){let t=e.split("/").find(Boolean);return t||"landing"}(globalThis.location.pathname);l("/subscribe?from=".concat(e))},[]),(0,n.jsxs)("div",{className:"flex flex-col items-center gap-2 ".concat(t||""),children:[(0,n.jsxs)("p",{className:"text-center text-sm text-gray-500",children:["Part of the"," ",(0,n.jsx)("a",{href:"https://imajin.ai",className:"text-orange-500 hover:underline",children:s.nX})," ","sovereign network"]}),(0,n.jsxs)("p",{className:"text-center text-sm text-gray-500",children:[(0,n.jsx)("a",{href:"https://app.dfos.com/j/c3rff6e96e4ca9hncc43en",className:"hover:underline",children:"Community"})," \xb7 ",(0,n.jsx)("a",{href:"https://github.com/ima-jin/imajin-ai",className:"hover:underline",children:"GitHub"})," \xb7 ",(0,n.jsx)("a",{href:"/privacy",className:"hover:underline",children:"Privacy"})," \xb7 ",(0,n.jsx)("a",{href:a,className:"hover:underline",children:"Subscribe"})]}),(0,n.jsx)(q,{})]})}function X(){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(l._,{}),(0,n.jsx)(i.wv,{}),(0,n.jsx)(o.p,{options:["Bold","Italic"]}),(0,n.jsx)(i.wv,{}),(0,n.jsx)(c.d,{}),(0,n.jsx)(i.wv,{}),(0,n.jsx)(d.I,{})]})}function G(e){let{value:t,onChange:a,placeholder:r,maxLength:s}=e;return(0,n.jsx)("div",{className:"rounded-lg border border-gray-600 overflow-hidden",style:{"--baseBg":"#1a1a1a","--basePageBg":"#1a1a1a","--baseTextContrast":"#e5e7eb","--baseText":"#d1d5db","--baseBorder":"#374151","--accentBase":"#f97316","--accentBgHover":"rgba(249,115,22,0.15)","--accentTextContrast":"#f97316"},children:(0,n.jsx)(u.R,{markdown:t,onChange:e=>{void 0!==s&&e.length>s||a(e)},placeholder:r,className:"dark-theme dark-editor",plugins:[(0,x.xO)({allowedHeadingLevels:[1,2,3]}),(0,g.Zq)(),(0,m.G)(),(0,h.O)(),(0,p.Mi)(),(0,f.r)(),(0,y.F7)({toolbarContents:X})]})})}var H={h1:e=>{let{children:t}=e;return(0,n.jsx)("h1",{className:"text-2xl font-bold mb-4 text-gray-900 dark:text-white",children:t})},h2:e=>{let{children:t}=e;return(0,n.jsx)("h2",{className:"text-xl font-bold mb-3 text-gray-900 dark:text-white",children:t})},h3:e=>{let{children:t}=e;return(0,n.jsx)("h3",{className:"text-lg font-semibold mb-2 text-gray-900 dark:text-white",children:t})},p:e=>{let{children:t}=e;return(0,n.jsx)("p",{className:"mb-4 leading-relaxed text-gray-700 dark:text-gray-200",children:t})},a:e=>{let{href:t,children:a}=e;return(0,n.jsx)("a",{href:t,className:"text-orange-500 dark:text-orange-400 hover:text-orange-600 dar
1k:hover:text-orange-300 underline",target:"_blank",rel:"noopener noreferrer",children:a})},ul:e=>{let{children:t}=e;return(0,n.jsx)("ul",{className:"list-disc list-inside mb-4 space-y-1 text-gray-700 dark:text-gray-200",children:t})},ol:e=>{let{children:t}=e;return(0,n.jsx)("ol",{className:"list-decimal list-inside mb-4 space-y-1 text-gray-700 dark:text-gray-200",children:t})},li:e=>{let{children:t}=e;return(0,n.jsx)("li",{className:"text-gray-700 dark:text-gray-200",children:t})},blockquote:e=>{let{children:t}=e;return(0,n.jsx)("blockquote",{className:"border-l-4 border-orange-500 pl-4 my-4 italic text-gray-500 dark:text-gray-400",children:t})},strong:e=>{let{children:t}=e;return(0,n.jsx)("strong",{className:"font-bold text-gray-900 dark:text-white",children:t})},em:e=>{let{children:t}=e;return(0,n.jsx)("em",{className:"italic text-gray-700 dark:text-gray-200",children:t})},code:e=>{let{children:t}=e;return(0,n.jsx)("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded text-sm font-mono text-orange-600 dark:text-orange-300",children:t})}};
1function J(e){let{content:t}=e;return(0,n.jsx)("div",{className:"prose dark:prose-invert max-w-none",children:(0,n.jsx)(b.oz,{components:H,children:t})})}function K(e){let{connectionsUrl:t,excludeDids:a=[],onSelect:s,placeholder:l="Search connections...",disabled:i=!1}=e,[o,c]=(0,r.useState)([]),[d,u]=(0,r.useState)(!0),[x,g]=(0,r.useState)(null),[m,h]=(0,r.useState)("");(0,r.useEffect)(()=>{fetch(t).then(e=>e.json()).then(e=>{c(e.connections||[]),u(!1)}).catch(()=>{g("Failed to load connections"),u(!1)})},[t]);let p=new Set(a),f=o.filter(e=>!p.has(e.did)),y=m?f.filter(e=>(e.handle||"").toLowerCase().includes(m.toLowerCase())||(e.name||"").toLowerCase().includes(m.toLowerCase())):f;return(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("input",{type:"text",value:m,onChange:e=>h(e.target.value),placeholder:l,disabled:i||d,className:"w-full px-3 py-2 text-sm border border-gray-600 rounded-lg bg-gray-900 text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-orange-500 disabled:opacity-50"}),d?(0,n.jsx)("p",{className:"text-sm text-gray-500 px-1",children:"Loading connections..."}):x?(0,n.jsx)("p",{className:"text-sm text-red-400 px-1",children:x}):0===y.length?(0,n.jsx)("p",{className:"text-sm text-gray-500 px-1",children:0===f.length?"No connections available.":"No matching connections."}):(0,n.jsx)("div",{className:"space-y-0 max-h-48 overflow-y-auto rounded-lg border border-gray-700 bg-gray-900",children:y.map(e=>(0,n.jsxs)("button",{type:"button",onClick:()=>{s(e),h("")},disabled:i,className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-gray-800 transition text-left disabled:opacity-50",children:[e.avatar?(0,n.jsx)("img",{src:e.avatar,alt:e.name||e.handle||e.did,className:"w-8 h-8 rounded-full object-cover flex-shrink-0"}):(0,n.jsx)("div",{className:"w-8 h-8 rounded-full bg-gray-700 flex items-center justify-center text-gray-400 text-sm font-semibold flex-shrink-0",children:(e.name||e.handle||e.did).charAt(0).toUpperCase()}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("div",{className:"text-sm font-medium text-white truncate",children:e.name||(e.handle?"@".concat(e.handle):e.did.slice(0,20)+"...")}),e.handle&&e.name&&(0,n.jsxs)("div",{className:"text-xs text-gray-400 truncate",children:["@",e.handle]})]})]},e.did))})]})}function W(e){let{open:t,onClose:a,title:s,children:l}=e;return((0,r.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&a()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,a]),t)?(0,n.jsxs)("div",{className:"fixed inset-0 z-[9998] flex items-end",children:[(0,n.jsx)("style",{children:"\n        @keyframes actionSheetSlideUp {\n          from { transform: translateY(100%); }\n          to { transform: translateY(0); }\n        }\n      "}),(0,n.jsx)("div",{className:"absolute inset-0 bg-black/60",onClick:a,"aria-hidden":"true"}),(0,n.jsxs)("dialog",{open:!0,"aria-modal":"true","aria-label":null!=s?s:"Actions",className:"static m-0 p-0 w-full text-inherit bg-gray-900 rounded-t-2xl border-0 border-t border-gray-700 max-h-[70vh] overflow-y-auto",style:{animation:"actionSheetSlideUp 0.25s ease-out"},children:[(0,n.jsx)("div",{className:"flex justify-center pt-3 pb-1",children:(0,n.jsx)("div",{className:"w-10 h-1 rounded-full bg-gray-600"})}),s&&(0,n.jsx)("div",{className:"px-5 py-2 border-b border-gray-700",children:(0,n.jsx)("p",{className:"text-sm font-medium text-gray-400 text-center",children:s})}),l]})]}):null}W.Reactions=function(e){let{emojis:t,onSelect:a}=e;return(0,n.jsx)("div",{className:"flex justify-around px-4 py-3 border-b border-gray-700",children:t.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>a(e),className:"w-11 h-11 flex items-center justify-center text-2xl hover:bg-gray-700 rounded-full transition","aria-label":e,children:e},e))})},W.Actions=function(e){let{children:t}=e;return(0,n.jsx)("div",{className:"border-b border-gray-700 last:border-b-0",children:t})},W.Action=function(e){let{icon:t,label:a,onPress:r,variant:s="default"}=e;return(0,n.jsxs)("button",{type:"button",onClick:r,className:"w-full flex items-center gap-3 px-5 py-3.5 text-left text-sm transition hover:bg-gray-800 ".concat("danger"===s?"text-red-400":"text-white"),children:[t&&(0,n.jsx)("span",{className:"text-lg w-6 text-center",children:t}),(0,n.jsx)("span",{children:a})]})};var $=r.forwardRef(function(e,t){let{className:a="",children:r,...s}=e;return(0,n.jsx)("div",{ref:t,className:"h-dvh flex flex-col overflow-hidden ".concat(a),...s,children:r})}),Y=r.forwardRef(function(e,t){let{className:a="",children:r,...s}=e;return(0,n.jsx)("div",{ref:t,className:"shrink-0 ".concat(a),...s,children:r})}),Z=r.forwardRef(function(e,t){let{className:a="",children:r,...s}=e;return(0,n.jsx)("div",{ref:t,className:"flex-1 min-h-0 overflow-auto ".concat(a),...s,children:r})}),Q=r.forwardRef(function(e,t){let{className:a="",children:r,...s}=e;return(0,n.jsx)("div",{ref:t,className:"shrink-0 ".concat(a),...s,children:r})}),ee=r.forwardRef(function(e,t){let{className:a="",children:r,...s}=e;return(0,n.jsx)("div",{ref:t,className:"flex-1 min-h-0 flex flex-row overflow-hidden ".concat(a),...s,children:r})}),et=r.forwardRef(function(e,t){let{width:a,className:r="",style:s,children:l,...i}=e,o=null==a?s:{width:a,...s};return(0,n.jsx)("div",{ref:t,className:"flex flex-col min-h-0 overflow-hidden ".concat(r),style:o,...i,children:l})});$.displayName="AppShell",Y.displayName="AppShell.Header",Z.displayName="AppShell.Body",Q.displayName="AppShell.Footer",ee.displayName="AppShell.Split",et.displayName="AppShell.Split.Pane";var ea=Object.assign($,{Header:Y,Body:Z,Footer:Q,Split:Object.assign(ee,{Pane:et})}),er=["creator","collaborator","producer","performer","platform","venue","distributor","label","other"];function en(e){let{did:t,profile:a,onClear:r,readOnly:s}=e,l=(null==a?void 0:a.name)||t.slice(0,16)+"…",i=null==a?void 0:a.handle,o=null==a?void 0:a.avatar,c=()=>{"undefined"!=typeof navigator&&navigator.clipboard&&navigator.clipboard.writeText(t).catch(()=>{})};return(0,n.jsxs)("div",{className:"relative flex-1 flex items-center gap-2 bg-[#1a1a1a] border border-gray-700 rounded px-2 py-1 min-w-0 cursor-pointer hover:border-gray-600 transition",title:t,children:[(0,n.jsx)("button",{type:"button",className:"absolute inset-0 z-0 w-full text-left",onClick:c,onKeyDown:e=>
1{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),c())},"aria-label":"Copy DID ".concat(t)}),o?(0,n.jsx)("img",{src:o,alt:"",className:"relative w-5 h-5 rounded-full object-cover flex-shrink-0"}):(0,n.jsx)("div",{className:"relative w-5 h-5 rounded-full bg-gray-700 flex items-center justify-center text-gray-400 text-[10px] font-semibold flex-shrink-0",children:l.charAt(0).toUpperCase()}),(0,n.jsx)("span",{className:"relative text-xs text-gray-200 truncate",children:l}),i&&(0,n.jsxs)("span",{className:"relative text-xs text-gray-500 truncate",children:["@",i]}),!s&&(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),r()},className:"relative ml-auto text-gray-600 hover:text-red-400 transition text-xs px-1",title:"Clear",type:"button",children:"✕"})]})}function es(e){let{connectionsUrl:t,onSelect:a,readOnly:s}=e,[l,i]=(0,r.useState)(""),[o,c]=(0,r.useState)(!1),[d,u]=(0,r.useState)([]),[x,g]=(0,r.useState)(!1),m=(0,r.useRef)(null),h=(0,r.useRef)(null);(0,r.useEffect)(()=>{t&&!(d.length>0)&&(g(!0),fetch(t).then(e=>e.json()).then(e=>{u((e.connections||[]).map(e=>({did:"string"==typeof e.did?e.did:"",name:"string"==typeof e.name&&e.name.length>0?e.name:null,handle:"string"==typeof e.handle&&e.handle.length>0?e.handle:null,avatar:"string"==typeof e.avatar&&e.avatar.length>0?e.avatar:null})))}).catch(()=>{u([])}).finally(()=>g(!1)))},[t,d.length]),(0,r.useEffect)(()=>{function e(e){m.current&&!m.current.contains(e.target)&&c(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);let p=l.trim().startsWith("did:"),f=(0,r.useMemo)(()=>{let e=l.trim().toLowerCase();return e?d.filter(t=>(t.handle||"").toLowerCase().includes(e)||(t.name||"").toLowerCase().includes(e)||t.did.toLowerCase().includes(e)):d},[l,d]),y=e=>{a(e),i(""),c(!1)},b=o&&(f.length>0||p||x);return(0,n.jsxs)("div",{ref:m,className:"flex-1 relative",children:[(0,n.jsx)("input",{ref:h,type:"text",value:l,onChange:e=>{i(e.target.value),c(!0)},onFocus:()=>c(!0),onKeyDown:e=>{if("Enter"===e.key){e.preventDefault();let t=l.trim();p?y(t):f.length>0&&y(f[0].did)}else"Escape"===e.key&&c(!1)},placeholder:t?"Search connections or paste DID…":"did:key:...",readOnly:s,className:"w-full bg-[#1a1a1a] border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-orange-500 read-only:opacity-60"}),b&&(0,n.jsx)("div",{className:"absolute z-10 top-full left-0 right-0 mt-1 bg-[#1a1a1a] border border-gray-700 rounded max-h-36 overflow-y-auto shadow-lg",children:x?(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-gray-500",children:"Loading…"}):(0,n.jsxs)(n.Fragment,{children:[p&&(0,n.jsxs)("button",{onClick:()=>y(l.trim()),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-[#252525] transition text-left",type:"button",children:[(0,n.jsx)("span",{className:"text-xs text-orange-400",children:"Use raw DID:"}),(0,n.jsx)("span",{className:"text-xs text-gray-300 truncate",children:l.trim()})]}),f.map(e=>(0,n.jsxs)("button",{onClick:()=>y(e.did),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-[#252525] transition text-left",type:"button",children:[e.avatar?(0,n.jsx)("img",{src:e.avatar,alt:"",className:"w-5 h-5 rounded-full object-cover flex-shrink-0"}):(0,n.jsx)("div",{className:"w-5 h-5 rounded-full bg-gray-700 flex items-center justify-center text-gray-400 text-[10px] font-semibold flex-shrink-0",children:(e.name||e.handle||e.did).charAt(0).toUpperCase()}),(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("span",{className:"text-xs text-gray-200 truncate",children:e.name||(e.handle?"@".concat(e.handle):e.did.slice(0,20)+"…")}),e.handle&&e.name&&(0,n.jsxs)("span",{className:"text-xs text-gray-500 ml-1",children:["@",e.handle]})]})]},e.did)),0===f.length&&!p&&(0,n.jsx)("div",{className:"px-3 py-2 text-xs text-gray-500",children:0===d.length?"No connections available.":"No matches."})]})})]})}function el(e){let{value:t,onChange:a,readOnly:s=!1,className:l="",defaultDid:i,showFixed:o=!1,connectionsUrl:c,resolveProfile:d}=e,[u,x]=(0,r.useState)({}),g=(0,r.useMemo)(()=>t.reduce((e,t)=>
1e+t.share,0),[t]),m=1e-6>=Math.abs(g-1),h=g>1.000001,p=(e,r)=>{a(t.map((t,a)=>a===e?{...t,...r}:t))};return(0,r.useEffect)(()=>{if(!d)return;let e=[...new Set(t.map(e=>e.did).filter(e=>!!e))].filter(e=>!(e in u));0!==e.length&&Promise.all(e.map(async e=>{try{let t=await d(e);return{did:e,profile:t}}catch(t){return{did:e,profile:null}}})).then(e=>{x(t=>{let a={...t};for(let{did:t,profile:r}of e)a[t]=r;return a})})},[d,t.map(e=>e.did).join(",")]),(0,n.jsxs)("div",{className:"space-y-3 ".concat(l),children:[t.map((e,r)=>{var l,i;return(0,n.jsxs)("div",{className:"bg-[#252525] rounded-lg p-3 space-y-2",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[e.did?(0,n.jsx)(en,{did:e.did,profile:null!=(l=u[e.did])?l:null,onClear:()=>p(r,{did:""}),readOnly:s}):(0,n.jsx)(es,{connectionsUrl:c,onSelect:e=>p(r,{did:e}),readOnly:s}),(0,n.jsx)("select",{value:e.role,onChange:e=>p(r,{role:e.target.value}),disabled:s,className:"bg-[#1a1a1a] border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-orange-500 disabled:opacity-60",children:er.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),!s&&(0,n.jsx)("button",{onClick:()=>{a(t.filter((e,t)=>t!==r))},className:"text-gray-600 hover:text-red-400 transition text-sm px-1",title:"Remove",type:"button",children:"✕"})]}),(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("input",{type:"range",min:0,max:100,step:.5,value:Math.round(1e3*e.share)/10,onChange:e=>p(r,{share:Number.parseFloat(e.target.value)/100}),disabled:s,className:"flex-1 accent-orange-500 disabled:opacity-60"}),(0,n.jsx)("input",{type:"number",min:0,max:100,step:.5,value:(100*e.share).toFixed(1),onChange:e=>p(r,{share:Number.parseFloat(e.target.value)/100}),readOnly:s,className:"w-16 bg-[#1a1a1a] border border-gray-700 rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-orange-500 text-right read-only:opacity-60"}),(0,n.jsx)("span",{className:"text-xs text-gray-500",children:"%"})]}),(0,n.jsx)("input",{type:"text",value:null!=(i=e.name)?i:"",onChange:e=>p(r,{name:e.target.value||void 0}),placeholder:"Name (optional)",readOnly:s,className:"w-full bg-[#1a1a1a] border border-gray-700 rounded px-2 py-1 text-xs text-gray-500 placeholder-gray-700 focus:outline-none focus:border-orange-500 read-only:opacity-60"})]},"".concat(e.role,"-").concat(e.did||"pending","-").concat(e.share))}),!s&&(0,n.jsx)("button",{onClick:()=>{a([...t,{did:null!=i?i:"",role:"collaborator",share:0}])},type:"button",className:"w-full py-1.5 rounded border border-dashed border-gray-700 text-xs text-gray-500 hover:border-orange-500 hover:text-orange-400 transition",children:"+ Add contributor"}),(0,n.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,n.jsxs)("span",{className:m?"text-gray-500":h?"text-red-400 font-medium":"text-orange-400 font-medium",children:["Total: ",(100*g).toFixed(1),"%",!m&&(0,n.jsx)("span",{className:"ml-1",children:h?"(must be ≤ 100%)":"(must equal 100%)"})]}),(0,n.jsxs)("span",{className:"text-gray-600",children:[t.length," ",1===t.length?"entry":"entries"]})]})]})}var ei=["USD","EUR","GBP","CAD","MJNX"],eo={USD:"$",EUR:"€",GBP:"\xa3",CAD:"C$",MJNX:"Ⓜ"};function ec(e){var t,a;let{value:s,onChange:l,readOnly:i=!1,className:o="",currencies:c=ei}=e,d=s?null!=(t=eo[s.currency])?t:s.currency:"$",u=(0,r.useMemo)(()=>{if(!s)return"";let e=(s.amount/100).toFixed(2);return"".concat(d).concat(e," ").concat(s.currency)},[s,d]);return(0,n.jsxs)("div",{className:"space-y-1 ".concat(o),children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsxs)("div",{className:"relative flex-1",children:[(0,n.jsx)("span",{className:"absolute left-2 top-1/2 -translate-y-1/2 text-xs text-gray-500 pointer-events-none",children:d}),(0,n.jsx)("input",{type:"text",inputMode:"decimal",value:s?(s.amount/100).toFixed(2):"",onChange:e=>{var t;let a=function(e){let t=Number.parseFloat(e.replaceAll(",",""));return Number.isNaN(t)||t<0?null:Math.round(100*t)}(e.target.value);if(null===a)return void l(void 0);l({amount:a,currency:null!=(t=null==s?void 0:s.currency)?t:c[0]})},placeholder:"0.00",readOnly:i,className:"w-full bg-[#1a1a1a] border border-gray-700 rounded pl-6 pr-2 py-1.5 text-xs text-gray-200 placeholder-gray-600 focus:outline-none focus:border-orange-500 read-only:opacity-60"})]}),(0,n.jsx)("select",{value:null!=(a=null==s?void 0:s.currency)?a:c[0],onChange:e=>{var t;let a=e.target.value,r=null!=(t=null==s?void 0:s.amount)?t:0;0!==r||s?l({amount:r,currency:a}):l(void 0)},disabled:i,className:"bg-[#1a1a1a] border border-gray-700 rounded px-2 py-1.5 text-xs text-gray-200 focus:outline-none focus:border-orange-500 disabled:opacity-60",children:c.map(e=>(0,n.jsx)("option",{value:e,children:e},e))})]}),s&&s.amount>0&&(0,n.jsx)("p",{className:"text-[10px] text-gray-500",children:u})]})}}}]);

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