module.exports=[76181,a=>{"use strict";var b=a.i(87924),c=a.i(72131);let d={id:void 0,name:"",description:"",greeting:"",gender:"",appearance:"",image_url:"",image_style:"anime",generated_images:[],background:"",personality:{dominant:50,kind:50,flirty:50,funny:50,intelligent:50,brave:50},step1_personality:void 0,voice_id:"",voice_archetype:void 0,visibility:"",chat_filter:"",communication_style:"roleplay",age:"",rank:0,is_edited:!1},e=(0,c.createContext)(void 0);function f({children:a}){let[f,g]=(0,c.useState)(d),[h,i]=(0,c.useState)(!1),[j,k]=(0,c.useState)(!1),l=(0,c.useRef)(!0);return(0,c.useEffect)(()=>{if(j)return;let a=localStorage.getItem("character_draft");if(a)try{let b=JSON.parse(a);b.is_edited?(console.log("[Context] Abandoned re-edit draft detected in localStorage — discarding to ensure clean slate."),localStorage.removeItem("character_draft")):(g({...d,...b,personality:{dominant:50,kind:50,flirty:50,funny:50,intelligent:50,brave:50,...b.personality||{}},voice_id:b.voice_id?b.voice_id.toString():"",visibility:b.visibility||"private",chat_filter:b.chat_filter||"filtered",communication_style:b.communication_style||"roleplay",age:b.age||18,rank:b.rank||0,is_edited:!1,...b.step1_personality?{step1_personality:b.step1_personality}:{}}),console.log("[Context] Restored new-character draft from localStorage"))}catch(a){console.error("[Context] Failed to parse draft:",a)}k(!0)},[j]),(0,c.useEffect)(()=>{if(!j)return;i(!0);let a=setTimeout(()=>{l.current=!1},100);return()=>clearTimeout(a)},[j]),(0,c.useEffect)(()=>{if(!h||l.current)return;let a=setTimeout(()=>{console.log("[Context] Persisting changes to localStorage");let a={...f,last_saved:new Date().toLocaleString()};localStorage.setItem("character_draft",JSON.stringify(a))},500);return()=>clearTimeout(a)},[f,h]),(0,b.jsx)(e.Provider,{value:{characterData:f,isInitialized:h,updateCharacter:a=>{g(b=>{let c=a.personality?{...b.personality,...a.personality}:b.personality,d=a.step1_personality?{...b.step1_personality||{},...a.step1_personality}:b.step1_personality;return{...b,...a,personality:c,step1_personality:d}})},resetCharacter:()=>{localStorage.removeItem("character_draft"),localStorage.removeItem("character_creation_progressed"),l.current=!0,g(d),i(!1),k(!1)}},children:a})}function g(){let a=(0,c.useContext)(e);if(!a)throw Error("useCharacterCreation must be used within CharacterCreationProvider");return a}a.s(["CharacterCreationProvider",()=>f,"useCharacterCreation",()=>g])},61876,a=>{"use strict";var b=a.i(87924),c=a.i(76181);function d({children:a}){return(0,b.jsx)(c.CharacterCreationProvider,{children:a})}a.s(["default",()=>d])}];

//# sourceMappingURL=_59b33864._.js.map