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