PageSourceSearch

https://www.ijoa.co.kr/js/site_shop/site_shop_payment_method_benefit_sdk.js?1784164725

js ijoa.co.kr collected 2026-09-24 12:32:25 UTC 11,459 bytes, 279 lines download raw bytes

1window.IMWEB_SHOP_PAYMENT_METHOD_BENEFIT_SDK = window.IMWEB_SHOP_PAYMENT_METHOD_BENEFIT_SDK || (function () {
2    var _cachedState = null;
3    var _hydratePaymentMethodBenefitModuleScripts = function () {};
4    var DEBUG_PREFIX = '[PaymentMethodBenefit SDK]';
5
6    function debugLog(message, payload) {
7        return;
8        // if (typeof console === 'undefined' || typeof console.log !== 'function') {
9        //     return;
10        // }
11        // if (typeof payload === 'undefined') {
12        //     console.log(DEBUG_PREFIX, message);
13        //     return;
14        // }
15        // console.log(DEBUG_PREFIX, message, payload);
16    }
17
18    function debugWarn(message, payload) {
19        return;
20        // if (typeof console === 'undefined' || typeof console.warn !== 'function') {
21        //     return;
22        // }
23        // if (typeof payload === 'undefined') {
24        //     console.warn(DEBUG_PREFIX, message);
25        //     return;
26        // }
27        // console.warn(DEBUG_PREFIX, message, payload);
28    }
29
30    function patchMagnetShell(MagnetShellClass) {
31        if (!MagnetShellClass || MagnetShellClass.__imwebPaymentMethodBenefitPatched) {
32            return;
33        }
34
35        var proto = MagnetShellClass.prototype;
36        var connectedCallback = proto.connectedCallback;
37        var resetMangetNode = proto.resetMangetNode;
38        var attributeChangedCallback = proto.attributeChangedCallback;
39
40        function syncManifestUrl(element) {
41            element.manifestUrl = element.manifestUrl || element.getAttribute('data-manifest-url') || element.getAttribute('manifest-url') || '';
42        }
43
44        function executePaymentMethodBenefitModuleScripts(element) {
45            if (!element.classList || !element.classList.contains('foPaymentMethodBenefitMagnet')) {
46                return;
47            }
48
49            debugLog('execute module scripts start', element);
50            var roots = [element];
51            if (element.shadowRoot) {
52                roots.push(element.shadowRoot);
53            }
54
55            Array.prototype.forEach.call(roots, function (root) {
56                var scripts = root.querySelectorAll('script[type="module"]');
57                debugLog('module script candidates', {
58                    root: root,
59                    count: scripts.length
60                });
61                Array.prototype.forEach.call(scripts, function (script) {
62                    var src = script.getAttribute('src') || '';
63                    var scriptContent = script.textContent || '';
64                    var isPaymentMethodBenefitScript =
65                        src.indexOf('/_/fo-shopping/assets/payment-method-benefit-') !== -1 ||
66                        src.indexOf('/src/app/payment-method-benefit/') !== -1 ||
67                        src.indexOf('/_/fo-shopping/@vite/client') !== -1 ||
68                        src.indexOf('/_/fo-shopping/@react-refresh') !== -1 ||
69                        scriptContent.indexOf('@react-refresh') !== -1 ||
70                        scriptContent.indexOf('RefreshRuntime') !== -1;
71
72                    if (!isPaymentMethodBenefitScript || script.getAttribute('data-imweb-executed') === 'Y') {
73                        return;
74                    }
75
76                    if (!src && scriptContent === '') {
77                        return;
78                    }
79
80                    script.setAttribute('data-imweb-executed', 'Y');
81                    debugLog('execute module script', {
82                        src: src,
83                        inlinePreview: src ? '' : scriptContent.slice(0, 120)
84                    });
85
86                    var executedScript = document.createElement('script');
87                    executedScript.type = 'module';
88                    if (src) {
89                        executedScript.src = src;
90                        if (script.getAttribute('crossorigin') !== null) {
91                            executedScript.setAttribute('crossorigin', script.getAttribute('crossorigin') || '');
92                        }
93                    } else {
94                        executedScript.textContent = scriptContent;
95                    }
96                    document.head.appendChild(executedScript);
97                });
98            });
99        }
100
101        function executeExistingPaymentMethodBenefitModuleScripts(root) {
102            var scope = root && root.nodeType ? root : document;
103            var elements = [];
104            if (scope.matches && scope.matches('magnet-shell.foPaymentMethodBenefitMagnet')) {
105                elements.push(scope);
106            }
107            if (scope.querySelectorAll) {
108                Array.prototype.push.apply(
109                    elements,
110                    scope.querySelectorAll('magnet-shell.foPaymentMethodBenefitMagnet')
111                );
112            }
113            debugLog('hydrate existing magnets', {
114                scope: scope,
115                count: elements.length
116            });
117            Array.prototype.forEach.call(elements, function (element) {
118                syncManifestUrl(element);
119                executePaymentMethodBenefitModuleScripts(element);
120            });
121        }
122
123        _hydratePaymentMethodBenefitModuleScripts = executeExistingPaymentMethodBenefitModuleScripts;
124
125        proto.connectedCallback = function () {
126            syncManifestUrl(this);
127            var result = connectedCallback.apply(this, arguments);
128            if (result && typeof result.then === 'function') {
129                return result.then(function (value) {
130                    executePaymentMethodBenefitModuleScripts(this);
131                    return value;
132                }.bind(this));
133            }
134
135            executePaymentMethodBenefitModuleScripts(this);
136            return result;
137        };
138
139        proto.resetMangetNode = function () {
140            syncManifestUrl(this);
141            var result = resetMangetNode.apply(this, arguments);
142            if (result && typeof result.then === 'function') {
143                return result.then(function (value) {
144                    executePaymentMethodBenefitModuleScripts(this);
145                    return value;
146                }.bind(this));
147            }
148
149            executePaymentMethodBenefitModuleScripts(this);
150            return result;
151        };
152
153        proto.attributeChangedCallback = function (name, oldValue, newValue) {
154            if (name === 'data-manifest-url' || name === 'manifest-url') {
155                this.manifestUrl = newValue || this.getAttribute('data-manifest-url') || this.getAttribute('manifest-url') || '';
156                if (typeof this.clearManifest === 'function') {
157                    this.clearManifest();
158                }
159                return;
160            }
161            if (typeof attributeChangedCallback === 'function') {
162                return attributeChangedCallback.apply(this, arguments);
163            }
164        };
165
166        MagnetShellClass.__imwebPaymentMethodBenefitPatched = true;
167        executeExistingPaymentMethodBenefitModuleScripts();
168    }
169
170    function hydrate(root) {
171        debugLog('hydrate called', root || document);
172        if (typeof customElements === 'undefined') {
173            debugWarn('customElements is undefined');
174            return;
175        }
176
177        var registeredMagnetShell = customElements.get('magnet-shell');
178        if (registeredMagnetShell) {
179            debugLog('magnet-shell already registered');
180            patchMagnetShell(registeredMagnetShell);
181            _hydratePaymentMethodBenefitModuleScripts(root || document);
182        } else {
183            debugLog('import magnet-shell');
184            import('https://static.imweb.me/design-system/magnet/magnet-shell.js')
185                .then(function (module) {
186                    var currentMagnetShell = customElements.get('magnet-shell');
187                    if (currentMagnetShell) {
188                        debugLog('magnet-shell registered while importing');
189                        patchMagnetShell(currentMagnetShell);
190                        _hydratePaymentMethodBenefitModuleScripts(root || document);
191                        return;
192                    }
193
194                    var BaseMagnetShell = module.MagnetShell;
195                    class ImwebPaymentMethodBenefitMagnetShell extends BaseMagnetShell {
196                        static get observedAttributes() {
197                            var observedAttributes = BaseMagnetShell.observedAttributes || [];
198                            return observedAttributes.indexOf('data-manifest-url') === -1
199                                ? observedAttributes.concat('data-manifest-url')
200                                : observedAttributes;
201                        }
202                    }
203
204                    customElements.define('magnet-shell', ImwebPaymentMethodBenefitMagnetShell);
205                    debugLog('magnet-shell defined by payment method benefit sdk');
206                    patchMagnetShell(ImwebPaymentMethodBenefitMagnetShell);
207                    _hydratePaymentMethodBenefitModuleScripts(root || document);
208                })
209                .catch(function (e) {
210                    debugWarn('magnet-shell import failed', e);
211                });
212        }
213    }
214
215    hydrate();
216
217    function sendState(paymentMethodBenefit) {
218        _cachedState = paymentMethodBenefit || { items: [], cards: [], payments: [] };
219        debugLog('sendState', {
220            itemCount: _cachedState.items && _cachedState.items.length ? _cachedState.items.length : 0,
221            state: _cachedState
222        });
223        try {
224            window.dispatchEvent(new CustomEvent('imweb:paymentMethodBenefit:state:update', {
225                detail: {
226                    paymentMethodBenefit: _cachedState
227                }
228            }));
229            debugLog('state update event dispatched');
230        } catch (e) {
231            debugWarn('state update event dispatch failed', e);
232        }
233    }
234
235    function loadState() {
236        debugLog('loadState request start');
237        $.ajax({
238            type: 'POST',
239            data: {},
240            url: '/shop/payment_method_benefit/load_state.cm',
241            dataType: 'json',
242            cache: false,
243            success: function (result) {
244                debugLog('loadState success response', result);
245                if (result && result.msg === 'SUCCESS') {
246                    debugLog('loadState success payload', result.payment_method_benefit);
247                    sendState(result.payment_method_benefit);
248                    return;
249                }
250                debugWarn('loadState response is not SUCCESS', result);
251                sendState({ items: [], cards: [], payments: [] });
252            },
253            error: function (xhr, textStatus, errorThrown) {
254                debugWarn('loadState ajax error', {
255                    status: xhr && xhr.status,
256                    textStatus: textStatus,
257                    errorThrown: errorThrown,
258                    responseText: xhr && xhr.responseText
259                });
260                sendState({ items: [], cards: [], payments: [] });
261            }
262        });
263    }
264
265    function getCachedState() {
266        debugLog('getCachedState', _cachedState);
267        return _cachedState;
268    }
269
270    return {
271        loadState: loadState,
272        getCachedState: getCachedState,
273        hydrate: hydrate
274    };
275})();
276
277try {
278    window.dispatchEvent(new CustomEvent('imweb:paymentMethodBenefit:sdk-ready'));
279} catch (e) {}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.