@coxwave/tap-sdk 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -36
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.global.js +3 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,10 +45,11 @@ await sdk.initChat({
|
|
|
45
45
|
### Constructor
|
|
46
46
|
|
|
47
47
|
```javascript
|
|
48
|
-
new TapSDK(options)
|
|
48
|
+
new TapSDK(options);
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
**Options:**
|
|
52
|
+
|
|
52
53
|
- `pluginKey` (string) - Your unique plugin identifier
|
|
53
54
|
- `isProd` (boolean) - Production mode flag (default: false)
|
|
54
55
|
- `isLocal` (boolean) - Local development flag (default: false)
|
|
@@ -88,8 +89,8 @@ await sdk.initChat({
|
|
|
88
89
|
|
|
89
90
|
```javascript
|
|
90
91
|
sdk.seekTimeline({
|
|
91
|
-
clipId:
|
|
92
|
-
clipPlayHead: 150.5
|
|
92
|
+
clipId: "clip-123",
|
|
93
|
+
clipPlayHead: 150.5,
|
|
93
94
|
});
|
|
94
95
|
```
|
|
95
96
|
|
|
@@ -108,12 +109,12 @@ sdk.events.onTimelineSeek((clipPlayHead, clipId) => {
|
|
|
108
109
|
});
|
|
109
110
|
|
|
110
111
|
// Chat state events
|
|
111
|
-
sdk.events.onChatOpened(() => console.log(
|
|
112
|
-
sdk.events.onChatClosed(() => console.log(
|
|
112
|
+
sdk.events.onChatOpened(() => console.log("Chat opened"));
|
|
113
|
+
sdk.events.onChatClosed(() => console.log("Chat closed"));
|
|
113
114
|
|
|
114
115
|
// Notification events
|
|
115
116
|
sdk.events.onAlarmFadeIn((messageInfo) => {
|
|
116
|
-
console.log(
|
|
117
|
+
console.log("Alarm notification:", messageInfo);
|
|
117
118
|
});
|
|
118
119
|
```
|
|
119
120
|
|
|
@@ -122,8 +123,8 @@ sdk.events.onAlarmFadeIn((messageInfo) => {
|
|
|
122
123
|
### React
|
|
123
124
|
|
|
124
125
|
```jsx
|
|
125
|
-
import { useEffect, useRef } from
|
|
126
|
-
import TapSDK from
|
|
126
|
+
import { useEffect, useRef } from "react";
|
|
127
|
+
import TapSDK from "@coxwave/tap-sdk";
|
|
127
128
|
|
|
128
129
|
function ChatWidget({ userId, courseId }) {
|
|
129
130
|
const sdkRef = useRef(null);
|
|
@@ -132,11 +133,11 @@ function ChatWidget({ userId, courseId }) {
|
|
|
132
133
|
const initSDK = async () => {
|
|
133
134
|
sdkRef.current = new TapSDK({
|
|
134
135
|
pluginKey: process.env.REACT_APP_TAP_PLUGIN_KEY,
|
|
135
|
-
isProd: process.env.NODE_ENV ===
|
|
136
|
+
isProd: process.env.NODE_ENV === "production",
|
|
136
137
|
});
|
|
137
138
|
|
|
138
139
|
await sdkRef.current.initChat({
|
|
139
|
-
chatApiParams: { userId, courseId
|
|
140
|
+
chatApiParams: { userId, courseId /* ... */ },
|
|
140
141
|
});
|
|
141
142
|
};
|
|
142
143
|
|
|
@@ -148,31 +149,6 @@ function ChatWidget({ userId, courseId }) {
|
|
|
148
149
|
}
|
|
149
150
|
```
|
|
150
151
|
|
|
151
|
-
### Next.js
|
|
152
|
-
|
|
153
|
-
```jsx
|
|
154
|
-
"use client";
|
|
155
|
-
import { useEffect } from 'react';
|
|
156
|
-
import TapSDK from '@coxwave/tap-sdk';
|
|
157
|
-
|
|
158
|
-
export default function ChatPage() {
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
const sdk = new TapSDK({
|
|
161
|
-
pluginKey: process.env.NEXT_PUBLIC_TAP_PLUGIN_KEY,
|
|
162
|
-
isProd: process.env.NODE_ENV === 'production'
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
sdk.initChat({
|
|
166
|
-
chatApiParams: { /* ... */ }
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
return () => sdk.removeChat();
|
|
170
|
-
}, []);
|
|
171
|
-
|
|
172
|
-
return <div>Chat Widget will appear here</div>;
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
152
|
## Build Formats
|
|
177
153
|
|
|
178
154
|
- **ESM**: `dist/index.mjs` - Modern ES modules
|
|
@@ -191,4 +167,4 @@ export default function ChatPage() {
|
|
|
191
167
|
|
|
192
168
|
MIT
|
|
193
169
|
|
|
194
|
-
Copyright (c) 2025-present, Coxwave
|
|
170
|
+
Copyright (c) 2025-present, Coxwave
|
package/dist/index.d.cts
CHANGED
|
@@ -40,7 +40,7 @@ declare class TapIframeBridge extends Messenger<ToTapMessage, FromTapMessage> {
|
|
|
40
40
|
hostClientUrl: string;
|
|
41
41
|
pluginKey: string;
|
|
42
42
|
});
|
|
43
|
-
protected isValidOrigin(
|
|
43
|
+
protected isValidOrigin(_event: MessageEvent): boolean;
|
|
44
44
|
protected getMessageTarget(): Window | null;
|
|
45
45
|
protected getTargetOrigin(): string;
|
|
46
46
|
renderIframe({ chatBody, isProd, isLocal, }: {
|
|
@@ -50,7 +50,7 @@ declare class TapIframeBridge extends Messenger<ToTapMessage, FromTapMessage> {
|
|
|
50
50
|
}): Promise<HTMLIFrameElement>;
|
|
51
51
|
hasIframe(): boolean;
|
|
52
52
|
removeIframe(): void;
|
|
53
|
-
get postToTap(): (message: ToTapMessage) => boolean;
|
|
53
|
+
get postToTap(): (() => void) | ((message: ToTapMessage) => boolean);
|
|
54
54
|
listenToTap: <T extends "timeline:seek" | "chat:opened" | "chat:initiated" | "chat:closed" | "alarm:fadeIn" | "popUp:open" | "pdf:open" | "pdf:close">(messageType: T, callback: (data: Extract<TimelineSeekMessage, {
|
|
55
55
|
type: T;
|
|
56
56
|
}> | Extract<ChatInitiatedMessage, {
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ declare class TapIframeBridge extends Messenger<ToTapMessage, FromTapMessage> {
|
|
|
40
40
|
hostClientUrl: string;
|
|
41
41
|
pluginKey: string;
|
|
42
42
|
});
|
|
43
|
-
protected isValidOrigin(
|
|
43
|
+
protected isValidOrigin(_event: MessageEvent): boolean;
|
|
44
44
|
protected getMessageTarget(): Window | null;
|
|
45
45
|
protected getTargetOrigin(): string;
|
|
46
46
|
renderIframe({ chatBody, isProd, isLocal, }: {
|
|
@@ -50,7 +50,7 @@ declare class TapIframeBridge extends Messenger<ToTapMessage, FromTapMessage> {
|
|
|
50
50
|
}): Promise<HTMLIFrameElement>;
|
|
51
51
|
hasIframe(): boolean;
|
|
52
52
|
removeIframe(): void;
|
|
53
|
-
get postToTap(): (message: ToTapMessage) => boolean;
|
|
53
|
+
get postToTap(): (() => void) | ((message: ToTapMessage) => boolean);
|
|
54
54
|
listenToTap: <T extends "timeline:seek" | "chat:opened" | "chat:initiated" | "chat:closed" | "alarm:fadeIn" | "popUp:open" | "pdf:open" | "pdf:close">(messageType: T, callback: (data: Extract<TimelineSeekMessage, {
|
|
55
55
|
type: T;
|
|
56
56
|
}> | Extract<ChatInitiatedMessage, {
|
package/dist/index.global.js
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
}
|
|
12
12
|
})();
|
|
13
13
|
|
|
14
|
-
var MySDK=(function(){'use strict';var je=Object.defineProperty;var J=i=>{throw TypeError(i)};var
|
|
14
|
+
var MySDK=(function(){'use strict';var je=Object.defineProperty;var J=i=>{throw TypeError(i)};var Be=(i,t,e)=>t in i?je(i,t,{enumerable:true,configurable:true,writable:true,value:e}):i[t]=e;var u=(i,t,e)=>Be(i,typeof t!="symbol"?t+"":t,e),Z=(i,t,e)=>t.has(i)||J("Cannot "+e);var Y=(i,t,e)=>(Z(i,t,"read from private field"),e?e.call(i):t.get(i)),g=(i,t,e)=>t.has(i)?J("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e);var d=(i,t,e)=>(Z(i,t,"access private method"),e);var Q="_1mlv4me2",w="_1mlv4me4";var D="_1mlv4me3";var O=class{constructor(){u(this,"chatBody",null);this.chatBody=null;}createChatBody({customChatBody:t}){return this.chatBody?this.chatBody:(this.chatBody=document.createElement("div"),this.chatBody.id="cw-chat-body",this.chatBody.className=Q,this.chatBody.style.setProperty("z-index","10000001","important"),this.chatBody.style.setProperty("position","fixed","important"),Object.assign(this.chatBody.style,{top:t?.position?.top??"50px",right:t?.position?.right??"24px",left:t?.position?.left??"unset",bottom:t?.position?.bottom??"unset",width:t?.width??"340px",height:t?.height??"calc(100% - 116px)",overflow:"hidden",backgroundColor:"transparent",borderRadius:t?.borderRadius??"16px",boxShadow:`
|
|
15
15
|
rgba(255, 255, 255, 0.12) 0px 0px 2px 0px inset,
|
|
16
16
|
rgba(0, 0, 0, 0.05) 0px 0px 2px 1px,
|
|
17
17
|
rgba(0, 0, 0, 0.3) 0px 12px 60px
|
|
18
|
-
`,willChange:"transform, opacity, width, max-height, max-width"}),document.body.appendChild(this.chatBody),this.chatBody)}toggleVisibility(t){if(!this.chatBody)return;this.chatBody.classList.remove(O,w),this.chatBody.style.display="block";let e=()=>{this.chatBody&&(this.chatBody.classList.contains(w)&&(this.chatBody.style.display="none"),this.chatBody.removeEventListener("animationend",e));};this.chatBody.addEventListener("animationend",e),requestAnimationFrame(()=>{this.chatBody?.classList.add(t?O:w);});}removeChatBody(){this.chatBody&&(this.chatBody.remove(),this.chatBody=null);}resizeChatBody(t,e){if(!this.chatBody)return;let n=e?.width??"340px",r=parseInt(n,10),o=r/3*10-r,s=t?`${r+o}px`:`${r}px`;this.chatBody.style.width=s;}},ee=D;var te="_6j1ub51",P={default:"_6j1ub5b _6j1ub5a","call-to-action":"_6j1ub5c _6j1ub5a"},ne="_6j1ub5a",re="_6j1ub59",L={default:"_6j1ub5e _6j1ub5d","call-to-action":"_6j1ub5f _6j1ub5d"},ie="_6j1ub5d",se="_6j1ub5h",ue="_6j1ub5g",S="_6j1ub53",oe="_6j1ub58",N={default:"_6j1ub56 _6j1ub55","call-to-action":"_6j1ub57 _6j1ub55"},ae="_6j1ub55",q="_6j1ub52",le="_6j1ub54";var h,ce,pe,fe,ye,he,R=class{constructor(){g(this,h);u(this,"container");u(this,"alarmTimeout");u(this,"alarmCornerSVG");u(this,"textContainer");u(this,"circleElement");u(this,"textInTextContainer");u(this,"messageInfo");}render({rootElement:t}){this.container=document.createElement("div"),this.container.id="alarm-container",this.container.className=te,this.container.addEventListener("click",n=>{n.stopPropagation();}),t.appendChild(this.container),d(this,h,ce).call(this,this.container);let e=d(this,h,pe).call(this,this.container);d(this,h,ye).call(this,e),d(this,h,fe).call(this,e);}fadeIn(t){t.type==="default"||t.type==="hourSpent"?(this.textContainer.className=N.default,this.alarmCornerSVG.setAttribute("class",P.default),this.circleElement.className=L.default):(this.textContainer.className=N["call-to-action"],this.alarmCornerSVG.setAttribute("class",P["call-to-action"]),this.circleElement.className=L["call-to-action"]),this.messageInfo=t,this.textInTextContainer.textContent=t.message,this.toggleVisibility(true),this.alarmTimeout=setTimeout(()=>{this.toggleVisibility(false);},18*1e3);}addClickEvent({callback:t}){this.container.addEventListener("click",()=>{this.toggleVisibility(false),t(this.messageInfo);});}toggleVisibility(t){this.container.classList.remove(q,S),requestAnimationFrame(()=>{this.container?.classList.add(t?q:S);});}remove(){this.container&&this.toggleVisibility(false),this.alarmTimeout&&clearTimeout(this.alarmTimeout);}};h=new WeakSet,ce=function(t){let e=document.createElement("div");e.className=re,t.appendChild(e);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","11"),n.setAttribute("height","8"),n.setAttribute("viewBox","0 0 11 8"),n.setAttribute("fill","currentColor"),n.setAttribute("class",ne);let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d","M5.5 0L11.1292 8.25H-0.129165L5.5 0Z"),r.setAttribute("fill","currentColor"),n.appendChild(r),this.alarmCornerSVG=n,e.appendChild(n);},pe=function(t){let e=document.createElement("div");return e.className=le,t.appendChild(e),e},fe=function(t){this.textContainer=document.createElement("div"),this.textContainer.className=ae,t.appendChild(this.textContainer),this.textInTextContainer=document.createElement("span"),this.textInTextContainer.className=oe,this.textContainer.appendChild(this.textInTextContainer);},ye=function(t){let e=document.createElement("div");e.className=ie,t.appendChild(e),e.addEventListener("click",r=>{r.stopPropagation(),this.remove();});let n=document.createElement("span");n.className=se,e.appendChild(n),n.textContent="\uC54C\uB9BC \uB044\uAE30",d(this,h,he).call(this,e),this.circleElement=e;},he=function(t){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","10"),e.setAttribute("height","10"),e.setAttribute("viewBox","0 0 14 14"),e.setAttribute("fill","none"),e.setAttribute("class",ue);let n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M1 1L13 13M13 1L1 13"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),e.appendChild(n),t.appendChild(e);};var me=R;var _,z=class{constructor(){u(this,"customFloatingButton");u(this,"floatingButton");u(this,"alarm");g(this,_,(t,e)=>t.key===e?true:t.code.startsWith("Key")?t.code.slice(3).toLowerCase()===e:false);this.alarm=new me;}render({customFloatingButton:t}){if(this.customFloatingButton=t,this.customFloatingButton?.isInElement&&this.customFloatingButton?.parentElementId){let e=document.getElementById(this.customFloatingButton.parentElementId);e?.style.setProperty("position","relative","important"),e?.style.setProperty("z-index","10000001","important"),this.floatingButton=e;}else {let e=document.getElementById("cw-plugin");e||(e=document.createElement("button"),e.id="cw-plugin",e.style.zIndex="10000001",e.style.setProperty("z-index","10000001","important"),e.style.setProperty("position","fixed","important"),e.style.width="50px",e.style.height="50px",e.style.borderRadius="50%",e.style.backgroundColor="#000",document.body.appendChild(e),this.floatingButton=e);}return this.alarm.render({rootElement:this.floatingButton}),this.floatingButton}addClickEvent({callback:t}){if(!this.floatingButton)throw new Error("not initialized");this.floatingButton.addEventListener("click",()=>{t();});}addAlarmClickEvent({callback:t}){this.alarm.addClickEvent({callback:t});}addShortCutEvent({openChatShortcutKey:t,callback:e}){if(!this.floatingButton)throw new Error("not initialized");window.addEventListener("keydown",n=>{Y(this,_).call(this,n,t.key)&&(!t.modifier||n[t.modifier])&&e();});}alarmFadeIn(t){this.alarm.fadeIn(t);}alarmRemove(){this.alarm.remove();}};_=new WeakMap;var de=z;var F;function H(i){return {lang:i?.lang??F?.lang,message:i?.message,abortEarly:i?.abortEarly??F?.abortEarly,abortPipeEarly:i?.abortPipeEarly??F?.abortPipeEarly}}var De;function Pe(i){return De?.get(i)}var Le;function Se(i){return Le?.get(i)}var Ne;function qe(i,t){return Ne?.get(i)?.get(t)}function ve(i){let t=typeof i;return t==="string"?`"${i}"`:t==="number"||t==="bigint"||t==="boolean"?`${i}`:t==="object"||t==="function"?(i&&Object.getPrototypeOf(i)?.constructor?.name)??"null":t}function k(i,t,e,n,r){let o=r&&"input"in r?r.input:e.value,s=r?.expected??i.expects??null,c=r?.received??ve(o),a={kind:i.kind,type:i.type,input:o,expected:s,received:c,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:i.requirement,path:r?.path,issues:r?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},p=i.kind==="schema",l=r?.message??i.message??qe(i.reference,a.lang)??(p?Se(a.lang):null)??n.message??Pe(a.lang);l!==void 0&&(a.message=typeof l=="function"?l(a):l),p&&(e.typed=false),e.issues?e.issues.push(a):e.issues=[a];}function x(i){return {version:1,vendor:"valibot",validate(t){return i["~run"]({value:t},H())}}}function Re(i,t){return Object.hasOwn(i,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}var ze=class extends Error{constructor(i){super(i[0].message),this.name="ValiError",this.issues=i;}};function Fe(i,t,e){return typeof i.fallback=="function"?i.fallback(t,e):i.fallback}function He(i,t,e){return typeof i.default=="function"?i.default(t,e):i.default}function G(){return {kind:"schema",type:"any",reference:G,expects:"any",async:false,get"~standard"(){return x(this)},"~run"(i){return i.typed=true,i}}}function T(i,t){return {kind:"schema",type:"literal",reference:T,expects:ve(i),async:false,literal:i,message:t,get"~standard"(){return x(this)},"~run"(e,n){return e.value===this.literal?e.typed=true:k(this,"type",e,n),e}}}function I(i,t){return {kind:"schema",type:"object",reference:I,expects:"Object",async:false,entries:i,message:t,get"~standard"(){return x(this)},"~run"(e,n){let r=e.value;if(r&&typeof r=="object"){e.typed=true,e.value={};for(let o in this.entries){let s=this.entries[o];if(o in r||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=o in r?r[o]:He(s),a=s["~run"]({value:c},n);if(a.issues){let p={type:"object",origin:"value",input:r,key:o,value:c};for(let l of a.issues)l.path?l.path.unshift(p):l.path=[p],e.issues?.push(l);if(e.issues||(e.issues=a.issues),n.abortEarly){e.typed=false;break}}a.typed||(e.typed=false),e.value[o]=a.value;}else if(s.fallback!==void 0)e.value[o]=Fe(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"&&(k(this,"key",e,n,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:r,key:o,value:r[o]}]}),n.abortEarly))break}}else k(this,"type",e,n);return e}}}function V(i,t,e){return {kind:"schema",type:"record",reference:V,expects:"Object",async:false,key:i,value:t,message:e,get"~standard"(){return x(this)},"~run"(n,r){let o=n.value;if(o&&typeof o=="object"){n.typed=true,n.value={};for(let s in o)if(Re(o,s)){let c=o[s],a=this.key["~run"]({value:s},r);if(a.issues){let l={type:"object",origin:"key",input:o,key:s,value:c};for(let f of a.issues)f.path=[l],n.issues?.push(f);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=false;break}}let p=this.value["~run"]({value:c},r);if(p.issues){let l={type:"object",origin:"value",input:o,key:s,value:c};for(let f of p.issues)f.path?f.path.unshift(l):f.path=[l],n.issues?.push(f);if(n.issues||(n.issues=p.issues),r.abortEarly){n.typed=false;break}}(!a.typed||!p.typed)&&(n.typed=false),a.typed&&(n.value[a.value]=p.value);}}else k(this,"type",n,r);return n}}}function C(i){return {kind:"schema",type:"string",reference:C,expects:"string",async:false,message:i,get"~standard"(){return x(this)},"~run"(t,e){return typeof t.value=="string"?t.typed=true:k(this,"type",t,e),t}}}function ge(i,t,e){let n=i["~run"]({value:t},H(e));if(n.issues)throw new ze(n.issues);return n.value}function be(i,t,e){let n=i["~run"]({value:t},H(e));return {typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}var ke="chat:init",Ge="chat:initiated";var xe=I({type:T(Ge),gaId:C()}),Ee=I({type:T("GA_EVENT"),payload:V(C(),G())});var A=class{constructor(){u(this,"listeners",new Map);u(this,"unifiedMessageHandler",null);}on(t,e){let n=o=>{if(this.isValidOrigin(o))try{let s=o.data,c=typeof s=="string"?JSON.parse(s):s,{type:a}=c;a===t&&e(c);}catch(s){console.warn("Messenger: Failed to parse message data",s);}},r=this.listeners.get(t)||[];return r.push(n),this.listeners.set(t,r),this.unifiedMessageHandler||(this.unifiedMessageHandler=o=>{this.listeners.forEach(s=>s.forEach(c=>c(o)));},window.addEventListener("message",this.unifiedMessageHandler)),()=>{this.unifiedMessageHandler&&(window.removeEventListener("message",this.unifiedMessageHandler),this.unifiedMessageHandler=null);}}removeListener(t){this.listeners.delete(t);}removeAllListeners(){this.listeners.clear(),this.unifiedMessageHandler&&(window.removeEventListener("message",this.unifiedMessageHandler),this.unifiedMessageHandler=null);}postMessage(t){try{let e=this.getMessageTarget();return e?(e.postMessage(t,this.getTargetOrigin()),!0):(console.warn("Messenger: Message target not available"),!1)}catch(e){return console.error("Messenger: postMessage failed",e),false}}};var v=class extends Error{constructor(e,n,r){super(`Handshake failed: ${e}${n?` - ${n}`:""}`);this.reason=e;this.details=n;this.originalError=r;this.name="HandshakeError";}},M=class{constructor(t,e,n){this.getTargetWindow=t;this.getTargetOrigin=e;this.isValidOrigin=n;u(this,"abortController",null);u(this,"messageListener",null);}async execute(t,e={}){let{timeout:n=1e4,maxRetries:r=10,retryInterval:o=500}=e;return this.cancel(),this.abortController=new AbortController,new Promise((s,c)=>{let a=0,p,l=()=>{p&&clearTimeout(p),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null);},f=()=>{l(),c(new v("TIMEOUT","Handshake was cancelled"));};this.abortController?.signal.addEventListener("abort",f),this.messageListener=y=>{if(this.isValidOrigin(y))try{let b=y.data,Me=typeof b=="string"?JSON.parse(b):b;try{let K=be(xe,Me);l(),this.abortController=null,s(K.output);return}catch{}}catch(b){console.warn("Failed to parse handshake message:",b);}},window.addEventListener("message",this.messageListener),p=setTimeout(()=>{l(),this.abortController=null,c(new v("TIMEOUT",`No valid response received within ${n}ms`));},n);let m=()=>{if(!this.abortController?.signal.aborted)try{let y=this.getTargetWindow();if(!y)throw new v("NO_TARGET_WINDOW","Target iframe window is not available");y.postMessage(t,this.getTargetOrigin()),a++,a<r&&setTimeout(()=>{this.abortController?.signal.aborted||m();},o);}catch(y){l(),this.abortController=null,y instanceof v?c(y):c(new v("MESSAGE_SEND_FAILED","Failed to send handshake message",y));}};m();})}cancel(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null);}isActive(){return this.abortController!==null&&!this.abortController.signal.aborted}};var j=class extends A{constructor({hostClientUrl:e,pluginKey:n}){super();u(this,"hostClientUrl");u(this,"pluginKey");u(this,"iframe");u(this,"listenToTap",super.on);this.hostClientUrl=e,this.pluginKey=n;}isValidOrigin(e){if(!this.iframe)return false;let n=e.origin,r=new URL(this.iframe.src).origin;return !!(n===r||n.includes("vercel.app")&&r.includes("vercel.app")||n.includes("localhost")&&r.includes("localhost"))}getMessageTarget(){return this.iframe?.contentWindow||null}getTargetOrigin(){if(!this.iframe?.src)return "*";try{return new URL(this.iframe.src).origin}catch{return "*"}}renderIframe({chatBody:e,isProd:n,isLocal:r}){return new Promise(o=>{this.iframe=document.createElement("iframe"),this.iframe.style.setProperty("display","flex","important"),this.iframe.style.setProperty("border","none","important"),r?this.iframe.src=`${this.hostClientUrl}/chat`:this.iframe.src="https://ax-tap-fe-staging.vercel.app/chat",this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.onload=()=>o(this.iframe),e.appendChild(this.iframe);})}hasIframe(){return !!this.iframe}removeIframe(){this.iframe?.remove(),this.iframe=null,this.removeAllListeners();}get postToTap(){return this.iframe||console.warn("TapIframeBridge: iframe not found"),super.postMessage}async performHandshake(e,n){if(!this.iframe)throw new Error("TapIframeBridge: iframe not available for handshake");let r=new M(()=>this.getMessageTarget(),()=>this.getTargetOrigin(),s=>this.isValidOrigin(s)),o={type:ke,hostClientUrl:this.hostClientUrl,pluginKey:this.pluginKey,chatApiParams:e.chatApiParams,theme:e.customStyles};try{return await r.execute(o,n)}catch(s){throw s instanceof Error?new Error(`TapIframeBridge handshake failed: ${s.message}`):s}}};var $=class{constructor(t){this.iframeBridge=t;}onTimelineSeek(t){this.iframeBridge.listenToTap("timeline:seek",e=>t(e.clipPlayHead,e.clipId));}onChatOpened(t){this.iframeBridge.listenToTap("chat:opened",t);}onChatClosed(t){this.iframeBridge.listenToTap("chat:closed",t);}onChatInitiated(t){this.iframeBridge.listenToTap("chat:initiated",t);}onAlarmFadeIn(t){this.iframeBridge.listenToTap("alarm:fadeIn",e=>{t(e.messageInfo);});}onPopUpOpen(t){this.iframeBridge.listenToTap("popUp:open",e=>{t(e.popUpInfo);});}onPdfOpen(t){this.iframeBridge.listenToTap("pdf:open",t);}onPdfClose(t){this.iframeBridge.listenToTap("pdf:close",t);}};var we="wu2gm66",_e="wu2gm67",Te="wu2gm68";function Ue({htmlString:i,callback:t,customStyles:e}){let n=document.createElement("div");n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100vw",n.style.height="100vh",n.style.background="rgba(0, 0, 0, 0.4)",n.style.zIndex="10000002";let r=document.createElement("div");r.style.position="fixed",r.style.display="flex",r.style.flexDirection="column";let s=15;if(e?.width){let m=parseFloat(e.width),y=e.width.match(/[a-zA-Z%]+/)?.[0];!isNaN(m)&&y==="px"&&(s+=m);}else s+=340;if(e?.position?.right){let m=parseFloat(e?.position?.right),y=e?.position?.right.match(/[a-zA-Z%]+/)?.[0];!isNaN(m)&&y==="px"&&(s+=m);}else s=s+24;r.style.top=e?.position?.top??"50px",r.style.right=`${s}px`,r.style.left=e?.position?.left??"unset",r.style.bottom=e?.position?.bottom??"unset",r.style.maxWidth="calc(100vw - 100px)",r.style.maxHeight=e?.height??"calc(100vh - 116px)",r.style.overflow="auto",r.style.background="#fff",r.style.padding="20px",r.style.border="1px solid #ccc",r.style.boxShadow="0 4px 20px rgba(0,0,0,0.2)",r.style.zIndex="10000003",r.style.borderRadius="8px";let c=document.createElement("div");c.innerHTML=i,n.addEventListener("click",()=>{document.body.removeChild(n),document.body.removeChild(r),t();}),r.addEventListener("click",m=>{m.stopPropagation();}),r.appendChild(c),document.body.appendChild(n),document.body.appendChild(r);let a=document.querySelector(`.${we}`),p=document.querySelector(".cw-plugin-code-block"),l=document.querySelector(`.${Te}`),f=document.querySelector(`.${_e}`);a&&p&&l&&f&&a.addEventListener("click",()=>{navigator.clipboard.writeText(p.textContent??""),l.style.display="none",f.textContent="\uBCF5\uC0AC\uB428",setTimeout(()=>{f.textContent="\uBCF5\uC0AC",l.style.display="inline";},1e3);});}var Ie=Ue;var E=class E{constructor({gaId:t}){E.isInitialized||(this.init(t),E.isInitialized=true);}init(t){if(!document.querySelector(`script[src="https://www.googletagmanager.com/gtag/js?id=${t}"]`)){let e=document.createElement("script");e.async=true,e.src=`https://www.googletagmanager.com/gtag/js?id=${t}`,document.head.appendChild(e);}if(typeof window.gtag!="function"){let e=document.createElement("script");e.innerHTML=`
|
|
18
|
+
`,willChange:"transform, opacity, width, max-height, max-width"}),document.body.appendChild(this.chatBody),this.chatBody)}toggleVisibility(t){if(!this.chatBody)return;this.chatBody.classList.remove(D,w),this.chatBody.style.display="block";let e=()=>{this.chatBody&&(this.chatBody.classList.contains(w)&&(this.chatBody.style.display="none"),this.chatBody.removeEventListener("animationend",e));};this.chatBody.addEventListener("animationend",e),requestAnimationFrame(()=>{this.chatBody?.classList.add(t?D:w);});}removeChatBody(){this.chatBody&&(this.chatBody.remove(),this.chatBody=null);}resizeChatBody(t,e){if(!this.chatBody)return;let n=e?.width??"340px",r=parseInt(n,10),o=r/3*10-r,s=t?`${r+o}px`:`${r}px`;this.chatBody.style.width=s;}},ee=O;var te="_6j1ub51",P={default:"_6j1ub5b _6j1ub5a","call-to-action":"_6j1ub5c _6j1ub5a"},ne="_6j1ub5a",re="_6j1ub59",L={default:"_6j1ub5e _6j1ub5d","call-to-action":"_6j1ub5f _6j1ub5d"},ie="_6j1ub5d",se="_6j1ub5h",ue="_6j1ub5g",S="_6j1ub53",oe="_6j1ub58",N={default:"_6j1ub56 _6j1ub55","call-to-action":"_6j1ub57 _6j1ub55"},ae="_6j1ub55",q="_6j1ub52",le="_6j1ub54";var h,ce,pe,fe,ye,he,z=class{constructor(){g(this,h);u(this,"container");u(this,"alarmTimeout");u(this,"alarmCornerSVG");u(this,"textContainer");u(this,"circleElement");u(this,"textInTextContainer");u(this,"messageInfo");}render({rootElement:t}){this.container=document.createElement("div"),this.container.id="alarm-container",this.container.className=te,this.container.addEventListener("click",n=>{n.stopPropagation();}),t.appendChild(this.container),d(this,h,ce).call(this,this.container);let e=d(this,h,pe).call(this,this.container);d(this,h,ye).call(this,e),d(this,h,fe).call(this,e);}fadeIn(t){t.type==="default"||t.type==="hourSpent"?(this.textContainer.className=N.default,this.alarmCornerSVG.setAttribute("class",P.default),this.circleElement.className=L.default):(this.textContainer.className=N["call-to-action"],this.alarmCornerSVG.setAttribute("class",P["call-to-action"]),this.circleElement.className=L["call-to-action"]),this.messageInfo=t,this.textInTextContainer.textContent=t.message,this.toggleVisibility(true),this.alarmTimeout=setTimeout(()=>{this.toggleVisibility(false);},18*1e3);}addClickEvent({callback:t}){this.container.addEventListener("click",()=>{this.toggleVisibility(false),t(this.messageInfo);});}toggleVisibility(t){this.container.classList.remove(q,S),requestAnimationFrame(()=>{this.container?.classList.add(t?q:S);});}remove(){this.container&&this.toggleVisibility(false),this.alarmTimeout&&clearTimeout(this.alarmTimeout);}};h=new WeakSet,ce=function(t){let e=document.createElement("div");e.className=re,t.appendChild(e);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","11"),n.setAttribute("height","8"),n.setAttribute("viewBox","0 0 11 8"),n.setAttribute("fill","currentColor"),n.setAttribute("class",ne);let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d","M5.5 0L11.1292 8.25H-0.129165L5.5 0Z"),r.setAttribute("fill","currentColor"),n.appendChild(r),this.alarmCornerSVG=n,e.appendChild(n);},pe=function(t){let e=document.createElement("div");return e.className=le,t.appendChild(e),e},fe=function(t){this.textContainer=document.createElement("div"),this.textContainer.className=ae,t.appendChild(this.textContainer),this.textInTextContainer=document.createElement("span"),this.textInTextContainer.className=oe,this.textContainer.appendChild(this.textInTextContainer);},ye=function(t){let e=document.createElement("div");e.className=ie,t.appendChild(e),e.addEventListener("click",r=>{r.stopPropagation(),this.remove();});let n=document.createElement("span");n.className=se,e.appendChild(n),n.textContent="\uC54C\uB9BC \uB044\uAE30",d(this,h,he).call(this,e),this.circleElement=e;},he=function(t){let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","10"),e.setAttribute("height","10"),e.setAttribute("viewBox","0 0 14 14"),e.setAttribute("fill","none"),e.setAttribute("class",ue);let n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("d","M1 1L13 13M13 1L1 13"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),e.appendChild(n),t.appendChild(e);};var me=z;var _,R=class{constructor(){u(this,"customFloatingButton");u(this,"floatingButton");u(this,"alarm");g(this,_,(t,e)=>t.key===e?true:t.code.startsWith("Key")?t.code.slice(3).toLowerCase()===e:false);this.alarm=new me;}render({customFloatingButton:t}){if(this.customFloatingButton=t,this.customFloatingButton?.isInElement&&this.customFloatingButton?.parentElementId){let e=document.getElementById(this.customFloatingButton.parentElementId);e?.style.setProperty("position","relative","important"),e?.style.setProperty("z-index","10000001","important"),this.floatingButton=e;}else {let e=document.getElementById("cw-plugin");e||(e=document.createElement("button"),e.id="cw-plugin",e.style.zIndex="10000001",e.style.setProperty("z-index","10000001","important"),e.style.setProperty("position","fixed","important"),e.style.width="50px",e.style.height="50px",e.style.borderRadius="50%",e.style.backgroundColor="#000",document.body.appendChild(e),this.floatingButton=e);}return this.alarm.render({rootElement:this.floatingButton}),this.floatingButton}addClickEvent({callback:t}){if(!this.floatingButton)throw new Error("not initialized");this.floatingButton.addEventListener("click",()=>{t();});}addAlarmClickEvent({callback:t}){this.alarm.addClickEvent({callback:t});}addShortCutEvent({openChatShortcutKey:t,callback:e}){if(!this.floatingButton)throw new Error("not initialized");window.addEventListener("keydown",n=>{Y(this,_).call(this,n,t.key)&&(!t.modifier||n[t.modifier])&&e();});}alarmFadeIn(t){this.alarm.fadeIn(t);}alarmRemove(){this.alarm.remove();}};_=new WeakMap;var de=R;var F;function H(i){return {lang:i?.lang??F?.lang,message:i?.message,abortEarly:i?.abortEarly??F?.abortEarly,abortPipeEarly:i?.abortPipeEarly??F?.abortPipeEarly}}var Oe;function Pe(i){return Oe?.get(i)}var Le;function Se(i){return Le?.get(i)}var Ne;function qe(i,t){return Ne?.get(i)?.get(t)}function ve(i){let t=typeof i;return t==="string"?`"${i}"`:t==="number"||t==="bigint"||t==="boolean"?`${i}`:t==="object"||t==="function"?(i&&Object.getPrototypeOf(i)?.constructor?.name)??"null":t}function k(i,t,e,n,r){let o=r&&"input"in r?r.input:e.value,s=r?.expected??i.expects??null,c=r?.received??ve(o),a={kind:i.kind,type:i.type,input:o,expected:s,received:c,message:`Invalid ${t}: ${s?`Expected ${s} but r`:"R"}eceived ${c}`,requirement:i.requirement,path:r?.path,issues:r?.issues,lang:n.lang,abortEarly:n.abortEarly,abortPipeEarly:n.abortPipeEarly},p=i.kind==="schema",l=r?.message??i.message??qe(i.reference,a.lang)??(p?Se(a.lang):null)??n.message??Pe(a.lang);l!==void 0&&(a.message=typeof l=="function"?l(a):l),p&&(e.typed=false),e.issues?e.issues.push(a):e.issues=[a];}function x(i){return {version:1,vendor:"valibot",validate(t){return i["~run"]({value:t},H())}}}function ze(i,t){return Object.hasOwn(i,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}var Re=class extends Error{constructor(i){super(i[0].message),this.name="ValiError",this.issues=i;}};function Fe(i,t,e){return typeof i.fallback=="function"?i.fallback(t,e):i.fallback}function He(i,t,e){return typeof i.default=="function"?i.default(t,e):i.default}function G(){return {kind:"schema",type:"any",reference:G,expects:"any",async:false,get"~standard"(){return x(this)},"~run"(i){return i.typed=true,i}}}function T(i,t){return {kind:"schema",type:"literal",reference:T,expects:ve(i),async:false,literal:i,message:t,get"~standard"(){return x(this)},"~run"(e,n){return e.value===this.literal?e.typed=true:k(this,"type",e,n),e}}}function I(i,t){return {kind:"schema",type:"object",reference:I,expects:"Object",async:false,entries:i,message:t,get"~standard"(){return x(this)},"~run"(e,n){let r=e.value;if(r&&typeof r=="object"){e.typed=true,e.value={};for(let o in this.entries){let s=this.entries[o];if(o in r||(s.type==="exact_optional"||s.type==="optional"||s.type==="nullish")&&s.default!==void 0){let c=o in r?r[o]:He(s),a=s["~run"]({value:c},n);if(a.issues){let p={type:"object",origin:"value",input:r,key:o,value:c};for(let l of a.issues)l.path?l.path.unshift(p):l.path=[p],e.issues?.push(l);if(e.issues||(e.issues=a.issues),n.abortEarly){e.typed=false;break}}a.typed||(e.typed=false),e.value[o]=a.value;}else if(s.fallback!==void 0)e.value[o]=Fe(s);else if(s.type!=="exact_optional"&&s.type!=="optional"&&s.type!=="nullish"&&(k(this,"key",e,n,{input:void 0,expected:`"${o}"`,path:[{type:"object",origin:"key",input:r,key:o,value:r[o]}]}),n.abortEarly))break}}else k(this,"type",e,n);return e}}}function V(i,t,e){return {kind:"schema",type:"record",reference:V,expects:"Object",async:false,key:i,value:t,message:e,get"~standard"(){return x(this)},"~run"(n,r){let o=n.value;if(o&&typeof o=="object"){n.typed=true,n.value={};for(let s in o)if(ze(o,s)){let c=o[s],a=this.key["~run"]({value:s},r);if(a.issues){let l={type:"object",origin:"key",input:o,key:s,value:c};for(let f of a.issues)f.path=[l],n.issues?.push(f);if(n.issues||(n.issues=a.issues),r.abortEarly){n.typed=false;break}}let p=this.value["~run"]({value:c},r);if(p.issues){let l={type:"object",origin:"value",input:o,key:s,value:c};for(let f of p.issues)f.path?f.path.unshift(l):f.path=[l],n.issues?.push(f);if(n.issues||(n.issues=p.issues),r.abortEarly){n.typed=false;break}}(!a.typed||!p.typed)&&(n.typed=false),a.typed&&(n.value[a.value]=p.value);}}else k(this,"type",n,r);return n}}}function C(i){return {kind:"schema",type:"string",reference:C,expects:"string",async:false,message:i,get"~standard"(){return x(this)},"~run"(t,e){return typeof t.value=="string"?t.typed=true:k(this,"type",t,e),t}}}function ge(i,t,e){let n=i["~run"]({value:t},H(e));if(n.issues)throw new Re(n.issues);return n.value}function be(i,t,e){let n=i["~run"]({value:t},H(e));return {typed:n.typed,success:!n.issues,output:n.value,issues:n.issues}}var ke="chat:init",Ge="chat:initiated";var xe=I({type:T(Ge),gaId:C()}),Ee=I({type:T("GA_EVENT"),payload:V(C(),G())});var A=class{constructor(){u(this,"listeners",new Map);u(this,"unifiedMessageHandler",null);}on(t,e){let n=o=>{if(this.isValidOrigin(o))try{let s=o.data,c=typeof s=="string"?JSON.parse(s):s,{type:a}=c;a===t&&e(c);}catch(s){console.warn("Messenger: Failed to parse message data",s);}},r=this.listeners.get(t)||[];return r.push(n),this.listeners.set(t,r),this.unifiedMessageHandler||(this.unifiedMessageHandler=o=>{this.listeners.forEach(s=>s.forEach(c=>c(o)));},window.addEventListener("message",this.unifiedMessageHandler)),()=>{this.unifiedMessageHandler&&(window.removeEventListener("message",this.unifiedMessageHandler),this.unifiedMessageHandler=null);}}removeListener(t){this.listeners.delete(t);}removeAllListeners(){this.listeners.clear(),this.unifiedMessageHandler&&(window.removeEventListener("message",this.unifiedMessageHandler),this.unifiedMessageHandler=null);}postMessage(t){try{let e=this.getMessageTarget();return e?(e.postMessage(t,this.getTargetOrigin()),!0):(console.warn("Messenger: Message target not available"),!1)}catch(e){return console.error("Messenger: postMessage failed",e),false}}};var v=class extends Error{constructor(e,n,r){super(`Handshake failed: ${e}${n?` - ${n}`:""}`);this.reason=e;this.details=n;this.originalError=r;this.name="HandshakeError";}},M=class{constructor(t,e,n){this.getTargetWindow=t;this.getTargetOrigin=e;this.isValidOrigin=n;u(this,"abortController",null);u(this,"messageListener",null);}async execute(t,e={}){let{timeout:n=1e4,maxRetries:r=10,retryInterval:o=500}=e;return this.cancel(),this.abortController=new AbortController,new Promise((s,c)=>{let a=0,p,l=()=>{p&&clearTimeout(p),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null);},f=()=>{l(),c(new v("TIMEOUT","Handshake was cancelled"));};this.abortController?.signal.addEventListener("abort",f),this.messageListener=y=>{if(this.isValidOrigin(y))try{let b=y.data,Me=typeof b=="string"?JSON.parse(b):b;try{let K=be(xe,Me);l(),this.abortController=null,s(K.output);return}catch{}}catch(b){console.warn("Failed to parse handshake message:",b);}},window.addEventListener("message",this.messageListener),p=setTimeout(()=>{l(),this.abortController=null,c(new v("TIMEOUT",`No valid response received within ${n}ms`));},n);let m=()=>{if(!this.abortController?.signal.aborted)try{let y=this.getTargetWindow();if(!y)throw new v("NO_TARGET_WINDOW","Target iframe window is not available");y.postMessage(t,this.getTargetOrigin()),a++,a<r&&setTimeout(()=>{this.abortController?.signal.aborted||m();},o);}catch(y){l(),this.abortController=null,y instanceof v?c(y):c(new v("MESSAGE_SEND_FAILED","Failed to send handshake message",y));}};m();})}cancel(){this.abortController&&(this.abortController.abort(),this.abortController=null),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null);}isActive(){return this.abortController!==null&&!this.abortController.signal.aborted}};var j=class extends A{constructor({hostClientUrl:e,pluginKey:n}){super();u(this,"hostClientUrl");u(this,"pluginKey");u(this,"iframe");u(this,"listenToTap",super.on);this.hostClientUrl=e,this.pluginKey=n;}isValidOrigin(e){return true}getMessageTarget(){return this.iframe?.contentWindow||null}getTargetOrigin(){if(!this.iframe?.src)return "*";try{return new URL(this.iframe.src).origin}catch{return "*"}}renderIframe({chatBody:e,isProd:n,isLocal:r}){return new Promise(o=>{this.iframe=document.createElement("iframe"),this.iframe.style.setProperty("display","flex","important"),this.iframe.style.setProperty("border","none","important"),r?this.iframe.src=`${this.hostClientUrl}/chat`:this.iframe.src="https://ax-tap-fe-staging.vercel.app/chat",this.iframe.style.width="100%",this.iframe.style.height="100%",this.iframe.onload=()=>o(this.iframe),e.appendChild(this.iframe);})}hasIframe(){return !!this.iframe}removeIframe(){this.iframe?.remove(),this.iframe=null,this.removeAllListeners();}get postToTap(){return this.iframe?super.postMessage:(console.warn("TapIframeBridge: iframe not found - ensure createIframeChat() was called first"),()=>{console.warn("TapIframeBridge: Cannot post message - no iframe available");})}async performHandshake(e,n){if(!this.iframe)throw new Error("TapIframeBridge: iframe not available for handshake");let r=new M(()=>this.getMessageTarget(),()=>this.getTargetOrigin(),s=>this.isValidOrigin(s)),o={type:ke,hostClientUrl:this.hostClientUrl,pluginKey:this.pluginKey,chatApiParams:e.chatApiParams,theme:e.customStyles};try{return await r.execute(o,n)}catch(s){throw s instanceof Error?new Error(`TapIframeBridge handshake failed: ${s.message}`):s}}};var B=class{constructor(t){this.iframeBridge=t;}onTimelineSeek(t){this.iframeBridge.listenToTap("timeline:seek",e=>t(e.clipPlayHead,e.clipId));}onChatOpened(t){this.iframeBridge.listenToTap("chat:opened",t);}onChatClosed(t){this.iframeBridge.listenToTap("chat:closed",t);}onChatInitiated(t){this.iframeBridge.listenToTap("chat:initiated",t);}onAlarmFadeIn(t){this.iframeBridge.listenToTap("alarm:fadeIn",e=>{t(e.messageInfo);});}onPopUpOpen(t){this.iframeBridge.listenToTap("popUp:open",e=>{t(e.popUpInfo);});}onPdfOpen(t){this.iframeBridge.listenToTap("pdf:open",t);}onPdfClose(t){this.iframeBridge.listenToTap("pdf:close",t);}};var we="wu2gm66",_e="wu2gm67",Te="wu2gm68";function Ue({htmlString:i,callback:t,customStyles:e}){let n=document.createElement("div");n.style.position="fixed",n.style.top="0",n.style.left="0",n.style.width="100vw",n.style.height="100vh",n.style.background="rgba(0, 0, 0, 0.4)",n.style.zIndex="10000002";let r=document.createElement("div");r.id="wow",r.style.position="fixed",r.style.display="flex",r.style.flexDirection="column";let s=15;if(e?.width){let m=parseFloat(e.width),y=e.width.match(/[a-zA-Z%]+/)?.[0];!isNaN(m)&&y==="px"&&(s+=m);}else s+=340;if(e?.position?.right){let m=parseFloat(e?.position?.right),y=e?.position?.right.match(/[a-zA-Z%]+/)?.[0];!isNaN(m)&&y==="px"&&(s+=m);}else s=s+24;r.style.top=e?.position?.top??"50px",r.style.right=`${s}px`,r.style.left=e?.position?.left??"unset",r.style.bottom=e?.position?.bottom??"unset",r.style.maxWidth="calc(100vw - 100px)",r.style.maxHeight=e?.height??"calc(100vh - 116px)",r.style.overflow="auto",r.style.background="#fff",r.style.padding="20px",r.style.border="1px solid #ccc",r.style.boxShadow="0 4px 20px rgba(0,0,0,0.2)",r.style.zIndex="10000003",r.style.borderRadius="8px";let c=document.createElement("div");c.innerHTML=i,n.addEventListener("click",()=>{document.body.removeChild(n),document.body.removeChild(r),t();}),r.addEventListener("click",m=>{m.stopPropagation();}),r.appendChild(c),document.body.appendChild(n),document.body.appendChild(r);let a=document.querySelector(`.${we}`),p=document.querySelector(".cw-plugin-code-block"),l=document.querySelector(`.${Te}`),f=document.querySelector(`.${_e}`);a&&p&&l&&f&&a.addEventListener("click",()=>{navigator.clipboard.writeText(p.textContent??""),l.style.display="none",f.textContent="\uBCF5\uC0AC\uB428",setTimeout(()=>{f.textContent="\uBCF5\uC0AC",l.style.display="inline";},1e3);});}var Ie=Ue;var E=class E{constructor({gaId:t}){E.isInitialized||(this.init(t),E.isInitialized=true);}init(t){if(!document.querySelector(`script[src="https://www.googletagmanager.com/gtag/js?id=${t}"]`)){let e=document.createElement("script");e.async=true,e.src=`https://www.googletagmanager.com/gtag/js?id=${t}`,document.head.appendChild(e);}if(typeof window.gtag!="function"){let e=document.createElement("script");e.innerHTML=`
|
|
19
19
|
window.dataLayer = window.dataLayer || [];
|
|
20
20
|
function gtag(){dataLayer.push(arguments);}
|
|
21
21
|
gtag('js', new Date());
|
|
22
22
|
gtag('config', '${t}');
|
|
23
|
-
`,document.head.appendChild(e);}window.addEventListener("message",e=>{try{let n=typeof e.data=="string"?JSON.parse(e.data):e.data,r=ge(Ee,n);typeof window.gtag=="function"&&window.gtag("event",r.payload.action??"click",{event_category:r.payload.category??"Default",event_label:r.payload.label,value:r.payload.value,fastCampus_user_id:r.payload.fastCampus_user_id,course_id:r.payload.course_id,...r.payload});}catch{}});}};u(E,"isInitialized",false);var W=E,Ce=W;var
|
|
23
|
+
`,document.head.appendChild(e);}window.addEventListener("message",e=>{try{let n=typeof e.data=="string"?JSON.parse(e.data):e.data,r=ge(Ee,n);typeof window.gtag=="function"&&window.gtag("event",r.payload.action??"click",{event_category:r.payload.category??"Default",event_label:r.payload.label,value:r.payload.value,fastCampus_user_id:r.payload.fastCampus_user_id,course_id:r.payload.course_id,...r.payload});}catch{}});}};u(E,"isInitialized",false);var W=E,Ce=W;var $,Ae,X=class{constructor({pluginKey:t,isProd:e=false,isLocal:n=false}){g(this,$);u(this,"pluginKey");u(this,"iframeBridge");u(this,"events");u(this,"chatBody",null);u(this,"chatBodyMaker");u(this,"floatingButtonMaker");u(this,"shortcutKey",{openChat:{key:"/",modifier:""},sendChat:{key:"Enter",modifier:""}});u(this,"isProd");u(this,"isLocal");u(this,"isOpen");u(this,"isPdfOpen");this.pluginKey=t,this.iframeBridge=new j({hostClientUrl:window.location.origin,pluginKey:this.pluginKey}),this.events=new B(this.iframeBridge),this.floatingButtonMaker=new de,this.chatBodyMaker=new ee,this.isProd=e,this.isLocal=n,this.isOpen=false,this.isPdfOpen=false;}setIsOpen(t){this.isOpen=t;}setIsPdfOpen(t){this.isPdfOpen=t;}seekTimeline({clipId:t,clipPlayHead:e}){this.iframeBridge.postToTap({type:"timeline:seek",clipId:t,clipPlayHead:e});}async initChat({chatApiParams:t,customStyles:e,shortcutKey:n}){if(!d(this,$,Ae).call(this))throw new Error("not client");this.shortcutKey={openChat:n?.openChat??this.shortcutKey.openChat,sendChat:n?.sendChat??this.shortcutKey.sendChat},this.chatBody||(this.chatBody=this.chatBodyMaker.createChatBody({...e?.chatBody&&{customChatBody:e.chatBody}})),this.iframeBridge.hasIframe()||await this.iframeBridge.renderIframe({chatBody:this.chatBody,isProd:this.isProd,isLocal:this.isLocal});try{let r=await this.iframeBridge.performHandshake({chatApiParams:t,customStyles:e},{retryInterval:500,maxRetries:10,timeout:1e4});new Ce({gaId:r.gaId});}catch(r){throw console.error("Handshake failed:",r),new Error(`Chat initialization failed: ${r instanceof Error?r.message:"Unknown error"}`)}this.floatingButtonMaker.render({...e?.floatingButton&&{customFloatingButton:e.floatingButton}}),this.floatingButtonMaker.addClickEvent({callback:()=>{this.iframeBridge.postToTap({type:this.isOpen?"chat:close":"chat:open"});}}),this.floatingButtonMaker.addAlarmClickEvent({callback:r=>{this.iframeBridge.postToTap({type:"chat:open",isAlarm:true}),this.iframeBridge.postToTap({type:"alarm:click",messageInfo:r});}}),this.iframeBridge.listenToTap("chat:opened",()=>{this.setIsOpen(true),this.chatBodyMaker.toggleVisibility(this.isOpen),this.floatingButtonMaker.alarmRemove();}),this.iframeBridge.listenToTap("chat:closed",()=>{this.setIsOpen(false),this.chatBodyMaker.toggleVisibility(this.isOpen);}),this.iframeBridge.listenToTap("alarm:fadeIn",r=>{this.isOpen||this.floatingButtonMaker.alarmFadeIn(r.messageInfo);}),this.iframeBridge.listenToTap("popUp:open",r=>{Ie({htmlString:r.popUpInfo.html,callback:()=>this.iframeBridge.postToTap({type:"popUp:close"}),...e?.chatBody&&{customStyles:e.chatBody}});}),this.iframeBridge.listenToTap("pdf:open",()=>{this.setIsPdfOpen(true),this.chatBodyMaker.resizeChatBody(this.isPdfOpen,e?.chatBody),this.iframeBridge.postToTap({type:"pdf:enlarged"});}),this.iframeBridge.listenToTap("pdf:close",()=>{this.setIsPdfOpen(false),this.chatBodyMaker.resizeChatBody(this.isPdfOpen,e?.chatBody),this.iframeBridge.postToTap({type:"pdf:shrinked"});}),this.isLocal&&this.iframeBridge.listenToTap("alarm:fadeIn",r=>{this.floatingButtonMaker.alarmFadeIn(r.messageInfo);});}removeChat(){if(!this.chatBody)throw new Error("chatBody is not initialized");this.chatBodyMaker.removeChatBody(),this.floatingButtonMaker.alarmRemove(),this.iframeBridge.removeIframe(),this.chatBody=null,this.isOpen=false;}postChatInfo({clipId:t,clipPlayHead:e}){this.seekTimeline({clipId:t,clipPlayHead:e});}getTimelineInfo({callback:t}){this.events.onTimelineSeek(t);}};$=new WeakSet,Ae=function(){return typeof window<"u"&&typeof document<"u"};var Xt=X;return Xt;})();//# sourceMappingURL=index.global.js.map
|
|
24
24
|
//# sourceMappingURL=index.global.js.map
|