PageSourceSearch

https://ruleway.ai/_next/static/chunks/9109-954d489857241e42.js?dpl=dpl_3qHZcCAUujhyRCPwjQbJUgWwxb2m

js ruleway.ai collected 2026-10-05 15:48:26 UTC 37,770 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9109],{6671:(e,t,r)=>{r.d(t,{Ey:()=>l,ID:()=>n,Od:()=>s,mR:()=>a,p6:()=>i});let o=(0,r(46414).U)();async function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"kr";try{let{data:t,error:r}=await o.rpc("get_regulations",{});if(r)throw Error("failed to load regulation list: ".concat(r.message));if(!t||!Array.isArray(t))return console.warn("⚠️ data is empty or not an array:",{data:t,isArray:Array.isArray(t)}),[];return t.map(t=>{let r=t.regulation_code;return"en"===e&&t.regulation_name_en?r=t.regulation_name_en:"vi"===e&&t.regulation_name_vi?r=t.regulation_name_vi:"ja"===e&&t.regulation_name_ja?r=t.regulation_name_ja:t.regulation_name_kr&&(r=t.regulation_name_kr),{value:t.regulation_code,label:r}})}catch(e){throw console.error("\uD83D\uDCA5 failed to load active regulations:",e),e}}async function s(e){try{let{data:t,error:r}=await o.rpc("insert_conversation_message",{p_session_id:e.sessionId,p_user_id:e.userId,p_content:e.content,p_qa_type:e.qaType,p_regulation_code:e.regulationCode||void 0});if(r)throw console.error("error occurred while saving conversation message:",r),Error("failed to save conversation message: ".concat(r.message));return t||""}catch(e){throw console.error("error occurred while saving conversation message:",e),e}}async function n(e){try{var t;let{data:r,error:a}=await o.rpc("get_recent_conversations",{p_user_id:e.userId,p_page:e.page||1,p_page_size:e.pageSize||20});if(a)throw console.error("❌ error occurred while loading recent conversations:",a),a;if(!r||0===r.length)return{conversations:[],totalCount:0,hasMore:!1};let s=r.map(e=>({sessionId:e.session_id,firstQuestion:e.first_question,messageCount:e.message_count,isFavorite:e.is_favorite,createdAt:e.created_at,updatedAt:e.updated_at,formattedDate:e.formatted_date,totalCount:e.total_count})),n=(null==(t=r[0])?void 0:t.total_count)||0,i=e.page||1,l=e.pageSize||20;return{conversations:s,totalCount:n,hasMore:i*l<n}}catch(e){throw console.error("\uD83D\uDCA5 failed to load recent conversations:",e),e}}async function i(e,t){try{let{data:r,error:a}=await o.rpc("get_conversation_detail",{p_session_id:e,p_user_id:t});if(a)throw console.error("error occurred while loading conversation detail:",a),Error("failed to load conversation detail: ".concat(a.message));if(!r||!Array.isArray(r))throw Error("conversation history not found");let s=r.map(e=>({messageId:e.message_id,content:e.content,qaType:e.qa_type,displayOrder:e.display_order,createdAt:e.created_at})),n=r[0],i={sessionId:n.session_id,firstQuestion:n.first_question,messageCount:n.message_count,isFavorite:n.is_favorite,sessionCreatedAt:n.session_created_at,sessionUpdatedAt:n.session_updated_at};return{messages:s,sessionMetadata:i}}catch(e){throw console.error("error occurred while loading conversation detail:",e),e}}async function l(e,t){try{let{data:r,error:a}=await o.rpc("toggle_recent_favorite",{p_session_id:e,p_user_id:t});if(a)throw console.error("error occurred while toggling conversation favorite:",a),Error("failed to toggle conversation favorite: ".concat(a.message));if(!r||!Array.isArray(r)||0===r.length)throw Error("failed to get toggle result");let s=r[0];if(!s.success)throw Error(s.message);return s.is_favorite}catch(e){throw console.error("error occurred while toggling conversation favorite:",e),e}}},12308:(e,t,r)=>{r.d(t,{G3:()=>a,p9:()=>n});var o=r(46414);let a=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;try{let a=(0,o.U)(),{data:s,error:n}=await a.rpc("get_credit_history",{p_user_id:e,p_limit:t,p_offset:r});if(n)throw console.error("credit history get error:",n),Error("credit history get error");return{success:!0,data:s||[],pagination:{current_page:Math.floor(r/t)+1,page_size:t,total_count:s&&s.length>0?s[0].total_count:0,total_pages:s&&s.length>0?Math.ceil(s[0].total_count/t):0,has_next:!!s&&s.length>0&&r+t<s[0].total_count,has_prev:r>0}}}catch(e){return console.error("credit history get error:",e),{success:!1,data:[],pagination:{current_page:1,page_size:t,total_count:0,total_pages:0,has_next:!1,has_prev:!1},error:e instanceof Error?e.message:"unknown error"}}};class s{async reactivateSubscription(e){try{console.log("reactivateSubscription start: ".concat(e));let t=await fetch("/api/billing/lemon-squeezy/reactivate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subscriptionId:e})});if(!t.ok){let e=await t.json();
1throw Error(e.error||"구독 재활성화에 실패했습니다.")}let r=await t.json();return console.log("reactivateSubscription success:",r),r}catch(e){if(console.error("reactivateSubscription failed:",e),e instanceof Error)throw Error("Lemon Squeezy API error: ".concat(e.message));throw Error("reactivateSubscription error")}}async getSubscriptionInfo(e){try{let{data:t,error:r}=await this.supabase.rpc("get_subs_info",{p_user_id:e});if(r)throw console.error("getSubscriptionInfo error:",r),Error(r.message);if(!t||0===t.length)return null;let o=t[0],a="cancelled"===o.status||"paused"===o.status||"expired"===o.status?null:o.renews_at,s="cancelled"===o.status?"cancel":"paused"===o.status?"pause":null,n=null;"cancelled"===o.status?n=o.ends_at:"paused"===o.status&&o.pause_resumes_at&&(n=o.pause_resumes_at);let i={productName:o.product_name,nextBillingDate:a,status:o.status,scheduledChangeType:s,scheduledChangeEffectiveDate:n,chatCount:o.chat_count,chatBillingCount:o.chat_billing_count,chatRemainingBillingCount:o.chat_remaining_billing_count,chatAddCount:o.chat_add_count,chatRemainingAddCount:o.chat_remaining_add_count,chatUsedBillingCount:o.chat_used_billing_count,chatUsedAddCount:o.chat_used_add_count,pauseMode:o.pause_mode,pauseResumesAt:o.pause_resumes_at,cancelled:o.cancelled,endsAt:o.ends_at,storeId:o.store_id||null,customerId:o.customer_id||null,lemonProductId:o.lemon_product_id||null,variantId:o.variant_id||null,lemonSubscriptionId:o.lemon_subscription_id||null,subscriptionStatusFormatted:o.subscription_status_formatted||null};return console.log("\uD83D\uDD0D 구독 정보 조회 결과:",{userId:e,lemonSubscriptionId:i.lemonSubscriptionId,lemonProductId:i.lemonProductId,status:i.status,cancelled:i.cancelled}),i}catch(e){throw console.error("getSubscriptionInfo error:",e),e}}async getCreditUsageLogs(e,t,r,o){let a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:20;console.log("\uD83D\uDD0D getCreditUsageLogs called:",{userId:e,startDate:t,endDate:r,creditType:o,page:a,pageSize:s});try{let n={p_user_id:e,p_start_date:t?"".concat(t,"T00:00:00Z"):void 0,p_end_date:r?"".concat(r,"T23:59:59Z"):void 0,p_credit_type:o,p_page:a,p_page_size:s};console.log("\uD83D\uDCE1 getCreditUsageLogs RPC params:",n);let{data:i,error:l}=await this.supabase.rpc("get_credit_usage_log",n);if(console.log("\uD83D\uDCE5 getCreditUsageLogs RPC response:",{data:i,error:l}),l)throw console.error("❌ getCreditUsageLogs RPC error:",{error:l,code:l.code,message:l.message,details:l.details,hint:l.hint}),Error("RPC error: ".concat(l.message," (code: ").concat(l.code,")"));if(!i)throw console.error("❌ RPC null data returned"),Error("server did not return data");return console.log("✅ getCreditUsageLogs success:",i),i}catch(e){throw console.error("\uD83D\uDCA5 getCreditUsageLogs failed:",{error:e,message:e instanceof Error?e.message:"unknown error",stack:e instanceof Error?e.stack:void 0}),e}}constructor(){this.supabase=(0,o.U)()}}let n=new s},17908:(e,t,r)=>{r.d(t,{D:()=>a});var o=r(46414);let a={getUserProfile:async e=>{try{let{data:t,error:r}=await o.N.rpc("get_user_profiles",{p_user_id:e});if(alert("RPC 응답 데이터: "+JSON.stringify(t)),console.log("\uD83D\uDD34 User Profile RPC 원시 응답 데이터:",JSON.stringify(t,null,2)),console.log("\uD83D\uDD35 User Profile RPC 응답 데이터 분석:",{functionName:"get_user_profiles",hasData:!!t,isArray:Array.isArray(t),dataLength:Array.isArray(t)?t.length:0,dataKeys:t?Object.keys(Array.isArray(t)&&t.length>0?t[0]:t):[],firstItem:Array.isArray(t)&&t.length>0?t[0]:null}),r)return console.error("❌ User profile fetch error:",r),null;if(t&&Array.isArray(t)&&t.length>0){let e=t[0];return console.log("\uD83D\uDFE2 변환된 사용자 프로필 데이터:",{id:e.id,name:e.name,company:e.company,tax_code:e.tax_code,billing_country_code:e.billing_country_code,country_code:e.country_code,address_first_line:e.address_first_line,address_second_line:e.address_second_line,city:e.city,region:e.region,postal_code:e.postal_code}),console.log("\uD83D\uDFE3 사용자 프로필 모든 필드:",e),e}return null}catch(e){return console.error("User service error:",e),null}},updateProfile:async e=>{try{let a={p_user_id:e.userId,p_name:e.name||void 0,p_phone:e.phone||void 0,p_company:e.company||void 0,p_plan_id:e.planId||void 0,p_chat_count:e.chatCount||void 0,p_chat_add_count:e.chatAddCount||void 0,p_address_first_line:e.addressFirstLine||void 0,p_address_second_line:e.addressSecondLine||void 0,p_city:e.city||void 0,p_region:e.region||void 0,p_postal_code:e.postalCode||void 0,p_billing_country_code:e.billingCountryCode||void 0,p_country_code:e.countryCode||void 0,p_tax_code:e.taxCode||void 0};console.log("\uD83D\uDD35 RPC 입력 파라미터:",{functionName:"update_user_profiles",params:a,originalParams:e});let{data:s,error:n}=await o.N.rpc("update_user_profiles",a);if(console.log("\uD83D\uDD34 RPC 응답 결과:",{data:s,error:n,hasError:!!n,errorCode:null==n?void 0:n.code,errorMessage:null==n?void 0:n.message,errorDetails:null==n?void 0:n.details,errorHint:null==n?void 0:n.hint}),n)return console.error("❌ User profile update error:",n),{success:!1,message:"프로필 업데이트 실패: ".concat(n.message),error_code:n.code};if(console.log("✅ RPC 성공 응답:",s),s&&"object"==typeof s&&!Array.isArray(s)){var t,r;return{success:null==(t=s.success)||t,message:null!=(r=s.message)?r:"프로필이 성공적으로 업데이트되었습니다.",user_id:s.user_id,updated_fields:s.updated_fields,updated_at:s.updated_at,error_code:s.error_code}}return{success:!0,message:"프로필이 성공적으로 업데이트되었습니다."}}catch(e){return console.error("User service error:",e),{success:!1,message:"네트워크 오류가 발생했습니다."}}}}},33547:(e,t,r)=>{r.d(t,{L:()=>n});var o=r(65453),a=r(46786),s=r(53999);let n=(0,o.v)()((0,a.Zr)((e,t)=>({conversations:[],currentConversation:null,messages:[],isLoading:!1,isTyping:!1,streamingMessageId:null,statusMessage:null,isAdvancedMode:!1,advancedSettings:{transformType:1,outputFormat:1,aiWebSearch:0},chatMode:"agentic",agenticProgress:null,creditError:null,setConversations:t=>e({conversations:t}),setCurrentConversation:t=>e({currentConversation:t,messages:[]}),addConversation:t=>e(e=>({conversations:[t,...e.conversations]})),setMessages:t=>e({messages:t}),addMessage:t=>e(e=>({messages:[...e.messages,t]})),updateMessage:(t,r)=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,...r}:e)}
1)),setLoading:t=>e({isLoading:t}),setTyping:t=>e({isTyping:t}),clearMessages:()=>e({messages:[],agenticProgress:null,isAdvancedMode:!1,advancedSettings:{transformType:1,outputFormat:1,aiWebSearch:1}}),rateMessage:(e,r)=>{let{updateMessage:o}=t();o(e,{rating:r})},startStreamingMessage:t=>{let r=crypto.randomUUID(),o={id:r,conversationId:t,userId:"assistant",content:"",type:"assistant",createdAt:new Date().toISOString(),isStreaming:!0};return e(e=>({messages:[...e.messages,o],streamingMessageId:r})),r},updateStreamingMessage:(t,r)=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,content:e.content+r}:e)})),finishStreamingMessage:t=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,isStreaming:!1}:e),streamingMessageId:null})),setStatusMessage:t=>{console.log("[ChatStore] setStatusMessage called with:",t),e({statusMessage:t})},loadPreviousConversation:t=>{let{sessionId:r}=t.sessionMetadata;e({messages:t.messages.map(e=>{if("answer"!==e.qaType)return{id:e.messageId,conversationId:r,userId:"user",content:e.content,type:"user",createdAt:e.createdAt,isStreaming:!1};{let{processedContent:t,originalArtifactContent:o,artifactType:a}=(0,s.c)(e.content);return console.log("\uD83C\uDFA8 loadPreviousConversation - processMessageContent 결과:"),console.log("- 메시지 ID:",e.messageId),console.log("- 원본 내용 길이:",e.content.length),console.log("- processedContent 길이:",t.length),console.log("- originalArtifactContent 존재:",!!o),console.log("- originalArtifactContent 길이:",(null==o?void 0:o.length)||0),console.log("- artifactType:",a),{id:e.messageId,conversationId:r,userId:"assistant",content:t,type:"assistant",createdAt:e.createdAt,isStreaming:!1,originalContent:e.content,originalArtifactContent:o,artifactType:a}}})})},toggleAdvancedMode:()=>e(e=>({isAdvancedMode:!e.isAdvancedMode})),setAdvancedMode:t=>e({isAdvancedMode:t}),setAdvancedSettings:t=>e({advancedSettings:t}),resetAdvancedMode:()=>e({isAdvancedMode:!1,advancedSettings:{transformType:1,outputFormat:1,aiWebSearch:1}}),setChatMode:t=>e({chatMode:t}),setAgenticProgress:t=>e({agenticProgress:t}),setCreditError:t=>e({creditError:t}),clearCreditError:()=>e({creditError:null})}),{name:"chat-storage",partialize:e=>({})}))},46414:(e,t,r)=>{let o;r.d(t,{N:()=>n,U:()=>s});var a=r(43865);let s=()=>(0,a.createBrowserClient)("https://kcwjvfdoclkpdiqjzhmq.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imtjd2p2ZmRvY2xrcGRpcWp6aG1xIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzAzNTgwMTUsImV4cCI6MjA4NTkzNDAxNX0.AE12KTxCM9xGirP0YLz9V2fjLkg2jn7Ol2DftipMyhE"),n=new Proxy({},{get:(e,t,r)=>Reflect.get((o||(o=s()),o),t,r)})},52071:(e,t,r)=>{r.d(t,{n:()=>l});var o=r(65453),a=r(46786),s=r(78703),n=r(17908);let i=e=>{var t,r,o,a,s,n,i,l,c,d,u,g,p;return{id:e.id,email:e.email||"",name:(null==(t=e.user_metadata)?void 0:t.name)||e.email,phone:null==(r=e.user_metadata)?void 0:r.phone,company:null==(o=e.user_metadata)?void 0:o.company,role:(null==(a=e.user_metadata)?void 0:a.role)||"user",language:(null==(s=e.user_metadata)?void 0:s.language)||"ko",plan:(null==(n=e.user_metadata)?void 0:n.plan)||"FREE",plan_id:(null==(i=e.user_metadata)?void 0:i.plan_id)?Number(null==(l=e.user_metadata)?void 0:l.plan_id):void 0,credit:null==(c=e.user_metadata)?void 0:c.credit,chat_count:null==(d=e.user_metadata)?void 0:d.chat_count,chat_add_count:null==(u=e.user_metadata)?void 0:u.chat_add_count,subs_status:null==(g=e.user_metadata)?void 0:g.subs_status,paddle_customer_id:null==(p=e.user_metadata)?void 0:p.paddle_customer_id,createdAt:e.created_at||new Date().toISOString()}},l=(0,o.v)()((0,a.Zr)((e,t)=>({user:null,isAuthenticated:!1,isLoading:!1,rememberMe:!1,setUser:t=>e({user:t,isAuthenticated:!!t}),setLoading:t=>e({isLoading:t}),setRememberMe:t=>e({rememberMe:t}),login:async function(t,r){let o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];e({isLoading:!0});try{let{data:a,error:n}=await s.y.signIn(t,r);if(n)return{success:!1,error:n};if(a.user){let t=i(a.user);return e({user:t,isAuthenticated:!0,rememberMe:o,isLoading:!1}),{success:!0}}return{success:!1,error:"로그인에 실패했습니다."}}catch(e){return{success:!1,error:"네트워크 오류가 발생했습니다."}}finally{e({isLoading:!1})}},loginWithGoogle:async()=>{e({isLoading:!0});try{let{data:e,error:t}=await s.y.signInWithGoogle();if(t)return{success:!1,error:t.message};return{success:!0}}catch(e){return{success:!1,error:"구글 로그인에 실패했습니다."}}finally{e({isLoading:!1})}},signup:async(t,r,o,a,n,i,l,c)=>{e({isLoading:!0});try{let e={};o&&(e.name=o),a&&(e.phone=a),n&&(e.phone_country_code=n),i&&(e.country_code=i),l&&(e.company=l);let{data:d,error:u}=await s.y.signUp(t,r,e,c);if(u)return{success:!1,error:u};return{success:!0}}catch(e){return{success:!1,error:"회원가입에 실패했습니다."}}finally{e({isLoading:!1})}},sendOTP:async t=>{e({isLoading:!0});try{let{data:e,error:r}=await s.y.sendOTP(t);if(r)return{success:!1,error:r.message};return{success:!0}}catch(e){return{success:!1,error:"OTP 발송에 실패했습니다."}}finally{e({isLoading:!1})}},verifyOTP:async(t,r)=>
1{e({isLoading:!0});try{let{data:o,error:a}=await s.y.verifyOTP(t,r);if(a)return{success:!1,error:a.message};if(o.user){let t=i(o.user);return e({user:t,isAuthenticated:!0,isLoading:!1}),{success:!0}}return{success:!1,error:"OTP 인증에 실패했습니다."}}catch(e){return{success:!1,error:"OTP 인증에 실패했습니다."}}finally{e({isLoading:!1})}},logout:async()=>{e({isLoading:!0});try{await s.y.signOut(),e({user:null,isAuthenticated:!1,rememberMe:!1,isLoading:!1})}catch(e){console.error("logout error:",e)}finally{e({isLoading:!1})}},resetPassword:async t=>{e({isLoading:!0});try{let{data:e,error:r}=await s.y.resetPassword(t);if(r)return{success:!1,error:r.message};return{success:!0}}catch(e){return{success:!1,error:"비밀번호 재설정에 실패했습니다."}}finally{e({isLoading:!1})}},updateUserLanguage:r=>{let o=t().user;o&&(e({user:{...o,language:r}}),s.y.updateProfile({language:r}))},updateUserProfile:async r=>{let o=t().user;if(console.log("\uD83D\uDFE2 Auth Store - updateUserProfile 호출:",{params:r,currentUser:o?{id:o.id,email:o.email,name:o.name,phone:o.phone,company:o.company}:null}),!o)return console.error("❌ Auth Store - 사용자가 로그인되어 있지 않습니다."),{success:!1,error:"사용자가 로그인되어 있지 않습니다."};e({isLoading:!0});try{let t={userId:o.id,...r};console.log("\uD83D\uDD35 Auth Store - userService.updateProfile 호출:",t);let a=await n.D.updateProfile(t);if(console.log("\uD83D\uDD34 Auth Store - userService 응답:",a),!a.success)return console.error("❌ Auth Store - 업데이트 실패:",a.message),{success:!1,error:a.message};{let t={...o};if(void 0!==r.name&&(t.name=r.name),void 0!==r.phone&&(t.phone=r.phone),void 0!==r.company&&(t.company=r.company),void 0!==r.chatCount&&(t.chat_count=r.chatCount),void 0!==r.chatAddCount&&(t.chat_add_count=r.chatAddCount),void 0!==r.planId&&(t.plan_id=r.planId),console.log("✅ Auth Store - 로컬 사용자 정보 업데이트:",{before:o,after:t}),e({user:t}),void 0!==r.planId)try{console.log("\uD83D\uDD04 Auth Store - plan_id 변경으로 세션 새로고침 시작"),await s.y.updateProfile({plan_id:r.planId});let{data:o,error:a}=await s.y.refreshSession();if(a)console.error("❌ Auth Store - 세션 새로고침 실패:",a);else if(null==o?void 0:o.user){let r=i(o.user);console.log("✅ Auth Store - 세션 새로고침으로 사용자 정보 업데이트:",{before:t,after:r}),e({user:r})}else console.log("✅ Auth Store - Supabase Auth Session plan_id 업데이트 완료 (세션 새로고침 데이터 없음)")}catch(e){console.error("❌ Auth Store - 세션 새로고침 실패:",e)}return{success:!0}}}catch(e){return console.error("❌ Auth Store - 예외 발생:",e),{success:!1,error:"프로필 업데이트 중 오류가 발생했습니다."}}finally{e({isLoading:!1})}},initializeAuth:async()=>{e({isLoading:!0});try{let t=await s.y.getCurrentUser();if(t){let r=i(t);e({user:r,isAuthenticated:!0})}}catch(t){console.error("authentication initialization error:",t),t&&"object"==typeof t&&"code"in t&&("refresh_token_not_found"===t.code||"invalid_refresh_token"===t.code)&&(console.log("리프레시 토큰 오류 감지, 자동 로그아웃 처리"),e({user:null,isAuthenticated:!1,rememberMe:!1}))}finally{e({isLoading:!1})}}}),{name:"auth-storage",partialize:e=>({user:e.rememberMe?e.user:null,isAuthenticated:!!e.rememberMe&&e.isAuthenticated,rememberMe:e.rememberMe})}));s.y.onAuthStateChange((e,t)=>{let r=l.getState();if("SIGNED_IN"===e&&(null==t?void 0:t.user)){let e=i(t.user);r.setUser(e)}else if("SIGNED_OUT"===e)r.setUser(null);else if("TOKEN_REFRESHED"===e&&(null==t?void 0:t.user)){let e=i(t.user);r.setUser(e)}else"TOKEN_REFRESH_FAILED"===e&&(console.log("토큰 갱신 실패, 자동 로그아웃 처리"),r.setUser(null))})},73811:(e,t,r)=>{r.d(t,{nc:()=>o.n,iW:()=>f,Lo:()=>a.L,w1:()=>d.w,Hr:()=>l,P7:()=>h,lu:()=>c,j_:()=>i});var o=r(52071),a=r(33547),s=r(65453),n=r(46786);let i=(0,s.v)()((0,n.Zr)((e,t)=>({sidebarOpen:!1,language:"ko",theme:"system",isMobile:!1,isVoiceInputMode:!1,mobileDrawerOpen:!1,noticeModalOpen:!1,favoritesModalOpen:!1,recentQuestionsModalOpen:!1,billingModalOpen:!1,isChatMode:!1,faqModalOpen:!1,faqDrawerOpen:!1,myRegulationsModalOpen:!1,setSidebarOpen:t=>e({sidebarOpen:t}),toggleSidebar:()=>e(e=>({sidebarOpen:!e.sidebarOpen}
1)),setLanguage:t=>e({language:t}),setTheme:t=>e({theme:t}),setIsMobile:t=>e({isMobile:t}),setVoiceInputMode:t=>e({isVoiceInputMode:t}),setMobileDrawerOpen:t=>e({mobileDrawerOpen:t}),setNoticeModalOpen:t=>e({noticeModalOpen:t}),setFavoritesModalOpen:t=>e({favoritesModalOpen:t}),setRecentQuestionsModalOpen:t=>e({recentQuestionsModalOpen:t}),setBillingModalOpen:t=>e({billingModalOpen:t}),setChatMode:t=>e(e=>e.isChatMode===t?e:{isChatMode:t}),setFAQModalOpen:t=>e({faqModalOpen:t}),setFAQDrawerOpen:t=>e({faqDrawerOpen:t}),setMyRegulationsModalOpen:t=>e({myRegulationsModalOpen:t})}),{name:"ui-storage",partialize:e=>({language:e.language,theme:e.theme,sidebarOpen:e.sidebarOpen})})),l=(0,s.v)()((0,n.Zr)((e,t)=>({regulations:[],categories:[],favorites:[],loading:!1,initialLoading:!0,error:null,selectedCategory:null,loadedLanguage:null,lastLoadTime:null,cacheExpiry:3e6,setRegulations:t=>e({regulations:t}),setCategories:t=>e({categories:t}),setLoading:t=>e({loading:t}),setError:t=>e({error:t}),toggleFavorite:t=>e(e=>({favorites:e.favorites.includes(t)?e.favorites.filter(e=>e!==t):[...e.favorites,t]})),setSelectedCategory:t=>e({selectedCategory:t}),loadFAQs:async function(){let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"kr",a=!(arguments.length>1)||void 0===arguments[1]||arguments[1],s=t();if(s.isCacheValid(o)){console.log("✅ ".concat(o," FAQ 캐시 사용 - 데이터 개수:"),s.regulations.length,s.categories.length),e({loading:!1,initialLoading:!1,error:null});return}if(s.loading)return void console.log("⏳ ".concat(o," FAQ 이미 로딩 중 - 중복 호출 방지"));console.log("\uD83D\uDD04 ".concat(o," FAQ 데이터 로드 시작")),e({loading:!0,error:null});try{let{faqService:t}=await r.e(2609).then(r.bind(r,22609));console.log("\uD83D\uDD0D FAQ Store - Using fixed planId: ".concat(3));let[s,n]=await Promise.all([t.getFAQsByRegulation(o,a,3),t.getFAQsByCategory(o,a,3)]);s.length>0||n.length>0?(e({regulations:s,categories:n,loading:!1,initialLoading:!1,loadedLanguage:o,lastLoadTime:Date.now()}),console.log("✅ ".concat(o," FAQ 데이터 로드 완료 - 캐시 저장"))):(e({regulations:[],categories:[],loading:!1,initialLoading:!1,loadedLanguage:null,lastLoadTime:null}),console.log("⚠️ ".concat(o," FAQ 빈 데이터 - 캐시하지 않음")))}catch(t){console.error("FAQ failed to load:",t),e({error:t instanceof Error?t.message:"FAQ failed to load",loading:!1,initialLoading:!1})}},isCacheValid:e=>{let r=t();if(console.log("\uD83D\uDD0D 캐시 확인: ".concat(e),{loadedLanguage:r.loadedLanguage,lastLoadTime:r.lastLoadTime,timeDiff:r.lastLoadTime?Date.now()-r.lastLoadTime:null,cacheExpiry:r.cacheExpiry,regulationsCount:r.regulations.length,categoriesCount:r.categories.length}),r.loadedLanguage!==e)return console.log("❌ 언어 불일치: ".concat(r.loadedLanguage," !== ").concat(e)),!1;if(null===r.lastLoadTime)return console.log("❌ 로드 시간 없음"),!1;if(0===r.regulations.length&&0===r.categories.length)return console.log("❌ 빈 데이터 캐시 - 무효화"),!1;let o=Date.now()-r.lastLoadTime<r.cacheExpiry;return console.log("".concat(o?"✅":"❌"," 캐시 ").concat(o?"유효":"만료")),o},clearCache:()=>{console.log("\uD83D\uDDD1️ FAQ 캐시 클리어"),e({regulations:[],categories:[],loadedLanguage:null,lastLoadTime:null,loading:!1,initialLoading:!0,error:null})}}),{name:"faq-storage",partialize:e=>({favorites:e.favorites,loadedLanguage:e.loadedLanguage,lastLoadTime:e.lastLoadTime,cacheExpiry:e.cacheExpiry})})),c=(0,s.v)()((0,n.Zr)((e,t)=>({notices:[],selectedNotice:null,loading:!1,initialLoading:!0,error:null,filter:{title:"",category:"all"},setNotices:t=>e({notices:t}),setSelectedNotice:t=>e({selectedNotice:t}),setLoading:t=>e({loading:t}),setError:t=>e({error:t}),setFilter:t=>e(e=>({filter:{...e.filter,...t}})),resetFilter:()=>e({filter:{title:"",category:"all"}}),loadNotices:async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;e({loading:!0,error:null});try{let{noticeService:n}=await r.e(6609).then(r.bind(r,36609)),i=await n.getNotices(t,o,a,s);e({notices:i,loading:!1,initialLoading:!1})}catch(t){console.error("failed to load notices:",t),e({error:t instanceof Error?t.message:"failed to load notices",loading:!1,initialLoading:!1})}},loadPinnedNotices:async t=>{e({loading:!0,error:null});try{let{noticeService:o}=await r.e(6609).then(r.bind(r,36609)),a=await o.getPinnedNotices(t);e({notices:a,loading:!1,initialLoading:!1})}catch(t){console.error("failed to load pinned notices:",t),e({error:t instanceof Error?t.message:"failed to load pinned notices",loading:!1,initialLoading:!1})}},loadNoticesByType:async(t,o)=>{e({loading:!0,error:null});try{let{noticeService:a}=await r.e(6609).then(r.bind(r,36609)),s=await a.getNoticesByType(t,o);e({notices:s,loading:!1,initialLoading:!1})}catch(t){console.error("failed to load notices by type:",t),e({error:t instanceof Error?t.message:"failed to load notices by type",loading:!1,initialLoading:!1})}},getFilteredNotices:()=>{let{notices:e,filter:r}=t();return e.filter(e=>{let t=e.title.toLowerCase().includes(r.title.toLowerCase()),o="all"===r.category||""===r.category||e.notice_type===r.category;return t&&o})}}),{name:"notice-storage",partialize:e=>({filter:e.filter})}));var d=r(80274),u=r(46414);async function g(e){try{let{data:t,error:r}=await u.N.rpc("insert_favorite_question",{p_regulation_code:e.regulationCode||void 0,p_user_id:e.userId,p_question_content:e.questionContent});if(r)throw console.error("error occurred while saving favorite question:",r),Error("failed to save favorite question: ".concat(r.message));return t||""}catch(e){throw console.error("error occurred while saving favorite question:",e),e}}async function p(e){try{var t,r;let{data:o,error:a}=await u.N.rpc("get_favorite_questions",{p_user_id:e.userId,p_language:e.language||"ko",p_question_filter:e.questionFilter||void 0,p_category_filter:e.categoryFilter||void 0,p_page:e.page||1,p_page_size:e.pageSize||20});if(a)throw console.error("error occurred while loading favorite questions:",a),Error("failed to load favorite questions: ".concat(a.message));if(!o||0===o.length)return{items:[],totalCount:0,hasMore:!1};return{items:o.map(e=>({id:e.id,category:e.category,question:e.question,isActive:e.is_active,regulationCode:e.regulation_code,effectiveDate:e.effective_date,regulationLevelName:e.regulation_level_name,regulationCategoryName:e.regulation_category_name,sortOrder:e.sort_order,createdAt:e.created_at,totalCount:e.total_count,hasMore:e.has_more})),totalCount:(null==(t=o[0])?void 0:t.total_count)||0,hasMore:(null==(r=o[0])?void 0:r.has_more)||!1}}catch(e){throw console.error("getFavoriteQuestions 실행 중 오류:",e),e}}let h=(0,s.v)()((e,t)=>({isSaving:!1,lastError:null,lastSavedId:null,favorites:[],totalCount:0,hasMore:!1,isLoadingList:!1,listError:null,saveFavoriteQuestion:async t=>{try{e({isSaving:!0,lastError:null,lastSavedId:null});let r=await g(t);return e({isSaving:!1,lastSavedId:r,lastError:null}),!0}catch(t){return e({isSaving:!1,lastError:t instanceof Error?t.message:"error occurred while saving favorite question.",lastSavedId:null}),console.error("\uD83D\uDEA8 error occurred while saving favorite question:",t),!1}},clearError:()=>e({lastError:null}),clearLastSaved:()=>e({lastSavedId:null}),loadFavoriteQuestions:async t=>{try{e({isLoadingList:!0,listError:null});let r=await p(t);e({favorites:r.items,totalCount:r.totalCount,hasMore:r.hasMore,isLoadingList:!1})}catch(t){e({listError:t instanceof Error?t.message:"error occurred while loading favorite questions.",isLoadingList:!1,favorites:[],totalCount:0,hasMore:!1}),console.error("\uD83D\uDEA8 error occurred while loading favorite questions:",t)}},clearFavorites:()=>e({favorites:[],totalCount:0,hasMore:!1,listError:null})}));var _=r(12308);let v=(0,u.U)();async function m(e){let{data:t,error:r}=await v.rpc("get_plans_for_pricing",{language_code:e});if(r)throw Error(r.message);return t}let f=(0,s.v)((e,t)=>({subscriptionInfo:null,pricingPlans:null,creditUsageLogs:[],creditUsagePagination:null,creditUsageSummary:null,isLoading:!1,isPlansLoading:!1,isCreditUsageLoading:!1,error:null,fetchSub
1scriptionInfo:async t=>{e({isLoading:!0,error:null});try{let r=await _.p9.getSubscriptionInfo(t);e({subscriptionInfo:r,isLoading:!1,error:null})}catch(t){e({subscriptionInfo:null,isLoading:!1,error:t instanceof Error?t.message:"구독 정보를 불러오는데 실패했습니다."})}},fetchPricingPlans:async t=>{e({isPlansLoading:!0,error:null});try{let r=await m(t);e({pricingPlans:r,isPlansLoading:!1,error:null})}catch(t){e({pricingPlans:null,isPlansLoading:!1,error:t instanceof Error?t.message:"플랜 정보를 불러오는데 실패했습니다."})}},fetchCreditUsageLogs:async function(t,r,o,a){let s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1;console.log("\uD83C\uDFEA fetchCreditUsageLogs 시작:",{userId:t,startDate:r,endDate:o,creditType:a,page:s}),e({isCreditUsageLoading:!0,error:null});try{let n=await _.p9.getCreditUsageLogs(t,r,o,a,s,20);if(console.log("\uD83C\uDFEA billingService 응답:",n),n.success)console.log("✅ Store 상태 업데이트 성공:",{logsCount:n.data.logs.length,pagination:n.data.pagination,summary:n.data.summary}),e({creditUsageLogs:n.data.logs,creditUsagePagination:n.data.pagination,creditUsageSummary:n.data.summary,isCreditUsageLoading:!1,error:null});else throw console.error("❌ 응답 success가 false:",n),Error("크레딧 사용 내역을 불러오는데 실패했습니다.")}catch(t){console.error("\uD83D\uDCA5 fetchCreditUsageLogs 오류:",{error:t,message:t instanceof Error?t.message:"알 수 없는 오류",stack:t instanceof Error?t.stack:void 0}),e({creditUsageLogs:[],creditUsagePagination:null,creditUsageSummary:null,isCreditUsageLoading:!1,error:t instanceof Error?t.message:"크레딧 사용 내역을 불러오는데 실패했습니다."})}},loadMoreCreditUsageLogs:async(r,o,a,s)=>{let{creditUsagePagination:n,creditUsageLogs:i}=t();if(console.log("\uD83C\uDFEA loadMoreCreditUsageLogs 시작:",{userId:r,startDate:o,endDate:a,creditType:s,currentLogsCount:i.length,pagination:n}),!(null==n?void 0:n.has_next))return void console.log("⚠️ 다음 페이지가 없음");e({isCreditUsageLoading:!0});try{let t=n.current_page+1;console.log("\uD83D\uDCC4 다음 페이지 요청:",t);let l=await _.p9.getCreditUsageLogs(r,o,a,s,t,20);if(console.log("\uD83C\uDFEA loadMore billingService 응답:",l),l.success)console.log("✅ 더보기 데이터 추가 성공:",{existingCount:i.length,newCount:l.data.logs.length,totalCount:i.length+l.data.logs.length}),e({creditUsageLogs:[...i,...l.data.logs],creditUsagePagination:l.data.pagination,creditUsageSummary:l.data.summary,isCreditUsageLoading:!1,error:null});else throw console.error("❌ 더보기 응답 success가 false:",l),Error("크레딧 사용 내역을 불러오는데 실패했습니다.")}catch(t){console.error("\uD83D\uDCA5 loadMoreCreditUsageLogs 오류:",{error:t,message:t instanceof Error?t.message:"알 수 없는 오류",stack:t instanceof Error?t.stack:void 0}),e({isCreditUsageLoading:!1,error:t instanceof Error?t.message:"크레딧 사용 내역을 불러오는데 실패했습니다."})}},clearError:()=>{e({error:null})},reset:()=>{e({subscriptionInfo:null,pricingPlans:null,creditUsageLogs:[],creditUsagePagination:null,creditUsageSummary:null,isLoading:!1,isPlansLoading:!1,isCreditUsageLoading:!1,error:null})}}))},78703:(e,t,r)=>{r.d(t,{y:()=>s});var o=r(46414);class a{async signUp(e,t,r,o){console.log({email:e,password:t,userData:r});let a=window.location.origin,s=o?"".concat(a,"/auth/callback?next=").concat(encodeURIComponent(o)):"".concat(a,"/auth/callback"),{data:n,error:i}=await this.supabase.auth.signUp({email:e,password:t,options:{data:r,emailRedirectTo:s}});return{data:n,error:i}}async signIn(e,t){let{data:r,error:o}=await this.supabase.auth.signInWithPassword({email:e,password:t});return{data:r,error:o}}async signInWithGoogle(){let{data:e,error:t}=await this.supabase.auth.signInWithOAuth({provider:"google",options:{redirectTo:"".concat(window.location.origin,"/auth/callback")}});return{data:e,error:t}}async sendOTP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"signup",{data:r,error:o}=await this.supabase.auth.signInWithOtp({email:e,options:{shouldCreateUser:"signup"===t}});return{data:r,error:o}}async verifyOTP(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"signup",{data:o,error:a}=await this.supabase.auth.verifyOtp({email:e,token:t,type:"signup"===r?"email":"recovery"});return{data:o,error:a}}async signOut(){let{error:e}=await this.supabase.auth.signOut();return{error:e}}async getCurrentUser(){let{data:{user:e}}=await this.supabase.auth.getUser();return e}async resetPassword(e){let{data:t,error:r}=await this.supabase.auth.resetPasswordForEmail(e,{redirectTo:"".concat(window.location.origin,"/auth/reset-password")});return{data:t,error:r}}async updatePassword(e){let{data:t,error:r}=await this.supabase.auth.updateUser({password:e});return{data:t,error:r}}async updateProfile(e){let{data:t,error:r}=await this.supabase.auth.updateUser({data:e});return{data:t,error:r}}onAuthStateChange(e){return this.supabase.auth.onAuthStateChange(e)}async refreshSession(){try{let{data:e}=await this.supabase.auth.getSession();if(!(null==e?void 0:e.session))return console.log("⚠️ 세션이 없거나 만료되었습니다."),{data:null,error:{message:"Auth session missing or expired",code:"auth_session_missing"}};let{data:t,error:r}=await this.supabase.auth.refreshSession();return{data:t,error:r}}catch(e){return console.error("❌ 세션 새로고침 중 예외 발생:",e),{data:null,error:{message:"Failed to refresh session",originalError:e}}}}constructor(){this.supabase=(0,o.U)()}}let s=new a},80274:(e,t,r)=>{r.d(t,{w:()=>s});var o=r(65453),a=r(6671);let s=(0,o.v)()((e,t)=>({lastError:null,isInserting:!1,recentConversations:[],isLoadingRecents:!1,isLoadingMore:!1,recentConversationsError:null,currentPage:1,totalCount:0,hasMore:!1,conversationDetail:null,isLoadingDetail:!1,conversationDetailError:null,isTogglingFavorite:!1,insertMessage:async t=>{try{return e({isInserting:!0,lastError:null}),await (0,a.Od)(t),e({isInserting:!1}),!0}catch(t){return e({isInserting:!1,lastError:t instanceof Error?t.message:"error occurred while saving conversation."}),console.error("\uD83D\uDEA8 error occurred while inserting conversation message:",t),!1}},clearError:()=>e({lastError:null}),loadRecentConversations:async function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:20;try{e({isLoadingRecents:!0,recentConversationsError:null});let s=await (0,a.ID)({userId:t,page:r,pageSize:o});e({recentConversations:s.conversations,totalCount:s.totalCount,hasMore:s.hasMore,currentPage:r,isLoadingRecents:!1})}catch(t){e({isLoadingRecents:!1,recentConversationsError:t instanceof Error?t.message:"error occurred while loading recent conversations."}),console.error("\uD83D\uDEA8 error occurred while loading recent conversations:",t)}}
1,loadMoreRecentConversations:async r=>{let{currentPage:o,hasMore:s,isLoadingMore:n,isLoadingRecents:i}=t();if(s&&!n&&!i)try{e({isLoadingMore:!0,recentConversationsError:null});let t=o+1,s=await (0,a.ID)({userId:r,page:t,pageSize:20});e(e=>({recentConversations:[...e.recentConversations,...s.conversations],totalCount:s.totalCount,hasMore:s.hasMore,currentPage:t,isLoadingMore:!1}))}catch(t){e({isLoadingMore:!1,recentConversationsError:t instanceof Error?t.message:"error occurred while loading additional conversations."}),console.error("\uD83D\uDEA8 error occurred while loading additional conversations:",t)}},resetRecentConversations:()=>e({recentConversations:[],currentPage:1,totalCount:0,hasMore:!1,isLoadingMore:!1,recentConversationsError:null}),loadConversationDetail:async(t,r)=>{e({isLoadingDetail:!0,conversationDetailError:null,conversationDetail:null});try{let o=await (0,a.p6)(t,r);e({conversationDetail:o,isLoadingDetail:!1})}catch(t){e({isLoadingDetail:!1,conversationDetailError:t instanceof Error?t.message:"대화 내역을 불러올 수 없습니다."})}},clearConversationDetail:()=>e({conversationDetail:null,conversationDetailError:null}),toggleFavorite:async(t,r)=>{e({isTogglingFavorite:!0});try{let o=await (0,a.Ey)(t,r);e(e=>({recentConversations:e.recentConversations.map(e=>e.sessionId===t?{...e,isFavorite:o}:e),isTogglingFavorite:!1})),e(e=>({conversationDetail:e.conversationDetail?{...e.conversationDetail,sessionMetadata:{...e.conversationDetail.sessionMetadata,isFavorite:o}}:null}))}catch(t){console.error("error occurred while toggling favorite:",t),e({isTogglingFavorite:!1})}}}))},87691:(e,t,r)=>{r.d(t,{al:()=>a,tc:()=>s});var o=r(12115);function a(){var e="(max-width: 768px)";let[t,r]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{let t=window.matchMedia(e);r(t.matches);let o=e=>{r(e.matches)};return t.addEventListener("change",o),()=>{t.removeEventListener("change",o)}},[e]),t}function s(){let[e,t]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{t(!0)},[]),e}}}]);

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.