PageSourceSearch

https://storybookrpg.com/_next/static/chunks/5658-359a13c4831e0191.js

js storybookrpg.com collected 2026-10-09 22:59:52 UTC 30,670 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5658],{41022:(e,a,t)=>{"use strict";t.d(a,{$:()=>s});var r=t(12115);function s(e,a){(0,r.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;!(!(t instanceof Element)||t.closest('.sg-inspector, .cast-inspector, [role="dialog"]'))&&t.closest(".sg-app, .cast-workspace, .persona-workspace")&&(e.preventDefault(),e.stopPropagation(),a())};return document.addEventListener("click",t,!0),()=>document.removeEventListener("click",t,!0)},[e,a])}},48878:(e,a,t)=>{"use strict";t.d(a,{A:()=>o,C:()=>n});var r=t(62114);let s=e=>"/storybooks/".concat(encodeURIComponent(e),"/cast-network"),n={load:async(e,a)=>(await r.api.request({url:s(e),method:"GET",signal:a})).data,save:async(e,a,t)=>(await r.api.request({url:s(e),method:"PUT",data:{expected_revision:a,config:t}})).data.network,async detach(e,a){await r.api.request({url:"/storybooks/".concat(encodeURIComponent(e),"/characters/").concat(encodeURIComponent(a)),method:"DELETE"})},async attach(e,a){var t;let{data:s}=await r.api.request({url:"/storybooks/".concat(encodeURIComponent(e),"/characters"),method:"POST",data:{characterIds:[a]}});if(!s.results.success.includes(a))throw Error((null==(t=s.results.errors[0])?void 0:t.error)||"Unable to add character.")}},i=async(e,a,t,n)=>{let i=new URLSearchParams;for(let[e,a]of Object.entries(t||{}))void 0!==a&&""!==a&&i.set(e,String(a));return(await r.api.request({url:"".concat(s(e)).concat(a).concat(i.toString()?"?".concat(i):""),method:"GET",signal:n})).data},o={summary:(e,a)=>i(e,"/summary",void 0,a),roster:(e,a,t)=>i(e,"/roster",a,t),groups:(e,a,t)=>i(e,"/groups",a,t),character:(e,a,t)=>i(e,"/characters/".concat(encodeURIComponent(a)),void 0,t),memberships:(e,a,t,r)=>i(e,"/characters/".concat(encodeURIComponent(a),"/groups"),t,r),relationships:(e,a,t,r)=>i(e,"/characters/".concat(encodeURIComponent(a),"/relationships"),t,r),group:(e,a,t)=>i(e,"/groups/".concat(encodeURIComponent(a)),void 0,t),library:(e,a,t)=>i(e,"/library",a,t),async saveGroup(e,a){let{id:t,revision:n,name:i,kind:o,description:l,element_id:c}=a,d={name:i,kind:o,description:l,...c?{element_id:c}:{}};return(await r.api.request({url:"".concat(s(e),"/groups/").concat(encodeURIComponent(t)),method:"PUT",data:{...d,expected_revision:n}})).data.group},async deleteGroup(e,a){await r.api.request({url:"".concat(s(e),"/groups/").concat(encodeURIComponent(a.id)),method:"DELETE",data:{expected_revision:a.revision}})},membership:async(e,a,t,n)=>(await r.api.request({url:"".concat(s(e),"/groups/").concat(encodeURIComponent(a.id),"/members"),method:"POST",data:{expected_revision:a.revision,character_ids:t,action:n}})).data.group,async saveRelationship(e,a){let{id:t,revision:n,...i}=a;return(await r.api.request({url:"".concat(s(e),"/relationships/").concat(encodeURIComponent(t)),method:"PUT",data:{...i,expected_revision:n}})).data.relationship},async deleteRelationship(e,a){await r.api.request({url:"".concat(s(e),"/relationships/").concat(encodeURIComponent(a.id)),method:"DELETE",data:{expected_revision:a.revision}})}}},50399:()=>{},60101:(e,a,t)=>{"use strict";t.d(a,{s:()=>i});var r=t(62114);let s=e=>"/storybooks/".concat(encodeURIComponent(e),"/personas"),n=e=>{let a=new URLSearchParams;for(let[t,r]of Object.entries(e))void 0!==r&&""!==r&&a.set(t,String(r));return a.toString()?"?".concat(a):""},i={roster:async(e,a,t)=>(await r.api.request({url:"".concat(s(e)).concat(n(a)),method:"GET",signal:t})).data,library:async(e,a,t)=>(await r.api.request({url:"".concat(s(e),"/library").concat(n(a)),method:"GET",signal:t})).data,detail:async(e,a,t)=>(await r.api.request({url:"".concat(s(e),"/").concat(encodeURIComponent(a)),method:"GET",signal:t})).data.persona,attach:async(e,a)=>(await r.api.request({url:"".concat(s(e),"/").concat(encodeURIComponent(a),"/attach"),method:"POST"})).data,relationships:async(e,a,t,i)=>(await r.api.request({url:"".concat(s(e),"/").concat(encodeURIComponent(a),"/relationships").concat(n(t)),method:"GET",signal:i})).data,async saveRelationship(e,a){let{id:t,revision:n,...i}=a;return(await r.api.request({url:"".concat(s(e),"/relationships/").concat(encodeURIComponent(t)),method:"PUT",data:{...i,expected_revision:n}})).data},deleteRelationship:async(e,a)=>(await r.api.request({url:"".concat(s(e),"/relationships/").concat(encodeURIComponent(a.id)),method:"DELETE",data:{expected_revision:a.revision}})).data}},85658:(e,a,t)=>{"use strict";t.d(a,{A:()=>P});var r=t(95155),s=t(67155),n=t(98460),i=t(6784),o=t(52619),l=t.n(o),c=t(12115),d=t(47650),p=t(98211),u=t(32265),h=t(90109),m=t(26615),v=t
1(23748),x=t(21985),f=t(62114),j=t(60101),k=t(48878),g=t(44950),y=t(59317),b=t(26814),w=t(41022),N=t(18111);t(50399);let C=["allies","rivals","family","mentor","other"];function S(e){let{row:a}=e;return(0,r.jsx)("span",{className:"persona-workspace-portrait",children:a.avatar_url?(0,r.jsx)(v.A,{src:a.avatar_url,alt:"",width:42,height:48}):(0,r.jsx)(p.A,{size:19,"aria-hidden":"true"})})}function _(e){let{page:a,onPage:t}=e;return a?(0,r.jsxs)("div",{className:"persona-workspace-pagination",children:[(0,r.jsx)("span",{children:a.total?"".concat(a.offset+1,"–").concat(Math.min(a.offset+a.limit,a.total)," of ").concat(a.total):"0 results"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("button",{disabled:0===a.offset,onClick:()=>t(Math.max(0,a.offset-a.limit)),children:"Previous"}),(0,r.jsx)("button",{disabled:null===a.next_offset,onClick:()=>null!==a.next_offset&&t(a.next_offset),children:"Next"})]})]}):null}function E(e){let{resource:a}=e;return a.error?(0,r.jsxs)("p",{className:"persona-workspace-error",role:"alert",children:[a.error," ",(0,r.jsx)("button",{onClick:a.retry,children:"Retry"})]}):a.loading?(0,r.jsx)("p",{className:"persona-workspace-loading",role:"status",children:"Loading…"}):null}function P(e){let a=(0,x.$)();return(0,r.jsx)(R,{...e},"".concat(e.bookId,":").concat(a.epoch,":").concat(a.uid||"",":").concat(a.status))}function R(e){var a,t,o;let{bookId:l,editable:v,onDirtyChange:f,onBusyChange:k,onPreview:g,onPlaytest:N,itemNames:C=[]}=e,P=(0,x.$)(),R="authenticated"===P.status,[U,A]=(0,c.useState)(""),O=(0,b.F)(U),[q,F]=(0,c.useState)("all"),[G,L]=(0,c.useState)(0),[M,Y]=(0,c.useState)(0),[J,z]=(0,c.useState)(null),[B,$]=(0,c.useState)(!1),[H,K]=(0,c.useState)(!1),[W,V]=(0,c.useState)(null),[Q,X]=(0,c.useState)(""),Z=(0,c.useRef)(!1),ee=(0,c.useRef)(null),ea=v&&R&&!H,{access:et}=(0,n.x)(),er="owner"===et.role||"platform-admin"===et.role,es=(0,b.p)(e=>j.s.roster(l,{search:O,ownership:q,offset:G,limit:20},e),[l,O,q,G,P.epoch],R,M),en=(0,b.p)(async e=>(await s.x.list(l,e)).items,[l,P.epoch],R,M),ei=(null==J?void 0:J.type)==="persona"?(null==(a=es.data)?void 0:a.items.find(e=>e.id===J.persona.id))||J.persona:null,eo=(0,c.useRef)(null);
1function el(e){return!H&&(!B||!!window.confirm("Discard your unsaved changes?"))&&(z(e),$(!1),V(null),!0)}(0,c.useEffect)(()=>{let e=new URL(window.location.href),a=e.searchParams.get("persona");a&&(eo.current=a,e.searchParams.delete("persona"),window.history.replaceState(window.history.state,"",e))},[]),(0,c.useEffect)(()=>{var e;let a=eo.current;if(!a)return;if(J){eo.current=null;return}if(!es.data)return;let t=es.data.items.find(e=>e.id===a);if(t){eo.current=null,z({type:"persona",persona:t});return}if(!en.data)return;let r=null==(e=en.data.find(e=>e.id===a))?void 0:e.name;if(!r||O===r){eo.current=null;return}U!==r&&A(r)},[U,es.data,O,J,en.data]),(0,c.useEffect)(()=>L(0),[O,q]),(0,c.useEffect)(()=>{es.data&&G>0&&G>=es.data.total&&L(Math.max(0,20*Math.floor((es.data.total-1)/20)))},[G,es.data]),(0,c.useEffect)(()=>(null==f||f(B),()=>null==f?void 0:f(!1)),[B,f]),(0,c.useEffect)(()=>(null==k||k(H),()=>null==k?void 0:k(!1)),[H,k]),(0,c.useEffect)(()=>{let e=e=>{(B||H)&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[H,B]);let ec=!!J;async function ed(e,a,t){if(!Z.current){Z.current=!0,K(!0),V(null);try{await e(),$(!1),X(a),Y(e=>e+1),null==t||t()}catch(e){V((0,y.G0)(e))}finally{Z.current=!1,K(!1)}}}return(0,w.$)(ec,()=>el(null)),(0,c.useEffect)(()=>{var e;if(!ec)return;let a=document.activeElement;return null==(e=ee.current)||e.focus(),()=>{(null==a?void 0:a.isConnected)&&a.focus()}},[ec]),(0,c.useEffect)(()=>{if(!ec)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),el(null))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),(0,r.jsxs)("section",{className:"persona-workspace","aria-label":"Storybook Personas",children:[(0,r.jsxs)("header",{className:"persona-workspace-toolbar",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{children:"Personas"}),(0,r.jsx)("p",{children:"Starter Personas players can choose, and identities already participating in this world."})]}),(0,r.jsxs)("div",{className:"persona-workspace-actions",children:[(0,r.jsxs)("button",{className:"persona-workspace-primary",disabled:!ea,onClick:()=>el({type:"add"}),children:[(0,r.jsx)(u.A,{size:15})," Add persona"]}),(0,r.jsx)(i.Ay,{bookId:l,kind:"personas",disabled:!ea||B||H,onImported:()=>Y(e=>e+1)})]})]}),!v&&(0,r.jsx)("p",{className:"persona-workspace-note",children:"You have read-only access to this roster."}),Q&&(0,r.jsx)("p",{className:"persona-workspace-note",role:"status",children:Q}),W&&!J&&(0,r.jsx)("p",{className:"persona-workspace-error",role:"alert",children:W}),(0,r.jsxs)("div",{className:"persona-workspace-controls",children:[(0,r.jsxs)("label",{className:"persona-workspace-search",children:[(0,r.jsx)(h.A,{size:15,"aria-hidden":"true"}),(0,r.jsx)("input",{type:"search","aria-label":"Search attached personas",placeholder:"Search attached personas…",value:U,onChange:e=>A(e.target.value)})]}),(0,r.jsxs)("select",{"aria-label":"Filter personas by owner",value:q,onChange:e=>F(e.target.value),children:[(0,r.jsx)("option",{value:"all",children:"All attached personas"}),(0,r.jsx)("option",{value:"mine",children:"My personas"}),(0,r.jsx)("option",{value:"others",children:"Other members’ personas"})]})]}),(0,r.jsxs)("div",{className:"persona-workspace-table",children:[(0,r.jsxs)("div",{className:"persona-workspace-table-head",children:[(0,r.jsx)("span",{children:"PERSONA"}),(0,r.jsx)("span",{children:"PLACE IN THIS STORYBOOK"}),(0,r.jsx)("span",{children:"ACTIONS"})]}),(0,r.jsxs)("div",{className:"persona-workspace-rows",children:[(0,r.jsx)(E,{resource:es}),null==(t=es.data)?void 0:t.items.map(e=>(0,r.jsxs)("div",{className:"persona-workspace-row",children:[(0,r.jsxs)("button",{className:"persona-workspace-persona",onClick:()=>el({type:"persona",persona:e}),children:[(0,r.jsx)(S,{row:e}),(0,r.jsxs)("span",{children:[(0,r.jsx)("strong",{children:e.name}),(0,r.jsx)("small",{children:e.is_starter?["Starter persona",function(e){if(!("starting_kit"in e))return null;if(!e.starting_kit)return"Storybook kit";let a=e.starting_kit.items.length;return"Own kit \xb7 ".concat(a," ").concat(1===a?"item":"items")}
1(e)].filter(Boolean).join(" \xb7 "):e.is_owner?"Your reusable persona":"Member persona"})]})]}),(0,r.jsx)("span",{className:"persona-workspace-status",children:e.is_default?"Default starter":"active"===e.membership_status?"Active in this world":e.membership_status}),(0,r.jsxs)("div",{className:"persona-workspace-row-actions",children:[e.is_starter&&er&&!e.is_default&&(0,r.jsx)("button",{disabled:H,onClick:()=>void ed(()=>s.x.setDefault(l,e.id),"Default starter Persona updated."),children:"Set as default"}),e.is_starter&&N?(0,r.jsx)("button",{disabled:B||H,onClick:()=>N(e.id),children:"Playtest"}):e.can_preview&&g?(0,r.jsx)("button",{onClick:()=>g(e.id),children:"Preview stories"}):null,(0,r.jsx)("button",{onClick:()=>el({type:"persona",persona:e}),children:"Manage"})]})]},e.id)),(null==(o=es.data)?void 0:o.total)===0&&(0,r.jsxs)("div",{className:"persona-workspace-empty",children:[(0,r.jsx)(p.A,{size:25}),(0,r.jsx)("h3",{children:O||"all"!==q?"No matching personas":"No personas attached"}),(0,r.jsx)("p",{children:O||"all"!==q?"Try another name or owner filter.":"Attach one of your reusable personas to this Storybook."}),(O||"all"!==q)&&(0,r.jsx)("button",{onClick:()=>{A(""),F("all")},children:"Clear filters"})]})]}),(0,r.jsx)(_,{page:es.data,onPage:L})]}),J&&(0,d.createPortal)((0,r.jsxs)("aside",{ref:ee,tabIndex:-1,className:"persona-workspace-inspector cast-inspector","aria-label":"Persona inspector",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("h2",{children:"persona"===J.type?J.persona.name:"relationship"===J.type?"Relationship":"Add a persona"}),(0,r.jsx)("button",{"aria-label":"Close Persona inspector",disabled:H,onClick:()=>el(null),children:(0,r.jsx)(m.A,{size:18})})]}),(0,r.jsxs)("div",{className:"persona-workspace-inspector-body",children:[W&&(0,r.jsxs)("p",{className:"persona-workspace-error",role:"alert",children:[W,(0,r.jsx)("br",{}),"Your draft is still here. Retry or reload this item."]}),"persona"===J.type&&ei&&(0,r.jsx)(I,{bookId:l,row:ei,refresh:M,canManageWorld:ea,starters:en,itemNames:C,onDirty:$,onSaved:e=>{$(!1),Y(e=>e+1),X(e)},onError:e=>V((0,y.G0)(e)),onBusy:K,canPreview:!!g&&J.persona.can_preview,onPreview:()=>null==g?void 0:g(J.persona.id),onNewRelationship:()=>{var e;el({type:"relationship",persona:e=J.persona,targetName:"",draft:{id:crypto.randomUUID(),source:{type:"persona",id:e.id},target:{type:"character",id:""},kind:"allies",description:"",revision:0}})},onEditRelationship:e=>el({type:"relationship",persona:J.persona,targetName:e.source.id===J.persona.id?e.target.name:e.source.name,draft:{id:e.id,source:{type:e.source.type,id:e.source.id},target:{type:e.target.type,id:e.target.id},kind:e.kind,description:e.description,revision:e.revision}})},ei.id),"add"===J.type&&(0,r.jsx)(T,{bookId:l,canEdit:ea,refresh:M,created:J.created,onCreated:e=>z({type:"add",created:e}),onDirty:$,onBusy:K,onAttach:e=>void ed(()=>j.s.attach(l,e),"Starter Persona added to this Storybook.",()=>z(null)),onError:e=>V((0,y.G0)(e))}),"relationship"===J.type&&(0,r.jsx)(D,{bookId:l,selection:J,canEdit:ea,onChange:e=>{z(e),$(!0)},onSave:()=>void ed(()=>j.s.saveRelationship(l,J.draft),"Relationship saved in this Storybook.",()=>z({type:"persona",persona:J.persona})),onDelete:()=>void ed(()=>j.s.deleteRelationship(l,J.draft),"Relationship removed.",()=>z({type:"persona",persona:J.persona}))}),H&&(0,r.jsx)("p",{role:"status",children:"Saving…"}),B&&(0,r.jsx)("p",{className:"persona-workspace-pending",children:"Unsaved changes"})]})]}),document.body)]})}function I(e){var a,t,s,n,i,o,d,p;let{bookId:h,row:m,refresh:v,canManageWorld:x,starters:k,itemNames:w,onDirty:C,onSaved:P,onError:R,onBusy:I,canPreview:U,onPreview:T,onNewRelationship:D,onEditRelationship:O}=e,[q,F]=(0,c.useState)(""),G=(0,b.F)(q),[L,M]=(0,c.useState)(0),Y=(0,b.p)(e=>j.s.detail(h,m.id,e),[h,m.id],!0,v),J=(0,b.p)(e=>j.s.relationships(h,m.id,{search:G,offset:L,limit:10},e),[h,m.id,G,L],x,v),[z,B]=(0,c.useState)(""),[$,H]=(0,c.useState)(""),[K,W]=(0,c.useState)(!1),[V,Q]=(0,c.useState)(!1),X=m.is_starter&&"starting_kit"in m?null!=(p=m.starting_kit)?p:null:void 0,Z=JSON.stringify(X),[ee,ea]=(0,c.useState)(null),et=ee&&ee.over===Z?ee.kit:X,er=JSON.stringify(et),es=(0,b.p)(e=>y.EI.getWorld(h,e),[h],void 0!==et),en=null==(t=es.data)||null==(a=t.world)?void 0:a.definition,ei=et&&en?function(e,a){let t=[],r={};for(let[s,n]of Object.entries(e.trait_values)){let e=a.traits.find(e=>e.id===s),i=(null==e?void 0:e.scope)==="persona"?function(e,a){switch(e.type){case"rank":return e.levels.some(e=>e.id===a)?a:void 0;case"boolean":return"boolean"==typeof a?a:void 0;case"number":case"currency":return"number"==typeof a&&Number.isFinite(a)?a:void 0;case"text":var t;return"string"==typeof a&&(!(null==(t=e.allowed_values)?void 0:t.length)||e.allowed_values.includes(a))?a:void 0;case"unlock_set":return Array.isArray(a)?a.filter(a=>e.unlocks.some(e=>e.id===a)):void 0}}(e,n):void 0;void 0!==i&&(r[s]=i),JSON.stringify(i)!==JSON.stringify(n)&&t.push((null==e?void 0:e.name)||s)}let s=e.class_ids.filter(e=>{let r=a.classes.find(a=>a.id===e);return(null==r?void 0:r.scope)==="persona"||(t.push((null==r?void 0:r.name)||e),!1)});return{kit:t.length?{...e,trait_values:r,class_ids:s}:e,dropped:t}}(et,en):null,eo=JSON.stringify(ei?ei.kit:null!=et?et:null),[el,ec]=(0,c.useState)(null),ed=el&&el.seed===eo?el.kit:JSON.parse(eo),ep=x&&void 0!==et,eu=ep&&JSON.stringify(ed)!==er,eh=ed?(0,N.G$)(ed.items):null;(0,c.useEffect)(()=>{Y.data&&(B(Y.data.name),H(Y.data.description||""))},[Y.data]),(0,c.useEffect)(()=>M(0),[G]);let em=(e,a)=>{e(a),W(!0),C(!0)},ev=K&&!!(null==(s=Y.data)?void 0:s.is_owner);async function ex(){if(V||!ev&&!eu||ev&&!z.trim())return;Q(!0),I(!0);let e=!1;try{if(ev&&(await f.api.updatePersona(m.id,{name:z.trim(),description:$}),W(!1),e=!0),eu){let e=await g.ce.setPersonaKit(h,m.id,ed&&{...ed,items:(0,N.I0)(ed.items)});ea({over:Z,kit:e.starting_kit})}P(eu?e?"Profile and starting kit saved for ".concat(z.trim(),"."):"Starting kit saved for ".concat(z.trim()||m.name,"."):"Persona profile updated everywhere it is used.")}catch(a){R(e?Error("The profile saved;
1 the starting kit did not: ".concat((0,y.G0)(a))):a)}finally{Q(!1),I(!1)}}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"persona-workspace-profile-heading",children:[(0,r.jsx)(S,{row:m}),(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:m.name}),(0,r.jsx)("small",{children:m.is_owner?"Your reusable persona":"Profile owned by another member"})]})]}),U&&(0,r.jsx)("button",{className:"persona-workspace-primary persona-workspace-wide",onClick:T,children:"Preview their stories"}),(0,r.jsx)("h3",{children:"Reusable profile"}),(0,r.jsx)("p",{children:(null==(n=Y.data)?void 0:n.is_owner)?"Changes here apply wherever you use this persona.":"You can manage this persona’s place in the Storybook, but only its owner can change the profile."}),(0,r.jsx)(E,{resource:Y}),Y.data&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("label",{children:["Name",(0,r.jsx)("input",{"aria-label":"Name",value:z,disabled:!Y.data.is_owner||V,onChange:e=>em(B,e.target.value)})]}),(0,r.jsxs)("label",{children:["Description",(0,r.jsx)("textarea",{"aria-label":"Description",value:$,disabled:!Y.data.is_owner||V,onChange:e=>em(H,e.target.value)})]})]}),m.is_starter&&(0,r.jsx)(A,{name:(null==(i=Y.data)?void 0:i.name)||m.name,stored:et,world:es,dropped:ep&&(null==ei?void 0:ei.dropped)||[],starters:k,itemNames:w,kit:ed,editable:ep&&!V,onChange:e=>{ec({seed:eo,kit:e}),C(!0)}}),Y.data&&(Y.data.is_owner||ep)&&(0,r.jsxs)("div",{className:"persona-workspace-drawer-actions",children:[(0,r.jsx)("button",{className:"persona-workspace-primary",disabled:V||!ev&&!eu||ev&&!z.trim()||eu&&!!eh,onClick:()=>void ex(),children:"Save"}),Y.data.is_owner&&(0,r.jsx)(l(),{href:"/persona/".concat(encodeURIComponent(m.id),"/settings"),onClick:e=>{if((K||eu)&&!window.confirm("Discard your unsaved changes?"))return void e.preventDefault();W(!1),C(!1)},children:"Manage portrait and full profile ↗"})]}),(0,r.jsx)("hr",{}),(0,r.jsxs)("div",{className:"persona-workspace-section-heading",children:[(0,r.jsx)("h3",{children:"Relationships in this Storybook"}),x&&(0,r.jsxs)("button",{onClick:D,children:[(0,r.jsx)(u.A,{size:14})," Add"]})]}),(0,r.jsx)("p",{children:"Narrative relationships with characters and other personas."}),x?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("input",{"aria-label":"Search Persona relationships",placeholder:"Search relationships…",value:q,onChange:e=>F(e.target.value)}),(0,r.jsx)(E,{resource:J}),(0,r.jsxs)("div",{className:"persona-workspace-drawer-list",children:[null==(o=J.data)?void 0:o.items.map(e=>{let a=e.source.id===m.id?e.target:e.source;return(0,r.jsxs)("button",{onClick:()=>O(e),children:[(0,r.jsxs)("span",{children:[(0,r.jsx)("strong",{children:a.name}),(0,r.jsx)("small",{children:"persona"===a.type?"Persona":"Character"})]}),(0,r.jsx)("em",{children:e.kind})]},e.id)}),(null==(d=J.data)?void 0:d.total)===0&&(0,r.jsx)("p",{children:"No relationships yet."})]}),(0,r.jsx)(_,{page:J.data,onPage:M})]}):(0,r.jsx)("p",{className:"persona-workspace-note",children:"Relationship management is available to this Storybook’s cast managers."})]})}function U(e){var a,t,s;let{trait:n,value:i,disabled:o,onChange:l}=e,c="Default: ".concat((null==(t=n.initial)?void 0:t.mode)==="random"?"rolled when they join":"rank"===n.type?(null==(s=n.levels.find(e=>e.id===n.default_value))?void 0:s.label)||n.default_value:"boolean"===n.type?n.default_value?"Yes":"No":"unlock_set"===n.type?n.default_value.map(e=>{var a;return(null==(a=n.unlocks.find(a=>a.id===e))?void 0:a.label)||e}).join(", ")||"none":String(n.default_value));if("unlock_set"===n.type){let e=Array.isArray(i)?i:n.default_value;return(0,r.jsxs)("fieldset",{className:"persona-workspace-kit-trait",children:[(0,r.jsx)("legend",{children:n.name}),n.unlocks.map(a=>(0,r.jsxs)("label",{className:"persona-workspace-check",children:[(0,r.jsx)("input",{type:"checkbox",disabled:o,checked:e.includes(a.id),onChange:t=>l(t.target.checked?[...e,a.id]:e.filter(e=>e!==a.id))}),a.label]},a.id)),void 0!==i&&(0,r.jsx)("button",{type:"button",disabled:o,onClick:()=>l(void 0),children:"Use the default"})]})}let d="rank"===n.type?n.levels.map(e=>[e.id,e.label]):"boolean"===n.type?[["true","Yes"],["false","No"]]:"text"===n.type&&(null==(a=n.allowed_values)?void 0:a.length)?n.allowed_values.map(e=>[e,e]):null;if(d)return(0,r.jsxs)("label",{children:[n.name,(0,r.jsxs)("select",{"aria-label":n.name,value:void 0===i?"":String(i),disabled:o,onChange:e=>{let a=e.target.value;l(""===a?void 0:"boolean"===n.type?"true"===a:a)},children:[(0,r.jsx)("option",{value:"",children:c}),d.map(e=>{let[a,t]=e;return(0,r.jsx)("option",{value:a,children:t},a)})]})]});let p="number"===n.type||"currency"===n.type;return(0,r.jsxs)("label",{children:[n.name,(0,r.jsx)("input",{"aria-label":n.name,type:p?"number":"text",value:void 0===i?"":String(i),placeholder:c,disabled:o,onChange:e=>{let a=e.target.value;l(""===a?void 0:p?Number(a):a)}})]})}function A(e){var a,t,s,n,i,o,l;
1let c,{name:d,stored:p,world:u,dropped:h,starters:m,itemNames:v,kit:x,editable:f,onChange:j}=e,k=null==(t=u.data)||null==(a=t.world)?void 0:a.definition,g=((null==k?void 0:k.traits)||[]).filter(e=>"persona"===e.scope),y=((null==k?void 0:k.classes)||[]).filter(e=>"persona"===e.scope),b=(null==(l=u.data)||null==(o=l.world)||null==(i=o.settings)||null==(n=i.progression)||null==(s=n.starting_kit)?void 0:s.items)||[],w=[...v,...[...b,...(m.data||[]).flatMap(e=>{var a;return(null==(a=e.starting_kit)?void 0:a.items)||[]})].map(e=>e.name)];return c=void 0===p?(0,r.jsx)("p",{className:"persona-workspace-note",children:"Starting kits aren’t available from the server yet."}):u.error||u.loading?(0,r.jsx)(E,{resource:u}):x?(0,r.jsxs)(r.Fragment,{children:[h.length>0&&(0,r.jsxs)("p",{className:"persona-workspace-kit-stale",role:"note",children:[h.join(", ")," no longer ",1===h.length?"fits":"fit"," this world. Saving removes ",1===h.length?"it":"them"," from ",d,"’s kit."]}),(0,r.jsx)(N.Ay,{label:"".concat(d,"’s kit items"),items:x.items,knownItemNames:w,disabled:!f,emptyText:"".concat(d," starts with nothing."),onChange:e=>j({...x,items:e})}),g.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h4",{children:"Starting values"}),g.map(e=>(0,r.jsx)(U,{trait:e,value:x.trait_values[e.id],disabled:!f,onChange:a=>((e,a)=>{if(!x)return;let t={...x.trait_values};void 0===a?delete t[e]:t[e]=a,j({...x,trait_values:t})})(e.id,a)},e.id))]}),y.length>0&&(0,r.jsxs)("fieldset",{className:"persona-workspace-kit-trait",children:[(0,r.jsx)("legend",{children:"Classes"}),y.map(e=>(0,r.jsxs)("label",{className:"persona-workspace-check",children:[(0,r.jsx)("input",{type:"checkbox",disabled:!f,checked:x.class_ids.includes(e.id),onChange:a=>j({...x,class_ids:a.target.checked?[...x.class_ids,e.id]:x.class_ids.filter(a=>a!==e.id)})}),e.name]},e.id))]}),f&&(0,r.jsx)("button",{className:"persona-workspace-kit-reset",onClick:()=>j(null),children:"Use the storybook kit instead"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("p",{className:"persona-workspace-note",children:[d," uses the storybook kit."]}),b.length?(0,r.jsx)("ul",{className:"persona-workspace-kit-inherited","aria-label":"Storybook kit",children:b.map(e=>(0,r.jsxs)("li",{children:[(0,N.Sv)(e),e.note?(0,r.jsx)("small",{children:e.note}):null]},e.name))}):(0,r.jsx)("p",{className:"persona-workspace-kit-inherited",children:"The storybook kit is empty."}),f&&(0,r.jsxs)("button",{onClick:()=>j({items:b.map(e=>({name:e.name,count:e.count,note:e.note||""})),trait_values:{},class_ids:[]}),children:["Give ",d," their own kit"]})]}),(0,r.jsxs)("section",{"aria-label":"Starting kit",children:[(0,r.jsx)("hr",{}),(0,r.jsx)("h3",{children:"Starting kit"}),c,void 0!==p&&(0,r.jsxs)("p",{className:"persona-workspace-note",children:["Applies to players who choose ",d," from now on."]})]})}function T(e){var a,t;let{bookId:s,canEdit:n,refresh:i,created:o,onCreated:d,onDirty:p,onBusy:u,onAttach:h,onError:m}=e,[v,x]=(0,c.useState)(""),k=(0,b.F)(v),[g,y]=(0,c.useState)(0),[w,N]=(0,c.useState)(""),[C,P]=(0,c.useState)(""),[R,I]=(0,c.useState)(!1),U=(0,b.p)(e=>j.s.library(s,{search:k,offset:g,limit:10},e),[s,k,g,i],n);async function A(){if(w.trim()&&!R&&!o){I(!0),u(!0);try{let e=await f.api.createPersona({name:w.trim(),description:C});d(e.data),p(!1)}catch(e){m(e)}finally{I(!1),u(!1)}}}return((0,c.useEffect)(()=>{y(0)},[k]),o)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"persona-workspace-created",children:[(0,r.jsx)(S,{row:o}),(0,r.jsxs)("div",{children:[(0,r.jsx)("strong",{children:o.name}),(0,r.jsx)("p",{children:"Created in your reusable Persona library."})]})]}),(0,r.jsx)("p",{children:"If attaching failed, retry here. The Persona will not be created a second time."}),(0,r.jsx)("button",{className:"persona-workspace-primary persona-workspace-wide",disabled:!n,onClick:()=>h(o.id),children:"Attach to this Storybook"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"Choose one of your reusable personas. It remains available in every other part of Storybook RPG."}),(0,r.jsx)("input",{"aria-label":"Search your Persona library",placeholder:"Search your Persona library…",value:v,onCh
1ange:e=>x(e.target.value)}),(0,r.jsx)(E,{resource:U}),(0,r.jsxs)("div",{className:"persona-workspace-library",children:[null==(a=U.data)?void 0:a.items.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)(S,{row:e}),(0,r.jsxs)("span",{children:[(0,r.jsx)("strong",{children:e.name}),(0,r.jsx)("small",{children:"Your library"})]}),(0,r.jsx)("button",{className:"persona-workspace-primary",disabled:!n,onClick:()=>h(e.id),children:"Attach"})]},e.id)),(null==(t=U.data)?void 0:t.total)===0&&(0,r.jsx)("p",{children:"Every matching Persona is already attached."})]}),(0,r.jsx)(_,{page:U.data,onPage:y}),(0,r.jsx)("hr",{}),(0,r.jsx)("h3",{children:"Create a reusable Persona"}),(0,r.jsx)("p",{children:"Create the basic identity here. You can manage its portrait and complete profile afterward."}),(0,r.jsxs)("label",{children:["Name",(0,r.jsx)("input",{"aria-label":"Name",value:w,disabled:!n||R,onChange:e=>{N(e.target.value),p(!0)}})]}),(0,r.jsxs)("label",{children:["Description",(0,r.jsx)("textarea",{"aria-label":"Description",value:C,disabled:!n||R,onChange:e=>{P(e.target.value),p(!0)}})]}),(0,r.jsx)("button",{className:"persona-workspace-primary",disabled:!n||R||!w.trim(),onClick:()=>void A(),children:R?"Creating…":"Create Persona"}),(0,r.jsx)(l(),{href:"/persona/create",onClick:e=>{if(R||(w||C)&&!window.confirm("Discard your unsaved changes?"))return void e.preventDefault();p(!1)},children:"Open the full Persona creator ↗"})]})}function D(e){var a,t;let{bookId:s,selection:n,canEdit:i,onChange:o,onSave:l,onDelete:d}=e,[p,u]=(0,c.useState)(n.draft.target.type),[h,m]=(0,c.useState)(n.targetName),v=(0,b.F)(h),[x,f]=(0,c.useState)(0),g=(0,b.p)(e=>j.s.roster(s,{search:v,offset:x,limit:10},e),[s,v,x],"persona"===p),y=(0,b.p)(e=>k.A.roster(s,{search:v,offset:x,limit:10,sort:"name"},e),[s,v,x],"character"===p);(0,c.useEffect)(()=>f(0),[v,p]);let w="persona"===p?g:y,N="persona"===p?((null==(a=g.data)?void 0:a.items)||[]).map(e=>({type:"persona",id:e.id,name:e.name,avatar_url:e.avatar_url})):((null==(t=y.data)?void 0:t.items)||[]).map(e=>({type:"character",id:e.id,name:e.name||[e.first_name,e.last_name].filter(Boolean).join(" ")||"Unnamed character",avatar_url:e.avatar_url}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{children:"Relationships here are narrative context for this Storybook."}),(0,r.jsxs)("label",{children:["Connect to",(0,r.jsxs)("select",{"aria-label":"Connect to",value:p,disabled:n.draft.revision>0,onChange:e=>{let a=e.target.value;u(a),m(""),o({...n,targetName:"",draft:{...n.draft,target:{type:a,id:""}}})},children:[(0,r.jsx)("option",{value:"character",children:"Character"}),(0,r.jsx)("option",{value:"persona",children:"Persona"})]})]}),(0,r.jsx)("input",{"aria-label":"Search relationship targets",placeholder:"Search ".concat("persona"===p?"personas":"characters","…"),value:h,disabled:n.draft.revision>0,onChange:e=>{m(e.target.value),o({...n,targetName:e.target.value,draft:{...n.draft,target:{...n.draft.target,id:""}}})}}),0===n.draft.revision&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(E,{resource:w}),(0,r.jsx)("div",{className:"persona-workspace-target-list",children:N.filter(e=>"persona"!==e.type||e.id!==n.persona.id).map(e=>(0,r.jsxs)("button",{className:n.draft.target.id===e.id?"selected":"",onClick:()=>{o({...n,targetName:e.name,draft:{...n.draft,target:{type:e.type,id:e.id}}}),m(e.name)},children:[(0,r.jsx)(S,{row:e}),(0,r.jsx)("span",{children:e.name})]},e.id))}),(0,r.jsx)(_,{page:w.data,onPage:f})]}),n.draft.revision>0&&(0,r.jsxs)("p",{className:"persona-workspace-note",children:["Connected with ",n.targetName]}),(0,r.jsxs)("label",{children:["Relationship",(0,r.jsx)("select",{"aria-label":"Relationship",value:n.draft.kind,onChange:e=>o({...n,draft:{...n.draft,kind:e.target.value}}),children:C.map(e=>(0,r.jsx)("option",{value:e,children:"mentor"===e?"mentor / student":e},e))})]}),(0,r.jsxs)("label",{children:["Notes",(0,r.jsx)("textarea",{"aria-label":"Notes",value:n.draft.description,placeholder:"How do they know each other?",onChange:e=>o({...n,draft:{...n.draft,description:e.target.value}})})]}),(0,r.jsxs)("div",{className:"persona-workspace-drawer-actions",children:[(0,r.jsx)("button",{className:"persona-workspace-primary",disabled:!i||!n.draft.target.id,onClick:l,children:"Save relationship"}),n.draft.revision>0&&(0,r.jsx)("button",{className:"persona-workspace-danger",disabled:!i,onClick:()=>{window.confirm("Remove this relationship?")&&d()},children:"Remove"})]})]})}}}]);

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.