diff --git a/plugins/_bundled/sirsoft-pay_kginicis/dist/js/plugin.iife.js b/plugins/_bundled/sirsoft-pay_kginicis/dist/js/plugin.iife.js index 158395bf..0b93f32c 100644 --- a/plugins/_bundled/sirsoft-pay_kginicis/dist/js/plugin.iife.js +++ b/plugins/_bundled/sirsoft-pay_kginicis/dist/js/plugin.iife.js @@ -88,4 +88,3 @@ `),t.document.close()}function E(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}const D="sirsoft-pay_kginicis",we="__kginicisOrderShowInjectorInstalled",K="kginicis-mp-receipt-row",be=/^(?:\/mypage\/orders\/([^/]+)|\/shop\/guest\/orders\/([^/]+))$/,G=new Map;function Tt(e){try{const n=window.G7Core?.getState,i=n?.()?.currentDataContext?.order?.data;return i&&(i.order_number===e||i.id!==void 0&&String(i.id)===e)?i:null}catch{return null}}function xt(){const e=document.getElementById("order_payment_info_panel");if(e)return Array.from(e.children).find(r=>r.className?.includes("space-y"))??e;const t=Array.from(document.querySelectorAll("h3")).find(r=>{const o=r.textContent?.trim()??"";return o.includes("결제 정보")||/^Payment Information$/i.test(o)});if(!t)return null;const n=t.parentElement?.parentElement;return n?Array.from(n.children).find(r=>r.className?.includes("space-y"))??n:null}function Rt(e,t){if(!t)return!1;const n=Array.from(e.querySelectorAll("div"));for(const r of n){const o=Array.from(r.children).filter(a=>a instanceof HTMLElement&&a.tagName==="SPAN");if(o.length<2)continue;const i=o[0].textContent?.trim();if(i!=="결제 방법"&&i!=="결제수단"&&i!=="Payment Method")continue;const s=o[o.length-1];return s.textContent?.trim()===t?(r.dataset.kginicisPaymentMethodRow="true",!0):(s.textContent=t,s.dataset.kginicisPaymentMethodPatched="true",r.dataset.kginicisPaymentMethodRow="true",!0)}return!1}function Mt(e,t){const n=document.createElement("div");n.id=K,n.className="flex items-center justify-between",n.dataset.kginicisReceiptRow="mypage-order";const r=document.createElement("span");r.className="text-gray-500 dark:text-gray-400 text-sm",r.textContent=vt(t);const o=document.createElement("button");return o.type="button",o.dataset.kginicisReceiptButton="mypage-order",o.className="inline-flex items-center gap-1 text-sm text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",o.textContent=A(t),o.addEventListener("click",async()=>{o.disabled=!0,o.textContent="로딩 중...";const i=await v(e);o.disabled=!1,o.textContent=A(i??t),C(i)&&ge(i)}),n.appendChild(r),n.appendChild(o),n}async function Nt(e,t){const n=Tt(e),r=n?.payment;if(r&&(r.pg_provider!=="kginicis"||!r.transaction_id))return!0;const o=n?.order_number??(t?e:null);if(!o)return!1;if(!t&&n&&!r)return!0;const i=xt();if(!i)return!1;const{status:s,info:a}=await he(o);if(!t&&s===404)return!0;const c=r?.payment_status==="paid",u=a?.receipt_type==="cbt_confirmation";if(r&&!c&&!u)return!0;if(!r&&!C(a))return!1;const d=Rt(i,a?.payment_method_display_label);return!document.getElementById(K)&&C(a)&&(i.appendChild(Mt(o,a)),console.info(`[${D}] receipt button injected on mypage order show`)),d&&console.info(`[${D}] payment method display patched on mypage order show`),!!(document.getElementById(K)||d)}function Lt(e,t){if(G.has(e))return;let n=0;const r=window.setInterval(()=>{n++,Nt(e,t).then(o=>{(o||n>=30)&&(window.clearInterval(r),G.delete(e))})},400);G.set(e,r)}function Ot(){const e=location.pathname.match(be);if(e){const t=e[1],n=e[2],r=t??n;r&&Lt(r,n!==void 0)}}function $t(){if(typeof window>"u")return;const e=window;if(e[we])return;e[we]=!0,console.info(`[${D}] mypage order show injector installed`);let t=null;const n=(a=1500)=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null,Ot()},a)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>n()):n();const r=history.pushState.bind(history);history.pushState=(...a)=>{r(...a),n(600)};const o=history.replaceState.bind(history);history.replaceState=(...a)=>{o(...a),n(600)},window.addEventListener("popstate",()=>n(500));const i=document.getElementById("app")??document.body;new MutationObserver(()=>{be.test(location.pathname)&&n(250)}).observe(i,{childList:!0,subtree:!0})}const j="sirsoft-pay_kginicis",ke="__kginicisAdminPaymentDisplayInjectorInstalled",Dt=/^\/admin\/ecommerce\/orders\/([^/]+)$/;function Kt(){return localStorage.getItem("auth_token")}async function Gt(e){const t=Kt();if(!t)return null;try{const n=await fetch(`/api/plugins/${j}/admin/orders/${e}/transaction-status`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!n.ok)return null;const r=await n.json();return("data"in r?r.data:r)??null}catch{return null}}function jt(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function Yt(e,t){let n=!1;const r=Array.from(e.querySelectorAll("div"));for(const o of r){const i=jt(o),s=i.findIndex(l=>l.textContent?.trim()==="결제수단");if(s<0)continue;const a=i.slice(s+1).find(l=>l.textContent?.trim()&&l.textContent.trim()!=="결제수단");if(!a)continue;const c=i.slice(s+2).find(l=>/^\(.+\)$/.test(l.textContent?.trim()??"")),u=c?.textContent?.trim().replace(/^\(|\)$/g,"")??"",d=u&&t.endsWith(")")?t.replace(/\)$/,`, ${u})`):t;a.textContent?.trim()!==d&&(a.textContent=d,a.dataset.kginicisPaymentMethodPatched="true"),o.dataset.kginicisPaymentMethodRow="admin-order",c&&u&&(c.textContent="",c.style.display="none",c.dataset.kginicisPaymentInstallmentHidden="true"),n=!0}return n}function Bt(e,t,n){const o=Array.from(e.querySelectorAll("span")).filter(i=>i.textContent?.trim()===t).find(i=>{const s=typeof i.className=="string"?i.className:"";return s.includes("rounded-full")||s.includes("font-medium")});return o?(o.textContent=n,o.dataset.kginicisPaymentMethodPatched="true",o.dataset.kginicisPaymentMethodBadge="admin-order",!0):!1}function Ut(e,t){const n=t?._pay_method_label,r=t?._embedded_pg_provider_label,o=t?._base_pay_method_label;if(!n||!r)return!1;const i=Yt(e,n),s=o?Bt(e,o,r):!1;return i||s}async function Ht(e){const t=document.getElementById("section_payment_info")??document.getElementById("payment_info_card");if(!t)return!1;const n=await Gt(e);return n&&Ut(t,n)&&console.info(`[${j}] payment method display patched on admin order detail`),!0}function Jt(e){let t=0;const n=setInterval(()=>{t++,Ht(e).then(r=>{(r||t>=30)&&clearInterval(n)})},400)}function Ft(){const e=location.pathname.match(Dt);e&&Jt(e[1])}function qt(){if(typeof window>"u")return;const e=window;if(e[ke])return;e[ke]=!0,console.info(`[${j}] admin order payment display injector installed`);const t=(r=1500)=>setTimeout(Ft,r);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...r)=>{n(...r),t(600)},window.addEventListener("popstate",()=>t(500))}const Ce="sirsoft-pay_kginicis",Ee="__kginicisOcReceiptInjectorInstalled",Se="kginicis-oc-receipt-btn",Wt=/^\/shop\/orders\/([^/]+)\/complete$/;function Vt(){return localStorage.getItem("auth_token")}function zt(){try{const t=sessionStorage.getItem("g7_guest_order_token");if(t)return t}catch{}const e=window.G7Core?.state?.get?.("_global")?.guestOrderToken;return typeof e=="string"&&e!==""?e:null}async function Xt(e){const t=Vt(),n=zt();if(!t&&!n)return null;const r={Accept:"application/json"};t?r.Authorization=`Bearer ${t}`:n&&(r["X-Guest-Order-Token"]=n);try{const o=await fetch(`/api/modules/sirsoft-ecommerce/user/orders/${e}`,{headers:r});return o.ok?(await o.json())?.data?.payment??null:null}catch{return null}}function Zt(e){if(!e)return!1;const t=Array.from(document.querySelectorAll("div"));for(const n of t){const r=Array.from(n.children).filter(s=>s instanceof HTMLElement&&s.tagName==="SPAN");if(r.length<2)continue;const o=r[0].textContent?.trim();if(o!=="결제 방법"&&o!=="결제수단"&&o!=="결제 방식")continue;const i=r[r.length-1];return i.textContent?.trim()===e?(n.dataset.kginicisPaymentMethodRow="true",!0):(i.textContent=e,i.dataset.kginicisPaymentMethodPatched="true",n.dataset.kginicisPaymentMethodRow="true",!0)}return!1}async function Qt(e){if(document.getElementById(Se))return;const t=await v(e);if(!C(t))return;const n=await Xt(e);if(n){if(n.pg_provider!=="kginicis"||!n.transaction_id)return;const a=n.payment_status==="paid",c=t.receipt_type==="cbt_confirmation";if(!a&&!c)return}Zt(t.payment_method_display_label);const r=Array.from(document.querySelectorAll('button[type="button"]')).find(a=>a.className.includes("bg-blue-600"));if(!r?.parentElement)return;const o=r.parentElement;o.dataset.kginicisReceiptContainer="order-complete";const i=document.createElement("button");i.id=Se,i.type="button",i.dataset.kginicisReceiptButton="order-complete",i.className=r.className.replace(/bg-blue-\d+/g,"bg-green-600").replace(/hover:bg-blue-\d+/g,"hover:bg-green-700"),i.textContent=A(t),i.addEventListener("click",async()=>{i.disabled=!0,i.textContent="로딩 중...";const a=await v(e);i.disabled=!1,i.textContent=A(a??t),C(a)&&ge(a)});const s=o.lastElementChild;o.insertBefore(i,s),console.info(`[${Ce}] receipt button injected on order complete page`)}function en(){const e=location.pathname.match(Wt);e&&Qt(e[1])}function tn(){if(typeof window>"u")return;const e=window;if(e[Ee])return;e[Ee]=!0,console.info(`[${Ce}] order complete receipt injector installed`);const t=(r=1200)=>setTimeout(en,r);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...r)=>{n(...r),t()},window.addEventListener("popstate",()=>t(500))}const Pe="sirsoft-pay_kginicis",Ie="__kginicisVbankInfoInjectorInstalled",Y="kginicis-mp-vbank-info",nn=/^\/shop\/orders\/([^/]+)\/complete$/,rn=/^\/mypage\/orders\/([^/]+)$/,on=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+\-]\d{2}:\d{2}/,an={"03":"기업은행","04":"국민은행","05":"외환은행","07":"수협중앙회",11:"농협중앙회",20:"우리은행",23:"SC 제일은행",31:"대구은행",32:"부산은행",34:"광주은행",37:"전북은행",39:"경남은행",53:"한국씨티은행",71:"우체국",81:"하나은행",88:"신한은행",89:"케이뱅크",90:"카카오뱅크",92:"토스뱅크",D1:"동양종합금융증권",D2:"현대증권",D3:"미래에셋증권",D4:"한국투자증권",D5:"우리투자증권",D6:"하이투자증권",D7:"HMC 투자증권",D8:"SK 증권",D9:"대신증권",DA:"하나대투증권",DB:"굿모닝신한증권",DC:"동부증권",DD:"유진투자증권",DE:"메리츠증권",DF:"신영증권"};function sn(e){if(e.vbank_code)return String(e.vbank_code);const t=(e.vbank_name??"").trim();if(!t)return null;for(const[n,r]of Object.entries(an))if(r===t)return n;return null}function cn(){try{const t=window.G7Core?.getState;return t?.()?.currentDataContext?._global?.currentUser?.is_admin===!0}catch{return!1}}function ve(e){try{return new Date(e).toLocaleString("ko-KR",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",timeZone:"Asia/Seoul"})}catch{return e}}function dn(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t=[];let n=e.nextNode();for(;n;){const r=n.textContent??"",o=r.match(on);o&&t.push({node:n,formatted:r.replace(o[0],ve(o[0]))}),n=e.nextNode()}for(const{node:r,formatted:o}of t)r.textContent=o}function ln(e){try{const n=window.G7Core?.getState,i=n?.()?.currentDataContext?.order?.data;return!i||i.order_number!==e?null:i}catch{return null}}function un(){const e=document.getElementById("order_payment_info_panel");if(e)return Array.from(e.children).find(r=>r.className?.includes("space-y"))??e;const t=Array.from(document.querySelectorAll("h3")).find(r=>r.textContent?.includes("결제 정보"));if(!t)return null;const n=t.parentElement?.parentElement;return n?Array.from(n.children).find(r=>r.className?.includes("space-y"))??n:null}function _(e,t,n=!1){const r=document.createElement("div");r.className="flex items-center justify-between";const o=document.createElement("span");o.className="text-gray-500 dark:text-gray-400 text-sm",o.textContent=e;const i=document.createElement("span");return i.className=n?"text-sm font-medium text-blue-600 dark:text-blue-400":"text-sm text-gray-900 dark:text-gray-100",i.textContent=t,r.appendChild(o),r.appendChild(i),r}function mn(e,t){const n=document.createElement("div");n.id=Y,n.className="mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 space-y-2";const r=document.createElement("p");if(r.className="text-sm font-semibold text-gray-700 dark:text-gray-300",r.textContent="가상계좌 입금 안내",n.appendChild(r),e.vbank_name&&n.appendChild(_("은행",e.vbank_name)),cn()){const o=sn(e);o&&n.appendChild(_("은행코드",o))}return e.vbank_number&&n.appendChild(_("계좌번호",e.vbank_number)),e.vbank_holder&&n.appendChild(_("예금주",e.vbank_holder)),t&&n.appendChild(_("입금 기한",t,!0)),n}function g(e,t){return e?.receipt_fields?.find(n=>n.label===t)?.value??""}function fn(e,t){if(t?.receipt_type!=="cbt_confirmation")return!1;if(g(t,"결제수단").includes("편의점"))return!0;const r=String(e.transaction_id??"");return String(e.currency??"").toUpperCase()==="JPY"&&(String(e.vbank_name??"").toUpperCase()==="CVS"||r.startsWith("INIJPGCVS"))}function pn(e,t,n){const r=document.createElement("div");r.id=Y,r.className="mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 space-y-2";const o=document.createElement("p");o.className="text-sm font-semibold text-gray-700 dark:text-gray-300",o.textContent="일본 편의점 입금 안내",r.appendChild(o);const i=g(t,"입금 상태"),s=g(t,"입금예정금액")||g(t,"결제금액"),a=g(t,"편의점 코드"),c=g(t,"편의점 확인번호")||String(e.vbank_number??""),u=g(t,"편의점 접수번호"),d=g(t,"입금 마감일시")||n;return i&&r.appendChild(_("상태",i)),s&&r.appendChild(_("입금예정금액",s,!0)),a&&r.appendChild(_("편의점 코드",a)),c&&r.appendChild(_("편의점 확인번호",c)),u&&r.appendChild(_("편의점 접수번호",u)),d&&r.appendChild(_("입금 마감일시",d,!0)),r}async function yn(e){const t=ln(e);if(!t)return!1;const{payment:n}=t;if(!n||n.pg_provider!=="kginicis"||n.payment_status!=="waiting_deposit"||!n.vbank_number||document.getElementById(Y))return!0;const r=un();if(!r)return!1;const o=await v(e),i=n.vbank_due_at?ve(n.vbank_due_at):"";return r.appendChild(fn(n,o)?pn(n,o,i):mn(n,i)),console.info(`[${Pe}] vbank info injected on mypage`),!0}function _n(e){let t=0;const n=setInterval(()=>{t++,yn(e).then(r=>{(r||t>=30)&&clearInterval(n)})},400)}function hn(){if(location.pathname.match(nn)){setTimeout(dn,500);return}const t=location.pathname.match(rn);t&&_n(t[1])}function gn(){if(typeof window>"u")return;const e=window;if(e[Ie])return;e[Ie]=!0,console.info(`[${Pe}] vbank info injector installed`);const t=(r=800)=>setTimeout(hn,r);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...r)=>{n(...r),t(600)},window.addEventListener("popstate",()=>t(500))}const Ae="sirsoft-pay_kginicis",Te="__sirsoftKginicisCheckoutJpyPaymentMethodRestrictorInstalled",B=/^\/shop\/checkout\/?$/,wn="/api/modules/sirsoft-ecommerce/checkout",bn="/api/modules/sirsoft-ecommerce/settings/payment",kn="/api/modules/sirsoft-ecommerce/payments/client-config/kginicis",xe="__sirsoftKginicisCheckoutCurrency",U=new Set(["card","kginicis_japan_paypay","kginicis_japan_cvs"]),H=new Set(["kginicis_japan_paypay","kginicis_japan_cvs"]),Re=new Set(["card","vbank","dbank","bank","phone","kginicis_samsung_pay","kginicis_naverpay","kginicis_lpay","kginicis_kakaopay","kginicis_japan_paypay","kginicis_japan_cvs"]),Cn=[{id:"card",labels:["신용카드","Credit Card","クレジットカード"]},{id:"vbank",labels:["가상계좌","Virtual Account","バーチャル口座"]},{id:"dbank",labels:["무통장입금","Bank Transfer","銀行振込"]},{id:"bank",labels:["계좌이체","Account Transfer","口座振替"]},{id:"phone",labels:["휴대폰결제","Mobile Payment","携帯電話決済"]},{id:"kginicis_naverpay",labels:["네이버페이 (KG이니시스)","Naver Pay (KG Inicis)"]},{id:"kginicis_samsung_pay",labels:["삼성페이 (KG이니시스)","Samsung Pay (KG Inicis)"]},{id:"kginicis_lpay",labels:["L.pay (KG이니시스)","L.pay (KG Inicis)"]},{id:"kginicis_kakaopay",labels:["카카오페이 (KG이니시스)","Kakao Pay (KG Inicis)"]},{id:"kginicis_japan_paypay",labels:["PayPay (일본 KG이니시스)","PayPay (KG Inicis Japan)"]},{id:"kginicis_japan_cvs",labels:["일본 편의점결제 (KG이니시스)","Japan Convenience Store (KG Inicis)"]}],J={info:(...e)=>console.info(`[${Ae}]`,...e),warn:(...e)=>console.warn(`[${Ae}]`,...e)};let S=null,F=null,b=null;function q(){return window}function En(e){return typeof e=="string"?e:e instanceof URL?e.toString():typeof Request<"u"&&e instanceof Request?e.url:String(e)}function Sn(e,t){return t?.method?t.method.toUpperCase():typeof Request<"u"&&e instanceof Request?e.method.toUpperCase():"GET"}function Pn(e){try{return new URL(e,window.location.origin).pathname}catch{return e.split("?")[0].split("#")[0]}}function Me(e){if(typeof e!="string")return null;const t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function W(e,t){return t.split(".").reduce((n,r)=>{if(!(n===null||typeof n!="object"))return n[r]},e)}function In(e,t){for(const n of t){const r=Me(W(e,n));if(r)return r}return null}function vn(e){return In(e,["data.calculation.summary.selected_payment_currency","data.calculation.metadata.payment_currency","data.calculation.metadata.currency","data.currency","data.currency_code"])}function An(e){const t=vn(e);t&&(q()[xe]=t)}function Ne(){const e=q(),n=e.__templateApp?.globalState,r=[e[xe],n?.preferredCurrency];try{r.push(window.localStorage?.getItem("g7_preferred_currency"))}catch{}r.push(W(n,"modules.sirsoft-ecommerce.language_currency.default_currency"),W(n,"modules.sirsoft-ecommerce.language_currency.currencies.0.code"));for(const o of r){const i=Me(o);if(i)return i}return null}function V(){return B.test(window.location.pathname)&&Ne()==="JPY"}function z(){if(!B.test(window.location.pathname))return!1;const e=Ne();return e!==null&&e!=="JPY"}async function Le(e){return S!==null||(S=(async()=>{try{const t=await e(kn,{headers:{Accept:"application/json"}});return t.ok?(await t.json()).data?.japan_restrict_jpy_payment_methods===!0:!1}catch{return!1}})()),S}function Tn(e){const t=e.data?.order_settings?.payment_methods;return Array.isArray(t)?{...e,data:{...e.data,order_settings:{...e.data?.order_settings,payment_methods:t.map(n=>{const r=typeof n.id=="string"?n.id:"";return!Re.has(r)||U.has(r)?n:{...n,is_active:!1,_kginicis_restricted_for_jpy:!0}})}}}:e}function xn(e){const t=e.data?.order_settings?.payment_methods;return Array.isArray(t)?{...e,data:{...e.data,order_settings:{...e.data?.order_settings,payment_methods:t.map(n=>{const r=typeof n.id=="string"?n.id:"";return H.has(r)?{...n,is_active:!1,_kginicis_restricted_for_non_jpy:!0}:n})}}}:e}function Rn(e,t){const n=new Headers(e.headers);return n.set("Content-Type","application/json"),new Response(JSON.stringify(t),{status:e.status,statusText:e.statusText,headers:n})}function Mn(){const e=Array.from(document.querySelectorAll("h2")).find(n=>{const r=n.textContent??"";return r.includes("결제 수단")||r.includes("결제 방법")||r.includes("Payment Method")});if(!e)return null;let t=e.parentElement;for(;t&&t!==document.body;){if(t.tagName==="DIV"&&String(t.className).includes("rounded-lg"))return t;t=t.parentElement}return null}function Nn(e){const t=e.querySelector("p")?.textContent?.trim()??e.textContent?.trim()??"";for(const n of Cn)if(n.labels.some(r=>t.includes(r)))return n.id;return null}function X(){const e=V(),t=z();if(!e&&!t)return!1;const n=Mn();if(!n)return!1;let r=!1;if(n.querySelectorAll('button[type="button"]').forEach(o=>{const i=Nn(o);if(!i||!Re.has(i))return;if(e?U.has(i):!H.has(i)){o.style.removeProperty("display"),o.disabled=!1,o.removeAttribute("aria-hidden");return}o.style.display="none",o.disabled=!0,o.setAttribute("aria-hidden","true"),e?o.dataset.kginicisRestrictedForJpy="true":o.dataset.kginicisRestrictedForNonJpy="true",r=!0}),r)try{const i=window.G7Core?.state?.getLocal?.()?.paymentMethod;typeof i=="string"&&(e&&!U.has(i)||t&&H.has(i))&&window.G7Core?.state?.setLocal?.({paymentMethod:"card"})}catch{}return r}async function Oe(e){if(!B.test(window.location.pathname))return;const t=V(),n=z();if(!t&&!n||t&&!await Le(e))return;X(),F===null&&(F=new MutationObserver(()=>{X()}),F.observe(document.body,{childList:!0,subtree:!0})),b!==null&&clearInterval(b);let r=0;b=setInterval(()=>{r++,X(),r>=50&&b!==null&&(clearInterval(b),b=null)},200)}function $e(e){S=null,Oe(e)}function Ln(){if(typeof window>"u"||typeof window.fetch!="function")return;const e=q();if(e[Te])return;e[Te]=!0;const t=window.fetch.bind(window);window.fetch=async function(i,s){const a=En(i),c=Sn(i,s),u=Pn(a),d=await t(i,s);if(c==="GET"&&u.endsWith(wn)){try{const f=await d.clone().json();An(f)}catch{}return d}if(c!=="GET"||!u.endsWith(bn))return d;const l=V(),m=z();if(!l&&!m||l&&!await Le(t))return d;try{const f=await d.clone().json(),p=l?Tn(f):xn(f);return J.info(l?"restricted checkout payment methods for JPY order":"hid Japan-only payment methods for non-JPY order"),Rn(d,p)}catch(f){return J.warn("failed to restrict checkout payment methods",f),d}},J.info("checkout JPY payment method restrictor installed");const n=()=>{Oe(t)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n):n();const r=history.pushState.bind(history);history.pushState=(...o)=>{r(...o),setTimeout(()=>$e(t),200)},window.addEventListener("popstate",()=>setTimeout(()=>$e(t),200))}const On="sirsoft-pay_kginicis",De="__kginicisAdminPaymentMethodBrandInjectorInstalled",Ke="__kginicisAdminPaymentMethodBrandSyncListenerAttached",$n=/^\/admin\/ecommerce\/settings\/?$/,Ge='[data-kginicis-admin-payment-brand-mark="true"]',Dn=200,Kn=120,Gn=[{id:"kginicis_naverpay",labels:["네이버페이 (KG이니시스)","Naver Pay (KG Inicis)"],shortLabels:[],markLines:["N","Pay"],markClassName:"bg-green-500 text-white"},{id:"kginicis_samsung_pay",labels:["삼성페이 (KG이니시스)","Samsung Pay (KG Inicis)"],shortLabels:[],markLines:["S","Pay"],markClassName:"bg-blue-700 text-white"},{id:"kginicis_lpay",labels:["L.pay (KG이니시스)","L.pay (KG Inicis)"],shortLabels:[],markLines:["L","pay"],markClassName:"bg-red-600 text-white"},{id:"kginicis_kakaopay",labels:["카카오페이 (KG이니시스)","Kakao Pay (KG Inicis)"],shortLabels:[],markLines:["Kakao","Pay"],markClassName:"bg-yellow-400 text-gray-950"},{id:"kginicis_japan_paypay",labels:["PayPay (일본 KG이니시스)","PayPay (KG Inicis Japan)"],shortLabels:[],markLines:["Pay","Pay"],markClassName:"bg-red-600 text-white"},{id:"kginicis_japan_cvs",labels:["일본 편의점결제 (KG이니시스)","Japan Convenience Store (KG Inicis)"],shortLabels:[],markLines:["CVS","JP"],markClassName:"bg-blue-600 text-white"}];let je=null,T=null,Z=!1;function jn(){return window}function Q(){if(!$n.test(window.location.pathname))return!1;const e=new URLSearchParams(window.location.search).get("tab");return e===null||e===""||e==="order_settings"}function Yn(e){return e instanceof HTMLElement?e.className:""}function Ye(e){return(e??"").replace(/\u200B/g,"").replace(/\s+/g," ").trim()}function Bn(e){const t=Yn(e);return t.includes("excel-card")||t.includes("flex-center")&&t.includes("border")&&t.includes("gap-4")}function Be(e){return e.querySelector(".font-medium")}function Un(e){const t=Ye(Be(e)?.textContent),n=Ye(e.textContent);return Gn.find(r=>r.shortLabels.some(o=>t===o)||r.labels.some(o=>n.includes(o)))??null}function Hn(e){return Array.from(e.querySelectorAll("div")).filter(Bn)}function Jn(e){return Array.from(e.querySelectorAll("svg, [data-icon], i")).find(n=>!n.closest("[data-drag-handle]")&&!n.closest(Ge)&&!n.closest('.row-stack, .excel-card-body, button, select, [role="switch"]'))??null}function Ue(e,t){e.dataset.kginicisAdminPaymentBrandMark="true",e.dataset.kginicisAdminPaymentMethod=t.id,e.setAttribute("aria-hidden","true"),e.className=`inline-flex items-center justify-center rounded-lg font-bold ${t.markClassName}`,e.style.width="32px",e.style.height="32px",e.style.flex="0 0 32px",e.style.flexDirection="column",e.style.lineHeight="1",e.style.fontSize="9px";const n=t.markLines.join("");e.textContent!==n&&(e.replaceChildren(),t.markLines.forEach(r=>{const o=document.createElement("span");o.style.lineHeight="1",o.textContent=r,e.appendChild(o)}))}function Fn(e){const t=document.createElement("span");return Ue(t,e),t}function qn(e,t){const n=e.querySelector(Ge);if(n instanceof HTMLSpanElement)return e.dataset.kginicisAdminPaymentMethod=t.id,Ue(n,t),!0;const r=Fn(t),o=Jn(e);if(o&&o.parentElement)return e.dataset.kginicisAdminPaymentMethod=t.id,o.replaceWith(r),!0;const i=Be(e);return i&&i.parentElement?(e.dataset.kginicisAdminPaymentMethod=t.id,i.parentElement.insertBefore(r,i),!0):!1}function ee(e=document){if(typeof window>"u"||typeof document>"u"||!Q())return!1;let t=!1;return Hn(e).forEach(n=>{const r=Un(n);r&&qn(n,r)&&(t=!0)}),t}function Wn(){Z||(Z=!0,window.setTimeout(()=>{Z=!1,ee()},0))}function te(){T!==null&&(window.clearInterval(T),T=null)}function ne(){if(!Q())return;te(),ee();let e=0;T=window.setInterval(()=>{e+=1,ee(),e>=Kn&&te()},Dn);const t=document.body;t[Ke]||(t[Ke]=!0,je=new MutationObserver(()=>Wn()),je.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function He(){if(Q()){ne();return}te()}function Vn(){if(typeof window>"u"||typeof document>"u")return;const e=jn();if(e[De])return;e[De]=!0,console.info(`[${On}] admin payment method brand sync installed`),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>ne()):ne();const t=history.pushState.bind(history);history.pushState=(...n)=>{t(...n),window.setTimeout(()=>He(),200)},window.addEventListener("popstate",()=>window.setTimeout(()=>He(),200))}const k="sirsoft-pay_kginicis",re={info:(...e)=>console.info(`[${k}]`,...e),warn:(...e)=>console.warn(`[${k}]`,...e),error:(...e)=>console.error(`[${k}]`,...e)};function Je(){const e=window.G7Core;if(!e)return 0;const t=e.getActionDispatcher;if(typeof t!="function")return 0;const n=t();if(!n||typeof n.registerHandler!="function")return 0;let r=0;for(const[o,i]of Object.entries(ye)){const s=`${k}.${o}`;n.registerHandler(s,i,{category:"plugin",source:k}),r++}return r}function Fe(){const e=()=>{const t=Je();if(t>0){re.info(`${t} handler(s) registered`);return}let n=0;const r=50,o=setInterval(()=>{n++;const i=Je();if(i>0){clearInterval(o),re.info(`${i} handler(s) registered (after ${n} retries)`);return}n>=r&&(clearInterval(o),re.warn("ActionDispatcher not available after timeout"))},100)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}Et(),Ln(),$t(),qt(),Vn(),tn(),gn(),at(),Fe(),window.__SirsoftKginicis={identifier:k,handlers:Object.keys(ye),initPlugin:Fe}})(); -//# sourceMappingURL=plugin.iife.js.map diff --git a/plugins/_bundled/sirsoft-pay_nhnkcp/components.json b/plugins/_bundled/sirsoft-pay_nhnkcp/components.json index d4a939eb..b713834c 100644 --- a/plugins/_bundled/sirsoft-pay_nhnkcp/components.json +++ b/plugins/_bundled/sirsoft-pay_nhnkcp/components.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "identifier": "sirsoft-pay_nhnkcp", - "version": "1.0.0-beta.4", + "version": "1.0.0", "components": { "basic": [], "composite": [], diff --git a/plugins/_bundled/sirsoft-pay_nhnkcp/dist/js/plugin.iife.js b/plugins/_bundled/sirsoft-pay_nhnkcp/dist/js/plugin.iife.js index 2438c6db..4ccf9cfa 100644 --- a/plugins/_bundled/sirsoft-pay_nhnkcp/dist/js/plugin.iife.js +++ b/plugins/_bundled/sirsoft-pay_nhnkcp/dist/js/plugin.iife.js @@ -15,4 +15,3 @@ try { } <\/script> `),Q.close(),y=window.setTimeout(()=>{N(new Error("KCP SDK load timeout"))},15e3),f.__kcpReady=()=>{y!==void 0&&(clearTimeout(y),y=void 0)}})}const Xe={nhnkcp_payco:"PAYCO",nhnkcp_naverpay:"네이버페이",nhnkcp_naverpay_point:"네이버페이 포인트",nhnkcp_kakaopay:"카카오페이",nhnkcp_applepay:"Apple Pay"},Ze="0 0 0 2px #ffffff, 0 0 0 5px rgba(0,0,0,0.55)";function ne(){return document.querySelector(".nhnkcp-easy-pay-btns")??null}function oe(){const e=ne();e&&e.querySelectorAll("button").forEach(t=>{t.style.boxShadow="",t.style.outline=""})}function et(e){const t=ne();if(!t)return;const n=Xe[e];t.querySelectorAll("button").forEach(o=>{o.textContent?.trim()===n?(o.style.boxShadow=Ze,o.style.outline="none"):(o.style.boxShadow="",o.style.outline="")})}function tt(e){const t=e.params?.paymentMethod;if(!t)return;const n=window.G7Core;if(S(t)&&!x()){const r=M();n?.state?.setLocal?.({paymentErrorMessage:r,isSubmittingOrder:!1}),n?.modal?.open?.("nhnkcp_payment_error_modal"),oe();return}const o=typeof t=="string"&&t.startsWith("nhnkcp_");n?.state?.setLocal?.({paymentMethod:t}),o?et(t):oe()}function nt(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","readonly"),t.style.position="fixed",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.select();try{document.execCommand("copy")}finally{t.remove()}}async function ot(e){const t=String(e.params?.text??"");if(t!==""){if(navigator.clipboard&&typeof navigator.clipboard.writeText=="function"){await navigator.clipboard.writeText(t);return}nt(t)}}const re={requestPayment:Je,setPaymentMethod:tt,copyToClipboard:ot},ae="/api/modules/sirsoft-ecommerce/user/orders",$="sirsoft-pay_nhnkcp",se={info:(...e)=>console.info(`[${$}]`,...e),warn:(...e)=>console.warn(`[${$}]`,...e),error:(...e)=>console.error(`[${$}]`,...e)};function rt(e){return typeof e=="string"?e:e instanceof URL?e.toString():typeof Request<"u"&&e instanceof Request?e.url:String(e)}function at(e,t){return t?.method?t.method.toUpperCase():typeof Request<"u"&&e instanceof Request?e.method.toUpperCase():"GET"}function st(e,t){if(t!=="POST")return!1;const n=e.split("?")[0].split("#")[0];return n===ae||n.endsWith(ae)}function it(e){try{return JSON.parse(e).payment_method}catch{return}}function ct(e){return new Response(JSON.stringify({success:!1,message:e,error:e,errors:{payment_method:[e]}}),{status:422,statusText:"Unprocessable Content",headers:{"Content-Type":"application/json"}})}function dt(){if(typeof window>"u"||typeof window.fetch!="function")return;const e="__sirsoftNhnkcpInterceptorInstalled",t=window;if(t[e])return;t[e]=!0;const n=window.fetch.bind(window);window.fetch=async function(r,a){const s=rt(r),i=at(r,a);if(!st(s,i))return n(r,a);let c;if(a?.body&&typeof a.body=="string"&&(c=it(a.body)),S(c)&&!x()){const d=M();return se.warn(d),ct(d)}return n(r,a)},se.info("order request interceptor installed (Apple Pay device guard)")}const L="sirsoft-pay_nhnkcp",ie="__kcpOcReceiptInjectorInstalled",ce="kcp-oc-receipt-btn",lt=/^\/shop\/orders\/([^/]+)\/complete$/;function de(){return localStorage.getItem("auth_token")}async function ut(e){const t=de();if(!t)return null;try{const n=await fetch(`/api/modules/sirsoft-ecommerce/user/orders/${e}`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});return n.ok?(await n.json())?.data?.payment??null:null}catch{return null}}async function O(e){const t=de();if(!t)return null;try{const n=await fetch(`/api/plugins/${L}/user/orders/${e}/receipt`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});return n.ok?await n.json():null}catch{return null}}function le(e,t,n){const o=document.createElement("button");return o.type="button",o.className=t,o.textContent=e,o.addEventListener("click",()=>n(o)),o}function pt(e){if(!e)return!1;const t=Array.from(document.querySelectorAll("div"));for(const n of t){const o=Array.from(n.children).filter(s=>s instanceof HTMLElement&&s.tagName==="SPAN");if(o.length<2)continue;const r=o[0].textContent?.trim();if(r!=="결제 방법"&&r!=="결제수단"&&r!=="결제 방식")continue;const a=o[o.length-1];return a.textContent?.trim()===e?(n.dataset.nhnkcpPaymentMethodRow="true",!0):(a.textContent=e,a.dataset.nhnkcpPaymentMethodPatched="true",n.dataset.nhnkcpPaymentMethodRow="true",!0)}return!1}async function mt(e){if(document.getElementById(ce))return;const t=await ut(e);if(!t||t.pg_provider!=="nhnkcp"||!t.transaction_id||!t.paid_at)return;const n=Array.from(document.querySelectorAll('button[type="button"]')).find(c=>c.className.includes("bg-blue-600"));if(!n?.parentElement)return;const o=await O(e);pt(o?.payment_method_display_label);const r=n.parentElement,a=le("영수증 조회",n.className.replace(/bg-blue-\d+/g,"bg-green-600").replace(/hover:bg-blue-\d+/g,"hover:bg-green-700"),async c=>{c.disabled=!0,c.textContent="로딩 중...";const d=await O(e);if(c.disabled=!1,c.textContent="영수증 조회",d){const l=window.KcpReceiptPopup;l&&new l({url:d.receipt_url??void 0})}});a.id=ce;const s=r.lastElementChild;r.insertBefore(a,s);const i="kcp-oc-cash-receipt-btn";if(!document.getElementById(i)&&(t.payment_method==="vbank"||t.payment_method==="bank_transfer")){const c=le("현금영수증 조회",a.className.replace(/bg-green-\d+/g,"bg-teal-600").replace(/hover:bg-green-\d+/g,"hover:bg-teal-700"),async d=>{d.disabled=!0,d.textContent="로딩 중...";const l=await O(e);if(d.disabled=!1,d.textContent="현금영수증 조회",l){const u=window.KcpReceiptPopup;u&&new u({cash_url:l.cash_receipt_url??void 0})}});c.id=i,r.insertBefore(c,s)}console.info(`[${L}] receipt button injected on order complete page`)}function ft(){const t=location.pathname.match(lt);t&&mt(t[1])}function yt(){if(typeof window>"u")return;const e=window;if(e[ie])return;e[ie]=!0,console.info(`[${L}] order complete receipt injector installed`);const t=(o=1200)=>setTimeout(ft,o);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...o)=>{n(...o),t()},window.addEventListener("popstate",()=>t(500))}const _="sirsoft-pay_nhnkcp",ue="__kcpMpShowInjectorInstalled",K="kcp-mp-vbank-row",j="kcp-mp-receipt-row",v="kcp-mp-mock-deposit",ht=/^\/mypage\/orders\/([^/]+)$/;function _t(e){try{const n=window.G7Core?.getState,a=n?.()?.currentDataContext?.order?.data;return!a||a.order_number!==e?null:a}catch{return null}}function pe(){return localStorage.getItem("auth_token")}async function me(e){const t=pe();if(!t)return null;try{const n=await fetch(`/api/plugins/${_}/user/orders/${e}/receipt`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});return n.ok?await n.json():null}catch{return null}}async function fe(e){const t=pe();if(!t)return null;try{const n=await fetch(`/api/plugins/${_}/user/orders/${e}/vbank-mock-deposit-info`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});return n.ok?await n.json():null}catch{return null}}function ye(e){const t=document.createElement("div");t.id=v,t.className="pt-4 mt-2 border-t border-dashed border-orange-300 dark:border-orange-700";const n=document.createElement("div");n.className="flex items-center gap-2 mb-3";const o=document.createElement("span");o.className="inline-flex items-center px-2 py-0.5 rounded text-xs font-bold bg-orange-100 text-orange-700 dark:bg-orange-900/40 dark:text-orange-300 border border-orange-300 dark:border-orange-700",o.textContent="TEST";const r=document.createElement("p");r.className="text-sm font-semibold text-orange-700 dark:text-orange-300",r.textContent="모의입금처리",n.appendChild(o),n.appendChild(r);const a=document.createElement("form");a.method="POST",a.action=e.mock_url??"",a.target="_blank",a.className="space-y-2";const s=[{label:"KCP 거래번호",name:"e_trade_no",value:e.trade_no??""},{label:"입금계좌",name:"deposit_no",value:e.account_no??""},{label:"입금자명",name:"req_name",value:"NHN KCP",editable:!0},{label:"입금통보 URL",name:"noti_url",value:e.notify_url??""}];for(const d of s){const l=document.createElement("div");l.className="flex items-center gap-2 text-sm";const u=document.createElement("span");u.className="w-28 flex-shrink-0 text-gray-500 dark:text-gray-400 text-xs",u.textContent=d.label;const p=document.createElement("input");p.type="text",p.name=d.name,p.value=d.value,p.readOnly=!d.editable,p.className=d.editable?"flex-1 px-2 py-1 text-xs border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-700 text-gray-900 dark:text-white font-mono":"flex-1 px-2 py-1 text-xs border border-gray-200 dark:border-gray-700 rounded bg-gray-50 dark:bg-gray-800 text-gray-700 dark:text-gray-300 font-mono",l.appendChild(u),l.appendChild(p),a.appendChild(l)}const i=document.createElement("div");i.className="pt-1";const c=document.createElement("button");if(c.type="submit",c.className="w-full py-1.5 text-xs font-semibold rounded border border-orange-400 dark:border-orange-600 bg-orange-50 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300 hover:bg-orange-100 dark:hover:bg-orange-900/50 transition-colors",c.textContent="입금통보 테스트",i.appendChild(c),a.appendChild(i),t.appendChild(n),t.appendChild(a),e.is_admin_view){const d=document.createElement("p");d.className="mt-2 text-xs text-center text-orange-500 dark:text-orange-400 font-medium",d.textContent="관리자에게만 출력되는 내용",t.appendChild(d)}return t}function he(){const e=document.getElementById("order_payment_info_panel");if(e)return Array.from(e.children).find(a=>a.className?.includes("space-y"))??e;const t=Array.from(document.querySelectorAll("h3")).find(r=>r.textContent?.includes("결제 정보"));if(!t)return null;const n=t.parentElement?.parentElement;return n?Array.from(n.children).find(r=>r.className?.includes("space-y"))??n:null}function w(e,t,n="font-medium text-gray-900 dark:text-white"){const o=document.createElement("div");o.className="flex items-center justify-between text-sm";const r=document.createElement("span");r.className="text-gray-500 dark:text-gray-400",r.textContent=e;const a=document.createElement("span");return a.className=n,a.textContent=t,o.appendChild(r),o.appendChild(a),o}function bt(e,t){if(!t)return!1;const n=Array.from(e.querySelectorAll("div"));for(const o of n){const r=Array.from(o.children).filter(i=>i instanceof HTMLElement&&i.tagName==="SPAN");if(r.length<2)continue;const a=r[0].textContent?.trim();if(a!=="결제 방법"&&a!=="결제수단"&&a!=="Payment Method")continue;const s=r[r.length-1];return s.textContent?.trim()===t?(o.dataset.nhnkcpPaymentMethodRow="true",!0):(s.textContent=t,s.dataset.nhnkcpPaymentMethodPatched="true",o.dataset.nhnkcpPaymentMethodRow="true",!0)}return!1}function gt(e,t){const n=document.createElement("div");n.id=K,n.className="pt-4 mt-2 border-t border-gray-200 dark:border-gray-700 space-y-3";const o=document.createElement("p");o.className="text-sm font-semibold text-gray-800 dark:text-gray-200",o.textContent="가상계좌 입금 안내";const r=document.createElement("div");r.className="space-y-1.5",r.appendChild(w("은행",e.vbank_name??"")),r.appendChild(w("계좌번호",e.vbank_number??"","font-medium text-gray-900 dark:text-white font-mono tracking-wide")),r.appendChild(w("예금주",e.vbank_holder??"")),r.appendChild(w("입금 금액",t)),e.due_date_formatted&&r.appendChild(w("입금 기한",e.due_date_formatted));const a=document.createElement("p");return a.className="text-xs text-amber-600 dark:text-amber-400",a.textContent="입금 기한 내에 입금하지 않으시면 주문이 자동 취소됩니다.",n.appendChild(o),n.appendChild(r),n.appendChild(a),n}function wt(e){const t=document.createElement("div");t.id=j,t.className="pt-4 mt-2 border-t border-gray-200 dark:border-gray-700";const n=document.createElement("div");n.className="flex items-center justify-between";const o=document.createElement("span");o.className="text-gray-500 dark:text-gray-400 text-sm",o.textContent="영수증";const r=document.createElement("button");return r.type="button",r.className="inline-flex items-center gap-1 text-sm text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",r.textContent="영수증 조회",r.addEventListener("click",async()=>{r.disabled=!0,r.textContent="로딩 중...";const a=await me(e);if(r.disabled=!1,r.textContent="영수증 조회",a){const s=window.KcpReceiptPopup;s&&new s({url:a.receipt_url,cash_url:a.cash_receipt_url})}}),n.appendChild(o),n.appendChild(r),t.appendChild(n),t}async function kt(e){const t=_t(e);if(!t){if(!document.getElementById(v)){const p=he();if(!p)return!1;const f=await fe(e);f?.available&&(p.appendChild(ye(f)),console.info(`[${_}] mock deposit form injected on mypage order show`))}return!0}const{payment:n}=t;if(!n||n.pg_provider!=="nhnkcp")return!0;const o=n.payment_method==="vbank"&&!!n.vbank_name,r=!!n.transaction_id&&!!n.paid_at,a=n.payment_method==="vbank"&&!!n.vbank_number,s=!o||!!document.getElementById(K),i=!r||!!document.getElementById(j),c=!a||!!document.getElementById(v);if(s&&i&&c)return!0;const d=he();if(!d)return!1;const l=r?await me(e):null,u=bt(d,l?.payment_method_display_label);if(!document.getElementById(K)&&o)return d.appendChild(gt(n,t.total_amount_formatted??"")),console.info(`[${_}] vbank info injected on mypage order show`),!1;if(!document.getElementById(j)&&r)return d.appendChild(wt(e)),console.info(`[${_}] receipt button injected on mypage order show`),!1;if(u&&console.info(`[${_}] payment method display patched on mypage order show`),!document.getElementById(v)&&a){const p=await fe(e);if(p?.available)d.appendChild(ye(p)),console.info(`[${_}] mock deposit form injected on mypage order show`);else return!0}return!0}function Ct(e){let t=0;const n=setInterval(()=>{t++,kt(e).then(o=>{(o||t>=30)&&clearInterval(n)})},400)}function xt(){const e=location.pathname.match(ht);e&&Ct(e[1])}function vt(){if(typeof window>"u")return;const e=window;if(e[ue])return;e[ue]=!0,console.info(`[${_}] mypage order show injector installed`);const t=(o=1500)=>setTimeout(xt,o);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...o)=>{n(...o),t(600)},window.addEventListener("popstate",()=>t(500))}const Pt="sirsoft-pay_nhnkcp",_e="__kcpAdminApplePayNoticeInjectorInstalled",Et=/^\/admin\/ecommerce\/settings\/?$/,be="__kcpAdminApplePayNoticeListenerAttached",Nt="애플페이는 IOS 기기에 모바일결제만 가능합니다.",At="Apple Pay is available only for mobile payments on iOS devices.";let ge=null,P=null,B=!1;function It(){return window}function D(){if(!Et.test(window.location.pathname))return!1;const e=new URLSearchParams(window.location.search).get("tab");return e===null||e==="order_settings"}function we(){return(document.documentElement.lang||navigator.language||"").toLowerCase().startsWith("ko")?Nt:At}function ke(e){return(e??"").replace(/\s+/g," ").trim()}function St(e){const t=ke(e.textContent);return t==="애플페이"||t==="Apple Pay"}function Mt(){const e=document.createElement("span");return e.dataset.nhnkcpAdminApplePayNotice="true",e.className="text-label-subtle",e.style.display="block",e.style.width="100%",e.style.flexBasis="100%",e.style.marginTop="2px",e.style.fontSize="12px",e.style.lineHeight="1rem",e.textContent=we(),e}function H(e=document){if(typeof window>"u"||typeof document>"u"||!D()||ke(document.body?.innerText??document.body?.textContent).includes(we()))return!1;const n=Array.from(e.querySelectorAll("span, p, div")).find(St);return n?(n.insertAdjacentElement("afterend",Mt()),!0):!1}function Tt(){B||(B=!0,window.setTimeout(()=>{B=!1,H()},0))}function Ce(){P!==null&&(window.clearInterval(P),P=null)}function F(){if(!D())return;Ce(),H();let e=0;P=window.setInterval(()=>{e+=1,(H()||e>=50)&&Ce()},200);const t=document.body;t[be]||(t[be]=!0,ge=new MutationObserver(()=>Tt()),ge.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function xe(){D()&&F()}function Rt(){if(typeof window>"u"||typeof document>"u")return;const e=It();if(e[_e])return;e[_e]=!0,console.info(`[${Pt}] admin Apple Pay notice injector installed`),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>F()):F();const t=history.pushState.bind(history);history.pushState=(...n)=>{t(...n),window.setTimeout(()=>xe(),200)},window.addEventListener("popstate",()=>window.setTimeout(()=>xe(),200))}const $t="sirsoft-pay_nhnkcp",ve="__nhnkcpAdminPaymentMethodBrandInjectorInstalled",Pe="__nhnkcpAdminPaymentMethodBrandSyncListenerAttached",Lt=/^\/admin\/ecommerce\/settings\/?$/,Ee='[data-nhnkcp-admin-payment-brand-mark="true"]',Ot=200,Kt=120,jt=[{id:"nhnkcp_payco",labels:["PAYCO (NHN KCP)","PAYCO로 결제 (NHN KCP)","Pay with PAYCO (NHN KCP)"],shortLabels:["PAYCO"],markLines:["P"],markClassName:"bg-red-500 text-white"},{id:"nhnkcp_naverpay",labels:["네이버페이 (NHN KCP)","네이버페이 신용카드로 결제 (NHN KCP)","Naver Pay (NHN KCP)","Pay by Naver Pay credit card (NHN KCP)"],shortLabels:["네이버페이 (카드)","Naver Pay (Card)"],markLines:["N"],markClassName:"bg-green-500 text-white"},{id:"nhnkcp_naverpay_point",labels:["네이버페이 포인트 (NHN KCP)","네이버페이 머니/포인트로 결제 (NHN KCP)","Naver Pay Point (NHN KCP)","Pay with Naver Pay Money/Points (NHN KCP)"],shortLabels:["네이버페이 (포인트)","Naver Pay (Point)"],markLines:["NP"],markClassName:"bg-green-600 text-white"},{id:"nhnkcp_kakaopay",labels:["카카오페이 (NHN KCP)","카카오페이로 결제 (NHN KCP)","Kakao Pay (NHN KCP)","Pay with Kakao Pay (NHN KCP)"],shortLabels:["카카오페이","Kakao Pay"],markLines:["K"],markClassName:"bg-yellow-400 text-gray-950"},{id:"nhnkcp_applepay",labels:["애플페이 (NHN KCP)","애플페이로 결제 (NHN KCP)","Apple Pay (NHN KCP)","Pay with Apple Pay (NHN KCP)"],shortLabels:["애플페이","Apple Pay"],markLines:["A"],markClassName:"bg-gray-900 text-white"}];let Ne=null,E=null,q=!1;function Bt(){return window}function U(){if(!Lt.test(window.location.pathname))return!1;const e=new URLSearchParams(window.location.search).get("tab");return e===null||e===""||e==="order_settings"}function Dt(e){return e instanceof HTMLElement?e.className:""}function Ae(e){return(e??"").replace(/\u200B/g,"").replace(/\s+/g," ").trim()}function Ht(e){const t=Dt(e);return t.includes("excel-card")||t.includes("flex-center")&&t.includes("border")&&t.includes("gap-4")}function Ie(e){return e.querySelector(".font-medium")}function Ft(e){const t=Ae(Ie(e)?.textContent),n=Ae(e.textContent);return jt.find(o=>o.shortLabels.some(r=>t===r)||o.labels.some(r=>n.includes(r)))??null}function qt(e){return Array.from(e.querySelectorAll("div")).filter(Ht)}function Ut(e){return Array.from(e.querySelectorAll("svg, [data-icon], i")).find(n=>!n.closest("[data-drag-handle]")&&!n.closest(Ee)&&!n.closest('.row-stack, .excel-card-body, button, select, [role="switch"]'))??null}function Se(e,t){e.dataset.nhnkcpAdminPaymentBrandMark="true",e.dataset.nhnkcpAdminPaymentMethod=t.id,e.setAttribute("aria-hidden","true"),e.className=`inline-flex items-center justify-center rounded-lg font-bold ${t.markClassName}`,e.style.width="32px",e.style.height="32px",e.style.flex="0 0 32px",e.style.lineHeight="1",e.style.fontSize=t.markLines.join("").length>2?"9px":"12px";const n=t.markLines.join("");e.textContent!==n&&(e.replaceChildren(),t.markLines.length>1?(e.style.flexDirection="column",t.markLines.forEach(o=>{const r=document.createElement("span");r.style.lineHeight="1",r.textContent=o,e.appendChild(r)})):(e.style.removeProperty("flex-direction"),e.textContent=t.markLines[0]??""))}function Yt(e){const t=document.createElement("span");return Se(t,e),t}function Gt(e,t){const n=e.querySelector(Ee);if(n instanceof HTMLSpanElement)return e.dataset.nhnkcpAdminPaymentMethod=t.id,Se(n,t),!0;const o=Yt(t),r=Ut(e);if(r&&r.parentElement)return e.dataset.nhnkcpAdminPaymentMethod=t.id,r.replaceWith(o),!0;const a=Ie(e);return a&&a.parentElement?(e.dataset.nhnkcpAdminPaymentMethod=t.id,a.parentElement.insertBefore(o,a),!0):!1}function Y(e=document){if(typeof window>"u"||typeof document>"u"||!U())return!1;let t=!1;return qt(e).forEach(n=>{const o=Ft(n);o&&Gt(n,o)&&(t=!0)}),t}function Wt(){q||(q=!0,window.setTimeout(()=>{q=!1,Y()},0))}function G(){E!==null&&(window.clearInterval(E),E=null)}function W(){if(!U())return;G(),Y();let e=0;E=window.setInterval(()=>{e+=1,Y(),e>=Kt&&G()},Ot);const t=document.body;t[Pe]||(t[Pe]=!0,Ne=new MutationObserver(()=>Wt()),Ne.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function Me(){if(U()){W();return}G()}function zt(){if(typeof window>"u"||typeof document>"u")return;const e=Bt();if(e[ve])return;e[ve]=!0,console.info(`[${$t}] admin payment method brand sync installed`),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>W()):W();const t=history.pushState.bind(history);history.pushState=(...n)=>{t(...n),window.setTimeout(()=>Me(),200)},window.addEventListener("popstate",()=>window.setTimeout(()=>Me(),200))}const z="sirsoft-pay_nhnkcp",Te="__nhnkcpAdminPaymentDisplayInjectorInstalled",Jt=/^\/admin\/ecommerce\/orders\/([^/]+)$/;function Vt(){return localStorage.getItem("auth_token")}async function Qt(e){const t=Vt();if(!t)return null;try{const n=await fetch(`/api/plugins/${z}/admin/orders/${e}/transaction-status`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!n.ok)return null;const o=await n.json();return("data"in o?o.data:o)??null}catch{return null}}function Xt(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function Zt(e,t){let n=!1;const o=Array.from(e.querySelectorAll("div"));for(const r of o){const a=Xt(r),s=a.findIndex(u=>u.textContent?.trim()==="결제수단");if(s<0)continue;const i=a.slice(s+1).find(u=>u.textContent?.trim()&&u.textContent.trim()!=="결제수단");if(!i)continue;const c=a.slice(s+2).find(u=>/^\(.+\)$/.test(u.textContent?.trim()??"")),d=c?.textContent?.trim().replace(/^\(|\)$/g,"")??"",l=d&&t.endsWith(")")?t.replace(/\)$/,`, ${d})`):t;i.textContent?.trim()!==l&&(i.textContent=l,i.dataset.nhnkcpPaymentMethodPatched="true"),r.dataset.nhnkcpPaymentMethodRow="admin-order",c&&d&&(c.textContent="",c.style.display="none",c.dataset.nhnkcpPaymentInstallmentHidden="true"),n=!0}return n}function en(e,t,n){const r=Array.from(e.querySelectorAll("span")).filter(a=>a.textContent?.trim()===t).find(a=>{const s=typeof a.className=="string"?a.className:"";return s.includes("rounded-full")||s.includes("font-medium")});return r?(r.textContent=n,r.dataset.nhnkcpPaymentMethodPatched="true",r.dataset.nhnkcpPaymentMethodBadge="admin-order",!0):!1}function tn(e,t){const n=t?._pay_method_label,o=t?._embedded_pg_provider_label,r=t?._base_pay_method_label;if(!n||!o)return!1;const a=Zt(e,n),s=r?en(e,r,o):!1;return a||s}async function nn(e){const t=document.getElementById("section_payment_info")??document.getElementById("payment_info_card");if(!t)return!1;const n=await Qt(e);return n&&tn(t,n)&&console.info(`[${z}] payment method display patched on admin order detail`),!0}function on(e){let t=0;const n=setInterval(()=>{t++,nn(e).then(o=>{(o||t>=30)&&clearInterval(n)})},400)}function rn(){const e=location.pathname.match(Jt);e&&on(e[1])}function an(){if(typeof window>"u")return;const e=window;if(e[Te])return;e[Te]=!0,console.info(`[${z}] admin order payment display injector installed`);const t=(o=1500)=>setTimeout(rn,o);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...o)=>{n(...o),t(600)},window.addEventListener("popstate",()=>t(500))}class sn{constructor(t){const n="width=800,height=600,scrollbars=yes,resizable=yes,toolbar=no,menubar=no";t.url&&window.open(t.url,"kcp_receipt",n),t.cash_url&&window.open(t.cash_url,"kcp_cash_receipt",n)}}window.KcpReceiptPopup=sn;const b="sirsoft-pay_nhnkcp",J={info:(...e)=>console.info(`[${b}]`,...e),warn:(...e)=>console.warn(`[${b}]`,...e),error:(...e)=>console.error(`[${b}]`,...e)};function Re(){const e=window.G7Core;if(!e)return 0;const t=e.getActionDispatcher;if(typeof t!="function")return 0;const n=t();if(!n||typeof n.registerHandler!="function")return 0;let o=0;for(const[r,a]of Object.entries(re)){const s=`${b}.${r}`;n.registerHandler(s,a,{category:"plugin",source:b}),o++}return o}function $e(){const e=()=>{const t=Re();if(t>0){J.info(`${t} handler(s) registered`);return}let n=0;const o=50,r=setInterval(()=>{n++;const a=Re();if(a>0){clearInterval(r),J.info(`${a} handler(s) registered (after ${n} retries)`);return}n>=o&&(clearInterval(r),J.warn("ActionDispatcher not available after timeout"))},100)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}dt(),yt(),vt(),Rt(),zt(),an(),$e(),window.__SirsoftNhnkcp={identifier:b,handlers:Object.keys(re),initPlugin:$e}})(); -//# sourceMappingURL=plugin.iife.js.map diff --git a/plugins/_bundled/sirsoft-pay_nicepayments/components.json b/plugins/_bundled/sirsoft-pay_nicepayments/components.json index 93417209..65500af5 100644 --- a/plugins/_bundled/sirsoft-pay_nicepayments/components.json +++ b/plugins/_bundled/sirsoft-pay_nicepayments/components.json @@ -1,7 +1,7 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", "identifier": "sirsoft-pay_nicepayments", - "version": "1.0.0-beta.4", + "version": "1.0.0", "components": { "basic": [], "composite": [], diff --git a/plugins/_bundled/sirsoft-pay_nicepayments/dist/js/plugin.iife.js b/plugins/_bundled/sirsoft-pay_nicepayments/dist/js/plugin.iife.js index 14397591..8ce57f50 100644 --- a/plugins/_bundled/sirsoft-pay_nicepayments/dist/js/plugin.iife.js +++ b/plugins/_bundled/sirsoft-pay_nicepayments/dist/js/plugin.iife.js @@ -1,2 +1 @@ (function(){"use strict";function le(e){return/^https?:\/\//i.test(e)||e.startsWith("/api/")?e:e.startsWith("/plugins/")?`/api${e}`:e.startsWith("plugins/")?`/api/${e}`:e}function de(e){return e.trim().slice(0,160)}async function ue(e,t="nicepay-window-closed"){if(!e.closeReportUrl)return;const n={oid:e.oid,price:Number(e.price),buyer_email:e.buyer_email??"",buyer_phone:e.buyer_phone??"",payment_method:e.payment_method??"",reason:de(t)||"nicepay-window-closed"};try{const a=window.G7Core?.api;if(typeof a?.post=="function"){await a.post(e.closeReportUrl,n);return}await fetch(le(e.closeReportUrl),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),keepalive:!0})}catch(a){console.warn("[sirsoft-pay_nicepayments] failed to report payment window close",a)}}function pe(e){return new Promise((t,n)=>{if(document.querySelector(`script[src="${e}"]`)){t();return}const a=document.createElement("script");a.src=e,a.onload=()=>t(),a.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(a)})}function me(e,t){const n=document.createElement("form");n.id="nicepayForm",n.method="post",n.action=e,n.acceptCharset="utf-8";for(const[a,r]of Object.entries(t)){const o=document.createElement("input");o.type="hidden",o.name=a,o.value=r,n.appendChild(o)}return document.body.appendChild(n),n}const ye="/plugins/sirsoft-pay_nicepayments/payment/callback",fe="https://web.nicepay.co.kr/v3/v3Payment.jsp";function he(){if(typeof navigator>"u")return!1;const e=navigator;if(e.userAgentData?.mobile!==void 0)return e.userAgentData.mobile;const t=(navigator.userAgent||"").toLowerCase();return!!(/android|iphone|ipod|windows phone|iemobile|blackberry|opera mini|mobile safari/.test(t)||(navigator.maxTouchPoints??0)>1&&!t.includes("windows")&&!t.includes("macintosh"))}async function be(e,t){const{pgPaymentData:n,paymentMethod:a}=e.params??{},r=window.__templateApp?.globalState?._local,o=a??n?.payment_method??r?.paymentMethod??"card";if(!n){console.error("[sirsoft-pay_nicepayments] pgPaymentData is required");return}const i=window.G7Core;try{const s=await i.api.get("/modules/sirsoft-ecommerce/payments/client-config/nicepayments");if(!s.data){console.error("[sirsoft-pay_nicepayments] Failed to fetch client config",s);return}const l=s.data,d=he();if(!d&&(await pe(l.sdk_url),typeof window.goPay!="function")){i?.toast?.error?.("나이스페이먼츠 SDK를 불러올 수 없습니다. 잠시 후 다시 시도해주세요."),i?.state?.setLocal?.({isSubmittingOrder:!1,paymentMethod:o});return}const w=window.location.origin+l.sign_data_url,u=typeof localStorage<"u"?localStorage.getItem("auth_token"):null,te={"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest",Accept:"application/json"};u&&(te.Authorization=`Bearer ${u}`);const ne=await fetch(w,{method:"POST",credentials:"include",headers:te,body:JSON.stringify({amt:n.amount,moid:n.order_number,buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??""})});if(!ne.ok)throw new Error("SignData 생성에 실패했습니다.");const I=await ne.json(),ae=window.location.origin+ye,L=typeof o=="string"&&o.startsWith("nicepay_"),oe=L?"CARD":{card:"CARD",vbank:"VBANK",bank:"BANK",phone:"CELLPHONE"}[o??"card"]??"CARD",c={PayMethod:oe,GoodsName:n.order_name,Amt:String(n.amount),MID:I.mid,Moid:n.order_number,BuyerName:n.customer_name??"",BuyerEmail:n.customer_email??"",BuyerTel:n.customer_phone??"",ReturnURL:ae,EdiDate:I.ediDate,SignData:I.signData,CharSet:"utf-8",GoodsCl:"1",DirectShowOpt:"",DirectEasyPay:"",NicepayReserved:"",EasyPayMethod:"",MallReserved:"",MallReserved1:""};oe==="CELLPHONE"&&(c.GoodsCl=n.goods_cl??"1");const ft=l.useEscrow&&!L;if(c.TransType=ft?"1":"0",L)switch(c.DirectShowOpt="CARD",c.MallReserved=`nicepay_easy_pay_method=${encodeURIComponent(o)}`,c.MallReserved1=o,o){case"nicepay_naverpay":c.DirectEasyPay="E020",c.EasyPayMethod="E020=CARD";break;case"nicepay_kakaopay":c.NicepayReserved="DirectKakao=Y";break;case"nicepay_samsungpay":c.DirectEasyPay="E021";break;case"nicepay_applepay":c.DirectEasyPay="E025";break;case"nicepay_payco":c.NicepayReserved="DirectPayco=Y";break;case"nicepay_skpay":c.NicepayReserved="DirectPay11=Y";break;case"nicepay_ssgpay":c.DirectEasyPay="E007";break;case"nicepay_lpay":c.DirectEasyPay="E018";break}try{const m=(await i.api.get(`/modules/sirsoft-ecommerce/user/orders/${n.order_number}`))?.data;if(m){const P=Number(m.total_tax_amount??0),h=Number(m.total_vat_amount??0),ce=Number(m.total_tax_free_amount??0);(P>0||h>0||ce>0)&&(c.TaxAmt=String(P),c.VatAmt=String(h),c.TaxFreeAmt=String(ce))}}catch{}const p=me(ae,c);if(d){p.action=fe,p.acceptCharset="euc-kr";const f=p.querySelector('input[name="CharSet"]');f&&(f.value="euc-kr"),p.submit();return}window.nicepaySubmit=()=>{p.submit()};let re=!1;const ht=new Set(document.body.children),ie=(f,m)=>{if(re)return;re=!0;const P=[f,m].filter(Boolean).join(": ")||"nicepay-window-closed";ue({closeReportUrl:l.close_report_url,oid:n.order_number,price:Number(n.amount),buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??"",payment_method:o},P),window.removeEventListener("popstate",se),Array.from(document.body.children).forEach(h=>{ht.has(h)||h.remove()}),p.parentNode&&p.parentNode.removeChild(p),window.__sirsoftNicepayPaymentInProgress=!1,i?.state?.setLocal?.({isSubmittingOrder:!1,paymentMethod:o}),m&&i?.toast?.error?.(m)};window.nicepayClose=ie;const se=()=>ie("","");window.history.pushState({nicepayOpen:!0},""),window.addEventListener("popstate",se),window.goPay(p)}catch(s){console.error("[sirsoft-pay_nicepayments] requestPayment error",s),window.__sirsoftNicepayPaymentInProgress=!1,i?.state?.setLocal?.({isSubmittingOrder:!1,paymentMethod:o}),i?.toast?.error?.("결제 중 오류가 발생했습니다. 잠시 후 다시 시도해주세요.")}}const ge={nicepay_naverpay:"네이버페이",nicepay_kakaopay:"카카오페이",nicepay_samsungpay:"삼성페이",nicepay_applepay:"애플페이",nicepay_payco:"PAYCO",nicepay_skpay:"11pay",nicepay_ssgpay:"SSG페이",nicepay_lpay:"L.pay"},_e="0 0 0 2px #ffffff, 0 0 0 5px rgba(0,0,0,0.55)";function M(){const e=document.getElementById("nicepay_checkout_payment_section");if(!e)return null;const t=e.querySelectorAll("p");for(const n of t)if(n.textContent?.includes("간편결제"))return n.nextElementSibling;return null}function D(){const e=M();e&&e.querySelectorAll("button").forEach(t=>{t.style.boxShadow="",t.style.outline=""})}function we(e){const t=M();if(!t)return;const n=ge[e];t.querySelectorAll("button").forEach(a=>{a.textContent?.trim()===n?(a.style.boxShadow=_e,a.style.outline="none"):(a.style.boxShadow="",a.style.outline="")})}function Pe(e){const t=e.params?.paymentMethod;if(!t)return;const n=typeof t=="string"&&t.indexOf("nicepay_")===0;window.G7Core?.state?.setLocal?.({paymentMethod:t}),n?we(t):D()}function R(){const e=window.__templateApp;typeof e?.onGlobalStateChange=="function"&&e.onGlobalStateChange(t=>{const n=t?._local?.paymentMethod;typeof n=="string"&&(n.startsWith("nicepay_")||D())})}const $={requestPayment:be,setPaymentMethod:Pe},Ce="sirsoft-pay_nicepayments",Ee={info:(...e)=>console.info(`[${Ce}]`,...e)};function Se(){Ee.info("order interceptor is a no-op — payment entry is dispatched via pg_payment_handler")}const C="sirsoft-pay_nicepayments",T="__nicepayOcReceiptInjectorInstalled",O="nicepay-oc-receipt-btn",xe=/^\/shop\/orders\/([^/]+)\/complete$/;function B(){return localStorage.getItem("auth_token")}async function Ae(e){const t=B();if(!t)return null;try{const n=await fetch(`/api/modules/sirsoft-ecommerce/user/orders/${e}`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});return n.ok?(await n.json())?.data?.payment??null:null}catch{return null}}async function j(e){const t=B();if(!t)return null;try{const n=await fetch(`/api/plugins/${C}/user/orders/${e}/receipt`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});return n.ok?await n.json():null}catch{return null}}function Ne(e){if(!e)return!1;const t=Array.from(document.querySelectorAll("div"));for(const n of t){const a=Array.from(n.children).filter(i=>i instanceof HTMLElement&&i.tagName==="SPAN");if(a.length<2)continue;const r=a[0].textContent?.trim();if(r!=="결제 방법"&&r!=="결제수단"&&r!=="결제 방식")continue;const o=a[a.length-1];return o.textContent?.trim()!==e&&(o.textContent=e,o.dataset.nicepayPaymentMethodPatched="true"),n.dataset.nicepayPaymentMethodRow="true",!0}return!1}async function ke(e){if(document.getElementById(O))return;const t=await Ae(e);if(!t||t.pg_provider!=="nicepayments"||!t.transaction_id||!t.paid_at)return;const n=Array.from(document.querySelectorAll('button[type="button"]')).find(s=>s.className.includes("bg-blue-600"));if(!n?.parentElement)return;const a=await j(e);Ne(a?.payment_method_display_label);const r=n.parentElement,o=document.createElement("button");o.id=O,o.type="button",o.className=n.className.replace(/bg-blue-\d+/g,"bg-green-600").replace(/hover:bg-blue-\d+/g,"hover:bg-green-700"),o.textContent="영수증 조회",o.addEventListener("click",async()=>{o.disabled=!0,o.textContent="로딩 중...";const s=await j(e);o.disabled=!1,o.textContent="영수증 조회";const l=s?.receipt_url??null;l&&window.open(l,"nicepay_receipt","width=800,height=600,scrollbars=yes,resizable=yes")});const i=r.lastElementChild;r.insertBefore(o,i),console.info(`[${C}] receipt button injected on order complete page`)}function ve(){const e=location.pathname.match(xe);e&&ke(e[1])}function Ie(){if(typeof window>"u")return;const e=window;if(e[T])return;e[T]=!0,console.info(`[${C}] order complete receipt injector installed`);const t=(a=1200)=>setTimeout(ve,a);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...a)=>{n(...a),t()},window.addEventListener("popstate",()=>t(500))}const b="sirsoft-pay_nicepayments",G="__nicepayOrderShowInjectorInstalled",q="nicepay-mp-receipt-row",H="nicepay-mp-vbank-info",Le=/^\/mypage\/orders\/([^/]+)$/;function Me(e){try{const n=window.G7Core?.getState,o=n?.()?.currentDataContext?.order?.data;return!o||o.order_number!==e?null:o}catch{return null}}function De(){return localStorage.getItem("auth_token")}async function F(e){const t=De();if(!t)return null;try{const n=await fetch(`/api/plugins/${b}/user/orders/${e}/receipt`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});return n.ok?await n.json():null}catch{return null}}function Re(e,t){if(!t)return!1;const n=Array.from(e.querySelectorAll("div"));for(const a of n){const r=Array.from(a.children).filter(s=>s instanceof HTMLElement&&s.tagName==="SPAN");if(r.length<2)continue;const o=r[0].textContent?.trim();if(o!=="결제 방법"&&o!=="결제수단"&&o!=="Payment Method")continue;const i=r[r.length-1];return i.textContent?.trim()!==t&&(i.textContent=t,i.dataset.nicepayPaymentMethodPatched="true"),a.dataset.nicepayPaymentMethodRow="true",!0}return!1}function $e(){const e=document.getElementById("order_payment_info_panel");if(e)return Array.from(e.children).find(a=>a.className?.includes("space-y"))??e;const t=Array.from(document.querySelectorAll("h3")).find(a=>a.textContent?.includes("결제 정보"));if(!t)return null;const n=t.parentElement?.parentElement;return n?Array.from(n.children).find(a=>a.className?.includes("space-y"))??n:null}function Te(e){const t=document.createElement("div");t.id=q,t.className="flex items-center justify-between";const n=document.createElement("span");n.className="text-gray-500 dark:text-gray-400 text-sm",n.textContent="영수증";const a=document.createElement("button");return a.type="button",a.className="inline-flex items-center gap-1 text-sm text-blue-600 dark:text-blue-400 hover:underline disabled:opacity-50",a.textContent="영수증 조회",a.addEventListener("click",async()=>{a.disabled=!0,a.textContent="로딩 중...";const r=await F(e);a.disabled=!1,a.textContent="영수증 조회";const o=r?.receipt_url??null;o&&window.open(o,"nicepay_receipt","width=800,height=600,scrollbars=yes,resizable=yes")}),t.appendChild(n),t.appendChild(a),t}function Oe(e){if(!e)return"";try{const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=a=>String(a).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}catch{return e}}function g(e,t,n="font-medium text-gray-900 dark:text-white"){const a=document.createElement("div");a.className="flex justify-between text-sm";const r=document.createElement("span");r.className="text-gray-600 dark:text-gray-400",r.textContent=e;const o=document.createElement("span");return o.className=n,o.textContent=t,a.appendChild(r),a.appendChild(o),a}function Be(e){const t=e.payment??{},n=document.createElement("div");n.id=H,n.className="pt-4 mt-2 border-t border-gray-200 dark:border-gray-700";const a=document.createElement("div");a.className="bg-blue-50 dark:bg-blue-900/30 border border-blue-200 dark:border-blue-700 rounded-lg p-4";const r=document.createElement("h3");r.className="text-sm font-semibold text-blue-800 dark:text-blue-300 mb-3",r.textContent="가상계좌 입금 안내";const o=document.createElement("div");o.className="space-y-2",o.appendChild(g("은행",t.vbank_name??"")),o.appendChild(g("계좌번호",t.vbank_number??"","font-medium font-mono text-gray-900 dark:text-white")),o.appendChild(g("예금주",t.vbank_holder??"")),o.appendChild(g("입금 금액",e.total_amount_formatted??"","font-bold text-blue-600 dark:text-blue-400"));const i=t.vbank_due_at;if(i){const s=document.createElement("div");s.className="flex justify-between text-sm pt-2 border-t border-blue-200 dark:border-blue-700 mt-2";const l=document.createElement("span");l.className="text-gray-600 dark:text-gray-400",l.textContent="입금 기한";const d=document.createElement("span");d.className="font-medium text-red-600 dark:text-red-400",d.textContent=Oe(i),s.appendChild(l),s.appendChild(d),o.appendChild(s)}if(a.appendChild(r),a.appendChild(o),!t.paid_at){const s=document.createElement("p");s.className="text-xs text-blue-700 dark:text-blue-300 mt-3",s.textContent="입금 기한 내에 입금이 완료되지 않으면 주문이 자동 취소됩니다.",a.appendChild(s)}return n.appendChild(a),n}async function je(e){const t=Me(e);if(!t)return!1;const{payment:n}=t;if(!n||n.pg_provider!=="nicepayments")return!0;const a=$e();if(!a)return!1;const r=await F(e);return Re(a,r?.payment_method_display_label),n.payment_method==="vbank"&&n.vbank_number&&!document.getElementById(H)&&(a.appendChild(Be(t)),console.info(`[${b}] vbank info injected on mypage order show`)),!n.transaction_id||!n.paid_at||document.getElementById(q)||(a.appendChild(Te(e)),console.info(`[${b}] receipt button injected on mypage order show`)),!0}function Ge(e){let t=0;const n=setInterval(()=>{t++,je(e).then(a=>{(a||t>=30)&&clearInterval(n)})},400)}function qe(){const e=location.pathname.match(Le);e&&Ge(e[1])}function He(){if(typeof window>"u")return;const e=window;if(e[G])return;e[G]=!0,console.info(`[${b}] mypage order show injector installed`);const t=(a=1500)=>setTimeout(qe,a);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...a)=>{n(...a),t(600)},window.addEventListener("popstate",()=>t(500))}const Fe="sirsoft-pay_nicepayments",U="__nicepayAdminPaymentMethodBrandInjectorInstalled",Y="__nicepayAdminPaymentMethodBrandSyncListenerAttached",Ue=/^\/admin\/ecommerce\/settings\/?$/,W='[data-nicepay-admin-payment-brand-mark="true"]',Ye=200,We=120,Ke=[{id:"nicepay_naverpay",labels:["네이버페이 (나이스페이먼츠)","네이버페이로 결제 (나이스페이먼츠)","Naver Pay (NicePayments)","Pay with Naver Pay (NicePayments)"],shortLabels:[],markLines:["N"],markClassName:"bg-green-500 text-white"},{id:"nicepay_kakaopay",labels:["카카오페이 (나이스페이먼츠)","카카오페이로 결제 (나이스페이먼츠)","Kakao Pay (NicePayments)","Pay with Kakao Pay (NicePayments)"],shortLabels:[],markLines:["K"],markClassName:"bg-yellow-400 text-gray-950"},{id:"nicepay_samsungpay",labels:["삼성페이 (나이스페이먼츠)","삼성페이로 결제 (나이스페이먼츠)","Samsung Pay (NicePayments)","Pay with Samsung Pay (NicePayments)"],shortLabels:[],markLines:["S"],markClassName:"bg-blue-600 text-white"},{id:"nicepay_applepay",labels:["애플페이 (나이스페이먼츠)","애플페이로 결제 (나이스페이먼츠)","Apple Pay (NicePayments)","Pay with Apple Pay (NicePayments)"],shortLabels:[],markLines:["A"],markClassName:"bg-gray-900 text-white"},{id:"nicepay_payco",labels:["PAYCO (나이스페이먼츠)","PAYCO로 결제 (나이스페이먼츠)","PAYCO (NicePayments)","Pay with PAYCO (NicePayments)"],shortLabels:[],markLines:["P"],markClassName:"bg-red-500 text-white"},{id:"nicepay_skpay",labels:["11pay (나이스페이먼츠)","11pay로 결제 (나이스페이먼츠)","11pay (NicePayments)","Pay with 11pay (NicePayments)"],shortLabels:[],markLines:["11"],markClassName:"bg-orange-500 text-white"},{id:"nicepay_ssgpay",labels:["SSG페이 (나이스페이먼츠)","SSG페이로 결제 (나이스페이먼츠)","SSG Pay (NicePayments)","Pay with SSG Pay (NicePayments)"],shortLabels:[],markLines:["SSG"],markClassName:"bg-red-700 text-white"},{id:"nicepay_lpay",labels:["L.pay (나이스페이먼츠)","L.pay로 결제 (나이스페이먼츠)","L.pay (NicePayments)","Pay with L.pay (NicePayments)"],shortLabels:[],markLines:["L"],markClassName:"bg-purple-600 text-white"}];let K=null,_=null,E=!1;function ze(){return window}function S(){if(!Ue.test(window.location.pathname))return!1;const e=new URLSearchParams(window.location.search).get("tab");return e===null||e===""||e==="order_settings"}function Ve(e){return e instanceof HTMLElement?e.className:""}function z(e){return(e??"").replace(/\u200B/g,"").replace(/\s+/g," ").trim()}function Je(e){const t=Ve(e);return t.includes("excel-card")||t.includes("flex-center")&&t.includes("border")&&t.includes("gap-4")}function V(e){return e.querySelector(".font-medium")}function Xe(e){const t=z(V(e)?.textContent),n=z(e.textContent);return Ke.find(a=>a.shortLabels.some(r=>t===r)||a.labels.some(r=>n.includes(r)))??null}function Qe(e){return Array.from(e.querySelectorAll("div")).filter(Je)}function Ze(e){return Array.from(e.querySelectorAll("svg, [data-icon], i")).find(n=>!n.closest("[data-drag-handle]")&&!n.closest(W)&&!n.closest('.row-stack, .excel-card-body, button, select, [role="switch"]'))??null}function J(e,t){e.dataset.nicepayAdminPaymentBrandMark="true",e.dataset.nicepayAdminPaymentMethod=t.id,e.setAttribute("aria-hidden","true"),e.className=`inline-flex items-center justify-center rounded-lg font-bold ${t.markClassName}`,e.style.width="32px",e.style.height="32px",e.style.flex="0 0 32px",e.style.lineHeight="1",e.style.fontSize=t.markLines.join("").length>2?"9px":"12px";const n=t.markLines.join("");e.textContent!==n&&(e.textContent=t.markLines[0]??"")}function et(e){const t=document.createElement("span");return J(t,e),t}function tt(e,t){const n=e.querySelector(W);if(n instanceof HTMLSpanElement)return e.dataset.nicepayAdminPaymentMethod=t.id,J(n,t),!0;const a=et(t),r=Ze(e);if(r&&r.parentElement)return e.dataset.nicepayAdminPaymentMethod=t.id,r.replaceWith(a),!0;const o=V(e);return o&&o.parentElement?(e.dataset.nicepayAdminPaymentMethod=t.id,o.parentElement.insertBefore(a,o),!0):!1}function x(e=document){if(typeof window>"u"||typeof document>"u"||!S())return!1;let t=!1;return Qe(e).forEach(n=>{const a=Xe(n);a&&tt(n,a)&&(t=!0)}),t}function nt(){E||(E=!0,window.setTimeout(()=>{E=!1,x()},0))}function A(){_!==null&&(window.clearInterval(_),_=null)}function N(){if(!S())return;A(),x();let e=0;_=window.setInterval(()=>{e+=1,x(),e>=We&&A()},Ye);const t=document.body;t[Y]||(t[Y]=!0,K=new MutationObserver(()=>nt()),K.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function X(){if(S()){N();return}A()}function at(){if(typeof window>"u"||typeof document>"u")return;const e=ze();if(e[U])return;e[U]=!0,console.info(`[${Fe}] admin payment method brand sync installed`),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>N()):N();const t=history.pushState.bind(history);history.pushState=(...n)=>{t(...n),window.setTimeout(()=>X(),200)},window.addEventListener("popstate",()=>window.setTimeout(()=>X(),200))}const k="sirsoft-pay_nicepayments",Q="__nicepayAdminPaymentDisplayInjectorInstalled",ot=/^\/admin\/ecommerce\/orders\/([^/]+)$/;function rt(){return localStorage.getItem("auth_token")}async function it(e){const t=rt();if(!t)return null;try{const n=await fetch(`/api/plugins/${k}/admin/orders/${e}/transaction-status`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!n.ok)return null;const a=await n.json();return("data"in a?a.data:a)??null}catch{return null}}function st(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function ct(e,t){let n=!1;const a=Array.from(e.querySelectorAll("div"));for(const r of a){const o=st(r),i=o.findIndex(u=>u.textContent?.trim()==="결제수단");if(i<0)continue;const s=o.slice(i+1).find(u=>u.textContent?.trim()&&u.textContent.trim()!=="결제수단");if(!s)continue;const l=o.slice(i+2).find(u=>/^\(.+\)$/.test(u.textContent?.trim()??"")),d=l?.textContent?.trim().replace(/^\(|\)$/g,"")??"",w=d&&t.endsWith(")")?t.replace(/\)$/,`, ${d})`):t;s.textContent?.trim()!==w&&(s.textContent=w,s.dataset.nicepayPaymentMethodPatched="true"),r.dataset.nicepayPaymentMethodRow="admin-order",l&&d&&(l.textContent="",l.style.display="none",l.dataset.nicepayPaymentInstallmentHidden="true"),n=!0}return n}function lt(e,t,n){const r=Array.from(e.querySelectorAll("span")).filter(o=>o.textContent?.trim()===t).find(o=>{const i=typeof o.className=="string"?o.className:"";return i.includes("rounded-full")||i.includes("font-medium")});return r?(r.textContent=n,r.dataset.nicepayPaymentMethodPatched="true",r.dataset.nicepayPaymentMethodBadge="admin-order",!0):!1}function dt(e,t){const n=t?._pay_method_label,a=t?._embedded_pg_provider_label,r=t?._base_pay_method_label;if(!n||!a)return!1;const o=ct(e,n),i=r?lt(e,r,a):!1;return o||i}async function ut(e){const t=document.getElementById("section_payment_info")??document.getElementById("payment_info_card");if(!t)return!1;const n=await it(e);return n&&dt(t,n)&&console.info(`[${k}] payment method display patched on admin order detail`),!0}function pt(e){let t=0;const n=setInterval(()=>{t++,ut(e).then(a=>{(a||t>=30)&&clearInterval(n)})},400)}function mt(){const e=location.pathname.match(ot);e&&pt(e[1])}function yt(){if(typeof window>"u")return;const e=window;if(e[Q])return;e[Q]=!0,console.info(`[${k}] admin order payment display injector installed`);const t=(a=1500)=>setTimeout(mt,a);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>t()):t();const n=history.pushState.bind(history);history.pushState=(...a)=>{n(...a),t(600)},window.addEventListener("popstate",()=>t(500))}const y="sirsoft-pay_nicepayments",v={info:(...e)=>console.info(`[${y}]`,...e),warn:(...e)=>console.warn(`[${y}]`,...e),error:(...e)=>console.error(`[${y}]`,...e)};function Z(){const e=window.G7Core;if(!e)return 0;const t=e.getActionDispatcher;if(typeof t!="function")return 0;const n=t();if(!n||typeof n.registerHandler!="function")return 0;let a=0;for(const[r,o]of Object.entries($)){const i=`${y}.${r}`;n.registerHandler(i,o,{category:"plugin",source:y}),a++}return a}function ee(){Se(),Ie(),He(),at(),yt();const e=()=>{const t=Z();if(t>0){v.info(`${t} handler(s) registered`),R();return}let n=0;const a=50,r=setInterval(()=>{n++;const o=Z();if(o>0){clearInterval(r),v.info(`${o} handler(s) registered (after ${n} retries)`),R();return}n>=a&&(clearInterval(r),v.warn("ActionDispatcher not available after timeout"))},100)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}ee(),window.__SirsoftNicepayments={identifier:y,handlers:Object.keys($),initPlugin:ee}})(); -//# sourceMappingURL=plugin.iife.js.map diff --git a/templates/_bundled/sirsoft-basic/dist/js/components.iife.js b/templates/_bundled/sirsoft-basic/dist/js/components.iife.js index 96144288..664587c5 100644 --- a/templates/_bundled/sirsoft-basic/dist/js/components.iife.js +++ b/templates/_bundled/sirsoft-basic/dist/js/components.iife.js @@ -84,4 +84,3 @@ self.addEventListener('message', async (e) => { } } `})]}):null},n0=Object.freeze(Object.defineProperty({__proto__:null,PageTransitionIndicator:Sa,default:Sa},Symbol.toStringTag,{value:"Module"})),Yi=window.G7Core?.createLogger?.("Comp:PageTransitionBlur")??{log:(...e)=>console.log("[Comp:PageTransitionBlur]",...e),warn:(...e)=>console.warn("[Comp:PageTransitionBlur]",...e)},_a=({className:e="",style:t})=>{const[r,n]=k.useState(!1);return k.useEffect(()=>{const o=window.G7Core?.TransitionManager;if(!o){Yi.warn("TransitionManager를 찾을 수 없습니다.");return}return n(o.getIsPending()),o.subscribe(s=>{Yi.log("isPending changed:",s),n(s)})},[]),r?c.jsx(W,{className:`fixed inset-0 z-40 bg-white/30 dark:bg-gray-900/30 backdrop-blur-sm transition-opacity duration-150 pointer-events-none ${e}`,style:t,role:"status","aria-label":"페이지 전환 중","data-testid":"page-transition-blur"}):null},o0=Object.freeze(Object.defineProperty({__proto__:null,PageTransitionBlur:_a,default:_a},Symbol.toStringTag,{value:"Module"})),Xi={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Zi=new Set(["hidden","block","inline-block","inline","flex","inline-flex","grid","inline-grid","table","table-row","table-cell","contents","list-item","flow-root"]),a0=new Set(["Div","Flex","Grid","Section","Article","Nav","Aside","Main","Header","Footer","Fragment","Form","Container"]),s0=new Set(["H1","H2","H3","H4","H5","H6","P","Span","Label","A","Strong","Em","Small","Badge"]),l0=new Set(["Input","Textarea","Select","Checkbox","Radio","Toggle","DatePicker","TagInput","SearchBar"]),i0=new Set(["Img","Image","Avatar","AvatarUploader","ImageGallery","ProductImageViewer","FileUploader"]),qi={DataGrid:(e,t)=>c.jsxs("div",{className:"w-full border border-gray-200 dark:border-gray-700 rounded-lg overflow-hidden",children:[c.jsx("div",{className:`h-10 bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 ${e}`,children:c.jsxs("div",{className:"flex items-center h-full px-4 gap-8",children:[c.jsx("div",{className:"h-3 w-16 bg-gray-300 dark:bg-gray-600 rounded"}),c.jsx("div",{className:"h-3 w-24 bg-gray-300 dark:bg-gray-600 rounded"}),c.jsx("div",{className:"h-3 w-20 bg-gray-300 dark:bg-gray-600 rounded"}),c.jsx("div",{className:"h-3 w-16 bg-gray-300 dark:bg-gray-600 rounded"})]})}),Array.from({length:t},(r,n)=>c.jsx("div",{className:`h-12 border-b border-gray-100 dark:border-gray-800 ${e}`,style:{animationDelay:`${n*75}ms`},children:c.jsxs("div",{className:"flex items-center h-full px-4 gap-8",children:[c.jsx("div",{className:"h-3 w-12 bg-gray-200 dark:bg-gray-700 rounded"}),c.jsx("div",{className:"h-3 flex-1 bg-gray-200 dark:bg-gray-700 rounded"}),c.jsx("div",{className:"h-3 w-16 bg-gray-100 dark:bg-gray-800 rounded"}),c.jsx("div",{className:"h-3 w-14 bg-gray-100 dark:bg-gray-800 rounded"})]})},n))]}),Pagination:e=>c.jsx("div",{className:"flex justify-center gap-1.5 py-3",children:Array.from({length:5},(t,r)=>c.jsx("div",{className:`w-8 h-8 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),Tabs:e=>c.jsxs("div",{children:[c.jsx("div",{className:"flex gap-4 border-b border-gray-200 dark:border-gray-700 pb-2 mb-3",children:Array.from({length:3},(t,r)=>c.jsx("div",{className:`h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),c.jsx("div",{className:`h-32 bg-gray-100 dark:bg-gray-800 rounded ${e}`})]}),TabNavigation:e=>c.jsx("div",{className:"flex gap-4 border-b border-gray-200 dark:border-gray-700 pb-2",children:Array.from({length:3},(t,r)=>c.jsx("div",{className:`h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))}),ProductCard:e=>c.jsxs("div",{className:"rounded-lg overflow-hidden",children:[c.jsx("div",{className:`h-48 w-full bg-gray-200 dark:bg-gray-700 ${e}`}),c.jsxs("div",{className:"p-3 space-y-2",children:[c.jsx("div",{className:`h-3.5 w-3/4 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),c.jsx("div",{className:`h-4 w-1/3 bg-gray-300 dark:bg-gray-600 rounded ${e}`})]})]}),UserInfo:e=>c.jsx("div",{className:`h-3 w-14 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),QuantitySelector:e=>c.jsx("div",{className:`h-9 w-28 bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 ${e}`}),Header:e=>c.jsx("header",{className:"bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700",children:c.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:c.jsxs("div",{className:"flex items-center justify-between h-16",children:[c.jsxs("div",{className:"flex items-center gap-8",children:[c.jsx("div",{className:`h-8 w-24 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),c.jsx("div",{className:"hidden lg:flex items-center gap-6",children:Array.from({length:4},(t,r)=>c.jsx("div",{className:`h-3.5 w-16 bg-gray-200 dark:bg-gray-700 rounded ${e}`},r))})]}),c.jsx("div",{className:"flex items-center gap-4",children:Array.from({length:3},(t,r)=>c.jsx("div",{className:`h-8 w-8 bg-gray-200 dark:bg-gray-700 rounded-full ${e}`},r))})]})})}),Footer:e=>c.jsx("footer",{className:"bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 mt-auto",children:c.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:c.jsxs("div",{className:"flex flex-col items-center gap-4",children:[c.jsx("div",{className:`h-4 w-32 bg-gray-200 dark:bg-gray-700 rounded ${e}`}),c.jsx("div",{className:`h-3 w-48 bg-gray-100 dark:bg-gray-800 rounded ${e}`}),c.jsx("div",{className:"flex gap-3",children:Array.from({length:3},(t,r)=>c.jsx("div",{className:`h-6 w-6 bg-gray-200 dark:bg-gray-700 rounded-full ${e}`},r))}),c.jsx("div",{className:`h-3 w-40 bg-gray-100 dark:bg-gray-800 rounded ${e}`})]})})}),Modal:()=>c.jsx(c.Fragment,{}),Toast:()=>c.jsx(c.Fragment,{}),ConfirmDialog:()=>c.jsx(c.Fragment,{})};function c0(e){if(!e||e.length===0)return[];const t=e.filter(n=>n.if),r=e.filter(n=>!n.if);if(r.length>0&&t.length>0){const n=t.filter(o=>!Qi(o.if));return n.length>1&&d0(n)?[...r,Ji(n)]:[...r,...n]}if(t.length>1&&r.length===0){const n=t.filter(o=>!Qi(o.if));return n.length===0?[]:n.length===1?n:[Ji(n)]}return e}function Qi(e){const t=e.replace(/^\{\{|\}\}$/g,"").trim();return t.startsWith("!")||/\b(hasError|isError|isLoading|error|Error)\b/.test(t)||/===\s*0\s*(\)|\}|$)/.test(t)}function d0(e){if(e.length<2)return!1;const t=[];for(const n of e){const o=(n.if||"").replace(/^\{\{|\}\}$/g,"").trim(),a=o.match(/^(.+?)\s*===\s*['"]/);if(a)t.push(a[1].trim());else{const s=o.match(/(.+?)\s*===\s*['"]/);if(!s)return!1;t.push(s[1].trim())}}const r=t[0];return t.every(n=>n===r)}function Ji(e){return e.reduce((t,r)=>Ea(r)>Ea(t)?r:t)}function Ea(e){return e.children?e.children.length+e.children.reduce((t,r)=>t+Ea(r),0):0}function u0(e){return e.includes("{{")?e.replace(/\{\{([^}]+)\}\}/g,(t,r)=>{const n=r.match(/\?[\s]*['"]([^'"]*)['"]\s*:\s*['"]/);return n?n[1]:""}):e}function Ta(e,t){if(!e)return"";let r=e;return r=r.replace(/\b(bg-\S+|text-\S+|border\b|border-\S+|shadow\S*|ring-\S+|outline-\S+|divide-\S+|opacity-\S+|font-\S+|tracking-\S+|leading-\S+|whitespace-\S+|truncate|line-clamp-\S+|underline|no-underline|decoration-\S+|cursor-\S+|hover:\S+|focus:\S+|active:\S+|group-hover:\S+|transition\S*|duration-\S+|ease-\S+|animate-\S+|dark:\S+)\b/g,"").replace(/\s{2,}/g," ").trim(),(t==="Grid"||/\bgrid-cols-\d/.test(r))&&(r=r.replace(/\bgrid-cols-(\d+)/g,(n,o)=>{const a=parseInt(o);return a>4?`grid-cols-${Math.ceil(a/2)}`:`grid-cols-${a}`})),r}function f0(e){const{name:t,props:r}=e;if(!r||!t)return"";const n=[];if(t==="Flex"){n.push("flex");const o=r.direction||"row",a={row:"flex-row","row-reverse":"flex-row-reverse",col:"flex-col","col-reverse":"flex-col-reverse"};a[o]&&n.push(a[o]);const s=r.justify||"start",l={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};l[s]&&n.push(l[s]);const f=r.align||"stretch",h={start:"items-start",end:"items-end",center:"items-center",baseline:"items-baseline",stretch:"items-stretch"};h[f]&&n.push(h[f]);const d=r.wrap||"nowrap",i={wrap:"flex-wrap",nowrap:"flex-nowrap","wrap-reverse":"flex-wrap-reverse"};i[d]&&n.push(i[d]),r.gap&&r.gap>0&&n.push(`gap-${r.gap}`)}if(t==="Grid"){n.push("grid");const o=r.cols||1;if(n.push(`grid-cols-${o}`),r.responsive){const a=r.responsive;a.sm&&n.push(`sm:grid-cols-${a.sm}`),a.md&&n.push(`md:grid-cols-${a.md}`),a.lg&&n.push(`lg:grid-cols-${a.lg}`),a.xl&&n.push(`xl:grid-cols-${a.xl}`),a["2xl"]&&n.push(`2xl:grid-cols-${a["2xl"]}`)}r.gap!==void 0&&r.gap>0&&n.push(`gap-${r.gap}`),r.rowGap!==void 0&&r.rowGap>0&&n.push(`gap-y-${r.rowGap}`),r.colGap!==void 0&&r.colGap>0&&n.push(`gap-x-${r.colGap}`)}return n.join(" ")}function g0(e){switch(e){case"pulse":return"animate-pulse";case"wave":return"animate-pulse";case"none":return"";default:return"animate-pulse"}}function Zn(e,t,r,n){return!e||e.length===0?[]:c0(e).map((a,s)=>Ri(a,t,r,s,n))}function h0(e,t){const r=e.props?.className||e.className||"";return e.responsive?t>=1024&&e.responsive.desktop?.props?.className?e.responsive.desktop.props.className:t>=768&&e.responsive.tablet?.props?.className?e.responsive.tablet.props.className:r:r}function p0(e,t){const r=e.split(/\s+/).filter(Boolean),n=[],o=[];for(const f of r){const h=f.match(/^(sm|md|lg|xl|2xl):(.+)$/);if(h){const[,d,i]=h;if(Zi.has(i)){n.push({breakpoint:Xi[d]||0,display:i});continue}(Xi[d]||0)<=t&&o.push(i);continue}if(Zi.has(f)){n.push({breakpoint:0,display:f});continue}o.push(f)}if(n.length===0)return{visible:!0,className:e};n.sort((f,h)=>f.breakpoint-h.breakpoint);let a="";for(const f of n)f.breakpoint<=t&&(a=f.display);a||(a=n[0].display);const s=a!=="hidden",l=s?[a,...o].join(" "):"";return{visible:s,className:l}}function m0(e){const t=e.match(/\bgrid-cols-\[([^\]]+)\]/);if(!t)return{className:e};const r=t[1].replace(/_/g," ");return{className:e.replace(/\bgrid-cols-\[([^\]]+)\]/,"").replace(/\s{2,}/g," ").trim(),style:{gridTemplateColumns:r}}}function Ri(e,t,r,n,o){const{name:a,children:s,iteration:l}=e,f=h0(e,o),h=f0(e),d=h?`${h} ${f}`.trim():f,i=u0(d),u=p0(i,o);if(!a||!u.visible)return null;const g=u.className;if(l)return c.jsx(k.Fragment,{children:Array.from({length:r},(m,w)=>Ri({...e,iteration:void 0},t,r,w,o))},n);if(qi[a])return c.jsx("div",{className:g,children:qi[a](t,r)},n);if(a0.has(a)){const m=Ta(g,a);if(!s||s.length===0){const E=/\b(h-\S|w-\S)/.test(m)?`${m} bg-gray-200 dark:bg-gray-700 rounded ${t}`:`${m} h-3.5 w-full bg-gray-200 dark:bg-gray-700 rounded ${t}`.trim();return c.jsx("div",{className:E},n)}const w=Zn(s,t,r,o);if(!(w.length>0&&w.some(v=>v!==null)))return null;const A=m0(m);return c.jsx("div",{className:A.className,style:A.style,children:w},n)}const p=Ta(g,a);if(s0.has(a)){const m={H1:"h-7",H2:"h-6",H3:"h-5",H4:"h-5",H5:"h-4",H6:"h-4",P:"h-3.5",Span:"h-3",Label:"h-3",A:"h-3.5",Badge:"h-5 w-16"},w={H1:"w-3/5",H2:"w-2/5",H3:"w-1/3",H4:"w-1/3",H5:"w-1/4",H6:"w-1/4",P:"w-full",Span:"w-1/4",Label:"w-1/4",A:"w-1/3",Strong:"w-1/5",Em:"w-1/4",Small:"w-1/5",Badge:"w-16"},x=m[a]||"h-3.5",A=w[a]||"w-full",v=a.startsWith("H")?"mb-2 mt-1":"mb-1.5";return c.jsx("div",{className:`${x} ${A} bg-gray-200 dark:bg-gray-700 rounded ${t} ${v} ${p}`.trim()},n)}if(l0.has(a))return a==="Textarea"?c.jsx("div",{className:`h-20 w-full bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 mb-2 ${t}`},n):a==="Checkbox"||a==="Radio"||a==="Toggle"?c.jsx("div",{className:`h-5 w-5 bg-gray-200 dark:bg-gray-700 rounded mb-1.5 ${t}`},n):c.jsx("div",{className:`h-9 w-full bg-gray-100 dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-700 mb-2 ${t}`},n);if(i0.has(a))return a==="Avatar"||a==="AvatarUploader"?c.jsx("div",{className:`h-10 w-10 bg-gray-200 dark:bg-gray-700 rounded-full ${t}`},n):a==="ProductImageViewer"?c.jsx("div",{className:`h-80 w-full bg-gray-200 dark:bg-gray-700 rounded ${t}`},n):c.jsx("div",{className:`h-40 w-full bg-gray-200 dark:bg-gray-700 rounded mb-2 ${t}`},n);if(a==="Button"){if(s&&s.length>0){const m=Ta(g,a),w=Zn(s,t,r,o);if(!(w.length>0&&w.some(E=>E!==null)))return null;const v=/\b(border|rounded|px-\d|py-\d)/.test(f)?"border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 rounded-lg":"";return c.jsx("div",{className:`${m} ${v}`.trim(),children:w},n)}return c.jsx("div",{className:`h-9 w-24 bg-gray-200 dark:bg-gray-700 rounded ${t}`},n)}return a==="Icon"?c.jsx("div",{className:`h-5 w-5 bg-gray-200 dark:bg-gray-700 rounded ${t}`},n):s&&s.length>0?c.jsx("div",{className:p,children:Zn(s,t,r,o)},n):c.jsx("div",{className:`h-3.5 w-full bg-gray-200 dark:bg-gray-700 rounded mb-1.5 ${t}`},n)}const Na=({components:e,options:t})=>{const r=g0(t.animation),o=window.G7Core?.useResponsive,a=o?.(),s=a?a.width:typeof window<"u"?window.innerWidth:1024;return c.jsx("div",{className:"w-full",role:"status","aria-busy":"true","aria-label":"Loading...",children:Zn(e,r,t.iteration_count,s)})},b0=Object.freeze(Object.defineProperty({__proto__:null,PageSkeleton:Na,default:Na},Symbol.toStringTag,{value:"Module"})),y0=(e,t)=>window.G7Core?.t?.(e,t)??e,ec=({options:e})=>{const t=document.documentElement.classList.contains("dark"),r=t?"rgb(17,24,39)":"rgb(249,250,251)",n=t?"#6b7280":"#9ca3af",o=t?"#9ca3af":"#6b7280";return c.jsxs("div",{style:{position:"absolute",inset:0,zIndex:2147483647,overflow:"hidden",background:r,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"flex-start",paddingTop:"15%",gap:"12px"},children:[c.jsx("div",{style:{width:"32px",height:"32px",border:`3px solid ${n}`,borderTopColor:"transparent",borderRadius:"50%",animation:"g7-spin 0.8s linear infinite"}}),c.jsx("span",{style:{color:o,fontSize:"14px"},children:e?.text||y0("nav.loading")})]})},v0=Object.freeze(Object.defineProperty({__proto__:null,default:ec},Symbol.toStringTag,{value:"Module"})),Dr=(e,t)=>window.G7Core?.t?.(e,t)??e,tc=({currentPage:e,totalPages:t,onPageChange:r,maxVisiblePages:n=5,showFirstLast:o=!0,className:a="",style:s,prevText:l,nextText:f,id:h,editorAttrs:d})=>{const i=k.useMemo(()=>{const m=[];if(t<=n+2)for(let w=1;w<=t;w++)m.push(w);else{const w=Math.floor(n/2);let x=Math.max(2,e-w),A=Math.min(t-1,e+w);e<=w+1?A=n:e>=t-w&&(x=t-n+1),m.push(1),x>2&&m.push("...");for(let v=x;v<=A;v++)m.push(v);A1&&m.push(t)}return m},[e,t,n]),u=m=>{m<1||m>t||m===e||r(m)},g=()=>{e>1&&r(e-1)},p=()=>{eu(1),disabled:e===1,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Dr("common.first_page"),children:"«"}),c.jsx(Q,{onClick:g,disabled:e===1,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Dr("common.prev_page"),children:l||c.jsx(c.Fragment,{children:"‹"})}),c.jsx(W,{className:"flex items-center gap-1",children:i.map((m,w)=>{if(m==="...")return c.jsx(ee,{className:"px-3 py-1 text-sm text-gray-500 dark:text-gray-400",children:"..."},`ellipsis-${w}`);const x=m,A=x===e;return c.jsx(Q,{onClick:()=>u(x),className:`px-3 py-1 text-sm border rounded ${A?"bg-blue-500 dark:bg-blue-600 text-white border-blue-500 dark:border-blue-600":"border-gray-300 dark:border-gray-600 hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800"}`,"aria-label":Dr("common.page_n",{n:x}),"aria-current":A?"page":void 0,children:x},x)})}),c.jsx(Q,{onClick:p,disabled:e===t,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Dr("common.next_page"),children:f||c.jsx(c.Fragment,{children:"›"})}),o&&c.jsx(Q,{onClick:()=>u(t),disabled:e===t,className:"px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-100 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800","aria-label":Dr("common.last_page"),children:"»"})]})},w0=Object.freeze(Object.defineProperty({__proto__:null,Pagination:tc},Symbol.toStringTag,{value:"Module"})),rc=(e,t)=>window.G7Core?.t?.(e,t)??e,nc=({name:e="search",placeholder:t,value:r,onChange:n,onSubmit:o,showButton:a=!1,suggestions:s=[],onSuggestionClick:l,showSuggestions:f=!1,className:h="",style:d,id:i,editorAttrs:u})=>{const g=t??rc("common.search_placeholder"),[p,m]=k.useState(""),[w,x]=k.useState(!1),A=k.useRef(null),v=k.useRef(""),E=r!==void 0?r:p,O=f&&w&&s.length>0&&E.length>0;k.useEffect(()=>{r!==void 0&&(v.current=r)},[r]);const _=y=>{const N=y.target.value;m(N),n?.(y),v.current!==""&&N===""&&!y.nativeEvent.inputType&&setTimeout(()=>{const M=A.current?.querySelector("form");M&&M.requestSubmit()},0),v.current=N},I=y=>{m(y.text);const N={target:{value:y.text,name:e}};n?.(N),l?.(y),x(!1)},C=y=>{y.preventDefault(),o?.(y)};return c.jsxs(W,{ref:A,className:`relative ${h}`,style:d,id:i,...u,children:[c.jsx(so,{onSubmit:C,className:"relative",children:c.jsxs(W,{className:`relative flex items-center ${a?"gap-2":""}`,children:[c.jsxs(W,{className:"relative flex-1",children:[c.jsx(W,{className:"absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",children:c.jsx(de,{name:Je.Search,className:"w-5 h-5 text-gray-400 dark:text-gray-500"})}),c.jsx(xt,{type:"search",name:e,value:E,onChange:_,onFocus:()=>x(!0),onBlur:()=>setTimeout(()=>x(!1),200),placeholder:g,className:"w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm"})]}),a&&c.jsx(Q,{type:"submit",className:"px-4 py-2 bg-gray-800 dark:bg-gray-600 text-white rounded-lg hover:bg-gray-900 dark:hover:bg-gray-500 transition-colors text-sm font-medium cursor-pointer h-[42px]",children:rc("common.search")})]})}),O&&c.jsx(W,{className:"absolute z-10 w-full mt-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-64 overflow-y-auto",children:s.map(y=>c.jsx(W,{className:"px-4 py-3 hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-b-0 transition-colors",onClick:()=>I(y),children:c.jsxs(W,{className:"flex items-center gap-2",children:[c.jsx(de,{name:Je.Search,className:"w-4 h-4 text-gray-400 dark:text-gray-500"}),c.jsx(ee,{className:"text-sm text-gray-700 dark:text-gray-300",children:y.text})]})},y.id))})]})},x0=Object.freeze(Object.defineProperty({__proto__:null,SearchBar:nc},Symbol.toStringTag,{value:"Module"})),vt=window.G7Core,k0={sm:"md",md:"lg",lg:"xl",xl:"2xl","2xl":"3xl"};function Aa({src:e,fallbackText:t="U",size:r="lg",uploadEndpoint:n="/api/me/avatar",deleteEndpoint:o="/api/me/avatar",onUploadSuccess:a,onUploadError:s,onDeleteSuccess:l,onDeleteError:f,showDeleteButton:h=!0,accept:d="image/*",maxSize:i=5,className:u="",uploadButtonText:g,deleteButtonText:p,readOnly:m=!1,confirmDelete:w=!0,deleteConfirmMessage:x,confirmUpload:A=!0,uploadConfirmMessage:v,uploadSuccessActions:E,uploadErrorActions:O,deleteSuccessActions:_,deleteErrorActions:I,id:C,editorAttrs:y}){const N=k.useRef(null),[M,P]=k.useState(!1),[D,L]=k.useState(!1),[U,S]=k.useState(void 0),[b,$]=k.useState(null),[F,G]=k.useState(!1),[Y,B]=k.useState(!1),[V,j]=k.useState(null),[H,Z]=k.useState(null),ue=k.useRef(`avatar-upload-${Math.random().toString(36).slice(2,11)}`).current;k.useEffect(()=>{if(V){const oe=URL.createObjectURL(V);return Z(oe),()=>URL.revokeObjectURL(oe)}else Z(null)},[V]);const te=k.useCallback(oe=>vt?.t?.(oe)??oe,[]),fe=k.useCallback(()=>{const oe=document.cookie.match(/XSRF-TOKEN=([^;]+)/);return oe?decodeURIComponent(oe[1]):null},[]),R=k.useCallback(()=>vt?.api?.getToken?.()??null,[]),ke=k.useCallback(async oe=>{B(!1),j(null),P(!0),$(null);try{const ae=new FormData;ae.append("avatar",oe);const be=fe(),xe=R(),He=await fetch(n,{method:"POST",headers:{Accept:"application/json",...be&&{"X-XSRF-TOKEN":be},...xe&&{Authorization:`Bearer ${xe}`}},credentials:"include",body:ae});if(!He.ok){const Oe=await He.json().catch(()=>({}));throw new Error(Oe.message||te("attachment.upload_failed"))}const Pe=await He.json(),Ke=Pe.data||Pe;Ke.avatar&&S(Ke.avatar),a?.(Ke),vt?.toast?.success?.(te("mypage.profile.avatar_uploaded")),E?.length?E.forEach(Oe=>vt?.dispatch?.(Oe)):vt?.refetchDataSource?.("user")}catch(ae){const be=ae instanceof Error?ae:new Error(String(ae));$(be.message),s?.(be),vt?.toast?.error?.(be.message),O?.length&&O.forEach(xe=>vt?.dispatch?.(xe))}finally{P(!1),N.current&&(N.current.value="")}},[n,a,s,fe,R,te]),me=k.useCallback(async oe=>{const ae=oe.target.files?.[0];if(!ae)return;$(null);const be=i*1024*1024;if(ae.size>be){const xe=new Error(te("attachment.file_too_large").replace(":max",`${i}MB`));$(xe.message),s?.(xe),vt?.toast?.error?.(xe.message);return}if(d&&!ae.type.match(d.replace("*",".*"))){const xe=new Error(te("attachment.invalid_file_type"));$(xe.message),s?.(xe),vt?.toast?.error?.(xe.message);return}A?(j(ae),B(!0)):ke(ae)},[i,d,s,A,ke,te]),Ge=k.useCallback(async()=>{G(!1),L(!0),$(null);try{const oe=fe(),ae=R(),be=await fetch(o,{method:"DELETE",headers:{Accept:"application/json","Content-Type":"application/json",...oe&&{"X-XSRF-TOKEN":oe},...ae&&{Authorization:`Bearer ${ae}`}},credentials:"include"});if(!be.ok){const xe=await be.json().catch(()=>({}));throw new Error(xe.message||te("attachment.delete_failed"))}S(null),l?.(),vt?.toast?.success?.(te("mypage.profile.avatar_deleted")),_?.length?_.forEach(xe=>vt?.dispatch?.(xe)):vt?.refetchDataSource?.("user")}catch(oe){const ae=oe instanceof Error?oe:new Error(String(oe));$(ae.message),f?.(ae),vt?.toast?.error?.(ae.message),I?.length&&I.forEach(be=>vt?.dispatch?.(be))}finally{L(!1)}},[o,l,f,fe,R,te]),De=k.useCallback(()=>{w?G(!0):Ge()},[w,Ge]),ye=k.useCallback(()=>{G(!1)},[]),Me=k.useCallback(()=>{B(!1),j(null),N.current&&(N.current.value="")},[]),Ce=k.useCallback(()=>{V&&ke(V)},[V,ke]),we=U===void 0?e:U,$e=!!we,Le=k0[r]||"lg",K=F||Y,re=()=>c.jsxs(W,{className:"flex items-center justify-center gap-2",children:[c.jsx(xt,{ref:N,id:ue,type:"file",accept:d,className:"hidden",onChange:me,disabled:M}),!$e&&c.jsxs(yr,{htmlFor:ue,className:`inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${M?"opacity-50 cursor-not-allowed":""}`,children:[M?c.jsx(de,{name:"spinner",size:"sm",className:"animate-spin"}):c.jsx(de,{name:"image",size:"sm"}),c.jsx(ee,{children:g||te("mypage.profile.register_avatar")})]}),$e&&c.jsxs(c.Fragment,{children:[c.jsxs(yr,{htmlFor:ue,className:`inline-flex items-center gap-2 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer ${M?"opacity-50 cursor-not-allowed":""}`,children:[M?c.jsx(de,{name:"spinner",size:"sm",className:"animate-spin"}):c.jsx(de,{name:"upload",size:"sm"}),c.jsx(ee,{children:g||te("common.change")})]}),h&&c.jsxs(Q,{type:"button",className:"inline-flex items-center gap-2 px-4 py-2 border border-red-300 dark:border-red-600 text-red-600 dark:text-red-400 rounded-lg text-sm font-medium hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:De,disabled:D,children:[D?c.jsx(de,{name:"spinner",size:"sm",className:"animate-spin"}):c.jsx(de,{name:"trash-2",size:"sm"}),c.jsx(ee,{children:p||te("common.delete")})]})]})]});return c.jsxs(W,{className:`flex flex-col items-center gap-3 ${u}`,id:C,...y,children:[Y&&H?c.jsxs(W,{className:"relative",children:[c.jsx(Lt,{src:H,alt:"Preview",className:`rounded-full object-cover ${r==="sm"?"w-10 h-10":r==="md"?"w-12 h-12":r==="lg"?"w-16 h-16":r==="xl"?"w-24 h-24":"w-32 h-32"}`}),c.jsx(W,{className:"absolute inset-0 rounded-full bg-blue-500/20 border-2 border-blue-500 border-dashed"})]}):c.jsx(Ur,{avatar:we||void 0,name:t,size:Le}),!m&&c.jsxs(W,{className:"w-[220px] flex flex-col items-center gap-2",children:[Y&&V&&c.jsxs(W,{className:"w-full p-3 bg-blue-50 dark:bg-blue-950/50 border border-blue-200 dark:border-blue-800 rounded-lg",children:[c.jsxs(W,{className:"flex items-center gap-2 mb-2",children:[c.jsx(de,{name:"upload",size:"sm",className:"text-blue-600 dark:text-blue-400 shrink-0"}),c.jsx(ee,{className:"text-sm font-medium text-blue-800 dark:text-blue-300",children:v||te("mypage.profile.upload_avatar_confirm")})]}),c.jsxs(W,{className:"text-xs text-blue-600 dark:text-blue-400 truncate mb-3",title:V.name,children:[V.name," (",(V.size/1024/1024).toFixed(2),"MB)"]}),c.jsxs(W,{className:"grid grid-cols-2 gap-2",children:[c.jsxs(Q,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors disabled:opacity-50",onClick:Ce,disabled:M,children:[M?c.jsx(de,{name:"spinner",size:"sm",className:"animate-spin"}):c.jsx(de,{name:"check",size:"sm"}),c.jsx(ee,{children:te("common.confirm")})]}),c.jsx(Q,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",onClick:Me,children:c.jsx(ee,{children:te("common.cancel")})})]})]}),F&&c.jsxs(W,{className:"w-full p-3 bg-red-50 dark:bg-red-950/50 border border-red-200 dark:border-red-800 rounded-lg",children:[c.jsxs(W,{className:"flex items-center gap-2 mb-2",children:[c.jsx(de,{name:"alert-triangle",size:"sm",className:"text-red-600 dark:text-red-400 shrink-0"}),c.jsx(ee,{className:"text-sm font-medium text-red-800 dark:text-red-300",children:x||te("mypage.profile.delete_avatar_confirm")})]}),c.jsxs(W,{className:"grid grid-cols-2 gap-2",children:[c.jsxs(Q,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-red-600 hover:bg-red-700 text-white rounded-md text-sm font-medium transition-colors disabled:opacity-50",onClick:Ge,disabled:D,children:[D?c.jsx(de,{name:"spinner",size:"sm",className:"animate-spin"}):c.jsx(de,{name:"trash-2",size:"sm"}),c.jsx(ee,{children:te("common.delete")})]}),c.jsx(Q,{type:"button",className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-md text-sm font-medium hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors",onClick:ye,children:c.jsx(ee,{children:te("common.cancel")})})]})]}),!K&&re()]}),b&&!K&&c.jsxs(W,{className:"flex items-center gap-2 text-sm text-red-600 dark:text-red-400",children:[c.jsx(de,{name:"alert-circle",size:"sm"}),c.jsx(ee,{children:b})]})]})}const C0=Object.freeze(Object.defineProperty({__proto__:null,AvatarUploader:Aa,default:Aa},Symbol.toStringTag,{value:"Module"})),oc=()=>window.G7Core,qn=(e,t)=>window.G7Core?.t?.(e,t)??e,ac={horizontal:"flex items-center gap-1.5",vertical:"flex flex-col items-start"},S0=()=>[{key:"view_profile",label:qn("userinfo.view_profile"),icon:"user",path:"/users/{{userId}}"},{key:"view_posts",label:qn("userinfo.view_posts"),icon:"file-lines",path:"/users/{{userId}}/posts"}],Ma=({text:e,title:t})=>e?c.jsx(ee,{className:"text-sm text-gray-500 dark:text-gray-400",title:t,children:e}):null,sc=({author:e,name:t,userId:r,subText:n,subTextTitle:o,isGuest:a=!1,isWithdrawn:s=!1,showDropdown:l=!0,clickable:f=!0,profilePath:h="/users/{userId}",className:d="",layout:i="vertical",text:u,stopPropagation:g=!1,menuItems:p,hideMenuItems:m=[],appendMenuItems:w=[],id:x,editorAttrs:A})=>{const v=r??e?.uuid,E=a||e?.is_guest||!1,O=s||e?.status==="withdrawn",_=O?qn("userinfo.withdrawn_user"):u??t??e?.name??"",[I,C]=k.useState(!1),[y,N]=k.useState({top:0,left:0}),M=k.useRef(null),P=k.useRef(null),D=k.useRef(null),L=h.replace("{userId}",String(v??"")),U=`${ac[i]} ${d}`;k.useEffect(()=>{if(!I)return;const j=Z=>{const ue=Z.target,te=M.current?.contains(ue),fe=P.current?.contains(ue);!te&&!fe&&C(!1)},H=()=>C(!1);return document.addEventListener("mousedown",j),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{document.removeEventListener("mousedown",j),window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[I]);const S=k.useCallback(()=>{if(p&&p.length>0)return p.filter(Z=>Z.show!==!1);let H=S0().filter(Z=>!m.includes(Z.key)&&Z.show!==!1);return w&&w.length>0&&(H=[...H,...w.filter(Z=>Z.show!==!1)]),H},[p,m,w]),b=k.useCallback(()=>{if(D.current){const j=D.current.getBoundingClientRect();N({top:j.bottom+4,left:j.left})}},[]),$=k.useCallback((j,H)=>{if(H.stopPropagation(),H.preventDefault(),C(!1),j.onClick)j.onClick();else if(j.path){const Z=j.path.replace(/\{\{userId\}\}/g,String(v??"")),ue=oc();ue?.navigate?ue.navigate(Z):window.location.href=Z}},[v]),F=k.useCallback(j=>{j.preventDefault(),g&&j.stopPropagation(),!(E||!v)&&(l?(I||b(),C(H=>!H)):f&&oc()?.navigate?.(L))},[g,E,v,l,I,b,f,L]);if(E||!v)return c.jsxs(W,{className:U,id:x,...A,children:[c.jsxs(W,{className:"flex items-center gap-1.5 text-gray-400 dark:text-gray-500",children:[c.jsx(ee,{children:_}),c.jsx(ee,{className:"text-xs px-1.5 py-0.5 bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded",children:qn("userinfo.guest_badge")})]}),c.jsx(Ma,{text:n,title:o})]});if(O)return c.jsxs(W,{className:U,id:x,...A,children:[c.jsx(ee,{className:"text-gray-400 dark:text-gray-500 line-through",children:_}),c.jsx(Ma,{text:n,title:o})]});const G=S(),B=/\btext-\S+/.test(d)?"":"text-gray-900 dark:text-white",V=l||f?`${B} hover:text-blue-600 dark:hover:text-blue-400 cursor-pointer font-medium`.trim():`${B} font-medium`.trim();return c.jsxs(W,{ref:M,className:`relative inline-block ${d}`,id:x,...A,children:[c.jsxs(W,{className:ac[i],children:[c.jsx(Q,{ref:D,onClick:F,className:V,children:_}),c.jsx(Ma,{text:n,title:o})]}),l&&I&&G.length>0&&Jt.createPortal(c.jsx(W,{ref:P,className:"fixed w-40 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 z-[9999]",style:{top:y.top,left:y.left},"data-testid":"author-dropdown-menu",children:G.map(j=>c.jsxs(Q,{onClick:H=>$(j,H),className:"flex items-center justify-start gap-2 w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer","data-testid":`menu-item-${j.key}`,children:[j.icon&&c.jsx(de,{name:j.icon,className:"w-4 h-4"}),c.jsx(ee,{children:j.label})]},j.key))}),document.body)]})},_0=Object.freeze(Object.defineProperty({__proto__:null,UserInfo:sc},Symbol.toStringTag,{value:"Module"})),lc=({tabs:e,activeTabId:t,onTabChange:r,variant:n="underline",className:o="",style:a,hiddenTabIds:s=[],mobileBreakpoint:l=768,id:f,editorAttrs:h})=>{const i=window.G7Core?.useResponsive,u=i?.(),g=u?u.width{!v.disabled&&v.id!==t&&r?.(v.id)},m=v=>{const E=v.target.value,O=Number(E),_=typeof E=="string"&&E!==""&&!Number.isNaN(O)?O:E,I=e.find(C=>String(C.id)===String(_));I&&p(I)},w=s.length>0?e.filter(v=>!s.includes(v.id)):e;if(g)return c.jsx(W,{className:`relative ${o}`,style:a,id:f,...h,children:c.jsx(Xa,{value:t!==void 0?String(t):"",onChange:m,options:w.map(v=>({value:String(v.id),label:v.badge!==void 0?`${v.label} (${v.badge})`:v.label,disabled:v.disabled})),className:"w-full"})});const x=v=>{const E=v.id===t,O="flex items-center gap-2 px-3 py-2 font-medium text-sm transition-all shrink-0 whitespace-nowrap";if(v.disabled)return`${O} opacity-50 cursor-not-allowed text-gray-400 dark:text-gray-600`;switch(n){case"pills":return E?`${O} bg-blue-600 dark:bg-blue-500 text-white rounded-lg`:`${O} text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg`;case"underline":return E?`${O} text-gray-900 dark:text-white border-b-2 border-gray-900 dark:border-white`:`${O} text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 border-b-2 border-transparent hover:border-gray-300 dark:hover:border-gray-600`;default:return E?`${O} text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/20 border-b-2 border-blue-600 dark:border-blue-400`:`${O} text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700 border-b-2 border-transparent`}},A=n==="underline"?"flex gap-0 border-b border-gray-200 dark:border-gray-700":"flex gap-2";return c.jsx(W,{className:`relative ${o}`,style:a,id:f,...h,children:c.jsx($r,{className:A,children:w.map(v=>c.jsxs(Q,{type:"button",onClick:()=>p(v),disabled:v.disabled,className:x(v),children:[v.iconName&&c.jsx(de,{name:v.iconName,size:"sm"}),c.jsx(ee,{children:v.label}),v.badge!==void 0&&c.jsx(W,{className:"flex items-center justify-center min-w-5 h-5 px-1.5 bg-red-500 text-white text-xs font-bold rounded-full",children:c.jsx(ee,{children:v.badge})})]},v.id))})})},E0=Object.freeze(Object.defineProperty({__proto__:null,TabNavigation:lc},Symbol.toStringTag,{value:"Module"})),T0={Header:()=>Promise.resolve().then(()=>od),Footer:()=>Promise.resolve().then(()=>id),MobileNav:()=>Promise.resolve().then(()=>cd),SlotContainer:()=>Promise.resolve().then(()=>rd),NotificationCenter:()=>Promise.resolve().then(()=>nd),ProductCard:()=>Promise.resolve().then(()=>Ld),BrandMark:()=>Promise.resolve().then(()=>Fd),ImageGallery:()=>Promise.resolve().then(()=>Al),ProductImageViewer:()=>Promise.resolve().then(()=>jf),QuantitySelector:()=>Promise.resolve().then(()=>Bf),PostReactions:()=>Promise.resolve().then(()=>Vf),RichTextEditor:()=>Promise.resolve().then(()=>Yf),HtmlContent:()=>Promise.resolve().then(()=>Xf),HtmlEditor:()=>Promise.resolve().then(()=>Zf),ExpandableContent:()=>Promise.resolve().then(()=>qf),FileUploader:()=>Promise.resolve().then(()=>Xh),ConfirmDialog:()=>Promise.resolve().then(()=>Rf),SocialLoginButtons:()=>Promise.resolve().then(()=>qh),Toast:()=>Promise.resolve().then(()=>t0),PageTransitionIndicator:()=>Promise.resolve().then(()=>n0),PageTransitionBlur:()=>Promise.resolve().then(()=>o0),PageSkeleton:()=>Promise.resolve().then(()=>b0),PageLoading:()=>Promise.resolve().then(()=>v0),ThemeToggle:()=>Promise.resolve().then(()=>Qc),Pagination:()=>Promise.resolve().then(()=>w0),SearchBar:()=>Promise.resolve().then(()=>x0),Avatar:()=>Promise.resolve().then(()=>ed),AvatarUploader:()=>Promise.resolve().then(()=>C0),UserInfo:()=>Promise.resolve().then(()=>_0),Modal:()=>Promise.resolve().then(()=>Jf),TabNavigation:()=>Promise.resolve().then(()=>E0)},N0=({id:e,className:t,style:r,children:n,editorAttrs:o})=>c.jsx(W,{id:e,className:t,style:r,...o,children:n}),A0=({id:e,children:t,cols:r=1,responsive:n,gap:o,rowGap:a,colGap:s,autoRows:l,autoCols:f,flow:h="row",className:d="",style:i,onClick:u,editorAttrs:g})=>{const p=["grid"];if(r&&p.push(`grid-cols-${r}`),n&&(n.sm&&p.push(`sm:grid-cols-${n.sm}`),n.md&&p.push(`md:grid-cols-${n.md}`),n.lg&&p.push(`lg:grid-cols-${n.lg}`),n.xl&&p.push(`xl:grid-cols-${n.xl}`),n["2xl"]&&p.push(`2xl:grid-cols-${n["2xl"]}`)),o!==void 0&&o>0&&p.push(`gap-${o}`),a!==void 0&&a>0&&p.push(`gap-y-${a}`),s!==void 0&&s>0&&p.push(`gap-x-${s}`),l){const w={auto:"auto-rows-auto",min:"auto-rows-min",max:"auto-rows-max",fr:"auto-rows-fr"};p.push(w[l])}if(f){const w={auto:"auto-cols-auto",min:"auto-cols-min",max:"auto-cols-max",fr:"auto-cols-fr"};p.push(w[f])}const m={row:"grid-flow-row",col:"grid-flow-col",dense:"grid-flow-dense","row-dense":"grid-flow-row-dense","col-dense":"grid-flow-col-dense"};return p.push(m[h]),d&&p.push(d),c.jsx(W,{id:e,className:p.join(" "),style:i,onClick:u,...g,children:t})},M0=({id:e,children:t,direction:r="row",justify:n="start",align:o="stretch",wrap:a="nowrap",gap:s=0,grow:l=!1,shrink:f=!0,className:h="",style:d,onClick:i,editorAttrs:u})=>{const g=["flex"],p={row:"flex-row","row-reverse":"flex-row-reverse",col:"flex-col","col-reverse":"flex-col-reverse"};g.push(p[r]);const m={wrap:"flex-wrap",nowrap:"flex-nowrap","wrap-reverse":"flex-wrap-reverse"};g.push(m[a]);const w={start:"justify-start",end:"justify-end",center:"justify-center",between:"justify-between",around:"justify-around",evenly:"justify-evenly"};g.push(w[n]);const x={start:"items-start",end:"items-end",center:"items-center",baseline:"items-baseline",stretch:"items-stretch"};return g.push(x[o]),s>0&&g.push(`gap-${s}`),l===!0?g.push("flex-grow"):typeof l=="number"&&l>0&&g.push(`flex-grow-${l}`),f===!1?g.push("shrink-0"):f===!0?g.push("flex-shrink"):typeof f=="number"&&f>0&&g.push(`flex-shrink-${f}`),h&&g.push(h),c.jsx(W,{id:e,className:g.join(" "),style:d,onClick:i,...u,children:t})},O0=({id:e,title:t,subtitle:r,children:n,padding:o="md",background:a="none",maxWidth:s,centered:l=!1,border:f=!1,shadow:h="none",rounded:d=!1,className:i="",style:u,onClick:g,editorAttrs:p})=>{const m=[],w={none:"p-0",sm:"p-2",md:"p-4",lg:"p-6",xl:"p-8"};m.push(w[o]);const x={none:"",white:"bg-white dark:bg-gray-700",gray:"bg-gray-50 dark:bg-gray-800",primary:"bg-blue-50 dark:bg-blue-900/20",secondary:"bg-gray-50 dark:bg-gray-800"};if(a!=="none"&&m.push(x[a]),s){const v={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl","4xl":"max-w-4xl","6xl":"max-w-6xl","7xl":"max-w-7xl",full:"max-w-full"};m.push(v[s])}l&&m.push("mx-auto"),f&&m.push("border","border-gray-200","dark:border-gray-700");const A={none:"",sm:"shadow-sm",md:"shadow-md",lg:"shadow-lg",xl:"shadow-xl"};return h!=="none"&&m.push(A[h]),d&&m.push("rounded-lg"),i&&m.push(i),c.jsxs(qa,{id:e,className:m.join(" "),style:u,onClick:g,...p,children:[(t||r)&&c.jsxs(W,{className:"mb-4",children:[t&&c.jsx(Va,{className:"text-2xl font-bold text-gray-900 dark:text-white",children:t}),r&&c.jsx(Dt,{className:"mt-1 text-sm text-gray-600 dark:text-gray-400",children:r})]}),n]})},I0=({id:e,leftWidth:t="250px",rightWidth:r="300px",leftSlot:n,centerSlot:o,rightSlot:a,className:s="",style:l,editorAttrs:f})=>{const h=`flex flex-row w-full h-full ${s}`.trim(),d={width:t,flexShrink:0},i={flex:1,minWidth:0},u={width:r,flexShrink:0};return c.jsxs(W,{id:e,className:h,style:l,...f,children:[c.jsx(W,{className:"flex flex-col",style:d,children:n}),c.jsx(W,{className:"flex flex-col",style:i,children:o}),c.jsx(W,{className:"flex flex-col",style:u,children:a})]})},D0={identifier:"sirsoft-basic",vendor:"sirsoft",name:{ko:"Basic",en:"Basic"},version:"1.0.3",license:"MIT",description:{ko:"그누보드7 기본 사용자 템플릿",en:"Gnuboard7 default user template"},type:"user",locales:["ko","en"],author:{name:"sirsoft",email:"contact@sirsoft.com",url:"https://sirsoft.com"},release_date:"2026-01-07",g7_version:">=7.0.0",dependencies:{modules:{"sirsoft-board":">=1.0.0","sirsoft-ecommerce":">=1.0.2","sirsoft-page":">=1.0.0"},plugins:{"sirsoft-daum_postcode":">=1.0.0"}},assets:{css:["dist/css/components.css"],js:["dist/js/components.iife.js"],fonts:[],images:[]},components:{basic:["a","button","checkbox","div","form","h1","h2","h3","h4","hr","icon","img","input","label","li","nav","p","section","select","span","svg","table","tbody","td","textarea","th","thead","tr","ul"],composite:["header","footer","mobile-nav","product-card","rich-text-editor","image-gallery","quantity-selector","post-reactions","social-login-buttons","file-uploader","card","modal","toast","pagination","stat-card","status-badge","tab-navigation","empty-state","loading-spinner","breadcrumb","search-bar","dropdown"],layout:["container","flex","grid","section"]},preview:{thumbnail:"preview/thumbnail.png",screenshots:["preview/screenshot1.png","preview/screenshot2.png"]},error_config:{layouts:{401:"errors/401",403:"errors/403",404:"errors/404",500:"errors/500",503:"errors/503",maintenance:"errors/maintenance"}},features:{dark_mode:!0,responsive:!0,multi_language:!0,multi_currency:!0},github_url:"https://github.com/gnuboard/g7-template-sirsoft-basic",github_changelog_url:"https://github.com/gnuboard/g7-template-sirsoft-basic/blob/main/CHANGELOG.md",externals:[{id:"fontawesome",type:"style",url:"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css",preconnect:"https://cdnjs.cloudflare.com"},{id:"pretendard",type:"webfont",url:"https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css",preconnect:"https://cdn.jsdelivr.net",crossorigin:"anonymous"}]},ic={KRW:{locale:"ko-KR",decimals:0},USD:{locale:"en-US",decimals:2},JPY:{locale:"ja-JP",decimals:0},CNY:{locale:"zh-CN",decimals:2},EUR:{locale:"de-DE",decimals:2}};function Lr(e,t="KRW"){if(!Number.isFinite(e))return"0";const r=ic[t]||ic.KRW;try{return new Intl.NumberFormat(r.locale,{style:"currency",currency:t,minimumFractionDigits:r.decimals,maximumFractionDigits:r.decimals}).format(e)}catch{return e.toLocaleString()+(t==="KRW"?"원":"")}}function Qn(e,t,r=0){if(!e)return;const n=e.KRW?.value??e.KRW?.price??0,o={};for(const[a,s]of Object.entries(e)){const l=s?.value??s?.price??0;let f=0;r>0&&(a==="KRW"?f=r:n>0&&(f=r*l/n));const h=(l+f)*t;o[a]={value:h,formatted:Lr(h,a)}}return o}function Jn(e){const t={};for(const n of e){const o=n?.multiCurrencyTotalPrice;if(o)for(const[a,s]of Object.entries(o)){const l=s?.value??s?.price??0;t[a]=(t[a]??0)+l}}const r={};for(const[n,o]of Object.entries(t))r[n]={value:o,formatted:Lr(o,n)};return r}function cc(e,t){if(!e||!t?.length)return 0;let r=0;for(const n of t){const o=e[n.id];if(o==null)continue;const a=n.values?.find(s=>s.id===Number(o));a&&(r+=a.price_adjustment??0)}return r}function Rn(e){return e.name_localized?e.name_localized:typeof e.name=="string"?e.name:e.name?.ko??""}function L0(e,t,r){if(t&&r in t)return t[r];if(Array.isArray(e)){const n=e.find(o=>typeof o.key=="string"?o.key===r:o.key?.ko===r||Object.values(o.key).includes(r));return n?typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]:void 0}return e[r]}function P0(e,t){if(t)return t;if(!Array.isArray(e))return e;const r={};for(const n of e){const o=typeof n.key=="string"?n.key:n.key?.ko??Object.values(n.key)[0]??"",a=typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]??"";o&&(r[o]=a)}return r}function F0(e,t,r){return r.find(n=>!n?.option_values||!n?.is_active?!1:e.every(o=>{const a=Rn(o),s=t?.[a];return L0(n.option_values,n.option_values_localized,a)===s}))}function $0(e,t){const r=e.params;if(!r)return;const{optionGroups:n,options:o,selectedOptionItems:a,preferredCurrency:s}=r;let l;if(r.newGroupName&&r.newValue?l={...r.currentSelection??{},[r.newGroupName]:r.newValue}:l=r.currentSelection??{},!n?.every(O=>{const _=Rn(O);return l?.[_]}))return;const h=F0(n,l,o??[]);if(!h){t.setState?.({currentSelection:{},__mergeMode:"shallow"});return}const d=n.map(O=>l[Rn(O)]).join("_"),i=a??[];if(i.find(O=>O.id===d)){const O=window.G7Core;O?.toast?.warning?.(O?.t?.("sirsoft-ecommerce.shop.already_added_option")??"이미 추가된 옵션입니다."),t.setState?.({currentSelection:{},__mergeMode:"shallow"});return}const g=h.selling_price??0,p={};n.forEach(O=>{const _=Rn(O);p[_]=l[_]});const m=r.additionalOptionGroups??[],w={};for(const O of m){if(!O.is_required)continue;const _=O.values?.find(I=>I.is_default);_&&(w[O.id]=_.id)}const x=cc(w,m),A=g+x,v={id:d,optionId:h.id,options:p,optionValues:P0(h.option_values,h.option_values_localized),quantity:1,stock:h.stock_quantity??999,unitPrice:g,unitPriceFormatted:Lr(g,s),totalPrice:A,totalPriceFormatted:Lr(A,s),multiCurrencyUnitPrice:h.multi_currency_selling_price,multiCurrencyTotalPrice:Qn(h.multi_currency_selling_price,1,x),additionalOptionSelections:w,additionalOptionsTotal:x},E=[...i,v];t.setState?.({selectedOptionItems:E,selectedTotalMultiCurrency:Jn(E),currentSelection:{},__mergeMode:"shallow"})}function U0(e,t){const r=e.params;if(!r)return;const{selectedOptionItems:n,preferredCurrency:o}=r,a=Number(r.itemIndex)||0,s=Number(r.newQuantity)||1,l=(n??[]).map((f,h)=>{if(h!==a)return f;const d=f?.unitPrice??0,i=f?.additionalOptionsTotal??0,u=(d+i)*s;return{...f,quantity:s,totalPrice:u,totalPriceFormatted:Lr(u,o),multiCurrencyTotalPrice:Qn(f?.multiCurrencyUnitPrice,s,i)}});t.setState?.({selectedOptionItems:l,selectedTotalMultiCurrency:Jn(l)})}function z0(e,t){const r=e.params;if(!r)return;const{selectedOptionItems:n,additionalOptionGroups:o,preferredCurrency:a}=r,s=Number(r.itemIndex)||0,l=Number(r.additionalOptionId),f=Object.prototype.hasOwnProperty.call(r,"customText"),h=r.valueId===""||r.valueId==null?null:Number(r.valueId),d=(n??[]).map((i,u)=>{if(u!==s)return i;const g={...i.additionalOptionSelections??{}},p={...i.additionalOptionCustomTexts??{}};if(f){const v=String(r.customText??"");v.trim()===""?delete p[l]:p[l]=v}else h==null?(delete g[l],delete p[l]):(g[l]=h,(o??[]).find(O=>O.id===l)?.values?.find(O=>O.id===h)?.allow_custom_text||delete p[l]);const m=cc(g,o),w=i?.unitPrice??0,x=i?.quantity??1,A=(w+m)*x;return{...i,additionalOptionSelections:g,additionalOptionCustomTexts:p,additionalOptionsTotal:m,totalPrice:A,totalPriceFormatted:Lr(A,a),multiCurrencyTotalPrice:Qn(i?.multiCurrencyUnitPrice,x,m)}});t.setState?.({selectedOptionItems:d,selectedTotalMultiCurrency:Jn(d)})}function H0(e,t){const r=e.params;if(!r)return;const n=Number(r.itemIndex)||0,o=(r.selectedOptionItems??[]).filter((a,s)=>s!==n);t.setState?.({selectedOptionItems:o,selectedTotalMultiCurrency:Jn(o)})}function G0(e,t){const r=e.params;if(!r)return;const n=Math.max(1,Number(r.newQuantity)||1);t.setState?.({noOptionQuantity:n,noOptionTotalMultiCurrency:Qn(r.multiCurrencyUnitPrice,n)})}const cn=window.G7Core?.createLogger?.("Handler:Cart")??{log:(...e)=>console.log("[Handler:Cart]",...e),warn:(...e)=>console.warn("[Handler:Cart]",...e),error:(...e)=>console.error("[Handler:Cart]",...e)};function hr(e){const t=window.G7Core;t?.state?.setLocal?(t.state.setLocal(e),cn.log("Local state updated:",e)):cn.warn("G7Core.state.setLocal not available")}function dc(){return window.G7Core?.state?.getLocal?.()||{}}function j0(){return window.G7Core?.state?.get?.()||{}}function B0(e,t="info"){const r=window.G7Core;r?.toast?.show?r.toast.show(e,t):cn.warn("G7Core.toast.show not available, message:",e)}function W0(e){const t=window.G7Core;return t?.t?t.t(e):e}function uc(){const e=window.G7Core;if(e?.dispatch){const r=dc().selectedItems||[];e.dispatch({handler:"refetchDataSource",params:{dataSourceId:"cartItems"}}),cn.log("Refetching cartItems with selected_ids:",r)}else cn.warn("G7Core.dispatch not available")}function K0(e,t){const{itemId:r,selectedItems:n}=e?.params||{},o=n||[];let a;o.includes(r)?a=o.filter(h=>h!==r):a=[...o,r];const l=j0().cartItems?.data?.items||[],f=l.length>0&&a.length===l.length;hr({selectedItems:a,allSelected:f,selectedCount:a.length}),uc()}function V0(e,t){const{allItemIds:r,isSelected:n}=e?.params||{};hr({selectedItems:n?r:[],allSelected:n,selectedCount:n?r.length:0}),uc()}function Y0(e,t){const{optionName:r,optionValue:n}=e?.params||{},a=dc().selectedOptions||{};hr({selectedOptions:{...a,[r]:n}})}function X0(e,t){const{targetIds:r}=e?.params||{};if(!r||r.length===0){B0(W0("shop.cart.select_items_to_delete"),"warning");return}hr({deleteModal:{visible:!0,targetIds:r}})}function Z0(e,t){const{targetItem:r}=e?.params||{};hr({optionModal:{visible:!0,targetItem:r},selectedOptions:r?.options||{},selectedQuantity:r?.quantity})}function q0(e,t){const{selectedItems:r}=e?.params||{};if(!r||r.length===0){hr({isCalculating:!1});return}hr({isCalculating:!0})}const pr=window.G7Core?.createLogger?.("Handler:CartOptionChange")??{log:(...e)=>console.log("[Handler:CartOptionChange]",...e),warn:(...e)=>console.warn("[Handler:CartOptionChange]",...e),error:(...e)=>console.error("[Handler:CartOptionChange]",...e)};function Oa(e){return e.name_localized?e.name_localized:typeof e.name=="string"?e.name:e.name?.ko??""}function Q0(e,t,r){if(t&&r in t)return t[r];if(Array.isArray(e)){const n=e.find(o=>typeof o.key=="string"?o.key===r:o.key?.ko===r||Object.values(o.key).includes(r));return n?typeof n.value=="string"?n.value:n.value?.ko??Object.values(n.value)[0]:void 0}return e[r]}function fc(e,t,r){return!e||!t?.length?null:t.every(a=>{const s=Oa(a);return e[s]})?r?.find(a=>t.every(s=>{const l=Oa(s);return Q0(a.option_values,a.option_values_localized,l)===e[l]}))||null:(pr.log("Not all options selected yet"),null)}function J0(e,t){const{selectedOptions:r,optionGroups:n,options:o}=e?.params||{};pr.log("findMatchingOption called:",{selectedOptions:r,optionGroups:n,optionsCount:o?.length});const a=fc(r,n,o);return pr.log("Matched option:",a),{matchedOption:a}}function R0(e,t){const{currentOptionValues:r,optionGroups:n,options:o}=e?.params||{};if(pr.log("initCartOptionSelection called:",{currentOptionValues:r,optionGroups:n,optionsCount:o?.length}),!n?.length||!r)return pr.log("No option groups or current values, returning empty"),{selectedOptions:{},matchedOption:null};const a={};for(const l of n){const f=Oa(l),h=r[f],d=l.values_localized??(Array.isArray(l.values)?l.values.map(i=>typeof i=="string"?i:i?.ko??""):[]);h&&d.includes(h)&&(a[f]=h)}pr.log("Initial selectedOptions:",a);const s=fc(a,n,o||[]);return pr.log("Matched option:",s),{selectedOptions:a,matchedOption:s}}const dn="g7_cart_key",ep="/api/modules/sirsoft-ecommerce/cart/key",Ia="g7_guest_order_token",gc="g7_guest_order_number",Da="g7_guest_order_expires_at",at=window.G7Core?.createLogger?.("Handler:Storage")??{log:(...e)=>console.log("[Handler:Storage]",...e),warn:(...e)=>console.warn("[Handler:Storage]",...e),error:(...e)=>console.error("[Handler:Storage]",...e)};async function hc(){try{const e=await fetch(ep,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}});return e.ok?(await e.json()).data?.cart_key||null:(at.error("Failed to issue cartKey from API:",e.status),null)}catch(e){return at.error("Error issuing cartKey from API:",e),null}}function rr(e){const t=window.G7Core;t?.state?.set?(t.state.set(e),at.log("Global state updated:",e)):at.warn("G7Core.state.set not available")}function tp(){try{const e=window.G7Config;return e?.user?e.user:(window.G7Core?.state?.get?.()||{}).currentUser||null}catch{return null}}async function rp(e,t){let r=null;try{r=localStorage.getItem(dn)}catch{}if(r)at.log("Existing cartKey loaded:",r);else if(r=await hc(),r)try{localStorage.setItem(dn,r),at.log("New cartKey issued from API:",r)}catch{}else at.error("Failed to issue cartKey from API");rr({cartKey:r})}function np(e,t){try{return localStorage.getItem(dn)}catch{return null}}function pc(e,t){try{localStorage.removeItem(dn),at.log("cartKey removed from localStorage")}catch{}rr({cartKey:null})}async function op(e,t){if(tp()){pc();return}const n=await hc();if(n){try{localStorage.setItem(dn,n),at.log("New cartKey regenerated from API:",n)}catch{}rr({cartKey:n})}else at.error("Failed to regenerate cartKey from API")}function ap(e,t){const{key:r,value:n}=e?.params||{};if(!r){at.warn("saveToStorage: key is required");return}try{localStorage.setItem(r,n),at.log("Saved to storage:",r,n)}catch{}}function sp(e,t){const{key:r,defaultValue:n}=e?.params||{};if(!r)return at.warn("loadFromStorage: key is required"),n||null;try{return localStorage.getItem(r)||n||null}catch{return n||null}}function La(){try{sessionStorage.removeItem(Ia),sessionStorage.removeItem(gc),sessionStorage.removeItem(Da)}catch{}}function lp(e,t){let r=null,n=null;try{r=sessionStorage.getItem(Ia),n=sessionStorage.getItem(Da)}catch{}let o=!1;if(r){const a=n?new Date(n).getTime():NaN;(isNaN(a)||a<=Date.now())&&(La(),r=null,o=!0)}if(r){rr({guestOrderToken:r}),at.log("Guest order token loaded from sessionStorage");return}if(!o){const s=window.G7Core?.state?.get?.("_global")?.guestOrderToken;if(typeof s=="string"&&s!==""){at.log("Guest order token preserved from in-memory _global (sessionStorage empty)");return}}rr({guestOrderToken:null}),at.log("No guest order token (visitor not authenticated)")}function ip(e,t){const{token:r,orderNumber:n,expiresAt:o}=e?.params||{};if(!r||!n||!o){at.warn("saveGuestOrderToken: token, orderNumber, expiresAt are required");return}try{sessionStorage.setItem(Ia,r),sessionStorage.setItem(gc,n),sessionStorage.setItem(Da,o)}catch{}rr({guestOrderToken:r})}function cp(e,t){La(),rr({guestOrderToken:null})}function dp(e,t){La(),rr({guestOrderToken:null})}function up(e,t){const{product:r,priceField:n,currencyCode:o}=e,a=o||t.getState("_global.preferredCurrency")||"KRW",s=`multi_currency_${n}`,l=r[s];if(l&&l[a])return l[a].formatted;const f=`${n}_formatted`;return r[f]||String(r[n])}const Pa={KRW:{code:"KRW",symbol:"₩",locale:"ko-KR",decimals:0},USD:{code:"USD",symbol:"$",locale:"en-US",decimals:2},JPY:{code:"JPY",symbol:"¥",locale:"ja-JP",decimals:0},CNY:{code:"CNY",symbol:"¥",locale:"zh-CN",decimals:2},EUR:{code:"EUR",symbol:"€",locale:"de-DE",decimals:2}};function fp(e,t){const{value:r,currencyCode:n,locale:o}=e,a=n||t.getState("_global.preferredCurrency")||"KRW",s=Pa[a]||Pa.KRW,l=o||s.locale;try{return new Intl.NumberFormat(l,{style:"currency",currency:s.code,minimumFractionDigits:s.decimals,maximumFractionDigits:s.decimals}).format(r)}catch{const f=r.toLocaleString(void 0,{minimumFractionDigits:s.decimals,maximumFractionDigits:s.decimals});return`${s.symbol}${f}`}}function gp(e){return Pa[e]?.symbol||e}const Fa=window.G7Core?.createLogger?.("Handler:Currency")??{log:(...e)=>console.log("[Handler:Currency]",...e),warn:(...e)=>console.warn("[Handler:Currency]",...e),error:(...e)=>console.error("[Handler:Currency]",...e)},mc="g7_preferred_currency",hp="KRW";function pp(e,t){const{defaultCurrency:r=hp}=e;let n=r;try{if(typeof window<"u"&&window.localStorage){const o=localStorage.getItem(mc);o&&bc(o)&&(n=o)}}catch{Fa.warn("localStorage 접근 불가, 기본 통화 사용:",r)}return t.setState("global",{preferredCurrency:n}),n}function mp(e,t){const{currencyCode:r}=e;if(!bc(r)){Fa.warn("유효하지 않은 통화 코드:",r);return}try{typeof window<"u"&&window.localStorage&&localStorage.setItem(mc,r)}catch{Fa.warn("localStorage 저장 실패")}t.setState("global",{preferredCurrency:r})}function bc(e){return typeof e=="string"&&/^[A-Z]{3}$/.test(e)}const Pr=window.G7Core?.createLogger?.("Handler:SetTheme")??{log:(...e)=>console.log("[Handler:SetTheme]",...e),warn:(...e)=>console.warn("[Handler:SetTheme]",...e),error:(...e)=>console.error("[Handler:SetTheme]",...e)},$a=["auto","light","dark"],yc="g7_color_scheme",bp=e=>e==="auto"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,eo=e=>{const t=bp(e);document.documentElement.setAttribute("data-theme",t),t==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")};function yp(){try{const e=localStorage.getItem(yc),t=e&&$a.includes(e)?e:"auto";eo(t),Pr.log("Initial theme applied:",t)}catch(e){Pr.warn("Failed to load initial theme:",e),eo("auto")}}async function vp(e,t){const r=e?.target;if(r&&typeof r=="string"&&$a.includes(r)){eo(r);return}yp()}async function wp(e,t){let r;if(e?.target&&typeof e.target=="string"&&!e.target.includes("{{")&&(r=e.target),!r||typeof r!="string"){Pr.warn("Invalid theme:",r);return}if(!$a.includes(r)){Pr.warn("Unsupported theme:",r);return}const n=r;try{localStorage.setItem(yc,n)}catch(o){Pr.error("Failed to save theme to localStorage:",o);return}eo(n),Pr.log("Theme changed to:",n)}const xp=window.G7Core?.createLogger?.("Handler:RedirectToLoginWithReturn")??{log:(...e)=>console.log("[Handler:RedirectToLoginWithReturn]",...e),warn:(...e)=>console.warn("[Handler:RedirectToLoginWithReturn]",...e),error:(...e)=>console.error("[Handler:RedirectToLoginWithReturn]",...e)};async function kp(e,t){const r=window.G7Core;if(!r?.dispatch){xp.error("G7Core.dispatch 가 초기화되지 않아 로그인 리다이렉트를 실행할 수 없습니다.");return}const n=window.location.pathname+window.location.search;await r.dispatch({handler:"navigate",params:{path:"/login",query:{redirect:n}}})}const Ua=window.G7Core?.createLogger?.("Handler:DownloadAttachment")??{log:(...e)=>console.log("[Handler:DownloadAttachment]",...e),warn:(...e)=>console.warn("[Handler:DownloadAttachment]",...e),error:(...e)=>console.error("[Handler:DownloadAttachment]",...e)};async function Cp(e,t){const r=window.G7Core,{url:n,filename:o}=e?.params||{};if(!n){Ua.warn("다운로드 URL 이 없어 요청을 건너뜁니다.");return}if(!r?.api?.get){Ua.error("G7Core.api.get 이 초기화되지 않아 다운로드를 실행할 수 없습니다.");return}try{const a=await r.api.get(n,{responseType:"blob"});if(a){const s=URL.createObjectURL(a),l=document.createElement("a");l.href=s,l.download=o||"",document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(s)}}catch(a){Ua.error("첨부파일 다운로드 실패",a),r?.toast?.error?.(r?.t?.("common.download_failed")??"Download failed")}}const to={"sirsoft-basic.addSelectedItemIfComplete":$0,"sirsoft-basic.updateSelectedItemQuantity":U0,"sirsoft-basic.removeSelectedItem":H0,"sirsoft-basic.updateNoOptionQuantity":G0,"sirsoft-basic.setBlockAdditionalOption":z0,"sirsoft-basic.getDisplayPrice":up,"sirsoft-basic.formatCurrency":fp,"sirsoft-basic.getCurrencySymbol":gp,"sirsoft-basic.loadPreferredCurrency":pp,"sirsoft-basic.savePreferredCurrency":mp,setTheme:wp,initTheme:vp,redirectToLoginWithReturn:kp,downloadAttachment:Cp,toggleCartItemSelection:K0,selectAllCartItems:V0,setCartOption:Y0,openCartDeleteModal:X0,openCartOptionModal:Z0,recalculateCart:q0,findMatchingOption:J0,initCartOptionSelection:R0,initCartKey:rp,getCartKey:np,clearCartKey:pc,regenerateCartKey:op,saveToStorage:ap,loadFromStorage:sp,initGuestOrderToken:lp,saveGuestOrderToken:ip,clearGuestOrderToken:cp,clearGuestTokenOnEntry:dp},un=window.G7Core?.createLogger?.("Template:sirsoft-basic:IdentityLauncher")??{log:(...e)=>console.log("[Template:sirsoft-basic:IdentityLauncher]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:IdentityLauncher]",...e),error:(...e)=>console.error("[Template:sirsoft-basic:IdentityLauncher]",...e)};function Sp(e){const t=window.G7Core,r=t?.state?.getLocal?.()??{},n=t?.state?.getGlobal?.()??t?.state?.get?.()??{},o=(...f)=>f.find(h=>typeof h=="string"&&h.length>0),a=o(e.target?.email,n?.currentUser?.email,n?.user?.email,n?.auth?.user?.email,e.purpose==="signup"?r?.registerForm?.email:void 0,e.purpose==="password_reset"?r?.passwordResetForm?.email:void 0,e.purpose==="password_reset"?r?.email:void 0),s=o(e.target?.phone,n?.currentUser?.phone,n?.user?.phone,n?.auth?.user?.phone);if(!a&&!s)return null;const l={};return a&&(l.email=a),s&&(l.phone=s),l}function _p(){const t=window.G7Core?.api?.getToken?.()??null;return t?{Authorization:`Bearer ${t}`}:{}}function Ep(){try{const e=typeof window<"u"?window.localStorage?.getItem("g7_locale"):null;return e?{"Accept-Language":e}:{}}catch{return{}}}async function Tp(e,t){const r={purpose:e.purpose};e.provider_id&&(r.provider_id=e.provider_id),t&&(r.target=t);const n=e.challenge_start_url||"/api/identity/challenges",o=await fetch(n,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json",...Ep(),..._p()},body:JSON.stringify(r)}),a=await o.json().catch(()=>null);if(!o.ok||!a?.success){const l=a?.message??`Challenge 시작 실패 (HTTP ${o.status})`;throw new Error(l)}const s=a.data??a;return{id:s.id,expires_at:s.expires_at,render_hint:s.render_hint??e.render_hint??"text_code",public_payload:s.public_payload,redirect_url:s.redirect_url,max_attempts:typeof s.max_attempts=="number"?s.max_attempts:void 0}}async function Np(e){const t=window.G7Core,r=t?.identity;if(!t?.dispatch||!t?.state||!r)return un.error("G7Core 또는 G7Core.identity 가 초기화되지 않아 launcher 를 실행할 수 없습니다."),{status:"failed",failureCode:"G7_NOT_READY"};if(e.render_hint==="external_redirect"||e.redirect_url)return r.redirectExternally(e);const n=Sp(e);let o;try{o=await Tp(e,n)}catch(p){un.error("Challenge 시작 실패:",p);try{await t.dispatch({handler:"toast",params:{type:"error",message:p instanceof Error?p.message:"본인인증 시작에 실패했습니다."}})}catch{}return{status:"failed",failureCode:"CHALLENGE_START_FAILED",reason:p instanceof Error?p.message:String(p)}}if(o.redirect_url)return r.redirectExternally({...e,render_hint:"external_redirect",redirect_url:o.redirect_url});const a=o.expires_at?new Date(o.expires_at).getTime():0,s=a>0?Math.max(0,Math.floor((a-Date.now())/1e3)):0,l=typeof o.max_attempts=="number"?o.max_attempts:0;t.state.set({identityChallenge:{policy_key:e.policy_key,purpose:e.purpose,provider_id:e.provider_id??null,render_hint:o.render_hint,challenge_id:o.id,expires_at:o.expires_at,public_payload:o.public_payload??{},target:n??null,code:"",error:null,attempts:0,maxAttempts:l,remainingSeconds:s,resendCooldown:0}});let f=a,h=0;const d=window.setInterval(()=>{const p=f>0?Math.max(0,Math.floor((f-Date.now())/1e3)):0;h=Math.max(0,h-1),t.state.set({identityChallenge:{remainingSeconds:p,resendCooldown:h}})},1e3);let i=null;try{i=t.state.subscribe?.(p=>{const m=p?.identityChallenge?.expires_at;if(typeof m=="string"){const x=new Date(m).getTime();Number.isFinite(x)&&x!==f&&(f=x)}const w=p?.identityChallenge?.resendCooldown;typeof w=="number"&&w>h&&(h=w)})??null}catch{}const u=r.createDeferred();try{await t.dispatch({handler:"openModal",target:"identity-challenge-modal"})}catch(p){return un.error("openModal 실패 — 풀페이지로 폴백:",p),window.clearInterval(d),i?.(),r.redirectExternally({...e,render_hint:"external_redirect",redirect_url:`/identity/challenge?challenge_id=${encodeURIComponent(o.id)}&return=${encodeURIComponent(window.location.href)}`})}const g=await u;return window.clearInterval(d),i?.(),g}function Ap(){const e=window.G7Core?.identity;if(!e?.setLauncher){un.warn("G7Core.identity 가 아직 초기화되지 않아 launcher 등록을 건너뜁니다. 코어 부트스트랩 순서를 확인하세요.");return}e.setLauncher(Np),un.log("IDV launcher registered (sirsoft-basic)")}const vc=window.G7Core?.createLogger?.("Template:sirsoft-basic:device")??{log:(...e)=>console.log("[Template:sirsoft-basic:device]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:device]",...e)};function Mp(){if(typeof navigator>"u")return!1;const e=navigator,t=(e.userAgent||"").toLowerCase(),r=((e.userAgentData?.platform??e.platform)||"").toLowerCase(),n=e.maxTouchPoints??0;return/iphone|ipad|ipod/.test(t)||/iphone|ipad|ipod|ios/.test(r)?!0:/macintosh|mac os x/.test(t)&&n>1}function Op(){const e=window.G7Core;if(!e?.state?.get||!e?.state?.set){vc.warn("G7Core.state not available; skip iOS device correction");return}if(!Mp())return;const r=(e.state.get()||{}).appConfig||{};r.isIos!==!0&&(e.state.set({appConfig:{...r,isIos:!0}}),vc.log("appConfig.isIos corrected to true by client signals (iPadOS desktop-UA)"))}function Ip(e){const t=e.icons;return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"&&typeof r.value=="string"):[]}function Dp(e,t){const r=e.label;return typeof r=="string"?r.startsWith("$t:")?t(r.slice(3)):r:e.value}function Lp(e,t,r){if(r==="")return!0;const n=r.toLowerCase();return e.value.toLowerCase().includes(n)||t.toLowerCase().includes(n)?!0:(e.keywords??[]).some(o=>o.toLowerCase().includes(n))}function Pp({entry:e}){const t=e.preview;return t?.html?c.jsx("span",{className:"g7le-icon-preview",dangerouslySetInnerHTML:{__html:t.html},style:Ha}):t?.className?c.jsx("span",{className:`g7le-icon-preview ${t.className}`,style:Ha}):c.jsx("i",{className:`fas fa-${e.value}`,style:Ha,"aria-hidden":"true"})}function Fp({control:e,value:t,onChange:r,t:n}){const o=Ip(e),a=t==null?"":String(t),s=typeof e.iconColumns=="number"?e.iconColumns:6,l=e.iconSearchPlaceholder,f=typeof l=="string"&&l.startsWith("$t:")?n(l.slice(3)):n("layout_editor.icon_picker.search_placeholder"),[h,d]=k.useState("");if(o.length===0)return c.jsx("div",{className:"g7le-widget g7le-widget--icon-picker","data-testid":"g7le-widget-icon-picker",style:wc,children:c.jsx("input",{type:"text",className:"g7le-widget g7le-widget--icon-free","data-testid":"g7le-widget-icon-picker-free",value:a,placeholder:n("layout_editor.icon_picker.free_input_hint"),onChange:g=>r(g.target.value===""?void 0:g.target.value),style:xc})});const i=g=>Dp(g,n),u=o.filter(g=>Lp(g,i(g),h));return c.jsxs("div",{className:"g7le-widget g7le-widget--icon-picker","data-testid":"g7le-widget-icon-picker",style:wc,children:[c.jsx("input",{type:"text",className:"g7le-widget g7le-widget--icon-search","data-testid":"g7le-widget-icon-picker-search",value:h,placeholder:f,onChange:g=>d(g.target.value),style:xc}),c.jsxs("div",{className:"g7le-icon-grid","data-testid":"g7le-widget-icon-picker-grid",style:{...$p,gridTemplateColumns:`repeat(${s}, minmax(0, 1fr))`},children:[c.jsx("button",{type:"button","data-testid":"g7le-icon-cell-none",title:n("layout_editor.icon_picker.none"),onClick:()=>r(void 0),"aria-pressed":a==="",style:a===""?kc:za,children:c.jsx("span",{style:Up,children:"—"})}),u.map(g=>{const p=g.value===a;return c.jsx("button",{type:"button","data-testid":`g7le-icon-cell-${g.value}`,title:i(g),"aria-pressed":p,onClick:()=>r(g.value),style:p?kc:za,children:c.jsx(Pp,{entry:g})},g.value)})]}),u.length===0&&c.jsx("div",{"data-testid":"g7le-widget-icon-picker-empty",style:zp,children:n("layout_editor.icon_picker.no_results")})]})}const wc={display:"flex",flexDirection:"column",gap:6,width:"100%"},xc={padding:"5px 8px",fontSize:12,border:"1px solid #cbd5e1",borderRadius:6,width:"100%"},$p={display:"grid",gap:4,maxHeight:220,overflowY:"auto",padding:2},za={display:"flex",alignItems:"center",justifyContent:"center",minHeight:34,padding:4,border:"1px solid #e2e8f0",borderRadius:6,background:"#fff",cursor:"pointer"},kc={...za,border:"2px solid #2563eb",background:"#eff6ff"},Ha={display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:16,lineHeight:1},Up={fontSize:10,color:"#475569",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},zp={fontSize:11,color:"#94a3b8",fontStyle:"italic",padding:"4px 2px"},Cc=window.G7Core?.createLogger?.("Template:sirsoft-basic:EditorWidgets")??{log:(...e)=>console.log("[Template:sirsoft-basic:EditorWidgets]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic:EditorWidgets]",...e)};function Hp(){if(typeof window>"u")return;const e=window.G7Core?.layoutEditor;if(!e?.registerWidget){Cc.warn("G7Core.layoutEditor 미노출 — icon-picker 위젯 등록 보류");return}e.registerWidget("icon-picker",Fp),Cc.log("편집기 위젯 'icon-picker' 등록됨(Font Awesome 검색 그리드)")}const Ga=window.G7Core?.createLogger?.("Template:sirsoft-basic")??{log:(...e)=>console.log("[Template:sirsoft-basic]",...e),warn:(...e)=>console.warn("[Template:sirsoft-basic]",...e),error:(...e)=>console.error("[Template:sirsoft-basic]",...e)};typeof window<"u"&&(window.G7TemplateHandlers=to);function Sc(){if(typeof window<"u"){let e=0;const t=50,r=()=>{const n=window.G7Core?.getActionDispatcher?.();n?(Object.entries(to).forEach(([o,a])=>{n.registerHandler(o,a)}),Ga.log(`${Object.keys(to).length} custom handler(s) registered:`,Object.keys(to)),Ap(),Op()):(e++,e<=t?(Ga.warn(`ActionDispatcher not found, retrying... (${e}/${t})`),setTimeout(r,100)):Ga.error("Failed to register handlers: ActionDispatcher not available after maximum retries"))};document.readyState==="complete"?r():window.addEventListener("load",r)}}return Hp(),Sc(),J.A=ao,J.Avatar=Ur,J.AvatarUploader=Aa,J.BrandMark=xo,J.Button=Q,J.Checkbox=Za,J.Code=Xc,J.ConfirmDialog=ta,J.Container=N0,J.Div=W,J.ExpandableContent=Jo,J.FileInput=Ba,J.FileUploader=Xn,J.Flex=M0,J.Footer=rs,J.Form=so,J.Grid=A0,J.H1=Fc,J.H2=Va,J.H3=gn,J.H4=Ya,J.Header=es,J.Hr=lo,J.HtmlContent=Zo,J.HtmlEditor=Ll,J.Icon=de,J.IconName=Je,J.ImageGallery=Tr,J.Img=Lt,J.Input=xt,J.Label=yr,J.Li=Xt,J.MobileNav=ns,J.Modal=Ro,J.Nav=$r,J.NotificationCenter=mn,J.Ol=$c,J.Optgroup=Gc,J.Option=Hc,J.P=Dt,J.PageLoading=ec,J.PageSkeleton=Na,J.PageTransitionBlur=_a,J.PageTransitionIndicator=Sa,J.Pagination=tc,J.PasswordInput=Ka,J.PostReactions=Il,J.ProductCard=ms,J.ProductImageViewer=An,J.QuantitySelector=Ml,J.RichTextEditor=Dl,J.SearchBar=nc,J.Section=qa,J.SectionLayout=O0,J.Select=Xa,J.SlotContainer=pn,J.SocialLoginButtons=Ki,J.Span=ee,J.Svg=fn,J.TabNavigation=lc,J.Table=jc,J.Tbody=Wc,J.Td=Yc,J.Textarea=no,J.Th=Vc,J.Thead=Bc,J.ThemeToggle=hn,J.ThreeColumnLayout=I0,J.Toast=Ca,J.Tr=Kc,J.Ul=oo,J.UserInfo=sc,J.availablePasswordRules=ro,J.compositeComponents=T0,J.defaultPasswordRules=Wa,J.initTemplate=Sc,J.templateMetadata=D0,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"}),J})({},ReactJSXRuntime,React,ReactDOM); -//# sourceMappingURL=components.iife.js.map