window.storecrm_config = {"backendUrl":"https://obake.groovymedia.co","appProxyName":"obake"}; (()=>{"use strict";var e={208:(e,t,o)=>{o.d(t,{A:()=>a});var n=o(601),i=o.n(n),r=o(314),s=o.n(r)()(i());s.push([e.id,'.storecrm_modal {\n display: none;\n}\n\n.storecrm_modal.is-open {\n display: block;\n}\n\n.storecrm_modal_line {\n margin: 1rem 0;\n}\n\n.storecrm_modal_line label {\n display: flex;\n align-items: center;\n}\n\n#storecrm_restock_accepts_marketing {\n margin: 0 5px 0 0;\n max-width: 15px;\n}\n\n@media (hover: hover) {\n .storecrm_modal_line label:hover {\n cursor: pointer;\n }\n #storecrm_restock_accepts_marketing:hover {\n cursor: pointer;\n }\n}\n\n.storecrm_modal input, .storecrm_modal select {\n width: 100%;\n padding: 10px;\n font-size: 100%;\n margin: 1rem 0;\n}\n\n.storecrm_modal__overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n z-index: 10000;\n background: rgba(0,0,0,0.6);\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.storecrm_modal__container {\n background-color: #fff;\n padding: 30px;\n min-width: 320px;\n max-width: 500px;\n min-height: 200px;\n max-height: 100vh;\n border-radius: 4px;\n overflow-y: auto;\n box-sizing: border-box;\n}\n\n.storecrm_modal__header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.storecrm_modal__title {\n margin-top: 0;\n margin-bottom: 0;\n font-weight: 600;\n font-size: 1.25;\n line-height: 1.25;\n box-sizing: border-box;\n}\n\n.storecrm_modal__close {\n background: transparent;\n border: 0;\n cursor: pointer;\n}\n\n.storecrm_modal_message {\n margin-top: 2rem;\n padding: 1rem;\n}\n\n.storecrm_modal__header .storecrm_modal__close:before { content: "\\2715"; }\n\n.storecrm_modal__content {\n margin-top: 2rem;\n margin-bottom: 1rem;\n line-height: 1.5;\n color: rgba(0,0,0,.8);\n}\n\n.storecrm_modal__btn {\n display: block;\n width: 100%;\n padding-top: 1rem;\n padding-bottom: 1rem;\n background-color: #e6e6e6;\n color: rgba(0,0,0,.8);\n border-radius: .25rem;\n border-style: none;\n border-width: 0;\n cursor: pointer;\n -webkit-appearance: button;\n text-transform: none;\n overflow: visible;\n line-height: 1.15;\n margin: 0;\n margin-top: 1rem;\n will-change: transform;\n -moz-osx-font-smoothing: grayscale;\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n transition: -webkit-transform .25s ease-out;\n transition: transform .25s ease-out;\n transition: transform .25s ease-out,-webkit-transform .25s ease-out;\n}\n\n.storecrm_modal__btn:hover {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n}\n\n.storecrm_modal__btn-primary {\n background-color: #00449e;\n color: #fff;\n}\n\n.storecrm_modal__btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n@keyframes mmfadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n@keyframes mmfadeOut {\n from { opacity: 1; }\n to { opacity: 0; }\n}\n\n@keyframes mmslideIn {\n from { transform: translateY(15%); }\n to { transform: translateY(0); }\n}\n\n@keyframes mmslideOut {\n from { transform: translateY(0); }\n to { transform: translateY(-10%); }\n}\n\n.micromodal-slide {\n display: none;\n}\n\n.micromodal-slide.is-open {\n display: block;\n}\n\n.micromodal-slide[aria-hidden="false"] .storecrm_modal__overlay {\n animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden="false"] .storecrm_modal__container {\n animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);\n}\n\n.micromodal-slide[aria-hidden="true"] .storecrm_modal__overlay {\n animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden="true"] .storecrm_modal__container {\n animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);\n}\n\n.micromodal-slide .storecrm_modal__container,\n.micromodal-slide .storecrm_modal__overlay {\n will-change: transform;\n}\n\n/* フェードイン・フェードアウトアニメーション用のクラス */\n.fade-out {\n animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1) forwards;\n}\n\n.fade-in {\n animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1) forwards;\n}\n\n.storecrm-status-widget {\n width: 100%;\n border: 1px solid #e6e6e6;\n display: flex;\n align-items: center;\n justify-content: center;\n max-height: 3em;\n}\n\n.storecrm-status-widget > div {\n padding: 1rem;\n}\n\n.storecrm-on {\n /* deep green, bold */\n color: #094c00;\n font-weight: bold;;\n}\n\n.storecrm-off {\n color: #df8536c6;\n font-weight: bold;\n}\n\n.line-chat-preview {\n display: flex;\n flex-direction: column;\n width: 360px;\n height: 640px;\n border: 1px solid #ddd;\n overflow: hidden;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n background-color: #92AAD4;\n}\n\n.line-chat-header {\n display: flex;\n align-items: center;\n padding: 10px 16px;\n background-color: #44556F;\n color: white;\n height: 50px;\n}\n\n.line-chat-body {\n flex-grow: 1;\n overflow-y: auto;\n display: flex;\n flex-direction: column;\n gap: 8px;\n position: relative;\n scrollbar-width: none;\n -ms-overflow-style: none;\n}\n\n.line-chat-body::-webkit-scrollbar {\n display: none;\n}\n\n.line-chat-footer {\n padding: 0 16px 0 16px;\n background-color: #ffffff;\n display: flex;\n align-items: center;\n justify-content: space-between;\n height: 50px;\n}\n\n.line-chat-keyboard-icon {\n width: 22px;\n height: 22px;\n}\n\n.line-chat-chatbarText {\n flex-grow: 1;\n font-size: 14px;\n color: #000;\n text-align: center;\n}\n\n/* リッチメニュー表示時のスタイル */\n.line-chat-footer.menu-open .line-chat-chatbarText:after {\n content: "▼";\n}\n\n/* リッチメニュー非表示時のスタイル */\n.line-chat-footer:not(.menu-open) .line-chat-chatbarText:after {\n content: "▲";\n}\n\n.line-richmenu-preview {\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n background-color: #ffffff;\n transform: translateY(100%);\n transition: transform 0.3s cubic-bezier(0.0, 0.0, 0.2, 1);\n z-index: 10;\n box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);\n}\n\n.line-richmenu-preview.menu-open {\n transform: translateY(0);\n}\n\n.line-richmenu-preview.menu-closed {\n transform: translateY(100%);\n} ',""]);const a=s},314:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var o="",n=void 0!==t[5];return t[4]&&(o+="@supports (".concat(t[4],") {")),t[2]&&(o+="@media ".concat(t[2]," {")),n&&(o+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),o+=e(t),n&&(o+="}"),t[2]&&(o+="}"),t[4]&&(o+="}"),o})).join("")},t.i=function(e,o,n,i,r){"string"==typeof e&&(e=[[null,e,void 0]]);var s={};if(n)for(var a=0;a0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),o&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=o):d[2]=o),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),t.push(d))}},t}},601:e=>{e.exports=function(e){return e[1]}},804:(e,t,o)=>{function n(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return i(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);return"Object"===o&&e.constructor&&(o=e.constructor.name),"Map"===o||"Set"===o?Array.from(e):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?i(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var o=0,n=new Array(t);ou});var r,s,a,c,l,d=(r=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],s=function(){function e(t){var o=t.targetModal,i=t.triggers,r=void 0===i?[]:i,s=t.onShow,a=void 0===s?function(){}:s,c=t.onClose,l=void 0===c?function(){}:c,d=t.openTrigger,u=void 0===d?"data-micromodal-trigger":d,h=t.closeTrigger,m=void 0===h?"data-micromodal-close":h,g=t.openClass,p=void 0===g?"is-open":g,f=t.disableScroll,b=void 0!==f&&f,v=t.disableFocus,_=void 0!==v&&v,y=t.awaitCloseAnimation,w=void 0!==y&&y,k=t.awaitOpenAnimation,S=void 0!==k&&k,x=t.debugMode,C=void 0!==x&&x;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.modal=document.getElementById(o),this.config={debugMode:C,disableScroll:b,openTrigger:u,closeTrigger:m,openClass:p,onShow:a,onClose:l,awaitCloseAnimation:w,awaitOpenAnimation:S,disableFocus:_},r.length>0&&this.registerTriggers.apply(this,n(r)),this.onClick=this.onClick.bind(this),this.onKeydown=this.onKeydown.bind(this)}var t;return(t=[{key:"registerTriggers",value:function(){for(var e=this,t=arguments.length,o=new Array(t),n=0;n0&&void 0!==arguments[0]?arguments[0]:null;this.activeElement=document.activeElement,this.modal.setAttribute("aria-hidden","false"),this.modal.classList.add(this.config.openClass),this.scrollBehaviour("disable"),this.addEventListeners(),this.config.awaitOpenAnimation?this.modal.addEventListener("animationend",(function t(){e.modal.removeEventListener("animationend",t,!1),e.setFocusToFirstNode()}),!1):this.setFocusToFirstNode(),this.config.onShow(this.modal,this.activeElement,t)}},{key:"closeModal",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this.modal;if(this.modal.setAttribute("aria-hidden","true"),this.removeEventListeners(),this.scrollBehaviour("enable"),this.activeElement&&this.activeElement.focus&&this.activeElement.focus(),this.config.onClose(this.modal,this.activeElement,e),this.config.awaitCloseAnimation){var o=this.config.openClass;this.modal.addEventListener("animationend",(function e(){t.classList.remove(o),t.removeEventListener("animationend",e,!1)}),!1)}else t.classList.remove(this.config.openClass)}},{key:"closeModalById",value:function(e){this.modal=document.getElementById(e),this.modal&&this.closeModal()}},{key:"scrollBehaviour",value:function(e){if(this.config.disableScroll){var t=document.querySelector("body");switch(e){case"enable":Object.assign(t.style,{overflow:""});break;case"disable":Object.assign(t.style,{overflow:"hidden"})}}}},{key:"addEventListeners",value:function(){this.modal.addEventListener("touchstart",this.onClick),this.modal.addEventListener("click",this.onClick),document.addEventListener("keydown",this.onKeydown)}},{key:"removeEventListeners",value:function(){this.modal.removeEventListener("touchstart",this.onClick),this.modal.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeydown)}},{key:"onClick",value:function(e){(e.target.hasAttribute(this.config.closeTrigger)||e.target.parentNode.hasAttribute(this.config.closeTrigger))&&(e.preventDefault(),e.stopPropagation(),this.closeModal(e))}},{key:"onKeydown",value:function(e){27===e.keyCode&&this.closeModal(e),9===e.keyCode&&this.retainFocus(e)}},{key:"getFocusableNodes",value:function(){var e=this.modal.querySelectorAll(r);return Array.apply(void 0,n(e))}},{key:"setFocusToFirstNode",value:function(){var e=this;if(!this.config.disableFocus){var t=this.getFocusableNodes();if(0!==t.length){var o=t.filter((function(t){return!t.hasAttribute(e.config.closeTrigger)}));o.length>0&&o[0].focus(),0===o.length&&t[0].focus()}}}},{key:"retainFocus",value:function(e){var t=this.getFocusableNodes();if(0!==t.length)if(t=t.filter((function(e){return null!==e.offsetParent})),this.modal.contains(document.activeElement)){var o=t.indexOf(document.activeElement);e.shiftKey&&0===o&&(t[t.length-1].focus(),e.preventDefault()),!e.shiftKey&&t.length>0&&o===t.length-1&&(t[0].focus(),e.preventDefault())}else t[0].focus()}}])&&function(e,t){for(var o=0;o')),!1},l=function(e,t){if(function(e){e.length<=0&&(console.warn("MicroModal: ❗Please specify at least one %c'micromodal-trigger'","background-color: #f8f9fa;color: #50596c;font-weight: bold;","data attribute."),console.warn("%cExample:","background-color: #f8f9fa;color: #50596c;font-weight: bold;",''))}(e),!t)return!0;for(var o in t)c(o);return!0},{init:function(e){var t=Object.assign({},{openTrigger:"data-micromodal-trigger"},e),o=n(document.querySelectorAll("[".concat(t.openTrigger,"]"))),i=function(e,t){var o=[];return e.forEach((function(e){var n=e.attributes[t].value;void 0===o[n]&&(o[n]=[]),o[n].push(e)})),o}(o,t.openTrigger);if(!0!==t.debugMode||!1!==l(o,i))for(var r in i){var c=i[r];t.targetModal=r,t.triggers=n(c),a=new s(t)}},show:function(e,t){var o=t||{};o.targetModal=e,!0===o.debugMode&&!1===c(e)||(a&&a.removeEventListeners(),(a=new s(o)).showModal())},close:function(e){e?a.closeModalById(e):a.closeModal()}});"undefined"!=typeof window&&(window.MicroModal=d);const u=d},511:(e,t,o)=>{o.r(t),o.d(t,{default:()=>b});var n=o(72),i=o.n(n),r=o(825),s=o.n(r),a=o(659),c=o.n(a),l=o(56),d=o.n(l),u=o(540),h=o.n(u),m=o(113),g=o.n(m),p=o(208),f={};f.styleTagTransform=g(),f.setAttributes=d(),f.insert=c().bind(null,"head"),f.domAPI=s(),f.insertStyleElement=h(),i()(p.A,f);const b=p.A&&p.A.locals?p.A.locals:void 0},72:e=>{var t=[];function o(e){for(var o=-1,n=0;n{var t={};e.exports=function(e,o){var n=function(e){if(void 0===t[e]){var o=document.querySelector(e);if(window.HTMLIFrameElement&&o instanceof window.HTMLIFrameElement)try{o=o.contentDocument.head}catch(e){o=null}t[e]=o}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(o)}},540:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},56:(e,t,o)=>{e.exports=function(e){var t=o.nc;t&&e.setAttribute("nonce",t)}},825:e=>{e.exports=function(e){if("undefined"==typeof document)return{update:function(){},remove:function(){}};var t=e.insertStyleElement(e);return{update:function(o){!function(e,t,o){var n="";o.supports&&(n+="@supports (".concat(o.supports,") {")),o.media&&(n+="@media ".concat(o.media," {"));var i=void 0!==o.layer;i&&(n+="@layer".concat(o.layer.length>0?" ".concat(o.layer):""," {")),n+=o.css,i&&(n+="}"),o.media&&(n+="}"),o.supports&&(n+="}");var r=o.sourceMap;r&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,o)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},113:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},989:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.schema=t.renderWidgetSelector=t.hideWidgetSelector=t.render=t.getIcon=void 0,t.getIcon=(e,t=!1)=>{let o=null;return"star"===e.buttonicon?o=t?'':'':"heart"===e.buttonicon?o=t?'':'':"tag"===e.buttonicon?o='':"clip"===e.buttonicon&&(o=''),o&&(o=o.replace("viewBox",`width="${e.icon_size}" height="${e.icon_size}" style="margin-right: ${e.icon_margin}px;" viewBox`)),o};class o{constructor(e,t,o,n,i,r=!1,s=!1,a){this.eventTriggered=!1,this.variants=o,this.buttonSettings=Object.assign({},n),this.productId=t,this.button=i,this.isFavorited=r,this.hasVariantSelector=s,this.variantId=a,this.buttonSettings.has_background||(this.buttonSettings.button_width="auto",this.buttonSettings.button_height="auto",this.buttonSettings.button_radius=0,this.buttonSettings.button_border_width=0,this.buttonSettings.button_background_color="transparent",this.buttonSettings.button_border_color="transparent",this.buttonSettings.button_hover_border_color="transparent",this.buttonSettings.button_hover_background_color="transparent")}static getInstance(e,t,n,i,r,s=!1,a=!1,c){return o.instances[e]?(o.instances[e].isFavorited=s,o.instances[e].hasVariantSelector=a):o.instances[e]=new o(e,t,n,i,r,s,a,c),o.instances[e]}checkRender(e){document.querySelectorAll(`.storecrm-wishlistbutton-${e}`).forEach((e=>{if(e instanceof HTMLElement&&e.closest('[data-type="wishlist-button"]')){const t=new URL(location.href),o=t.searchParams.get("variant")&&t.searchParams.get("variant")||"";o&&(e.dataset.variantId=o),window.storecrm&&window.storecrm.render(!0)}}))}render(e,o=!1){const n=(0,t.getIcon)(this.buttonSettings,this.isFavorited),i=new URL(location.href),r=parseInt(i.searchParams.get("variant")||this.variantId||"0",10)||"",s=this.hasVariantSelector?"data-variant-selector":"",a=void 0!==this.button.dataset.noLabel;if(!this.eventTriggered)if(window.navigation)window.navigation.addEventListener("navigate",(()=>{window.setTimeout((()=>this.checkRender(e)),100)})),window.setTimeout((()=>this.checkRender(e)),100),window.setTimeout((()=>this.checkRender(e)),1e3);else{let t=location.href;window.setInterval((()=>{t!==location.href&&(t=location.href,this.checkRender(e))}),1e3),window.setTimeout((()=>this.checkRender(e)),100),window.setTimeout((()=>this.checkRender(e)),1e3)}this.eventTriggered,this.eventTriggered=!0;const c=o?"":`onclick="event.preventDefault();window.storecrm ? window.storecrm.toggleWishlist(this, ${this.isFavorited?"true":"false"}, ${this.buttonSettings.is_only_member}, '${this.buttonSettings.non_member_link}') : alert('読込中です。しばらくたってから再度お試しください。');"`,l=``,d=document.querySelector("#storecrm-wishlistbutton-style");return o?(d&&d.remove(),document.body.insertAdjacentHTML("afterend",l)):d||document.body.insertAdjacentHTML("afterend",l),`
\n\n
`}}let n,i,r;o.instances={},t.render=({productId:e,variantId:t,id:n,variants:i,product:r,button:s,buttonSettings:a,isFavorited:c=!1,preview:l=!1,hasVariantSelector:d=!1})=>o.getInstance(n,e,i,a,s,c,d,t).render(n,l),t.hideWidgetSelector=()=>{n&&(n.remove(),n=void 0),document.querySelectorAll(".storecrm-variantselector-dropdown").forEach((e=>e.remove())),i=void 0,r=void 0},t.renderWidgetSelector=({button:e,productId:o,variants:s,wishlist:a,buttonSettings:c,preview:l=!1,rerender:d=!1})=>{const u=i===o&&r?r:s,h=n&&d&&i==o?n.style:void 0;if(!l&&d&&i!==o)return;if(!l&&n&&(n.remove(),n=void 0,!d))return;i=o,r=u;const m=u.map((e=>{const n=a.variants.indexOf(e.id.toString())>=0,i=(0,t.getIcon)(c,n),r=l?"":`onclick="event.preventDefault();event.stopPropagation();window.storecrm ? window.storecrm.toggleWishlist(this, ${n?"true":"false"}, ${c.is_only_member}, '${c.non_member_link}') : alert('読込中です。しばらくたってから再度お試しください。');"`;return`\n ${i||(n?c.button_text_remove:c.button_text)}\n ${e.title}\n `})).join("");let g="";if(l)g="position: static;";else if(h)g=`top: ${h.top}; left: ${h.left};`;else{const t=e.getBoundingClientRect(),o=250;let n=t.left+document.documentElement.scrollLeft;n+o>window.innerWidth&&(n=window.innerWidth-o),g=`top: ${t.bottom+document.documentElement.scrollTop}px; left: ${n}px;`}const p=``;l||(document.body.insertAdjacentHTML("afterend",p),n=document.querySelector(".storecrm-variantselector-dropdown"));{const e=e=>{e.target&&e.target instanceof HTMLElement&&e.target.closest("[data-variant-selector]")||n&&(n.remove(),n=void 0)};document.addEventListener("click",e),document.addEventListener("resize",e)}return p},t.schema={preview:e=>{let o='
お気に入り(お気に入り前)
';return o+=(0,t.render)({productId:"TEMP_product",id:"TEMP_favorite",buttonSettings:e,button:document.createElement("div"),isFavorited:!1,preview:!0,variants:[],product:null}),"variant"===e.favoriteMode&&(o+='
バリエーションモードの際の
',o+=(0,t.renderWidgetSelector)({productId:"TEMP_product",variants:[{id:"1",title:"バリエーション1"},{id:"2",title:"バリエーション2"},{id:"3",title:"バリエーション3"}],wishlist:{variants:[]},buttonSettings:e,button:document.createElement("div"),preview:!0,rerender:!1})),o+='
お気に入り(お気に入り後)
',o+=(0,t.render)({productId:"TEMP_product",id:"TEMP_favorite2",buttonSettings:e,button:document.createElement("div"),isFavorited:!0,preview:!0,variants:[],product:null}),o},rows:[{type:"card",slug:"favoriteMode",nameJa:"お気に入りのモードを選んでください",nameEn:"Choose the favorite mode",default:"product",selectOptions:[{value:"product",label:"商品ごとにお気に入りをする"},{value:"variant",label:"バリエーション(商品の色やサイズなど)ごとにお気に入りをする"}],warningOnChangeJa:"設定を変更すると、既存のお気に入りデータが無効となります。データ移管をご希望の方はこの設定を保存せずに、お問い合わせください。",warningOnChangeEn:"Changing the setting will invalidate existing favorite data. Please contact us if you wish to transfer the data.",fullsize:!0},{type:"checkbox",slug:"is_only_member",nameJa:"お気に入り機能の利用を会員限定にする",nameEn:"isOnlyMember",default:!1,fullsize:!0},{type:"text",slug:"non_member_link",nameJa:"ゲストがお気に入りを押した場合の遷移先URL ※空欄の場合ログイン画面に遷移します",nameEn:"nonMemberLink ※If left blank, you will be redirected to the login screen.",default:"",depends:"is_only_member",fullsize:!0},{type:"select",slug:"buttonicon",nameJa:"アイコン",nameEn:"buttonIcon",selectOptions:[{value:"star",label:"星マーク(☆)"},{value:"heart",label:"ハートマーク(♡)"},{value:"tag",label:"タグアイコン"},{value:"clip",label:"クリップアイコン"},{value:"none",label:"なし"}],default:"star"},{type:"text",slug:"button_text",nameJa:"ボタンのテキスト",nameEn:"buttonText",default:"お気に入り"},{type:"text",slug:"button_text_remove",nameJa:"ボタンのテキスト(お気に入り解除)",nameEn:"buttonTextRemove",default:"お気に入り済み"},{type:"checkbox",slug:"has_background",nameJa:"背景があるボタンにする",nameEn:"hasBackground",default:!1},{type:"range",slug:"button_width",nameJa:"ボタンの幅",nameEn:"buttonWidth",default:200,min:50,max:600,step:10,depends:"has_background"},{type:"range",slug:"button_height",nameJa:"ボタンの高さ",nameEn:"buttonHeight",default:50,min:30,max:100,step:10,depends:"has_background"},{type:"colorpicker",slug:"button_color",nameJa:"ボタンの文字色",nameEn:"buttonColor",default:"#000000"},{type:"colorpicker",slug:"icon_color",nameJa:"アイコンの文字色",nameEn:"iconColor",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"ボタンの背景色",nameEn:"buttonBackgroundColor",default:"#ffffff",depends:"has_background"},{type:"colorpicker",slug:"button_border_color",nameJa:"ボタンの線の色",nameEn:"buttonBorderColor",default:"#000000",depends:"has_background"},{type:"colorpicker",slug:"button_hover_color",nameJa:"ボタンの文字色(ホバー時)",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"icon_hover_color",nameJa:"アイコンの文字色(ホバー時)",nameEn:"iconHoverColor",default:"#000000"},{type:"colorpicker",slug:"button_hover_background_color",nameJa:"ボタンの背景色(ホバー時)",nameEn:"buttonHoverBackgroundColor",default:"#dddddd",depends:"has_background"},{type:"colorpicker",slug:"button_hover_border_color",nameJa:"ボタンの線の色(ホバー時)",nameEn:"buttonHoverBorderColor",default:"#222222",depends:"has_background"},{type:"range",slug:"button_radius",nameJa:"ボタンの丸み",nameEn:"buttonRadius",default:5,min:0,max:20,step:1,depends:"has_background"},{type:"range",slug:"button_border_width",nameJa:"ボタンの線の太さ",nameEn:"buttonBorderWidth",default:0,min:0,max:10,step:1,depends:"has_background"},{type:"fontpicker",slug:"button_font",nameJa:"ボタンのフォント",nameEn:"buttonFont",default:"helvetica_n4"},{type:"range",slug:"button_fontsize",nameJa:"ボタ���のフォントサイズ",nameEn:"buttonFontSize",default:16,min:10,max:30,step:1},{type:"range",slug:"button_fontweight",nameJa:"ボタンのフォントウェイト",nameEn:"buttonFontWeight",default:400,min:100,max:900,step:100},{type:"range",slug:"icon_size",nameJa:"アイコンのサイズ",nameEn:"iconSize",default:16,min:10,max:30,step:1},{type:"range",slug:"icon_margin",nameJa:"アイコンとテキストとの間隔",nameEn:"iconMargin",default:5,min:0,max:20,step:1},{type:"range",slug:"button_speed",nameJa:"ボタンのアニメーション速度",nameEn:"buttonSpeed",default:.3,min:0,max:1,step:.1},{type:"select",slug:"align",nameJa:"ボタンの配置",nameEn:"align",default:"center",selectOptions:[{value:"left",label:"左寄せ"},{value:"center",label:"中央寄せ"},{value:"right",label:"右寄せ"}]},{type:"colorpicker",slug:"popup_text_color",nameJa:"POPUPのテキスト色",nameEn:"popupTextColor",default:"#000000",checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_background_color",nameJa:"POPUPの背景色",nameEn:"popupBackgroundColor",default:"#ffffff",checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_icon_color",nameJa:"POPUPのアイコン色",nameEn:"popupIconColor",default:"#000000",checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_icon_hover_color",nameJa:"POPUPのアイコン色(ホバー時)",nameEn:"popupIconHoverColor",default:"#000000",checkVisible:e=>"variant"===e.favoriteMode},{type:"range",slug:"popup_border_width",nameJa:"POPUPの線の太さ",nameEn:"popupBorderWidth",default:0,min:0,max:10,step:1,checkVisible:e=>"variant"===e.favoriteMode},{type:"colorpicker",slug:"popup_border_color",nameJa:"POPUPの線の色",nameEn:"popupBorderColor",default:"#999",checkVisible:e=>"variant"===e.favoriteMode}]}},158:function(e,t,o){var n=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(i,r){function s(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Renderer=void 0;const i=o(215),r=o(264),s={list_title:"お気に入り一覧",loading_text:"読込中です...",non_item_text:"現在お気に入り中の商品はありません",show_cart:!1,insert_cart_directly:!0};class a{static getInstance(e){return a.instance||(a.instance=new a(e)),a.instance}constructor(e){this.config=s,this.mode="product",this.inited=!1,this.parent=e}init(){return n(this,void 0,void 0,(function*(){this.inited||(this.inited=!0,yield this.loadConfig())}))}loadConfig(){return n(this,void 0,void 0,(function*(){this.config=Object.assign(Object.assign({},s),this.parent.config.favoriteList||{}),this.applyConfig(),this.mode=this.parent.favoriteMode}))}applyConfig(){const e=document.getElementById("list_title"),t=document.getElementById("loading_text"),o=document.getElementById("non_item_text");e&&(e.textContent=this.config.list_title),t&&(t.textContent=this.config.loading_text),o&&(o.textContent=this.config.non_item_text)}render(){return n(this,void 0,void 0,(function*(){var e;const t=JSON.parse(localStorage.getItem("storecrm_wishlist")||"{}");if("product"===this.mode?t.products.join(","):t.variants.join(","),!(null==t?void 0:t.products)||0===t.products.length){null===(e=document.querySelector(".storecrm_favoritelist table"))||void 0===e||e.remove();const t=document.querySelector(".storecrm_favoritelist_loading"),o=document.querySelector(".storecrm_favoritelist_non_item");return t&&(t.style.display="none"),void(o&&(o.style.display="block"))}const o=document.querySelector(".storecrm_favoritelist_loading");o&&(o.style.display="none");const n="product"===this.mode?t.products.join(","):t.variants.join(",");yield this.loadProductAndRender(n)}))}loadProductAndRender(e){return n(this,void 0,void 0,(function*(){const t=yield fetch(`/apps/${this.parent.config.appProxyName}/favorites/products?mode=${this.mode}&ids=${e}`),o=yield t.json();this.renderProducts(o)}))}renderProducts(e){const t=document.querySelector(".storecrm_favoritelist tbody"),o=document.querySelector(".storecrm_favoritelist_loading"),n=document.querySelector(".storecrm_favoritelist table");if(!(t&&o&&n&&t instanceof HTMLElement&&o instanceof HTMLElement&&n instanceof HTMLElement))return void console.log("StoreCRM: Elements not found",t,o,n);const i="variant"===this.mode?e.variants:e.products;for(;t.firstChild;)t.removeChild(t.firstChild);i.forEach((e=>t.appendChild(this.createFavoriteRow(t,e)))),o.style.display="none",n.style.display="table"}createFavoriteRow(e,t){const o=document.createElement("tr");o.classList.add(`storecrm_favoritelist_id-${t.variant_id||t.product_id}`);const n="product"===this.mode?`/products/${t.handle}`:`/products/${t.handle}?variant=${t.variant_id}`,s=document.createElement("td");s.classList.add("storecrm_favoritelist_lefttd");const a=document.createElement("a");if(a.href=n,a.textContent=t.title,t.thumbnail_url){const e=document.createElement("img");e.classList.add("storecrm_favoritelist_img"),e.src=t.thumbnail_url,s.appendChild(e)}s.appendChild(a);const c=document.createElement("td");c.classList.add("storecrm_favoritelist_righttd");const l=document.createElement("div");if(l.classList.add("storecrm_favoritelist_links"),this.config.show_cart&&t.available){const e=document.createElement("a");e.classList.add("storecrm_favoritelist_link"),e.href="javascript:void(0);",e.innerHTML=r.iconCart,e.onclick=()=>(0,i.cartFavorite)(this.mode,"product"==this.mode?t.product_id:t.variant_id||"",t.handle,this.config.insert_cart_directly),l.appendChild(e)}const d=document.createElement("a");return d.classList.add("storecrm_favoritelist_link"),d.href="javascript:void(0);",d.innerHTML=r.iconDelete,"product"==this.mode||(d.dataset.variantId=t.variant_id),d.dataset.productId=t.product_id,d.onclick=()=>this.parent.toggleWishlist(d,!0,this.parent.config.favorite.is_only_member,this.parent.config.favorite.non_member_link),l.appendChild(d),c.appendChild(l),o.appendChild(s),o.appendChild(c),o}}t.Renderer=a,a.instance=void 0},264:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.iconCart=t.iconDelete=void 0,t.iconDelete='',t.iconCart=''},215:function(e,t){var o=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(i,r){function s(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};function n(e){return o(this,void 0,void 0,(function*(){try{const t=yield fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,quantity:1})});if(!t.ok)throw new Error(`Failed to add to cart: ${t.statusText}`);const o=yield t.json();console.log("StoreCRM: 商品がカートに追加されました:",o),window.location.href="/cart"}catch(e){console.error("StoreCRM: エラーが発生しました:",e),alert("カートに追加できませんでした。")}}))}Object.defineProperty(t,"__esModule",{value:!0}),t.addToCart=t.cartFavorite=void 0,t.cartFavorite=function(e,t,o,i){"product"!==e?i?n(t):window.location.href=`/products/${encodeURIComponent(o)}?variant=${t}`:window.location.href=`/products/${encodeURIComponent(o)}`},t.addToCart=n},779:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class o{constructor(e,t){this.loginButtonImg="/buttons/images/line_login_btn.png",this.store_id=null,this.shop=null,this.registered=!1,this.baseUrl=e,this.storeId=t,this.store_id=t,console.log("StoreCRM: LineLogin constructed with:",{baseUrl:e,storeId:t})}static getInstance(){var e,t;return o.instance||(o.instance=new o((null===(e=o.detectStoreConfig())||void 0===e?void 0:e.baseUrl)||"https://serverless.storecrm.io/line",(null===(t=o.detectStoreConfig())||void 0===t?void 0:t.storeId)||"")),o.instance}static detectStoreConfig(){console.debug("StoreCRM: detectStoreConfig called");try{const e=document.querySelectorAll("script");console.debug(`Found ${e.length} script tags`);let t="",o="https://serverless.storecrm.io/line";for(let n=0;n0)return console.debug("StoreCRM: Adding LINE login buttons to custom containers"),void e.forEach((e=>{const t=this.createLineButton();e.appendChild(t),console.debug("StoreCRM: LINE login button added to custom container")}));console.debug("StoreCRM: No custom containers found, falling back to auto-detection"),this.isLoginPage()&&(console.debug("Adding LINE login button to login page"),this.addLoginButton()),this.isRegisterPage()&&(console.debug("Adding LINE login button to register page"),this.addRegisterButton())}catch(e){console.error("Error in init:",e)}else console.debug("StoreCRM: LINE login is not enabled. LINE login will not be initialized.")}isLoginPage(){console.debug("Checking if current page is a login page");try{const e=document.querySelector('form[action*="login"], form[action*="sign_in"]');return console.debug(`Login form found: ${!!e}`),!!e}catch(e){return console.error("Error in isLoginPage:",e),!1}}isRegisterPage(){console.debug("Checking if current page is a register page");try{const e=document.querySelector('form[action*="register"], form[action*="sign_up"], form[action*="create_customer"]');return console.debug(`Register form found: ${!!e}`),!!e}catch(e){return console.error("Error in isRegisterPage:",e),!1}}addLoginButton(){var e;const t=document.querySelector('form[action*="/account/login"]');if(console.debug("StoreCRM: Login form found:",!!t),!t)return void console.debug("StoreCRM: All forms on page:",document.querySelectorAll("form"));let o=t.querySelector('button[type="submit"]');if(o||(o=t.querySelector("button"),console.debug("StoreCRM: Using generic button instead:",!!o)),console.debug("StoreCRM: Submit button found:",!!o),!o){console.debug("StoreCRM: All buttons in form:",t.querySelectorAll("button")),console.debug("StoreCRM: No button found, appending to form");const e=document.createElement("div");e.className="line-login-container",e.style.marginTop="20px",e.style.textAlign="center";const o=this.createLineButton();return e.appendChild(o),t.appendChild(e),void console.debug("StoreCRM: LINE login button appended to form")}const n=document.createElement("div");n.className="line-login-container",n.style.marginTop="20px",n.style.textAlign="center";const i=this.createLineButton();n.appendChild(i),console.debug("StoreCRM: Inserting LINE login button after submit button"),null===(e=o.parentNode)||void 0===e||e.insertBefore(n,o.nextSibling),console.debug("StoreCRM: LINE login button inserted")}addRegisterButton(){var e;const t=document.querySelector('form[action*="/account/register"]');if(console.debug("StoreCRM: Register form found:",!!t),!t)return;let o=t.querySelector('button[type="submit"]');if(o||(o=t.querySelector("button"),console.debug("StoreCRM: Using generic button instead:",!!o)),console.debug("StoreCRM: Submit button found:",!!o),!o){console.debug("StoreCRM: No button found, appending to form");const e=document.createElement("div");e.className="line-login-container",e.style.marginTop="20px",e.style.textAlign="center";const o=this.createLineButton();return e.appendChild(o),t.appendChild(e),void console.debug("StoreCRM: LINE register button appended to form")}const n=document.createElement("div");n.className="line-login-container",n.style.marginTop="20px",n.style.textAlign="center";const i=this.createLineButton();n.appendChild(i),console.debug("StoreCRM: Inserting LINE register button after submit button"),null===(e=o.parentNode)||void 0===e||e.insertBefore(n,o.nextSibling),console.debug("StoreCRM: LINE register button inserted")}createLineButton(){if(console.debug("StoreCRM: Creating LINE button"),!document.getElementById("btn-line-login-style")){const e=document.createElement("style");e.id="btn-line-login-style",e.innerHTML=".btn-line-login::after { box-shadow: none !important; }",document.head.appendChild(e)}const e=document.createElement("button");e.type="button",e.className="btn-line-login",e.style.backgroundColor="#06C755",e.style.color="#FFFFFF",e.style.border="none",e.style.borderRadius="4px",e.style.padding="0 6px",e.style.cursor="pointer",e.style.display="flex",e.style.alignItems="center",e.style.justifyContent="center",e.style.width="auto",e.style.height="48px",e.style.marginBottom="10px",e.style.textAlign="center",e.style.fontWeight="bold",e.style.fontSize="16px",e.style.letterSpacing="0.03em",e.style.boxShadow="0 2px 4px 0 rgba(0,0,0,0.04)",e.style.transition="background 0.2s",e.style.position="relative",e.style.overflow="hidden",e.style.boxSizing="border-box",e.style.marginTop="12px",e.style.marginBottom="12px",e.style.paddingTop="0",e.style.paddingBottom="0",e.onmouseover=()=>{e.style.backgroundColor="#06C755",e.style.filter="brightness(0.95)"},e.onmouseout=()=>{e.style.backgroundColor="#06C755",e.style.filter="none"},e.onmousedown=()=>{e.style.backgroundColor="#06C755",e.style.filter="brightness(0.85)"},e.onmouseup=()=>{e.style.backgroundColor="#06C755",e.style.filter="brightness(0.95)"};const t=document.createElement("span");t.style.display="flex",t.style.alignItems="center",t.style.justifyContent="center",t.style.marginRight="12px",t.style.width="32px",t.style.height="32px",t.style.flexShrink="0",t.style.background="none";const n=document.createElement("img");n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAYAAAAehFoBAAACpUlEQVRYhe2XTYhNURzAf8cMZSQSRT4LSRaGfISNlLJ8WUiUUMrKRoqFlUyyQNnY2tnaaEI2vmZKeoo0YUE+UhYTEoN+FveOnjvn3ufNu++N9H6re+85//P/nf875577oEOHDh3+K0IzwWo3sAXYDqwDlgMLgClplxHgNfAMeADcBO6EEH40k3c8ovPUs+p7G+d9GjuvHaLT1DPqt3GIZhlJx5rWKtledagE0SxDam/ZstvUTy2QHeWTuq0s2c3qlxbKjvJF3VzPp/Atoc4GqsD8UmZfnzdAbwjhQ16HSXUG6KN9sqS5+oo65FZYXQy8ALpKlqrHT2BpCOFlrLG7IHAfY2WHgGFgY+b5C+AtsAl4BbwjOVBGeUJyiKwC7mdie4D1Nfddae5TBW5jUe9GNsbWtC1LJX1eVfen1xdq2teoS9RqJM/MyHh387yKKryqoRmO5RiwgaTqZiQrQCW9jR0cubmLNt2MBgWzTAV2AbEd/5VkaQ0DHxvJXVThZrkM7AT2kGyk34QQ+oF+SJYEcPBvBy2qcHSXNkAFOBpCuAE8rm1QD6frvQoMRGJf5Q1aVOFBYHFO24Ga66LqnFEHQwi39Y9lPECyLABmAuczcfcKxoyj7o7s3h2RfpfSvkF9qh5Su2ti3qpz1eXq40j8nEienXleRQfHFOA5sLDh2TbHc2Bl3kd+7hoOIYwAx1tlVcCRpv6RqFciP1mruNj0dNUe46de2VxXJzctnEpPV6+1UPaW2lOKbI30JPWE+rVk2auly2bEl5ms658lyJ5T2/P5qi5ST6qPxiH6Wd3dFtEc+VnqdvW4+qyO7EN1xYTJZlHX5Yh+V0+bHEj/DuraiOwDdfVEu0VR99aIDqtHbdfGGg8mn46fTd4Asyfap0OHDh3+cX4BcUOZ2CqT2BUAAAAASUVORK5CYII=",n.width=32,n.height=32,n.alt="LINE",n.style.display="block",n.style.width="32px",n.style.height="32px",t.appendChild(n);const i=document.createElement("span");i.textContent=o.BUTTON_TEXT,i.style.display="inline-block",i.style.whiteSpace="nowrap",i.style.fontWeight="bold",i.style.fontSize="16px",i.style.lineHeight="1",i.style.letterSpacing="0.03em",i.style.userSelect="none",i.style.padding="0 32px",e.appendChild(t),e.appendChild(i);const r=document.createElement("div");return r.className="line-login-container",r.style.display="flex",r.style.justifyContent="center",r.style.alignItems="center",r.style.width="100%",r.style.marginTop="20px",r.style.marginBottom="10px",r.appendChild(e),e.onclick=()=>{console.debug("LINE login button clicked"),this.handleLineLogin()},console.debug("LINE login button created successfully"),r}handleLineLogin(){var e,t;console.debug("handleLineLogin called");try{const n=this.getCustomerId();console.debug(`Customer ID: ${n}`);let i=localStorage.getItem("storecrm_user_id");if(!i&&window.storecrm_data){const e=window.storecrm_data;e&&e.user_id&&(i=e.user_id)}if(!i){const n=null===(e=o.detectStoreConfig())||void 0===e?void 0:e.storeId,r=null===(t=window.line_config)||void 0===t?void 0:t.store_id;i=this.store_id||n||r||""}if(i&&!i.includes("myshopify.com")||(i="01GXYGKZ8Q1TKPMXFTZNZ0F4EE",console.debug("Using hardcoded user_id for testing purposes:",i)),!i)return console.error("No valid user_id found. Please make sure the user ID is properly configured."),void alert("LINE連携に必要な設定が見つかりません。ストアの管理者にお問い合わせください。");this.setCookie("line_login_customer_id",n||"",1),this.setCookie("line_login_store_id",i,1),this.setCookie("line_login_referrer",window.location.href,1),console.debug("Cookies set, redirecting to LINE login");let r=this.baseUrl;"localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||window.location.hostname.includes("dev-")||window.location.hostname.includes("test-")?(r="http://localhost:3002/line",console.debug("Development environment detected, using localhost:3002")):r||(r="https://serverless.storecrm.io/line");const s="https://obake-dev.groovymedia.biz/line/connect/callback",a=`${r}/auth?store_id=${i}&callback_url=${encodeURIComponent(s)}`;console.debug(`Redirecting to: ${a} with user_id: ${i}, callback_url: ${s}`),window.location.href=a}catch(e){console.error("Error in handleLineLogin:",e)}}getCustomerId(){console.debug("getCustomerId called");try{if(window.ShopifyAnalytics&&window.ShopifyAnalytics.meta){const e=window.ShopifyAnalytics.meta.page.customerId;return console.debug(`Found Shopify customer ID: ${e}`),e}return console.debug("No customer ID found"),null}catch(e){return console.error("Error in getCustomerId:",e),null}}setCookie(e,t,o){console.debug(`Setting cookie: ${e}=${t}, expires in ${o} days`);const n=new Date;n.setTime(n.getTime()+24*o*60*60*1e3),document.cookie=`${e}=${t};expires=${n.toUTCString()};path=/`}isLoginPath(e){return console.debug(`Checking if ${e} is a login path`),"/account/login"===e||/\blogin\b/i.test(e)}isRegisterPath(e){return console.debug(`Checking if ${e} is a register path`),"/account/register"===e||/\bregister\b/i.test(e)||/\bsignup\b/i.test(e)}}o.BUTTON_CLASS="line-login-button",o.CUSTOM_CONTAINER_CLASS="line-login-custom-container",o.instance=null,o.BUTTON_TEXT="LINEでログイン",t.default=o},435:function(e,t,o){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.schema=t.RestockPopupManager=void 0;const i=n(o(804));class r{constructor(e,t=!1){this.content=null,this.title=null,this.secondTitle=null,this.popup=null,this.button=null,this.footer=null,this.secondFooter=null,this.preview=!1,this.showSecondPopup=!1,this.container=null,this.secondContainer=null,this.secondContent=null,this.close=null,this.product_id=null,this.inited=!1,this.preview=t,this.config=e,this.init()}static getInstance(e,t=!1){return r.instance||(r.instance=new r(e,t)),r.instance}setParent(e){this.parent=e}renderTemplate(){document&&document.body?document.body.insertAdjacentHTML("beforeend",r.template):window.setTimeout(this.renderTemplate.bind(this),100)}init(){document&&document.body?this.runInit():window.setTimeout(this.init.bind(this),100)}runInit(){this.inited=!0,this.preview||document.body.insertAdjacentHTML("beforeend",r.template),i.default.init(),this.popup=document.getElementById("storecrm-modal"),this.content=document.getElementById("storecrm-modal-content"),this.secondContent=document.getElementById("storecrm-modal-second-content"),this.title=document.getElementById("storecrm-modal-title"),this.secondTitle=document.getElementById("storecrm-modal-second-title"),this.footer=document.querySelector(".storecrm_modal__footer"),this.secondFooter=document.getElementById("storecrm-modal-second-footer"),this.container=document.querySelector(".storecrm_modal__container"),this.secondContainer=document.getElementById("storecrm-modal-second-popup-preview"),this.container&&this.container.addEventListener("click",(e=>{e.stopPropagation()})),this.close=document.querySelector(".storecrm_modal__close"),this.close&&!this.preview&&this.close.addEventListener("click",(e=>{i.default.close("storecrm-modal")}))}render(e,t){var o,n,i,r;this.showSecondPopup=e.add_accepts_marketing_checkbox&&this.preview;const s=document.createElement("button");s.className="storecrm_modal__btn storecrm_modal__btn-primary",s.innerHTML=e.button_text,this.footer&&0!==this.footer.children.length&&(this.footer.innerHTML=""),null===(o=this.footer)||void 0===o||o.appendChild(s),this.button=s,this.button&&!this.preview&&this.button.addEventListener("click",(()=>{this.checkAcceptsMarketingStatusAndClearMessages()})),this.config=e;const a=(null===(n=window.storecrm_data)||void 0===n?void 0:n.customer_email)||window.localStorage.getItem("storecrm_restock_email")||"";if(this.title&&this.content&&this.popup){this.title.innerText=e.popup_title;let o=`\n
${e.popup_description}
\n
\n
${e.emailaddress}
\n${e.add_accepts_marketing_checkbox?``:""}\n${e.add_accepts_marketing_checkbox?``:""}\n
\n`.trim(),n=null;if(location.search&&location.search.includes("variant")){const e=new URL(location.href);n=e.searchParams.get("variant")}console.log("RestockPopupManager: render: variants",t,n);const i=t.filter((e=>!e.available)).map((e=>``)).join("");t&&Array.isArray(t)&&t.length>1?(o=o.replace("\x3c!-- select_style --\x3e",""),o=o.replace("\x3c!-- options --\x3e",i)):(o=o.replace("\x3c!-- select_style --\x3e","display:none"),o=o.replace("\x3c!-- options --\x3e",i)),this.content.innerHTML=o,this.content.style.color=e.text_color,this.container&&(this.container.style.backgroundColor=e.background_color,this.container.style.borderRadius=`${e.button_radius}px`,this.container.style.width="100%"),this.button&&(this.button.style.backgroundColor=e.button_background_color,this.button.style.color=e.button_text_color),this.close&&(this.close.style.color=e.close_text_color)}if(this.resetMessage(),this.showSecondPopup&&this.secondTitle&&this.secondContent&&this.secondContainer){this.secondContainer.style.display="block",this.secondTitle.innerText=e.popup_title;let t="";t=`\n
${e.email_confirmation_text}
hogehoge@hoge.com
\n
`,this.secondContent.innerHTML=t,this.secondContent.style.color=e.text_color,this.secondContainer.style.backgroundColor=e.background_color,this.secondContainer.style.borderRadius=`${e.button_radius}px`,this.secondContainer.style.marginTop="20px",this.secondContainer.style.width="100%",this.secondFooter&&0!==this.secondFooter.children.length&&(this.secondFooter.innerHTML="");const o=document.createElement("button");o.className="storecrm_modal__btn storecrm_modal__btn-primary",o.innerHTML=e.button_text,o.style.backgroundColor=e.button_background_color,o.style.color=e.button_text_color,null===(i=this.secondFooter)||void 0===i||i.appendChild(o)}else this.secondContainer&&(this.secondContainer.style.display="none");this.preview||null===(r=document.getElementById("storecrm-modal-second-popup-preview"))||void 0===r||r.remove(),this.preview&&(this.success(this.config.success_text),this.failure(this.config.error_text),this.popup&&this.popup.querySelectorAll(".storecrm_modal__overlay,.storecrm_modal__close").forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),e.stopPropagation()}))})))}resetMessage(){var e,t;this.footer&&(null===(e=this.footer)||void 0===e||e.querySelectorAll(".storecrm_modal_message").forEach((e=>e.remove()))),this.preview&&this.secondFooter&&(null===(t=this.secondFooter)||void 0===t||t.querySelectorAll(".storecrm_modal_message").forEach((e=>e.remove())))}disableButton(){this.button&&(this.button.setAttribute("disabled","disabled"),this.button.innerText="Sending...")}enableButtion(){this.button&&(this.button.removeAttribute("disabled"),this.button.innerText=this.config.button_text||"Enable Restock Notification")}submit(e=!1){var t,o,n;if(this.preview)return;this.resetMessage(),this.disableButton();const i=null===(t=this.content)||void 0===t?void 0:t.querySelector("#storecrm_restock_email"),r=null===(o=this.content)||void 0===o?void 0:o.querySelector("#storecrm_restock_variant"),s=null===(n=this.content)||void 0===n?void 0:n.querySelector("#storecrm_restock_accepts_marketing"),a=i?i.value:"",c=r?r.value:"",l=this.product_id,d=s?s.checked:null;this.parent&&this.parent.storeRestock(a,c,l,d,this.config.add_accepts_marketing_checkbox,e,this.success.bind(this),this.failure.bind(this))}show(e,t,o){this.product_id=o,this.inited?this.runShow(e,t):window.setTimeout(this.show.bind(this),100)}runShow(e,t){this.render(e,t),i.default.show("storecrm-modal")}hide(){i.default.close("storecrm-modal")}success(e){this.enableButtion();const t=document.createElement("div");t.classList.add("storecrm_modal_success","storecrm_modal_message"),t.style.color=this.config.success_text_color,t.style.backgroundColor=this.config.success_background_color,t.innerText=e,this.showSecondPopup?this.secondFooter&&this.secondFooter.appendChild(t):this.footer&&this.footer.appendChild(t)}failure(e){this.enableButtion();const t=document.createElement("div");t.classList.add("storecrm_modal_error","storecrm_modal_message"),t.style.color=this.config.failure_text_color,t.style.backgroundColor=this.config.failure_background_color,t.innerText=e,this.showSecondPopup?this.secondFooter&&this.secondFooter.appendChild(t):this.footer&&this.footer.appendChild(t)}checkAcceptsMarketingStatusAndClearMessages(){var e;if(this.resetMessage(),!this.config.add_accepts_marketing_checkbox)return void this.submit(!1);const t=null===(e=this.content)||void 0===e?void 0:e.querySelector("#storecrm_restock_email");this.parent.doMailCheck(t.value,this.failure.bind(this)).then((e=>{e.email?e.accepts_marketing?this.submit(!1):this.showAcceptsMarketingCheckbox(!1):this.showAcceptsMarketingCheckbox(!0)}))}showAcceptsMarketingCheckbox(e){var t;const o=document.getElementById("storecrm-modal-content"),n=null===(t=this.content)||void 0===t?void 0:t.querySelector("#storecrm_restock_email"),i=document.getElementById("accepts_marketing_checkbox_container"),r=document.getElementById("email_confirmation_container");if(!o||!i||!r)return;r.innerHTML=this.config.email_confirmation_text+"
"+n.value;const s=Array.from(o.children);s.forEach((e=>{"none"!==e.style.display&&e.classList.add("fade-out")})),setTimeout((()=>{s.forEach((e=>{e.style.display="none"}))}),300),i.classList.add("fade-in"),setTimeout((()=>{i.style.display="block"}),300),r.classList.add("fade-in"),setTimeout((()=>{r.style.display="block"}),300),this.switchSubmitButton(e)}switchSubmitButton(e){var t;this.footer&&(this.footer.innerHTML="");const o=document.createElement("button");o.className="storecrm_modal__btn storecrm_modal__btn-primary",o.style.color=this.config.button_text_color,o.style.backgroundColor=this.config.button_background_color,o.innerHTML=this.config.button_text,this.footer&&this.footer.appendChild(o),this.button=o,null===(t=this.button)||void 0===t||t.addEventListener("click",(()=>{this.submit(e)}))}}t.RestockPopupManager=r,r.template='';let s=null;t.schema={preview:e=>{var t;return t=()=>{r.getInstance(e,!0).show(e,[],"1234567890")},300,clearTimeout(s),s=setTimeout(t,300),r.template},rows:[{type:"text",slug:"popup_title",nameJa:"ポップアップのタイトル",nameEn:"Popup title",default:"再入荷通知"},{type:"text",slug:"popup_description",nameJa:"POPUPの本文",nameEn:"Popup description",default:"再入荷通知をご希望の方は以下から、ご選択ください。"},{type:"text",slug:"emailaddress",nameJa:"メールアドレスフォーム名",nameEn:"Email address form name",default:"ご連絡メールアドレス"},{type:"colorpicker",slug:"background_color",nameJa:"ポップアップの背景色",nameEn:"Popup background color",default:"#ffffff"},{type:"colorpicker",slug:"text_color",nameJa:"ポップアップのテキスト色",nameEn:"Popup text color",default:"#000000"},{type:"colorpicker",slug:"close_text_color",nameJa:"閉じるボタンの色",nameEn:"Popup close button text color",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"ボタンの背景色",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"button_text_color",nameJa:"ボタンのテキストカラー",nameEn:"buttonHoverBackgroundColor",default:"#dddddd"},{type:"text",slug:"button_text",nameJa:"ボタンのテキスト",nameEn:"buttonText",default:"再入荷通知を有効にする"},{type:"text",slug:"success_text",nameJa:"成功時のテキスト",nameEn:"Success text",default:"再入荷通知が登録されました。"},{type:"colorpicker",slug:"success_background_color",nameJa:"成功時の背景色",nameEn:"Success background color",default:"#F0FDF4"},{type:"colorpicker",slug:"success_text_color",nameJa:"成功時の文字色",nameEn:"Success text color",default:"#166534"},{type:"text",slug:"error_text",nameJa:"失敗時のテキスト",nameEn:"Error text",default:"再入荷通知の登録に失敗しました。しばらくたってから再度お試しください。"},{type:"text",slug:"error_text_email",nameJa:"失敗時のテキスト(メールアドレスの判定)",nameEn:"Error text",default:"メールアドレスが正しくありません。確認の上、再度ご記入ください。"},{type:"colorpicker",slug:"failure_background_color",nameJa:"エラー時の背景色",nameEn:"Success background color",default:"#FEF2F2"},{type:"colorpicker",slug:"failure_text_color",nameJa:"エラー時の文字色",nameEn:"Success text color",default:"#991B1B"},{type:"range",slug:"button_radius",nameJa:"ポップアップの丸み",nameEn:"buttonRadius",default:10,min:0,max:40,step:1},{type:"checkbox",slug:"add_accepts_marketing_checkbox",nameJa:"メルマガ配信チェックボックスを有効化",nameEn:"Add accepts marketing checkbox",default:!1},{type:"text",slug:"accepts_marketing_checkbox_text",nameJa:"メルマガ配信チェックボックスのテキスト",nameEn:"Accepts marketing checkbox text",default:"メルマガ配信に同意する"},{type:"text",slug:"email_confirmation_text",nameJa:"メールアドレス確認テキスト",nameEn:"Email confirmation text",default:"こちらのメールアドレスで間違いないですか?"}]}},898:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.schema=t.render=t.RestockButton=void 0;class o{constructor(e,t,o,n,i){this.eventTriggered=!1,this.variants=o,this.buttonSettings=n,this.productId=t,this.product=i}static getInstance(e,t=null,n=null,i=null,r=null){if(!o.instances[e]){if(!(t&&n&&i&&r))throw console.log("StoreCRM Restock: productId, variants, buttonSettings, product are required",e,t,n,i,r),new Error("StoreCRM Restock: productId, variants, buttonSettings, product are required");o.instances[e]=new o(e,t,n,i,r)}return o.instances[e]}createScript(e,t){const o=e?"":"onclick=\"event.preventDefault();window.storecrm ? window.storecrm.showRestock(this) : alert('読込中です。しばらくたってから再度お試しください。');\"";return`\n\n\n
\n\n
\n `}checkRender(e){document.querySelectorAll(`.storecrm-restock-${e}`).forEach((e=>{var t;if(e instanceof HTMLElement&&e.closest('[data-type="restock-button"]')){const o=new URL(location.href),n=(null===(t=this.variants.find((e=>e.available)))||void 0===t?void 0:t.id)||this.variants[0].id||null,i=parseInt(o.searchParams.get("variant")||n,10);if(!i)return void console.error("StoreCRM Restock: variantId is not set",i);if(!this.product||!this.product.tags||this.product.tags.indexOf("storecrm-restock-hidden")>=0)return console.log("StoreCRM: Restock:product not found or hidden"),void(e.style.display="none");const r=window.Shopify&&window.Shopify.designMode||this.variants.find((e=>!e.available&&e.id===i));e.style.display=r?"inline-block":"none"}}))}render(e,t=!1){if(t)return this.createScript(!0,e);if(!this.eventTriggered){if(this.eventTriggered=!0,window.navigation)window.navigation.addEventListener("navigate",(()=>{window.setTimeout((()=>this.checkRender(e)),100)})),window.setTimeout((()=>this.checkRender(e)),100),window.setTimeout((()=>this.checkRender(e)),1e3);else{let t=location.href;window.setInterval((()=>{t!==location.href&&(t=location.href,this.checkRender(e))}),1e3),window.setTimeout((()=>this.checkRender(e)),100),window.setTimeout((()=>this.checkRender(e)),1e3)}return this.createScript(!1,e)}}}t.RestockButton=o,o.instances={},t.render=({productId:e,variantId:t,variants:n,id:i,buttonSettings:r,isOutOfStock:s,product:a,preview:c=!1})=>(console.log("StoreCRM Restock: render",i,e,n,r,a),o.getInstance(i,e,n,r,a).render(i,c)),t.schema={preview:e=>(0,t.render)({productId:"TEMP_productId",id:"TEMP_restock",buttonSettings:e,isOutOfStock:!1,preview:!0,product:{tags:[]},variants:[]}),rows:[{type:"text",slug:"button_text",nameJa:"ボタンのテキスト",nameEn:"buttonText",default:"再入荷通知をする"},{type:"range",slug:"button_width",nameJa:"ボタンの幅",nameEn:"buttonWidth",default:200,min:50,max:600,step:10},{type:"range",slug:"button_height",nameJa:"ボタンの高さ",nameEn:"buttonHeight",default:50,min:30,max:100,step:5},{type:"colorpicker",slug:"button_color",nameJa:"ボタンの文字色",nameEn:"buttonColor",default:"#000000"},{type:"colorpicker",slug:"button_background_color",nameJa:"ボタンの背景色",nameEn:"buttonBackgroundColor",default:"#ffffff"},{type:"colorpicker",slug:"button_border_color",nameJa:"ボタンの線の色",nameEn:"buttonBorderColor",default:"#000000"},{type:"colorpicker",slug:"button_hover_color",nameJa:"ボタンの文字色(ホバー時)",nameEn:"buttonHoverColor",default:"#222222"},{type:"colorpicker",slug:"button_hover_background_color",nameJa:"ボタンの背景色(ホバー時)",nameEn:"buttonHoverBackgroundColor",default:"#dddddd"},{type:"colorpicker",slug:"button_hover_border_color",nameJa:"ボタンの線の色(ホバー時)",nameEn:"buttonHoverBorderColor",default:"#222222"},{type:"range",slug:"button_radius",nameJa:"ボタンの丸み",nameEn:"buttonRadius",default:0,min:0,max:20,step:1},{type:"range",slug:"button_border_width",nameJa:"ボタンの線の太さ",nameEn:"buttonBorderWidth",default:0,min:0,max:5,step:1},{type:"fontpicker",slug:"button_font",nameJa:"ボタンのフォント",nameEn:"buttonFont",default:"helvetica_n4"},{type:"range",slug:"button_fontsize",nameJa:"ボタンのフォントサイズ",nameEn:"buttonFontSize",default:16,min:10,max:30,step:1},{type:"range",slug:"button_fontweight",nameJa:"ボタンのフォントウェイト",nameEn:"buttonFontWeight",default:400,min:100,max:900,step:100},{type:"range",slug:"button_speed",nameJa:"ボタンのアニメーション速度",nameEn:"buttonSpeed",default:.3,min:0,max:1,step:.1},{type:"select",slug:"align",nameJa:"ボタンの配置",nameEn:"align",default:"center",selectOptions:[{value:"left",label:"左寄せ"},{value:"center",label:"中央寄せ"},{value:"right",label:"右寄せ"}]}]}},247:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StatusWidget=void 0,t.StatusWidget=class{constructor(e,t,o){this.position="beforeend",this.header=e,this.config=o,this.position=t}setParent(e){this.parent=e}render(){this.parent&&this.parent.getStatus((e=>{this.renderedWidget&&(this.renderedWidget.remove(),this.renderedWidget=void 0),this.renderedWidget=this.createWidget(e),console.log("StoreCRM: StatusWidget rendered:",this.renderedWidget),this.header.insertAdjacentElement(this.position,this.renderedWidget)}),(e=>{console.error("StoreCRM: StatusWidget render failed",e)})),this.parent||console.error("StoreCRM render: no parent. Abort.")}isLineVisible(e){return e.line_show_account&&(!e.line_debug_account||document.querySelector("#OnlineStorePreviewBarNextData")||window.Shopify.designMode)}createWidget(e){var t,o,n,i;const r=document.createElement("div");function s(e){const t=document.createElement("span");return t.classList.add("storecrm-off"),t.appendChild(document.createTextNode(e)),t}function a(e){const t=document.createElement("span");return t.classList.add("storecrm-on"),t.appendChild(document.createTextNode(e)),t}function c(e){const t=document.createElement("button");return t.classList.add("storecrm-button","storecrm-button-off"),t.appendChild(document.createTextNode(e)),t}function l(e){const t=document.createElement("button");return t.classList.add("storecrm-button","storecrm-button-on"),t.appendChild(document.createTextNode(e)),t}if(r.classList.add("storecrm-status-widget"),this.isLineVisible(e)){const n=document.createElement("div");n.appendChild(document.createTextNode("LINE設定: ")),n.appendChild(e.line?a("設定済"):s("未登録")),this.lineButton=e.line?c("解除する"):l("登録する"),n.appendChild(this.lineButton),r.appendChild(n),e.line?null===(t=this.lineButton)||void 0===t||t.addEventListener("click",this.lineUnsubscribe.bind(this)):null===(o=this.lineButton)||void 0===o||o.addEventListener("click",this.lineSubscribe.bind(this))}if(e.mail_show_account){const t=document.createElement("div");t.appendChild(document.createTextNode("メールマガジン: ")),t.appendChild(e.accepts_marketing?a("購読中"):s("未購読")),this.mailButton=e.accepts_marketing?c("購読解除する"):l("購読する"),t.appendChild(this.mailButton),r.appendChild(t),e.accepts_marketing?null===(n=this.mailButton)||void 0===n||n.addEventListener("click",this.unsubscribe.bind(this)):null===(i=this.mailButton)||void 0===i||i.addEventListener("click",this.subscribe.bind(this))}return r}lineSubscribe(){console.log("StoreCRM: LINE購読処理をします"),this.parent&&this.parent.lineSubscribe((function(e){alert(e)}))}lineUnsubscribe(){console.log("StoreCRM: LINE購読解除処理をします"),this.parent&&this.parent.lineUnsubscribe((function(e){alert(e)}))}subscribe(){console.log("StoreCRM: メール購読処理をします"),this.parent&&this.parent.mailSubscribe((function(e){alert(e)}))}unsubscribe(){console.log("StoreCRM: メール購読解除処理をします"),this.parent&&this.parent.mailUnsubscribe((function(e){alert(e)}))}}},398:function(e,t,o){var n=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(i,r){function s(e){try{c(n.next(e))}catch(e){r(e)}}function a(e){try{c(n.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(s,a)}c((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const i=o(989),r=o(898),s=o(435),a=o(247),c=o(158);o(511),t.default=class{constructor(e){this.statusWidget=void 0,this.isTokenRefreshed=!1,this.isTokenFetching=!1,this.favoriteMode="product",this.favoriteKey="products",window.storecrm_data=window.storecrm_data||{},console.log("StoreCRM initialized version 0.7.3",e),this.config=e,this.fillDefault(),this.popupManager=s.RestockPopupManager.getInstance(e.restockPopup),this.popupManager.setParent(this)}init(){(()=>{n(this,void 0,void 0,(function*(){try{yield this.checkCustomer(),window.localStorage.getItem("storecrm_wishlist")||(yield this.syncWishlist())}catch(e){console.error("StoreCRM: init: error",e)}yield this.render(),window.location.pathname.startsWith("/apps/")&&(yield this.renderFavoriteList())}))})(),window.addEventListener("pageshow",(e=>{e.persisted&&this.render(!0)})),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&this.render(!0)}))}getCurrentShopifyCustomerId(){try{return window.storecrm_data.customer_id||window.ShopifyAnalytics.meta.page.customerId}catch(e){return null}}checkCustomer(){return n(this,void 0,void 0,(function*(){if(window.storecrm_data.is_customer_checked)return;window.storecrm_data.is_customer_checked=!0;const e=(window.localStorage.getItem("storecrm_customer_id")||"").toString(),t=(this.getCurrentShopifyCustomerId()||"").toString();if(e!==t){if(t)return!e||e.startsWith("TEMP_")&&t?(console.log("StoreCRM: checkCustomer: storageCustomerId is not found",e,t),yield this.refreshToken(!1),void(yield this.syncWishlist(null,e,!0))):e!==t?(console.log("StoreCRM: checkCustomer: storageCustomerId is not same",e,t),void(yield this.refreshToken(!0))):void 0;(null==e?void 0:e.startsWith("TEMP_"))||(console.log("StoreCRM: checkCustomer: customerId is not found",e,t),yield this.refreshToken(!0))}else console.log("StoreCRM: checkCustomer: customerId is same",e,t)}))}refreshToken(){return n(this,arguments,void 0,(function*(e=!1){return e&&(window.localStorage.removeItem("storecrm_customer_id"),window.localStorage.removeItem("storecrm_wishlist")),yield this.fetchToken()}))}fillDefault(){this.config.favorite=this.config.favorite||{},i.schema.rows.forEach((e=>{this.config.favorite[e.slug]=this.config.favorite[e.slug]||e.default})),this.favoriteMode=this.config.favorite.favoriteMode||"product",this.favoriteKey="product"===this.favoriteMode?"products":"variants",console.log("StoreCRM: Current favorite mode: ",this.favoriteMode),this.config.restock=this.config.restock||{},r.schema.rows.forEach((e=>{this.config.restock[e.slug]=this.config.restock[e.slug]||e.default})),this.config.restockPopup=this.config.restockPopup||{},s.schema.rows.forEach((e=>{this.config.restockPopup[e.slug]=this.config.restockPopup[e.slug]||e.default}))}render(e=!1){this.doRender(e),e||(window.setTimeout(this.doRender.bind(this),500),window.setTimeout(this.doRender.bind(this),2e3),window.setTimeout(this.doRender.bind(this),5e3))}doRender(e=!1){window.location.pathname.startsWith("/apps")&&window.location.pathname.endsWith("/connect")&&(this.checkConnect(),this.renderStatusWidget());const t=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");t[this.favoriteKey]||(t[this.favoriteKey]=[]),console.log("StoreCRM: Wishlist",t),document.querySelectorAll(".storecrm-button").forEach((e=>{if(e instanceof HTMLElement==0)return;const o=e.id||"storecrm-button-"+Math.random().toString(36).slice(-8);e.id||(e.id=o);const n=new URL(location.href),s=n.searchParams.get("variant")&&n.searchParams.get("variant"),a=e.dataset.productId,c=s||e.dataset.variantId,l=void 0!==e.dataset.variantSelector,d=JSON.parse(e.dataset.variants||"[]"),u={tags:JSON.parse(e.dataset.productTags||"[]"),id:e.dataset.productId};if(!u||!a||!c)return void console.error("StoreCRM: product or productId or variantId is not set",a,c);const h=t&&("product"==this.favoriteMode?t.products&&t.products.includes(a):t.variants&&t.variants.includes(c)),m=!!e.dataset.currentVariantAvailable,g="wishlist-button"===e.dataset.type?(0,i.render)({productId:a,variantId:c,id:o,button:e,variants:d,product:u,buttonSettings:this.config.favorite,isFavorited:h,hasVariantSelector:l}):(0,r.render)({productId:a,variantId:c,id:o,buttonSettings:this.config.restock,isOutOfStock:m,product:u,variants:d});g&&(e.innerHTML=g)})),document.querySelectorAll(".storecrm-favorite").forEach((o=>{if(o instanceof HTMLElement==0)return;if(!e&&"true"===o.dataset.isRendered)return;o.dataset.isRendered="true";const n=o.dataset.productId||"",r=o.dataset.variantId||"";if(!n)return;const s=void 0!==o.dataset.variantSelector,a=o.id||"storecrm-favorite-"+Math.random().toString(36).slice(-8);o.id||(o.id=a);const c=JSON.parse(o.dataset.variants||"[]"),l={tags:JSON.parse(o.dataset.productTags||"[]"),id:o.dataset.productId},d=t&&t.products&&t.products.includes(n);o.innerHTML=(0,i.render)({productId:n,variantId:r,button:o,id:a,buttonSettings:this.config.favorite,isFavorited:d,hasVariantSelector:s,variants:c,product:l})||""})),"/account"!==window.location.pathname&&"/account/"!==window.location.pathname||this.renderStatusWidget(),this.checkToken()}checkToken(){this.isTokenRefreshed||this.isTokenRefreshNeeded()&&this.fetchToken()}isTokenRefreshNeeded(){const e=window.localStorage.getItem("storecrm_customer_id"),t=parseInt(window.localStorage.getItem("storecrm_customer_id")||"0",10),o=window.localStorage.getItem("storecrm_token");let n=null;try{n=o?o.split("|")[1]:null}catch(e){}return this.isTokenRefreshed?(console.log("StoreCRM: Token refresh needed: false (already refreshed)"),!1):e&&o&&n?window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page&&window.ShopifyAnalytics.meta.page.customerId&&window.ShopifyAnalytics.meta.page.customerId!==t?(console.log("StoreCRM: Token refresh needed: true (customerId mismatch)"),!0):window.ShopifyAnalytics&&window.ShopifyAnalytics.meta&&window.ShopifyAnalytics.meta.page&&window.ShopifyAnalytics.meta.page.customerId?1e3*parseFloat(n)<(new Date).getTime()&&(console.log("StoreCRM: Token refresh needed: true (expired)"),!0):(console.log("StoreCRM: Token refresh needed: true (no customerId)"),!0):(console.log("StoreCRM: Token refresh needed: true (no token)"),!0)}fetchToken(){return n(this,void 0,void 0,(function*(){if(this.isTokenFetching)return yield new Promise((e=>{const t=setInterval((()=>{this.isTokenFetching||(clearInterval(t),e(null))}),100)})),window.localStorage.getItem("storecrm_token");this.isTokenFetching=!0;const e=window.localStorage.getItem("storecrm_customer_id"),t=yield fetch(`/apps/${this.config.appProxyName}/token?current_customer_id=${e}`),o=(yield t.text()).match(/\[data\]([\s\S]*?)\[\/data\]/);if(!o)throw this.isTokenRefreshed=!0,new Error("No data from API");const n=JSON.parse(o[1]);if(!n||!n.customer)throw this.isTokenRefreshed=!0,new Error("No data from API2");return window.localStorage.setItem("storecrm_token",n.customer.token),window.localStorage.setItem("storecrm_customer_id",n.customer.id),this.isTokenRefreshed=!0,console.log("StoreCRM: fetchToken: customerId",e,n.customer.id),(null==e?void 0:e.startsWith("TEMP_"))&&n.customer.id!==e&&(yield this.syncWishlist(null,e)),this.isTokenFetching=!1,n.customer.token}))}getToken(){return n(this,void 0,void 0,(function*(){return this.isTokenFetching&&(yield this.fetchToken()),window.localStorage.getItem("storecrm_token")}))}getCustomerId(){return n(this,void 0,void 0,(function*(){return this.isTokenFetching&&(yield this.fetchToken()),window.localStorage.getItem("storecrm_customer_id")}))}request(){return n(this,arguments,void 0,(function*(e="GET",t,o=null,n=!1){const i=yield this.getCustomerId(),r=yield this.getToken(),s=window.location.href;t.includes("?")?t+=`&customer_id=${i}&host=${window.location.host}&referrer=${encodeURIComponent(s)}`:t+=`?customer_id=${i}&host=${window.location.host}&referrer=${encodeURIComponent(s)}`;const a=yield fetch(t,{method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:o?JSON.stringify(o):null,credentials:n?"include":"same-origin"});if(!a.ok)throw new Error("API request failed");return a.json()}))}toggleWishlist(e,t=!1,o=!1,n=""){o?this.fetchToken().then((()=>{var o=window.localStorage.getItem("storecrm_customer_id");o&&!/^TEMP_/.test(o)?this.doToggleWishlist(e,!t).then((()=>{console.log(t?"StoreCRM: Wishlist removed!":"StoreCRM: Wishlist added!")})).catch((e=>{console.error(e),alert("サーバエラーが発生しました! error: "+e.message+" しばらくたってから再度お試しください。")})):window.location.href=""===n?"/account/login":n})):this.doToggleWishlist(e,!t).then((()=>{console.log(t?"StoreCRM: Wishlist removed!":"StoreCRM: Wishlist added!")})).catch((e=>{console.error(e),alert("サーバエラーが発生しました! error: "+e.message+" しばらくたってから再度お試しください。")}))}syncWishlist(){return n(this,arguments,void 0,(function*(e=null,t=void 0,o=!1){if(!o){const e=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");if(e.lastUpdated&&Date.now()-e.lastUpdated<12e5)return e}let n=null;try{n=e||(yield this.getWishlist(t))}catch(e){return void console.error("StoreCRM: syncWishlist: error",e)}if(n&&this.favoriteKey in n)return window.localStorage.getItem("storecrm_wishlist"),"product"===this.favoriteMode?(window.localStorage.setItem("storecrm_wishlist",JSON.stringify({products:n.products,lastUpdated:Date.now()})),this.renderFavoriteList(),{products:n.products}):(window.localStorage.setItem("storecrm_wishlist",JSON.stringify({products:n.products,variants:n.variants,lastUpdated:Date.now()})),this.renderFavoriteList(),{products:n.products,variants:n.variants});console.error("StoreCRM: Invalid response from favorite fetch API",n)}))}renderFavoriteList(){return n(this,void 0,void 0,(function*(){const e=document.querySelector(".storecrm_favoritelist");if(!e||e instanceof HTMLElement==0)return;console.log("StoreCRM: Render Favroite List");const t=c.Renderer.getInstance(this);yield t.init(),yield t.render()}))}getWishlist(){return n(this,arguments,void 0,(function*(e=void 0){return e?this.request("GET",`${this.config.backendUrl}/frontend/favorite/?old_customer_id=${e}&mode=${this.favoriteMode}`):this.request("GET",`${this.config.backendUrl}/frontend/favorite/?mode=${this.favoriteMode}`)}))}doToggleWishlist(e){return n(this,arguments,void 0,(function*(e,t=!1){const o=e.dataset.productId;let n=e.dataset.variantId;const r=void 0!==e.dataset.variantSelector;if(!o)return void console.error("Product ID not found");const s=e.closest(".storecrm-favorite"),a=s&&JSON.parse(s.dataset.variants||"null");if("variant"==this.favoriteMode&&a&&1===a.length&&(n=a[0].id,(0,i.hideWidgetSelector)()),"variant"==this.favoriteMode&&!n){if(r){const t=JSON.parse(window.localStorage.getItem("storecrm_wishlist")||"{}");return void(0,i.renderWidgetSelector)({button:e,productId:o,variants:a,wishlist:t,buttonSettings:this.config.favorite})}return void console.error("Variant ID not found: you need to set data-variant-id (Specify variant id) or data-variant-selector(Show variant selector) attribute.")}let c={};c=t?yield this.request("POST",`${this.config.backendUrl}/frontend/favorite/`,{product_id:o,variant_id:n,mode:this.favoriteMode}):yield this.request("DELETE",`${this.config.backendUrl}/frontend/favorite/?product_id=${o}&variant_id=${n}&mode=${this.favoriteMode}`),console.log("StoreCRM response wishlist: ",c),c&&window.localStorage.setItem("storecrm_wishlist",JSON.stringify(Object.assign(Object.assign({},c),{lastUpdated:Date.now()}))),"variant"==this.favoriteMode&&r&&(0,i.renderWidgetSelector)({button:e,productId:o,variants:a,wishlist:c,buttonSettings:this.config.favorite,rerender:!0}),this.render(!0),this.renderFavoriteList()}))}showRestock(e){const t=e.dataset.id||e.id,o=r.RestockButton.getInstance(t);o?this.popupManager.show(this.config.restockPopup,o.variants,o.productId):console.error("StoreCRM Restock: restockButton not found")}storeRestock(e,t,o,n,i,r,s=void 0,a=void 0){if(!this.checkEmailFormat(e))return a&&a("メールアドレスが正しくありません。");this.doStoreRestock(t,o,e,i,n,r).then((()=>{console.log("StoreCRM: Restock saved successfully"),s&&s(this.config.restockPopup.success_text)})).catch((e=>{console.error("StoreCRM: API call failed:",e),a&&a(this.config.restockPopup.error_text)}))}doStoreRestock(e,t,o,i,r,s){return n(this,void 0,void 0,(function*(){if(i)try{yield this.doUpsertCustomerAcceptsMarketing(o,r,s),console.log("StoreCRM: Accepts marketing status saved successfully")}catch(e){console.error("API call failed:",e)}return yield this.request("POST",`${this.config.backendUrl}/frontend/restock/`,{product_id:t,variant_id:e,email:o})}))}doUpsertCustomerAcceptsMarketing(e,t,o){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/accepts-marketing/`,{email:e,accepts_marketing:t,new_customer:o})}))}renderStatusWidget(){if(this.statusWidget)return void console.log("StoreCRM: warning: statusWidget already exists");const e=document.querySelector(".storecrm-status-widget-target"),t=document.querySelector("#shopify-section-header,.section-header,.section--header,header,.header-wrapper,.header,.header_nav"),o=document.querySelector("#MainContent, #main, .main, main");if(console.log("StoreCRM: renderStatusWidget",t,o),t||o||e){if(e)this.statusWidget=new a.StatusWidget(e,"beforeend",this.config);else if(o)this.statusWidget=new a.StatusWidget(o,"afterbegin",this.config);else{if(!t)return;this.statusWidget=new a.StatusWidget(t,"beforeend",this.config)}this.statusWidget.setParent(this),this.statusWidget.render()}else console.error("Shopify header not found. Please assign following class/id/element to header: #shopify-section-header,.section-header,.section--header,header,.header_nav")}getStatus(e,t){this.doGetStatus().then((t=>{e(t)})).catch((e=>{console.error(e),t("サーバエラーが発生しました。")}))}doGetStatus(){return n(this,void 0,void 0,(function*(){return yield this.request("GET",`${this.config.backendUrl}/frontend/status`)}))}lineSubscribe(e=void 0){this.doLineSubscribe()}doLineSubscribe(){return n(this,void 0,void 0,(function*(){const e=yield this.getCustomerId(),t=yield this.getToken(),o=window.location.href;location.href=`${this.config.backendUrl}/frontend/line/connect?token=${t}&customer_id=${e}&host=${window.location.host}&referrer=${encodeURIComponent(o)}`}))}lineUnsubscribe(e=void 0){this.doLineUnsubscribe().then((e=>{location.href=location.pathname+"?line_disconnect=1"})).catch((t=>{console.error(t),e?e("LINEの通知解除に失敗しました。"):alert("LINEの通知解除に失敗しました。")}))}doLineUnsubscribe(){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/line/disconnect`)}))}mailSubscribe(){this.doMailSubscribe().then((e=>{console.log("StoreCRM: メールマガジンの購読に成功しました。",e),this.statusWidget&&this.statusWidget.render()})).catch((e=>{console.error(e),alert("メールマガジンの購読に失敗しました。")}))}doMailSubscribe(){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/email/subscribe`)}))}mailUnsubscribe(){this.doMailUnsubscribe().then((e=>{console.log("StoreCRM: メールマガジンの解除に成功しました。",e);const t=document.getElementById("storecrm_message");t&&(t.innerHTML="メールマガジンの解除に成功しました。"),this.statusWidget&&this.statusWidget.render()})).catch((e=>{console.error(e);const t=document.getElementById("storecrm_message");t&&(t.innerHTML="メールマガジンの解除に失敗しました。","API"in e.toString()&&(t.innerHTML+='
解除を進めるにはログインをしてください。')),alert("メールマガジンの解除に失敗しました。")}))}doMailUnsubscribe(){return n(this,void 0,void 0,(function*(){return yield this.request("POST",`${this.config.backendUrl}/frontend/email/unsubscribe`)}))}doMailCheck(e){return n(this,arguments,void 0,(function*(e,t=void 0){return this.checkEmailFormat(e)?yield this.request("GET",`${this.config.backendUrl}/frontend/accepts-marketing/?email=${encodeURIComponent(e)}`):t&&t("メールアドレスが正しくありません。")}))}birthdaySet(){}checkEmailFormat(e){return!(!e||!e.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|.(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/))}checkConnect(){const e=new URLSearchParams(window.location.search),t=e.get("storecrm"),o=window.localStorage.getItem("storecrm_customer_id");if(o&&!o.startsWith("TEMP_")){if("line_connect"===t?this.lineSubscribe((function(){console.log("StoreCRM: LINEの通知登録に失敗しました。")})):"line_disconnect"===t?this.lineUnsubscribe():"email_subscribe"===t?this.mailSubscribe():"email_unsubscribe"===t?this.mailUnsubscribe():"birthday_set"===t&&this.birthdaySet(),e.get("line_disconnect")){const e=document.querySelector("#storecrm_message");e&&(e.innerHTML="LINEの通知を解除しました。")}if(e.get("line_connect")){const e=document.querySelector("#storecrm_message");e&&(e.innerHTML="LINEを連携しました。")}}else{const e=document.getElementById("storecrm_message");e&&(e.innerHTML='設定変更に失敗しました。
進めるにはログインをしてください。')}}}},927:function(e,t,o){var n,i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const r=i(o(398)),s=i(o(779));window.storecrm=new r.default(window.storecrm_config||{}),window.storecrm.init(),window.LineLogin=s.default;const a=s.default.detectStoreConfig();if(a&&(window.line_config=window.line_config||{store_id:a.storeId,base_url:a.baseUrl}),"loading"===document.readyState)document.addEventListener("DOMContentLoaded",(()=>{var e;if(s.default.isLoginOrRegisterPage()&&(null===(e=window.line_config)||void 0===e?void 0:e.store_id)){const e=window.line_config.base_url||"https://serverless.storecrm.io/line",t=window.line_config.store_id;new s.default(e,t).init()}}));else if(s.default.isLoginOrRegisterPage()&&(null===(n=window.line_config)||void 0===n?void 0:n.store_id)){const e=window.line_config.base_url||"https://serverless.storecrm.io/line",t=window.line_config.store_id;new s.default(e,t).init()}}},t={};function o(n){var i=t[n];if(void 0!==i)return i.exports;var r=t[n]={id:n,exports:{}};return e[n].call(r.exports,r,r.exports,o),r.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nc=void 0,o(927)})();