@census-ai/census-sdk 0.5.5 → 0.5.6

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.
@@ -1,4 +1,4 @@
1
- import {createContext,useState,useMemo,useEffect,useContext,useCallback,useRef}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var ro="https://census-api-production-97c0.up.railway.app",De=class{constructor(t){this.currentUserId=null;if(!t.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(r=>t.apiKey.startsWith(r))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=t.apiKey,this.baseUrl=t.baseUrl||ro,this.projectId=t.projectId||null,this.debug=t.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(t){if(!t.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=t.userId,await this.request("/api/sdk/identify","POST",{userId:t.userId,email:t.email,name:t.name,avatarUrl:t.avatarUrl,metadata:t.metadata,organizationId:t.organizationId,organizationName:t.organizationName,organizationDomain:t.organizationDomain,organizationPlan:t.organizationPlan}),this.log("User identified:",t.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(t){let o=["feedback","bug_report","feature_request","article_rating"];if(!t.type||!o.includes(t.type))throw new Error(`Census: type must be one of: ${o.join(", ")}`);if(t.type==="article_rating"){if(t.rating===void 0&&t.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!t.message)throw new Error("Census: message is required for this feedback type");let r=await this.request("/api/sdk/feedback","POST",{type:t.type,message:t.message,rating:t.rating,helpful:t.helpful,userId:this.currentUserId,articleId:t.articleId,projectId:this.projectId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:t.metadata});return this.log("Feedback submitted:",r.feedbackId),{feedbackId:r.feedbackId}}async getArticles(t){let o=new URLSearchParams;this.projectId&&o.set("project_id",this.projectId),t?.category&&o.set("category",t.category),t?.search&&o.set("search",t.search),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=o.toString(),i=`/api/sdk/articles${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched articles:",n.articles.length),n}async getArticle(t){try{let o=await this.request(`/api/sdk/articles/${encodeURIComponent(t)}`,"GET");return this.log("Fetched article:",t),o.article}catch(o){if(o.status===404)return null;throw o}}async getFeatureGroups(){let t=new URLSearchParams;this.projectId&&t.set("project_id",this.projectId);let o=t.toString(),r=await this.request(`/api/sdk/feature-groups${o?`?${o}`:""}`,"GET");return this.log("Fetched feature groups:",r.feature_groups.length),r}async getRequests(t){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let o=new URLSearchParams;o.set("userId",this.currentUserId),this.projectId&&o.set("project_id",this.projectId),t?.status&&o.set("status",t.status),t?.type&&o.set("type",t.type),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=await this.request(`/api/sdk/requests?${o.toString()}`,"GET");return this.log("Fetched requests:",r.requests.length),r}async track(t,o){if(!t)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:t,userId:this.currentUserId,properties:o}),this.log("Event tracked:",t);}async trackBatch(t){if(!t.events||t.events.length===0)throw new Error("Census: at least one event is required");if(t.events.length>100)throw new Error("Census: maximum 100 events per batch");let o=t.events.map(r=>({eventType:r.eventType,userId:this.currentUserId,articleId:r.articleId,featureId:r.featureId,properties:r.properties}));await this.request("/api/sdk/events","POST",{events:o}),this.log("Batch events tracked:",t.events.length);}async getGuides(t){let o=new URLSearchParams,r=t?.projectId||this.projectId;r&&o.set("project_id",r),t?.url&&o.set("url",t.url),t?.userId&&o.set("user_id",t.userId);let i=o.toString(),n=`/api/sdk/guides${i?`?${i}`:""}`,c=await this.request(n,"GET");return this.log("Fetched guides:",c.guides.length),c}async getGuide(t){try{let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"GET");return this.log("Fetched guide:",t),o.guide}catch(o){if(o.status===404)return null;throw o}}async createGuide(t){if(!t.name||!t.slug)throw new Error("Census: name and slug are required for createGuide()");let o=await this.request("/api/sdk/guides","POST",{name:t.name,slug:t.slug,description:t.description,project_id:t.projectId||this.projectId,trigger_type:t.triggerType||"manual",trigger_config:t.triggerConfig||{},theme:t.theme||{},allow_skip:t.allowSkip??true,show_progress:t.showProgress??true});return this.log("Guide created:",o.guide.id),o.guide}async updateGuide(t,o){if(!t)throw new Error("Census: guideId is required for updateGuide()");let r={};o.name!==void 0&&(r.name=o.name),o.slug!==void 0&&(r.slug=o.slug),o.description!==void 0&&(r.description=o.description),o.triggerType!==void 0&&(r.trigger_type=o.triggerType),o.triggerConfig!==void 0&&(r.trigger_config=o.triggerConfig),o.theme!==void 0&&(r.theme=o.theme),o.allowSkip!==void 0&&(r.allow_skip=o.allowSkip),o.showProgress!==void 0&&(r.show_progress=o.showProgress),o.status!==void 0&&(r.status=o.status);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"PUT",r);return this.log("Guide updated:",t),i.guide}async deleteGuide(t){if(!t)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"DELETE"),this.log("Guide deleted:",t);}async getGuideSteps(t){let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"GET");return this.log("Fetched steps for guide:",t),o.steps}async addGuideStep(t,o){if(!t)throw new Error("Census: guideId is required for addGuideStep()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"POST",{step_type:o.stepType||"tooltip",sort_order:o.sortOrder,selector_strategy:o.selectorStrategy||{},title:o.title,content:o.content,tooltip_position:o.tooltipPosition||"auto",rich_content:o.richContent||{},display_config:o.displayConfig||{},advance_config:o.advanceConfig||{trigger:"button"},style_config:o.styleConfig||{}});return this.log("Step added to guide:",t),r.step}async updateGuideStep(t,o,r){if(!t||!o)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let i={};r.stepType!==void 0&&(i.step_type=r.stepType),r.sortOrder!==void 0&&(i.sort_order=r.sortOrder),r.selectorStrategy!==void 0&&(i.selector_strategy=r.selectorStrategy),r.title!==void 0&&(i.title=r.title),r.content!==void 0&&(i.content=r.content),r.tooltipPosition!==void 0&&(i.tooltip_position=r.tooltipPosition),r.richContent!==void 0&&(i.rich_content=r.richContent),r.displayConfig!==void 0&&(i.display_config=r.displayConfig),r.advanceConfig!==void 0&&(i.advance_config=r.advanceConfig),r.styleConfig!==void 0&&(i.style_config=r.styleConfig);let n=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"PUT",i);return this.log("Step updated:",o),n.step}async deleteGuideStep(t,o){if(!t||!o)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"DELETE"),this.log("Step deleted:",o);}async reorderGuideSteps(t,o){if(!t)throw new Error("Census: guideId is required for reorderGuideSteps()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"PUT",{steps:o});return this.log("Steps reordered for guide:",t),r.steps}async trackGuideEvent(t){if(!t.guideId||!t.eventType||!t.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:t.guideId,eventType:t.eventType,stepId:t.stepId,stepIndex:t.stepIndex,pageUrl:t.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:t.sessionId,userId:t.userId||this.currentUserId,metadata:t.metadata}),this.log("Guide event tracked:",t.eventType,t.guideId);}async markGuideCompleted(t){if(!t)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:t,userId:this.currentUserId}),this.log("Guide marked completed:",t);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(t,o,r){let i=`${this.baseUrl}${t}`,n=1;for(let c=0;c<=n;c++){let p=new AbortController,l=setTimeout(()=>p.abort(),3e4);try{let s={"X-Census-Key":this.apiKey};r&&(s["Content-Type"]="application/json"),this.log(`${o} ${t}`,r);let a=await fetch(i,{method:o,headers:s,body:r?JSON.stringify(r):void 0,signal:p.signal});if(!a.ok){if(a.status>=500&&c<n){this.log(`Retrying ${o} ${t} after ${a.status}`),await new Promise(f=>setTimeout(f,1e3*(c+1)));continue}let d=`Request failed with status ${a.status}`;try{d=(await a.json()).error||d;}catch{}throw {error:d,status:a.status}}return a.json()}catch(s){if(s&&typeof s=="object"&&"error"in s)throw s;if(c<n){this.log(`Retrying ${o} ${t} after network error`),await new Promise(d=>setTimeout(d,1e3*(c+1)));continue}throw {error:p.signal.aborted?`Request timed out after 30s: ${o} ${t}`:`Network error: ${o} ${t}`}}finally{clearTimeout(l);}}throw {error:"Unexpected error",status:500}}log(...t){this.debug&&console.log("[Census]",...t);}};function ut(e){return new De(e)}var Ne=createContext(null);function so({apiKey:e,baseUrl:t,projectId:o,debug:r,user:i,theme:n={},children:c}){let[p,l]=useState(false),[s,a]=useState(false),d=useMemo(()=>ut({apiKey:e,baseUrl:t,projectId:o,debug:r}),[e,t,o,r]);useEffect(()=>{i?d.identify(i).then(()=>{a(true),l(true);}).catch(f=>{console.error("[Census] Failed to identify user:",f),l(true);}):l(true);},[d,i]);let g=useMemo(()=>({client:d,theme:n,isReady:p,isIdentified:s}),[d,n,p,s]);return jsx(Ne.Provider,{value:g,children:c})}function ao(){let e=useContext(Ne);if(!e)throw new Error("useCensus must be used within a CensusProvider");return e.client}function O(){let e=useContext(Ne);if(!e)throw new Error("useCensusContext must be used within a CensusProvider");return e}function lo(){let{client:e}=O(),[t,o]=useState(false),[r,i]=useState(null);return {identify:async p=>{o(true),i(null);try{await e.identify(p);}catch(l){throw i(l instanceof Error?l:new Error("Failed to identify user")),l}finally{o(false);}},reset:()=>{e.reset();},isIdentifying:t,isIdentified:e.isIdentified(),error:r}}function ye(){let{client:e}=O(),[t,o]=useState(false),[r,i]=useState(false),[n,c]=useState(null),[p,l]=useState(null),s=useCallback(async d=>{o(true),i(false),c(null),l(null);try{let g=await e.submitFeedback(d);return l(g.feedbackId),i(!0),g}catch(g){let f=g instanceof Error?g:new Error("Failed to submit feedback");throw c(f),f}finally{o(false);}},[e]),a=useCallback(()=>{i(false),c(null),l(null);},[]);return {submitFeedback:s,reset:a,isSubmitting:t,isSuccess:r,error:n,feedbackId:p}}function he(e){let{client:t,isReady:o}=O(),[r,i]=useState(null),[n,c]=useState(true),[p,l]=useState(null),s=useCallback(async()=>{c(true),l(null);try{let a=await t.getArticles(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch articles"));}finally{c(false);}},[t,JSON.stringify(e)]);return useEffect(()=>{o&&s();},[o,s]),{articles:r?.articles||[],pagination:r?.pagination,isLoading:n,error:p,refetch:s}}function xe(e){let{client:t,isReady:o}=O(),[r,i]=useState(null),[n,c]=useState(true),[p,l]=useState(null),s=useCallback(async()=>{if(!e){i(null),c(false);return}c(true),l(null);try{let a=await t.getArticle(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch article"));}finally{c(false);}},[t,e]);return useEffect(()=>{o&&s();},[o,s]),{article:r,isLoading:n,error:p,refetch:s}}function Oe(){let{client:e,isReady:t}=O(),[o,r]=useState([]),[i,n]=useState(true),[c,p]=useState(null),l=useCallback(async()=>{n(true),p(null);try{let s=await e.getFeatureGroups();r(s.feature_groups);}catch(s){p(s instanceof Error?s:new Error("Failed to fetch feature groups"));}finally{n(false);}},[e]);return useEffect(()=>{t&&l();},[t,l]),{featureGroups:o,isLoading:i,error:c,refetch:l}}function ve(e){let{client:t,isReady:o,isIdentified:r}=O(),[i,n]=useState(null),[c,p]=useState(true),[l,s]=useState(null),a=useCallback(async()=>{if(!r){n(null),p(false);return}p(true),s(null);try{let d=await t.getRequests(e);n(d);}catch(d){s(d instanceof Error?d:new Error("Failed to fetch requests"));}finally{p(false);}},[t,r,e?.status,e?.type,e?.limit,e?.offset]);return useEffect(()=>{o&&r&&a();},[o,r,a]),{requests:i?.requests||[],pagination:i?.pagination,isLoading:c,error:l,refetch:a}}function uo(){let{client:e}=O(),t=useCallback(async(r,i)=>{await e.track(r,i);},[e]),o=useCallback(async r=>{await e.trackBatch({events:r});},[e]);return {track:t,trackBatch:o}}function fo(e){let{client:t,isReady:o}=O(),[r,i]=useState(null),[n,c]=useState(true),[p,l]=useState(null),s=useCallback(async()=>{c(true),l(null);try{let a=await t.getGuides(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch guides"));}finally{c(false);}},[t,e?.projectId,e?.url,e?.userId]);return useEffect(()=>{o&&s();},[o,s]),{guides:r?.guides||[],completedGuides:r?.completedGuides||[],isLoading:n,error:p,refetch:s}}function $e(){let{client:e,isReady:t}=O(),[o,r]=useState(null),[i,n]=useState([]),[c,p]=useState(false),[l,s]=useState(false),[a,d]=useState(null),[g,f]=useState(null),u=useRef(false),C=useCallback(async R=>{p(true),d(null);try{let h=await e.getGuide(R);return h&&(r(h),n(h.guide_steps||[]),f(h.guide_steps?.[0]?.id||null)),h}catch(h){return d(h instanceof Error?h:new Error("Failed to load guide")),null}finally{p(false);}},[e]),G=useCallback(async R=>{s(true),d(null);try{let h=await e.createGuide(R);return r(h),n([]),f(null),h}catch(h){throw d(h instanceof Error?h:new Error("Failed to create guide")),h}finally{s(false);}},[e]),x=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let h=await e.updateGuide(o.id,R);return r(h),u.current=!1,h}catch(h){throw d(h instanceof Error?h:new Error("Failed to update guide")),h}finally{s(false);}},[e,o]),E=useCallback(async()=>x({status:"published"}),[x]),v=useCallback(async()=>x({status:"draft"}),[x]),w=useCallback(async()=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuide(o.id),r(null),n([]),f(null);}catch(R){throw d(R instanceof Error?R:new Error("Failed to delete guide")),R}finally{s(false);}},[e,o]),T=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let h=await e.addGuideStep(o.id,R);return n(U=>[...U,h]),f(h.id),u.current=!0,h}catch(h){throw d(h instanceof Error?h:new Error("Failed to add step")),h}finally{s(false);}},[e,o]),S=useCallback(async(R,h)=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let U=await e.updateGuideStep(o.id,R,h);return n(q=>q.map(Q=>Q.id===R?U:Q)),u.current=!0,U}catch(U){throw d(U instanceof Error?U:new Error("Failed to update step")),U}finally{s(false);}},[e,o]),I=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuideStep(o.id,R),n(h=>h.filter(U=>U.id!==R)),g===R&&f(i[0]?.id||null),u.current=!0;}catch(h){throw d(h instanceof Error?h:new Error("Failed to delete step")),h}finally{s(false);}},[e,o,g,i]),m=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let h=await e.reorderGuideSteps(o.id,R);return n(h),u.current=!0,h}catch(h){throw d(h instanceof Error?h:new Error("Failed to reorder steps")),h}finally{s(false);}},[e,o]),A=useCallback(async R=>{let h=i.findIndex(q=>q.id===R);if(h<=0)return;let U=i.map((q,Q)=>Q===h?{id:q.id,sort_order:h-1}:Q===h-1?{id:q.id,sort_order:h}:{id:q.id,sort_order:Q});return m(U)},[i,m]),D=useCallback(async R=>{let h=i.findIndex(q=>q.id===R);if(h<0||h>=i.length-1)return;let U=i.map((q,Q)=>Q===h?{id:q.id,sort_order:h+1}:Q===h+1?{id:q.id,sort_order:h}:{id:q.id,sort_order:Q});return m(U)},[i,m]),y=g&&i.find(R=>R.id===g)||null,P=useCallback(()=>{r(null),n([]),f(null),d(null),u.current=false;},[]);return {guide:o,steps:i,selectedStep:y,selectedStepId:g,isLoading:c,isSaving:l,error:a,isReady:t,hasUnsavedChanges:u.current,loadGuide:C,createGuide:G,updateGuide:x,publishGuide:E,unpublishGuide:v,deleteGuide:w,addStep:T,updateStep:S,deleteStep:I,reorderSteps:m,moveStepUp:A,moveStepDown:D,setSelectedStepId:f,reset:P}}function go(){let{client:e,isReady:t}=O(),[o,r]=useState(null),[i,n]=useState(0),[c,p]=useState(false),[l,s]=useState([]),[a,d]=useState([]),g=useCallback((P,R=0)=>{r(P),n(R),p(true);},[]),f=useCallback(()=>{if(!o)return;let P=o.guide_steps||[];i<P.length-1?n(R=>R+1):(s(R=>[...R,o.id]),p(false),r(null));},[o,i]),u=useCallback(()=>{i>0&&n(P=>P-1);},[i]),C=useCallback(P=>{if(!o)return;let R=o.guide_steps||[];P>=0&&P<R.length&&n(P);},[o]),G=useCallback(()=>{o&&d(P=>[...P,o.id]),p(false),r(null),n(0);},[o]),x=useCallback(()=>{p(false);},[]),E=useCallback(()=>{o&&p(true);},[o]),v=useCallback(async(P,R)=>{let h=P.guide_steps?.[R];if(h)try{await e.track("guide_step_viewed",{guide_id:P.id,guide_name:P.name,step_id:h.id,step_index:R,step_type:h.step_type});}catch{}},[e]),w=useCallback(async P=>{try{await e.track("guide_completed",{guide_id:P.id,guide_name:P.name,total_steps:P.guide_steps?.length||0});}catch{}},[e]),T=useCallback(async(P,R)=>{try{await e.track("guide_dismissed",{guide_id:P.id,guide_name:P.name,dismissed_at_step:R,total_steps:P.guide_steps?.length||0});}catch{}},[e]),S=o?.guide_steps?.[i]||null,I=o?.guide_steps?.length||0,m=i===I-1,A=i===0,D=useCallback(P=>l.includes(P),[l]),y=useCallback(P=>a.includes(P),[a]);return {activeGuide:o,currentStep:S,currentStepIndex:i,totalSteps:I,isPlaying:c,isFirstStep:A,isLastStep:m,isReady:t,startGuide:g,nextStep:f,prevStep:u,goToStep:C,dismiss:G,pause:x,resume:E,trackStepView:v,trackGuideComplete:w,trackGuideDismiss:T,completedGuideIds:l,dismissedGuideIds:a,isGuideCompleted:D,isGuideDismissed:y}}var ie={button:{position:"fixed",padding:"12px 20px",border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px",fontWeight:"500",transition:"transform 0.2s",zIndex:9999},modal:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4},modalContent:{backgroundColor:"white",borderRadius:"12px",padding:"24px",width:"100%",maxWidth:"400px",margin:"16px",boxShadow:"0 20px 50px rgba(0, 0, 0, 0.2)",fontFamily:"system-ui, -apple-system, sans-serif"},textarea:{width:"100%",padding:"10px 12px",border:"1px solid #e0e0e0",borderRadius:"6px",fontSize:"14px",marginBottom:"16px",minHeight:"100px",resize:"vertical",boxSizing:"border-box",fontFamily:"inherit"},submitButton:{width:"100%",padding:"12px",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",fontWeight:"500",transition:"opacity 0.2s"},typeButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"6px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"}},mo={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},bo={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},yo={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function ho(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function xo({position:e="bottom-right",text:t="Feedback",allowedTypes:o=["feedback","bug_report","feature_request"],theme:r,onSubmit:i,onError:n,children:c}){let{theme:p}=O(),{submitFeedback:l,isSubmitting:s,isSuccess:a,reset:d}=ye(),[g,f]=useState(false),[u,C]=useState(o[0]),[G,x]=useState(""),E={...p,...r},v=ho(E),w=useCallback(()=>{f(true),d();},[d]),T=useCallback(()=>{f(false),x(""),C(o[0]);},[o]),S=useCallback(async I=>{I.preventDefault();let m={type:u,message:G};try{await l(m),i?.(m),setTimeout(T,1500);}catch(A){n?.(A instanceof Error?A:new Error("Failed to submit feedback"));}},[u,G,l,i,n,T]);return c?jsxs(Fragment,{children:[jsx("div",{onClick:w,style:{cursor:"pointer"},children:c}),g&&jsx(mt,{isOpen:g,onClose:T,selectedType:u,onTypeChange:C,allowedTypes:o,message:G,onMessageChange:x,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]}):jsxs(Fragment,{children:[jsx("button",{onClick:w,style:{...ie.button,...mo[e],backgroundColor:v.primaryColor,color:"white",borderRadius:v.borderRadius,fontFamily:v.fontFamily},"aria-label":"Open feedback form",children:t}),g&&jsx(mt,{isOpen:g,onClose:T,selectedType:u,onTypeChange:C,allowedTypes:o,message:G,onMessageChange:x,onSubmit:S,isSubmitting:s,isSuccess:a,themeStyles:v})]})}function mt({isOpen:e,onClose:t,selectedType:o,onTypeChange:r,allowedTypes:i,message:n,onMessageChange:c,onSubmit:p,isSubmitting:l,isSuccess:s,themeStyles:a}){return e?s?jsx("div",{style:ie.modal,onClick:t,children:jsxs("div",{style:{...ie.modalContent,textAlign:"center",fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"\u{1F389}"}),jsx("h3",{style:{margin:"0 0 8px 0",color:a.textColor},children:"Thanks for your feedback!"}),jsx("p",{style:{margin:0,color:"#666"},children:"We appreciate you taking the time to share."})]})}):jsx("div",{style:ie.modal,onClick:t,children:jsxs("div",{style:{...ie.modalContent,fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[jsx("h3",{style:{margin:0,color:a.textColor},children:"Send Feedback"}),jsx("button",{onClick:t,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#999",padding:"0",lineHeight:"1"},"aria-label":"Close",children:"\xD7"})]}),jsxs("form",{onSubmit:p,children:[jsxs("div",{style:{marginBottom:"16px"},children:[jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"What kind of feedback?"}),jsx("div",{style:{display:"flex",flexWrap:"wrap"},children:i.map(d=>jsxs("button",{type:"button",onClick:()=>r(d),style:{...ie.typeButton,backgroundColor:o===d?a.primaryColor:"white",color:o===d?"white":a.textColor,borderColor:o===d?a.primaryColor:"#e0e0e0"},children:[yo[d]," ",bo[d]]},d))})]}),jsxs("div",{children:[jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"Your message"}),jsx("textarea",{value:n,onChange:d=>c(d.target.value),placeholder:o==="bug_report"?"Describe the bug and steps to reproduce...":o==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:ie.textarea,required:true})]}),jsx("button",{type:"submit",disabled:l||!n.trim(),style:{...ie.submitButton,backgroundColor:a.primaryColor,color:"white",opacity:l||!n.trim()?.6:1,cursor:l||!n.trim()?"not-allowed":"pointer"},children:l?"Sending...":"Send Feedback"})]})]})}):null}var M={container:{fontFamily:"system-ui, -apple-system, sans-serif",maxWidth:"800px"},searchInput:{width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"8px",fontSize:"15px",marginBottom:"24px",boxSizing:"border-box"},categoryButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"20px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"},articleCard:{padding:"20px",border:"1px solid #e0e0e0",borderRadius:"8px",marginBottom:"12px",cursor:"pointer",transition:"border-color 0.2s",backgroundColor:"white"},articleTitle:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:"600"},articleDescription:{margin:0,fontSize:"14px",color:"#666",lineHeight:1.5},articleMeta:{display:"flex",gap:"16px",marginTop:"12px",fontSize:"12px",color:"#999"},backButton:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"8px 0",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"#666",marginBottom:"16px"},articleContent:{lineHeight:1.7,fontSize:"15px"},loading:{textAlign:"center",padding:"40px",color:"#666"},error:{padding:"20px",backgroundColor:"#fef2f2",borderRadius:"8px",color:"#b91c1c",textAlign:"center"},empty:{textAlign:"center",padding:"40px",color:"#666"}};function Co(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function So({showSearch:e=true,showCategories:t=true,defaultCategory:o,theme:r,className:i,onArticleView:n}){let{theme:c}=O(),[p,l]=useState(""),[s,a]=useState(o),[d,g]=useState(null),f={...c,...r},u=Co(f),{articles:C,isLoading:G,error:x}=he({category:s,search:p||void 0}),{article:E,isLoading:v,error:w}=xe(d||""),T=useMemo(()=>{let m=new Set;return C.forEach(A=>{A.category&&m.add(A.category);}),Array.from(m).sort()},[C]),S=m=>{g(m.slug),n?.(m);},I=()=>{g(null);};return d?v?jsx("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:jsx("div",{style:M.loading,children:"Loading article..."})}):w?jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[jsx("button",{onClick:I,style:M.backButton,children:"\u2190 Back to articles"}),jsx("div",{style:M.error,children:"Failed to load article. Please try again."})]}):E?jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[jsx("button",{onClick:I,style:M.backButton,children:"\u2190 Back to articles"}),jsxs("article",{children:[jsx("h1",{style:{margin:"0 0 16px 0",color:u.textColor},children:E.title}),E.read_time_minutes&&jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[E.read_time_minutes," min read"]}),E.content_html?jsx("div",{style:{...M.articleContent,color:u.textColor},dangerouslySetInnerHTML:{__html:E.content_html}}):jsx("div",{style:{...M.articleContent,color:u.textColor},children:typeof E.content=="string"?E.content:"No content available."})]})]}):jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[jsx("button",{onClick:I,style:M.backButton,children:"\u2190 Back to articles"}),jsx("div",{style:M.empty,children:"Article not found."})]}):jsxs("div",{style:{...M.container,fontFamily:u.fontFamily},className:i,children:[e&&jsx("input",{type:"text",placeholder:"Search articles...",value:p,onChange:m=>l(m.target.value),style:M.searchInput}),t&&T.length>0&&jsxs("div",{style:{marginBottom:"24px"},children:[jsx("button",{onClick:()=>a(void 0),style:{...M.categoryButton,backgroundColor:s?"white":u.primaryColor,color:s?u.textColor:"white",borderColor:s?"#e0e0e0":u.primaryColor},children:"All"}),T.map(m=>jsx("button",{onClick:()=>a(m),style:{...M.categoryButton,backgroundColor:s===m?u.primaryColor:"white",color:s===m?"white":u.textColor,borderColor:s===m?u.primaryColor:"#e0e0e0"},children:m},m))]}),G&&jsx("div",{style:M.loading,children:"Loading articles..."}),x&&jsx("div",{style:M.error,children:"Failed to load articles. Please try again."}),!G&&!x&&C.length===0&&jsx("div",{style:M.empty,children:p?`No articles found for "${p}"`:"No articles available yet."}),!G&&!x&&C.length>0&&jsx("div",{children:C.map(m=>jsxs("div",{onClick:()=>S(m),style:M.articleCard,role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&S(m);},children:[jsx("h3",{style:{...M.articleTitle,color:u.textColor},children:m.title}),m.seo_description&&jsx("p",{style:M.articleDescription,children:m.seo_description}),jsxs("div",{style:M.articleMeta,children:[m.category&&jsx("span",{children:m.category}),m.read_time_minutes&&jsxs("span",{children:[m.read_time_minutes," min read"]})]})]},m.id))})]})}var K={container:{fontFamily:"system-ui, -apple-system, sans-serif"},list:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"12px"},card:{border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px",backgroundColor:"#ffffff",cursor:"pointer",transition:"border-color 0.15s"},cardHover:{borderColor:"#d1d5db"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"8px"},badges:{display:"flex",alignItems:"center",gap:"6px"},badge:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500},message:{fontSize:"14px",color:"#111827",margin:0,lineHeight:1.5},meta:{display:"flex",gap:"12px",marginTop:"8px",fontSize:"12px",color:"#6b7280"},empty:{textAlign:"center",padding:"32px 16px",color:"#6b7280"},emptyIcon:{width:"48px",height:"48px",margin:"0 auto 12px",color:"#d1d5db"},loading:{textAlign:"center",padding:"24px",color:"#6b7280"},error:{textAlign:"center",padding:"24px",color:"#dc2626"}},yt={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},ht={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},reviewed:{label:"Reviewed",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function Ro(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Eo({status:e,type:t,limit:o=50,className:r,showEmptyState:i=true,onRequestClick:n}){let{isIdentified:c}=O(),[p,l]=useState(null),{requests:s,isLoading:a,error:d,refetch:g}=ve({status:e,type:t,limit:o}),f=useCallback(u=>{n?.(u);},[n]);return c?a?jsx("div",{style:K.loading,children:jsx("p",{children:"Loading requests..."})}):d?jsx("div",{style:K.error,children:jsxs("p",{children:["Failed to load requests. ",jsx("button",{onClick:g,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})}):s.length===0&&i?jsxs("div",{style:K.empty,children:[jsx("svg",{style:K.emptyIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),jsx("p",{style:{margin:0,fontWeight:500,color:"#111827"},children:"No requests yet"}),jsx("p",{style:{margin:"8px 0 0",fontSize:"14px"},children:"When you submit feedback, bug reports, or feature requests, they'll appear here."})]}):jsx("div",{style:K.container,className:r,children:jsx("ul",{style:K.list,children:s.map(u=>{let C=yt[u.feedback_type]||yt.feedback,G=ht[u.status]||ht.new,x=p===u.id;return jsxs("li",{style:{...K.card,...x?K.cardHover:{}},onMouseEnter:()=>l(u.id),onMouseLeave:()=>l(null),onClick:()=>f(u),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&f(u);},children:[jsx("div",{style:K.header,children:jsxs("div",{style:K.badges,children:[jsx("span",{style:{...K.badge,color:C.color,backgroundColor:C.bg},children:C.label}),jsx("span",{style:{...K.badge,color:G.color,backgroundColor:G.bg},children:G.label})]})}),jsx("p",{style:K.message,children:u.message||"No message provided"}),jsxs("div",{style:K.meta,children:[jsx("span",{children:Ro(u.created_at)}),u.page_url&&jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"200px"},children:["From: ",u.page_url]})]})]},u.id)})})}):i?jsx("div",{style:K.empty,children:jsx("p",{children:"Please sign in to view your requests."})}):null}var Io={articles:"Documentation",requests:"My Requests"},vt={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},Ct={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},planned:{label:"Planned",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function Po(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var _o=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],Bo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),St=()=>jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),wt=()=>jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),Lo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),Fo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),zo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),Ao=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),qo=()=>jsx("svg",{width:"48",height:"48",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),Mo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),Ve=()=>jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",style:{animation:"spin 1s linear infinite"},children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),kt={light:{primary:"#c45a2c",primaryHover:"#a84a24",primaryLight:"rgba(196, 90, 44, 0.08)",primaryLightHover:"rgba(196, 90, 44, 0.15)",background:"transparent",surface:"#ffffff",surfaceHover:"#fafafa",border:"rgba(0, 0, 0, 0.08)",borderHover:"rgba(196, 90, 44, 0.25)",text:"#1a1a1a",textSecondary:"#525252",textMuted:"#737373",textLight:"#a3a3a3"},dark:{primary:"#e07347",primaryHover:"#f08a5d",primaryLight:"rgba(224, 115, 71, 0.12)",primaryLightHover:"rgba(224, 115, 71, 0.2)",background:"transparent",surface:"rgba(255, 255, 255, 0.03)",surfaceHover:"rgba(255, 255, 255, 0.06)",border:"rgba(255, 255, 255, 0.08)",borderHover:"rgba(224, 115, 71, 0.35)",text:"#fafafa",textSecondary:"#d4d4d4",textMuted:"#a3a3a3",textLight:"#737373"}},Do=e=>({container:{fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',minHeight:"400px",color:e.text},grid:{display:"grid",gridTemplateColumns:"220px 1fr",gap:"40px"},sidebar:{position:"sticky",top:"24px",height:"fit-content"},main:{minWidth:0},tabs:{display:"flex",borderBottom:`1px solid ${e.border}`,marginBottom:"28px",gap:"0"},tab:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",cursor:"pointer",transition:"all 0.15s",backgroundColor:"transparent",color:e.textMuted,marginBottom:"-1px"},tabActive:{color:e.primary,borderBottomColor:e.primary},searchContainer:{position:"relative",marginBottom:"20px"},searchIcon:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:e.textLight},searchInput:{width:"100%",padding:"8px 10px 8px 32px",fontSize:"13px",border:`1px solid ${e.border}`,borderRadius:"6px",outline:"none",backgroundColor:"transparent",color:e.text,boxSizing:"border-box"},sectionTitle:{fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:e.textLight,marginBottom:"8px",marginTop:"20px"},navList:{listStyle:"none",padding:0,margin:0},navItem:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"6px 10px",fontSize:"13px",color:e.textSecondary,backgroundColor:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},navItemActive:{backgroundColor:e.surfaceHover,color:e.text,fontWeight:500},subNav:{marginLeft:"20px",marginTop:"2px",paddingLeft:"10px",borderLeft:`1px solid ${e.border}`},articleGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},articleCard:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px",border:`1px solid ${e.border}`,borderRadius:"8px",backgroundColor:e.surface,cursor:"pointer",transition:"all 0.2s ease",textAlign:"left"},articleIcon:{flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:e.primaryLight,borderRadius:"8px",color:e.primary,transition:"background-color 0.2s"},articleContent:{flex:1,minWidth:0},articleTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0,lineHeight:1.4},articleDesc:{fontSize:"12px",color:e.textMuted,margin:"4px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:1.5},articleMeta:{fontSize:"11px",color:e.textLight,marginTop:"6px"},articleChevron:{flexShrink:0,color:e.textLight,transition:"color 0.2s"},backButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 0",fontSize:"13px",color:e.textMuted,backgroundColor:"transparent",border:"none",cursor:"pointer",marginBottom:"20px",transition:"color 0.15s"},articleDetail:{maxWidth:"720px"},articleDetailTitle:{fontSize:"28px",fontWeight:600,color:e.text,margin:0,lineHeight:1.3},articleDetailMeta:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.textMuted,marginTop:"10px"},articleDetailContent:{marginTop:"28px",fontSize:"15px",lineHeight:1.7,color:e.textSecondary},emptyState:{textAlign:"center",padding:"48px 24px",color:e.textMuted},emptyIcon:{color:e.textLight,marginBottom:"12px",opacity:.5},emptyTitle:{fontSize:"16px",fontWeight:500,color:e.text,margin:"0 0 6px"},emptyText:{fontSize:"13px",margin:0,color:e.textMuted},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px",color:e.textMuted,fontSize:"13px"},requestCard:{border:`1px solid ${e.border}`,borderRadius:"8px",padding:"16px",backgroundColor:e.surface,marginBottom:"10px",transition:"border-color 0.2s"},requestHeader:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},badge:{display:"inline-flex",alignItems:"center",padding:"3px 8px",borderRadius:"9999px",fontSize:"11px",fontWeight:500},requestMessage:{fontSize:"14px",color:e.text,margin:0,lineHeight:1.5},requestMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:e.textMuted},form:{padding:"16px",backgroundColor:e.surface,borderRadius:"8px",border:`1px solid ${e.border}`,marginBottom:"20px"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0},typeSelector:{display:"flex",gap:"6px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,backgroundColor:"transparent",color:e.textSecondary,fontSize:"13px",cursor:"pointer",transition:"all 0.15s",fontWeight:500},typeButtonActive:{backgroundColor:e.primary,borderColor:e.primary,color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,fontSize:"13px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px",boxSizing:"border-box",backgroundColor:"transparent",color:e.text},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:e.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",transition:"all 0.15s"},newRequestButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:e.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",marginBottom:"20px",transition:"background-color 0.15s"},successMessage:{padding:"12px 14px",backgroundColor:"rgba(5, 150, 105, 0.1)",borderRadius:"6px",color:"#059669",fontSize:"13px",marginBottom:"12px",fontWeight:500}}),No=(e,t)=>`
1
+ import {createContext,useState,useCallback,useEffect,useRef,useMemo,useContext}from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {createPortal}from'react-dom';var so="https://census-api-production-97c0.up.railway.app",De=class{constructor(t){this.currentUserId=null;if(!t.apiKey)throw new Error("Census: apiKey is required");["cs_live_","cs_test_","op_live_","op_test_"].some(r=>t.apiKey.startsWith(r))||console.warn('Census: API key should start with "cs_live_" or "cs_test_"'),this.apiKey=t.apiKey,this.baseUrl=t.baseUrl||so,this.projectId=t.projectId||null,this.debug=t.debug||false,this.log("Initialized with base URL:",this.baseUrl);}async identify(t){if(!t.userId)throw new Error("Census: userId is required for identify()");this.currentUserId=t.userId,await this.request("/api/sdk/identify","POST",{userId:t.userId,email:t.email,name:t.name,avatarUrl:t.avatarUrl,metadata:t.metadata,organizationId:t.organizationId,organizationName:t.organizationName,organizationDomain:t.organizationDomain,organizationPlan:t.organizationPlan}),this.log("User identified:",t.userId);}reset(){this.currentUserId=null,this.log("User identity reset");}async submitFeedback(t){let o=["feedback","bug_report","feature_request","article_rating"];if(!t.type||!o.includes(t.type))throw new Error(`Census: type must be one of: ${o.join(", ")}`);if(t.type==="article_rating"){if(t.rating===void 0&&t.helpful===void 0)throw new Error("Census: article_rating requires rating or helpful field")}else if(!t.message)throw new Error("Census: message is required for this feedback type");let r=await this.request("/api/sdk/feedback","POST",{type:t.type,message:t.message,rating:t.rating,helpful:t.helpful,userId:this.currentUserId,articleId:t.articleId,projectId:this.projectId,pageUrl:typeof window<"u"?window.location.href:void 0,metadata:t.metadata});return this.log("Feedback submitted:",r.feedbackId),{feedbackId:r.feedbackId}}async getArticles(t){let o=new URLSearchParams;this.projectId&&o.set("project_id",this.projectId),t?.category&&o.set("category",t.category),t?.search&&o.set("search",t.search),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=o.toString(),i=`/api/sdk/articles${r?`?${r}`:""}`,n=await this.request(i,"GET");return this.log("Fetched articles:",n.articles.length),n}async getArticle(t){try{let o=await this.request(`/api/sdk/articles/${encodeURIComponent(t)}`,"GET");return this.log("Fetched article:",t),o.article}catch(o){if(o.status===404)return null;throw o}}async getFeatureGroups(){let t=new URLSearchParams;this.projectId&&t.set("project_id",this.projectId);let o=t.toString(),r=await this.request(`/api/sdk/feature-groups${o?`?${o}`:""}`,"GET");return this.log("Fetched feature groups:",r.feature_groups.length),r}async getRequests(t){if(!this.currentUserId)throw new Error("Census: User must be identified before fetching requests. Call identify() first.");let o=new URLSearchParams;o.set("userId",this.currentUserId),this.projectId&&o.set("project_id",this.projectId),t?.status&&o.set("status",t.status),t?.type&&o.set("type",t.type),t?.limit&&o.set("limit",String(t.limit)),t?.offset&&o.set("offset",String(t.offset));let r=await this.request(`/api/sdk/requests?${o.toString()}`,"GET");return this.log("Fetched requests:",r.requests.length),r}async track(t,o){if(!t)throw new Error("Census: eventType is required for track()");await this.request("/api/sdk/events","POST",{eventType:t,userId:this.currentUserId,properties:o}),this.log("Event tracked:",t);}async trackBatch(t){if(!t.events||t.events.length===0)throw new Error("Census: at least one event is required");if(t.events.length>100)throw new Error("Census: maximum 100 events per batch");let o=t.events.map(r=>({eventType:r.eventType,userId:this.currentUserId,articleId:r.articleId,featureId:r.featureId,properties:r.properties}));await this.request("/api/sdk/events","POST",{events:o}),this.log("Batch events tracked:",t.events.length);}async getGuides(t){let o=new URLSearchParams,r=t?.projectId||this.projectId;r&&o.set("project_id",r),t?.url&&o.set("url",t.url),t?.userId&&o.set("user_id",t.userId);let i=o.toString(),n=`/api/sdk/guides${i?`?${i}`:""}`,c=await this.request(n,"GET");return this.log("Fetched guides:",c.guides.length),c}async getGuide(t){try{let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"GET");return this.log("Fetched guide:",t),o.guide}catch(o){if(o.status===404)return null;throw o}}async createGuide(t){if(!t.name||!t.slug)throw new Error("Census: name and slug are required for createGuide()");let o=await this.request("/api/sdk/guides","POST",{name:t.name,slug:t.slug,description:t.description,project_id:t.projectId||this.projectId,trigger_type:t.triggerType||"manual",trigger_config:t.triggerConfig||{},theme:t.theme||{},allow_skip:t.allowSkip??true,show_progress:t.showProgress??true});return this.log("Guide created:",o.guide.id),o.guide}async updateGuide(t,o){if(!t)throw new Error("Census: guideId is required for updateGuide()");let r={};o.name!==void 0&&(r.name=o.name),o.slug!==void 0&&(r.slug=o.slug),o.description!==void 0&&(r.description=o.description),o.triggerType!==void 0&&(r.trigger_type=o.triggerType),o.triggerConfig!==void 0&&(r.trigger_config=o.triggerConfig),o.theme!==void 0&&(r.theme=o.theme),o.allowSkip!==void 0&&(r.allow_skip=o.allowSkip),o.showProgress!==void 0&&(r.show_progress=o.showProgress),o.status!==void 0&&(r.status=o.status);let i=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"PUT",r);return this.log("Guide updated:",t),i.guide}async deleteGuide(t){if(!t)throw new Error("Census: guideId is required for deleteGuide()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}`,"DELETE"),this.log("Guide deleted:",t);}async getGuideSteps(t){let o=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"GET");return this.log("Fetched steps for guide:",t),o.steps}async addGuideStep(t,o){if(!t)throw new Error("Census: guideId is required for addGuideStep()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"POST",{step_type:o.stepType||"tooltip",sort_order:o.sortOrder,selector_strategy:o.selectorStrategy||{},title:o.title,content:o.content,tooltip_position:o.tooltipPosition||"auto",rich_content:o.richContent||{},display_config:o.displayConfig||{},advance_config:o.advanceConfig||{trigger:"button"},style_config:o.styleConfig||{}});return this.log("Step added to guide:",t),r.step}async updateGuideStep(t,o,r){if(!t||!o)throw new Error("Census: guideId and stepId are required for updateGuideStep()");let i={};r.stepType!==void 0&&(i.step_type=r.stepType),r.sortOrder!==void 0&&(i.sort_order=r.sortOrder),r.selectorStrategy!==void 0&&(i.selector_strategy=r.selectorStrategy),r.title!==void 0&&(i.title=r.title),r.content!==void 0&&(i.content=r.content),r.tooltipPosition!==void 0&&(i.tooltip_position=r.tooltipPosition),r.richContent!==void 0&&(i.rich_content=r.richContent),r.displayConfig!==void 0&&(i.display_config=r.displayConfig),r.advanceConfig!==void 0&&(i.advance_config=r.advanceConfig),r.styleConfig!==void 0&&(i.style_config=r.styleConfig);let n=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"PUT",i);return this.log("Step updated:",o),n.step}async deleteGuideStep(t,o){if(!t||!o)throw new Error("Census: guideId and stepId are required for deleteGuideStep()");await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps/${encodeURIComponent(o)}`,"DELETE"),this.log("Step deleted:",o);}async reorderGuideSteps(t,o){if(!t)throw new Error("Census: guideId is required for reorderGuideSteps()");let r=await this.request(`/api/sdk/guides/${encodeURIComponent(t)}/steps`,"PUT",{steps:o});return this.log("Steps reordered for guide:",t),r.steps}async trackGuideEvent(t){if(!t.guideId||!t.eventType||!t.sessionId)throw new Error("Census: guideId, eventType, and sessionId are required for trackGuideEvent()");await this.request("/api/sdk/guides/events","POST",{guideId:t.guideId,eventType:t.eventType,stepId:t.stepId,stepIndex:t.stepIndex,pageUrl:t.pageUrl||(typeof window<"u"?window.location.href:void 0),sessionId:t.sessionId,userId:t.userId||this.currentUserId,metadata:t.metadata}),this.log("Guide event tracked:",t.eventType,t.guideId);}async markGuideCompleted(t){if(!t)throw new Error("Census: guideId is required for markGuideCompleted()");if(!this.currentUserId)throw new Error("Census: User must be identified before marking guides complete. Call identify() first.");await this.request("/api/sdk/guides/complete","POST",{guideId:t,userId:this.currentUserId}),this.log("Guide marked completed:",t);}getCurrentUserId(){return this.currentUserId}isIdentified(){return this.currentUserId!==null}async request(t,o,r){let i=`${this.baseUrl}${t}`,n=1;for(let c=0;c<=n;c++){let p=new AbortController,l=setTimeout(()=>p.abort(),3e4);try{let s={"X-Census-Key":this.apiKey};r&&(s["Content-Type"]="application/json"),this.log(`${o} ${t}`,r);let a=await fetch(i,{method:o,headers:s,body:r?JSON.stringify(r):void 0,signal:p.signal});if(!a.ok){if(a.status>=500&&c<n){this.log(`Retrying ${o} ${t} after ${a.status}`),await new Promise(f=>setTimeout(f,1e3*(c+1)));continue}let d=`Request failed with status ${a.status}`;try{d=(await a.json()).error||d;}catch{}throw {error:d,status:a.status}}return a.json()}catch(s){if(s&&typeof s=="object"&&"error"in s)throw s;if(c<n){this.log(`Retrying ${o} ${t} after network error`),await new Promise(d=>setTimeout(d,1e3*(c+1)));continue}throw {error:p.signal.aborted?`Request timed out after 30s: ${o} ${t}`:`Network error: ${o} ${t}`}}finally{clearTimeout(l);}}throw {error:"Unexpected error",status:500}}log(...t){this.debug&&console.log("[Census]",...t);}};function bt(e){return new De(e)}function ye(){let{client:e}=U(),[t,o]=useState(false),[r,i]=useState(false),[n,c]=useState(null),[p,l]=useState(null),s=useCallback(async d=>{o(true),i(false),c(null),l(null);try{let g=await e.submitFeedback(d);return l(g.feedbackId),i(!0),g}catch(g){let f=g instanceof Error?g:new Error("Failed to submit feedback");throw c(f),f}finally{o(false);}},[e]),a=useCallback(()=>{i(false),c(null),l(null);},[]);return {submitFeedback:s,reset:a,isSubmitting:t,isSuccess:r,error:n,feedbackId:p}}function xe(e){let{client:t,isReady:o}=U(),[r,i]=useState(null),[n,c]=useState(true),[p,l]=useState(null),s=useCallback(async()=>{c(true),l(null);try{let a=await t.getArticles(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch articles"));}finally{c(false);}},[t,JSON.stringify(e)]);return useEffect(()=>{o&&s();},[o,s]),{articles:r?.articles||[],pagination:r?.pagination,isLoading:n,error:p,refetch:s}}function he(e){let{client:t,isReady:o}=U(),[r,i]=useState(null),[n,c]=useState(true),[p,l]=useState(null),s=useCallback(async()=>{if(!e){i(null),c(false);return}c(true),l(null);try{let a=await t.getArticle(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch article"));}finally{c(false);}},[t,e]);return useEffect(()=>{o&&s();},[o,s]),{article:r,isLoading:n,error:p,refetch:s}}function Oe(){let{client:e,isReady:t}=U(),[o,r]=useState([]),[i,n]=useState(true),[c,p]=useState(null),l=useCallback(async()=>{n(true),p(null);try{let s=await e.getFeatureGroups();r(s.feature_groups);}catch(s){p(s instanceof Error?s:new Error("Failed to fetch feature groups"));}finally{n(false);}},[e]);return useEffect(()=>{t&&l();},[t,l]),{featureGroups:o,isLoading:i,error:c,refetch:l}}function ve(e){let{client:t,isReady:o,isIdentified:r}=U(),[i,n]=useState(null),[c,p]=useState(true),[l,s]=useState(null),a=useCallback(async()=>{if(!r){n(null),p(false);return}p(true),s(null);try{let d=await t.getRequests(e);n(d);}catch(d){s(d instanceof Error?d:new Error("Failed to fetch requests"));}finally{p(false);}},[t,r,e?.status,e?.type,e?.limit,e?.offset]);return useEffect(()=>{o&&r&&a();},[o,r,a]),{requests:i?.requests||[],pagination:i?.pagination,isLoading:c,error:l,refetch:a}}function lo(){let{client:e}=U(),t=useCallback(async(r,i)=>{await e.track(r,i);},[e]),o=useCallback(async r=>{await e.trackBatch({events:r});},[e]);return {track:t,trackBatch:o}}function co(e){let{client:t,isReady:o}=U(),[r,i]=useState(null),[n,c]=useState(true),[p,l]=useState(null),s=useCallback(async()=>{c(true),l(null);try{let a=await t.getGuides(e);i(a);}catch(a){l(a instanceof Error?a:new Error("Failed to fetch guides"));}finally{c(false);}},[t,e?.projectId,e?.url,e?.userId]);return useEffect(()=>{o&&s();},[o,s]),{guides:r?.guides||[],completedGuides:r?.completedGuides||[],isLoading:n,error:p,refetch:s}}function Ne(){let{client:e,isReady:t}=U(),[o,r]=useState(null),[i,n]=useState([]),[c,p]=useState(false),[l,s]=useState(false),[a,d]=useState(null),[g,f]=useState(null),u=useRef(false),w=useCallback(async R=>{p(true),d(null);try{let x=await e.getGuide(R);return x&&(r(x),n(x.guide_steps||[]),f(x.guide_steps?.[0]?.id||null)),x}catch(x){return d(x instanceof Error?x:new Error("Failed to load guide")),null}finally{p(false);}},[e]),I=useCallback(async R=>{s(true),d(null);try{let x=await e.createGuide(R);return r(x),n([]),f(null),x}catch(x){throw d(x instanceof Error?x:new Error("Failed to create guide")),x}finally{s(false);}},[e]),h=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let x=await e.updateGuide(o.id,R);return r(x),u.current=!1,x}catch(x){throw d(x instanceof Error?x:new Error("Failed to update guide")),x}finally{s(false);}},[e,o]),E=useCallback(async()=>h({status:"published"}),[h]),C=useCallback(async()=>h({status:"draft"}),[h]),S=useCallback(async()=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuide(o.id),r(null),n([]),f(null);}catch(R){throw d(R instanceof Error?R:new Error("Failed to delete guide")),R}finally{s(false);}},[e,o]),_=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let x=await e.addGuideStep(o.id,R);return n(H=>[...H,x]),f(x.id),u.current=!0,x}catch(x){throw d(x instanceof Error?x:new Error("Failed to add step")),x}finally{s(false);}},[e,o]),v=useCallback(async(R,x)=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let H=await e.updateGuideStep(o.id,R,x);return n(q=>q.map(V=>V.id===R?H:V)),u.current=!0,H}catch(H){throw d(H instanceof Error?H:new Error("Failed to update step")),H}finally{s(false);}},[e,o]),G=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{await e.deleteGuideStep(o.id,R),n(x=>x.filter(H=>H.id!==R)),g===R&&f(i[0]?.id||null),u.current=!0;}catch(x){throw d(x instanceof Error?x:new Error("Failed to delete step")),x}finally{s(false);}},[e,o,g,i]),m=useCallback(async R=>{if(!o)throw new Error("No guide loaded");s(true),d(null);try{let x=await e.reorderGuideSteps(o.id,R);return n(x),u.current=!0,x}catch(x){throw d(x instanceof Error?x:new Error("Failed to reorder steps")),x}finally{s(false);}},[e,o]),A=useCallback(async R=>{let x=i.findIndex(q=>q.id===R);if(x<=0)return;let H=i.map((q,V)=>V===x?{id:q.id,sort_order:x-1}:V===x-1?{id:q.id,sort_order:x}:{id:q.id,sort_order:V});return m(H)},[i,m]),B=useCallback(async R=>{let x=i.findIndex(q=>q.id===R);if(x<0||x>=i.length-1)return;let H=i.map((q,V)=>V===x?{id:q.id,sort_order:x+1}:V===x+1?{id:q.id,sort_order:x}:{id:q.id,sort_order:V});return m(H)},[i,m]),b=g&&i.find(R=>R.id===g)||null,P=useCallback(()=>{r(null),n([]),f(null),d(null),u.current=false;},[]);return {guide:o,steps:i,selectedStep:b,selectedStepId:g,isLoading:c,isSaving:l,error:a,isReady:t,hasUnsavedChanges:u.current,loadGuide:w,createGuide:I,updateGuide:h,publishGuide:E,unpublishGuide:C,deleteGuide:S,addStep:_,updateStep:v,deleteStep:G,reorderSteps:m,moveStepUp:A,moveStepDown:B,setSelectedStepId:f,reset:P}}function po(){let{client:e,isReady:t}=U(),[o,r]=useState(null),[i,n]=useState(0),[c,p]=useState(false),[l,s]=useState([]),[a,d]=useState([]),g=useCallback((P,R=0)=>{r(P),n(R),p(true);},[]),f=useCallback(()=>{if(!o)return;let P=o.guide_steps||[];i<P.length-1?n(R=>R+1):(s(R=>[...R,o.id]),p(false),r(null));},[o,i]),u=useCallback(()=>{i>0&&n(P=>P-1);},[i]),w=useCallback(P=>{if(!o)return;let R=o.guide_steps||[];P>=0&&P<R.length&&n(P);},[o]),I=useCallback(()=>{o&&d(P=>[...P,o.id]),p(false),r(null),n(0);},[o]),h=useCallback(()=>{p(false);},[]),E=useCallback(()=>{o&&p(true);},[o]),C=useCallback(async(P,R)=>{let x=P.guide_steps?.[R];if(x)try{await e.track("guide_step_viewed",{guide_id:P.id,guide_name:P.name,step_id:x.id,step_index:R,step_type:x.step_type});}catch{}},[e]),S=useCallback(async P=>{try{await e.track("guide_completed",{guide_id:P.id,guide_name:P.name,total_steps:P.guide_steps?.length||0});}catch{}},[e]),_=useCallback(async(P,R)=>{try{await e.track("guide_dismissed",{guide_id:P.id,guide_name:P.name,dismissed_at_step:R,total_steps:P.guide_steps?.length||0});}catch{}},[e]),v=o?.guide_steps?.[i]||null,G=o?.guide_steps?.length||0,m=i===G-1,A=i===0,B=useCallback(P=>l.includes(P),[l]),b=useCallback(P=>a.includes(P),[a]);return {activeGuide:o,currentStep:v,currentStepIndex:i,totalSteps:G,isPlaying:c,isFirstStep:A,isLastStep:m,isReady:t,startGuide:g,nextStep:f,prevStep:u,goToStep:w,dismiss:I,pause:h,resume:E,trackStepView:C,trackGuideComplete:S,trackGuideDismiss:_,completedGuideIds:l,dismissedGuideIds:a,isGuideCompleted:B,isGuideDismissed:b}}var yt={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},fo={tooltip:"Points to a specific element with an arrow",modal:"Centered overlay that grabs attention",slideout:"Slides in from the side of the screen",hotspot:"Pulsing beacon that expands on click",banner:"Top or bottom bar announcement",embedded:"Inline content injected into the page"},go=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],mo=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function Ue({step:e,onUpdate:t,onSelectElement:o,isSelectingElement:r}){let[i,n]=useState(false),[c,p]=useState(e.step_type),[l,s]=useState(e.rich_content?.title||e.title||""),[a,d]=useState(e.rich_content?.body||e.content||""),[g,f]=useState(e.tooltip_position||e.display_config?.position||"auto"),[u,w]=useState(e.selector_strategy?.css||""),[I,h]=useState(e.display_config?.backdrop!==false),[E,C]=useState(e.advance_config?.trigger||"button"),[S,_]=useState(e.advance_config?.delay||3e3),v=useCallback(async()=>{n(true);try{let m=u?{css:u}:void 0,A={title:l||void 0,body:a||void 0},B={position:g!=="auto"?g:void 0,backdrop:I},b={trigger:E,delay:E==="delay"?S:void 0};await t(e.id,{stepType:c,selectorStrategy:m,richContent:A,displayConfig:B,advanceConfig:b,tooltipPosition:g});}finally{n(false);}},[e.id,c,l,a,g,u,I,E,S,t]),G=c==="tooltip"||c==="hotspot";return jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsx("span",{style:{fontWeight:500},children:"Edit Step"}),jsx("button",{onClick:v,disabled:i,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:i?"wait":"pointer",opacity:i?.7:1},children:i?"Saving...":"Save Changes"})]}),jsxs("div",{style:{flex:1,overflow:"auto",padding:"16px"},children:[jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Step Type"}),jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px"},children:Object.keys(yt).map(m=>jsxs("button",{onClick:()=>p(m),style:{padding:"10px",border:`2px solid ${c===m?"#2563eb":"#e5e7eb"}`,borderRadius:"6px",backgroundColor:c===m?"#eff6ff":"white",cursor:"pointer",textAlign:"left"},children:[jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:yt[m]}),jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:fo[m]})]},m))})]}),G&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Target Element"}),jsxs("div",{style:{display:"flex",gap:"8px"},children:[jsx("input",{type:"text",value:u,onChange:m=>w(m.target.value),placeholder:"CSS selector (e.g., #my-button)",style:{flex:1,padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",fontFamily:"monospace"}}),jsx("button",{onClick:o,disabled:r,style:{padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:r?"#f3f4f6":"white",cursor:r?"wait":"pointer"},children:r?"Selecting...":"Select"})]}),jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px"},children:'Click "Select" to pick an element on the page, or enter a CSS selector manually'})]}),jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Title"}),jsx("input",{type:"text",value:l,onChange:m=>s(m.target.value),placeholder:"Enter step title",style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]}),jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Content"}),jsx("textarea",{value:a,onChange:m=>d(m.target.value),placeholder:"Enter step content (HTML supported)",rows:4,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",resize:"vertical",fontFamily:"inherit"}})]}),(c==="tooltip"||c==="hotspot")&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Position"}),jsx("select",{value:g,onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:go.map(m=>jsx("option",{value:m.value,children:m.label},m.value))})]}),c==="banner"&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Banner Position"}),jsxs("select",{value:g==="bottom"?"bottom":"top",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsx("option",{value:"top",children:"Top"}),jsx("option",{value:"bottom",children:"Bottom"})]})]}),c==="slideout"&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Slideout Side"}),jsxs("select",{value:g==="left"?"left":"right",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsx("option",{value:"right",children:"Right"}),jsx("option",{value:"left",children:"Left"})]})]}),(c==="tooltip"||c==="modal")&&jsxs("div",{style:{marginBottom:"20px"},children:[jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[jsx("input",{type:"checkbox",checked:I,onChange:m=>h(m.target.checked),style:{width:"16px",height:"16px"}}),jsx("span",{style:{fontSize:"13px",fontWeight:500},children:"Show backdrop overlay"})]}),jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px",marginLeft:"24px"},children:"Dims the background to focus attention on the step"})]}),jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Advance When"}),jsx("select",{value:E,onChange:m=>C(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:mo.map(m=>jsx("option",{value:m.value,children:m.label},m.value))})]}),E==="delay"&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Delay (seconds)"}),jsx("input",{type:"number",value:S/1e3,onChange:m=>_(Number(m.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function yo(e){let t={},o=e.getAttribute("data-testid");if(o)return t.testId=o,t.css=`[data-testid="${o}"]`,t;if(e.id)return t.css=`#${CSS.escape(e.id)}`,t;let r=[],i=e,n=0,c=5;for(;i&&i!==document.body&&n<c;){let l=i.tagName.toLowerCase(),s=Array.from(i.classList).filter(g=>!g.startsWith("hover")&&!g.startsWith("focus")&&!g.startsWith("active")).slice(0,2);s.length>0&&(l+="."+s.map(g=>CSS.escape(g)).join("."));let a=i.parentElement;if(a){let g=Array.from(a.children).filter(f=>f.tagName===i.tagName);if(g.length>1){let f=g.indexOf(i)+1;l+=`:nth-of-type(${f})`;}}r.unshift(l);let d=r.join(" > ");try{if(document.querySelectorAll(d).length===1){t.css=d;break}}catch{}i=i.parentElement,n++;}!t.css&&r.length>0&&(t.css=r.join(" > "));let p=e.textContent?.trim();return p&&p.length<100&&p.length>2&&(t.text=p.slice(0,50)),t}function xo(e){let t=0;if(e.css)try{t=document.querySelectorAll(e.css).length;}catch{}return e.testId&&(t=document.querySelectorAll(`[data-testid="${e.testId}"]`).length),{isUnique:t===1,count:t}}function ht({isActive:e,onSelect:t,onCancel:o,ignoreSelector:r="[data-census-builder]",zIndex:i=99999}){let[n,c]=useState(null),[p,l]=useState(null),[s,a]=useState(null),d=useRef(null),g=useCallback(()=>{if(!n){l(null);return}l(n.getBoundingClientRect());},[n]);useEffect(()=>{if(!e)return;let w=h=>{let C=document.elementsFromPoint(h.clientX,h.clientY).find(S=>!(d.current?.contains(S)||r&&S.closest(r)||S===document.body||S===document.documentElement));C!==n&&(c(C||null),a(C?yo(C):null));},I=()=>{g();};return document.addEventListener("mousemove",w,true),window.addEventListener("scroll",I,true),window.addEventListener("resize",I),()=>{document.removeEventListener("mousemove",w,true),window.removeEventListener("scroll",I,true),window.removeEventListener("resize",I);}},[e,n,r,g]),useEffect(()=>{g();},[n,g]);let f=useCallback(w=>{w.preventDefault(),w.stopPropagation(),n&&s&&t(s,n);},[n,s,t]);if(useEffect(()=>{if(!e)return;let w=I=>{I.key==="Escape"&&o();};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[e,o]),!e)return null;let u=s?xo(s):null;return jsxs("div",{ref:d,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:f,children:[p&&jsx("div",{style:{position:"fixed",top:p.top,left:p.left,width:p.width,height:p.height,border:"2px solid #2563eb",borderRadius:"4px",backgroundColor:"rgba(37, 99, 235, 0.1)",pointerEvents:"none",transition:"all 0.1s ease-out"}}),p&&s&&jsxs("div",{style:{position:"fixed",top:Math.max(8,p.top-40),left:p.left,padding:"6px 10px",backgroundColor:"#1f2937",color:"white",fontSize:"12px",fontFamily:"monospace",borderRadius:"4px",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},children:[jsx("span",{style:{color:"#9ca3af"},children:s.testId?"data-testid: ":""}),s.testId||s.css,u&&jsxs("span",{style:{marginLeft:"8px",color:u.isUnique?"#4ade80":"#fbbf24"},children:["(",u.count," match",u.count!==1?"es":"",")"]})]}),jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,padding:"12px 20px",backgroundColor:"#1f2937",color:"white",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px"},children:[jsxs("span",{children:["Click on any element to select it, or press ",jsx("kbd",{style:{padding:"2px 6px",backgroundColor:"#374151",borderRadius:"4px",marginLeft:"4px",marginRight:"4px"},children:"Esc"})," to cancel"]}),jsx("button",{onClick:w=>{w.stopPropagation(),o();},style:{padding:"6px 12px",border:"1px solid #4b5563",borderRadius:"4px",backgroundColor:"transparent",color:"white",cursor:"pointer"},children:"Cancel"})]})]})}function je({isOpen:e,onClose:t,guideId:o,onSave:r,onPublish:i,trigger:n,className:c,mode:p="fullscreen"}){let[l,s]=useState(false),a=e??l,{guide:d,steps:g,selectedStep:f,selectedStepId:u,isLoading:w,isSaving:I,error:h,loadGuide:E,updateGuide:C,publishGuide:S,addStep:_,updateStep:v,deleteStep:G,moveStepUp:m,moveStepDown:A,setSelectedStepId:B,reset:b}=Ne(),P=useCallback(async()=>{s(true),o&&await E(o);},[o,E]),R=useCallback(()=>{s(false),b(),t?.();},[b,t]),x=useCallback(async()=>{if(d)try{await C({}),r?.(d);}catch{}},[d,C,r]),H=useCallback(async()=>{if(d)try{let V=await S();i?.(V);}catch{}},[d,S,i]),q=useCallback(async(V="tooltip")=>{try{await _({stepType:V,richContent:{title:"New Step",body:"Click to edit..."}});}catch{}},[_]);return n&&e===void 0?jsxs(Fragment,{children:[jsx("span",{onClick:P,children:n}),a&&jsx(vt,{guide:d,steps:g,selectedStep:f,selectedStepId:u,isLoading:w,isSaving:I,error:h,onClose:R,onSave:x,onPublish:H,onAddStep:q,onSelectStep:B,onUpdateStep:v,onDeleteStep:G,onMoveStepUp:m,onMoveStepDown:A,className:c,mode:p})]}):a?jsx(vt,{guide:d,steps:g,selectedStep:f,selectedStepId:u,isLoading:w,isSaving:I,error:h,onClose:R,onSave:x,onPublish:H,onAddStep:q,onSelectStep:B,onUpdateStep:v,onDeleteStep:G,onMoveStepUp:m,onMoveStepDown:A,className:c,mode:p}):null}function vt({guide:e,steps:t,selectedStep:o,selectedStepId:r,isLoading:i,isSaving:n,error:c,onClose:p,onSave:l,onPublish:s,onAddStep:a,onSelectStep:d,onUpdateStep:g,onDeleteStep:f,onMoveStepUp:u,onMoveStepDown:w,className:I,mode:h="fullscreen"}){let[E,C]=useState(false),[S,_]=useState(false),v=h==="docked",G={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},m=useCallback((B,b)=>{o&&g(o.id,{selectorStrategy:B}),C(false);},[o,g]),A=i?jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:"Loading..."}):t.length===0?jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:'No steps yet. Click "Add Step" to get started.'}):t.map((B,b)=>jsxs("div",{onClick:()=>d(B.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:r===B.id?"#eff6ff":"white",border:`1px solid ${r===B.id?"#3b82f6":"#e5e7eb"}`,cursor:"pointer"},children:[jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("span",{style:{fontWeight:500,fontSize:"14px"},children:[b+1,". ",G[B.step_type]]}),jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsx("button",{onClick:P=>{P.stopPropagation(),u(B.id);},disabled:b===0,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:b===0?"not-allowed":"pointer",opacity:b===0?.3:1},children:"Up"}),jsx("button",{onClick:P=>{P.stopPropagation(),w(B.id);},disabled:b===t.length-1,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:b===t.length-1?"not-allowed":"pointer",opacity:b===t.length-1?.3:1},children:"Down"}),jsx("button",{onClick:P=>{P.stopPropagation(),confirm("Delete this step?")&&f(B.id);},style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #fecaca",borderRadius:"3px",backgroundColor:"#fef2f2",color:"#dc2626",cursor:"pointer"},children:"Delete"})]})]}),jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"#6b7280"},children:B.rich_content?.title||B.title||"Untitled"})]},B.id));return jsxs(Fragment,{children:[jsx(ht,{isActive:E,onSelect:m,onCancel:()=>C(false),ignoreSelector:"[data-census-builder]"}),v&&jsx("button",{"data-census-builder":true,onClick:()=>_(!S),style:{position:"fixed",top:"50%",right:S?0:"420px",transform:"translateY(-50%)",zIndex:1e4,width:"24px",height:"48px",border:"1px solid #e5e7eb",borderRight:S?"1px solid #e5e7eb":"none",borderRadius:"6px 0 0 6px",backgroundColor:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"-2px 0 8px rgba(0,0,0,0.08)",transition:"right 0.2s ease",fontSize:"12px",color:"#6b7280",padding:0},children:S?"\u25C0":"\u25B6"}),jsxs("div",{className:I,"data-census-builder":true,style:v?{position:"fixed",top:0,right:S?"-420px":0,bottom:0,width:"420px",zIndex:9999,display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",fontFamily:"system-ui, -apple-system, sans-serif",boxShadow:"-4px 0 20px rgba(0,0,0,0.1)",transition:"right 0.2s ease"}:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:v?"10px 16px":"12px 20px",backgroundColor:"white",borderBottom:"1px solid #e5e7eb"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:v?"8px":"12px",minWidth:0},children:[jsx("button",{onClick:p,style:{padding:v?"6px 10px":"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:"pointer",fontSize:v?"13px":"14px",flexShrink:0},children:"Close"}),jsx("h1",{style:{margin:0,fontSize:v?"15px":"18px",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e?e.name:"Guide Builder"}),e?.status&&jsx("span",{style:{padding:"2px 8px",fontSize:"12px",borderRadius:"4px",backgroundColor:e.status==="published"?"#dcfce7":"#fef3c7",color:e.status==="published"?"#166534":"#92400e",flexShrink:0},children:e.status})]}),jsxs("div",{style:{display:"flex",gap:"8px",flexShrink:0},children:[c&&!v&&jsx("span",{style:{color:"#dc2626",fontSize:"14px"},children:c.message}),jsx("button",{onClick:l,disabled:n||!e,style:{padding:v?"6px 12px":"8px 16px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:n?"wait":"pointer",opacity:n?.5:1,fontSize:v?"13px":"14px"},children:n?"Saving...":"Save"}),jsx("button",{onClick:s,disabled:n||!e||e.status==="published",style:{padding:v?"6px 12px":"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#2563eb",color:"white",cursor:n?"wait":"pointer",opacity:n||e?.status==="published"?.5:1,fontSize:v?"13px":"14px"},children:"Publish"})]})]}),v&&c&&jsx("div",{style:{padding:"8px 16px",backgroundColor:"#fef2f2",borderBottom:"1px solid #fecaca",color:"#dc2626",fontSize:"13px"},children:c.message}),v?jsxs("div",{style:{flex:1,overflow:"auto"},children:[jsxs("div",{style:{backgroundColor:"white",borderBottom:"1px solid #e5e7eb"},children:[jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("span",{style:{fontWeight:500,fontSize:"14px"},children:["Steps (",t.length,")"]}),jsx("button",{onClick:()=>a("tooltip"),disabled:!e,style:{padding:"5px 10px",fontSize:"12px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:e?"pointer":"not-allowed",opacity:e?1:.5},children:"+ Add Step"})]}),jsx("div",{style:{padding:"8px"},children:A})]}),jsx("div",{style:{backgroundColor:"white"},children:o?jsx(Ue,{step:o,onUpdate:g,onSelectElement:()=>C(true),isSelectingElement:E}):jsx("div",{style:{padding:"16px",textAlign:"center",color:"#6b7280"},children:jsx("p",{children:"Select a step to edit"})})})]}):jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[jsxs("aside",{style:{width:"280px",backgroundColor:"white",borderRight:"1px solid #e5e7eb",display:"flex",flexDirection:"column"},children:[jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("span",{style:{fontWeight:500},children:["Steps (",t.length,")"]}),jsx("button",{onClick:()=>a("tooltip"),disabled:!e,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:e?"pointer":"not-allowed",opacity:e?1:.5},children:"+ Add Step"})]}),jsx("div",{style:{flex:1,overflow:"auto",padding:"8px"},children:A})]}),jsxs("main",{style:{flex:1,display:"flex",flexDirection:"column",backgroundColor:"#f3f4f6"},children:[jsx("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",backgroundColor:"white"},children:jsx("span",{style:{fontWeight:500},children:"Preview"})}),jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"},children:o?jsxs("div",{style:{padding:"24px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)",maxWidth:"400px",width:"100%"},children:[jsx("div",{style:{marginBottom:"12px"},children:jsx("span",{style:{padding:"4px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",textTransform:"uppercase"},children:G[o.step_type]})}),jsx("h3",{style:{margin:"0 0 8px",fontSize:"16px"},children:o.rich_content?.title||o.title||"Step Preview"}),jsx("p",{style:{margin:0,color:"#4b5563"},children:o.rich_content?.body||o.content||"No content"}),o.rich_content?.media&&jsx("div",{style:{marginTop:"12px"},children:o.rich_content.media.type==="image"&&jsx("img",{src:o.rich_content.media.url,alt:o.rich_content.media.alt||"",style:{maxWidth:"100%",borderRadius:"4px"}})}),o.rich_content?.buttons&&o.rich_content.buttons.length>0&&jsx("div",{style:{marginTop:"16px",display:"flex",gap:"8px"},children:o.rich_content.buttons.map((B,b)=>jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:B.style==="primary"?"#2563eb":"#f3f4f6",color:B.style==="primary"?"white":"#374151"},children:B.label},b))}),o.selector_strategy?.css&&jsxs("div",{style:{marginTop:"16px",padding:"8px",backgroundColor:"#f9fafb",borderRadius:"4px",fontSize:"11px",fontFamily:"monospace",color:"#6b7280"},children:["Target: ",o.selector_strategy.css]})]}):jsx("p",{children:"Select a step to preview"})})]}),jsx("aside",{style:{width:"360px",backgroundColor:"white",borderLeft:"1px solid #e5e7eb",display:"flex",flexDirection:"column",overflow:"hidden"},children:o?jsx(Ue,{step:o,onUpdate:g,onSelectElement:()=>C(true),isSelectingElement:E}):jsx("div",{style:{padding:"16px"},children:jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function Ve(){let[e,t]=useState(false),[o,r]=useState(void 0);useEffect(()=>{if(typeof window>"u")return;let n=new URLSearchParams(window.location.search),c=n.get("census-builder"),p=n.get("census-guide-id");c==="true"&&(t(true),p&&r(p));},[]);let i=useCallback(()=>{if(t(false),r(void 0),typeof window<"u"){let n=new URL(window.location.href);n.searchParams.delete("census-builder"),n.searchParams.delete("census-guide-id"),window.history.replaceState({},"",n.toString());}},[]);return e?jsx(je,{isOpen:true,guideId:o,mode:"docked",onClose:i}):null}var Ke=createContext(null);function ko({apiKey:e,baseUrl:t,projectId:o,debug:r,user:i,theme:n={},children:c}){let[p,l]=useState(false),[s,a]=useState(false),d=useMemo(()=>bt({apiKey:e,baseUrl:t,projectId:o,debug:r}),[e,t,o,r]);useEffect(()=>{i?d.identify(i).then(()=>{a(true),l(true);}).catch(f=>{console.error("[Census] Failed to identify user:",f),l(true);}):l(true);},[d,i]);let g=useMemo(()=>({client:d,theme:n,isReady:p,isIdentified:s}),[d,n,p,s]);return jsxs(Ke.Provider,{value:g,children:[c,jsx(Ve,{})]})}function Ro(){let e=useContext(Ke);if(!e)throw new Error("useCensus must be used within a CensusProvider");return e.client}function U(){let e=useContext(Ke);if(!e)throw new Error("useCensusContext must be used within a CensusProvider");return e}function Eo(){let{client:e}=U(),[t,o]=useState(false),[r,i]=useState(null);return {identify:async p=>{o(true),i(null);try{await e.identify(p);}catch(l){throw i(l instanceof Error?l:new Error("Failed to identify user")),l}finally{o(false);}},reset:()=>{e.reset();},isIdentifying:t,isIdentified:e.isIdentified(),error:r}}var ie={button:{position:"fixed",padding:"12px 20px",border:"none",borderRadius:"8px",cursor:"pointer",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px",fontWeight:"500",transition:"transform 0.2s",zIndex:9999},modal:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e4},modalContent:{backgroundColor:"white",borderRadius:"12px",padding:"24px",width:"100%",maxWidth:"400px",margin:"16px",boxShadow:"0 20px 50px rgba(0, 0, 0, 0.2)",fontFamily:"system-ui, -apple-system, sans-serif"},textarea:{width:"100%",padding:"10px 12px",border:"1px solid #e0e0e0",borderRadius:"6px",fontSize:"14px",marginBottom:"16px",minHeight:"100px",resize:"vertical",boxSizing:"border-box",fontFamily:"inherit"},submitButton:{width:"100%",padding:"12px",border:"none",borderRadius:"6px",cursor:"pointer",fontSize:"14px",fontWeight:"500",transition:"opacity 0.2s"},typeButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"6px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"}},To={"bottom-right":{bottom:"20px",right:"20px"},"bottom-left":{bottom:"20px",left:"20px"},"top-right":{top:"20px",right:"20px"},"top-left":{top:"20px",left:"20px"}},Po={feedback:"General Feedback",bug_report:"Bug Report",feature_request:"Feature Request",article_rating:"Article Rating"},_o={feedback:"\u{1F4AC}",bug_report:"\u{1F41B}",feature_request:"\u{1F4A1}",article_rating:"\u2B50"};function Bo(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function Lo({position:e="bottom-right",text:t="Feedback",allowedTypes:o=["feedback","bug_report","feature_request"],theme:r,onSubmit:i,onError:n,children:c}){let{theme:p}=U(),{submitFeedback:l,isSubmitting:s,isSuccess:a,reset:d}=ye(),[g,f]=useState(false),[u,w]=useState(o[0]),[I,h]=useState(""),E={...p,...r},C=Bo(E),S=useCallback(()=>{f(true),d();},[d]),_=useCallback(()=>{f(false),h(""),w(o[0]);},[o]),v=useCallback(async G=>{G.preventDefault();let m={type:u,message:I};try{await l(m),i?.(m),setTimeout(_,1500);}catch(A){n?.(A instanceof Error?A:new Error("Failed to submit feedback"));}},[u,I,l,i,n,_]);return c?jsxs(Fragment,{children:[jsx("div",{onClick:S,style:{cursor:"pointer"},children:c}),g&&jsx(Rt,{isOpen:g,onClose:_,selectedType:u,onTypeChange:w,allowedTypes:o,message:I,onMessageChange:h,onSubmit:v,isSubmitting:s,isSuccess:a,themeStyles:C})]}):jsxs(Fragment,{children:[jsx("button",{onClick:S,style:{...ie.button,...To[e],backgroundColor:C.primaryColor,color:"white",borderRadius:C.borderRadius,fontFamily:C.fontFamily},"aria-label":"Open feedback form",children:t}),g&&jsx(Rt,{isOpen:g,onClose:_,selectedType:u,onTypeChange:w,allowedTypes:o,message:I,onMessageChange:h,onSubmit:v,isSubmitting:s,isSuccess:a,themeStyles:C})]})}function Rt({isOpen:e,onClose:t,selectedType:o,onTypeChange:r,allowedTypes:i,message:n,onMessageChange:c,onSubmit:p,isSubmitting:l,isSuccess:s,themeStyles:a}){return e?s?jsx("div",{style:ie.modal,onClick:t,children:jsxs("div",{style:{...ie.modalContent,textAlign:"center",fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"\u{1F389}"}),jsx("h3",{style:{margin:"0 0 8px 0",color:a.textColor},children:"Thanks for your feedback!"}),jsx("p",{style:{margin:0,color:"#666"},children:"We appreciate you taking the time to share."})]})}):jsx("div",{style:ie.modal,onClick:t,children:jsxs("div",{style:{...ie.modalContent,fontFamily:a.fontFamily},onClick:d=>d.stopPropagation(),children:[jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[jsx("h3",{style:{margin:0,color:a.textColor},children:"Send Feedback"}),jsx("button",{onClick:t,style:{background:"none",border:"none",fontSize:"24px",cursor:"pointer",color:"#999",padding:"0",lineHeight:"1"},"aria-label":"Close",children:"\xD7"})]}),jsxs("form",{onSubmit:p,children:[jsxs("div",{style:{marginBottom:"16px"},children:[jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"What kind of feedback?"}),jsx("div",{style:{display:"flex",flexWrap:"wrap"},children:i.map(d=>jsxs("button",{type:"button",onClick:()=>r(d),style:{...ie.typeButton,backgroundColor:o===d?a.primaryColor:"white",color:o===d?"white":a.textColor,borderColor:o===d?a.primaryColor:"#e0e0e0"},children:[_o[d]," ",Po[d]]},d))})]}),jsxs("div",{children:[jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"13px",color:"#666",fontWeight:"500"},children:"Your message"}),jsx("textarea",{value:n,onChange:d=>c(d.target.value),placeholder:o==="bug_report"?"Describe the bug and steps to reproduce...":o==="feature_request"?"Describe the feature you would like...":"Share your thoughts...",style:ie.textarea,required:true})]}),jsx("button",{type:"submit",disabled:l||!n.trim(),style:{...ie.submitButton,backgroundColor:a.primaryColor,color:"white",opacity:l||!n.trim()?.6:1,cursor:l||!n.trim()?"not-allowed":"pointer"},children:l?"Sending...":"Send Feedback"})]})]})}):null}var D={container:{fontFamily:"system-ui, -apple-system, sans-serif",maxWidth:"800px"},searchInput:{width:"100%",padding:"12px 16px",border:"1px solid #e0e0e0",borderRadius:"8px",fontSize:"15px",marginBottom:"24px",boxSizing:"border-box"},categoryButton:{padding:"8px 16px",border:"1px solid #e0e0e0",borderRadius:"20px",cursor:"pointer",fontSize:"13px",backgroundColor:"white",transition:"all 0.2s",marginRight:"8px",marginBottom:"8px"},articleCard:{padding:"20px",border:"1px solid #e0e0e0",borderRadius:"8px",marginBottom:"12px",cursor:"pointer",transition:"border-color 0.2s",backgroundColor:"white"},articleTitle:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:"600"},articleDescription:{margin:0,fontSize:"14px",color:"#666",lineHeight:1.5},articleMeta:{display:"flex",gap:"16px",marginTop:"12px",fontSize:"12px",color:"#999"},backButton:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"8px 0",border:"none",background:"none",cursor:"pointer",fontSize:"14px",color:"#666",marginBottom:"16px"},articleContent:{lineHeight:1.7,fontSize:"15px"},loading:{textAlign:"center",padding:"40px",color:"#666"},error:{padding:"20px",backgroundColor:"#fef2f2",borderRadius:"8px",color:"#b91c1c",textAlign:"center"},empty:{textAlign:"center",padding:"40px",color:"#666"}};function Fo(e){return {primaryColor:e.primaryColor||"#000000",textColor:e.textColor||"#333333",backgroundColor:e.backgroundColor||"#ffffff",borderRadius:e.borderRadius||"8px",fontFamily:e.fontFamily||"system-ui, -apple-system, sans-serif"}}function Ao({showSearch:e=true,showCategories:t=true,defaultCategory:o,theme:r,className:i,onArticleView:n}){let{theme:c}=U(),[p,l]=useState(""),[s,a]=useState(o),[d,g]=useState(null),f={...c,...r},u=Fo(f),{articles:w,isLoading:I,error:h}=xe({category:s,search:p||void 0}),{article:E,isLoading:C,error:S}=he(d||""),_=useMemo(()=>{let m=new Set;return w.forEach(A=>{A.category&&m.add(A.category);}),Array.from(m).sort()},[w]),v=m=>{g(m.slug),n?.(m);},G=()=>{g(null);};return d?C?jsx("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:jsx("div",{style:D.loading,children:"Loading article..."})}):S?jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[jsx("button",{onClick:G,style:D.backButton,children:"\u2190 Back to articles"}),jsx("div",{style:D.error,children:"Failed to load article. Please try again."})]}):E?jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[jsx("button",{onClick:G,style:D.backButton,children:"\u2190 Back to articles"}),jsxs("article",{children:[jsx("h1",{style:{margin:"0 0 16px 0",color:u.textColor},children:E.title}),E.read_time_minutes&&jsxs("div",{style:{fontSize:"14px",color:"#666",marginBottom:"24px"},children:[E.read_time_minutes," min read"]}),E.content_html?jsx("div",{style:{...D.articleContent,color:u.textColor},dangerouslySetInnerHTML:{__html:E.content_html}}):jsx("div",{style:{...D.articleContent,color:u.textColor},children:typeof E.content=="string"?E.content:"No content available."})]})]}):jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[jsx("button",{onClick:G,style:D.backButton,children:"\u2190 Back to articles"}),jsx("div",{style:D.empty,children:"Article not found."})]}):jsxs("div",{style:{...D.container,fontFamily:u.fontFamily},className:i,children:[e&&jsx("input",{type:"text",placeholder:"Search articles...",value:p,onChange:m=>l(m.target.value),style:D.searchInput}),t&&_.length>0&&jsxs("div",{style:{marginBottom:"24px"},children:[jsx("button",{onClick:()=>a(void 0),style:{...D.categoryButton,backgroundColor:s?"white":u.primaryColor,color:s?u.textColor:"white",borderColor:s?"#e0e0e0":u.primaryColor},children:"All"}),_.map(m=>jsx("button",{onClick:()=>a(m),style:{...D.categoryButton,backgroundColor:s===m?u.primaryColor:"white",color:s===m?"white":u.textColor,borderColor:s===m?u.primaryColor:"#e0e0e0"},children:m},m))]}),I&&jsx("div",{style:D.loading,children:"Loading articles..."}),h&&jsx("div",{style:D.error,children:"Failed to load articles. Please try again."}),!I&&!h&&w.length===0&&jsx("div",{style:D.empty,children:p?`No articles found for "${p}"`:"No articles available yet."}),!I&&!h&&w.length>0&&jsx("div",{children:w.map(m=>jsxs("div",{onClick:()=>v(m),style:D.articleCard,role:"button",tabIndex:0,onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&v(m);},children:[jsx("h3",{style:{...D.articleTitle,color:u.textColor},children:m.title}),m.seo_description&&jsx("p",{style:D.articleDescription,children:m.seo_description}),jsxs("div",{style:D.articleMeta,children:[m.category&&jsx("span",{children:m.category}),m.read_time_minutes&&jsxs("span",{children:[m.read_time_minutes," min read"]})]})]},m.id))})]})}var X={container:{fontFamily:"system-ui, -apple-system, sans-serif"},list:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:"12px"},card:{border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px",backgroundColor:"#ffffff",cursor:"pointer",transition:"border-color 0.15s"},cardHover:{borderColor:"#d1d5db"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"8px"},badges:{display:"flex",alignItems:"center",gap:"6px"},badge:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"9999px",fontSize:"12px",fontWeight:500},message:{fontSize:"14px",color:"#111827",margin:0,lineHeight:1.5},meta:{display:"flex",gap:"12px",marginTop:"8px",fontSize:"12px",color:"#6b7280"},empty:{textAlign:"center",padding:"32px 16px",color:"#6b7280"},emptyIcon:{width:"48px",height:"48px",margin:"0 auto 12px",color:"#d1d5db"},loading:{textAlign:"center",padding:"24px",color:"#6b7280"},error:{textAlign:"center",padding:"24px",color:"#dc2626"}},It={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},Gt={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},reviewed:{label:"Reviewed",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function Do(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}function Oo({status:e,type:t,limit:o=50,className:r,showEmptyState:i=true,onRequestClick:n}){let{isIdentified:c}=U(),[p,l]=useState(null),{requests:s,isLoading:a,error:d,refetch:g}=ve({status:e,type:t,limit:o}),f=useCallback(u=>{n?.(u);},[n]);return c?a?jsx("div",{style:X.loading,children:jsx("p",{children:"Loading requests..."})}):d?jsx("div",{style:X.error,children:jsxs("p",{children:["Failed to load requests. ",jsx("button",{onClick:g,style:{color:"inherit",textDecoration:"underline",background:"none",border:"none",cursor:"pointer"},children:"Try again"})]})}):s.length===0&&i?jsxs("div",{style:X.empty,children:[jsx("svg",{style:X.emptyIcon,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),jsx("p",{style:{margin:0,fontWeight:500,color:"#111827"},children:"No requests yet"}),jsx("p",{style:{margin:"8px 0 0",fontSize:"14px"},children:"When you submit feedback, bug reports, or feature requests, they'll appear here."})]}):jsx("div",{style:X.container,className:r,children:jsx("ul",{style:X.list,children:s.map(u=>{let w=It[u.feedback_type]||It.feedback,I=Gt[u.status]||Gt.new,h=p===u.id;return jsxs("li",{style:{...X.card,...h?X.cardHover:{}},onMouseEnter:()=>l(u.id),onMouseLeave:()=>l(null),onClick:()=>f(u),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&f(u);},children:[jsx("div",{style:X.header,children:jsxs("div",{style:X.badges,children:[jsx("span",{style:{...X.badge,color:w.color,backgroundColor:w.bg},children:w.label}),jsx("span",{style:{...X.badge,color:I.color,backgroundColor:I.bg},children:I.label})]})}),jsx("p",{style:X.message,children:u.message||"No message provided"}),jsxs("div",{style:X.meta,children:[jsx("span",{children:Do(u.created_at)}),u.page_url&&jsxs("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"200px"},children:["From: ",u.page_url]})]})]},u.id)})})}):i?jsx("div",{style:X.empty,children:jsx("p",{children:"Please sign in to view your requests."})}):null}var $o={articles:"Documentation",requests:"My Requests"},Pt={feedback:{label:"Feedback",color:"#2563eb",bg:"#dbeafe"},bug_report:{label:"Bug Report",color:"#dc2626",bg:"#fee2e2"},feature_request:{label:"Feature Request",color:"#d97706",bg:"#fef3c7"},article_rating:{label:"Article Rating",color:"#7c3aed",bg:"#ede9fe"}},_t={new:{label:"New",color:"#6b7280",bg:"#f3f4f6"},planned:{label:"Planned",color:"#2563eb",bg:"#dbeafe"},in_progress:{label:"In Progress",color:"#d97706",bg:"#fef3c7"},resolved:{label:"Resolved",color:"#059669",bg:"#d1fae5"},closed:{label:"Closed",color:"#6b7280",bg:"#f3f4f6"}};function Ho(e){return new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}var Wo=[{value:"feedback",label:"Feedback"},{value:"bug_report",label:"Bug"},{value:"feature_request",label:"Feature"}],jo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Bt=()=>jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),Lt=()=>jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),Vo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}),Ko=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),Xo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),Yo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),Qo=()=>jsx("svg",{width:"48",height:"48",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"})}),Jo=()=>jsx("svg",{width:"16",height:"16",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),Ze=()=>jsx("svg",{width:"20",height:"20",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",style:{animation:"spin 1s linear infinite"},children:jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),zt={light:{primary:"#c45a2c",primaryHover:"#a84a24",primaryLight:"rgba(196, 90, 44, 0.08)",primaryLightHover:"rgba(196, 90, 44, 0.15)",background:"transparent",surface:"#ffffff",surfaceHover:"#fafafa",border:"rgba(0, 0, 0, 0.08)",borderHover:"rgba(196, 90, 44, 0.25)",text:"#1a1a1a",textSecondary:"#525252",textMuted:"#737373",textLight:"#a3a3a3"},dark:{primary:"#e07347",primaryHover:"#f08a5d",primaryLight:"rgba(224, 115, 71, 0.12)",primaryLightHover:"rgba(224, 115, 71, 0.2)",background:"transparent",surface:"rgba(255, 255, 255, 0.03)",surfaceHover:"rgba(255, 255, 255, 0.06)",border:"rgba(255, 255, 255, 0.08)",borderHover:"rgba(224, 115, 71, 0.35)",text:"#fafafa",textSecondary:"#d4d4d4",textMuted:"#a3a3a3",textLight:"#737373"}},Zo=e=>({container:{fontFamily:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',minHeight:"400px",color:e.text},grid:{display:"grid",gridTemplateColumns:"220px 1fr",gap:"40px"},sidebar:{position:"sticky",top:"24px",height:"fit-content"},main:{minWidth:0},tabs:{display:"flex",borderBottom:`1px solid ${e.border}`,marginBottom:"28px",gap:"0"},tab:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderBottomWidth:"2px",borderBottomStyle:"solid",borderBottomColor:"transparent",cursor:"pointer",transition:"all 0.15s",backgroundColor:"transparent",color:e.textMuted,marginBottom:"-1px"},tabActive:{color:e.primary,borderBottomColor:e.primary},searchContainer:{position:"relative",marginBottom:"20px"},searchIcon:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:e.textLight},searchInput:{width:"100%",padding:"8px 10px 8px 32px",fontSize:"13px",border:`1px solid ${e.border}`,borderRadius:"6px",outline:"none",backgroundColor:"transparent",color:e.text,boxSizing:"border-box"},sectionTitle:{fontSize:"10px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:e.textLight,marginBottom:"8px",marginTop:"20px"},navList:{listStyle:"none",padding:0,margin:0},navItem:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"6px 10px",fontSize:"13px",color:e.textSecondary,backgroundColor:"transparent",border:"none",borderRadius:"6px",cursor:"pointer",textAlign:"left",transition:"all 0.15s"},navItemActive:{backgroundColor:e.surfaceHover,color:e.text,fontWeight:500},subNav:{marginLeft:"20px",marginTop:"2px",paddingLeft:"10px",borderLeft:`1px solid ${e.border}`},articleGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},articleCard:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"14px",border:`1px solid ${e.border}`,borderRadius:"8px",backgroundColor:e.surface,cursor:"pointer",transition:"all 0.2s ease",textAlign:"left"},articleIcon:{flexShrink:0,width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:e.primaryLight,borderRadius:"8px",color:e.primary,transition:"background-color 0.2s"},articleContent:{flex:1,minWidth:0},articleTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0,lineHeight:1.4},articleDesc:{fontSize:"12px",color:e.textMuted,margin:"4px 0 0",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",lineHeight:1.5},articleMeta:{fontSize:"11px",color:e.textLight,marginTop:"6px"},articleChevron:{flexShrink:0,color:e.textLight,transition:"color 0.2s"},backButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 0",fontSize:"13px",color:e.textMuted,backgroundColor:"transparent",border:"none",cursor:"pointer",marginBottom:"20px",transition:"color 0.15s"},articleDetail:{maxWidth:"720px"},articleDetailTitle:{fontSize:"28px",fontWeight:600,color:e.text,margin:0,lineHeight:1.3},articleDetailMeta:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:e.textMuted,marginTop:"10px"},articleDetailContent:{marginTop:"28px",fontSize:"15px",lineHeight:1.7,color:e.textSecondary},emptyState:{textAlign:"center",padding:"48px 24px",color:e.textMuted},emptyIcon:{color:e.textLight,marginBottom:"12px",opacity:.5},emptyTitle:{fontSize:"16px",fontWeight:500,color:e.text,margin:"0 0 6px"},emptyText:{fontSize:"13px",margin:0,color:e.textMuted},loading:{display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",padding:"48px",color:e.textMuted,fontSize:"13px"},requestCard:{border:`1px solid ${e.border}`,borderRadius:"8px",padding:"16px",backgroundColor:e.surface,marginBottom:"10px",transition:"border-color 0.2s"},requestHeader:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"10px"},badge:{display:"inline-flex",alignItems:"center",padding:"3px 8px",borderRadius:"9999px",fontSize:"11px",fontWeight:500},requestMessage:{fontSize:"14px",color:e.text,margin:0,lineHeight:1.5},requestMeta:{display:"flex",gap:"12px",marginTop:"10px",fontSize:"12px",color:e.textMuted},form:{padding:"16px",backgroundColor:e.surface,borderRadius:"8px",border:`1px solid ${e.border}`,marginBottom:"20px"},formHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},formTitle:{fontSize:"14px",fontWeight:500,color:e.text,margin:0},typeSelector:{display:"flex",gap:"6px",marginBottom:"12px"},typeButton:{padding:"6px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,backgroundColor:"transparent",color:e.textSecondary,fontSize:"13px",cursor:"pointer",transition:"all 0.15s",fontWeight:500},typeButtonActive:{backgroundColor:e.primary,borderColor:e.primary,color:"#ffffff"},textarea:{width:"100%",padding:"10px 12px",borderRadius:"6px",border:`1px solid ${e.border}`,fontSize:"13px",resize:"vertical",minHeight:"80px",fontFamily:"inherit",marginBottom:"12px",boxSizing:"border-box",backgroundColor:"transparent",color:e.text},submitButton:{padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:e.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",transition:"all 0.15s"},newRequestButton:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"8px 16px",borderRadius:"6px",border:"none",backgroundColor:e.primary,color:"#ffffff",fontSize:"13px",fontWeight:500,cursor:"pointer",marginBottom:"20px",transition:"background-color 0.15s"},successMessage:{padding:"12px 14px",backgroundColor:"rgba(5, 150, 105, 0.1)",borderRadius:"6px",color:"#059669",fontSize:"13px",marginBottom:"12px",fontWeight:500}}),er=(e,t)=>`
2
2
  @keyframes spin {
3
3
  from { transform: rotate(0deg); }
4
4
  to { transform: rotate(360deg); }
@@ -50,7 +50,7 @@ import {createContext,useState,useMemo,useEffect,useContext,useCallback,useRef}f
50
50
  .census-hc .census-textarea::placeholder {
51
51
  color: ${e.textLight};
52
52
  }
53
- `;function Oo({tabs:e=["articles","requests"],defaultTab:t="articles",tabLabels:o={},showSearch:r=true,className:i,theme:n="auto"}){let[c,p]=useState(t),[l,s]=useState(""),[a,d]=useState(null),[g,f]=useState(new Set),[u,C]=useState(null),[G,x]=useState(false),[E,v]=useState("feedback"),[w,T]=useState(""),S=useRef(null),[I,m]=useState(false);useEffect(()=>{if(n!=="auto")return;let k=()=>{let me=document.documentElement,pt=me.getAttribute("data-theme");if(pt==="dark")return true;if(pt==="light")return false;let oo=me.classList.contains("dark")||me.style.colorScheme!==""||me.getAttribute("data-color-mode")!==null;return me.classList.contains("dark")?true:oo?false:window.matchMedia("(prefers-color-scheme: dark)").matches};m(k());let N=window.matchMedia("(prefers-color-scheme: dark)"),J=()=>m(k());N.addEventListener("change",J);let ct=new MutationObserver(()=>m(k()));return ct.observe(document.documentElement,{attributes:true,attributeFilter:["class","data-theme"]}),()=>{N.removeEventListener("change",J),ct.disconnect();}},[n]);let A=n==="dark"||n==="auto"&&I,D=A?kt.dark:kt.light,y=useMemo(()=>Do(D),[D]),P=useMemo(()=>No(D),[D,A]),{isIdentified:R}=O(),{articles:h,isLoading:U}=he({search:l||void 0}),{article:q,isLoading:Q}=xe(a?.slug||""),{requests:nt,isLoading:jt,refetch:it}=ve({limit:50}),{featureGroups:st,isLoading:Vt}=Oe(),{submitFeedback:at,isSubmitting:ge,isSuccess:Kt,reset:lt}=ye(),Xt={...Io,...o};useEffect(()=>{let k=N=>{(N.metaKey||N.ctrlKey)&&N.key==="k"&&(N.preventDefault(),S.current?.focus());};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[]);let Yt=k=>{f(N=>{let J=new Set(N);return J.has(k)?J.delete(k):J.add(k),J});},dt=useMemo(()=>h.filter(k=>!u||k.feature_id===u),[h,u]),Qt=useCallback(async k=>{if(k.preventDefault(),!(!w.trim()||ge))try{await at({type:E,message:w}),T(""),x(!1),setTimeout(()=>{it(),lt();},500);}catch{}},[E,w,ge,at,it,lt]),Jt=()=>Q||!q?jsxs("div",{style:y.loading,children:[jsx(Ve,{}),jsx("span",{children:"Loading article..."})]}):jsxs("div",{style:y.articleDetail,children:[jsxs("button",{onClick:()=>d(null),style:y.backButton,className:"census-back-btn",children:[jsx(Fo,{}),"Back to articles"]}),jsx("h1",{style:y.articleDetailTitle,children:q.title}),q.read_time_minutes&&jsxs("div",{style:y.articleDetailMeta,children:[jsx(zo,{}),q.read_time_minutes," min read"]}),q.content_html?jsx("div",{style:y.articleDetailContent,dangerouslySetInnerHTML:{__html:q.content_html}}):jsx("p",{style:{...y.articleDetailContent,color:"#6b7280"},children:"No content available."})]}),Zt=()=>a?Jt():U||Vt?jsxs("div",{style:y.loading,children:[jsx(Ve,{}),jsx("span",{children:"Loading..."})]}):dt.length===0?jsxs("div",{style:y.emptyState,children:[jsx("div",{style:y.emptyIcon,children:jsx(St,{})}),jsx("h3",{style:y.emptyTitle,children:"No articles found"}),jsx("p",{style:y.emptyText,children:l?`No results for "${l}"`:"No documentation articles available yet."})]}):jsx("div",{style:y.articleGrid,children:dt.map(k=>jsxs("button",{onClick:()=>d(k),style:y.articleCard,className:"census-article-card",children:[jsx("div",{style:y.articleIcon,className:"census-article-icon",children:jsx(St,{})}),jsxs("div",{style:y.articleContent,children:[jsx("h3",{style:y.articleTitle,children:k.title}),k.seo_description&&jsx("p",{style:y.articleDesc,children:k.seo_description}),k.read_time_minutes&&jsxs("p",{style:y.articleMeta,children:[k.read_time_minutes," min read"]})]}),jsx("span",{style:y.articleChevron,className:"census-article-chevron",children:jsx(wt,{})})]},k.id))}),eo=()=>Kt?jsx("div",{style:y.successMessage,children:"Thanks for your feedback! It has been submitted."}):G?jsxs("form",{onSubmit:Qt,style:y.form,children:[jsxs("div",{style:y.formHeader,children:[jsx("p",{style:y.formTitle,children:"Submit a request"}),jsx("button",{type:"button",onClick:()=>x(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsx("div",{style:y.typeSelector,children:_o.map(k=>jsx("button",{type:"button",onClick:()=>v(k.value),style:{...y.typeButton,...E===k.value?y.typeButtonActive:{}},children:k.label},k.value))}),jsx("textarea",{value:w,onChange:k=>T(k.target.value),placeholder:"Describe your request...",style:y.textarea,className:"census-textarea",required:true}),jsx("button",{type:"submit",style:{...y.submitButton,opacity:ge?.6:1},disabled:ge,className:"census-submit-btn",children:ge?"Submitting...":"Submit"})]}):jsxs("button",{onClick:()=>x(true),style:y.newRequestButton,className:"census-new-request-btn",children:[jsx(Mo,{}),"New Request"]}),to=()=>R?jt?jsxs("div",{style:y.loading,children:[jsx(Ve,{}),jsx("span",{children:"Loading requests..."})]}):jsxs("div",{children:[eo(),nt.length===0?jsxs("div",{style:y.emptyState,children:[jsx("div",{style:y.emptyIcon,children:jsx(qo,{})}),jsx("h3",{style:y.emptyTitle,children:"No requests yet"}),jsx("p",{style:y.emptyText,children:"Submit your first request above."})]}):jsx("div",{children:nt.map(k=>{let N=vt[k.feedback_type]||vt.feedback,J=Ct[k.status]||Ct.new;return jsxs("div",{style:y.requestCard,children:[jsxs("div",{style:{...y.requestHeader,flexWrap:"wrap"},children:[jsx("span",{style:{...y.badge,color:N.color,backgroundColor:N.bg},children:N.label}),jsx("span",{style:{...y.badge,color:J.color,backgroundColor:J.bg},children:J.label}),k.feature_group&&jsx("span",{style:{...y.badge,color:k.feature_group.color||"#6b7280",backgroundColor:k.feature_group.color?`${k.feature_group.color}20`:"#f3f4f6",border:`1px solid ${k.feature_group.color||"#e5e7eb"}`},children:k.feature_group.name}),k.feature&&jsx("span",{style:{...y.badge,color:"#374151",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb"},children:k.feature.name})]}),jsx("p",{style:y.requestMessage,children:k.message||"No message provided"}),jsx("div",{style:y.requestMeta,children:jsx("span",{children:Po(k.created_at)})})]},k.id)})})]}):jsx("div",{style:y.emptyState,children:jsx("p",{style:y.emptyText,children:"Please sign in to view your requests."})});return jsxs("div",{style:y.container,className:`census-hc ${i||""}`,children:[jsx("style",{children:P}),e.length>1&&jsx("div",{style:y.tabs,children:e.map(k=>jsx("button",{onClick:()=>p(k),style:{...y.tab,...c===k?y.tabActive:{}},className:c!==k?"census-tab":void 0,children:Xt[k]},k))}),jsxs("div",{style:y.grid,children:[jsxs("aside",{style:y.sidebar,children:[r&&c==="articles"&&jsxs("div",{style:y.searchContainer,children:[jsx("div",{style:y.searchIcon,children:jsx(Bo,{})}),jsx("input",{ref:S,type:"text",placeholder:"Search...",value:l,onChange:k=>s(k.target.value),style:y.searchInput,className:"census-search-input"})]}),c==="articles"&&st.length>0&&jsxs("nav",{children:[jsx("h3",{style:y.sectionTitle,children:"Features"}),jsxs("ul",{style:y.navList,children:[jsx("li",{children:jsx("button",{onClick:()=>C(null),style:{...y.navItem,...u?{}:y.navItemActive},className:u?"census-nav-item":void 0,children:"All Articles"})}),st.map(k=>jsxs("li",{children:[jsxs("button",{onClick:()=>Yt(k.id),style:y.navItem,className:"census-nav-item",children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsx(Ao,{}),k.name]}),g.has(k.id)?jsx(Lo,{}):jsx(wt,{})]}),g.has(k.id)&&k.features.length>0&&jsx("ul",{style:y.subNav,children:k.features.map(N=>jsx("li",{children:jsx("button",{onClick:()=>C(N.id),style:{...y.navItem,padding:"6px 12px",fontSize:"13px",...u===N.id?y.navItemActive:{}},className:u!==N.id?"census-nav-item":void 0,children:N.name})},N.id))})]},k.id))]})]})]}),jsxs("main",{style:y.main,children:[c==="articles"&&Zt(),c==="requests"&&to()]})]})]})}var Rt={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},Uo={tooltip:"Points to a specific element with an arrow",modal:"Centered overlay that grabs attention",slideout:"Slides in from the side of the screen",hotspot:"Pulsing beacon that expands on click",banner:"Top or bottom bar announcement",embedded:"Inline content injected into the page"},Ho=[{value:"auto",label:"Auto"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],Wo=[{value:"button",label:"Button click"},{value:"click",label:"Click anywhere"},{value:"delay",label:"After delay"},{value:"form-submit",label:"Form submit"}];function Et({step:e,onUpdate:t,onSelectElement:o,isSelectingElement:r}){let[i,n]=useState(false),[c,p]=useState(e.step_type),[l,s]=useState(e.rich_content?.title||e.title||""),[a,d]=useState(e.rich_content?.body||e.content||""),[g,f]=useState(e.tooltip_position||e.display_config?.position||"auto"),[u,C]=useState(e.selector_strategy?.css||""),[G,x]=useState(e.display_config?.backdrop!==false),[E,v]=useState(e.advance_config?.trigger||"button"),[w,T]=useState(e.advance_config?.delay||3e3),S=useCallback(async()=>{n(true);try{let m=u?{css:u}:void 0,A={title:l||void 0,body:a||void 0},D={position:g!=="auto"?g:void 0,backdrop:G},y={trigger:E,delay:E==="delay"?w:void 0};await t(e.id,{stepType:c,selectorStrategy:m,richContent:A,displayConfig:D,advanceConfig:y,tooltipPosition:g});}finally{n(false);}},[e.id,c,l,a,g,u,G,E,w,t]),I=c==="tooltip"||c==="hotspot";return jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsx("span",{style:{fontWeight:500},children:"Edit Step"}),jsx("button",{onClick:S,disabled:i,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:i?"wait":"pointer",opacity:i?.7:1},children:i?"Saving...":"Save Changes"})]}),jsxs("div",{style:{flex:1,overflow:"auto",padding:"16px"},children:[jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Step Type"}),jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px"},children:Object.keys(Rt).map(m=>jsxs("button",{onClick:()=>p(m),style:{padding:"10px",border:`2px solid ${c===m?"#2563eb":"#e5e7eb"}`,borderRadius:"6px",backgroundColor:c===m?"#eff6ff":"white",cursor:"pointer",textAlign:"left"},children:[jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:Rt[m]}),jsx("div",{style:{fontSize:"11px",color:"#6b7280",marginTop:"2px"},children:Uo[m]})]},m))})]}),I&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Target Element"}),jsxs("div",{style:{display:"flex",gap:"8px"},children:[jsx("input",{type:"text",value:u,onChange:m=>C(m.target.value),placeholder:"CSS selector (e.g., #my-button)",style:{flex:1,padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",fontFamily:"monospace"}}),jsx("button",{onClick:o,disabled:r,style:{padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:r?"#f3f4f6":"white",cursor:r?"wait":"pointer"},children:r?"Selecting...":"Select"})]}),jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px"},children:'Click "Select" to pick an element on the page, or enter a CSS selector manually'})]}),jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Title"}),jsx("input",{type:"text",value:l,onChange:m=>s(m.target.value),placeholder:"Enter step title",style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]}),jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Content"}),jsx("textarea",{value:a,onChange:m=>d(m.target.value),placeholder:"Enter step content (HTML supported)",rows:4,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",resize:"vertical",fontFamily:"inherit"}})]}),(c==="tooltip"||c==="hotspot")&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Position"}),jsx("select",{value:g,onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Ho.map(m=>jsx("option",{value:m.value,children:m.label},m.value))})]}),c==="banner"&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Banner Position"}),jsxs("select",{value:g==="bottom"?"bottom":"top",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsx("option",{value:"top",children:"Top"}),jsx("option",{value:"bottom",children:"Bottom"})]})]}),c==="slideout"&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Slideout Side"}),jsxs("select",{value:g==="left"?"left":"right",onChange:m=>f(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:[jsx("option",{value:"right",children:"Right"}),jsx("option",{value:"left",children:"Left"})]})]}),(c==="tooltip"||c==="modal")&&jsxs("div",{style:{marginBottom:"20px"},children:[jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[jsx("input",{type:"checkbox",checked:G,onChange:m=>x(m.target.checked),style:{width:"16px",height:"16px"}}),jsx("span",{style:{fontSize:"13px",fontWeight:500},children:"Show backdrop overlay"})]}),jsx("p",{style:{fontSize:"11px",color:"#6b7280",marginTop:"4px",marginLeft:"24px"},children:"Dims the background to focus attention on the step"})]}),jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Advance When"}),jsx("select",{value:E,onChange:m=>v(m.target.value),style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white"},children:Wo.map(m=>jsx("option",{value:m.value,children:m.label},m.value))})]}),E==="delay"&&jsxs("div",{style:{marginBottom:"20px"},children:[jsx("label",{style:{display:"block",marginBottom:"6px",fontSize:"13px",fontWeight:500},children:"Delay (seconds)"}),jsx("input",{type:"number",value:w/1e3,onChange:m=>T(Number(m.target.value)*1e3),min:1,max:60,style:{width:"100%",padding:"8px 12px",fontSize:"13px",border:"1px solid #d1d5db",borderRadius:"6px"}})]})]})]})}function Vo(e){let t={},o=e.getAttribute("data-testid");if(o)return t.testId=o,t.css=`[data-testid="${o}"]`,t;if(e.id)return t.css=`#${CSS.escape(e.id)}`,t;let r=[],i=e,n=0,c=5;for(;i&&i!==document.body&&n<c;){let l=i.tagName.toLowerCase(),s=Array.from(i.classList).filter(g=>!g.startsWith("hover")&&!g.startsWith("focus")&&!g.startsWith("active")).slice(0,2);s.length>0&&(l+="."+s.map(g=>CSS.escape(g)).join("."));let a=i.parentElement;if(a){let g=Array.from(a.children).filter(f=>f.tagName===i.tagName);if(g.length>1){let f=g.indexOf(i)+1;l+=`:nth-of-type(${f})`;}}r.unshift(l);let d=r.join(" > ");try{if(document.querySelectorAll(d).length===1){t.css=d;break}}catch{}i=i.parentElement,n++;}!t.css&&r.length>0&&(t.css=r.join(" > "));let p=e.textContent?.trim();return p&&p.length<100&&p.length>2&&(t.text=p.slice(0,50)),t}function Ko(e){let t=0;if(e.css)try{t=document.querySelectorAll(e.css).length;}catch{}return e.testId&&(t=document.querySelectorAll(`[data-testid="${e.testId}"]`).length),{isUnique:t===1,count:t}}function Gt({isActive:e,onSelect:t,onCancel:o,ignoreSelector:r="[data-census-builder]",zIndex:i=99999}){let[n,c]=useState(null),[p,l]=useState(null),[s,a]=useState(null),d=useRef(null),g=useCallback(()=>{if(!n){l(null);return}l(n.getBoundingClientRect());},[n]);useEffect(()=>{if(!e)return;let C=x=>{let v=document.elementsFromPoint(x.clientX,x.clientY).find(w=>!(d.current?.contains(w)||r&&w.closest(r)||w===document.body||w===document.documentElement));v!==n&&(c(v||null),a(v?Vo(v):null));},G=()=>{g();};return document.addEventListener("mousemove",C,true),window.addEventListener("scroll",G,true),window.addEventListener("resize",G),()=>{document.removeEventListener("mousemove",C,true),window.removeEventListener("scroll",G,true),window.removeEventListener("resize",G);}},[e,n,r,g]),useEffect(()=>{g();},[n,g]);let f=useCallback(C=>{C.preventDefault(),C.stopPropagation(),n&&s&&t(s,n);},[n,s,t]);if(useEffect(()=>{if(!e)return;let C=G=>{G.key==="Escape"&&o();};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,o]),!e)return null;let u=s?Ko(s):null;return jsxs("div",{ref:d,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:i,cursor:"crosshair"},onClick:f,children:[p&&jsx("div",{style:{position:"fixed",top:p.top,left:p.left,width:p.width,height:p.height,border:"2px solid #2563eb",borderRadius:"4px",backgroundColor:"rgba(37, 99, 235, 0.1)",pointerEvents:"none",transition:"all 0.1s ease-out"}}),p&&s&&jsxs("div",{style:{position:"fixed",top:Math.max(8,p.top-40),left:p.left,padding:"6px 10px",backgroundColor:"#1f2937",color:"white",fontSize:"12px",fontFamily:"monospace",borderRadius:"4px",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},children:[jsx("span",{style:{color:"#9ca3af"},children:s.testId?"data-testid: ":""}),s.testId||s.css,u&&jsxs("span",{style:{marginLeft:"8px",color:u.isUnique?"#4ade80":"#fbbf24"},children:["(",u.count," match",u.count!==1?"es":"",")"]})]}),jsxs("div",{style:{position:"fixed",bottom:0,left:0,right:0,padding:"12px 20px",backgroundColor:"#1f2937",color:"white",display:"flex",alignItems:"center",justifyContent:"space-between",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:"14px"},children:[jsxs("span",{children:["Click on any element to select it, or press ",jsx("kbd",{style:{padding:"2px 6px",backgroundColor:"#374151",borderRadius:"4px",marginLeft:"4px",marginRight:"4px"},children:"Esc"})," to cancel"]}),jsx("button",{onClick:C=>{C.stopPropagation(),o();},style:{padding:"6px 12px",border:"1px solid #4b5563",borderRadius:"4px",backgroundColor:"transparent",color:"white",cursor:"pointer"},children:"Cancel"})]})]})}function Xo({isOpen:e,onClose:t,guideId:o,onSave:r,onPublish:i,trigger:n,className:c}){let[p,l]=useState(false),s=e??p,{guide:a,steps:d,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:G,loadGuide:x,updateGuide:E,publishGuide:v,addStep:w,updateStep:T,deleteStep:S,moveStepUp:I,moveStepDown:m,setSelectedStepId:A,reset:D}=$e(),y=useCallback(async()=>{l(true),o&&await x(o);},[o,x]),P=useCallback(()=>{l(false),D(),t?.();},[D,t]),R=useCallback(async()=>{if(a)try{await E({}),r?.(a);}catch{}},[a,E,r]),h=useCallback(async()=>{if(a)try{let q=await v();i?.(q);}catch{}},[a,v,i]),U=useCallback(async(q="tooltip")=>{try{await w({stepType:q,richContent:{title:"New Step",body:"Click to edit..."}});}catch{}},[w]);return n&&e===void 0?jsxs(Fragment,{children:[jsx("span",{onClick:y,children:n}),s&&jsx(It,{guide:a,steps:d,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:G,onClose:P,onSave:R,onPublish:h,onAddStep:U,onSelectStep:A,onUpdateStep:T,onDeleteStep:S,onMoveStepUp:I,onMoveStepDown:m,className:c})]}):s?jsx(It,{guide:a,steps:d,selectedStep:g,selectedStepId:f,isLoading:u,isSaving:C,error:G,onClose:P,onSave:R,onPublish:h,onAddStep:U,onSelectStep:A,onUpdateStep:T,onDeleteStep:S,onMoveStepUp:I,onMoveStepDown:m,className:c}):null}function It({guide:e,steps:t,selectedStep:o,selectedStepId:r,isLoading:i,isSaving:n,error:c,onClose:p,onSave:l,onPublish:s,onAddStep:a,onSelectStep:d,onUpdateStep:g,onDeleteStep:f,onMoveStepUp:u,onMoveStepDown:C,className:G}){let[x,E]=useState(false),v={tooltip:"Tooltip",modal:"Modal",slideout:"Slideout",hotspot:"Hotspot",banner:"Banner",embedded:"Embedded"},w=useCallback((T,S)=>{o&&g(o.id,{selectorStrategy:T}),E(false);},[o,g]);return jsxs(Fragment,{children:[jsx(Gt,{isActive:x,onSelect:w,onCancel:()=>E(false),ignoreSelector:"[data-census-builder]"}),jsxs("div",{className:G,"data-census-builder":true,style:{position:"fixed",inset:0,zIndex:9999,display:"flex",flexDirection:"column",backgroundColor:"#f8f9fa",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",backgroundColor:"white",borderBottom:"1px solid #e5e7eb"},children:[jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[jsx("button",{onClick:p,style:{padding:"8px 12px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:"pointer"},children:"Close"}),jsx("h1",{style:{margin:0,fontSize:"18px",fontWeight:600},children:e?e.name:"Guide Builder"}),e?.status&&jsx("span",{style:{padding:"2px 8px",fontSize:"12px",borderRadius:"4px",backgroundColor:e.status==="published"?"#dcfce7":"#fef3c7",color:e.status==="published"?"#166534":"#92400e"},children:e.status})]}),jsxs("div",{style:{display:"flex",gap:"8px"},children:[c&&jsx("span",{style:{color:"#dc2626",fontSize:"14px"},children:c.message}),jsx("button",{onClick:l,disabled:n||!e,style:{padding:"8px 16px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",cursor:n?"wait":"pointer",opacity:n?.5:1},children:n?"Saving...":"Save"}),jsx("button",{onClick:s,disabled:n||!e||e.status==="published",style:{padding:"8px 16px",border:"none",borderRadius:"6px",backgroundColor:"#2563eb",color:"white",cursor:n?"wait":"pointer",opacity:n||e?.status==="published"?.5:1},children:"Publish"})]})]}),jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[jsxs("aside",{style:{width:"280px",backgroundColor:"white",borderRight:"1px solid #e5e7eb",display:"flex",flexDirection:"column"},children:[jsxs("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("span",{style:{fontWeight:500},children:["Steps (",t.length,")"]}),jsx("button",{onClick:()=>a("tooltip"),disabled:!e,style:{padding:"6px 12px",fontSize:"13px",border:"none",borderRadius:"4px",backgroundColor:"#2563eb",color:"white",cursor:e?"pointer":"not-allowed",opacity:e?1:.5},children:"+ Add Step"})]}),jsx("div",{style:{flex:1,overflow:"auto",padding:"8px"},children:i?jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:"Loading..."}):t.length===0?jsx("div",{style:{padding:"20px",textAlign:"center",color:"#6b7280"},children:'No steps yet. Click "Add Step" to get started.'}):t.map((T,S)=>jsxs("div",{onClick:()=>d(T.id),style:{padding:"12px",marginBottom:"4px",borderRadius:"6px",backgroundColor:r===T.id?"#eff6ff":"white",border:`1px solid ${r===T.id?"#3b82f6":"#e5e7eb"}`,cursor:"pointer"},children:[jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[jsxs("span",{style:{fontWeight:500,fontSize:"14px"},children:[S+1,". ",v[T.step_type]]}),jsxs("div",{style:{display:"flex",gap:"4px"},children:[jsx("button",{onClick:I=>{I.stopPropagation(),u(T.id);},disabled:S===0,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:S===0?"not-allowed":"pointer",opacity:S===0?.3:1},children:"Up"}),jsx("button",{onClick:I=>{I.stopPropagation(),C(T.id);},disabled:S===t.length-1,style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #d1d5db",borderRadius:"3px",backgroundColor:"white",cursor:S===t.length-1?"not-allowed":"pointer",opacity:S===t.length-1?.3:1},children:"Down"}),jsx("button",{onClick:I=>{I.stopPropagation(),confirm("Delete this step?")&&f(T.id);},style:{padding:"2px 6px",fontSize:"12px",border:"1px solid #fecaca",borderRadius:"3px",backgroundColor:"#fef2f2",color:"#dc2626",cursor:"pointer"},children:"Delete"})]})]}),jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"#6b7280"},children:T.rich_content?.title||T.title||"Untitled"})]},T.id))})]}),jsxs("main",{style:{flex:1,display:"flex",flexDirection:"column",backgroundColor:"#f3f4f6"},children:[jsx("div",{style:{padding:"16px",borderBottom:"1px solid #e5e7eb",backgroundColor:"white"},children:jsx("span",{style:{fontWeight:500},children:"Preview"})}),jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"#6b7280"},children:o?jsxs("div",{style:{padding:"24px",backgroundColor:"white",borderRadius:"8px",boxShadow:"0 4px 6px -1px rgb(0 0 0 / 0.1)",maxWidth:"400px",width:"100%"},children:[jsx("div",{style:{marginBottom:"12px"},children:jsx("span",{style:{padding:"4px 8px",fontSize:"11px",fontWeight:500,borderRadius:"4px",backgroundColor:"#f3f4f6",color:"#6b7280",textTransform:"uppercase"},children:v[o.step_type]})}),jsx("h3",{style:{margin:"0 0 8px",fontSize:"16px"},children:o.rich_content?.title||o.title||"Step Preview"}),jsx("p",{style:{margin:0,color:"#4b5563"},children:o.rich_content?.body||o.content||"No content"}),o.rich_content?.media&&jsx("div",{style:{marginTop:"12px"},children:o.rich_content.media.type==="image"&&jsx("img",{src:o.rich_content.media.url,alt:o.rich_content.media.alt||"",style:{maxWidth:"100%",borderRadius:"4px"}})}),o.rich_content?.buttons&&o.rich_content.buttons.length>0&&jsx("div",{style:{marginTop:"16px",display:"flex",gap:"8px"},children:o.rich_content.buttons.map((T,S)=>jsx("span",{style:{padding:"6px 12px",fontSize:"13px",borderRadius:"4px",backgroundColor:T.style==="primary"?"#2563eb":"#f3f4f6",color:T.style==="primary"?"white":"#374151"},children:T.label},S))}),o.selector_strategy?.css&&jsxs("div",{style:{marginTop:"16px",padding:"8px",backgroundColor:"#f9fafb",borderRadius:"4px",fontSize:"11px",fontFamily:"monospace",color:"#6b7280"},children:["Target: ",o.selector_strategy.css]})]}):jsx("p",{children:"Select a step to preview"})})]}),jsx("aside",{style:{width:"360px",backgroundColor:"white",borderLeft:"1px solid #e5e7eb",display:"flex",flexDirection:"column",overflow:"hidden"},children:o?jsx(Et,{step:o,onUpdate:g,onSelectElement:()=>E(true),isSelectingElement:x}):jsx("div",{style:{padding:"16px"},children:jsx("p",{style:{color:"#6b7280"},children:"Select a step to edit its settings"})})})]})]})]})}function Qe(e){let t=e.getBoundingClientRect();return {top:t.top+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX,bottom:t.bottom+window.scrollY,width:t.width,height:t.height}}function Je(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function Ye(e,t,o,r,i){let n=Je(),{scrollX:c,scrollY:p,width:l,height:s}=n;switch(r){case "top":return e.top-p-o-i>0&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "bottom":return e.bottom-p+o+i<s&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "left":return e.left-c-t-i>0&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;case "right":return e.right-c+t+i<l&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;default:return true}}function Yo(e,t,o,r){let i=["bottom","top","right","left"];for(let n of i)if(Ye(e,t,o,n,r))return n;return "bottom"}function Ie(e,t,o,r){let{preferredPosition:i,offset:n={x:0,y:0},containerPadding:c=10,arrowSize:p=8}=r,l=Qe(e),s=Je(),a=i;if(i==="auto")a=Yo(l,t,o,c);else if(!Ye(l,t,o,i,c)){let S={top:"bottom",bottom:"top",left:"right",right:"left"}[i];S&&Ye(l,t,o,S,c)&&(a=S);}let d=0,g=0,f={},u=p+4;switch(a){case "top":d=l.top-o-u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:o,transform:"rotate(180deg)"};break;case "bottom":d=l.bottom+u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:-p};break;case "left":d=l.top+l.height/2-o/2+n.y,g=l.left-t-u+n.x,f={top:o/2-p/2,left:t,transform:"rotate(-90deg)"};break;case "right":d=l.top+l.height/2-o/2+n.y,g=l.right+u+n.x,f={top:o/2-p/2,left:-p,transform:"rotate(90deg)"};break}let C=s.scrollX+c,G=s.scrollX+s.width-t-c,x=s.scrollY+c,E=s.scrollY+s.height-o-c,v=g;g=Math.max(C,Math.min(G,g)),(a==="top"||a==="bottom")&&(f.left=(f.left||0)+(v-g));let w=d;return d=Math.max(x,Math.min(E,d)),(a==="left"||a==="right")&&(f.top=(f.top||0)+(w-d)),{top:d,left:g,placement:a,arrowPosition:f}}function Pe(e,t=100){let o=e.getBoundingClientRect(),r=Je(),i=o.top<t,n=o.bottom>r.height-t,c=o.left<t,p=o.right>r.width-t;(i||n||c||p)&&e.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});}function ce(e){if(!e)return null;if(e.css)try{let t=document.querySelector(e.css);if(t)return t}catch{}if(e.testId){let t=document.querySelector(`[data-testid="${e.testId}"]`);if(t)return t}if(e.xpath)try{let t=document.evaluate(e.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(t.singleNodeValue)return t.singleNodeValue}catch{}if(e.text){let t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),o;for(;o=t.nextNode();)if(o.textContent?.includes(e.text))return o.parentElement}return null}function Bt(e,t=8){let o=e.getBoundingClientRect(),r={top:o.top-t,left:o.left-t,right:o.right+t,bottom:o.bottom+t,width:o.width+t*2,height:o.height+t*2};return `polygon(
53
+ `;function tr({tabs:e=["articles","requests"],defaultTab:t="articles",tabLabels:o={},showSearch:r=true,className:i,theme:n="auto"}){let[c,p]=useState(t),[l,s]=useState(""),[a,d]=useState(null),[g,f]=useState(new Set),[u,w]=useState(null),[I,h]=useState(false),[E,C]=useState("feedback"),[S,_]=useState(""),v=useRef(null),[G,m]=useState(false);useEffect(()=>{if(n!=="auto")return;let k=()=>{let me=document.documentElement,mt=me.getAttribute("data-theme");if(mt==="dark")return true;if(mt==="light")return false;let io=me.classList.contains("dark")||me.style.colorScheme!==""||me.getAttribute("data-color-mode")!==null;return me.classList.contains("dark")?true:io?false:window.matchMedia("(prefers-color-scheme: dark)").matches};m(k());let N=window.matchMedia("(prefers-color-scheme: dark)"),J=()=>m(k());N.addEventListener("change",J);let gt=new MutationObserver(()=>m(k()));return gt.observe(document.documentElement,{attributes:true,attributeFilter:["class","data-theme"]}),()=>{N.removeEventListener("change",J),gt.disconnect();}},[n]);let A=n==="dark"||n==="auto"&&G,B=A?zt.dark:zt.light,b=useMemo(()=>Zo(B),[B]),P=useMemo(()=>er(B),[B,A]),{isIdentified:R}=U(),{articles:x,isLoading:H}=xe({search:l||void 0}),{article:q,isLoading:V}=he(a?.slug||""),{requests:lt,isLoading:Xt,refetch:dt}=ve({limit:50}),{featureGroups:ct,isLoading:Yt}=Oe(),{submitFeedback:pt,isSubmitting:ge,isSuccess:Qt,reset:ut}=ye(),Jt={...$o,...o};useEffect(()=>{let k=N=>{(N.metaKey||N.ctrlKey)&&N.key==="k"&&(N.preventDefault(),v.current?.focus());};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[]);let Zt=k=>{f(N=>{let J=new Set(N);return J.has(k)?J.delete(k):J.add(k),J});},ft=useMemo(()=>x.filter(k=>!u||k.feature_id===u),[x,u]),eo=useCallback(async k=>{if(k.preventDefault(),!(!S.trim()||ge))try{await pt({type:E,message:S}),_(""),h(!1),setTimeout(()=>{dt(),ut();},500);}catch{}},[E,S,ge,pt,dt,ut]),to=()=>V||!q?jsxs("div",{style:b.loading,children:[jsx(Ze,{}),jsx("span",{children:"Loading article..."})]}):jsxs("div",{style:b.articleDetail,children:[jsxs("button",{onClick:()=>d(null),style:b.backButton,className:"census-back-btn",children:[jsx(Ko,{}),"Back to articles"]}),jsx("h1",{style:b.articleDetailTitle,children:q.title}),q.read_time_minutes&&jsxs("div",{style:b.articleDetailMeta,children:[jsx(Xo,{}),q.read_time_minutes," min read"]}),q.content_html?jsx("div",{style:b.articleDetailContent,dangerouslySetInnerHTML:{__html:q.content_html}}):jsx("p",{style:{...b.articleDetailContent,color:"#6b7280"},children:"No content available."})]}),oo=()=>a?to():H||Yt?jsxs("div",{style:b.loading,children:[jsx(Ze,{}),jsx("span",{children:"Loading..."})]}):ft.length===0?jsxs("div",{style:b.emptyState,children:[jsx("div",{style:b.emptyIcon,children:jsx(Bt,{})}),jsx("h3",{style:b.emptyTitle,children:"No articles found"}),jsx("p",{style:b.emptyText,children:l?`No results for "${l}"`:"No documentation articles available yet."})]}):jsx("div",{style:b.articleGrid,children:ft.map(k=>jsxs("button",{onClick:()=>d(k),style:b.articleCard,className:"census-article-card",children:[jsx("div",{style:b.articleIcon,className:"census-article-icon",children:jsx(Bt,{})}),jsxs("div",{style:b.articleContent,children:[jsx("h3",{style:b.articleTitle,children:k.title}),k.seo_description&&jsx("p",{style:b.articleDesc,children:k.seo_description}),k.read_time_minutes&&jsxs("p",{style:b.articleMeta,children:[k.read_time_minutes," min read"]})]}),jsx("span",{style:b.articleChevron,className:"census-article-chevron",children:jsx(Lt,{})})]},k.id))}),ro=()=>Qt?jsx("div",{style:b.successMessage,children:"Thanks for your feedback! It has been submitted."}):I?jsxs("form",{onSubmit:eo,style:b.form,children:[jsxs("div",{style:b.formHeader,children:[jsx("p",{style:b.formTitle,children:"Submit a request"}),jsx("button",{type:"button",onClick:()=>h(false),style:{background:"none",border:"none",cursor:"pointer",color:"#6b7280",fontSize:"18px"},children:"\xD7"})]}),jsx("div",{style:b.typeSelector,children:Wo.map(k=>jsx("button",{type:"button",onClick:()=>C(k.value),style:{...b.typeButton,...E===k.value?b.typeButtonActive:{}},children:k.label},k.value))}),jsx("textarea",{value:S,onChange:k=>_(k.target.value),placeholder:"Describe your request...",style:b.textarea,className:"census-textarea",required:true}),jsx("button",{type:"submit",style:{...b.submitButton,opacity:ge?.6:1},disabled:ge,className:"census-submit-btn",children:ge?"Submitting...":"Submit"})]}):jsxs("button",{onClick:()=>h(true),style:b.newRequestButton,className:"census-new-request-btn",children:[jsx(Jo,{}),"New Request"]}),no=()=>R?Xt?jsxs("div",{style:b.loading,children:[jsx(Ze,{}),jsx("span",{children:"Loading requests..."})]}):jsxs("div",{children:[ro(),lt.length===0?jsxs("div",{style:b.emptyState,children:[jsx("div",{style:b.emptyIcon,children:jsx(Qo,{})}),jsx("h3",{style:b.emptyTitle,children:"No requests yet"}),jsx("p",{style:b.emptyText,children:"Submit your first request above."})]}):jsx("div",{children:lt.map(k=>{let N=Pt[k.feedback_type]||Pt.feedback,J=_t[k.status]||_t.new;return jsxs("div",{style:b.requestCard,children:[jsxs("div",{style:{...b.requestHeader,flexWrap:"wrap"},children:[jsx("span",{style:{...b.badge,color:N.color,backgroundColor:N.bg},children:N.label}),jsx("span",{style:{...b.badge,color:J.color,backgroundColor:J.bg},children:J.label}),k.feature_group&&jsx("span",{style:{...b.badge,color:k.feature_group.color||"#6b7280",backgroundColor:k.feature_group.color?`${k.feature_group.color}20`:"#f3f4f6",border:`1px solid ${k.feature_group.color||"#e5e7eb"}`},children:k.feature_group.name}),k.feature&&jsx("span",{style:{...b.badge,color:"#374151",backgroundColor:"#f3f4f6",border:"1px solid #e5e7eb"},children:k.feature.name})]}),jsx("p",{style:b.requestMessage,children:k.message||"No message provided"}),jsx("div",{style:b.requestMeta,children:jsx("span",{children:Ho(k.created_at)})})]},k.id)})})]}):jsx("div",{style:b.emptyState,children:jsx("p",{style:b.emptyText,children:"Please sign in to view your requests."})});return jsxs("div",{style:b.container,className:`census-hc ${i||""}`,children:[jsx("style",{children:P}),e.length>1&&jsx("div",{style:b.tabs,children:e.map(k=>jsx("button",{onClick:()=>p(k),style:{...b.tab,...c===k?b.tabActive:{}},className:c!==k?"census-tab":void 0,children:Jt[k]},k))}),jsxs("div",{style:b.grid,children:[jsxs("aside",{style:b.sidebar,children:[r&&c==="articles"&&jsxs("div",{style:b.searchContainer,children:[jsx("div",{style:b.searchIcon,children:jsx(jo,{})}),jsx("input",{ref:v,type:"text",placeholder:"Search...",value:l,onChange:k=>s(k.target.value),style:b.searchInput,className:"census-search-input"})]}),c==="articles"&&ct.length>0&&jsxs("nav",{children:[jsx("h3",{style:b.sectionTitle,children:"Features"}),jsxs("ul",{style:b.navList,children:[jsx("li",{children:jsx("button",{onClick:()=>w(null),style:{...b.navItem,...u?{}:b.navItemActive},className:u?"census-nav-item":void 0,children:"All Articles"})}),ct.map(k=>jsxs("li",{children:[jsxs("button",{onClick:()=>Zt(k.id),style:b.navItem,className:"census-nav-item",children:[jsxs("span",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[jsx(Yo,{}),k.name]}),g.has(k.id)?jsx(Vo,{}):jsx(Lt,{})]}),g.has(k.id)&&k.features.length>0&&jsx("ul",{style:b.subNav,children:k.features.map(N=>jsx("li",{children:jsx("button",{onClick:()=>w(N.id),style:{...b.navItem,padding:"6px 12px",fontSize:"13px",...u===N.id?b.navItemActive:{}},className:u!==N.id?"census-nav-item":void 0,children:N.name})},N.id))})]},k.id))]})]})]}),jsxs("main",{style:b.main,children:[c==="articles"&&oo(),c==="requests"&&no()]})]})]})}function tt(e){let t=e.getBoundingClientRect();return {top:t.top+window.scrollY,left:t.left+window.scrollX,right:t.right+window.scrollX,bottom:t.bottom+window.scrollY,width:t.width,height:t.height}}function ot(){return {width:window.innerWidth,height:window.innerHeight,scrollX:window.scrollX,scrollY:window.scrollY}}function et(e,t,o,r,i){let n=ot(),{scrollX:c,scrollY:p,width:l,height:s}=n;switch(r){case "top":return e.top-p-o-i>0&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "bottom":return e.bottom-p+o+i<s&&e.left-c+e.width/2-t/2>0&&e.left-c+e.width/2+t/2<l;case "left":return e.left-c-t-i>0&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;case "right":return e.right-c+t+i<l&&e.top-p+e.height/2-o/2>0&&e.top-p+e.height/2+o/2<s;default:return true}}function or(e,t,o,r){let i=["bottom","top","right","left"];for(let n of i)if(et(e,t,o,n,r))return n;return "bottom"}function Te(e,t,o,r){let{preferredPosition:i,offset:n={x:0,y:0},containerPadding:c=10,arrowSize:p=8}=r,l=tt(e),s=ot(),a=i;if(i==="auto")a=or(l,t,o,c);else if(!et(l,t,o,i,c)){let v={top:"bottom",bottom:"top",left:"right",right:"left"}[i];v&&et(l,t,o,v,c)&&(a=v);}let d=0,g=0,f={},u=p+4;switch(a){case "top":d=l.top-o-u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:o,transform:"rotate(180deg)"};break;case "bottom":d=l.bottom+u+n.y,g=l.left+l.width/2-t/2+n.x,f={left:t/2-p/2,top:-p};break;case "left":d=l.top+l.height/2-o/2+n.y,g=l.left-t-u+n.x,f={top:o/2-p/2,left:t,transform:"rotate(-90deg)"};break;case "right":d=l.top+l.height/2-o/2+n.y,g=l.right+u+n.x,f={top:o/2-p/2,left:-p,transform:"rotate(90deg)"};break}let w=s.scrollX+c,I=s.scrollX+s.width-t-c,h=s.scrollY+c,E=s.scrollY+s.height-o-c,C=g;g=Math.max(w,Math.min(I,g)),(a==="top"||a==="bottom")&&(f.left=(f.left||0)+(C-g));let S=d;return d=Math.max(h,Math.min(E,d)),(a==="left"||a==="right")&&(f.top=(f.top||0)+(S-d)),{top:d,left:g,placement:a,arrowPosition:f}}function Pe(e,t=100){let o=e.getBoundingClientRect(),r=ot(),i=o.top<t,n=o.bottom>r.height-t,c=o.left<t,p=o.right>r.width-t;(i||n||c||p)&&e.scrollIntoView({behavior:"smooth",block:"center",inline:"center"});}function ce(e){if(!e)return null;if(e.css)try{let t=document.querySelector(e.css);if(t)return t}catch{}if(e.testId){let t=document.querySelector(`[data-testid="${e.testId}"]`);if(t)return t}if(e.xpath)try{let t=document.evaluate(e.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(t.singleNodeValue)return t.singleNodeValue}catch{}if(e.text){let t=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),o;for(;o=t.nextNode();)if(o.textContent?.includes(e.text))return o.parentElement}return null}function Ft(e,t=8){let o=e.getBoundingClientRect(),r={top:o.top-t,left:o.left-t,right:o.right+t,bottom:o.bottom+t,width:o.width+t*2,height:o.height+t*2};return `polygon(
54
54
  0 0,
55
55
  100% 0,
56
56
  100% 100%,
@@ -61,20 +61,20 @@ import {createContext,useState,useMemo,useEffect,useContext,useCallback,useRef}f
61
61
  ${r.right}px ${r.bottom}px,
62
62
  ${r.right}px ${r.top}px,
63
63
  ${r.left}px ${r.top}px
64
- )`}function re({visible:e,spotlightElement:t,spotlightPadding:o=8,onClick:r,dismissOnClick:i=false,zIndex:n=9998,opacity:c=.5}){let[p,l]=useState(),s=useCallback(()=>{l(t?Bt(t,o):void 0);},[t,o]);return useEffect(()=>{if(e)return s(),window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}},[e,s]),e?jsx("div",{onClick:d=>{i&&r&&r(),d.stopPropagation();},style:{position:"fixed",inset:0,zIndex:n,backgroundColor:`rgba(0, 0, 0, ${c})`,clipPath:p,transition:"clip-path 0.2s ease-out",cursor:i?"pointer":"default",pointerEvents:"auto"},"aria-hidden":"true"}):null}function X({buttons:e,currentStep:t,isLastStep:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:p="#2563eb"}){if(!e||e.length===0)return jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"16px"},children:[jsx("div",{children:t>0&&jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"},children:"Back"})}),jsx("button",{onClick:o?n:r,style:{padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"},children:o?"Done":"Next"})]});let l=a=>{switch(a.action){case "next":r();break;case "prev":i();break;case "dismiss":n();break;case "url":a.url&&window.open(a.url,"_blank","noopener,noreferrer");break;case "custom":a.customAction&&c&&c(a.customAction);break}},s=a=>{switch(a){case "primary":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"};case "text":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:"transparent",color:p,cursor:"pointer"};default:return {padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"}}};return jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px"},children:e.map((a,d)=>jsx("button",{onClick:()=>l(a),style:s(a.style),children:a.label},d))})}function Y({step:e,textColor:t="#1f2937",showTitle:o=true}){let r=e.rich_content,i=r?.title||e.title,n=r?.body||e.content;return jsxs("div",{children:[o&&i&&jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:600,color:t,lineHeight:1.4},children:i}),n&&jsx("div",{style:{fontSize:"14px",color:t,opacity:.9,lineHeight:1.5},dangerouslySetInnerHTML:n.includes("<")?{__html:or(n)}:void 0,children:n.includes("<")?null:n}),r?.media&&jsxs("div",{style:{marginTop:"12px"},children:[r.media.type==="image"&&jsx("img",{src:r.media.url,alt:r.media.alt||"",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}}),r.media.type==="video"&&jsx("video",{src:r.media.url,controls:true,style:{maxWidth:"100%",height:"auto",borderRadius:"4px"},children:"Your browser does not support the video tag."})]})]})}function or(e){let t=["p","br","b","i","strong","em","u","s","h1","h2","h3","h4","h5","h6","ul","ol","li","a","code","pre","blockquote","span","div"];if(typeof document>"u")return e.replace(/<[^>]*>/g,"");let o=document.createElement("div");return o.innerHTML=e,o.querySelectorAll("script").forEach(n=>n.remove()),o.querySelectorAll("*").forEach(n=>{if(!t.includes(n.tagName.toLowerCase())){let p=document.createTextNode(n.textContent||"");n.parentNode?.replaceChild(p,n);return}Array.from(n.attributes).forEach(p=>{let l=p.name.toLowerCase();if(l.startsWith("on")&&n.removeAttribute(p.name),l==="href"||l==="src"){let a=p.value.toLowerCase().trim();(a.startsWith("javascript:")||a.startsWith("data:"))&&n.removeAttribute(p.name);}["href","target","rel","class","style"].includes(l)||n.removeAttribute(p.name);}),n.tagName.toLowerCase()==="a"&&(n.setAttribute("rel","noopener noreferrer"),n.setAttribute("target","_blank"));}),o.innerHTML}function we({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=useRef(null),[d,g]=useState(null),[f,u]=useState(null),[C,G]=useState(false),x={...l,...e.style_config},E=x.backgroundColor||"white",v=x.textColor||"#1f2937",w=x.accentColor||"#2563eb",T=x.borderRadius||8;useEffect(()=>{let I=ce(e.selector_strategy);g(I),I&&Pe(I,120);},[e.selector_strategy]);let S=useCallback(()=>{if(!d||!a.current)return;let I=a.current.getBoundingClientRect(),m=Ie(d,I.width,I.height,{preferredPosition:e.tooltip_position||e.display_config?.position||"auto",offset:e.display_config?.offset,arrowSize:8});u(m),G(true);},[d,e.tooltip_position,e.display_config]);return useEffect(()=>{let I=setTimeout(S,10);return window.addEventListener("scroll",S,true),window.addEventListener("resize",S),()=>{clearTimeout(I),window.removeEventListener("scroll",S,true),window.removeEventListener("resize",S);}},[S]),d?jsxs(Fragment,{children:[jsx(re,{visible:e.display_config?.backdrop!==false,spotlightElement:d,spotlightPadding:e.display_config?.spotlightPadding||8,dismissOnClick:false}),jsxs("div",{ref:a,style:{position:"absolute",top:f?.top||0,left:f?.left||0,zIndex:s,padding:"16px 20px",backgroundColor:E,color:v,borderRadius:T,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:e.display_config?.width||320,fontFamily:"system-ui, -apple-system, sans-serif",opacity:C?1:0,transition:"opacity 0.15s ease-out"},children:[f&&jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${E}`,top:f.arrowPosition.top,left:f.arrowPosition.left,transform:f.arrowPosition.transform}}),jsx(Y,{step:e,textColor:v}),p&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:w})]})]}):jsxs(Fragment,{children:[jsx(re,{visible:true}),jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:s,padding:"24px",backgroundColor:E,color:v,borderRadius:T,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",maxWidth:"400px",width:"90%",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsx(Y,{step:e,textColor:v}),p&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:w})]})]})}function Be({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a={...l,...e.style_config},d=a.backgroundColor||"white",g=a.textColor||"#1f2937",f=a.accentColor||"#2563eb",u=a.borderRadius||12,C=e.display_config||{},G=C.width||480,x=C.position||"center",E=C.backdrop!==false;return useEffect(()=>{let w=T=>{T.key==="Escape"&&n();};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[n]),useEffect(()=>{let w=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=w;}},[]),jsxs(Fragment,{children:[jsx(re,{visible:true,onClick:E?n:void 0,dismissOnClick:E,opacity:.6}),jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-modal-title",style:{position:"fixed",...(()=>{switch(x){case "top":return {top:"10%",left:"50%",transform:"translateX(-50%)"};case "bottom":return {bottom:"10%",left:"50%",transform:"translateX(-50%)"};default:return {top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}})(),zIndex:s,width:"90%",maxWidth:G,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:d,color:g,borderRadius:u,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsx("button",{onClick:n,"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.15s"},onMouseEnter:w=>w.currentTarget.style.color="#6b7280",onMouseLeave:w=>w.currentTarget.style.color="#9ca3af",children:"\xD7"}),jsx(Y,{step:e,textColor:g}),p&&o>1&&jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:o}).map((w,T)=>jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:T===t?f:"#e5e7eb",transition:"background-color 0.15s"}},T))}),jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:f})]})]})}function Le({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let[a,d]=useState(true),g={...l,...e.style_config},f=g.backgroundColor||"white",u=g.textColor||"#1f2937",C=g.accentColor||"#2563eb",G=g.borderRadius||0,x=e.display_config||{},E=x.width||400,v=x.position==="left"?"left":"right",w=x.backdrop!==false;return useEffect(()=>{let S=setTimeout(()=>d(false),50);return ()=>clearTimeout(S)},[]),useEffect(()=>{let S=I=>{I.key==="Escape"&&n();};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]),jsxs(Fragment,{children:[w&&jsx(re,{visible:true,onClick:n,dismissOnClick:true,opacity:.4}),jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-slideout-title",style:(()=>{let S={position:"fixed",top:0,bottom:0,width:"90%",maxWidth:E,zIndex:s,backgroundColor:f,color:u,boxShadow:v==="right"?"-10px 0 30px -5px rgba(0, 0, 0, 0.1)":"10px 0 30px -5px rgba(0, 0, 0, 0.1)",fontFamily:"system-ui, -apple-system, sans-serif",overflow:"auto",transition:"transform 0.3s ease-out"};return v==="right"?{...S,right:0,borderTopLeftRadius:G,borderBottomLeftRadius:G,transform:a?"translateX(100%)":"translateX(0)"}:{...S,left:0,borderTopRightRadius:G,borderBottomRightRadius:G,transform:a?"translateX(-100%)":"translateX(0)"}})(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid #e5e7eb",position:"sticky",top:0,backgroundColor:f,zIndex:1},children:[jsx("h2",{id:"guide-slideout-title",style:{margin:0,fontSize:"18px",fontWeight:600,color:u},children:e.rich_content?.title||e.title||"Guide"}),jsx("button",{onClick:n,"aria-label":"Close",style:{width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),jsxs("div",{style:{padding:"20px"},children:[jsx(Y,{step:e,textColor:u,showTitle:false}),p&&o>1&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"16px"},children:["Step ",t+1," of ",o]})]}),jsx("div",{style:{padding:"16px 20px",borderTop:"1px solid #e5e7eb",position:"sticky",bottom:0,backgroundColor:f},children:jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:C})})]})]})}function ze({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=useRef(null),[d,g]=useState(null),[f,u]=useState(false),[C,G]=useState({top:0,left:0}),[x,E]=useState(null),v={...l,...e.style_config},w=v.backgroundColor||"white",T=v.textColor||"#1f2937",S=v.accentColor||"#2563eb",I=v.borderRadius||8,m=e.display_config||{};useEffect(()=>{let R=ce(e.selector_strategy);g(R),R&&Pe(R,120);},[e.selector_strategy]);let D=useCallback(()=>{if(!d)return;let R=Qe(d);G({top:R.top-8,left:R.right-8});},[d]),y=useCallback(()=>{if(!d||!a.current||!f)return;let R=a.current.getBoundingClientRect(),h=Ie(d,R.width,R.height,{preferredPosition:e.tooltip_position||"auto",offset:e.display_config?.offset,arrowSize:8});E(h);},[d,f,e.tooltip_position,e.display_config?.offset]);if(useEffect(()=>(D(),f&&setTimeout(y,10),window.addEventListener("scroll",D,true),window.addEventListener("resize",D),()=>{window.removeEventListener("scroll",D,true),window.removeEventListener("resize",D);}),[D,y,f]),useEffect(()=>{if(!f)return;let R=h=>{a.current&&!a.current.contains(h.target)&&u(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[f]),!d)return null;let P=`
64
+ )`}function re({visible:e,spotlightElement:t,spotlightPadding:o=8,onClick:r,dismissOnClick:i=false,zIndex:n=9998,opacity:c=.5}){let[p,l]=useState(),s=useCallback(()=>{l(t?Ft(t,o):void 0);},[t,o]);return useEffect(()=>{if(e)return s(),window.addEventListener("scroll",s,true),window.addEventListener("resize",s),()=>{window.removeEventListener("scroll",s,true),window.removeEventListener("resize",s);}},[e,s]),e?jsx("div",{onClick:d=>{i&&r&&r(),d.stopPropagation();},style:{position:"fixed",inset:0,zIndex:n,backgroundColor:`rgba(0, 0, 0, ${c})`,clipPath:p,transition:"clip-path 0.2s ease-out",cursor:i?"pointer":"default",pointerEvents:"auto"},"aria-hidden":"true"}):null}function Y({buttons:e,currentStep:t,isLastStep:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:p="#2563eb"}){if(!e||e.length===0)return jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"16px"},children:[jsx("div",{children:t>0&&jsx("button",{onClick:i,style:{padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"},children:"Back"})}),jsx("button",{onClick:o?n:r,style:{padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"},children:o?"Done":"Next"})]});let l=a=>{switch(a.action){case "next":r();break;case "prev":i();break;case "dismiss":n();break;case "url":a.url&&window.open(a.url,"_blank","noopener,noreferrer");break;case "custom":a.customAction&&c&&c(a.customAction);break}},s=a=>{switch(a){case "primary":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:p,color:"white",cursor:"pointer"};case "text":return {padding:"8px 16px",fontSize:"14px",border:"none",borderRadius:"6px",backgroundColor:"transparent",color:p,cursor:"pointer"};default:return {padding:"8px 16px",fontSize:"14px",border:"1px solid #d1d5db",borderRadius:"6px",backgroundColor:"white",color:"#374151",cursor:"pointer"}}};return jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px",marginTop:"16px"},children:e.map((a,d)=>jsx("button",{onClick:()=>l(a),style:s(a.style),children:a.label},d))})}function Q({step:e,textColor:t="#1f2937",showTitle:o=true}){let r=e.rich_content,i=r?.title||e.title,n=r?.body||e.content;return jsxs("div",{children:[o&&i&&jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"16px",fontWeight:600,color:t,lineHeight:1.4},children:i}),n&&jsx("div",{style:{fontSize:"14px",color:t,opacity:.9,lineHeight:1.5},dangerouslySetInnerHTML:n.includes("<")?{__html:lr(n)}:void 0,children:n.includes("<")?null:n}),r?.media&&jsxs("div",{style:{marginTop:"12px"},children:[r.media.type==="image"&&jsx("img",{src:r.media.url,alt:r.media.alt||"",style:{maxWidth:"100%",height:"auto",borderRadius:"4px"}}),r.media.type==="video"&&jsx("video",{src:r.media.url,controls:true,style:{maxWidth:"100%",height:"auto",borderRadius:"4px"},children:"Your browser does not support the video tag."})]})]})}function lr(e){let t=["p","br","b","i","strong","em","u","s","h1","h2","h3","h4","h5","h6","ul","ol","li","a","code","pre","blockquote","span","div"];if(typeof document>"u")return e.replace(/<[^>]*>/g,"");let o=document.createElement("div");return o.innerHTML=e,o.querySelectorAll("script").forEach(n=>n.remove()),o.querySelectorAll("*").forEach(n=>{if(!t.includes(n.tagName.toLowerCase())){let p=document.createTextNode(n.textContent||"");n.parentNode?.replaceChild(p,n);return}Array.from(n.attributes).forEach(p=>{let l=p.name.toLowerCase();if(l.startsWith("on")&&n.removeAttribute(p.name),l==="href"||l==="src"){let a=p.value.toLowerCase().trim();(a.startsWith("javascript:")||a.startsWith("data:"))&&n.removeAttribute(p.name);}["href","target","rel","class","style"].includes(l)||n.removeAttribute(p.name);}),n.tagName.toLowerCase()==="a"&&(n.setAttribute("rel","noopener noreferrer"),n.setAttribute("target","_blank"));}),o.innerHTML}function we({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=useRef(null),[d,g]=useState(null),[f,u]=useState(null),[w,I]=useState(false),h={...l,...e.style_config},E=h.backgroundColor||"white",C=h.textColor||"#1f2937",S=h.accentColor||"#2563eb",_=h.borderRadius||8;useEffect(()=>{let G=ce(e.selector_strategy);g(G),G&&Pe(G,120);},[e.selector_strategy]);let v=useCallback(()=>{if(!d||!a.current)return;let G=a.current.getBoundingClientRect(),m=Te(d,G.width,G.height,{preferredPosition:e.tooltip_position||e.display_config?.position||"auto",offset:e.display_config?.offset,arrowSize:8});u(m),I(true);},[d,e.tooltip_position,e.display_config]);return useEffect(()=>{let G=setTimeout(v,10);return window.addEventListener("scroll",v,true),window.addEventListener("resize",v),()=>{clearTimeout(G),window.removeEventListener("scroll",v,true),window.removeEventListener("resize",v);}},[v]),d?jsxs(Fragment,{children:[jsx(re,{visible:e.display_config?.backdrop!==false,spotlightElement:d,spotlightPadding:e.display_config?.spotlightPadding||8,dismissOnClick:false}),jsxs("div",{ref:a,style:{position:"absolute",top:f?.top||0,left:f?.left||0,zIndex:s,padding:"16px 20px",backgroundColor:E,color:C,borderRadius:_,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:e.display_config?.width||320,fontFamily:"system-ui, -apple-system, sans-serif",opacity:w?1:0,transition:"opacity 0.15s ease-out"},children:[f&&jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${E}`,top:f.arrowPosition.top,left:f.arrowPosition.left,transform:f.arrowPosition.transform}}),jsx(Q,{step:e,textColor:C}),p&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:S})]})]}):jsxs(Fragment,{children:[jsx(re,{visible:true}),jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:s,padding:"24px",backgroundColor:E,color:C,borderRadius:_,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",maxWidth:"400px",width:"90%",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsx(Q,{step:e,textColor:C}),p&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:S})]})]})}function Be({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a={...l,...e.style_config},d=a.backgroundColor||"white",g=a.textColor||"#1f2937",f=a.accentColor||"#2563eb",u=a.borderRadius||12,w=e.display_config||{},I=w.width||480,h=w.position||"center",E=w.backdrop!==false;return useEffect(()=>{let S=_=>{_.key==="Escape"&&n();};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[n]),useEffect(()=>{let S=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=S;}},[]),jsxs(Fragment,{children:[jsx(re,{visible:true,onClick:E?n:void 0,dismissOnClick:E,opacity:.6}),jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-modal-title",style:{position:"fixed",...(()=>{switch(h){case "top":return {top:"10%",left:"50%",transform:"translateX(-50%)"};case "bottom":return {bottom:"10%",left:"50%",transform:"translateX(-50%)"};default:return {top:"50%",left:"50%",transform:"translate(-50%, -50%)"}}})(),zIndex:s,width:"90%",maxWidth:I,maxHeight:"85vh",overflow:"auto",padding:"24px",backgroundColor:d,color:g,borderRadius:u,boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)",fontFamily:"system-ui, -apple-system, sans-serif"},children:[jsx("button",{onClick:n,"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.15s"},onMouseEnter:S=>S.currentTarget.style.color="#6b7280",onMouseLeave:S=>S.currentTarget.style.color="#9ca3af",children:"\xD7"}),jsx(Q,{step:e,textColor:g}),p&&o>1&&jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"16px"},children:Array.from({length:o}).map((S,_)=>jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",backgroundColor:_===t?f:"#e5e7eb",transition:"background-color 0.15s"}},_))}),jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:f})]})]})}function Le({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let[a,d]=useState(true),g={...l,...e.style_config},f=g.backgroundColor||"white",u=g.textColor||"#1f2937",w=g.accentColor||"#2563eb",I=g.borderRadius||0,h=e.display_config||{},E=h.width||400,C=h.position==="left"?"left":"right",S=h.backdrop!==false;return useEffect(()=>{let v=setTimeout(()=>d(false),50);return ()=>clearTimeout(v)},[]),useEffect(()=>{let v=G=>{G.key==="Escape"&&n();};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[n]),jsxs(Fragment,{children:[S&&jsx(re,{visible:true,onClick:n,dismissOnClick:true,opacity:.4}),jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"guide-slideout-title",style:(()=>{let v={position:"fixed",top:0,bottom:0,width:"90%",maxWidth:E,zIndex:s,backgroundColor:f,color:u,boxShadow:C==="right"?"-10px 0 30px -5px rgba(0, 0, 0, 0.1)":"10px 0 30px -5px rgba(0, 0, 0, 0.1)",fontFamily:"system-ui, -apple-system, sans-serif",overflow:"auto",transition:"transform 0.3s ease-out"};return C==="right"?{...v,right:0,borderTopLeftRadius:I,borderBottomLeftRadius:I,transform:a?"translateX(100%)":"translateX(0)"}:{...v,left:0,borderTopRightRadius:I,borderBottomRightRadius:I,transform:a?"translateX(-100%)":"translateX(0)"}})(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid #e5e7eb",position:"sticky",top:0,backgroundColor:f,zIndex:1},children:[jsx("h2",{id:"guide-slideout-title",style:{margin:0,fontSize:"18px",fontWeight:600,color:u},children:e.rich_content?.title||e.title||"Guide"}),jsx("button",{onClick:n,"aria-label":"Close",style:{width:"28px",height:"28px",border:"none",borderRadius:"50%",backgroundColor:"transparent",color:"#9ca3af",fontSize:"20px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]}),jsxs("div",{style:{padding:"20px"},children:[jsx(Q,{step:e,textColor:u,showTitle:false}),p&&o>1&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"16px"},children:["Step ",t+1," of ",o]})]}),jsx("div",{style:{padding:"16px 20px",borderTop:"1px solid #e5e7eb",position:"sticky",bottom:0,backgroundColor:f},children:jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:w})})]})]})}function Fe({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let a=useRef(null),[d,g]=useState(null),[f,u]=useState(false),[w,I]=useState({top:0,left:0}),[h,E]=useState(null),C={...l,...e.style_config},S=C.backgroundColor||"white",_=C.textColor||"#1f2937",v=C.accentColor||"#2563eb",G=C.borderRadius||8,m=e.display_config||{};useEffect(()=>{let R=ce(e.selector_strategy);g(R),R&&Pe(R,120);},[e.selector_strategy]);let B=useCallback(()=>{if(!d)return;let R=tt(d);I({top:R.top-8,left:R.right-8});},[d]),b=useCallback(()=>{if(!d||!a.current||!f)return;let R=a.current.getBoundingClientRect(),x=Te(d,R.width,R.height,{preferredPosition:e.tooltip_position||"auto",offset:e.display_config?.offset,arrowSize:8});E(x);},[d,f,e.tooltip_position,e.display_config?.offset]);if(useEffect(()=>(B(),f&&setTimeout(b,10),window.addEventListener("scroll",B,true),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,true),window.removeEventListener("resize",B);}),[B,b,f]),useEffect(()=>{if(!f)return;let R=x=>{a.current&&!a.current.contains(x.target)&&u(false);};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[f]),!d)return null;let P=`
65
65
  @keyframes census-hotspot-pulse {
66
66
  0% {
67
67
  transform: scale(1);
68
- box-shadow: 0 0 0 0 ${S}66;
68
+ box-shadow: 0 0 0 0 ${v}66;
69
69
  }
70
70
  70% {
71
71
  transform: scale(1.1);
72
- box-shadow: 0 0 0 10px ${S}00;
72
+ box-shadow: 0 0 0 10px ${v}00;
73
73
  }
74
74
  100% {
75
75
  transform: scale(1);
76
- box-shadow: 0 0 0 0 ${S}00;
76
+ box-shadow: 0 0 0 0 ${v}00;
77
77
  }
78
78
  }
79
- `;return jsxs(Fragment,{children:[jsx("style",{dangerouslySetInnerHTML:{__html:P}}),jsx("button",{onClick:()=>u(!f),"aria-label":"Show more information","aria-expanded":f,style:{position:"absolute",top:C.top,left:C.left,width:"24px",height:"24px",borderRadius:"50%",border:"none",backgroundColor:S,color:"white",cursor:"pointer",zIndex:s,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,animation:!f?"census-hotspot-pulse 2s infinite":"none",transition:"transform 0.15s"},children:"?"}),f&&jsxs("div",{ref:a,style:{position:"absolute",top:x?.top||C.top+30,left:x?.left||C.left-140,zIndex:s+1,padding:"16px 20px",backgroundColor:w,color:T,borderRadius:I,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:m.width||300,fontFamily:"system-ui, -apple-system, sans-serif"},children:[x&&jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${w}`,top:x.arrowPosition.top,left:x.arrowPosition.left,transform:x.arrowPosition.transform}}),jsx(Y,{step:e,textColor:T}),p&&o>1&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsx(X,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:()=>{u(false),r();},onPrev:()=>{u(false),i();},onDismiss:()=>{u(false),n();},onCustomAction:c,accentColor:S})]})]})}var Ae={info:{bg:"#eff6ff",text:"#1e40af",icon:"i"},warning:{bg:"#fef3c7",text:"#92400e",icon:"!"},success:{bg:"#dcfce7",text:"#166534",icon:"\u2713"},custom:{bg:"#2563eb",text:"white",icon:""}};function qe({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let [a,d]=useState(true),[g,f]=useState(true),u={...l,...e.style_config},G=(e.display_config||{}).bannerPosition||"top",x="custom",E=u.backgroundColor||Ae[x].bg,v=u.textColor||Ae[x].text;useEffect(()=>{let D=setTimeout(()=>d(false),50);return ()=>clearTimeout(D)},[]);let T=()=>{d(true),setTimeout(()=>{f(false),n();},200);};if(!g)return null;let S=e.rich_content,I=S?.title||e.title,m=S?.body||e.content,A=S?.buttons&&S.buttons.length>0;return jsx("div",{role:"alert",style:{position:"fixed",left:0,right:0,[G]:0,zIndex:s,padding:"12px 20px",backgroundColor:E,color:v,boxShadow:G==="top"?"0 4px 6px -1px rgba(0, 0, 0, 0.1)":"0 -4px 6px -1px rgba(0, 0, 0, 0.1)",fontFamily:"system-ui, -apple-system, sans-serif",transform:a?G==="top"?"translateY(-100%)":"translateY(100%)":"translateY(0)",transition:"transform 0.2s ease-out"},children:jsxs("div",{style:{maxWidth:"1200px",margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"16px"},children:[jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",gap:"12px"},children:[Ae[x].icon,jsxs("div",{style:{flex:1},children:[I&&jsx("strong",{style:{display:"block",marginBottom:m?"2px":0},children:I}),m&&jsx("span",{style:{opacity:.9,fontSize:"14px"},children:m})]}),p&&o>1&&jsxs("span",{style:{fontSize:"12px",opacity:.7,flexShrink:0},children:[t+1,"/",o]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[A?jsx(X,{buttons:S.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:T,onCustomAction:c,accentColor:"white"}):jsx(Fragment,{children:t<o-1?jsx("button",{onClick:r,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:v,cursor:"pointer"},children:"Next"}):jsx("button",{onClick:T,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:v,cursor:"pointer"},children:"Got it"})}),jsx("button",{onClick:T,"aria-label":"Dismiss",style:{width:"28px",height:"28px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:v,opacity:.7,fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]})]})})}var fr=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","canvas"];function gr(e){return !fr.includes(e.tagName.toLowerCase())}function rt({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l}){let[s,a]=useState(null),[d,g]=useState(false),f=useRef(null),u=useRef(null),C={...l,...e.style_config},x=(e.display_config||{}).embeddedPosition||"append",E=C.backgroundColor||"white",v=C.textColor||"#1f2937",w=C.accentColor||"#2563eb",T=C.borderRadius??8;if(useEffect(()=>{let I=ce(e.selector_strategy);I&&gr(I)?a(I):a(null);},[e.selector_strategy]),useEffect(()=>{if(!s)return;let I=document.createElement("div");return I.setAttribute("data-census-embedded","true"),f.current=I,x==="replace"?(u.current=s.innerHTML,s.innerHTML="",s.appendChild(I)):x==="prepend"?s.insertBefore(I,s.firstChild):s.appendChild(I),g(true),()=>{f.current&&f.current.remove(),x==="replace"&&u.current!==null&&s&&(s.innerHTML=u.current),f.current=null,u.current=null;}},[s,x]),!s||!d||!f.current)return null;let S=e.rich_content;return createPortal(jsxs("div",{role:"region","aria-label":"Guide content",style:{position:"relative",padding:"16px",backgroundColor:E,color:v,borderRadius:`${T}px`,border:"1px solid #e5e7eb",fontFamily:"system-ui, -apple-system, sans-serif",boxSizing:"border-box"},children:[jsx("button",{onClick:n,"aria-label":"Dismiss",style:{position:"absolute",top:"8px",right:"8px",width:"24px",height:"24px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:v,opacity:.5,fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:"\xD7"}),p&&o>1&&jsxs("div",{style:{fontSize:"12px",color:v,opacity:.6,marginBottom:"8px"},children:["Step ",t+1," of ",o]}),jsx(Y,{step:e,textColor:v}),jsx(X,{buttons:S?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:w})]}),f.current)}function br({guide:e,onComplete:t,onDismiss:o,onStepChange:r,onCustomAction:i,globalStyle:n,startStep:c=0,zIndex:p=9999}){let[l,s]=useState(c),[a,d]=useState(true),g=e.guide_steps||[],f=g.length,u=g[l];useEffect(()=>{r?.(l,f);},[l,f,r]);let C=useCallback(()=>{l<f-1?s(w=>w+1):(d(false),t?.(e));},[l,f,e,t]),G=useCallback(()=>{l>0&&s(w=>w-1);},[l]),x=useCallback(()=>{d(false),o?.(e,l);},[e,l,o]),E=useCallback(w=>{u&&i?.(w,u);},[u,i]);if(!a||!u||g.length===0)return null;let v={step:u,currentStep:l,totalSteps:f,onNext:C,onPrev:G,onDismiss:x,onCustomAction:E,showProgress:e.show_progress!==false,globalStyle:{...e.theme,...n},zIndex:p};switch(u.step_type){case "tooltip":return jsx(we,{...v});case "modal":return jsx(Be,{...v});case "slideout":return jsx(Le,{...v});case "hotspot":return jsx(ze,{...v});case "banner":return jsx(qe,{...v});case "embedded":return jsx(rt,{...v});default:return jsx(we,{...v})}}export{re as Backdrop,qe as BannerStep,so as CensusProvider,xo as FeedbackButton,Xo as GuideBuilder,br as GuideRenderer,Oo as HelpCenter,ze as HotspotStep,So as KnowledgeBase,Be as ModalStep,Eo as Requests,Le as SlideoutStep,X as StepButtons,Y as StepContent,we as TooltipStep,xe as useArticle,he as useArticles,ao as useCensus,O as useCensusContext,Oe as useFeatureGroups,ye as useFeedback,$e as useGuideBuilder,go as useGuideRenderer,fo as useGuides,lo as useIdentify,ve as useRequests,uo as useTrack};//# sourceMappingURL=index.js.map
79
+ `;return jsxs(Fragment,{children:[jsx("style",{dangerouslySetInnerHTML:{__html:P}}),jsx("button",{onClick:()=>u(!f),"aria-label":"Show more information","aria-expanded":f,style:{position:"absolute",top:w.top,left:w.left,width:"24px",height:"24px",borderRadius:"50%",border:"none",backgroundColor:v,color:"white",cursor:"pointer",zIndex:s,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,animation:!f?"census-hotspot-pulse 2s infinite":"none",transition:"transform 0.15s"},children:"?"}),f&&jsxs("div",{ref:a,style:{position:"absolute",top:h?.top||w.top+30,left:h?.left||w.left-140,zIndex:s+1,padding:"16px 20px",backgroundColor:S,color:_,borderRadius:G,boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1)",maxWidth:m.width||300,fontFamily:"system-ui, -apple-system, sans-serif"},children:[h&&jsx("div",{style:{position:"absolute",width:0,height:0,borderLeft:"8px solid transparent",borderRight:"8px solid transparent",borderBottom:`8px solid ${S}`,top:h.arrowPosition.top,left:h.arrowPosition.left,transform:h.arrowPosition.transform}}),jsx(Q,{step:e,textColor:_}),p&&o>1&&jsxs("div",{style:{fontSize:"12px",color:"#6b7280",marginTop:"8px"},children:["Step ",t+1," of ",o]}),jsx(Y,{buttons:e.rich_content?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:()=>{u(false),r();},onPrev:()=>{u(false),i();},onDismiss:()=>{u(false),n();},onCustomAction:c,accentColor:v})]})]})}var Ae={info:{bg:"#eff6ff",text:"#1e40af",icon:"i"},warning:{bg:"#fef3c7",text:"#92400e",icon:"!"},success:{bg:"#dcfce7",text:"#166534",icon:"\u2713"},custom:{bg:"#2563eb",text:"white",icon:""}};function Me({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l,zIndex:s=9999}){let [a,d]=useState(true),[g,f]=useState(true),u={...l,...e.style_config},I=(e.display_config||{}).bannerPosition||"top",h="custom",E=u.backgroundColor||Ae[h].bg,C=u.textColor||Ae[h].text;useEffect(()=>{let B=setTimeout(()=>d(false),50);return ()=>clearTimeout(B)},[]);let _=()=>{d(true),setTimeout(()=>{f(false),n();},200);};if(!g)return null;let v=e.rich_content,G=v?.title||e.title,m=v?.body||e.content,A=v?.buttons&&v.buttons.length>0;return jsx("div",{role:"alert",style:{position:"fixed",left:0,right:0,[I]:0,zIndex:s,padding:"12px 20px",backgroundColor:E,color:C,boxShadow:I==="top"?"0 4px 6px -1px rgba(0, 0, 0, 0.1)":"0 -4px 6px -1px rgba(0, 0, 0, 0.1)",fontFamily:"system-ui, -apple-system, sans-serif",transform:a?I==="top"?"translateY(-100%)":"translateY(100%)":"translateY(0)",transition:"transform 0.2s ease-out"},children:jsxs("div",{style:{maxWidth:"1200px",margin:"0 auto",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"16px"},children:[jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",gap:"12px"},children:[Ae[h].icon,jsxs("div",{style:{flex:1},children:[G&&jsx("strong",{style:{display:"block",marginBottom:m?"2px":0},children:G}),m&&jsx("span",{style:{opacity:.9,fontSize:"14px"},children:m})]}),p&&o>1&&jsxs("span",{style:{fontSize:"12px",opacity:.7,flexShrink:0},children:[t+1,"/",o]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},children:[A?jsx(Y,{buttons:v.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:_,onCustomAction:c,accentColor:"white"}):jsx(Fragment,{children:t<o-1?jsx("button",{onClick:r,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:C,cursor:"pointer"},children:"Next"}):jsx("button",{onClick:_,style:{padding:"6px 12px",fontSize:"14px",border:"none",borderRadius:"4px",backgroundColor:"rgba(255,255,255,0.2)",color:C,cursor:"pointer"},children:"Got it"})}),jsx("button",{onClick:_,"aria-label":"Dismiss",style:{width:"28px",height:"28px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:C,opacity:.7,fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:"\xD7"})]})]})})}var hr=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","canvas"];function vr(e){return !hr.includes(e.tagName.toLowerCase())}function at({step:e,currentStep:t,totalSteps:o,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,showProgress:p=true,globalStyle:l}){let[s,a]=useState(null),[d,g]=useState(false),f=useRef(null),u=useRef(null),w={...l,...e.style_config},h=(e.display_config||{}).embeddedPosition||"append",E=w.backgroundColor||"white",C=w.textColor||"#1f2937",S=w.accentColor||"#2563eb",_=w.borderRadius??8;if(useEffect(()=>{let G=ce(e.selector_strategy);G&&vr(G)?a(G):a(null);},[e.selector_strategy]),useEffect(()=>{if(!s)return;let G=document.createElement("div");return G.setAttribute("data-census-embedded","true"),f.current=G,h==="replace"?(u.current=s.innerHTML,s.innerHTML="",s.appendChild(G)):h==="prepend"?s.insertBefore(G,s.firstChild):s.appendChild(G),g(true),()=>{f.current&&f.current.remove(),h==="replace"&&u.current!==null&&s&&(s.innerHTML=u.current),f.current=null,u.current=null;}},[s,h]),!s||!d||!f.current)return null;let v=e.rich_content;return createPortal(jsxs("div",{role:"region","aria-label":"Guide content",style:{position:"relative",padding:"16px",backgroundColor:E,color:C,borderRadius:`${_}px`,border:"1px solid #e5e7eb",fontFamily:"system-ui, -apple-system, sans-serif",boxSizing:"border-box"},children:[jsx("button",{onClick:n,"aria-label":"Dismiss",style:{position:"absolute",top:"8px",right:"8px",width:"24px",height:"24px",border:"none",borderRadius:"4px",backgroundColor:"transparent",color:C,opacity:.5,fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:"\xD7"}),p&&o>1&&jsxs("div",{style:{fontSize:"12px",color:C,opacity:.6,marginBottom:"8px"},children:["Step ",t+1," of ",o]}),jsx(Q,{step:e,textColor:C}),jsx(Y,{buttons:v?.buttons,currentStep:t,totalSteps:o,isLastStep:t===o-1,onNext:r,onPrev:i,onDismiss:n,onCustomAction:c,accentColor:S})]}),f.current)}function Sr({guide:e,onComplete:t,onDismiss:o,onStepChange:r,onCustomAction:i,globalStyle:n,startStep:c=0,zIndex:p=9999}){let[l,s]=useState(c),[a,d]=useState(true),g=e.guide_steps||[],f=g.length,u=g[l];useEffect(()=>{r?.(l,f);},[l,f,r]);let w=useCallback(()=>{l<f-1?s(S=>S+1):(d(false),t?.(e));},[l,f,e,t]),I=useCallback(()=>{l>0&&s(S=>S-1);},[l]),h=useCallback(()=>{d(false),o?.(e,l);},[e,l,o]),E=useCallback(S=>{u&&i?.(S,u);},[u,i]);if(!a||!u||g.length===0)return null;let C={step:u,currentStep:l,totalSteps:f,onNext:w,onPrev:I,onDismiss:h,onCustomAction:E,showProgress:e.show_progress!==false,globalStyle:{...e.theme,...n},zIndex:p};switch(u.step_type){case "tooltip":return jsx(we,{...C});case "modal":return jsx(Be,{...C});case "slideout":return jsx(Le,{...C});case "hotspot":return jsx(Fe,{...C});case "banner":return jsx(Me,{...C});case "embedded":return jsx(at,{...C});default:return jsx(we,{...C})}}export{re as Backdrop,Me as BannerStep,Ve as BuilderModeController,ko as CensusProvider,Lo as FeedbackButton,je as GuideBuilder,Sr as GuideRenderer,tr as HelpCenter,Fe as HotspotStep,Ao as KnowledgeBase,Be as ModalStep,Oo as Requests,Le as SlideoutStep,Y as StepButtons,Q as StepContent,we as TooltipStep,he as useArticle,xe as useArticles,Ro as useCensus,U as useCensusContext,Oe as useFeatureGroups,ye as useFeedback,Ne as useGuideBuilder,po as useGuideRenderer,co as useGuides,Eo as useIdentify,ve as useRequests,lo as useTrack};//# sourceMappingURL=index.js.map
80
80
  //# sourceMappingURL=index.js.map