"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),l=require("react"),i=require("./provider.js"),h=require("./useStreamLayerApp2.js"),p=()=>i.z,S=i.styled_default(p())({name:"QuestionWrap",class:"q10hhsxv",propsAsIs:!0}),f=({gamification:e,persistent:n,skipAutoClose:o,hideHeader:a,insightId:s})=>{const t=l.useRef(""),c=i.useStore(e.openedQuestion.$store);return l.useEffect(()=>s?(!n||e.isOpenedQuestion(s)||(t.current=s,e.getFeedItem(s).then(r=>{var d;t.current===s&&((d=r==null?void 0:r.attributes)==null?void 0:d.attributes.case)==="insight"&&e.openQuestion(s,r)})),()=>{t.current=""}):(e.activeQuestionId.subscribe(({data:r})=>{var d;r&&((d=r.feedItem)==null?void 0:d.type)==="insight"&&(!n||e.isOpenedQuestion(r.feedItem.id)||(t.current=r.feedItem.id,e.openQuestion(r.feedItem.id,r.feedItem))),!r&&t.current&&(e.closeQuestion(t.current),t.current="")}),()=>{}),[e,n,s]),c?u.jsx(S,{skipAutoClose:o,hideHeader:a,gamification:e,hideSponsor:!0}):null},m=({sdk:e,persistent:n,skipAutoClose:o,insightId:a,hideHeader:s})=>{if(!i.useStore(e.featuresList.getStore()))return null;const t=e.getFeature(h.SdkOverlayType.GAMES);return t?u.jsx(f,{insightId:a,persistent:n,hideHeader:s,gamification:t,skipAutoClose:o}):null},g=({event:e,theme:n,hideHeader:o,skipAutoClose:a,persistent:s})=>{const t=i.useStreamLayer(),c=i.useStreamLayerTheme();return t?u.jsxs("div",{className:"StreamLayerSDK",children:[u.jsx(i.h,{customTheme:n??c.theme,themeMode:c.themeMode,children:u.jsx(m,{skipAutoClose:a,sdk:t,hideHeader:o,persistent:s})}),e!==void 0&&u.jsx(i.StreamLayerSDKEvent,{event:e})]}):null};exports.StreamLayerSDKInsight=g;exports.StreamLayerSDKInsightUI=m;
