@embeddable/sdk 1.0.28 → 1.0.30

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.
@@ -1013,6 +1013,138 @@ function useAI(options) {
1013
1013
  reset
1014
1014
  };
1015
1015
  }
1016
+ function useCalendar(options = {}) {
1017
+ const { widgetId } = useEmbeddableConfig();
1018
+ const [state, setState] = useState({
1019
+ loading: false,
1020
+ error: null,
1021
+ success: false
1022
+ });
1023
+ const executeCalendarAction = useCallback(
1024
+ async (action, additionalData = {}) => {
1025
+ var _a, _b, _c, _d;
1026
+ setState({ loading: true, error: null, success: false });
1027
+ try {
1028
+ const requestData = {
1029
+ widgetId,
1030
+ action,
1031
+ ...additionalData
1032
+ };
1033
+ const response = await fetch(`${EVENTS_BASE_URL}/api/execute/google-calendar`, {
1034
+ method: "POST",
1035
+ headers: {
1036
+ "Content-Type": "application/json"
1037
+ },
1038
+ credentials: "omit",
1039
+ body: JSON.stringify(requestData)
1040
+ });
1041
+ const responseData = await response.json();
1042
+ if (!response.ok) {
1043
+ const errorMessage = responseData.message || responseData.error || `HTTP ${response.status}`;
1044
+ setState({ loading: false, error: errorMessage, success: false });
1045
+ (_a = options.onError) == null ? void 0 : _a.call(options, errorMessage);
1046
+ return {
1047
+ success: false,
1048
+ message: errorMessage
1049
+ };
1050
+ }
1051
+ if (responseData.success) {
1052
+ setState({ loading: false, error: null, success: true });
1053
+ (_b = options.onSuccess) == null ? void 0 : _b.call(options, responseData.data);
1054
+ return {
1055
+ success: true,
1056
+ message: "Calendar operation completed successfully",
1057
+ data: responseData.data,
1058
+ metadata: responseData.metadata
1059
+ };
1060
+ } else {
1061
+ const errorMessage = responseData.message || responseData.error || "Calendar operation failed";
1062
+ setState({ loading: false, error: errorMessage, success: false });
1063
+ (_c = options.onError) == null ? void 0 : _c.call(options, errorMessage);
1064
+ return {
1065
+ success: false,
1066
+ message: errorMessage
1067
+ };
1068
+ }
1069
+ } catch (error) {
1070
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
1071
+ setState({ loading: false, error: errorMessage, success: false });
1072
+ (_d = options.onError) == null ? void 0 : _d.call(options, errorMessage);
1073
+ return {
1074
+ success: false,
1075
+ message: errorMessage
1076
+ };
1077
+ }
1078
+ },
1079
+ [widgetId, options]
1080
+ );
1081
+ const getCalendar = useCallback(async () => {
1082
+ return executeCalendarAction("get_calendar");
1083
+ }, [executeCalendarAction]);
1084
+ const listEvents = useCallback(
1085
+ async (eventOptions = {}) => {
1086
+ return executeCalendarAction("list_events", {
1087
+ options: eventOptions
1088
+ });
1089
+ },
1090
+ [executeCalendarAction]
1091
+ );
1092
+ const getEvent = useCallback(
1093
+ async (eventId) => {
1094
+ return executeCalendarAction("get_event", {
1095
+ eventId
1096
+ });
1097
+ },
1098
+ [executeCalendarAction]
1099
+ );
1100
+ const createEvent = useCallback(
1101
+ async (eventData) => {
1102
+ return executeCalendarAction("create_event", {
1103
+ eventData
1104
+ });
1105
+ },
1106
+ [executeCalendarAction]
1107
+ );
1108
+ const updateEvent = useCallback(
1109
+ async (eventId, eventData) => {
1110
+ return executeCalendarAction("update_event", {
1111
+ eventId,
1112
+ eventData
1113
+ });
1114
+ },
1115
+ [executeCalendarAction]
1116
+ );
1117
+ const deleteEvent = useCallback(
1118
+ async (eventId) => {
1119
+ return executeCalendarAction("delete_event", {
1120
+ eventId
1121
+ });
1122
+ },
1123
+ [executeCalendarAction]
1124
+ );
1125
+ const getFreeBusy = useCallback(
1126
+ async (freeBusyOptions) => {
1127
+ return executeCalendarAction("get_freebusy", {
1128
+ options: freeBusyOptions
1129
+ });
1130
+ },
1131
+ [executeCalendarAction]
1132
+ );
1133
+ const reset = useCallback(() => {
1134
+ setState({ loading: false, error: null, success: false });
1135
+ }, []);
1136
+ return {
1137
+ ...state,
1138
+ getCalendar,
1139
+ listEvents,
1140
+ getEvent,
1141
+ createEvent,
1142
+ updateEvent,
1143
+ deleteEvent,
1144
+ getFreeBusy,
1145
+ reset
1146
+ };
1147
+ }
1016
1148
  function useDataIntegration(options = {}) {
1017
1149
  const { widgetId } = useEmbeddableConfig();
1018
1150
  const optionsRef = useRef(options);
@@ -2015,6 +2147,98 @@ function useVoteAggregations(options) {
2015
2147
  reset
2016
2148
  };
2017
2149
  }
2150
+ function useYouTube() {
2151
+ const { widgetId } = useEmbeddableConfig();
2152
+ const [state, setState] = useState({
2153
+ loading: false,
2154
+ error: null,
2155
+ success: false
2156
+ });
2157
+ const analyzeVideo = useCallback(
2158
+ async (request) => {
2159
+ setState({ loading: true, error: null, success: false });
2160
+ try {
2161
+ const requestData = {
2162
+ widgetId,
2163
+ url: request.url,
2164
+ action: request.action,
2165
+ options: request.options || {}
2166
+ };
2167
+ const response = await fetch(`${EVENTS_BASE_URL}/api/execute/youtube`, {
2168
+ method: "POST",
2169
+ headers: {
2170
+ "Content-Type": "application/json"
2171
+ },
2172
+ // Explicitly set credentials to 'omit' for CORS support
2173
+ credentials: "omit",
2174
+ body: JSON.stringify(requestData)
2175
+ });
2176
+ const responseData = await response.json();
2177
+ if (!response.ok) {
2178
+ const errorMessage = responseData.message || responseData.error || `HTTP ${response.status}`;
2179
+ setState({ loading: false, error: errorMessage, success: false });
2180
+ return {
2181
+ success: false,
2182
+ message: errorMessage
2183
+ };
2184
+ }
2185
+ if (responseData.success) {
2186
+ setState({ loading: false, error: null, success: true });
2187
+ return {
2188
+ success: true,
2189
+ message: "YouTube video analyzed successfully",
2190
+ data: responseData.data,
2191
+ metadata: responseData.metadata
2192
+ };
2193
+ } else {
2194
+ const errorMessage = responseData.message || responseData.error || "YouTube analysis failed";
2195
+ setState({ loading: false, error: errorMessage, success: false });
2196
+ return {
2197
+ success: false,
2198
+ message: errorMessage
2199
+ };
2200
+ }
2201
+ } catch (error) {
2202
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
2203
+ setState({ loading: false, error: errorMessage, success: false });
2204
+ return {
2205
+ success: false,
2206
+ message: errorMessage
2207
+ };
2208
+ }
2209
+ },
2210
+ [widgetId]
2211
+ );
2212
+ const summarizeVideo = useCallback(
2213
+ async (url, options) => {
2214
+ return analyzeVideo({ url, action: "summarize", options });
2215
+ },
2216
+ [analyzeVideo]
2217
+ );
2218
+ const getTranscript = useCallback(
2219
+ async (url) => {
2220
+ return analyzeVideo({ url, action: "transcript" });
2221
+ },
2222
+ [analyzeVideo]
2223
+ );
2224
+ const getStats = useCallback(
2225
+ async (url) => {
2226
+ return analyzeVideo({ url, action: "stats" });
2227
+ },
2228
+ [analyzeVideo]
2229
+ );
2230
+ const reset = useCallback(() => {
2231
+ setState({ loading: false, error: null, success: false });
2232
+ }, []);
2233
+ return {
2234
+ ...state,
2235
+ analyzeVideo,
2236
+ summarizeVideo,
2237
+ getTranscript,
2238
+ getStats,
2239
+ reset
2240
+ };
2241
+ }
2018
2242
  const defaultConfig = {
2019
2243
  version: "latest",
2020
2244
  mode: "embeddable",
@@ -2081,18 +2305,20 @@ function useEmbeddableContext() {
2081
2305
  export {
2082
2306
  EmbeddableProvider as E,
2083
2307
  useAI as a,
2084
- useDataIntegration as b,
2085
- useDebounce as c,
2086
- useEmbeddableConfig as d,
2087
- useFileUpload as e,
2088
- useEmbeddableData as f,
2089
- useEventTracking as g,
2090
- useFormSubmission as h,
2091
- useLocalStorage as i,
2092
- usePayment as j,
2093
- usePublicSubmissions as k,
2094
- useScraping as l,
2095
- useVote as m,
2096
- useVoteAggregations as n,
2308
+ useCalendar as b,
2309
+ useDataIntegration as c,
2310
+ useDebounce as d,
2311
+ useEmbeddableConfig as e,
2312
+ useFileUpload as f,
2313
+ useEmbeddableData as g,
2314
+ useEventTracking as h,
2315
+ useFormSubmission as i,
2316
+ useLocalStorage as j,
2317
+ usePayment as k,
2318
+ usePublicSubmissions as l,
2319
+ useScraping as m,
2320
+ useVote as n,
2321
+ useVoteAggregations as o,
2322
+ useYouTube as p,
2097
2323
  useEmbeddableContext as u
2098
2324
  };
@@ -0,0 +1,10 @@
1
+ "use strict";const e=require("react"),t=require("./storage-BtXo3gya.cjs");var r,s={exports:{}},n={};var a,o={};
2
+ /**
3
+ * @license React
4
+ * react-jsx-runtime.development.js
5
+ *
6
+ * Copyright (c) Facebook, Inc. and its affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */"production"===process.env.NODE_ENV?s.exports=function(){if(r)return n;r=1;var t=e,s=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var n,a={},u=null,l=null;for(n in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)o.call(t,n)&&!i.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:s,type:e,key:u,ref:l,props:a,_owner:c.current}}return n.Fragment=a,n.jsx=u,n.jsxs=u,n}():s.exports=(a||(a=1,"production"!==process.env.NODE_ENV&&function(){var t,r=e,s=Symbol.for("react.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),v=Symbol.iterator,b=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];!function(e,t,r){var s=b.ReactDebugCurrentFrame.getStackAddendum();""!==s&&(t+="%s",r=r.concat([s]));var n=r.map(function(e){return String(e)});n.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,n)}("error",e,r)}function w(e){return e.displayName||"Context"}function k(e){if(null==e)return null;if("number"==typeof e.tag&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case n:return"Portal";case i:return"Profiler";case c:return"StrictMode";case p:return"Suspense";case f:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return w(e)+".Consumer";case u:return w(e._context)+".Provider";case d:return function(e,t,r){var s=e.displayName;if(s)return s;var n=t.displayName||t.name||"";return""!==n?r+"("+n+")":r}(e,e.render,"ForwardRef");case g:var t=e.displayName||null;return null!==t?t:k(e.type)||"Memo";case m:var r=e,s=r._payload,o=r._init;try{return k(o(s))}catch(y){return null}}return null}t=Symbol.for("react.module.reference");var _,S,C,E,T,j,O,I=Object.assign,P=0;function x(){}x.__reactDisabledLog=!0;var $,R=b.ReactCurrentDispatcher;function N(e,t,r){if(void 0===$)try{throw Error()}catch(n){var s=n.stack.trim().match(/\n( *(at )?)/);$=s&&s[1]||""}return"\n"+$+e}var D,F=!1,U="function"==typeof WeakMap?WeakMap:Map;function L(e,t){if(!e||F)return"";var r,s=D.get(e);if(void 0!==s)return s;F=!0;var n,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,n=R.current,R.current=null,function(){if(0===P){_=console.log,S=console.info,C=console.warn,E=console.error,T=console.group,j=console.groupCollapsed,O=console.groupEnd;var e={configurable:!0,enumerable:!0,value:x,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}P++}();try{if(t){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(o,[])}catch(g){r=g}Reflect.construct(e,[],o)}else{try{o.call()}catch(g){r=g}e.call(o.prototype)}}else{try{throw Error()}catch(g){r=g}e()}}catch(m){if(m&&r&&"string"==typeof m.stack){for(var c=m.stack.split("\n"),i=r.stack.split("\n"),u=c.length-1,l=i.length-1;u>=1&&l>=0&&c[u]!==i[l];)l--;for(;u>=1&&l>=0;u--,l--)if(c[u]!==i[l]){if(1!==u||1!==l)do{if(u--,--l<0||c[u]!==i[l]){var d="\n"+c[u].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,d),d}}while(u>=1&&l>=0);break}}}finally{F=!1,R.current=n,function(){if(0===--P){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:_}),info:I({},e,{value:S}),warn:I({},e,{value:C}),error:I({},e,{value:E}),group:I({},e,{value:T}),groupCollapsed:I({},e,{value:j}),groupEnd:I({},e,{value:O})})}P<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var p=e?e.displayName||e.name:"",f=p?N(p):"";return"function"==typeof e&&D.set(e,f),f}function A(e,t,r){if(null==e)return"";if("function"==typeof e)return L(e,!(!(s=e.prototype)||!s.isReactComponent));var s;if("string"==typeof e)return N(e);switch(e){case p:return N("Suspense");case f:return N("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return L(e.render,!1);case g:return A(e.type,t,r);case m:var n=e,a=n._payload,o=n._init;try{return A(o(a),t,r)}catch(c){}}return""}D=new U;var V=Object.prototype.hasOwnProperty,z={},J=b.ReactDebugCurrentFrame;function W(e){if(e){var t=e._owner,r=A(e.type,e._source,t?t.type:null);J.setExtraStackFrame(r)}else J.setExtraStackFrame(null)}var H=Array.isArray;function B(e){return H(e)}function K(e){return""+e}function Y(e){if(function(e){try{return K(e),!1}catch(t){return!0}}(e))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),K(e)}var M,q,G=b.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,t,r,n,a){var o,c={},i=null,u=null;for(o in void 0!==r&&(Y(r),i=""+r),function(e){if(V.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(Y(t.key),i=""+t.key),function(e){if(V.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(u=t.ref,function(e){"string"==typeof e.ref&&G.current}(t)),t)V.call(t,o)&&!X.hasOwnProperty(o)&&(c[o]=t[o]);if(e&&e.defaultProps){var l=e.defaultProps;for(o in l)void 0===c[o]&&(c[o]=l[o])}if(i||u){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;i&&function(e,t){var r=function(){M||(M=!0,h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(c,d),u&&function(e,t){var r=function(){q||(q=!0,h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(c,d)}return function(e,t,r,n,a,o,c){var i={$$typeof:s,type:e,key:t,ref:r,props:c,_owner:o,_store:{}};return Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i}(e,i,u,a,n,G.current,c)}var Z,ee=b.ReactCurrentOwner,te=b.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=A(e.type,e._source,t?t.type:null);te.setExtraStackFrame(r)}else te.setExtraStackFrame(null)}function se(e){return"object"==typeof e&&null!==e&&e.$$typeof===s}function ne(){if(ee.current){var e=k(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var ae={};function oe(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=ne();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!ae[r]){ae[r]=!0;var s="";e&&e._owner&&e._owner!==ee.current&&(s=" It was passed a child from "+k(e._owner.type)+"."),re(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,s),re(null)}}}function ce(e,t){if("object"==typeof e)if(B(e))for(var r=0;r<e.length;r++){var s=e[r];se(s)&&oe(s,t)}else if(se(e))e._store&&(e._store.validated=!0);else if(e){var n=function(e){if(null===e||"object"!=typeof e)return null;var t=v&&e[v]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof n&&n!==e.entries)for(var a,o=n.call(e);!(a=o.next()).done;)se(a.value)&&oe(a.value,t)}}function ie(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==d&&r.$$typeof!==g)return;t=r.propTypes}if(t){var s=k(r);!function(e,t,r,s,n){var a=Function.call.bind(V);for(var o in e)if(a(e,o)){var c=void 0;try{if("function"!=typeof e[o]){var i=Error((s||"React class")+": "+r+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw i.name="Invariant Violation",i}c=e[o](t,o,s,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(u){c=u}!c||c instanceof Error||(W(n),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",r,o,typeof c),W(null)),c instanceof Error&&!(c.message in z)&&(z[c.message]=!0,W(n),h("Failed %s type: %s",r,c.message),W(null))}}(t,e.props,"prop",s,e)}else void 0===r.PropTypes||Z||(Z=!0,h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ue={};function le(e,r,n,o,v,b){var w=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===i||e===c||e===p||e===f||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===g||e.$$typeof===u||e.$$typeof===l||e.$$typeof===d||e.$$typeof===t||void 0!==e.getModuleId)}(e);if(!w){var _,S="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),S+=ne(),null===e?_="null":B(e)?_="array":void 0!==e&&e.$$typeof===s?(_="<"+(k(e.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,S)}var C=Q(e,r,n,v,b);if(null==C)return C;if(w){var E=r.children;if(void 0!==E)if(o)if(B(E)){for(var T=0;T<E.length;T++)ce(E[T],e);Object.freeze&&Object.freeze(E)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ce(E,e)}if(V.call(r,"key")){var j=k(e),O=Object.keys(r).filter(function(e){return"key"!==e}),I=O.length>0?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}";ue[j+I]||(h('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',I,j,O.length>0?"{"+O.join(": ..., ")+": ...}":"{}",j),ue[j+I]=!0)}return e===a?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var s=t[r];if("children"!==s&&"key"!==s){re(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),re(null);break}}null!==e.ref&&(re(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}(C):ie(C),C}var de=function(e,t,r){return le(e,t,r,!1)},pe=function(e,t,r){return le(e,t,r,!0)};o.Fragment=a,o.jsx=de,o.jsxs=pe}()),o);var c=s.exports;const i="https://events.embeddable.co";function u(){const{config:e}=g();if(!e)throw new Error("No Embeddable configuration found. Make sure to wrap your app with EmbeddableProvider and provide a valid config.");return e}const l=()=>{const{widgetId:t,mode:r}=u(),s=`${i}/api`,[n,a]=e.useState(!1),o=e.useCallback(async e=>{if(!t||"preview"===r)return[];const n=[];try{a(!0);const r=await fetch(`${s}/marketing/track`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify({widgetId:t,capabilityId:"trackEvent",inputs:e})}),o=await r.json();o.success?o.results?o.results.forEach(e=>{n.push({success:e.success,integrationKey:e.integrationKey,data:e.data,error:e.error})}):n.push({success:!0,data:o.data}):n.push({success:!1,error:o.error||"Unknown error"})}catch(o){n.push({success:!1,error:o instanceof Error?o.message:"Network error"})}finally{a(!1)}return n},[t,s,r]),c=e.useCallback(async(e={})=>o({event_name:"page_view",event_category:"engagement",custom_parameters:{page_url:window.location.href,page_title:document.title,referrer:document.referrer,...e}}),[o]),l=e.useCallback(async(e,t={})=>o({event_name:"form_submit",event_category:"conversion",custom_parameters:{form_data:e,...t}}),[o]),d=e.useCallback(async(e,t={})=>{let r={};return r="string"==typeof e?{element_selector:e}:{element_id:e.id,element_class:e.className,element_text:e.textContent||e.innerText,element_tag:e.tagName.toLowerCase()},o({event_name:"button_click",event_category:"interaction",custom_parameters:{...r,...t}})},[o]),p=e.useCallback(async(e,t,r={})=>o({event_name:"conversion",event_category:"conversion",value:t,custom_parameters:{conversion_type:e,currency:r.currency||"USD",...r}}),[o]),f=e.useCallback(async(e,t={})=>o({event_name:"signup",event_category:"conversion",user_data:e,custom_parameters:t}),[o]),g=e.useCallback(async(e,t={})=>o({event_name:"purchase",event_category:"ecommerce",value:e.amount,custom_parameters:{transaction_id:e.id,currency:e.currency||"USD",items:e.items||[],...t}}),[o]),m=e.useCallback(()=>{c()},[c]),y=e.useCallback(()=>{const e=async e=>{try{const t=e.target,r=new FormData(t),s=Object.fromEntries(r.entries());await l(s,{form_id:t.id,form_class:t.className,form_action:t.action,form_method:t.method})}catch(t){}};return document.addEventListener("submit",e),()=>{document.removeEventListener("submit",e)}},[l]),v=e.useCallback((e='button, .btn, [role="button"], a, input[type="submit"]')=>{const t=async t=>{const r=t.target.closest(e);if(r)try{await d(r)}catch(s){}};return document.addEventListener("click",t),()=>{document.removeEventListener("click",t)}},[d]);return{isLoading:n,track:o,trackPageView:c,trackFormSubmit:l,trackClick:d,trackConversion:p,trackSignup:f,trackPurchase:g,enableAutoPageView:m,enableAutoFormTracking:y,enableAutoClickTracking:v}};const d={version:"latest",mode:"embeddable",ignoreCache:!1,lazyLoad:!1,loader:!0,widgetId:"",_containerId:"",_shadowRoot:void 0},p=e.createContext({config:{...d},setConfig:()=>{},data:{},setData:()=>{}});function f(){const{trackPageView:t}=l(),{config:r}=g();return e.useEffect(()=>{(null==r?void 0:r.widgetId)&&"preview"!==(null==r?void 0:r.mode)&&t()},[null==r?void 0:r.widgetId,null==r?void 0:r.mode,t]),null}function g(){const t=e.useContext(p);if(!t)throw new Error("useEmbeddableContext must be used within an EmbeddableProvider");return t}exports.EmbeddableProvider=function({config:t,data:r,children:s}){const[n,a]=e.useState(d),[o,i]=e.useState(r||{});return e.useEffect(()=>{const e={...d,...t};a(e)},[t]),e.useEffect(()=>{const e=e=>{("https://embeddable.co"===e.origin||e.origin.includes("localhost"))&&e.data&&"object"==typeof e.data&&"embeddable-update-data"===e.data.type&&i(e.data.data||{})};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[]),c.jsxs(p.Provider,{value:{config:n,setConfig:a,data:o,setData:i},children:[c.jsx(f,{}),s]})},exports.useAI=function(t){const{widgetId:r}=u(),s=e.useRef(t);s.current=t;const[n,a]=e.useState({loading:!1,error:null,success:!1});return{...n,callAI:e.useCallback(async(e,t)=>{var n;a({loading:!0,error:null,success:!1});try{const o={widgetId:r,capabilityId:"aiCall",integrationKey:s.current.platform,prompt:e,history:t||[],inputs:s.current.inputs||{}};"embeddable-ai"!==s.current.platform&&(delete o.inputs.systemPrompt,delete o.inputs.maxTokens);const c=await fetch(`${i}/api/execute/ai`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(o)}),u=await c.json();if(!c.ok){const e=u.message||u.error||`HTTP ${c.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(u.success)return a({loading:!1,error:null,success:!0}),{success:!0,message:(null==(n=u.data)?void 0:n.response)||"AI call completed successfully",data:u.data,metadata:u.metadata};{const e=u.message||u.error||"AI call failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(o){const e=o instanceof Error?o.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useCalendar=function(t={}){const{widgetId:r}=u(),[s,n]=e.useState({loading:!1,error:null,success:!1}),a=e.useCallback(async(e,s={})=>{var a,o,c,u;n({loading:!0,error:null,success:!1});try{const u={widgetId:r,action:e,...s},l=await fetch(`${i}/api/execute/google-calendar`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(u)}),d=await l.json();if(!l.ok){const e=d.message||d.error||`HTTP ${l.status}`;return n({loading:!1,error:e,success:!1}),null==(a=t.onError)||a.call(t,e),{success:!1,message:e}}if(d.success)return n({loading:!1,error:null,success:!0}),null==(o=t.onSuccess)||o.call(t,d.data),{success:!0,message:"Calendar operation completed successfully",data:d.data,metadata:d.metadata};{const e=d.message||d.error||"Calendar operation failed";return n({loading:!1,error:e,success:!1}),null==(c=t.onError)||c.call(t,e),{success:!1,message:e}}}catch(l){const e=l instanceof Error?l.message:"Unknown error occurred";return n({loading:!1,error:e,success:!1}),null==(u=t.onError)||u.call(t,e),{success:!1,message:e}}},[r,t]);return{...s,getCalendar:e.useCallback(async()=>a("get_calendar"),[a]),listEvents:e.useCallback(async(e={})=>a("list_events",{options:e}),[a]),getEvent:e.useCallback(async e=>a("get_event",{eventId:e}),[a]),createEvent:e.useCallback(async e=>a("create_event",{eventData:e}),[a]),updateEvent:e.useCallback(async(e,t)=>a("update_event",{eventId:e,eventData:t}),[a]),deleteEvent:e.useCallback(async e=>a("delete_event",{eventId:e}),[a]),getFreeBusy:e.useCallback(async e=>a("get_freebusy",{options:e}),[a]),reset:e.useCallback(()=>{n({loading:!1,error:null,success:!1})},[])}},exports.useDataIntegration=function(t={}){const{widgetId:r}=u(),s=e.useRef(t);s.current=t;const[n,a]=e.useState({loading:!1,error:null,success:!1});return{...n,fetchData:e.useCallback(async()=>{a({loading:!0,error:null,success:!1});try{const e={widgetId:r,capabilityId:s.current.capabilityId||"fetchData",integrationKey:s.current.integrationKey||"sheets"},t=await fetch(`${i}/api/execute/data`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(e)}),n=await t.json();if(!t.ok){const e=n.message||n.error||`HTTP ${t.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(n.success)return a({loading:!1,error:null,success:!0}),{success:!0,message:"Data fetched successfully",data:n.data,metadata:n.metadata};{const e=n.message||n.error||"Data fetch failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(e){const t=e instanceof Error?e.message:"Unknown error occurred";return a({loading:!1,error:t,success:!1}),{success:!1,message:t}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useDebounce=function(t,r){const[s,n]=e.useState(t);return e.useEffect(()=>{const e=setTimeout(()=>{n(t)},r);return()=>{clearTimeout(e)}},[t,r]),s},exports.useEmbeddableConfig=u,exports.useEmbeddableContext=g,exports.useEmbeddableData=function(){const{data:e}=g();return{data:e}},exports.useEventTracking=l,exports.useFileUpload=function(){const{widgetId:t}=u(),[r,s]=e.useState({loading:!1,error:null,success:!1});return{...r,uploadFile:e.useCallback(async e=>{s({loading:!0,error:null,success:!1});try{const r=new FormData;r.append("file",e),r.append("widgetId",t);const n=await fetch(`${i}/api/execute/uploads`,{method:"POST",credentials:"omit",body:r}),a=await n.json();if(!n.ok){const e=a.message||a.error||`HTTP ${n.status}`;return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(a.success)return s({loading:!1,error:null,success:!0}),{success:!0,message:a.message||"File uploaded successfully",data:a.data};{const e=a.message||a.error||"File upload failed";return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(r){const e=r instanceof Error?r.message:"Unknown error occurred";return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[t]),reset:e.useCallback(()=>{s({loading:!1,error:null,success:!1})},[])}},exports.useFormSubmission=function(t){const{widgetId:r}=u(),s=e.useRef(t);s.current=t;const[n,a]=e.useState({loading:!1,error:null,success:!1});return{...n,submit:e.useCallback(async e=>{var t,n,o,c,u;a({loading:!0,error:null,success:!1});try{if(null==(t=s.current)?void 0:t.validatePayload){const t=s.current.validatePayload(e);if(t)return a({loading:!1,error:t,success:!1}),{success:!1,message:t}}const l={payload:e,widgetId:r,collectionName:(null==(n=s.current)?void 0:n.collectionName)||"submissions"},d=await fetch(`${i}/api/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(l)}),p=await d.json();if(!d.ok){const e=p.message||p.error||`HTTP ${d.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(p.success)return a({loading:!1,error:null,success:!0}),{id:(null==(o=p.data)?void 0:o.id)||(null==(c=p.data)?void 0:c._id),success:!0,message:(null==(u=p.data)?void 0:u.message)||"Submission successful"};{const e=p.message||p.error||"Submission failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(l){const e=l instanceof Error?l.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useLocalStorage=function(r,s,n={}){const{widgetId:a}=u(),o=e.useMemo(()=>({...n,prefix:`embd-${a}-${n.prefix||""}`}),[a,n]),[c,i]=e.useState(()=>{const e=t.storage.get(r,o);return null!==e?e:s}),l=e.useCallback(e=>{try{const s=e instanceof Function?e(c):e;i(s),t.storage.set(r,s,o)}catch(s){}},[r,c,o]),d=e.useCallback(()=>{try{i(s),t.storage.remove(r,o)}catch(e){}},[r,s,o]);return e.useEffect(()=>{const e=e=>{const t=o.prefix+r;if(e.key===t&&null!==e.newValue)try{const{deserialize:t=JSON.parse}=o,r=t(e.newValue);i(r)}catch(s){}};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[r,o]),[c,l,d]},exports.usePayment=function(t={}){const{widgetId:r}=u(),s=e.useRef(t);s.current=t;const[n,a]=e.useState({loading:!1,error:null,success:!1}),o=e.useRef(null);e.useEffect(()=>()=>{o.current&&window.clearInterval(o.current)},[]);const c=e.useCallback(async e=>{var t,n,c,u;try{const l=await fetch(`${i}/api/execute/payments/session/${e}?widgetId=${r}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"omit"}),d=await l.json();if(!l.ok)return;if(d.success&&d.session){const{status:e,payment_status:r}=d.session;"paid"===r&&"complete"===e?(o.current&&(window.clearInterval(o.current),o.current=null),a({loading:!1,error:null,success:!0}),null==(n=(t=s.current).onSuccess)||n.call(t,d.session)):"expired"===e&&(o.current&&(window.clearInterval(o.current),o.current=null),a({loading:!1,error:"Payment session expired",success:!1}),null==(u=(c=s.current).onFailure)||u.call(c,d.session))}}catch(l){}},[r]),l=e.useCallback(e=>{o.current&&window.clearInterval(o.current),o.current=window.setInterval(()=>{c(e)},1e4),c(e)},[c]);return{...n,createCheckout:e.useCallback(async e=>{var t;a({loading:!0,error:null,success:!1});try{const n={widgetId:r,capabilityId:s.current.capabilityId||"getCheckout",integrationKey:s.current.integrationKey||"stripe",inputs:e},o=await fetch(`${i}/api/execute/payments`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(n)}),c=await o.json();if(!o.ok){const e=c.message||c.error||`HTTP ${o.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(c.success)return(null==(t=c.data)?void 0:t.sessionId)&&l(c.data.sessionId),a({loading:!1,error:null,success:!1}),{success:!0,message:"Checkout session created successfully",data:c.data,metadata:c.metadata};{const e=c.message||c.error||"Payment checkout failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(n){const e=n instanceof Error?n.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r,l]),reset:e.useCallback(()=>{o.current&&(window.clearInterval(o.current),o.current=null),a({loading:!1,error:null,success:!1})},[])}},exports.usePublicSubmissions=function(t){const{widgetId:r}=u(),s=e.useRef(t);s.current=t;const[n,a]=e.useState({loading:!1,error:null,data:null,pagination:null}),o=e.useCallback(async e=>{a(e=>({...e,loading:!0,error:null}));try{const t={...s.current,...e},n=new URLSearchParams;n.append("widgetId",r),(null==t?void 0:t.collectionName)&&n.append("collectionName",t.collectionName),n.append("page",String((null==t?void 0:t.page)||1)),n.append("limit",String((null==t?void 0:t.limit)||10)),n.append("sortBy",(null==t?void 0:t.sortBy)||"createdAt"),n.append("sortOrder",(null==t?void 0:t.sortOrder)||"desc"),(null==t?void 0:t.fromDate)&&n.append("fromDate",t.fromDate),(null==t?void 0:t.toDate)&&n.append("toDate",t.toDate);const o=await fetch(`${i}/api/submissions/public?${n.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"omit"}),c=await o.json();if(!o.ok){const e=c.message||c.error||`HTTP ${o.status}`;return a(t=>({...t,loading:!1,error:e})),{success:!1,data:[],pagination:{page:1,limit:10,total:0,pages:0},message:e}}if(c.success)return a(e=>({...e,loading:!1,error:null,data:c.data||[],pagination:c.pagination||{page:1,limit:10,total:0,pages:0}})),{success:!0,data:c.data||[],pagination:c.pagination||{page:1,limit:10,total:0,pages:0}};{const e=c.message||c.error||"Failed to fetch submissions";return a(t=>({...t,loading:!1,error:e})),{success:!1,data:[],pagination:{page:1,limit:10,total:0,pages:0},message:e}}}catch(t){const e=t instanceof Error?t.message:"Unknown error occurred";return a(t=>({...t,loading:!1,error:e})),{success:!1,data:[],pagination:{page:1,limit:10,total:0,pages:0},message:e}}},[r]),c=e.useCallback(()=>{a({loading:!1,error:null,data:null,pagination:null})},[]);return e.useEffect(()=>{const e=s.current;e&&void 0===e.page&&void 0===e.limit||o()},[o]),{...n,fetchSubmissions:o,reset:c}},exports.useScraping=function(){const{widgetId:t}=u(),[r,s]=e.useState({loading:!1,error:null,success:!1});return{...r,scrapeWebsite:e.useCallback(async e=>{s({loading:!0,error:null,success:!1});try{const r={url:e.url,format:e.format||"markdown",options:e.options||{},widgetId:t},n=await fetch(`${i}/api/execute/scraping`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(r)}),a=await n.json();if(!n.ok){const e=a.message||a.error||`HTTP ${n.status}`;return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(a.success)return s({loading:!1,error:null,success:!0}),{success:!0,message:"Website scraped successfully",data:a.data,metadata:a.metadata};{const e=a.message||a.error||"Scraping failed";return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(r){const e=r instanceof Error?r.message:"Unknown error occurred";return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[t]),reset:e.useCallback(()=>{s({loading:!1,error:null,success:!1})},[])}},exports.useVote=function(t){const{widgetId:r}=u(),s=e.useRef(t);s.current=t;const[n,a]=e.useState({loading:!1,error:null,success:!1});return{...n,vote:e.useCallback(async e=>{var t,n,o,c;a({loading:!0,error:null,success:!1});try{const u={voteFor:e,widgetId:r,collectionName:(null==(t=s.current)?void 0:t.collectionName)||"votes"},l=await fetch(`${i}/api/votes`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(u)}),d=await l.json();if(!l.ok){const e=d.message||d.error||`HTTP ${l.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(d.success)return a({loading:!1,error:null,success:!0}),{id:(null==(n=d.data)?void 0:n.id)||(null==(o=d.data)?void 0:o._id),success:!0,message:(null==(c=d.data)?void 0:c.message)||"Vote submitted successfully"};{const e=d.message||d.error||"Vote submission failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(u){const e=u instanceof Error?u.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useVoteAggregations=function(t){const{widgetId:r}=u(),s=e.useRef(t);s.current=t;const[n,a]=e.useState({data:null,loading:!1,error:null}),o=e.useCallback(async()=>{var e;if(!r)return a({data:null,loading:!1,error:"Widget ID is required"}),{success:!1,data:{results:[],summary:{totalVotes:0,totalOptions:0,groupBy:""}}};a(e=>({...e,loading:!0,error:null}));try{const t=(null==(e=s.current)?void 0:e.collectionName)||"votes",n=new URL(`${i}/api/votes/aggregations`);n.searchParams.append("widgetId",r),n.searchParams.append("collectionName",t);const o=await fetch(n.toString(),{method:"GET",headers:{"Content-Type":"application/json"},credentials:"omit"}),c=await o.json();if(!o.ok){const e=c.message||c.error||`HTTP ${o.status}`;return a({data:null,loading:!1,error:e}),{success:!1,data:{results:[],summary:{totalVotes:0,totalOptions:0,groupBy:""}}}}return a({data:c.data,loading:!1,error:null}),c}catch(t){const e=t instanceof Error?t.message:"Unknown error occurred";return a({data:null,loading:!1,error:e}),{success:!1,data:{results:[],summary:{totalVotes:0,totalOptions:0,groupBy:""}}}}},[r]),c=e.useCallback(()=>o(),[o]),l=e.useCallback(()=>{a({data:null,loading:!1,error:null})},[]);return e.useEffect(()=>{const e=s.current;!1!==(null==e?void 0:e.autoFetch)&&r&&o()},[o,r]),e.useEffect(()=>{const e=s.current;if((null==e?void 0:e.refetchInterval)&&e.refetchInterval>0&&r){const t=setInterval(()=>{o()},e.refetchInterval);return()=>clearInterval(t)}},[o,r]),{...n,fetch:o,refetch:c,reset:l}},exports.useYouTube=function(){const{widgetId:t}=u(),[r,s]=e.useState({loading:!1,error:null,success:!1}),n=e.useCallback(async e=>{s({loading:!0,error:null,success:!1});try{const r={widgetId:t,url:e.url,action:e.action,options:e.options||{}},n=await fetch(`${i}/api/execute/youtube`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(r)}),a=await n.json();if(!n.ok){const e=a.message||a.error||`HTTP ${n.status}`;return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(a.success)return s({loading:!1,error:null,success:!0}),{success:!0,message:"YouTube video analyzed successfully",data:a.data,metadata:a.metadata};{const e=a.message||a.error||"YouTube analysis failed";return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(r){const e=r instanceof Error?r.message:"Unknown error occurred";return s({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[t]),a=e.useCallback(async(e,t)=>n({url:e,action:"summarize",options:t}),[n]),o=e.useCallback(async e=>n({url:e,action:"transcript"}),[n]),c=e.useCallback(async e=>n({url:e,action:"stats"}),[n]),l=e.useCallback(()=>{s({loading:!1,error:null,success:!1})},[]);return{...r,analyzeVideo:n,summarizeVideo:a,getTranscript:o,getStats:c,reset:l}};
@@ -1,4 +1,5 @@
1
1
  export { useAI } from './useAI';
2
+ export { useCalendar } from './useCalendar';
2
3
  export { useDataIntegration } from './useDataIntegration';
3
4
  export { useDebounce } from './useDebounce';
4
5
  export { useEmbeddableConfig } from './useEmbeddableConfig';
@@ -12,4 +13,5 @@ export { usePublicSubmissions } from './usePublicSubmissions';
12
13
  export { useScraping } from './useScraping';
13
14
  export { useVote } from './useVote';
14
15
  export { useVoteAggregations } from './useVoteAggregations';
16
+ export { useYouTube } from './useYouTube';
15
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,152 @@
1
+ export interface GoogleCalendar {
2
+ id: string;
3
+ summary: string;
4
+ description?: string;
5
+ timeZone: string;
6
+ colorId?: string;
7
+ backgroundColor?: string;
8
+ foregroundColor?: string;
9
+ accessRole: 'owner' | 'reader' | 'writer' | 'freeBusyReader';
10
+ defaultReminders?: Array<{
11
+ method: 'email' | 'popup';
12
+ minutes: number;
13
+ }>;
14
+ primary?: boolean;
15
+ }
16
+ export interface GoogleCalendarEvent {
17
+ id: string;
18
+ summary: string;
19
+ description?: string;
20
+ location?: string;
21
+ start: {
22
+ dateTime?: string;
23
+ date?: string;
24
+ timeZone?: string;
25
+ };
26
+ end: {
27
+ dateTime?: string;
28
+ date?: string;
29
+ timeZone?: string;
30
+ };
31
+ status: 'confirmed' | 'tentative' | 'cancelled';
32
+ created: string;
33
+ updated: string;
34
+ creator?: {
35
+ email?: string;
36
+ displayName?: string;
37
+ };
38
+ organizer?: {
39
+ email?: string;
40
+ displayName?: string;
41
+ };
42
+ attendees?: Array<{
43
+ email: string;
44
+ displayName?: string;
45
+ responseStatus: 'needsAction' | 'declined' | 'tentative' | 'accepted';
46
+ optional?: boolean;
47
+ }>;
48
+ recurrence?: string[];
49
+ htmlLink: string;
50
+ colorId?: string;
51
+ transparency?: 'opaque' | 'transparent';
52
+ visibility?: 'default' | 'public' | 'private' | 'confidential';
53
+ reminders?: {
54
+ useDefault: boolean;
55
+ overrides?: Array<{
56
+ method: 'email' | 'popup';
57
+ minutes: number;
58
+ }>;
59
+ };
60
+ }
61
+ export interface CreateEventData {
62
+ summary: string;
63
+ description?: string;
64
+ location?: string;
65
+ start: {
66
+ dateTime?: string;
67
+ date?: string;
68
+ timeZone?: string;
69
+ };
70
+ end: {
71
+ dateTime?: string;
72
+ date?: string;
73
+ timeZone?: string;
74
+ };
75
+ attendees?: Array<{
76
+ email: string;
77
+ displayName?: string;
78
+ optional?: boolean;
79
+ }>;
80
+ reminders?: {
81
+ useDefault?: boolean;
82
+ overrides?: Array<{
83
+ method: 'email' | 'popup';
84
+ minutes: number;
85
+ }>;
86
+ };
87
+ colorId?: string;
88
+ transparency?: 'opaque' | 'transparent';
89
+ visibility?: 'default' | 'public' | 'private' | 'confidential';
90
+ recurrence?: string[];
91
+ }
92
+ export interface CalendarListOptions {
93
+ maxResults?: number;
94
+ showDeleted?: boolean;
95
+ showHidden?: boolean;
96
+ }
97
+ export interface EventListOptions {
98
+ timeMin?: string;
99
+ timeMax?: string;
100
+ from?: string;
101
+ to?: string;
102
+ maxResults?: number;
103
+ singleEvents?: boolean;
104
+ orderBy?: 'startTime' | 'updated';
105
+ showDeleted?: boolean;
106
+ q?: string;
107
+ }
108
+ export interface FreeBusyOptions {
109
+ timeMin: string;
110
+ timeMax: string;
111
+ }
112
+ export interface CalendarResponse<T> {
113
+ success: boolean;
114
+ message?: string;
115
+ error?: string;
116
+ data?: T;
117
+ metadata?: {
118
+ executedAt: string;
119
+ integrationKey: string;
120
+ capabilityId: string;
121
+ credentialName: string;
122
+ action: string;
123
+ nextPageToken?: string;
124
+ totalResults?: number;
125
+ };
126
+ }
127
+ interface UseCalendarOptions {
128
+ capabilityId?: string;
129
+ integrationKey?: string;
130
+ onSuccess?: (data: any) => void;
131
+ onError?: (error: string) => void;
132
+ }
133
+ /**
134
+ * React hook for Google Calendar operations
135
+ * @param options - Configuration including capability ID, integration key, and callbacks
136
+ * @returns Object with calendar functions and state management
137
+ */
138
+ export declare function useCalendar(options?: UseCalendarOptions): {
139
+ getCalendar: () => Promise<CalendarResponse<GoogleCalendar>>;
140
+ listEvents: (eventOptions?: EventListOptions) => Promise<CalendarResponse<GoogleCalendarEvent[]>>;
141
+ getEvent: (eventId: string) => Promise<CalendarResponse<GoogleCalendarEvent>>;
142
+ createEvent: (eventData: CreateEventData) => Promise<CalendarResponse<GoogleCalendarEvent>>;
143
+ updateEvent: (eventId: string, eventData: Partial<CreateEventData>) => Promise<CalendarResponse<GoogleCalendarEvent>>;
144
+ deleteEvent: (eventId: string) => Promise<CalendarResponse<void>>;
145
+ getFreeBusy: (freeBusyOptions: FreeBusyOptions) => Promise<CalendarResponse<any>>;
146
+ reset: () => void;
147
+ loading: boolean;
148
+ error: string | null;
149
+ success: boolean;
150
+ };
151
+ export {};
152
+ //# sourceMappingURL=useCalendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCalendar.d.ts","sourceRoot":"","sources":["../../src/hooks/useCalendar.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,77 @@
1
+ type YouTubeActionType = 'summarize' | 'transcript' | 'stats';
2
+ interface YouTubeOptions {
3
+ customResponse?: Record<string, string> | string;
4
+ customPrompt?: string;
5
+ }
6
+ interface YouTubeSummaryData {
7
+ url?: string;
8
+ summary?: string;
9
+ mainTopics?: string[];
10
+ keyPoints?: string[];
11
+ tone?: string;
12
+ targetAudience?: string;
13
+ quotes?: string[];
14
+ timeline?: string;
15
+ [key: string]: any;
16
+ }
17
+ interface YouTubeTranscriptData {
18
+ url?: string;
19
+ transcript?: string;
20
+ transcriptSegments?: Array<{
21
+ text: string;
22
+ start: number;
23
+ duration: number;
24
+ timestamp: string;
25
+ }>;
26
+ wordCount?: number;
27
+ segments?: number;
28
+ [key: string]: any;
29
+ }
30
+ interface YouTubeStatsData {
31
+ url?: string;
32
+ title?: string;
33
+ channelName?: string;
34
+ channelLink?: string;
35
+ views?: number;
36
+ likes?: number;
37
+ comments?: number;
38
+ [key: string]: any;
39
+ }
40
+ type YouTubeData = YouTubeSummaryData | YouTubeTranscriptData | YouTubeStatsData;
41
+ interface YouTubeResponseMetadata {
42
+ executedAt: string;
43
+ integrationKey: string;
44
+ capabilityId: string;
45
+ credentialName: string;
46
+ action: YouTubeActionType;
47
+ url: string;
48
+ options: YouTubeOptions;
49
+ }
50
+ interface YouTubeResponse {
51
+ success: boolean;
52
+ message?: string;
53
+ error?: string;
54
+ data?: YouTubeData;
55
+ metadata?: YouTubeResponseMetadata;
56
+ }
57
+ interface YouTubeRequest {
58
+ url: string;
59
+ action: YouTubeActionType;
60
+ options?: YouTubeOptions;
61
+ }
62
+ /**
63
+ * React hook for YouTube video analysis with loading, error states
64
+ * @returns Object with YouTube analysis functions and state management
65
+ */
66
+ export declare function useYouTube(): {
67
+ analyzeVideo: (request: YouTubeRequest) => Promise<YouTubeResponse>;
68
+ summarizeVideo: (url: string, options?: YouTubeOptions) => Promise<YouTubeResponse>;
69
+ getTranscript: (url: string) => Promise<YouTubeResponse>;
70
+ getStats: (url: string) => Promise<YouTubeResponse>;
71
+ reset: () => void;
72
+ loading: boolean;
73
+ error: string | null;
74
+ success: boolean;
75
+ };
76
+ export {};
77
+ //# sourceMappingURL=useYouTube.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useYouTube.d.ts","sourceRoot":"","sources":["../../src/hooks/useYouTube.ts"],"names":[],"mappings":"AAIA,KAAK,iBAAiB,GAAG,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;AAQ9D,UAAU,cAAc;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,UAAU,kBAAkB;IAC1B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,UAAU,qBAAqB;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,KAAK,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAGD,UAAU,gBAAgB;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,WAAW,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;AAEjF,UAAU,uBAAuB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,cAAc,CAAC;CACzB;AAED,UAAU,eAAe;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACpC;AAED,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,UAAU;4BASN,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC;0BAkE7C,MAAM,YAAY,cAAc,KAAG,OAAO,CAAC,eAAe,CAAC;yBAO3D,MAAM,KAAG,OAAO,CAAC,eAAe,CAAC;oBAOjC,MAAM,KAAG,OAAO,CAAC,eAAe,CAAC;;aAxKtC,OAAO;WACT,MAAM,GAAG,IAAI;aACX,OAAO;EAwLjB"}
package/dist/hooks.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./EmbeddableProvider-CGNt-5fg.cjs");exports.useAI=e.useAI,exports.useDataIntegration=e.useDataIntegration,exports.useDebounce=e.useDebounce,exports.useEmbeddableConfig=e.useEmbeddableConfig,exports.useEmbeddableData=e.useEmbeddableData,exports.useEventTracking=e.useEventTracking,exports.useFileUpload=e.useFileUpload,exports.useFormSubmission=e.useFormSubmission,exports.useLocalStorage=e.useLocalStorage,exports.usePayment=e.usePayment,exports.usePublicSubmissions=e.usePublicSubmissions,exports.useScraping=e.useScraping,exports.useVote=e.useVote,exports.useVoteAggregations=e.useVoteAggregations;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./EmbeddableProvider-xfB7Tpj_.cjs");exports.useAI=e.useAI,exports.useCalendar=e.useCalendar,exports.useDataIntegration=e.useDataIntegration,exports.useDebounce=e.useDebounce,exports.useEmbeddableConfig=e.useEmbeddableConfig,exports.useEmbeddableData=e.useEmbeddableData,exports.useEventTracking=e.useEventTracking,exports.useFileUpload=e.useFileUpload,exports.useFormSubmission=e.useFormSubmission,exports.useLocalStorage=e.useLocalStorage,exports.usePayment=e.usePayment,exports.usePublicSubmissions=e.usePublicSubmissions,exports.useScraping=e.useScraping,exports.useVote=e.useVote,exports.useVoteAggregations=e.useVoteAggregations,exports.useYouTube=e.useYouTube;
package/dist/hooks.js CHANGED
@@ -1,17 +1,19 @@
1
- import { a, b, c, d, f, g, e, h, i, j, k, l, m, n } from "./EmbeddableProvider-v_5vMWDf.js";
1
+ import { a, b, c, d, e, g, h, f, i, j, k, l, m, n, o, p } from "./EmbeddableProvider-BfPpR66o.js";
2
2
  export {
3
3
  a as useAI,
4
- b as useDataIntegration,
5
- c as useDebounce,
6
- d as useEmbeddableConfig,
7
- f as useEmbeddableData,
8
- g as useEventTracking,
9
- e as useFileUpload,
10
- h as useFormSubmission,
11
- i as useLocalStorage,
12
- j as usePayment,
13
- k as usePublicSubmissions,
14
- l as useScraping,
15
- m as useVote,
16
- n as useVoteAggregations
4
+ b as useCalendar,
5
+ c as useDataIntegration,
6
+ d as useDebounce,
7
+ e as useEmbeddableConfig,
8
+ g as useEmbeddableData,
9
+ h as useEventTracking,
10
+ f as useFileUpload,
11
+ i as useFormSubmission,
12
+ j as useLocalStorage,
13
+ k as usePayment,
14
+ l as usePublicSubmissions,
15
+ m as useScraping,
16
+ n as useVote,
17
+ o as useVoteAggregations,
18
+ p as useYouTube
17
19
  };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./EmbeddableProvider-CGNt-5fg.cjs"),s=require("./utils.cjs"),o=require("./storage-BtXo3gya.cjs");exports.EmbeddableProvider=e.EmbeddableProvider,exports.useAI=e.useAI,exports.useDataIntegration=e.useDataIntegration,exports.useDebounce=e.useDebounce,exports.useEmbeddableConfig=e.useEmbeddableConfig,exports.useEmbeddableContext=e.useEmbeddableContext,exports.useEmbeddableData=e.useEmbeddableData,exports.useEventTracking=e.useEventTracking,exports.useFileUpload=e.useFileUpload,exports.useFormSubmission=e.useFormSubmission,exports.useLocalStorage=e.useLocalStorage,exports.usePayment=e.usePayment,exports.usePublicSubmissions=e.usePublicSubmissions,exports.useScraping=e.useScraping,exports.useVote=e.useVote,exports.useVoteAggregations=e.useVoteAggregations,exports.createApiClient=s.createApiClient,exports.debounce=s.debounce,exports.storage=o.storage;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./EmbeddableProvider-xfB7Tpj_.cjs"),s=require("./utils.cjs"),o=require("./storage-BtXo3gya.cjs");exports.EmbeddableProvider=e.EmbeddableProvider,exports.useAI=e.useAI,exports.useCalendar=e.useCalendar,exports.useDataIntegration=e.useDataIntegration,exports.useDebounce=e.useDebounce,exports.useEmbeddableConfig=e.useEmbeddableConfig,exports.useEmbeddableContext=e.useEmbeddableContext,exports.useEmbeddableData=e.useEmbeddableData,exports.useEventTracking=e.useEventTracking,exports.useFileUpload=e.useFileUpload,exports.useFormSubmission=e.useFormSubmission,exports.useLocalStorage=e.useLocalStorage,exports.usePayment=e.usePayment,exports.usePublicSubmissions=e.usePublicSubmissions,exports.useScraping=e.useScraping,exports.useVote=e.useVote,exports.useVoteAggregations=e.useVoteAggregations,exports.useYouTube=e.useYouTube,exports.createApiClient=s.createApiClient,exports.debounce=s.debounce,exports.storage=o.storage;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E, a, b, c, d, u, f, g, e, h, i, j, k, l, m, n } from "./EmbeddableProvider-v_5vMWDf.js";
1
+ import { E, a, b, c, d, e, u, g, h, f, i, j, k, l, m, n, o, p } from "./EmbeddableProvider-BfPpR66o.js";
2
2
  import { createApiClient, debounce } from "./utils.js";
3
3
  import { s } from "./storage-B4eeCFyo.js";
4
4
  export {
@@ -7,18 +7,20 @@ export {
7
7
  debounce,
8
8
  s as storage,
9
9
  a as useAI,
10
- b as useDataIntegration,
11
- c as useDebounce,
12
- d as useEmbeddableConfig,
10
+ b as useCalendar,
11
+ c as useDataIntegration,
12
+ d as useDebounce,
13
+ e as useEmbeddableConfig,
13
14
  u as useEmbeddableContext,
14
- f as useEmbeddableData,
15
- g as useEventTracking,
16
- e as useFileUpload,
17
- h as useFormSubmission,
18
- i as useLocalStorage,
19
- j as usePayment,
20
- k as usePublicSubmissions,
21
- l as useScraping,
22
- m as useVote,
23
- n as useVoteAggregations
15
+ g as useEmbeddableData,
16
+ h as useEventTracking,
17
+ f as useFileUpload,
18
+ i as useFormSubmission,
19
+ j as useLocalStorage,
20
+ k as usePayment,
21
+ l as usePublicSubmissions,
22
+ m as useScraping,
23
+ n as useVote,
24
+ o as useVoteAggregations,
25
+ p as useYouTube
24
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddable/sdk",
3
- "version": "1.0.28",
3
+ "version": "1.0.30",
4
4
  "description": "A TypeScript/JavaScript SDK with React utilities and hooks for embeddable applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1,10 +0,0 @@
1
- "use strict";const e=require("react"),t=require("./storage-BtXo3gya.cjs");var r,n={exports:{}},s={};var a,o={};
2
- /**
3
- * @license React
4
- * react-jsx-runtime.development.js
5
- *
6
- * Copyright (c) Facebook, Inc. and its affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */"production"===process.env.NODE_ENV?n.exports=function(){if(r)return s;r=1;var t=e,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var s,a={},u=null,l=null;for(s in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)o.call(t,s)&&!i.hasOwnProperty(s)&&(a[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps)void 0===a[s]&&(a[s]=t[s]);return{$$typeof:n,type:e,key:u,ref:l,props:a,_owner:c.current}}return s.Fragment=a,s.jsx=u,s.jsxs=u,s}():n.exports=(a||(a=1,"production"!==process.env.NODE_ENV&&function(){var t,r=e,n=Symbol.for("react.element"),s=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),l=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),v=Symbol.iterator,b=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];!function(e,t,r){var n=b.ReactDebugCurrentFrame.getStackAddendum();""!==n&&(t+="%s",r=r.concat([n]));var s=r.map(function(e){return String(e)});s.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,s)}("error",e,r)}function w(e){return e.displayName||"Context"}function k(e){if(null==e)return null;if("number"==typeof e.tag&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case a:return"Fragment";case s:return"Portal";case i:return"Profiler";case c:return"StrictMode";case f:return"Suspense";case p:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case l:return w(e)+".Consumer";case u:return w(e._context)+".Provider";case d:return function(e,t,r){var n=e.displayName;if(n)return n;var s=t.displayName||t.name||"";return""!==s?r+"("+s+")":r}(e,e.render,"ForwardRef");case g:var t=e.displayName||null;return null!==t?t:k(e.type)||"Memo";case m:var r=e,n=r._payload,o=r._init;try{return k(o(n))}catch(y){return null}}return null}t=Symbol.for("react.module.reference");var _,S,E,C,T,j,O,I=Object.assign,P=0;function x(){}x.__reactDisabledLog=!0;var R,$=b.ReactCurrentDispatcher;function N(e,t,r){if(void 0===R)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);R=n&&n[1]||""}return"\n"+R+e}var D,F=!1,L="function"==typeof WeakMap?WeakMap:Map;function U(e,t){if(!e||F)return"";var r,n=D.get(e);if(void 0!==n)return n;F=!0;var s,a=Error.prepareStackTrace;Error.prepareStackTrace=void 0,s=$.current,$.current=null,function(){if(0===P){_=console.log,S=console.info,E=console.warn,C=console.error,T=console.group,j=console.groupCollapsed,O=console.groupEnd;var e={configurable:!0,enumerable:!0,value:x,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}P++}();try{if(t){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(o,[])}catch(g){r=g}Reflect.construct(e,[],o)}else{try{o.call()}catch(g){r=g}e.call(o.prototype)}}else{try{throw Error()}catch(g){r=g}e()}}catch(m){if(m&&r&&"string"==typeof m.stack){for(var c=m.stack.split("\n"),i=r.stack.split("\n"),u=c.length-1,l=i.length-1;u>=1&&l>=0&&c[u]!==i[l];)l--;for(;u>=1&&l>=0;u--,l--)if(c[u]!==i[l]){if(1!==u||1!==l)do{if(u--,--l<0||c[u]!==i[l]){var d="\n"+c[u].replace(" at new "," at ");return e.displayName&&d.includes("<anonymous>")&&(d=d.replace("<anonymous>",e.displayName)),"function"==typeof e&&D.set(e,d),d}}while(u>=1&&l>=0);break}}}finally{F=!1,$.current=s,function(){if(0===--P){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:I({},e,{value:_}),info:I({},e,{value:S}),warn:I({},e,{value:E}),error:I({},e,{value:C}),group:I({},e,{value:T}),groupCollapsed:I({},e,{value:j}),groupEnd:I({},e,{value:O})})}P<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=a}var f=e?e.displayName||e.name:"",p=f?N(f):"";return"function"==typeof e&&D.set(e,p),p}function A(e,t,r){if(null==e)return"";if("function"==typeof e)return U(e,!(!(n=e.prototype)||!n.isReactComponent));var n;if("string"==typeof e)return N(e);switch(e){case f:return N("Suspense");case p:return N("SuspenseList")}if("object"==typeof e)switch(e.$$typeof){case d:return U(e.render,!1);case g:return A(e.type,t,r);case m:var s=e,a=s._payload,o=s._init;try{return A(o(a),t,r)}catch(c){}}return""}D=new L;var V=Object.prototype.hasOwnProperty,W={},J=b.ReactDebugCurrentFrame;function H(e){if(e){var t=e._owner,r=A(e.type,e._source,t?t.type:null);J.setExtraStackFrame(r)}else J.setExtraStackFrame(null)}var K=Array.isArray;function z(e){return K(e)}function B(e){return""+e}function M(e){if(function(e){try{return B(e),!1}catch(t){return!0}}(e))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(e){return"function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object"}(e)),B(e)}var Y,q,G=b.ReactCurrentOwner,X={key:!0,ref:!0,__self:!0,__source:!0};function Q(e,t,r,s,a){var o,c={},i=null,u=null;for(o in void 0!==r&&(M(r),i=""+r),function(e){if(V.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(t)&&(M(t.key),i=""+t.key),function(e){if(V.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return void 0!==e.ref}(t)&&(u=t.ref,function(e){"string"==typeof e.ref&&G.current}(t)),t)V.call(t,o)&&!X.hasOwnProperty(o)&&(c[o]=t[o]);if(e&&e.defaultProps){var l=e.defaultProps;for(o in l)void 0===c[o]&&(c[o]=l[o])}if(i||u){var d="function"==typeof e?e.displayName||e.name||"Unknown":e;i&&function(e,t){var r=function(){Y||(Y=!0,h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}(c,d),u&&function(e,t){var r=function(){q||(q=!0,h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}(c,d)}return function(e,t,r,s,a,o,c){var i={$$typeof:n,type:e,key:t,ref:r,props:c,_owner:o,_store:{}};return Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i}(e,i,u,a,s,G.current,c)}var Z,ee=b.ReactCurrentOwner,te=b.ReactDebugCurrentFrame;function re(e){if(e){var t=e._owner,r=A(e.type,e._source,t?t.type:null);te.setExtraStackFrame(r)}else te.setExtraStackFrame(null)}function ne(e){return"object"==typeof e&&null!==e&&e.$$typeof===n}function se(){if(ee.current){var e=k(ee.current.type);if(e)return"\n\nCheck the render method of `"+e+"`."}return""}Z=!1;var ae={};function oe(e,t){if(e._store&&!e._store.validated&&null==e.key){e._store.validated=!0;var r=function(e){var t=se();if(!t){var r="string"==typeof e?e:e.displayName||e.name;r&&(t="\n\nCheck the top-level render call using <"+r+">.")}return t}(t);if(!ae[r]){ae[r]=!0;var n="";e&&e._owner&&e._owner!==ee.current&&(n=" It was passed a child from "+k(e._owner.type)+"."),re(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,n),re(null)}}}function ce(e,t){if("object"==typeof e)if(z(e))for(var r=0;r<e.length;r++){var n=e[r];ne(n)&&oe(n,t)}else if(ne(e))e._store&&(e._store.validated=!0);else if(e){var s=function(e){if(null===e||"object"!=typeof e)return null;var t=v&&e[v]||e["@@iterator"];return"function"==typeof t?t:null}(e);if("function"==typeof s&&s!==e.entries)for(var a,o=s.call(e);!(a=o.next()).done;)ne(a.value)&&oe(a.value,t)}}function ie(e){var t,r=e.type;if(null!=r&&"string"!=typeof r){if("function"==typeof r)t=r.propTypes;else{if("object"!=typeof r||r.$$typeof!==d&&r.$$typeof!==g)return;t=r.propTypes}if(t){var n=k(r);!function(e,t,r,n,s){var a=Function.call.bind(V);for(var o in e)if(a(e,o)){var c=void 0;try{if("function"!=typeof e[o]){var i=Error((n||"React class")+": "+r+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw i.name="Invariant Violation",i}c=e[o](t,o,n,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(u){c=u}!c||c instanceof Error||(H(s),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",r,o,typeof c),H(null)),c instanceof Error&&!(c.message in W)&&(W[c.message]=!0,H(s),h("Failed %s type: %s",r,c.message),H(null))}}(t,e.props,"prop",n,e)}else void 0===r.PropTypes||Z||(Z=!0,h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",k(r)||"Unknown"));"function"!=typeof r.getDefaultProps||r.getDefaultProps.isReactClassApproved||h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}var ue={};function le(e,r,s,o,v,b){var w=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===i||e===c||e===f||e===p||e===y||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===g||e.$$typeof===u||e.$$typeof===l||e.$$typeof===d||e.$$typeof===t||void 0!==e.getModuleId)}(e);if(!w){var _,S="";(void 0===e||"object"==typeof e&&null!==e&&0===Object.keys(e).length)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),S+=se(),null===e?_="null":z(e)?_="array":void 0!==e&&e.$$typeof===n?(_="<"+(k(e.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,S)}var E=Q(e,r,s,v,b);if(null==E)return E;if(w){var C=r.children;if(void 0!==C)if(o)if(z(C)){for(var T=0;T<C.length;T++)ce(C[T],e);Object.freeze&&Object.freeze(C)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ce(C,e)}if(V.call(r,"key")){var j=k(e),O=Object.keys(r).filter(function(e){return"key"!==e}),I=O.length>0?"{key: someKey, "+O.join(": ..., ")+": ...}":"{key: someKey}";ue[j+I]||(h('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',I,j,O.length>0?"{"+O.join(": ..., ")+": ...}":"{}",j),ue[j+I]=!0)}return e===a?function(e){for(var t=Object.keys(e.props),r=0;r<t.length;r++){var n=t[r];if("children"!==n&&"key"!==n){re(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),re(null);break}}null!==e.ref&&(re(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),re(null))}(E):ie(E),E}var de=function(e,t,r){return le(e,t,r,!1)},fe=function(e,t,r){return le(e,t,r,!0)};o.Fragment=a,o.jsx=de,o.jsxs=fe}()),o);var c=n.exports;const i="https://events.embeddable.co";function u(){const{config:e}=g();if(!e)throw new Error("No Embeddable configuration found. Make sure to wrap your app with EmbeddableProvider and provide a valid config.");return e}const l=()=>{const{widgetId:t,mode:r}=u(),n=`${i}/api`,[s,a]=e.useState(!1),o=e.useCallback(async e=>{if(!t||"preview"===r)return[];const s=[];try{a(!0);const r=await fetch(`${n}/marketing/track`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify({widgetId:t,capabilityId:"trackEvent",inputs:e})}),o=await r.json();o.success?o.results?o.results.forEach(e=>{s.push({success:e.success,integrationKey:e.integrationKey,data:e.data,error:e.error})}):s.push({success:!0,data:o.data}):s.push({success:!1,error:o.error||"Unknown error"})}catch(o){s.push({success:!1,error:o instanceof Error?o.message:"Network error"})}finally{a(!1)}return s},[t,n,r]),c=e.useCallback(async(e={})=>o({event_name:"page_view",event_category:"engagement",custom_parameters:{page_url:window.location.href,page_title:document.title,referrer:document.referrer,...e}}),[o]),l=e.useCallback(async(e,t={})=>o({event_name:"form_submit",event_category:"conversion",custom_parameters:{form_data:e,...t}}),[o]),d=e.useCallback(async(e,t={})=>{let r={};return r="string"==typeof e?{element_selector:e}:{element_id:e.id,element_class:e.className,element_text:e.textContent||e.innerText,element_tag:e.tagName.toLowerCase()},o({event_name:"button_click",event_category:"interaction",custom_parameters:{...r,...t}})},[o]),f=e.useCallback(async(e,t,r={})=>o({event_name:"conversion",event_category:"conversion",value:t,custom_parameters:{conversion_type:e,currency:r.currency||"USD",...r}}),[o]),p=e.useCallback(async(e,t={})=>o({event_name:"signup",event_category:"conversion",user_data:e,custom_parameters:t}),[o]),g=e.useCallback(async(e,t={})=>o({event_name:"purchase",event_category:"ecommerce",value:e.amount,custom_parameters:{transaction_id:e.id,currency:e.currency||"USD",items:e.items||[],...t}}),[o]),m=e.useCallback(()=>{c()},[c]),y=e.useCallback(()=>{const e=async e=>{try{const t=e.target,r=new FormData(t),n=Object.fromEntries(r.entries());await l(n,{form_id:t.id,form_class:t.className,form_action:t.action,form_method:t.method})}catch(t){}};return document.addEventListener("submit",e),()=>{document.removeEventListener("submit",e)}},[l]),v=e.useCallback((e='button, .btn, [role="button"], a, input[type="submit"]')=>{const t=async t=>{const r=t.target.closest(e);if(r)try{await d(r)}catch(n){}};return document.addEventListener("click",t),()=>{document.removeEventListener("click",t)}},[d]);return{isLoading:s,track:o,trackPageView:c,trackFormSubmit:l,trackClick:d,trackConversion:f,trackSignup:p,trackPurchase:g,enableAutoPageView:m,enableAutoFormTracking:y,enableAutoClickTracking:v}};const d={version:"latest",mode:"embeddable",ignoreCache:!1,lazyLoad:!1,loader:!0,widgetId:"",_containerId:"",_shadowRoot:void 0},f=e.createContext({config:{...d},setConfig:()=>{},data:{},setData:()=>{}});function p(){const{trackPageView:t}=l(),{config:r}=g();return e.useEffect(()=>{(null==r?void 0:r.widgetId)&&"preview"!==(null==r?void 0:r.mode)&&t()},[null==r?void 0:r.widgetId,null==r?void 0:r.mode,t]),null}function g(){const t=e.useContext(f);if(!t)throw new Error("useEmbeddableContext must be used within an EmbeddableProvider");return t}exports.EmbeddableProvider=function({config:t,data:r,children:n}){const[s,a]=e.useState(d),[o,i]=e.useState(r||{});return e.useEffect(()=>{const e={...d,...t};a(e)},[t]),e.useEffect(()=>{const e=e=>{("https://embeddable.co"===e.origin||e.origin.includes("localhost"))&&e.data&&"object"==typeof e.data&&"embeddable-update-data"===e.data.type&&i(e.data.data||{})};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}},[]),c.jsxs(f.Provider,{value:{config:s,setConfig:a,data:o,setData:i},children:[c.jsx(p,{}),n]})},exports.useAI=function(t){const{widgetId:r}=u(),n=e.useRef(t);n.current=t;const[s,a]=e.useState({loading:!1,error:null,success:!1});return{...s,callAI:e.useCallback(async(e,t)=>{var s;a({loading:!0,error:null,success:!1});try{const o={widgetId:r,capabilityId:"aiCall",integrationKey:n.current.platform,prompt:e,history:t||[],inputs:n.current.inputs||{}};"embeddable-ai"!==n.current.platform&&(delete o.inputs.systemPrompt,delete o.inputs.maxTokens);const c=await fetch(`${i}/api/execute/ai`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(o)}),u=await c.json();if(!c.ok){const e=u.message||u.error||`HTTP ${c.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(u.success)return a({loading:!1,error:null,success:!0}),{success:!0,message:(null==(s=u.data)?void 0:s.response)||"AI call completed successfully",data:u.data,metadata:u.metadata};{const e=u.message||u.error||"AI call failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(o){const e=o instanceof Error?o.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useDataIntegration=function(t={}){const{widgetId:r}=u(),n=e.useRef(t);n.current=t;const[s,a]=e.useState({loading:!1,error:null,success:!1});return{...s,fetchData:e.useCallback(async()=>{a({loading:!0,error:null,success:!1});try{const e={widgetId:r,capabilityId:n.current.capabilityId||"fetchData",integrationKey:n.current.integrationKey||"sheets"},t=await fetch(`${i}/api/execute/data`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(e)}),s=await t.json();if(!t.ok){const e=s.message||s.error||`HTTP ${t.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(s.success)return a({loading:!1,error:null,success:!0}),{success:!0,message:"Data fetched successfully",data:s.data,metadata:s.metadata};{const e=s.message||s.error||"Data fetch failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(e){const t=e instanceof Error?e.message:"Unknown error occurred";return a({loading:!1,error:t,success:!1}),{success:!1,message:t}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useDebounce=function(t,r){const[n,s]=e.useState(t);return e.useEffect(()=>{const e=setTimeout(()=>{s(t)},r);return()=>{clearTimeout(e)}},[t,r]),n},exports.useEmbeddableConfig=u,exports.useEmbeddableContext=g,exports.useEmbeddableData=function(){const{data:e}=g();return{data:e}},exports.useEventTracking=l,exports.useFileUpload=function(){const{widgetId:t}=u(),[r,n]=e.useState({loading:!1,error:null,success:!1});return{...r,uploadFile:e.useCallback(async e=>{n({loading:!0,error:null,success:!1});try{const r=new FormData;r.append("file",e),r.append("widgetId",t);const s=await fetch(`${i}/api/execute/uploads`,{method:"POST",credentials:"omit",body:r}),a=await s.json();if(!s.ok){const e=a.message||a.error||`HTTP ${s.status}`;return n({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(a.success)return n({loading:!1,error:null,success:!0}),{success:!0,message:a.message||"File uploaded successfully",data:a.data};{const e=a.message||a.error||"File upload failed";return n({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(r){const e=r instanceof Error?r.message:"Unknown error occurred";return n({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[t]),reset:e.useCallback(()=>{n({loading:!1,error:null,success:!1})},[])}},exports.useFormSubmission=function(t){const{widgetId:r}=u(),n=e.useRef(t);n.current=t;const[s,a]=e.useState({loading:!1,error:null,success:!1});return{...s,submit:e.useCallback(async e=>{var t,s,o,c,u;a({loading:!0,error:null,success:!1});try{if(null==(t=n.current)?void 0:t.validatePayload){const t=n.current.validatePayload(e);if(t)return a({loading:!1,error:t,success:!1}),{success:!1,message:t}}const l={payload:e,widgetId:r,collectionName:(null==(s=n.current)?void 0:s.collectionName)||"submissions"},d=await fetch(`${i}/api/submissions`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(l)}),f=await d.json();if(!d.ok){const e=f.message||f.error||`HTTP ${d.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(f.success)return a({loading:!1,error:null,success:!0}),{id:(null==(o=f.data)?void 0:o.id)||(null==(c=f.data)?void 0:c._id),success:!0,message:(null==(u=f.data)?void 0:u.message)||"Submission successful"};{const e=f.message||f.error||"Submission failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(l){const e=l instanceof Error?l.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useLocalStorage=function(r,n,s={}){const{widgetId:a}=u(),o=e.useMemo(()=>({...s,prefix:`embd-${a}-${s.prefix||""}`}),[a,s]),[c,i]=e.useState(()=>{const e=t.storage.get(r,o);return null!==e?e:n}),l=e.useCallback(e=>{try{const n=e instanceof Function?e(c):e;i(n),t.storage.set(r,n,o)}catch(n){}},[r,c,o]),d=e.useCallback(()=>{try{i(n),t.storage.remove(r,o)}catch(e){}},[r,n,o]);return e.useEffect(()=>{const e=e=>{const t=o.prefix+r;if(e.key===t&&null!==e.newValue)try{const{deserialize:t=JSON.parse}=o,r=t(e.newValue);i(r)}catch(n){}};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[r,o]),[c,l,d]},exports.usePayment=function(t={}){const{widgetId:r}=u(),n=e.useRef(t);n.current=t;const[s,a]=e.useState({loading:!1,error:null,success:!1}),o=e.useRef(null);e.useEffect(()=>()=>{o.current&&window.clearInterval(o.current)},[]);const c=e.useCallback(async e=>{var t,s,c,u;try{const l=await fetch(`${i}/api/execute/payments/session/${e}?widgetId=${r}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"omit"}),d=await l.json();if(!l.ok)return;if(d.success&&d.session){const{status:e,payment_status:r}=d.session;"paid"===r&&"complete"===e?(o.current&&(window.clearInterval(o.current),o.current=null),a({loading:!1,error:null,success:!0}),null==(s=(t=n.current).onSuccess)||s.call(t,d.session)):"expired"===e&&(o.current&&(window.clearInterval(o.current),o.current=null),a({loading:!1,error:"Payment session expired",success:!1}),null==(u=(c=n.current).onFailure)||u.call(c,d.session))}}catch(l){}},[r]),l=e.useCallback(e=>{o.current&&window.clearInterval(o.current),o.current=window.setInterval(()=>{c(e)},1e4),c(e)},[c]);return{...s,createCheckout:e.useCallback(async e=>{var t;a({loading:!0,error:null,success:!1});try{const s={widgetId:r,capabilityId:n.current.capabilityId||"getCheckout",integrationKey:n.current.integrationKey||"stripe",inputs:e},o=await fetch(`${i}/api/execute/payments`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(s)}),c=await o.json();if(!o.ok){const e=c.message||c.error||`HTTP ${o.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(c.success)return(null==(t=c.data)?void 0:t.sessionId)&&l(c.data.sessionId),a({loading:!1,error:null,success:!1}),{success:!0,message:"Checkout session created successfully",data:c.data,metadata:c.metadata};{const e=c.message||c.error||"Payment checkout failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(s){const e=s instanceof Error?s.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r,l]),reset:e.useCallback(()=>{o.current&&(window.clearInterval(o.current),o.current=null),a({loading:!1,error:null,success:!1})},[])}},exports.usePublicSubmissions=function(t){const{widgetId:r}=u(),n=e.useRef(t);n.current=t;const[s,a]=e.useState({loading:!1,error:null,data:null,pagination:null}),o=e.useCallback(async e=>{a(e=>({...e,loading:!0,error:null}));try{const t={...n.current,...e},s=new URLSearchParams;s.append("widgetId",r),(null==t?void 0:t.collectionName)&&s.append("collectionName",t.collectionName),s.append("page",String((null==t?void 0:t.page)||1)),s.append("limit",String((null==t?void 0:t.limit)||10)),s.append("sortBy",(null==t?void 0:t.sortBy)||"createdAt"),s.append("sortOrder",(null==t?void 0:t.sortOrder)||"desc"),(null==t?void 0:t.fromDate)&&s.append("fromDate",t.fromDate),(null==t?void 0:t.toDate)&&s.append("toDate",t.toDate);const o=await fetch(`${i}/api/submissions/public?${s.toString()}`,{method:"GET",headers:{"Content-Type":"application/json"},credentials:"omit"}),c=await o.json();if(!o.ok){const e=c.message||c.error||`HTTP ${o.status}`;return a(t=>({...t,loading:!1,error:e})),{success:!1,data:[],pagination:{page:1,limit:10,total:0,pages:0},message:e}}if(c.success)return a(e=>({...e,loading:!1,error:null,data:c.data||[],pagination:c.pagination||{page:1,limit:10,total:0,pages:0}})),{success:!0,data:c.data||[],pagination:c.pagination||{page:1,limit:10,total:0,pages:0}};{const e=c.message||c.error||"Failed to fetch submissions";return a(t=>({...t,loading:!1,error:e})),{success:!1,data:[],pagination:{page:1,limit:10,total:0,pages:0},message:e}}}catch(t){const e=t instanceof Error?t.message:"Unknown error occurred";return a(t=>({...t,loading:!1,error:e})),{success:!1,data:[],pagination:{page:1,limit:10,total:0,pages:0},message:e}}},[r]),c=e.useCallback(()=>{a({loading:!1,error:null,data:null,pagination:null})},[]);return e.useEffect(()=>{const e=n.current;e&&void 0===e.page&&void 0===e.limit||o()},[o]),{...s,fetchSubmissions:o,reset:c}},exports.useScraping=function(){const{widgetId:t}=u(),[r,n]=e.useState({loading:!1,error:null,success:!1});return{...r,scrapeWebsite:e.useCallback(async e=>{n({loading:!0,error:null,success:!1});try{const r={url:e.url,format:e.format||"markdown",options:e.options||{},widgetId:t},s=await fetch(`${i}/api/execute/scraping`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(r)}),a=await s.json();if(!s.ok){const e=a.message||a.error||`HTTP ${s.status}`;return n({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(a.success)return n({loading:!1,error:null,success:!0}),{success:!0,message:"Website scraped successfully",data:a.data,metadata:a.metadata};{const e=a.message||a.error||"Scraping failed";return n({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(r){const e=r instanceof Error?r.message:"Unknown error occurred";return n({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[t]),reset:e.useCallback(()=>{n({loading:!1,error:null,success:!1})},[])}},exports.useVote=function(t){const{widgetId:r}=u(),n=e.useRef(t);n.current=t;const[s,a]=e.useState({loading:!1,error:null,success:!1});return{...s,vote:e.useCallback(async e=>{var t,s,o,c;a({loading:!0,error:null,success:!1});try{const u={voteFor:e,widgetId:r,collectionName:(null==(t=n.current)?void 0:t.collectionName)||"votes"},l=await fetch(`${i}/api/votes`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"omit",body:JSON.stringify(u)}),d=await l.json();if(!l.ok){const e=d.message||d.error||`HTTP ${l.status}`;return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}if(d.success)return a({loading:!1,error:null,success:!0}),{id:(null==(s=d.data)?void 0:s.id)||(null==(o=d.data)?void 0:o._id),success:!0,message:(null==(c=d.data)?void 0:c.message)||"Vote submitted successfully"};{const e=d.message||d.error||"Vote submission failed";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}}catch(u){const e=u instanceof Error?u.message:"Unknown error occurred";return a({loading:!1,error:e,success:!1}),{success:!1,message:e}}},[r]),reset:e.useCallback(()=>{a({loading:!1,error:null,success:!1})},[])}},exports.useVoteAggregations=function(t){const{widgetId:r}=u(),n=e.useRef(t);n.current=t;const[s,a]=e.useState({data:null,loading:!1,error:null}),o=e.useCallback(async()=>{var e;if(!r)return a({data:null,loading:!1,error:"Widget ID is required"}),{success:!1,data:{results:[],summary:{totalVotes:0,totalOptions:0,groupBy:""}}};a(e=>({...e,loading:!0,error:null}));try{const t=(null==(e=n.current)?void 0:e.collectionName)||"votes",s=new URL(`${i}/api/votes/aggregations`);s.searchParams.append("widgetId",r),s.searchParams.append("collectionName",t);const o=await fetch(s.toString(),{method:"GET",headers:{"Content-Type":"application/json"},credentials:"omit"}),c=await o.json();if(!o.ok){const e=c.message||c.error||`HTTP ${o.status}`;return a({data:null,loading:!1,error:e}),{success:!1,data:{results:[],summary:{totalVotes:0,totalOptions:0,groupBy:""}}}}return a({data:c.data,loading:!1,error:null}),c}catch(t){const e=t instanceof Error?t.message:"Unknown error occurred";return a({data:null,loading:!1,error:e}),{success:!1,data:{results:[],summary:{totalVotes:0,totalOptions:0,groupBy:""}}}}},[r]),c=e.useCallback(()=>o(),[o]),l=e.useCallback(()=>{a({data:null,loading:!1,error:null})},[]);return e.useEffect(()=>{const e=n.current;!1!==(null==e?void 0:e.autoFetch)&&r&&o()},[o,r]),e.useEffect(()=>{const e=n.current;if((null==e?void 0:e.refetchInterval)&&e.refetchInterval>0&&r){const t=setInterval(()=>{o()},e.refetchInterval);return()=>clearInterval(t)}},[o,r]),{...s,fetch:o,refetch:c,reset:l}};