"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),s=require("react/jsx-runtime"),t=require("react"),a=require("lucide-react"),n=require("../apis/scopeApis.js"),i=require("../components/ErrorStateDisplay.js"),r=require("../components/EmptyLearningState.js"),o=require("../store/useLearningTemplateStore.js"),l=require("../styles/StationsContent.module.css.js"),c=require("../RuleContent/RuleHeader.js");exports.default=function(d){var u=d.scopeId,p=d.scopeName,f=d.stationsCount,h=void 0===f?0:f,_=d.onViewStation,g=d.onDeleteStation,j=t.useState([]),m=j[0],x=j[1],v=t.useState(""),N=v[0],S=v[1],y=t.useState(!1),C=y[0],q=y[1],w=t.useState(null),b=w[0],D=w[1],I=o.useLearningTemplateStore(function(e){return e.setStationModalOpen}),L=function(){return e.__awaiter(void 0,void 0,void 0,function(){var s,t;return e.__generator(this,function(e){switch(e.label){case 0:if(!u)return[2];q(!0),D(null),e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,n.getStationsByScopeId()];case 2:return(s=e.sent())&&s.data?x(s.data):x([]),[3,5];case 3:return t=e.sent(),console.error("Failed to fetch stations:",t),D("Failed to load stations. Please try again."),[3,5];case 4:return q(!1),[7];case 5:return[2]}})})};t.useEffect(function(){L()},[u]);var R=m.filter(function(e){return e.stationName.toLowerCase().includes(N.toLowerCase())});return s.jsxs("div",e.__assign({className:l.default.container},{children:[s.jsxs("div",{children:[s.jsx(c.default,{ruleSetName:"".concat(p," > Stations (").concat(m.length||h,")"),ruleSetDescription:"Manage the stations assigned to the ".concat(p," scope."),onOnboardStation:function(){return I(!0)}}),s.jsx("div",e.__assign({className:l.default.searchBarWrapper},{children:s.jsxs("div",e.__assign({className:l.default.searchRelative},{children:[s.jsx("div",e.__assign({className:l.default.searchIconWrapper},{children:s.jsx(a.Search,{className:l.default.searchIcon})})),s.jsx("input",{type:"text",className:l.default.searchInput,placeholder:"Search station...",value:N,onChange:function(e){return S(e.target.value)}})]}))}))]}),s.jsx("div",e.__assign({className:l.default.contentArea},{children:C?s.jsx("div",e.__assign({className:l.default.loadingWrapper},{children:s.jsx("p",{children:"Loading stations..."})})):b?s.jsx(i.default,{errorMessage:b,onRetry:L}):0===m.length?s.jsx("div",e.__assign({className:l.default.emptyWrapper},{children:s.jsx(r.default,{title:"No stations in this scope yet!",desc:"Add stations to ".concat(p," to define which ones this scope applies to."),button:"Onboard a Station",onCreate:function(){return I(!0)}})})):0===R.length?s.jsx("div",e.__assign({className:l.default.noResultsWrapper},{children:s.jsx("p",{children:"No stations match your search query."})})):s.jsx("div",e.__assign({className:l.default.stationList},{children:R.map(function(t){return s.jsxs("div",e.__assign({className:l.default.stationCard},{children:[s.jsxs("div",e.__assign({className:l.default.stationCardLeft},{children:[s.jsx("div",e.__assign({className:l.default.stationIconWrapper},{children:s.jsx(a.RadioTower,{size:20})})),s.jsxs("div",e.__assign({className:l.default.stationDetails},{children:[s.jsxs("div",e.__assign({className:l.default.stationHeaderRow},{children:[s.jsx("span",e.__assign({className:l.default.stationNameText},{children:t.stationName})),s.jsxs("span",e.__assign({className:l.default.learningsBadge},{children:[t.learningsCount," learnings"]}))]})),t.stationDesc&&s.jsx("span",e.__assign({className:l.default.stationDescText},{children:t.stationDesc}))]}))]})),s.jsxs("div",e.__assign({className:l.default.actionButtonsWrapper},{children:[s.jsx("button",e.__assign({onClick:function(){return null==g?void 0:g(t.stationId)},className:l.default.deleteBtn},{children:"Delete"})),s.jsx("button",e.__assign({onClick:function(){return null==_?void 0:_(t)},className:l.default.viewBtn},{children:"View"}))]}))]}),t.stationId)})}))}))]}))};
//# sourceMappingURL=StationsContent.js.map
