Files
Gnuboard7/plugins/_bundled/sirsoft-pay_kginicis/dist/js/plugin.iife.js
T
HeuJung 1e89335258 fix(core,extensions): 동적 스크립트 주입 경로 전부에 출처 게이트 적용
레이아웃 scripts[] 에만 있던 원격 스크립트 차단 게이트가 다른 주입 경로에는
없어, 저장측(SafeLayoutExpressions·NoExternalUrls)이 외부 URL 저장을 422 로
막아도 런타임 디스패치 한 번으로 임의 원격 코드가 로드됐다. 저장 검증이
통째로 무의미해지는 상태였고 오류도 경고도 남지 않았다.

판정식을 support/scriptSrcPolicy.ts 로 분리해 런타임 SSoT 를 하나로 두고,
loadScript 액션 · 확장 핸들러 재로드 · 편집기 프리뷰 · 편집기 자산 매니페스트 ·
G7Core.asset.loadScript · PG 플러그인 SDK 주입이 모두 그것을 경유하게 했다.
사본을 두지 않은 이유는 차집합이 그대로 우회로가 되기 때문이다.

- 게이트는 캐시 검사보다 앞에 둔다 (뒤에 두면 이미 로드된 미신뢰 스크립트가
 캐시 히트로 통과한다)
- NoExternalUrls 순회를 9키로 확대 — 번들 레이아웃 601개 사전 스캔으로
 정당한 외부 URL 0건을 확인한 뒤 넓혔다 (저장 회귀 없음)
- callExternal 은 생성자를 참조 동일성으로 거부하고(별칭 전역 포함),
 프로토타입 경로 세그먼트를 읽기·매핑 키 양쪽에서 차단한다
- PG SDK 는 서비스 SDK 라 자체 호스팅이 불가능하므로 manifest 선언 +
 주입 직전 호스트 확인이 게이트다. tosspayments SDK URL 은 확장자가 없어
 정적 검사에 걸리지 않아 그 런타임 확인이 유일한 게이트다
- 함께 드러난 결함: 동시 loadScript 가 로드 전에 완료 처리되던 문제,
 확장 재로드에서 script 기존재가 CSS 까지 건너뛰던 문제, loadCSS 의
 in-flight 미공유
2026-09-02 21:43:13 +09:00

91 lines
43 KiB
JavaScript

(function(){"use strict";const x="kginicis_pay_form_",N="__sirsoftKginicisReloadStandardPaySdk",w="__sirsoftKginicisMobilePaymentReturnPending";function ce(){if(typeof document>"u")return 0;const e=document.querySelectorAll(`form[id^="${x}"]`);return e.forEach(t=>t.remove()),e.length}function ze(){typeof window>"u"||(window[N]=!0)}function Xe(){if(typeof window>"u")return!1;const e=window,t=e[N]===!0;return delete e[N],t}function Ze(e){typeof window>"u"||typeof document>"u"||(window.INIStdPay=void 0,document.querySelectorAll(`script[src="${e}"], script[src*="/INIStdPay_third-party.js"]`).forEach(t=>t.remove()))}function Qe(e=Date.now()){if(!(typeof window>"u"))try{window.sessionStorage.setItem(w,String(e))}catch{window[w]=e}}function M(){if(!(typeof window>"u")){try{window.sessionStorage.removeItem(w)}catch{}delete window[w]}}function de(e=Date.now()){if(typeof window>"u")return!1;let t=null;try{const n=window.sessionStorage.getItem(w);t=n?Number(n):null}catch{t=null}if(!Number.isFinite(t)){const n=window[w];t=typeof n=="number"?n:Number(n)}return!Number.isFinite(t)||e-t>18e5?(M(),!1):!0}const L="sirsoft-pay_kginicis",et=L,tt="payment-window-closed",le="__sirsoftKginicisPaymentCloseListenerInstalled",I="__sirsoftKginicisActiveStandardPaymentCloseContext",ue=20,nt=100,O={info:(...e)=>console.info(`[${L}]`,...e),warn:(...e)=>console.warn(`[${L}]`,...e)};function rt(e){if(!e||typeof e!="object")return!1;const t=e;return t.source===et&&t.type===tt}function $(){return/\/shop\/checkout\/?$/.test(window.location.pathname)}function C(){return window}function ot(){const e=C()[I];return!e||typeof e!="object"?null:e}function it(e){return/^https?:\/\//i.test(e)||e.startsWith("/api/")?e:e.startsWith("/plugins/")?`/api${e}`:e.startsWith("plugins/")?`/api/${e}`:e}const D="g7:sirsoft-pay_kginicis:pendingClose";function K(){try{return window.sessionStorage??null}catch{return null}}function at(e){if(e.closeReportUrl){C()[I]={...e,reported:!1};try{K()?.setItem(D,JSON.stringify({...e,reported:!1}))}catch{}}}function G(){delete C()[I];try{K()?.removeItem(D)}catch{}}function st(){try{const e=K()?.getItem(D);if(!e)return null;const t=JSON.parse(e);return t&&typeof t.oid=="string"&&t.oid!==""&&t.closeReportUrl?t:null}catch{return null}}async function ct(){const e=st();if(!e)return;let t;try{t=new URLSearchParams(window.location.search)}catch{return}const n=t.get("orderId")??"";if(n!==""&&n!==e.oid)return;if(/\/(complete|success)(\/|$|\?)/.test(window.location.pathname)){G();return}const r=t.get("error")??"",o=t.get("message")??"";r===""&&n===""||(C()[I]={...e,reported:!1},await me(o!==""?o:r||"payment-window-closed",!1))}function fe(){G()}async function me(e="payment-window-closed",t=!0){const n=ot();if(!n||n.reported||t&&!$())return;n.reported=!0;const r={oid:n.oid,price:n.price,buyer_email:n.buyer_email??"",buyer_phone:n.buyer_phone??"",payment_method:n.payment_method??"",reason:e};try{const o=window.G7Core?.api;typeof o?.post=="function"?await o.post(n.closeReportUrl,r):await fetch(it(n.closeReportUrl),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r),keepalive:!0})}catch(o){O.warn("failed to report KG payment window close",{reason:e,error:o})}finally{G()}}function pe(e="payment-window-closed",t=!0){if(!$())return!1;const r=window.G7Core?.state?.setLocal;return typeof r!="function"?(t&&O.warn("G7Core.state.setLocal not available while resetting payment submit state"),!1):(ce(),ze(),r({isSubmittingOrder:!1}),O.info("checkout submit state reset after KG payment close",{reason:e}),!0)}function dt(e,t=!1){let n=0;const r=()=>{if(n++,!(t&&!de())){if(pe(e,n>=ue)){t&&M();return}!$()||n>=ue||window.setTimeout(r,nt)}};r()}function v(e){de()&&dt(e,!0)}function lt(){if(typeof window>"u")return;const e=C();e[le]||(window.addEventListener("message",t=>{t.origin===window.location.origin&&rt(t.data)&&(me(t.data.reason),pe(t.data.reason))}),window.addEventListener("pagehide",()=>{fe()}),window.addEventListener("beforeunload",()=>{fe()}),window.addEventListener("pageshow",t=>{v(t.persisted?"mobile-payment-bfcache-return":"mobile-payment-page-show")}),window.addEventListener("focus",()=>{v("mobile-payment-window-focus")}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&v("mobile-payment-visibility-return")}),e[le]=!0,v("mobile-payment-listener-installed"))}function ye(){if(typeof navigator>"u")return!1;const e=navigator;if(e.userAgentData?.mobile!==void 0)return e.userAgentData.mobile;const t=(e.userAgent||"").toLowerCase(),n=((e.userAgentData?.platform??e.platform)||"").toLowerCase();if(/android|iphone|ipad|ipod|windows phone|iemobile|blackberry|opera mini|mobile safari/.test(t)||/iphone|ipad|ipod|ios/.test(n))return!0;const r=e.maxTouchPoints??0;return/macintosh|mac os x/.test(t)&&r>1}const ut=["stgstdpay.inicis.com","stdpay.inicis.com"];function ft(e,t){const n=window?.G7Core?.t;if(typeof n!="function")return t;const r=`sirsoft-pay_kginicis.${e}`,o=n(r);return typeof o=="string"&&o!==r?o:t}function mt(e){let t=null;try{t=new URL(e)}catch{t=null}if(t===null||t.protocol!=="https:"||!ut.includes(t.hostname.toLowerCase()))throw new Error(ft("payment.error.sdk_url_untrusted","결제 모듈 주소가 올바르지 않아 결제를 진행할 수 없습니다."))}async function pt(e){if(mt(e),window.INIStdPay)return;document.querySelectorAll(`script[src="${CSS.escape(e)}"]`).forEach(n=>n.remove());const t=window?.G7Core?.asset?.loadScript;if(typeof t=="function"){await t(e,{},{label:"kginicis SDK"});return}await new Promise((n,r)=>{const o=document.createElement("script");o.src=e,o.async=!0,o.onload=()=>n(),o.onerror=()=>r(new Error(`Failed to load script: ${e}`)),document.head.appendChild(o)})}function _e(e,t){if(!t.startsWith("kginicis_"))return e;const n=new URL(e,window.location.origin);return n.searchParams.set("selectedPaymentMethod",t),n.toString()}function yt(e){const t=(e??"").trim().toUpperCase();return t===""||t==="WON"?"KRW":t}function he(e,t,n="utf-8",r){const o=document.createElement("form");r&&(o.id=r),o.method="POST",o.action=e,o.acceptCharset=n,o.style.display="none";for(const[i,s]of Object.entries(t)){const a=document.createElement("input");a.type="hidden",a.name=i,a.value=s,o.appendChild(a)}document.body.appendChild(o),o.submit()}const _t={card:"Card",vbank:"VBank",bank:"DirectBank",phone:"HPP",kginicis_samsung_pay:"onlyssp",kginicis_naverpay:"onlynaverpay",kginicis_lpay:"onlylpay",kginicis_kakaopay:"onlykakaopay"},ht={card:"CARD",vbank:"VBANK",bank:"BANK",phone:"MOBILE"},gt={kginicis_samsung_pay:"d_samsungpay=Y",kginicis_naverpay:"d_npay=Y",kginicis_lpay:"d_lpay=Y",kginicis_kakaopay:"d_kakaopay=Y"},wt=["CARD","CVS","PAYpay"],ge={card:["CARD"],kginicis_japan_paypay:["PAYpay"],kginicis_japan_cvs:["CVS"]},bt=new Set(Object.keys(ge)),kt=new Set(["kginicis_samsung_pay","kginicis_naverpay","kginicis_lpay","kginicis_kakaopay"]);async function Ct(e,t,n,r){const o=String(Math.floor(Date.now())),i=await e.api.post(t.callback_urls.mobile_signature,{oid:n.order_number,price:n.amount,timestamp:o,buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??""}),{chkfake:s,mobile_payment_url:a}=i.data,c=_e(window.location.origin+t.callback_urls.mobile_callback+"?orderId="+encodeURIComponent(n.order_number),r),u=gt[r],d=u!==void 0,l=d?a.replace(/\/smart\/[^/]+\/?$/,"/smart/wcard/"):a,f=ht[r]??"CARD",m=t.use_escrow?"below1000=Y&vbank_receipt=Y&useescrow=Y&centerCd=Y&amt_hash=Y":"below1000=Y&vbank_receipt=Y&centerCd=Y&amt_hash=Y",p=d?m.replace("&useescrow=Y","")+"&"+u:m,y={P_MID:t.mid,P_OID:n.order_number,P_AMT:String(n.amount),P_GOODS:n.order_name,P_UNAME:n.customer_name??"",P_MOBILE:n.customer_phone??"",P_EMAIL:n.customer_email??"",P_NEXT_URL:c,P_CHARSET:"utf8",P_TIMESTAMP:o,P_CHKFAKE:s,P_RESERVED:p};d?y.P_SKIP_TERMS="Y":y.P_INI_PAYMENT=f,f==="MOBILE"&&!d&&(y.P_HPP_METHOD="2"),f==="VBANK"&&!d&&(y.P_NOTI_URL=window.location.origin+t.callback_urls.mobile_vbank_notify),Qe(),he(l,y,"euc-kr",x+"mobile_"+Date.now())}async function Et(e,t,n,r){const o=String(Math.floor(Date.now())),i=await e.api.post(t.callback_urls.signature,{oid:n.order_number,price:n.amount,timestamp:o,buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??""}),{signature:s,verification:a,mKey:c}=i.data;if(Xe()&&Ze(t.sdk_url),window.INIStdPay||await pt(t.sdk_url),window.INIStdPay||await new Promise(p=>setTimeout(p,100)),!window.INIStdPay)throw new Error("INIStdPay SDK not available");const u=_e(window.location.origin+t.callback_urls.callback,r),d=window.location.origin+t.callback_urls.close;ce();const l=x+Date.now(),f=document.createElement("form");f.id=l,f.method="POST",f.acceptCharset="euc-kr";const m={version:"1.0",mid:t.mid,oid:n.order_number,goodname:n.order_name,price:String(n.amount),currency:"WON",buyername:n.customer_name??"",buyeremail:n.customer_email??"",buyertel:n.customer_phone??"",timestamp:o,signature:s,verification:a,mKey:c,returnUrl:u,closeUrl:d,gopaymethod:_t[r]??"Card",acceptmethod:(()=>{const p=t.use_escrow?"useescrow:":"",y=t.use_credit_point?"CREDITCARD(Y):":"",h=r==="phone"?`HPP(1):${p}${y}centerCd(Y)`:`${p}${y}centerCd(Y)`;return r==="kginicis_samsung_pay"||r==="kginicis_naverpay"||r==="kginicis_lpay"||r==="kginicis_kakaopay"?h?`${h}:cardonly`:"cardonly":h})(),payViewType:"overlay",use_chkfake:"Y",charset:"UTF-8"};for(const[p,y]of Object.entries(m)){const h=document.createElement("input");h.type="hidden",h.name=p,h.value=y,f.appendChild(h)}document.body.appendChild(f),t.callback_urls.close_report&&at({closeReportUrl:t.callback_urls.close_report,oid:n.order_number,price:Number(n.amount),buyer_email:n.customer_email??"",buyer_phone:n.customer_phone??"",payment_method:r}),window.INIStdPay.pay(l)}function St(e=new Date){const t=n=>String(n).padStart(2,"0");return e.getFullYear().toString()+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function Pt(e,t){const n=e.cbt_extra_data??{},o=(t?ge[t]:void 0)??n.payment?.paymethod??wt,i=window.location.origin+e.callback_urls.cbt_cvs_notify;return{...n,paymentUI:{language:"JP",...n.paymentUI??{}},payment:{...n.payment??{},paymethod:o,isMobile:ye()?"true":"false",cvs:{...n.payment?.cvs??{},notiUrl:i}}}}async function It(e,t,n,r){const o=t.japan_mid,i=St(),s=n.customer_email??"",a=n.customer_phone??"",c=await e.api.post(t.callback_urls.cbt_checkout_token,{oid:n.order_number,price:n.amount,buyer_email:s,buyer_phone:a}),{checkout_token:u}=c.data,d=await e.api.post(t.callback_urls.cbt_hash_data,{oid:n.order_number,price:n.amount,timestamp:i,buyer_email:s,buyer_phone:a,checkout_token:u}),{hash_data:l}=d.data,f=window.location.origin+t.callback_urls.cbt_callback+`?oid=${encodeURIComponent(n.order_number)}&selectedPaymentMethod=${encodeURIComponent(r??"card")}`;he(t.callback_urls.cbt_auth_url,{cbtType:"JPPG",mid:o,timestamp:i,returnUrl:f,buyerName:n.customer_name??"",buyerTel:n.customer_phone??"",buyerEmail:n.customer_email??"",goodName:n.order_name,amount:String(n.amount),orderId:n.order_number,hashData:l,extraData:JSON.stringify(Pt(t,r))})}async function vt(e,t){const{pgPaymentData:n,paymentMethod:r}=e.params||{};if(!n)return;const o=window.__templateApp?.globalState?._local,i=r??n.payment_method??o?.paymentMethod??"card",s=window.G7Core;try{const a=await s.api.get("/modules/sirsoft-ecommerce/payments/client-config/kginicis");if(!a.data)throw new Error("Failed to fetch KG Inicis client config");const c=a.data,u=yt(n.currency),d=u==="JPY",l=u==="KRW",f=i.startsWith("kginicis_japan_"),m=kt.has(i),p=c.japan_enabled&&!!c.japan_mid&&c.japan_configured!==!1,y=c.japan_restrict_jpy_payment_methods===!0;if(f&&!d)throw new Error("KG Inicis Japan payment methods require a JPY order.");if(m&&Array.isArray(c.easy_pay_enabled_methods)&&!c.easy_pay_enabled_methods.includes(i))throw new Error("Selected KG Inicis easy pay method is disabled.");if(!d&&!l)throw new Error("KG Inicis supports only KRW standard payments or JPY Japan CBT payments.");if(d&&!p)throw new Error("KG Inicis Japan CBT payment is not configured.");if(d&&y&&!bt.has(i))throw new Error("JPY orders can only use KG Inicis Japan CBT payment methods.");const h=ye();if(l&&c.standard_configured===!1)throw new Error("KG Inicis live standard payment is not configured.");if(l&&h&&c.mobile_configured===!1)throw new Error("KG Inicis live mobile payment is not configured.");d?await It(s,c,n,i):h?await Ct(s,c,n,i):await Et(s,c,n,i)}catch(a){const c=a instanceof Error?a.message:"Unknown error";s?.state?.setLocal?.({paymentErrorMessage:c,isSubmittingOrder:!1,paymentMethod:i}),s?.modal?.open?.("kginicis_payment_error_modal")}}const we={requestPayment:vt},At="sirsoft-pay_kginicis",Tt={info:(...e)=>console.info(`[${At}]`,...e)};function Rt(){Tt.info("order interceptor is a no-op — payment entry is dispatched via pg_payment_handler")}const xt="sirsoft-pay_kginicis";function Nt(){return localStorage.getItem("auth_token")}function Mt(){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 be(e,t){try{const n=await fetch(`/api/plugins/${xt}/user/orders/${e}/receipt`,{headers:t,credentials:"same-origin"});return n.ok?{status:n.status,data:await n.json()}:{status:n.status,data:null}}catch{return{status:0,data:null}}}async function ke(e){const t=Nt(),n=Mt(),r={Accept:"application/json"};t?r.Authorization=`Bearer ${t}`:n&&(r["X-Guest-Order-Token"]=n);const o=await be(e,r);if(o.data||o.status!==401||!t)return{status:o.status,info:o.data};const i={Accept:"application/json"};n&&(i["X-Guest-Order-Token"]=n);const s=await be(e,i);return{status:s.status,info:s.data}}async function A(e){return(await ke(e)).info}function E(e){return e?e.receipt_url?!0:e.receipt_type==="cbt_confirmation"&&Array.isArray(e.receipt_fields)&&e.receipt_fields.length>0:!1}function T(e){return e?.receipt_view_label||"영수증 조회"}function Lt(e){return e?.receipt_label||"영수증"}function Ce(e){if(e.receipt_url){window.open(e.receipt_url,"kginicis_receipt","width=800,height=600,scrollbars=yes,resizable=yes");return}e.receipt_type==="cbt_confirmation"&&Ot(e)}function Ot(e){const t=window.open("","kginicis_receipt","width=800,height=700,scrollbars=yes,resizable=yes");if(!t)return;const n=e.receipt_title||"KG 이니시스 CBT 결제확인서",r=e.receipt_notice||"",o=(e.receipt_fields??[]).map(i=>`
<div class="row">
<dt>${S(i.label)}</dt>
<dd>${S(i.value)}</dd>
</div>
`).join("");t.document.open(),t.document.write(`<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${S(n)}</title>
<style>
body {
margin: 0;
padding: 32px;
background: #f8fafc;
color: #111827;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
main {
max-width: 720px;
margin: 0 auto;
background: #fff;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 28px;
box-shadow: 0 10px 30px rgba(15, 23, 42, .08);
}
h1 {
margin: 0 0 8px;
font-size: 22px;
line-height: 1.35;
}
.notice {
margin: 0 0 24px;
color: #4b5563;
font-size: 14px;
line-height: 1.6;
}
dl {
margin: 0;
border-top: 1px solid #e5e7eb;
}
.row {
display: grid;
grid-template-columns: 160px minmax(0, 1fr);
gap: 16px;
padding: 14px 0;
border-bottom: 1px solid #e5e7eb;
}
dt {
color: #6b7280;
font-size: 14px;
}
dd {
margin: 0;
color: #111827;
font-size: 14px;
font-weight: 600;
overflow-wrap: anywhere;
}
.actions {
margin-top: 24px;
text-align: right;
}
button {
border: 0;
border-radius: 6px;
background: #2563eb;
color: #fff;
padding: 10px 14px;
font-size: 14px;
cursor: pointer;
}
@media (max-width: 520px) {
body { padding: 16px; }
main { padding: 20px; }
.row { grid-template-columns: 1fr; gap: 6px; }
}
</style>
</head>
<body>
<main>
<h1>${S(n)}</h1>
${r?`<p class="notice">${S(r)}</p>`:""}
<dl>${o}</dl>
<div class="actions"><button type="button" onclick="window.print()">인쇄</button></div>
</main>
</body>
</html>`),t.document.close()}function S(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const j="sirsoft-pay_kginicis",Ee="__kginicisOrderShowInjectorInstalled",Y="kginicis-mp-receipt-row",Se=/^(?:\/mypage\/orders\/([^/]+)|\/shop\/guest\/orders\/([^/]+))$/,B=new Map;function $t(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 Dt(){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 Kt(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 Gt(e,t){const n=document.createElement("div");n.id=Y,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=Lt(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=T(t),o.addEventListener("click",async()=>{o.disabled=!0,o.textContent="로딩 중...";const i=await A(e);o.disabled=!1,o.textContent=T(i??t),E(i)&&Ce(i)}),n.appendChild(r),n.appendChild(o),n}async function jt(e,t){const n=$t(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=Dt();if(!i)return!1;const{status:s,info:a}=await ke(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&&!E(a))return!1;const d=Kt(i,a?.payment_method_display_label);return!document.getElementById(Y)&&E(a)&&(i.appendChild(Gt(o,a)),console.info(`[${j}] receipt button injected on mypage order show`)),d&&console.info(`[${j}] payment method display patched on mypage order show`),!!(document.getElementById(Y)||d)}function Yt(e,t){if(B.has(e))return;let n=0;const r=window.setInterval(()=>{n++,jt(e,t).then(o=>{(o||n>=30)&&(window.clearInterval(r),B.delete(e))})},400);B.set(e,r)}function Bt(){const e=location.pathname.match(Se);if(e){const t=e[1],n=e[2],r=t??n;r&&Yt(r,n!==void 0)}}function Ut(){if(typeof window>"u")return;const e=window;if(e[Ee])return;e[Ee]=!0,console.info(`[${j}] mypage order show injector installed`);let t=null;const n=(a=1500)=>{t!==null&&window.clearTimeout(t),t=window.setTimeout(()=>{t=null,Bt()},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(()=>{Se.test(location.pathname)&&n(250)}).observe(i,{childList:!0,subtree:!0})}const U="sirsoft-pay_kginicis",Pe="__kginicisAdminPaymentDisplayInjectorInstalled",Jt=/^\/admin\/ecommerce\/orders\/([^/]+)$/;function Ht(){return localStorage.getItem("auth_token")}async function Ft(e){const t=Ht();if(!t)return null;try{const n=await fetch(`/api/plugins/${U}/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 qt(e){return Array.from(e.children).filter(t=>t instanceof HTMLElement)}function Wt(e,t){let n=!1;const r=Array.from(e.querySelectorAll("div"));for(const o of r){const i=qt(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 Vt(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 zt(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=Wt(e,n),s=o?Vt(e,o,r):!1;return i||s}async function Xt(e){const t=document.getElementById("section_payment_info")??document.getElementById("payment_info_card");if(!t)return!1;const n=await Ft(e);return n&&zt(t,n)&&console.info(`[${U}] payment method display patched on admin order detail`),!0}function Zt(e){let t=0;const n=setInterval(()=>{t++,Xt(e).then(r=>{(r||t>=30)&&clearInterval(n)})},400)}function Qt(){const e=location.pathname.match(Jt);e&&Zt(e[1])}function en(){if(typeof window>"u")return;const e=window;if(e[Pe])return;e[Pe]=!0,console.info(`[${U}] admin order payment display injector installed`);const t=(r=1500)=>setTimeout(Qt,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 Ie="sirsoft-pay_kginicis",ve="__kginicisOcReceiptInjectorInstalled",Ae="kginicis-oc-receipt-btn",tn=/^\/shop\/orders\/([^/]+)\/complete$/;function nn(){return localStorage.getItem("auth_token")}function rn(){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 on(e){const t=nn(),n=rn();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 an(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 sn(e){if(document.getElementById(Ae))return;const t=await on(e);if(t&&(t.pg_provider!=="kginicis"||!t.transaction_id))return;const n=await A(e);if(!E(n))return;if(t){const a=t.payment_status==="paid",c=n.receipt_type==="cbt_confirmation";if(!a&&!c)return}an(n.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=Ae,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=T(n),i.addEventListener("click",async()=>{i.disabled=!0,i.textContent="로딩 중...";const a=await A(e);i.disabled=!1,i.textContent=T(a??n),E(a)&&Ce(a)});const s=o.lastElementChild;o.insertBefore(i,s),console.info(`[${Ie}] receipt button injected on order complete page`)}function cn(){const e=location.pathname.match(tn);e&&sn(e[1])}function dn(){if(typeof window>"u")return;const e=window;if(e[ve])return;e[ve]=!0,console.info(`[${Ie}] order complete receipt injector installed`);const t=(r=1200)=>setTimeout(cn,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 Te="sirsoft-pay_kginicis",Re="__kginicisVbankInfoInjectorInstalled",J="kginicis-mp-vbank-info",ln=/^\/shop\/orders\/([^/]+)\/complete$/,un=/^\/mypage\/orders\/([^/]+)$/,fn=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+\-]\d{2}:\d{2}/,mn={"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 pn(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(mn))if(r===t)return n;return null}function yn(){try{const t=window.G7Core?.getState;return t?.()?.currentDataContext?._global?.currentUser?.is_admin===!0}catch{return!1}}function xe(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 _n(){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t=[];let n=e.nextNode();for(;n;){const r=n.textContent??"",o=r.match(fn);o&&t.push({node:n,formatted:r.replace(o[0],xe(o[0]))}),n=e.nextNode()}for(const{node:r,formatted:o}of t)r.textContent=o}function hn(e){try{const n=window.G7Core?.getState,i=n?.()?.currentDataContext?.order?.data;return!i||i.order_number!==e?null:i}catch{return null}}function gn(){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 wn(e,t){const n=document.createElement("div");n.id=J,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)),yn()){const o=pn(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 bn(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 kn(e,t,n){const r=document.createElement("div");r.id=J,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 Cn(e){const t=hn(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(J))return!0;const r=gn();if(!r)return!1;const o=await A(e),i=n.vbank_due_at?xe(n.vbank_due_at):"";return r.appendChild(bn(n,o)?kn(n,o,i):wn(n,i)),console.info(`[${Te}] vbank info injected on mypage`),!0}function En(e){let t=0;const n=setInterval(()=>{t++,Cn(e).then(r=>{(r||t>=30)&&clearInterval(n)})},400)}function Sn(){if(location.pathname.match(ln)){setTimeout(_n,500);return}const t=location.pathname.match(un);t&&En(t[1])}function Pn(){if(typeof window>"u")return;const e=window;if(e[Re])return;e[Re]=!0,console.info(`[${Te}] vbank info injector installed`);const t=(r=800)=>setTimeout(Sn,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 Ne="sirsoft-pay_kginicis",Me="__sirsoftKginicisCheckoutJpyPaymentMethodRestrictorInstalled",H=/^\/shop\/checkout\/?$/,In="/api/modules/sirsoft-ecommerce/checkout",vn="/api/modules/sirsoft-ecommerce/settings/payment",An="/api/modules/sirsoft-ecommerce/payments/client-config/kginicis",Le="__sirsoftKginicisCheckoutCurrency",F=new Set(["card","kginicis_japan_paypay","kginicis_japan_cvs"]),q=new Set(["kginicis_japan_paypay","kginicis_japan_cvs"]),Oe=new Set(["card","vbank","dbank","bank","phone","kginicis_samsung_pay","kginicis_naverpay","kginicis_lpay","kginicis_kakaopay","kginicis_japan_paypay","kginicis_japan_cvs"]),Tn=[{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)"]}],W={info:(...e)=>console.info(`[${Ne}]`,...e),warn:(...e)=>console.warn(`[${Ne}]`,...e)};let P=null,V=null,b=null;function z(){return window}function Rn(e){return typeof e=="string"?e:e instanceof URL?e.toString():typeof Request<"u"&&e instanceof Request?e.url:String(e)}function xn(e,t){return t?.method?t.method.toUpperCase():typeof Request<"u"&&e instanceof Request?e.method.toUpperCase():"GET"}function Nn(e){try{return new URL(e,window.location.origin).pathname}catch{return e.split("?")[0].split("#")[0]}}function $e(e){if(typeof e!="string")return null;const t=e.trim().toUpperCase();return/^[A-Z]{3}$/.test(t)?t:null}function X(e,t){return t.split(".").reduce((n,r)=>{if(!(n===null||typeof n!="object"))return n[r]},e)}function Mn(e,t){for(const n of t){const r=$e(X(e,n));if(r)return r}return null}function Ln(e){return Mn(e,["data.calculation.summary.selected_payment_currency","data.calculation.metadata.payment_currency","data.calculation.metadata.currency","data.currency","data.currency_code"])}function On(e){const t=Ln(e);t&&(z()[Le]=t)}function De(){const e=z(),n=e.__templateApp?.globalState,r=[e[Le],n?.preferredCurrency];try{r.push(window.localStorage?.getItem("g7_preferred_currency"))}catch{}r.push(X(n,"modules.sirsoft-ecommerce.language_currency.default_currency"),X(n,"modules.sirsoft-ecommerce.language_currency.currencies.0.code"));for(const o of r){const i=$e(o);if(i)return i}return null}function Z(){return H.test(window.location.pathname)&&De()==="JPY"}function Q(){if(!H.test(window.location.pathname))return!1;const e=De();return e!==null&&e!=="JPY"}async function Ke(e){return P!==null||(P=(async()=>{try{const t=await e(An,{headers:{Accept:"application/json"}});return t.ok?(await t.json()).data?.japan_restrict_jpy_payment_methods===!0:!1}catch{return!1}})()),P}function $n(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!Oe.has(r)||F.has(r)?n:{...n,is_active:!1,_kginicis_restricted_for_jpy:!0}})}}}:e}function Dn(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 q.has(r)?{...n,is_active:!1,_kginicis_restricted_for_non_jpy:!0}:n})}}}:e}function Kn(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 Gn(){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 jn(e){const t=e.querySelector("p")?.textContent?.trim()??e.textContent?.trim()??"";for(const n of Tn)if(n.labels.some(r=>t.includes(r)))return n.id;return null}function ee(){const e=Z(),t=Q();if(!e&&!t)return!1;const n=Gn();if(!n)return!1;let r=!1;if(n.querySelectorAll('button[type="button"]').forEach(o=>{const i=jn(o);if(!i||!Oe.has(i))return;if(e?F.has(i):!q.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&&!F.has(i)||t&&q.has(i))&&window.G7Core?.state?.setLocal?.({paymentMethod:"card"})}catch{}return r}async function Ge(e){if(!H.test(window.location.pathname))return;const t=Z(),n=Q();if(!t&&!n||t&&!await Ke(e))return;ee(),V===null&&(V=new MutationObserver(()=>{ee()}),V.observe(document.body,{childList:!0,subtree:!0})),b!==null&&clearInterval(b);let r=0;b=setInterval(()=>{r++,ee(),r>=50&&b!==null&&(clearInterval(b),b=null)},200)}function je(e){P=null,Ge(e)}function Yn(){if(typeof window>"u"||typeof window.fetch!="function")return;const e=z();if(e[Me])return;e[Me]=!0;const t=window.fetch.bind(window);window.fetch=async function(i,s){const a=Rn(i),c=xn(i,s),u=Nn(a),d=await t(i,s);if(c==="GET"&&u.endsWith(In)){try{const m=await d.clone().json();On(m)}catch{}return d}if(c!=="GET"||!u.endsWith(vn))return d;const l=Z(),f=Q();if(!l&&!f||l&&!await Ke(t))return d;try{const m=await d.clone().json(),p=l?$n(m):Dn(m);return W.info(l?"restricted checkout payment methods for JPY order":"hid Japan-only payment methods for non-JPY order"),Kn(d,p)}catch(m){return W.warn("failed to restrict checkout payment methods",m),d}},W.info("checkout JPY payment method restrictor installed");const n=()=>{Ge(t)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",n):n();const r=history.pushState.bind(history);history.pushState=(...o)=>{r(...o),setTimeout(()=>je(t),200)},window.addEventListener("popstate",()=>setTimeout(()=>je(t),200))}const Bn="sirsoft-pay_kginicis",Ye="__kginicisAdminPaymentMethodBrandInjectorInstalled",Be="__kginicisAdminPaymentMethodBrandSyncListenerAttached",Un=/^\/admin\/ecommerce\/settings\/?$/,Ue='[data-kginicis-admin-payment-brand-mark="true"]',Jn=200,Hn=120,Fn=[{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,R=null,te=!1;function qn(){return window}function ne(){if(!Un.test(window.location.pathname))return!1;const e=new URLSearchParams(window.location.search).get("tab");return e===null||e===""||e==="order_settings"}function Wn(e){return e instanceof HTMLElement?e.className:""}function He(e){return(e??"").replace(/\u200B/g,"").replace(/\s+/g," ").trim()}function Vn(e){const t=Wn(e);return t.includes("excel-card")||t.includes("flex-center")&&t.includes("border")&&t.includes("gap-4")}function Fe(e){return e.querySelector(".font-medium")}function zn(e){const t=He(Fe(e)?.textContent),n=He(e.textContent);return Fn.find(r=>r.shortLabels.some(o=>t===o)||r.labels.some(o=>n.includes(o)))??null}function Xn(e){return Array.from(e.querySelectorAll("div")).filter(Vn)}function Zn(e){return Array.from(e.querySelectorAll("svg, [data-icon], i")).find(n=>!n.closest("[data-drag-handle]")&&!n.closest(Ue)&&!n.closest('.row-stack, .excel-card-body, button, select, [role="switch"]'))??null}function qe(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 Qn(e){const t=document.createElement("span");return qe(t,e),t}function er(e,t){const n=e.querySelector(Ue);if(n instanceof HTMLSpanElement)return e.dataset.kginicisAdminPaymentMethod=t.id,qe(n,t),!0;const r=Qn(t),o=Zn(e);if(o&&o.parentElement)return e.dataset.kginicisAdminPaymentMethod=t.id,o.replaceWith(r),!0;const i=Fe(e);return i&&i.parentElement?(e.dataset.kginicisAdminPaymentMethod=t.id,i.parentElement.insertBefore(r,i),!0):!1}function re(e=document){if(typeof window>"u"||typeof document>"u"||!ne())return!1;let t=!1;return Xn(e).forEach(n=>{const r=zn(n);r&&er(n,r)&&(t=!0)}),t}function tr(){te||(te=!0,window.setTimeout(()=>{te=!1,re()},0))}function oe(){R!==null&&(window.clearInterval(R),R=null)}function ie(){if(!ne())return;oe(),re();let e=0;R=window.setInterval(()=>{e+=1,re(),e>=Hn&&oe()},Jn);const t=document.body;t[Be]||(t[Be]=!0,Je=new MutationObserver(()=>tr()),Je.observe(document.body,{childList:!0,subtree:!0,characterData:!0}))}function ae(){if(ne()){ie();return}oe()}function nr(){if(typeof window>"u"||typeof document>"u")return;const e=qn();if(e[Ye])return;e[Ye]=!0,console.info(`[${Bn}] admin payment method brand sync installed`),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>ie()):ie();const t=history.pushState.bind(history);history.pushState=(...r)=>{t(...r),window.setTimeout(()=>ae(),200)};const n=history.replaceState.bind(history);history.replaceState=(...r)=>{n(...r),window.setTimeout(()=>ae(),200)},window.addEventListener("popstate",()=>window.setTimeout(()=>ae(),200))}const k="sirsoft-pay_kginicis",se={info:(...e)=>console.info(`[${k}]`,...e),warn:(...e)=>console.warn(`[${k}]`,...e),error:(...e)=>console.error(`[${k}]`,...e)};function We(){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(we)){const s=`${k}.${o}`;n.registerHandler(s,i,{category:"plugin",source:k}),r++}return r}function Ve(){const e=()=>{const t=We();if(t>0){se.info(`${t} handler(s) registered`);return}let n=0;const r=50,o=setInterval(()=>{n++;const i=We();if(i>0){clearInterval(o),se.info(`${i} handler(s) registered (after ${n} retries)`);return}n>=r&&(clearInterval(o),se.warn("ActionDispatcher not available after timeout"))},100)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}Rt(),Yn(),Ut(),en(),nr(),dn(),Pn(),lt(),ct(),Ve(),window.__SirsoftKginicis={identifier:k,handlers:Object.keys(we),initPlugin:Ve}})();